diff options
Diffstat (limited to 'src')
128 files changed, 1778 insertions, 1222 deletions
diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index 25befabbab..28836c7772 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -396,6 +396,12 @@ public: struct LanguageFeatures { LanguageFeatures() : flags(0) {} + static LanguageFeatures defaultFeatures() + { + LanguageFeatures features; + features.flags = 0xffffffff; // Enable all flags + return features; + } union { unsigned int flags; diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 57b612e90a..b19a510bf7 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -283,15 +283,8 @@ Document::Document(const QString &fileName) const QByteArray localFileName = fileName.toUtf8(); const StringLiteral *fileId = _control->stringLiteral(localFileName.constData(), localFileName.size()); - LanguageFeatures features; - features.qtEnabled = true; - features.qtMocRunEnabled = true; - features.qtKeywordsEnabled = true; - features.cxx11Enabled = true; - features.objCEnabled = true; - features.c99Enabled = true; _translationUnit = new TranslationUnit(_control, fileId); - _translationUnit->setLanguageFeatures(features); + _translationUnit->setLanguageFeatures(LanguageFeatures::defaultFeatures()); (void) _control->switchTranslationUnit(_translationUnit); } @@ -596,6 +589,19 @@ void Document::setUtf8Source(const QByteArray &source) _translationUnit->setSource(_source.constBegin(), _source.size()); } +LanguageFeatures Document::languageFeatures() const +{ + if (TranslationUnit *tu = translationUnit()) + return tu->languageFeatures(); + return LanguageFeatures::defaultFeatures(); +} + +void Document::setLanguageFeatures(LanguageFeatures features) +{ + if (TranslationUnit *tu = translationUnit()) + tu->setLanguageFeatures(features); +} + void Document::startSkippingBlocks(unsigned utf16charsOffset) { _skippedBlocks.append(Block(0, 0, utf16charsOffset, 0)); @@ -767,6 +773,7 @@ Document::Ptr Snapshot::preprocessedDocument(const QByteArray &source, newDoc->_lastModified = thisDocument->_lastModified; newDoc->_resolvedIncludes = thisDocument->_resolvedIncludes; newDoc->_unresolvedIncludes = thisDocument->_unresolvedIncludes; + newDoc->setLanguageFeatures(thisDocument->languageFeatures()); } FastPreprocessor pp(*this); @@ -788,6 +795,7 @@ Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode, newDoc->_unresolvedIncludes = thisDocument->_unresolvedIncludes; newDoc->_definedMacros = thisDocument->_definedMacros; newDoc->_macroUses = thisDocument->_macroUses; + newDoc->setLanguageFeatures(thisDocument->languageFeatures()); } newDoc->setUtf8Source(preprocessedCode); diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index ec2514894e..9d7b473e42 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -115,6 +115,9 @@ public: void setFingerprint(const QByteArray &fingerprint) { m_fingerprint = fingerprint; } + LanguageFeatures languageFeatures() const; + void setLanguageFeatures(LanguageFeatures features); + void startSkippingBlocks(unsigned utf16charsOffset); void stopSkippingBlocks(unsigned utf16charsOffset); diff --git a/src/libs/extensionsystem/invoker.cpp b/src/libs/extensionsystem/invoker.cpp index 88d5ce5c5d..d0b2d7a993 100644 --- a/src/libs/extensionsystem/invoker.cpp +++ b/src/libs/extensionsystem/invoker.cpp @@ -70,7 +70,7 @@ void InvokerBase::invoke(QObject *t, const char *slot) if (paramCount) sig.append(','); const char *type = arg[paramCount].name(); - sig.append(type, strlen(type)); + sig.append(type, int(strlen(type))); } sig.append(')'); sig.append('\0'); diff --git a/src/libs/ssh/sshbotanconversions_p.h b/src/libs/ssh/sshbotanconversions_p.h index fb9cfa83f1..d7f63cebcd 100644 --- a/src/libs/ssh/sshbotanconversions_p.h +++ b/src/libs/ssh/sshbotanconversions_p.h @@ -94,16 +94,20 @@ inline const char *botanSha1Name() { return "SHA-1"; } inline const char *botanHMacAlgoName(const QByteArray &rfcAlgoName) { - Q_ASSERT(rfcAlgoName == SshCapabilities::HMacSha1); - Q_UNUSED(rfcAlgoName); - return botanSha1Name(); + Q_ASSERT(rfcAlgoName == SshCapabilities::HMacSha1 + || rfcAlgoName == SshCapabilities::HMacSha256); + if (rfcAlgoName == SshCapabilities::HMacSha1) + return botanSha1Name(); + return "SHA-256"; } inline quint32 botanHMacKeyLen(const QByteArray &rfcAlgoName) { - Q_ASSERT(rfcAlgoName == SshCapabilities::HMacSha1); - Q_UNUSED(rfcAlgoName); - return 20; + Q_ASSERT(rfcAlgoName == SshCapabilities::HMacSha1 + || rfcAlgoName == SshCapabilities::HMacSha256); + if (rfcAlgoName == SshCapabilities::HMacSha1) + return 20; + return 32; } } // namespace Internal diff --git a/src/libs/ssh/sshcapabilities.cpp b/src/libs/ssh/sshcapabilities.cpp index 86e68c9f35..1d70d73a60 100644 --- a/src/libs/ssh/sshcapabilities.cpp +++ b/src/libs/ssh/sshcapabilities.cpp @@ -78,8 +78,10 @@ const QList<QByteArray> SshCapabilities::EncryptionAlgorithms const QByteArray SshCapabilities::HMacSha1("hmac-sha1"); const QByteArray SshCapabilities::HMacSha196("hmac-sha1-96"); +const QByteArray SshCapabilities::HMacSha256("hmac-sha2-256"); const QList<QByteArray> SshCapabilities::MacAlgorithms = QList<QByteArray>() /* << SshCapabilities::HMacSha196 */ + << SshCapabilities::HMacSha256 // Recommended as per RFC 6668 << SshCapabilities::HMacSha1; const QList<QByteArray> SshCapabilities::CompressionAlgorithms diff --git a/src/libs/ssh/sshcapabilities_p.h b/src/libs/ssh/sshcapabilities_p.h index 39b7dd0591..d0295fccd0 100644 --- a/src/libs/ssh/sshcapabilities_p.h +++ b/src/libs/ssh/sshcapabilities_p.h @@ -58,6 +58,7 @@ public: static const QByteArray HMacSha1; static const QByteArray HMacSha196; + static const QByteArray HMacSha256; static const QList<QByteArray> MacAlgorithms; static const QList<QByteArray> CompressionAlgorithms; diff --git a/src/libs/utils/mimetypes/mimeprovider.cpp b/src/libs/utils/mimetypes/mimeprovider.cpp index 8aad4fae07..a27cd11ea7 100644 --- a/src/libs/utils/mimetypes/mimeprovider.cpp +++ b/src/libs/utils/mimetypes/mimeprovider.cpp @@ -956,8 +956,5 @@ void MimeXMLProvider::addMagicMatcher(const MimeMagicRuleMatcher &matcher) void MimeXMLProvider::addFile(const QString &filePath) { m_additionalFiles.append(filePath); - if (m_loaded) { - m_allFiles.append(filePath); - load(filePath); - } // else: will be loaded in ensureLoaded() + m_loaded = false; // force reload to ensure correct load order for overridden mime types } diff --git a/src/libs/utils/projectintropage.ui b/src/libs/utils/projectintropage.ui index 946a5a1add..f0cc5aa3b1 100644 --- a/src/libs/utils/projectintropage.ui +++ b/src/libs/utils/projectintropage.ui @@ -49,6 +49,9 @@ <enum>QFrame::Raised</enum> </property> <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="nameLabel"> <property name="text"> diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp index c582000bcb..3013fac07d 100644 --- a/src/libs/utils/treemodel.cpp +++ b/src/libs/utils/treemodel.cpp @@ -705,6 +705,8 @@ void TreeItem::insertChild(int pos, TreeItem *item) m_model->endInsertRows(); } else { item->m_parent = this; + if (m_model) + item->propagateModel(m_model); m_children.insert(m_children.begin() + pos, item); } } diff --git a/src/plugins/analyzerbase/analyzermanager.cpp b/src/plugins/analyzerbase/analyzermanager.cpp index ee3d7a96d7..d8ed89bf87 100644 --- a/src/plugins/analyzerbase/analyzermanager.cpp +++ b/src/plugins/analyzerbase/analyzermanager.cpp @@ -153,14 +153,8 @@ public: void handleToolFinished(); void saveToolSettings(Id toolId); void loadToolSettings(Id toolId); - - // Convenience. - bool isActionRunnable(AnalyzerAction *action) const; - -public slots: void startTool(); void selectToolboxAction(int); - void selectMenuAction(); void modeChanged(IMode *mode); void resetLayout(); void updateRunActions(); @@ -424,20 +418,10 @@ bool AnalyzerManagerPrivate::showPromptDialog(const QString &title, const QStrin return messageBox.clickedStandardButton() == QDialogButtonBox::Yes; } -bool AnalyzerManagerPrivate::isActionRunnable(AnalyzerAction *action) const -{ - if (!action || m_isRunning) - return false; - if (action->startMode() == StartRemote) - return true; - - return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->runMode(), 0); -} - void AnalyzerManagerPrivate::startTool() { QTC_ASSERT(m_currentAction, return); - m_currentAction->toolStarter()(m_currentAction->startMode()); + m_currentAction->toolStarter()(); } void AnalyzerManagerPrivate::modeChanged(IMode *mode) @@ -472,15 +456,6 @@ void AnalyzerManagerPrivate::selectSavedTool() selectAction(m_actions.first()); } -void AnalyzerManagerPrivate::selectMenuAction() -{ - AnalyzerManager::showMode(); - AnalyzerAction *action = qobject_cast<AnalyzerAction *>(sender()); - QTC_ASSERT(action, return); - selectAction(action); - startTool(); -} - void AnalyzerManagerPrivate::selectToolboxAction(int index) { selectAction(m_actions[index]); @@ -540,7 +515,13 @@ void AnalyzerManagerPrivate::addAction(AnalyzerAction *action) m_actions.append(action); m_toolBox->addItem(action->text()); m_toolBox->blockSignals(blocked); - connect(action, &QAction::triggered, this, &AnalyzerManagerPrivate::selectMenuAction); + + connect(action, &QAction::triggered, this, [this, action] { + AnalyzerManager::showMode(); + selectAction(action); + startTool(); + }); + m_toolBox->setEnabled(true); } @@ -583,20 +564,23 @@ void AnalyzerManagerPrivate::saveToolSettings(Id toolId) void AnalyzerManagerPrivate::updateRunActions() { QString disabledReason; - if (m_isRunning) + bool enabled = true; + if (m_isRunning) { disabledReason = tr("An analysis is still in progress."); - else if (!m_currentAction) + enabled = false; + } else if (!m_currentAction) { disabledReason = tr("No analyzer tool selected."); - else - ProjectExplorerPlugin::canRun(SessionManager::startupProject(), - m_currentAction->runMode(), &disabledReason); + enabled = false; + } else { + enabled = m_currentAction->isRunnable(&disabledReason); + } - m_startAction->setEnabled(isActionRunnable(m_currentAction)); + m_startAction->setEnabled(enabled); m_startAction->setToolTip(disabledReason); m_toolBox->setEnabled(!m_isRunning); m_stopAction->setEnabled(m_isRunning); foreach (AnalyzerAction *action, m_actions) - action->setEnabled(isActionRunnable(action)); + action->setEnabled(!m_isRunning && action->isRunnable()); } //////////////////////////////////////////////////////////////////// @@ -643,10 +627,10 @@ QDockWidget *AnalyzerManager::createDockWidget(Core::Id toolId, return dockWidget; } -void AnalyzerManager::selectTool(Id toolId, StartMode mode) +void AnalyzerManager::selectTool(Id actionId) { foreach (AnalyzerAction *action, d->m_actions) - if (action->toolId() == toolId && action->startMode() == mode) + if (action->actionId() == actionId) d->selectAction(action); } @@ -706,8 +690,8 @@ AnalyzerRunControl *AnalyzerManager::createRunControl( const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) { foreach (AnalyzerAction *action, d->m_actions) { - if (action->runMode() == sp.runMode && action->startMode() == sp.startMode) - return action->createRunControl(sp, runConfiguration); + if (AnalyzerRunControl *rc = action->tryCreateRunControl(sp, runConfiguration)) + return rc; } QTC_CHECK(false); return 0; diff --git a/src/plugins/analyzerbase/analyzermanager.h b/src/plugins/analyzerbase/analyzermanager.h index 8a5e44ede6..f8360061dd 100644 --- a/src/plugins/analyzerbase/analyzermanager.h +++ b/src/plugins/analyzerbase/analyzermanager.h @@ -76,7 +76,7 @@ public: static Utils::FancyMainWindow *mainWindow(); static void showMode(); - static void selectTool(Core::Id toolId, StartMode mode); + static void selectTool(Core::Id actionId); static void startTool(); static void stopTool(); diff --git a/src/plugins/analyzerbase/detailederrorview.cpp b/src/plugins/analyzerbase/detailederrorview.cpp index bc1dfdbc35..165200523e 100644 --- a/src/plugins/analyzerbase/detailederrorview.cpp +++ b/src/plugins/analyzerbase/detailederrorview.cpp @@ -210,7 +210,7 @@ void DetailedErrorDelegate::onVerticalScroll() // Expects "file://some/path[:line[:column]]" - the line/column part is optional void DetailedErrorDelegate::openLinkInEditor(const QString &link) { - const QString linkWithoutPrefix = link.mid(strlen("file://")); + const QString linkWithoutPrefix = link.mid(int(strlen("file://"))); const QChar separator = QLatin1Char(':'); const int lineColon = linkWithoutPrefix.indexOf(separator, /*after drive letter + colon =*/ 2); const QString path = linkWithoutPrefix.left(lineColon); diff --git a/src/plugins/analyzerbase/ianalyzertool.cpp b/src/plugins/analyzerbase/ianalyzertool.cpp index 48866525df..b93e6dad57 100644 --- a/src/plugins/analyzerbase/ianalyzertool.cpp +++ b/src/plugins/analyzerbase/ianalyzertool.cpp @@ -62,6 +62,21 @@ AnalyzerAction::AnalyzerAction(QObject *parent) : QAction(parent) {} +bool AnalyzerAction::isRunnable(QString *reason) const +{ + if (m_startMode == StartRemote) + return true; + + return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), m_runMode, reason); +} + +AnalyzerRunControl *AnalyzerAction::tryCreateRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) const +{ + if (m_runMode == sp.runMode && m_startMode == sp.startMode) + return m_runControlCreator(sp, runConfiguration); + return 0; +} + static bool buildTypeAccepted(ToolMode toolMode, BuildConfiguration::BuildType buildType) { if (toolMode == AnyMode) diff --git a/src/plugins/analyzerbase/ianalyzertool.h b/src/plugins/analyzerbase/ianalyzertool.h index eb05272426..171bb6c903 100644 --- a/src/plugins/analyzerbase/ianalyzertool.h +++ b/src/plugins/analyzerbase/ianalyzertool.h @@ -79,7 +79,6 @@ public: explicit AnalyzerAction(QObject *parent = 0); public: - StartMode startMode() const { return m_startMode; } void setStartMode(StartMode startMode) { m_startMode = startMode; } Core::Id menuGroup() const { return m_menuGroup; } @@ -91,8 +90,8 @@ public: Core::Id toolId() const { return m_toolId; } void setToolId(Core::Id id) { m_toolId = id; } - ProjectExplorer::RunMode runMode() const { return m_runMode; } void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; } + bool isRunnable(QString *reason = 0) const; /// Creates all widgets used by the tool. /// Returns a control widget which will be shown in the status bar when @@ -105,12 +104,11 @@ public: /// Called each time the tool is launched. typedef std::function<AnalyzerRunControl *(const AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration)> RunControlCreator; - AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp, - ProjectExplorer::RunConfiguration *runConfiguration) const - { return m_runControlCreator(sp, runConfiguration); } + AnalyzerRunControl *tryCreateRunControl(const AnalyzerStartParameters &sp, + ProjectExplorer::RunConfiguration *runConfiguration) const; void setRunControlCreator(const RunControlCreator &creator) { m_runControlCreator = creator; } - typedef std::function<void(StartMode)> ToolStarter; + typedef std::function<void()> ToolStarter; ToolStarter toolStarter() const { return m_toolStarter; } void setToolStarter(const ToolStarter &toolStarter) { m_toolStarter = toolStarter; } diff --git a/src/plugins/android/androidpotentialkit.cpp b/src/plugins/android/androidpotentialkit.cpp index 0008a835a9..d1d5d9dcce 100644 --- a/src/plugins/android/androidpotentialkit.cpp +++ b/src/plugins/android/androidpotentialkit.cpp @@ -55,8 +55,7 @@ QString AndroidPotentialKit::displayName() const void AndroidPotentialKit::executeFromMenu() { - Core::ICore::showOptionsDialog(Constants::ANDROID_SETTINGS_CATEGORY, - Constants::ANDROID_SETTINGS_ID); + Core::ICore::showOptionsDialog(Constants::ANDROID_SETTINGS_ID); } QWidget *AndroidPotentialKit::createWidget(QWidget *parent) const @@ -120,9 +119,7 @@ AndroidPotentialKitWidget::AndroidPotentialKitWidget(QWidget *parent) void AndroidPotentialKitWidget::openOptions() { - Core::ICore::showOptionsDialog(Constants::ANDROID_SETTINGS_CATEGORY, - Constants::ANDROID_SETTINGS_ID, - this); + Core::ICore::showOptionsDialog(Constants::ANDROID_SETTINGS_ID, this); } void AndroidPotentialKitWidget::recheck() diff --git a/src/plugins/baremetal/baremetalrunconfigurationfactory.cpp b/src/plugins/baremetal/baremetalrunconfigurationfactory.cpp index d9f3b71dd0..ae812f00f8 100644 --- a/src/plugins/baremetal/baremetalrunconfigurationfactory.cpp +++ b/src/plugins/baremetal/baremetalrunconfigurationfactory.cpp @@ -52,7 +52,7 @@ static QString pathFromId(Core::Id id) QByteArray idStr = id.name(); if (!idStr.startsWith(BareMetalRunConfiguration::IdPrefix)) return QString(); - return QString::fromUtf8(idStr.mid(strlen(BareMetalRunConfiguration::IdPrefix))); + return QString::fromUtf8(idStr.mid(int(strlen(BareMetalRunConfiguration::IdPrefix)))); } BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory(QObject *parent) : diff --git a/src/plugins/baremetal/gdbserverproviderchooser.cpp b/src/plugins/baremetal/gdbserverproviderchooser.cpp index 8f52198a09..1f9b7d9d28 100644 --- a/src/plugins/baremetal/gdbserverproviderchooser.cpp +++ b/src/plugins/baremetal/gdbserverproviderchooser.cpp @@ -85,8 +85,7 @@ void GdbServerProviderChooser::setCurrentProviderId(const QString &id) void GdbServerProviderChooser::manageButtonClicked() { - Core::ICore::showOptionsDialog(Constants::BAREMETAL_SETTINGS_CATEGORY, - Constants::GDB_PROVIDERS_SETTINGS_ID, this); + Core::ICore::showOptionsDialog(Constants::GDB_PROVIDERS_SETTINGS_ID, this); } void GdbServerProviderChooser::currentIndexChanged(int index) diff --git a/src/plugins/bazaar/optionspage.ui b/src/plugins/bazaar/optionspage.ui index 297e5d1fea..2115baad0b 100644 --- a/src/plugins/bazaar/optionspage.ui +++ b/src/plugins/bazaar/optionspage.ui @@ -20,6 +20,9 @@ <string>Configuration</string> </property> <layout class="QFormLayout" name="formLayout_3"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="commandLabel"> <property name="text"> @@ -39,6 +42,9 @@ <string>User</string> </property> <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="defaultUsernameLabel"> <property name="toolTip"> diff --git a/src/plugins/clangcodemodel/pchmanager.cpp b/src/plugins/clangcodemodel/pchmanager.cpp index 0ca6ad40b4..11cf0abcba 100644 --- a/src/plugins/clangcodemodel/pchmanager.cpp +++ b/src/plugins/clangcodemodel/pchmanager.cpp @@ -304,6 +304,7 @@ void PchManager::doPchInfoUpdateFuzzy(QFutureInterface<void> &future, projectPart->languageVersion = languageVersions[pch]; projectPart->languageExtensions = languageExtensionsMap[pch]; projectPart->headerPaths = headers[pch].toList(); + projectPart->updateLanguageFeatures(); QList<QByteArray> defines = definesPerPCH[pch].toList(); if (!defines.isEmpty()) { @@ -386,6 +387,7 @@ void PchManager::doPchInfoUpdateCustom(QFutureInterface<void> &future, objc |= hasObjCFiles(projectPart); cplusplus |= hasCppFiles(projectPart); } + united->updateLanguageFeatures(); united->headerPaths = headers; QStringList opts = Utils::createClangOptions( united, getPrefixFileKind(objc, cplusplus)); diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp index df465c099b..628fa280e5 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp @@ -290,9 +290,7 @@ bool NoKitPage::isComplete() const void NoKitPage::showOptions() { - Core::ICore::showOptionsDialog(Core::Id(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY), - Core::Id(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID), - this); + Core::ICore::showOptionsDialog(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID, this); } InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard) diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index 80455ef163..cd3483776a 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -54,7 +54,6 @@ #include <QStyle> #include <QStyledItemDelegate> -static const char categoryKeyC[] = "General/LastPreferenceCategory"; static const char pageKeyC[] = "General/LastPreferencePage"; const int categoryIconSize = 24; @@ -70,6 +69,18 @@ class Category public: Category() : index(-1), providerPagesCreated(false) { } + bool findPageById(const Id id, int *pageIndex) const + { + for (int j = 0; j < pages.size(); ++j) { + IOptionsPage *page = pages.at(j); + if (page->id() == id) { + *pageIndex = j; + return true; + } + } + return false; + } + Id id; int index; QString displayName; @@ -333,54 +344,61 @@ SettingsDialog::SettingsDialog(QWidget *parent) : m_categoryList->setSelectionMode(QAbstractItemView::SingleSelection); m_categoryList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); - connect(m_categoryList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), - this, SLOT(currentChanged(QModelIndex))); + connect(m_categoryList->selectionModel(), &QItemSelectionModel::currentRowChanged, + this, &SettingsDialog::currentChanged); // The order of the slot connection matters here, the filter slot // opens the matching page after the model has filtered. - connect(m_filterLineEdit, SIGNAL(filterChanged(QString)), - m_proxyModel, SLOT(setFilterFixedString(QString))); - connect(m_filterLineEdit, SIGNAL(filterChanged(QString)), this, SLOT(filter(QString))); + connect(m_filterLineEdit, &Utils::FancyLineEdit::filterChanged, + m_proxyModel, &QSortFilterProxyModel::setFilterFixedString); + connect(m_filterLineEdit, &Utils::FancyLineEdit::filterChanged, + this, &SettingsDialog::filter); m_categoryList->setFocus(); } -void SettingsDialog::showPage(Id categoryId, Id pageId) +void SettingsDialog::showPage(const Id pageId) { // handle the case of "show last page" - Id initialCategory = categoryId; - Id initialPage = pageId; - if (!initialCategory.isValid() && !initialPage.isValid()) { + Id initialPageId = pageId; + if (!initialPageId.isValid()) { QSettings *settings = ICore::settings(); - initialCategory = Id::fromSetting(settings->value(QLatin1String(categoryKeyC))); - initialPage = Id::fromSetting(settings->value(QLatin1String(pageKeyC))); + initialPageId = Id::fromSetting(settings->value(QLatin1String(pageKeyC))); } - if (!initialCategory.isValid()) // no category given and no old setting - return; - int initialCategoryIndex = -1; int initialPageIndex = -1; + const QList<Category*> &categories = m_model->categories(); - for (int i = 0; i < categories.size(); ++i) { - Category *category = categories.at(i); - if (category->id == initialCategory) { - initialCategoryIndex = i; - if (initialPage.isValid()) { + if (initialPageId.isValid()) { + // First try categories without lazy items. + for (int i = 0; i < categories.size(); ++i) { + Category *category = categories.at(i); + if (category->providers.isEmpty()) { // no providers ensureCategoryWidget(category); - for (int j = 0; j < category->pages.size(); ++j) { - IOptionsPage *page = category->pages.at(j); - if (page->id() == initialPage) - initialPageIndex = j; + if (category->findPageById(initialPageId, &initialPageIndex)) { + initialCategoryIndex = i; + break; + } + } + } + + if (initialPageIndex == -1) { + // On failure, expand the remaining items. + for (int i = 0; i < categories.size(); ++i) { + Category *category = categories.at(i); + if (!category->providers.isEmpty()) { // has providers + ensureCategoryWidget(category); + if (category->findPageById(initialPageId, &initialPageIndex)) { + initialCategoryIndex = i; + break; + } } } - break; } } - QTC_ASSERT(initialCategoryIndex != -1, - qDebug("Unknown category: %s", initialCategory.name().constData()); return); - QTC_ASSERT(!initialPage.isValid() || initialPageIndex != -1, - qDebug("Unknown page: %s", initialPage.name().constData())); + QTC_ASSERT(!initialPageId.isValid() || initialPageIndex != -1, + qDebug("Unknown page: %s", initialPageId.name().constData())); if (initialCategoryIndex != -1) { const QModelIndex modelIndex = m_proxyModel->mapFromSource(m_model->index(initialCategoryIndex)); @@ -412,9 +430,11 @@ void SettingsDialog::createGui() QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel); - connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttonBox->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, + this, &SettingsDialog::apply); + + connect(buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &SettingsDialog::reject); QGridLayout *mainGridLayout = new QGridLayout; mainGridLayout->addWidget(m_filterLineEdit, 0, 0, 1, 1); @@ -474,8 +494,8 @@ void SettingsDialog::ensureCategoryWidget(Category *category) tabWidget->addTab(widget, page->displayName()); } - connect(tabWidget, SIGNAL(currentChanged(int)), - this, SLOT(currentTabChanged(int))); + connect(tabWidget, &QTabWidget::currentChanged, + this, &SettingsDialog::currentTabChanged); category->tabWidget = tabWidget; category->index = m_stackedLayout->addWidget(tabWidget); @@ -485,8 +505,8 @@ void SettingsDialog::disconnectTabWidgets() { foreach (Category *category, m_model->categories()) { if (category->tabWidget) - disconnect(category->tabWidget, SIGNAL(currentChanged(int)), - this, SLOT(currentTabChanged(int))); + disconnect(category->tabWidget, &QTabWidget::currentChanged, + this, &SettingsDialog::currentTabChanged); } } @@ -585,7 +605,6 @@ void SettingsDialog::apply() void SettingsDialog::done(int val) { QSettings *settings = ICore::settings(); - settings->setValue(QLatin1String(categoryKeyC), m_currentCategory.toSetting()); settings->setValue(QLatin1String(pageKeyC), m_currentPage.toSetting()); ICore::saveSettings(); // save all settings @@ -609,12 +628,11 @@ QSize SettingsDialog::sizeHint() const return minimumSize(); } -SettingsDialog *SettingsDialog::getSettingsDialog(QWidget *parent, - Id initialCategory, Id initialPage) +SettingsDialog *SettingsDialog::getSettingsDialog(QWidget *parent, Id initialPage) { if (!m_instance) m_instance = new SettingsDialog(parent); - m_instance->showPage(initialCategory, initialPage); + m_instance->showPage(initialPage); return m_instance; } diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.h b/src/plugins/coreplugin/dialogs/settingsdialog.h index 2b6f775893..30a52f6f1b 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.h +++ b/src/plugins/coreplugin/dialogs/settingsdialog.h @@ -62,8 +62,7 @@ public: // Returns a settings dialog. This makes sure that always only // a single settings dialog instance is running. // The dialog will be deleted automatically on close. - static SettingsDialog *getSettingsDialog(QWidget *parent, - Id initialCategory, Id initialPage); + static SettingsDialog *getSettingsDialog(QWidget *parent, Id initialPage); // Run the dialog and wait for it to finish. // Returns if the changes have been applied. bool execDialog(); @@ -73,7 +72,10 @@ public: public slots: void done(int); -private slots: +private: + SettingsDialog(QWidget *parent); + ~SettingsDialog(); + void accept(); void reject(); void apply(); @@ -81,13 +83,9 @@ private slots: void currentTabChanged(int); void filter(const QString &text); -private: - SettingsDialog(QWidget *parent); - ~SettingsDialog(); - void createGui(); void showCategory(int index); - void showPage(Id categoryId, Id pageId); + void showPage(Id pageId); void updateEnabledTabs(Category *category, const QString &searchText); void ensureCategoryWidget(Category *category); void disconnectTabWidgets(); diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp index e4c51f5838..38f9de1f14 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.cpp +++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp @@ -190,8 +190,10 @@ DocumentModel::Entry *DocumentModel::firstRestoredEntry() void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry) { + const Utils::FileName fileName = entry->fileName(); + // replace a non-loaded entry (aka 'restored') if possible - int previousIndex = indexOfFilePath(entry->fileName()); + int previousIndex = indexOfFilePath(fileName); if (previousIndex >= 0) { if (entry->document && m_entries.at(previousIndex)->document == 0) { DocumentModel::Entry *previousEntry = m_entries.at(previousIndex); @@ -265,13 +267,13 @@ void DocumentModelPrivate::removeDocument(int idx) if (idx < 0) return; QTC_ASSERT(idx < d->m_entries.size(), return); - IDocument *document = d->m_entries.at(idx)->document; int row = idx + 1/*<no document>*/; beginRemoveRows(QModelIndex(), row, row); - delete d->m_entries.takeAt(idx); + DocumentModel::Entry *entry = d->m_entries.takeAt(idx); endRemoveRows(); - if (document) + if (IDocument *document = entry->document) disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged())); + delete entry; } void DocumentModel::removeAllRestoredEntries() diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 39b24cb058..83fc2583a8 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1696,8 +1696,12 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document) Utils::MimeDatabase mdb; const QString filter = Utils::MimeDatabase::allFiltersString(); - QString selectedFilter = - mdb.mimeTypeForFile(document->filePath().toFileInfo()).filterString(); + QString selectedFilter; + QString filePath = document->filePath().toString(); + if (filePath.isEmpty()) + filePath = document->defaultPath() + QLatin1Char('/') + document->suggestedFileName(); + if (!filePath.isEmpty()) + selectedFilter = mdb.mimeTypeForFile(filePath).filterString(); if (selectedFilter.isEmpty()) selectedFilter = mdb.mimeTypeForName(document->mimeType()).filterString(); const QString &absoluteFilePath = @@ -2195,36 +2199,42 @@ IEditor *EditorManager::activateEditorForDocument(IDocument *document, OpenEdito * or IExternalEditor), find the one best matching the mimetype passed in. * Recurse over the parent classes of the mimetype to find them. */ template <class EditorFactoryLike> -static void mimeTypeFactoryRecursion(const Utils::MimeType &mimeType, +static void mimeTypeFactoryLookup(const Utils::MimeType &mimeType, const QList<EditorFactoryLike*> &allFactories, bool firstMatchOnly, QList<EditorFactoryLike*> *list) { - typedef typename QList<EditorFactoryLike*>::const_iterator EditorFactoryLikeListConstIterator; - // Loop factories to find type - const EditorFactoryLikeListConstIterator fcend = allFactories.constEnd(); - for (EditorFactoryLikeListConstIterator fit = allFactories.constBegin(); fit != fcend; ++fit) { - // Exclude duplicates when recursing over xml or C++ -> C -> text. - EditorFactoryLike *factory = *fit; - if (!list->contains(factory)) { - foreach (const QString &mt, factory->mimeTypes()) { - if (mimeType.matchesName(mt)) { - list->push_back(*fit); - if (firstMatchOnly) - return; + Utils::MimeDatabase mdb; + QSet<EditorFactoryLike *> matches; + // search breadth-first through parent hierarchy, e.g. for hierarchy + // * application/x-ruby + // * application/x-executable + // * application/octet-stream + // * text/plain + QList<Utils::MimeType> queue; + queue.append(mimeType); + while (!queue.isEmpty()) { + Utils::MimeType mt = queue.takeFirst(); + // check for matching factories + foreach (EditorFactoryLike *factory, allFactories) { + if (!matches.contains(factory)) { + foreach (const QString &mimeName, factory->mimeTypes()) { + if (mt.matchesName(mimeName)) { + list->append(factory); + if (firstMatchOnly) + return; + matches.insert(factory); + } } } } - } - // Any parent mime type classes? -> recurse - QStringList parentNames = mimeType.parentMimeTypes(); - if (parentNames.empty()) - return; - Utils::MimeDatabase mdb; - foreach (const QString &parentName, parentNames) { - const Utils::MimeType parent = mdb.mimeTypeForName(parentName); - if (parent.isValid()) - mimeTypeFactoryRecursion(parent, allFactories, firstMatchOnly, list); + // add parent mime types + QStringList parentNames = mt.parentMimeTypes(); + foreach (const QString &parentName, parentNames) { + const Utils::MimeType parent = mdb.mimeTypeForName(parentName); + if (parent.isValid()) + queue.append(parent); + } } } @@ -2233,7 +2243,7 @@ EditorManager::EditorFactoryList { EditorFactoryList rc; const EditorFactoryList allFactories = ExtensionSystem::PluginManager::getObjects<IEditorFactory>(); - mimeTypeFactoryRecursion(mimeType, allFactories, bestMatchOnly, &rc); + mimeTypeFactoryLookup(mimeType, allFactories, bestMatchOnly, &rc); if (debugEditorManager) qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc; return rc; @@ -2244,7 +2254,7 @@ EditorManager::ExternalEditorList { ExternalEditorList rc; const ExternalEditorList allEditors = ExtensionSystem::PluginManager::getObjects<IExternalEditor>(); - mimeTypeFactoryRecursion(mimeType, allEditors, bestMatchOnly, &rc); + mimeTypeFactoryLookup(mimeType, allEditors, bestMatchOnly, &rc); if (debugEditorManager) qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc; return rc; diff --git a/src/plugins/coreplugin/externaltoolmanager.cpp b/src/plugins/coreplugin/externaltoolmanager.cpp index 8221accc9b..9b99c1a420 100644 --- a/src/plugins/coreplugin/externaltoolmanager.cpp +++ b/src/plugins/coreplugin/externaltoolmanager.cpp @@ -80,7 +80,9 @@ ExternalToolManager::ExternalToolManager() d->m_configureSeparator = new QAction(this); d->m_configureSeparator->setSeparator(true); d->m_configureAction = new QAction(ICore::msgShowOptionsDialog(), this); - connect(d->m_configureAction, SIGNAL(triggered()), this, SLOT(openPreferences())); + connect(d->m_configureAction, &QAction::triggered, [this] { + ICore::showOptionsDialog(Constants::SETTINGS_ID_TOOLS); + }); // add the external tools menu ActionContainer *mexternaltools = ActionManager::createMenu(Id(Constants::M_TOOLS_EXTERNAL)); @@ -159,17 +161,6 @@ static void parseDirectory(const QString &directory, } } -void ExternalToolManager::menuActivated() -{ - QAction *action = qobject_cast<QAction *>(sender()); - QTC_ASSERT(action, return); - ExternalTool *tool = d->m_tools.value(action->data().toString()); - QTC_ASSERT(tool, return); - ExternalToolRunner *runner = new ExternalToolRunner(tool); - if (runner->hasError()) - MessageManager::write(runner->errorString()); -} - QMap<QString, QList<ExternalTool *> > ExternalToolManager::toolsByCategory() { return d->m_categoryMap; @@ -246,9 +237,13 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT command = ActionManager::command(externalToolsPrefix.withSuffix(toolId)); } else { action = new QAction(tool->displayName(), m_instance); - action->setData(toolId); d->m_actions.insert(toolId, action); - connect(action, SIGNAL(triggered()), m_instance, SLOT(menuActivated())); + connect(action, &QAction::triggered, [tool] { + ExternalToolRunner *runner = new ExternalToolRunner(tool); + if (runner->hasError()) + MessageManager::write(runner->errorString()); + }); + command = ActionManager::registerAction(action, externalToolsPrefix.withSuffix(toolId), Context(Constants::C_GLOBAL)); command->setAttribute(Command::CA_UpdateText); } @@ -330,11 +325,6 @@ static void writeSettings() settings->endGroup(); } -void ExternalToolManager::openPreferences() -{ - ICore::showOptionsDialog(Constants::SETTINGS_CATEGORY_CORE, Constants::SETTINGS_ID_TOOLS); -} - void ExternalToolManager::emitReplaceSelectionRequested(const QString &output) { emit m_instance->replaceSelectionRequested(output); diff --git a/src/plugins/coreplugin/externaltoolmanager.h b/src/plugins/coreplugin/externaltoolmanager.h index bc69106007..62fcdc833c 100644 --- a/src/plugins/coreplugin/externaltoolmanager.h +++ b/src/plugins/coreplugin/externaltoolmanager.h @@ -58,10 +58,6 @@ public: signals: void replaceSelectionRequested(const QString &text); - -private slots: - void menuActivated(); - void openPreferences(); }; } // namespace Core diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp index 99a9df5f80..28f66b50d4 100644 --- a/src/plugins/coreplugin/fileutils.cpp +++ b/src/plugins/coreplugin/fileutils.cpp @@ -66,11 +66,8 @@ static void showGraphicalShellError(QWidget *parent, const QString &app, const Q QAbstractButton *settingsButton = mbox.addButton(Core::ICore::msgShowOptionsDialog(), QMessageBox::ActionRole); mbox.exec(); - if (mbox.clickedButton() == settingsButton) { - ICore::showOptionsDialog(Constants::SETTINGS_CATEGORY_CORE, - Constants::SETTINGS_ID_ENVIRONMENT, - parent); - } + if (mbox.clickedButton() == settingsButton) + ICore::showOptionsDialog(Constants::SETTINGS_ID_ENVIRONMENT, parent); } void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn) diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 41ee44deb4..dce4a74a21 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -337,9 +337,9 @@ void ICore::showNewItemDialog(const QString &title, m_mainwindow->showNewItemDialog(title, factories, defaultLocation, extraVariables); } -bool ICore::showOptionsDialog(const Id group, const Id page, QWidget *parent) +bool ICore::showOptionsDialog(const Id page, QWidget *parent) { - return m_mainwindow->showOptionsDialog(group, page, parent); + return m_mainwindow->showOptionsDialog(page, parent); } QString ICore::msgShowOptionsDialog() @@ -358,14 +358,9 @@ QString ICore::msgShowOptionsDialogToolTip() } bool ICore::showWarningWithOptions(const QString &title, const QString &text, - const QString &details, - Id settingsCategory, - Id settingsId, - QWidget *parent) -{ - return m_mainwindow->showWarningWithOptions(title, text, - details, settingsCategory, - settingsId, parent); + const QString &details, Id settingsId, QWidget *parent) +{ + return m_mainwindow->showWarningWithOptions(title, text, details, settingsId, parent); } QSettings *ICore::settings(QSettings::Scope scope) diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index b18fb90f98..1391701cdc 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -74,13 +74,12 @@ public: const QString &defaultLocation = QString(), const QVariantMap &extraVariables = QVariantMap()); - static bool showOptionsDialog(Id group, Id page, QWidget *parent = 0); + static bool showOptionsDialog(Id page, QWidget *parent = 0); static QString msgShowOptionsDialog(); static QString msgShowOptionsDialogToolTip(); static bool showWarningWithOptions(const QString &title, const QString &text, const QString &details = QString(), - Id settingsCategory = Id(), Id settingsId = Id(), QWidget *parent = 0); diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index 0f3bca6a0a..f05f079770 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -625,7 +625,7 @@ void LocatorWidget::filterSelected() void LocatorWidget::showConfigureDialog() { - ICore::showOptionsDialog(Constants::SETTINGS_CATEGORY_CORE, Constants::FILTER_OPTIONS_PAGE); + ICore::showOptionsDialog(Constants::FILTER_OPTIONS_PAGE); } void LocatorWidget::addSearchResults(int firstIndex, int endIndex) diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 9d966f8a33..dd04c34010 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -73,6 +73,7 @@ #include <coreplugin/progressmanager/progressmanager_p.h> #include <coreplugin/progressmanager/progressview.h> #include <coreplugin/settingsdatabase.h> +#include <extensionsystem/pluginmanager.h> #include <utils/algorithm.h> #include <utils/historycompleter.h> #include <utils/hostosinfo.h> @@ -81,27 +82,26 @@ #include <utils/stylehelper.h> #include <utils/theme/theme.h> #include <utils/stringutils.h> -#include <extensionsystem/pluginmanager.h> - -#include <QDebug> -#include <QFileInfo> -#include <QSettings> -#include <QTimer> -#include <QUrl> -#include <QDir> #include <QApplication> #include <QCloseEvent> +#include <QDebug> +#include <QDir> +#include <QFileInfo> #include <QMenu> -#include <QPrinter> -#include <QStatusBar> -#include <QToolButton> -#include <QMessageBox> #include <QMenuBar> +#include <QMessageBox> +#include <QPrinter> #include <QPushButton> +#include <QSettings> +#include <QStatusBar> #include <QStyleFactory> +#include <QTimer> +#include <QToolButton> +#include <QUrl> using namespace ExtensionSystem; +using namespace Utils; namespace Core { namespace Internal { @@ -109,7 +109,7 @@ namespace Internal { enum { debugMainWindow = 0 }; MainWindow::MainWindow() : - Utils::AppMainWindow(), + AppMainWindow(), m_coreImpl(new ICore(this)), m_additionalContexts(Constants::C_GLOBAL), m_settingsDatabase(new SettingsDatabase(QFileInfo(PluginManager::settings()->fileName()).path(), @@ -147,17 +147,17 @@ MainWindow::MainWindow() : (void) new DocumentManager(this); OutputPaneManager::create(); - Utils::HistoryCompleter::setSettings(PluginManager::settings()); + HistoryCompleter::setSettings(PluginManager::settings()); setWindowTitle(tr("Qt Creator")); - if (Utils::HostOsInfo::isLinuxHost()) + if (HostOsInfo::isLinuxHost()) QApplication::setWindowIcon(QIcon(QLatin1String(Constants::ICON_QTLOGO_128))); QCoreApplication::setApplicationName(QLatin1String("QtCreator")); QCoreApplication::setApplicationVersion(QLatin1String(Constants::IDE_VERSION_LONG)); QCoreApplication::setOrganizationName(QLatin1String(Constants::IDE_SETTINGSVARIANT_STR)); QString baseName = QApplication::style()->objectName(); // Sometimes we get the standard windows 95 style as a fallback - if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost() + if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost() && baseName == QLatin1String("windows")) { baseName = QLatin1String("fusion"); } @@ -202,15 +202,15 @@ MainWindow::MainWindow() : statusBar()->insertPermanentWidget(0, m_toggleSideBarButton); // setUnifiedTitleAndToolBarOnMac(true); - //if (Utils::HostOsInfo::isAnyUnixHost()) + //if (HostOsInfo::isAnyUnixHost()) //signal(SIGINT, handleSigInt); statusBar()->setProperty("p_styled", true); - auto dropSupport = new Utils::FileDropSupport(this, [](QDropEvent *event) { + auto dropSupport = new FileDropSupport(this, [](QDropEvent *event) { return event->source() == 0; // only accept drops from the "outside" (e.g. file manager) }); - connect(dropSupport, &Utils::FileDropSupport::filesDropped, + connect(dropSupport, &FileDropSupport::filesDropped, this, &MainWindow::openDroppedFiles); } @@ -376,11 +376,11 @@ void MainWindow::closeEvent(QCloseEvent *event) event->accept(); } -void MainWindow::openDroppedFiles(const QList<Utils::FileDropSupport::FileSpec> &files) +void MainWindow::openDroppedFiles(const QList<FileDropSupport::FileSpec> &files) { raiseWindow(); QStringList filePaths = Utils::transform(files, - [](const Utils::FileDropSupport::FileSpec &spec) -> QString { + [](const FileDropSupport::FileSpec &spec) -> QString { return spec.filePath; }); openFiles(filePaths, ICore::SwitchMode); @@ -400,7 +400,7 @@ void MainWindow::registerDefaultContainers() { ActionContainer *menubar = ActionManager::createMenuBar(Constants::MENU_BAR); - if (!Utils::HostOsInfo::isMacHost()) // System menu bar on Mac + if (!HostOsInfo::isMacHost()) // System menu bar on Mac setMenuBar(menubar->menuBar()); menubar->appendGroup(Constants::G_FILE); menubar->appendGroup(Constants::G_EDIT); @@ -420,7 +420,7 @@ void MainWindow::registerDefaultContainers() filemenu->appendGroup(Constants::G_FILE_CLOSE); filemenu->appendGroup(Constants::G_FILE_PRINT); filemenu->appendGroup(Constants::G_FILE_OTHER); - connect(filemenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentFiles())); + connect(filemenu->menu(), &QMenu::aboutToShow, this, &MainWindow::aboutToShowRecentFiles); // Edit Menu @@ -650,11 +650,11 @@ void MainWindow::registerDefaultActions() // Full Screen Action QAction *toggleFullScreenAction = new QAction(tr("Full Screen"), this); - toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost()); + toggleFullScreenAction->setCheckable(!HostOsInfo::isMacHost()); toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); - if (Utils::HostOsInfo::isMacHost()) + if (HostOsInfo::isMacHost()) cmd->setAttribute(Command::CA_UpdateText); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); @@ -677,7 +677,7 @@ void MainWindow::registerDefaultActions() cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR, globalContext); cmd->setAttribute(Command::CA_UpdateText); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0"))); - connect(m_toggleSideBarAction, SIGNAL(triggered(bool)), this, SLOT(setSidebarVisible(bool))); + connect(m_toggleSideBarAction, &QAction::triggered, this, &MainWindow::setSidebarVisible); m_toggleSideBarButton->setDefaultAction(cmd->action()); mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS); m_toggleSideBarAction->setEnabled(false); @@ -686,7 +686,7 @@ void MainWindow::registerDefaultActions() m_toggleModeSelectorAction = new QAction(tr("Show Mode Selector"), this); m_toggleModeSelectorAction->setCheckable(true); cmd = ActionManager::registerAction(m_toggleModeSelectorAction, Constants::TOGGLE_MODE_SELECTOR, globalContext); - connect(m_toggleModeSelectorAction, SIGNAL(triggered(bool)), ModeManager::instance(), SLOT(setModeSelectorVisible(bool))); + connect(m_toggleModeSelectorAction, &QAction::triggered, ModeManager::instance(), &ModeManager::setModeSelectorVisible); mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS); // Window->Views @@ -696,12 +696,12 @@ void MainWindow::registerDefaultActions() // "Help" separators mhelp->addSeparator(globalContext, Constants::G_HELP_SUPPORT); - if (!Utils::HostOsInfo::isMacHost()) + if (!HostOsInfo::isMacHost()) mhelp->addSeparator(globalContext, Constants::G_HELP_ABOUT); // About IDE Action icon = QIcon::fromTheme(QLatin1String("help-about")); - if (Utils::HostOsInfo::isMacHost()) + if (HostOsInfo::isMacHost()) tmpaction = new QAction(icon, tr("About &Qt Creator"), this); // it's convention not to add dots to the about menu else tmpaction = new QAction(icon, tr("About &Qt Creator..."), this); @@ -709,7 +709,7 @@ void MainWindow::registerDefaultActions() cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR, globalContext); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); tmpaction->setEnabled(true); - connect(tmpaction, SIGNAL(triggered()), this, SLOT(aboutQtCreator())); + connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutQtCreator); //About Plugins Action tmpaction = new QAction(tr("About &Plugins..."), this); @@ -717,7 +717,7 @@ void MainWindow::registerDefaultActions() cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS, globalContext); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); tmpaction->setEnabled(true); - connect(tmpaction, SIGNAL(triggered()), this, SLOT(aboutPlugins())); + connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutPlugins); // About Qt Action // tmpaction = new QAction(tr("About &Qt..."), this); // cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT, globalContext); @@ -725,7 +725,7 @@ void MainWindow::registerDefaultActions() // tmpaction->setEnabled(true); // connect(tmpaction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); // About sep - if (!Utils::HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu + if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu tmpaction = new QAction(this); tmpaction->setSeparator(true); cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About", globalContext); @@ -746,8 +746,8 @@ void MainWindow::openFile() static IDocumentFactory *findDocumentFactory(const QList<IDocumentFactory*> &fileFactories, const QFileInfo &fi) { - Utils::MimeDatabase mdb; - const Utils::MimeType mt = mdb.mimeTypeForFile(fi); + MimeDatabase mdb; + const MimeType mt = mdb.mimeTypeForFile(fi); if (mt.isValid()) { const QString typeName = mt.name(); foreach (IDocumentFactory *factory, fileFactories) { @@ -823,12 +823,12 @@ void MainWindow::showNewItemDialog(const QString &title, emit newItemDialogRunningChanged(); } -bool MainWindow::showOptionsDialog(Id category, Id page, QWidget *parent) +bool MainWindow::showOptionsDialog(Id page, QWidget *parent) { emit m_coreImpl->optionsDialogRequested(); if (!parent) parent = ICore::dialogParent(); - SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, category, page); + SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, page); return dialog->execDialog(); } @@ -947,13 +947,12 @@ void MainWindow::readSettings() settings->beginGroup(QLatin1String(settingsGroup)); if (m_overrideColor.isValid()) { - Utils::StyleHelper::setBaseColor(m_overrideColor); + StyleHelper::setBaseColor(m_overrideColor); // Get adapted base color. - m_overrideColor = Utils::StyleHelper::baseColor(); + m_overrideColor = StyleHelper::baseColor(); } else { - Utils::StyleHelper::setBaseColor( - settings->value(QLatin1String(colorKey), - QColor(Utils::StyleHelper::DEFAULT_BASE_COLOR)).value<QColor>()); + StyleHelper::setBaseColor(settings->value(QLatin1String(colorKey), + QColor(StyleHelper::DEFAULT_BASE_COLOR)).value<QColor>()); } bool modeSelectorVisible = settings->value(QLatin1String(modeSelectorVisibleKey), true).toBool(); @@ -972,8 +971,8 @@ void MainWindow::writeSettings() QSettings *settings = PluginManager::settings(); settings->beginGroup(QLatin1String(settingsGroup)); - if (!(m_overrideColor.isValid() && Utils::StyleHelper::baseColor() == m_overrideColor)) - settings->setValue(QLatin1String(colorKey), Utils::StyleHelper::requestedBaseColor()); + if (!(m_overrideColor.isValid() && StyleHelper::baseColor() == m_overrideColor)) + settings->setValue(QLatin1String(colorKey), StyleHelper::requestedBaseColor()); settings->setValue(QLatin1String(windowGeometryKey), saveGeometry()); settings->setValue(QLatin1String(windowStateKey), saveState()); @@ -1031,8 +1030,7 @@ void MainWindow::updateContext() void MainWindow::aboutToShowRecentFiles() { - ActionContainer *aci = - ActionManager::actionContainer(Constants::M_FILE_RECENTFILES); + ActionContainer *aci = ActionManager::actionContainer(Constants::M_FILE_RECENTFILES); QMenu *menu = aci->menu(); menu->clear(); @@ -1041,8 +1039,9 @@ void MainWindow::aboutToShowRecentFiles() hasRecentFiles = true; QAction *action = menu->addAction( QDir::toNativeSeparators(Utils::withTildeHomePath(file.first))); - action->setData(qVariantFromValue(file)); - connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); + connect(action, &QAction::triggered, this, [file] { + EditorManager::openEditor(file.first, file.second); + }); } menu->setEnabled(hasRecentFiles); @@ -1051,15 +1050,8 @@ void MainWindow::aboutToShowRecentFiles() menu->addSeparator(); QAction *action = menu->addAction(QCoreApplication::translate( "Core", Constants::TR_CLEAR_MENU)); - connect(action, SIGNAL(triggered()), DocumentManager::instance(), SLOT(clearRecentFiles())); - } -} - -void MainWindow::openRecentFile() -{ - if (const QAction *action = qobject_cast<const QAction*>(sender())) { - const DocumentManager::RecentFile file = action->data().value<DocumentManager::RecentFile>(); - EditorManager::openEditor(file.first, file.second); + connect(action, &QAction::triggered, + DocumentManager::instance(), &DocumentManager::clearRecentFiles); } } @@ -1067,8 +1059,8 @@ void MainWindow::aboutQtCreator() { if (!m_versionDialog) { m_versionDialog = new VersionDialog(this); - connect(m_versionDialog, SIGNAL(finished(int)), - this, SLOT(destroyVersionDialog())); + connect(m_versionDialog, &QDialog::finished, + this, &MainWindow::destroyVersionDialog); } m_versionDialog->show(); } @@ -1100,7 +1092,6 @@ QPrinter *MainWindow::printer() const bool MainWindow::showWarningWithOptions(const QString &title, const QString &text, const QString &details, - Id settingsCategory, Id settingsId, QWidget *parent) { @@ -1111,11 +1102,11 @@ bool MainWindow::showWarningWithOptions(const QString &title, if (!details.isEmpty()) msgBox.setDetailedText(details); QAbstractButton *settingsButton = 0; - if (settingsId.isValid() || settingsCategory.isValid()) + if (settingsId.isValid()) settingsButton = msgBox.addButton(tr("Settings..."), QMessageBox::AcceptRole); msgBox.exec(); if (settingsButton && msgBox.clickedButton() == settingsButton) - return showOptionsDialog(settingsCategory, settingsId); + return showOptionsDialog(settingsId); return false; } diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index 7ee205f792..17b8f88457 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -122,11 +122,10 @@ public slots: const QString &defaultLocation = QString(), const QVariantMap &extraVariables = QVariantMap()); - bool showOptionsDialog(Id category = Id(), Id page = Id(), QWidget *parent = 0); + bool showOptionsDialog(Id page = Id(), QWidget *parent = 0); bool showWarningWithOptions(const QString &title, const QString &text, const QString &details = QString(), - Id settingsCategory = Id(), Id settingsId = Id(), QWidget *parent = 0); @@ -136,7 +135,6 @@ protected: private slots: void openFile(); void aboutToShowRecentFiles(); - void openRecentFile(); void setFocusToEditor(); void saveAll(); void aboutQtCreator(); diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index e59d5266cf..13f6cb5a7b 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -344,8 +344,7 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input d->m_unconfiguredVcs = versionControl; info.setCustomButtonInfo(ICore::msgShowOptionsDialog(), []() { QTC_ASSERT(d->m_unconfiguredVcs, return); - ICore::showOptionsDialog(Id(VcsBase::Constants::VCS_SETTINGS_CATEGORY), - d->m_unconfiguredVcs->id()); + ICore::showOptionsDialog(d->m_unconfiguredVcs->id()); }); infoBar->addInfo(info); diff --git a/src/plugins/cpaster/protocol.cpp b/src/plugins/cpaster/protocol.cpp index dcc8c33033..0e410868df 100644 --- a/src/plugins/cpaster/protocol.cpp +++ b/src/plugins/cpaster/protocol.cpp @@ -170,11 +170,8 @@ bool Protocol::showConfigurationError(const Protocol *p, settingsButton = mb.addButton(Core::ICore::msgShowOptionsDialog(), QMessageBox::AcceptRole); mb.exec(); bool rc = false; - if (mb.clickedButton() == settingsButton) { - rc = Core::ICore::showOptionsDialog(p->settingsPage()->category(), - p->settingsPage()->id(), - parent); - } + if (mb.clickedButton() == settingsButton) + rc = Core::ICore::showOptionsDialog(p->settingsPage()->id(), parent); return rc; } diff --git a/src/plugins/cpptools/builtineditordocumentparser.cpp b/src/plugins/cpptools/builtineditordocumentparser.cpp index 4aea3d3cc0..24ae027bfc 100644 --- a/src/plugins/cpptools/builtineditordocumentparser.cpp +++ b/src/plugins/cpptools/builtineditordocumentparser.cpp @@ -60,6 +60,7 @@ void BuiltinEditorDocumentParser::update(WorkingCopy workingCopy) ProjectPart::HeaderPaths headerPaths; QStringList precompiledHeaders; QString projectConfigFile; + LanguageFeatures features = LanguageFeatures::defaultFeatures(); updateProjectPart(); @@ -75,6 +76,7 @@ void BuiltinEditorDocumentParser::update(WorkingCopy workingCopy) projectConfigFile = part->projectConfigFile; if (usePrecompiledHeaders()) precompiledHeaders = part->precompiledHeaders; + features = part->languageFeatures; } if (configFile != m_configFile) { @@ -169,6 +171,7 @@ void BuiltinEditorDocumentParser::update(WorkingCopy workingCopy) sourceProcessor.setGlobalSnapshot(globalSnapshot); sourceProcessor.setWorkingCopy(workingCopy); sourceProcessor.setHeaderPaths(m_headerPaths); + sourceProcessor.setLanguageFeatures(features); sourceProcessor.run(configurationFileName); if (!m_projectConfigFile.isEmpty()) sourceProcessor.run(m_projectConfigFile); diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp index a35a5413a9..9d75998816 100644 --- a/src/plugins/cpptools/builtinindexingsupport.cpp +++ b/src/plugins/cpptools/builtinindexingsupport.cpp @@ -208,6 +208,8 @@ void index(QFutureInterface<void> &future, const ParseParams params) CppModelManager *cmm = CppModelManager::instance(); const ProjectPart::HeaderPaths fallbackHeaderPaths = cmm->headerPaths(); + const CPlusPlus::LanguageFeatures defaultFeatures = + CPlusPlus::LanguageFeatures::defaultFeatures(); for (int i = 0; i < files.size(); ++i) { if (future.isPaused()) future.waitForResume(); @@ -216,6 +218,11 @@ void index(QFutureInterface<void> &future, const ParseParams params) break; const QString fileName = files.at(i); + const QList<ProjectPart::Ptr> parts = cmm->projectPart(fileName); + const CPlusPlus::LanguageFeatures languageFeatures = parts.isEmpty() + ? defaultFeatures + : parts.first()->languageFeatures; + sourceProcessor->setLanguageFeatures(languageFeatures); const bool isSourceFile = i < sourceCount; if (isSourceFile) { @@ -226,7 +233,6 @@ void index(QFutureInterface<void> &future, const ParseParams params) processingHeaders = true; } - QList<ProjectPart::Ptr> parts = cmm->projectPart(fileName); ProjectPart::HeaderPaths headerPaths = parts.isEmpty() ? fallbackHeaderPaths : parts.first()->headerPaths; diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index e901021513..dd5bbe2ecd 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -2174,6 +2174,8 @@ void CppToolsPlugin::test_completion_data() "#define slots\n" "#define Q_OBJECT virtual const QMetaObject *metaObject() const;" "\n" + "namespace N {\n" + "\n" "class Base : public QObject\n" "{\n" " Q_OBJECT\n" @@ -2204,9 +2206,11 @@ void CppToolsPlugin::test_completion_data() " void derivedSlot2(int newValue);\n" "};\n" "\n" + "} // namespace N\n" + "\n" "void client()\n" "{\n" - " Derived *myObject = new Derived;\n" + " N::Derived *myObject = new N::Derived;\n" " @\n" "}\n"; @@ -2227,33 +2231,60 @@ void CppToolsPlugin::test_completion_data() << QLatin1String("derivedSlot1()") << QLatin1String("derivedSlot2(int)")); - QTest::newRow("Qt5 signal") + QTest::newRow("Qt5 signals: complete class after & at 2nd connect arg") << commonSignalSlotCompletionTestCode << _("connect(myObject, &") << (QStringList() - << QLatin1String("Base::baseSignal1") - << QLatin1String("Base::baseSignal2") - << QLatin1String("Base::hiddenSignal") - << QLatin1String("Derived::derivedSignal1") - << QLatin1String("Derived::derivedSignal2") - << QLatin1String("Derived::hiddenSignal")); // OK, hidden signal - - QTest::newRow("Qt5 slot") + << QLatin1String("N::Derived")); + + QTest::newRow("Qt5 signals: complete class after & at 4th connect arg") << commonSignalSlotCompletionTestCode << _("connect(myObject, &MyObject::timeout, myObject, &") << (QStringList() - << QLatin1String("Base::baseSignal1") - << QLatin1String("Base::baseSignal2") - << QLatin1String("Base::baseSlot1") - << QLatin1String("Base::baseSlot2") - << QLatin1String("Base::baseFunction") - << QLatin1String("Base::hiddenFunction") - << QLatin1String("Base::hiddenSignal") - << QLatin1String("Derived::derivedFunction") - << QLatin1String("Derived::derivedSignal1") - << QLatin1String("Derived::derivedSignal2") - << QLatin1String("Derived::derivedSlot1") - << QLatin1String("Derived::derivedSlot2") - << QLatin1String("Derived::hiddenFunction") - << QLatin1String("Derived::hiddenSignal")); + << QLatin1String("N::Derived")); + + QTest::newRow("Qt5 signals: complete signals") + << commonSignalSlotCompletionTestCode + << _("connect(myObject, &N::Derived::") << (QStringList() + << QLatin1String("baseSignal1") + << QLatin1String("baseSignal2") + << QLatin1String("hiddenSignal") + << QLatin1String("derivedSignal1") + << QLatin1String("derivedSignal2")); + + QTest::newRow("Qt5 slots") + << commonSignalSlotCompletionTestCode + << _("connect(myObject, &N::Derived, myObject, &N::Derived::") << (QStringList() + << QLatin1String("baseFunction") + << QLatin1String("baseSignal1") + << QLatin1String("baseSignal2") + << QLatin1String("baseSlot1") + << QLatin1String("baseSlot2") + << QLatin1String("derivedFunction") + << QLatin1String("derivedSignal1") + << QLatin1String("derivedSignal2") + << QLatin1String("derivedSlot1") + << QLatin1String("derivedSlot2") + << QLatin1String("hiddenFunction") + << QLatin1String("hiddenSignal")); + + QTest::newRow("Qt5 signals: no class name completion if not after 'connect(' 1") + << commonSignalSlotCompletionTestCode + << _("foo(myObject, &") << (QStringList()); + + QTest::newRow("Qt5 signals/slots: no class name completion if not after 'connect(' 2") + << commonSignalSlotCompletionTestCode + << _("&") << (QStringList()); + + QTest::newRow("Qt5 signals: fallback to scope completion") + << commonSignalSlotCompletionTestCode + << _("connect(myObject, &N::") << (QStringList() + << QLatin1String("Base") + << QLatin1String("Derived")); + + QTest::newRow("Qt5 slots: fallback to scope completion") + << commonSignalSlotCompletionTestCode + << _("connect(myObject, &N::Derived, myObject, &N::") << (QStringList() + << QLatin1String("Base") + << QLatin1String("Derived")); QTest::newRow("signals_hide_QPrivateSignal") << _( "#define SIGNAL(a) #a\n" diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index 1283e620a8..0ad70a4286 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -615,15 +615,186 @@ QString createQt4SignalOrSlot(CPlusPlus::Function *function, const Overview &ove return QString::fromUtf8(normalized, normalized.size()); } -QString createQt5SignalOrSlot(CPlusPlus::Function *function, Class *klass) +QString createQt5SignalOrSlot(CPlusPlus::Function *function, const Overview &overview) { QString text; - text += Overview().prettyName(klass->name()); - text += QLatin1String("::"); - text += Overview().prettyName(function->name()); + text += overview.prettyName(function->name()); return text; } +/*! + \class BackwardsEater + \brief Checks strings and expressions before given position. + + Similar to BackwardsScanner, but also can handle expressions. Ignores whitespace. +*/ +class BackwardsEater +{ +public: + explicit BackwardsEater(const CppCompletionAssistInterface *assistInterface, int position) + : m_position(position) + , m_assistInterface(assistInterface) + { + } + + bool isPositionValid() const + { + return m_position >= 0; + } + + bool eatConnectOpenParenthesis() + { + return eatString(QLatin1String("(")) && eatString(QLatin1String("connect")); + } + + bool eatExpressionCommaAmpersand() + { + return eatString(QLatin1String("&")) && eatString(QLatin1String(",")) && eatExpression(); + } + + bool eatConnectOpenParenthesisExpressionCommaAmpersandExpressionComma() + { + return eatString(QLatin1String(",")) + && eatExpression() + && eatExpressionCommaAmpersand() + && eatConnectOpenParenthesis(); + } + +private: + bool eatExpression() + { + if (!isPositionValid()) + return false; + + maybeEatWhitespace(); + + QTextCursor cursor(m_assistInterface->textDocument()); + cursor.setPosition(m_position + 1); + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(cursor); + if (expression.isEmpty()) + return false; + m_position = m_position - expression.length(); + return true; + } + + bool eatString(const QString &string) + { + if (!isPositionValid()) + return false; + + if (string.isEmpty()) + return true; + + maybeEatWhitespace(); + + const int stringLength = string.length(); + const int stringStart = m_position - (stringLength - 1); + + if (stringStart < 0) + return false; + + if (m_assistInterface->textAt(stringStart, stringLength) == string) { + m_position = stringStart - 1; + return true; + } + + return false; + } + + void maybeEatWhitespace() + { + while (isPositionValid() && m_assistInterface->characterAt(m_position).isSpace()) + --m_position; + } + +private: + int m_position; + const CppCompletionAssistInterface * const m_assistInterface; +}; + +bool canCompleteConnectSignalAt2ndArgument(const CppCompletionAssistInterface *assistInterface, + int startOfExpression) +{ + BackwardsEater eater(assistInterface, startOfExpression); + + return eater.isPositionValid() + && eater.eatExpressionCommaAmpersand() + && eater.eatConnectOpenParenthesis(); +} + +bool canCompleteConnectSignalAt4thArgument(const CppCompletionAssistInterface *assistInterface, + int startPosition) +{ + BackwardsEater eater(assistInterface, startPosition); + + return eater.isPositionValid() + && eater.eatExpressionCommaAmpersand() + && eater.eatConnectOpenParenthesisExpressionCommaAmpersandExpressionComma(); +} + +bool canCompleteClassNameAt2ndOr4thConnectArgument( + const CppCompletionAssistInterface *assistInterface, + int startPosition) +{ + BackwardsEater eater(assistInterface, startPosition); + + if (!eater.isPositionValid()) + return false; + + return eater.eatConnectOpenParenthesis() + || eater.eatConnectOpenParenthesisExpressionCommaAmpersandExpressionComma(); +} + +ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem, + const LookupContext &context) +{ + const Name *name = 0; + + if (Symbol *d = lookupItem.declaration()) { + if (Class *k = d->asClass()) + name = k->name(); + } + + if (!name) { + FullySpecifiedType type = lookupItem.type().simplified(); + + if (PointerType *pointerType = type->asPointerType()) + type = pointerType->elementType().simplified(); + else + return 0; // not a pointer or a reference to a pointer. + + NamedType *namedType = type->asNamedType(); + if (!namedType) // not a class name. + return 0; + + name = namedType->name(); + } + + return name ? context.lookupType(name, lookupItem.scope()) : 0; +} + +Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &context) +{ + ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context); + if (!b) + return 0; + + foreach (Symbol *s, b->symbols()) { + if (Class *klass = s->asClass()) + return klass; + } + return 0; +} + +const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext &context) +{ + ClassOrNamespace *target = context.lookupType(targetScope); + if (!target) + target = context.globalNamespace(); + return context.minimalName(symbol, target, context.bindings()->control().data()); +} + } // Anonymous // ------------------------------------ @@ -807,10 +978,8 @@ int InternalCppCompletionAssistProcessor::startOfOperator(int pos, if (*kind == T_AMPER && tokenIdx > 0) { const Token &previousToken = tokens.at(tokenIdx - 1); - if (previousToken.kind() == T_COMMA) { + if (previousToken.kind() == T_COMMA) start = pos - (tk.utf16charOffset - previousToken.utf16charOffset) - 1; - QTC_CHECK(m_interface->characterAt(start) == QLatin1Char(',')); - } } else if (*kind == T_DOXY_COMMENT && !(tk.is(T_DOXY_COMMENT) || tk.is(T_CPP_DOXY_COMMENT))) { *kind = T_EOF_SYMBOL; start = pos; @@ -895,18 +1064,6 @@ int InternalCppCompletionAssistProcessor::findStartOfName(int pos) const return pos + 1; } -static bool isPrecededByConnectAndOpenParenthesis( - const CppCompletionAssistInterface *assistInterface, - int startOfExpression) -{ - QTC_ASSERT(startOfExpression >= 0, return false); - - int beforeExpression = startOfExpression; - while (beforeExpression > 0 && assistInterface->characterAt(--beforeExpression).isSpace()) ; - const int pos = beforeExpression - 7; - return pos >= 0 && assistInterface->textAt(pos, 7) == QLatin1String("connect"); -} - int InternalCppCompletionAssistProcessor::startCompletionHelper() { if (m_languageFeatures.objCEnabled) { @@ -978,10 +1135,21 @@ int InternalCppCompletionAssistProcessor::startCompletionHelper() startOfExpression = endOfExpression - expression.length(); if (m_model->m_completionOperator == T_AMPER) { - m_model->m_completionOperator - = isPrecededByConnectAndOpenParenthesis(m_interface.data(), startOfExpression) - ? CompleteQt5SignalTrigger - : CompleteQtSlotTrigger; + // We expect 'expression' to be either "sender" or "receiver" in + // "connect(sender, &" or + // "connect(otherSender, &Foo::signal1, receiver, &" + const int beforeExpression = startOfExpression - 1; + if (canCompleteClassNameAt2ndOr4thConnectArgument(m_interface.data(), beforeExpression)) + m_model->m_completionOperator = CompleteQt5SignalOrSlotClassNameTrigger; + } else if (m_model->m_completionOperator == T_COLON_COLON) { + // We expect 'expression' to be "Foo" in + // "connect(sender, &Foo::" or + // "connect(sender, &Bar::signal1, receiver, &Foo::" + const int beforeExpression = startOfExpression - 1; + if (canCompleteConnectSignalAt2ndArgument(m_interface.data(), beforeExpression)) + m_model->m_completionOperator = CompleteQt5SignalTrigger; + else if (canCompleteConnectSignalAt4thArgument(m_interface.data(), beforeExpression)) + m_model->m_completionOperator = CompleteQt5SlotTrigger; } else if (m_model->m_completionOperator == T_LPAREN) { if (expression.endsWith(QLatin1String("SIGNAL"))) { m_model->m_completionOperator = T_SIGNAL; @@ -1249,10 +1417,7 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString if (expression.isEmpty()) { if (m_model->m_completionOperator == T_EOF_SYMBOL || m_model->m_completionOperator == T_COLON_COLON) { (void) (*m_model->m_typeOfExpression)(expression.toUtf8(), scope); - globalCompletion(scope); - if (m_completions.isEmpty()) - return -1; - return m_startPosition; + return globalCompletion(scope) ? m_startPosition : -1; } if (m_model->m_completionOperator == T_SIGNAL || m_model->m_completionOperator == T_SLOT) { @@ -1304,10 +1469,12 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString } return -1; - } else { - // nothing to do. - return -1; + } else if (m_model->m_completionOperator == CompleteQt5SignalOrSlotClassNameTrigger) { + // Fallback to global completion if we could not lookup sender/receiver object. + return globalCompletion(scope) ? m_startPosition : -1; + } else { + return -1; // nothing to do. } } @@ -1338,13 +1505,20 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString return m_startPosition; break; + case CompleteQt5SignalOrSlotClassNameTrigger: + if (completeQtMethodClassName(results, scope) || globalCompletion(scope)) + return m_startPosition; + break; + case CompleteQt5SignalTrigger: - if (completeQtMethod(results, CompleteQt5Signals)) + // Fallback to scope completion if "X::" is a namespace and not a class. + if (completeQtMethod(results, CompleteQt5Signals) || completeScope(results)) return m_startPosition; break; - case CompleteQtSlotTrigger: - if (completeQtMethod(results, CompleteQt5Slots)) + case CompleteQt5SlotTrigger: + // Fallback to scope completion if "X::" is a namespace and not a class. + if (completeQtMethod(results, CompleteQt5Slots) || completeScope(results)) return m_startPosition; break; @@ -1356,13 +1530,13 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString return -1; } -void InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope) +bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope) { const LookupContext &context = m_model->m_typeOfExpression->context(); if (m_model->m_completionOperator == T_COLON_COLON) { completeNamespace(context.globalNamespace()); - return; + return !m_completions.isEmpty(); } QList<ClassOrNamespace *> usingBindings; @@ -1431,6 +1605,7 @@ void InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope) addMacros(CppModelManager::configurationFileName(), context.snapshot()); addMacros(context.thisDocument()->fileName(), context.snapshot()); addSnippets(); + return !m_completions.isEmpty(); } bool InternalCppCompletionAssistProcessor::completeMember(const QList<LookupItem> &baseResults) @@ -1659,19 +1834,8 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt o.showFunctionSignatures = true; QSet<QString> signatures; - foreach (const LookupItem &p, results) { - FullySpecifiedType ty = p.type().simplified(); - - if (PointerType *ptrTy = ty->asPointerType()) - ty = ptrTy->elementType().simplified(); - else - continue; // not a pointer or a reference to a pointer. - - NamedType *namedTy = ty->asNamedType(); - if (!namedTy) // not a class name. - continue; - - ClassOrNamespace *b = context.lookupType(namedTy->name(), p.scope()); + foreach (const LookupItem &lookupItem, results) { + ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context); if (!b) continue; @@ -1712,7 +1876,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt unsigned count = fun->argumentCount(); while (true) { const QString completionText = wantQt5SignalOrSlot - ? createQt5SignalOrSlot(fun, klass) + ? createQt5SignalOrSlot(fun, o) : createQt4SignalOrSlot(fun, o); if (!signatures.contains(completionText)) { @@ -1736,6 +1900,34 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt return !m_completions.isEmpty(); } +bool InternalCppCompletionAssistProcessor::completeQtMethodClassName( + const QList<LookupItem> &results, Scope *cursorScope) +{ + QTC_ASSERT(cursorScope, return false); + + if (results.isEmpty()) + return false; + + const LookupContext &context = m_model->m_typeOfExpression->context(); + Overview overview; + + foreach (const LookupItem &lookupItem, results) { + Class *klass = classFromLookupItem(lookupItem, context); + QTC_ASSERT(klass, continue); + const Name *name = minimalName(klass, cursorScope, context); + QTC_ASSERT(name, continue); + + AssistProposalItem *item = new CppAssistProposalItem; + item->setText(overview.prettyName(name)); + item->setDetail(overview.prettyType(klass->type(), klass->name())); + item->setData(QVariant::fromValue(static_cast<Symbol *>(klass))); + m_completions.append(item); + break; + } + + return !m_completions.isEmpty(); +} + void InternalCppCompletionAssistProcessor::addKeywords() { int keywordLimit = T_FIRST_OBJC_AT_KEYWORD; diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h index 8a31f9387d..0b009e07ea 100644 --- a/src/plugins/cpptools/cppcompletionassist.h +++ b/src/plugins/cpptools/cppcompletionassist.h @@ -139,7 +139,9 @@ private: CompleteQt5Slots, }; bool completeQtMethod(const QList<CPlusPlus::LookupItem> &results, CompleteQtMethodMode type); - void globalCompletion(CPlusPlus::Scope *scope); + bool completeQtMethodClassName(const QList<CPlusPlus::LookupItem> &results, + CPlusPlus::Scope *cursorScope); + bool globalCompletion(CPlusPlus::Scope *scope); void addCompletionItem(const QString &text, const QIcon &icon = QIcon(), @@ -155,9 +157,11 @@ private: QSet<QString> *definedMacros); enum { - CompleteQt5SignalTrigger = CPlusPlus::T_LAST_TOKEN + 1, - CompleteQtSlotTrigger + CompleteQt5SignalOrSlotClassNameTrigger = CPlusPlus::T_LAST_TOKEN + 1, + CompleteQt5SignalTrigger, + CompleteQt5SlotTrigger }; + CPlusPlus::LanguageFeatures m_languageFeatures; QScopedPointer<const CppCompletionAssistInterface> m_interface; QScopedPointer<CppAssistProposalModel> m_model; diff --git a/src/plugins/cpptools/cppfilesettingspage.ui b/src/plugins/cpptools/cppfilesettingspage.ui index e11701a784..75cf6b83a1 100644 --- a/src/plugins/cpptools/cppfilesettingspage.ui +++ b/src/plugins/cpptools/cppfilesettingspage.ui @@ -23,6 +23,9 @@ <string>Headers</string> </property> <layout class="QFormLayout" name="formLayout_2"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="2" column="0"> <widget class="QLabel" name="headerSuffixLabel"> <property name="text"> @@ -98,6 +101,9 @@ These prefixes are used in addition to current file name on Switch Header/Source <string>Sources</string> </property> <layout class="QFormLayout" name="formLayout_3"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="3" column="0"> <widget class="QLabel" name="sourceSuffixLabel"> <property name="text"> diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index cf9858498d..c7a8065696 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -840,6 +840,7 @@ ProjectPart::Ptr CppModelManager::fallbackProjectPart() const part->languageVersion = ProjectPart::CXX14; part->languageExtensions = ProjectPart::AllExtensions; part->qtVersion = ProjectPart::Qt5; + part->updateLanguageFeatures(); return part; } diff --git a/src/plugins/cpptools/cppprojects.cpp b/src/plugins/cpptools/cppprojects.cpp index 4bea18d691..03d5bdcbe8 100644 --- a/src/plugins/cpptools/cppprojects.cpp +++ b/src/plugins/cpptools/cppprojects.cpp @@ -108,6 +108,29 @@ void ProjectPart::evaluateToolchain(const ToolChain *tc, } toolchainDefines = tc->predefinedMacros(commandLineFlags); + updateLanguageFeatures(); +} + +void ProjectPart::updateLanguageFeatures() +{ + const bool hasQt = qtVersion != NoQt; + languageFeatures.cxx11Enabled = languageVersion >= CXX11; + languageFeatures.qtEnabled = hasQt; + languageFeatures.qtMocRunEnabled = hasQt; + if (!hasQt) { + languageFeatures.qtKeywordsEnabled = false; + } else { + const QByteArray noKeywordsMacro = "#define QT_NO_KEYWORDS"; + const int noKeywordsIndex = projectDefines.indexOf(noKeywordsMacro); + if (noKeywordsIndex == -1) { + languageFeatures.qtKeywordsEnabled = true; + } else { + const char nextChar = projectDefines.at(noKeywordsIndex + noKeywordsMacro.length()); + // Detect "#define QT_NO_KEYWORDS" and "#define QT_NO_KEYWORDS 1", but exclude + // "#define QT_NO_KEYWORDS_FOO" + languageFeatures.qtKeywordsEnabled = nextChar != '\n' && nextChar != ' '; + } + } } ProjectPart::Ptr ProjectPart::copy() const @@ -198,6 +221,7 @@ void ProjectInfo::finish() QSet<HeaderPath> incs; foreach (const ProjectPart::Ptr &part, m_projectParts) { + part->updateLanguageFeatures(); // Update header paths foreach (const HeaderPath &hp, part->headerPaths) { if (!incs.contains(hp)) { diff --git a/src/plugins/cpptools/cppprojects.h b/src/plugins/cpptools/cppprojects.h index ebdfd989ce..f6c78c7852 100644 --- a/src/plugins/cpptools/cppprojects.h +++ b/src/plugins/cpptools/cppprojects.h @@ -38,6 +38,8 @@ #include <projectexplorer/project.h> #include <projectexplorer/toolchain.h> +#include <cplusplus/Token.h> + #include <QPointer> #include <QSet> @@ -109,6 +111,7 @@ public: // methods const QStringList &commandLineFlags, const Utils::FileName &sysRoot); + void updateLanguageFeatures(); Ptr copy() const; QString id() const; @@ -127,6 +130,7 @@ public: // fields QStringList precompiledHeaders; LanguageVersion languageVersion; LanguageExtensions languageExtensions; + CPlusPlus::LanguageFeatures languageFeatures; QtVersion qtVersion; ProjectExplorer::ToolChain::WarningFlags warningFlags; bool selectedForBuilding; diff --git a/src/plugins/cpptools/cppsourceprocessor.cpp b/src/plugins/cpptools/cppsourceprocessor.cpp index 8a3e4549b6..df792c3bcd 100644 --- a/src/plugins/cpptools/cppsourceprocessor.cpp +++ b/src/plugins/cpptools/cppsourceprocessor.cpp @@ -116,6 +116,7 @@ CppSourceProcessor::CppSourceProcessor(const Snapshot &snapshot, DocumentCallbac : m_snapshot(snapshot), m_documentFinished(documentFinished), m_preprocess(this, &m_env), + m_languageFeatures(LanguageFeatures::defaultFeatures()), m_revision(0), m_defaultCodec(Core::EditorManager::defaultTextCodec()) { @@ -145,6 +146,11 @@ void CppSourceProcessor::setHeaderPaths(const ProjectPart::HeaderPaths &headerPa } } +void CppSourceProcessor::setLanguageFeatures(const LanguageFeatures languageFeatures) +{ + m_languageFeatures = languageFeatures; +} + // Add the given framework path, and expand private frameworks. // // Example: @@ -466,6 +472,7 @@ void CppSourceProcessor::sourceNeeded(unsigned line, const QString &fileName, In Document::Ptr document = Document::create(absoluteFileName); document->setRevision(m_revision); document->setEditorRevision(editorRevision); + document->setLanguageFeatures(m_languageFeatures); foreach (const QString &include, initialIncludes) { m_included.insert(include); Document::Include inc(include, include, 0, IncludeLocal); diff --git a/src/plugins/cpptools/cppsourceprocessor.h b/src/plugins/cpptools/cppsourceprocessor.h index a1b9ac6bc2..3d8053bf26 100644 --- a/src/plugins/cpptools/cppsourceprocessor.h +++ b/src/plugins/cpptools/cppsourceprocessor.h @@ -68,6 +68,7 @@ public: void setRevision(unsigned revision); void setWorkingCopy(const CppTools::WorkingCopy &workingCopy); void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths); + void setLanguageFeatures(CPlusPlus::LanguageFeatures languageFeatures); void setTodo(const QSet<QString> &files); void run(const QString &fileName, const QStringList &initialIncludes = QStringList()); @@ -117,6 +118,7 @@ private: CPlusPlus::Environment m_env; CPlusPlus::Preprocessor m_preprocess; ProjectPart::HeaderPaths m_headerPaths; + CPlusPlus::LanguageFeatures m_languageFeatures; CppTools::WorkingCopy m_workingCopy; QSet<QString> m_included; CPlusPlus::Document::Ptr m_currentDoc; diff --git a/src/plugins/cvs/settingspage.ui b/src/plugins/cvs/settingspage.ui index 86f414e22b..8f0ce41dcc 100644 --- a/src/plugins/cvs/settingspage.ui +++ b/src/plugins/cvs/settingspage.ui @@ -17,6 +17,9 @@ <string>Configuration</string> </property> <layout class="QFormLayout" name="formLayout_2"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="commandLabel"> <property name="text"> @@ -46,6 +49,9 @@ <string>Miscellaneous</string> </property> <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="1" column="0"> <widget class="QLabel" name="diffOptionsLabel"> <property name="text"> diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 486977d157..1c0a01527a 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -2040,9 +2040,15 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, if (!conditionalBreakPointTriggered && !parameters.condition.isEmpty()) { *message = msgCheckingConditionalBreakPoint(id, number, parameters.condition, QString::number(threadId)); - ConditionalBreakPointCookie cookie(id); - cookie.stopReason = stopReason; - evaluateExpression(parameters.condition, cookie); + + QByteArray exp = parameters.condition; + if (exp.contains(' ') && !exp.startsWith('"')) { + exp.prepend('"'); + exp.append('"'); + } + postExtensionCommand("expression", exp, 0, + [this, id, stopReason](const CdbCommandPtr &r) { handleExpression(r, id, stopReason); }); + return StopReportLog; } } else { @@ -3081,7 +3087,7 @@ void CdbEngine::handleStackTrace(const CdbCommandPtr &command) } } -void CdbEngine::handleExpression(const CdbCommandPtr &command, const ConditionalBreakPointCookie &cookie) +void CdbEngine::handleExpression(const CdbCommandPtr &command, BreakpointModelId id, const GdbMi &stopReason) { int value = 0; if (command->success) @@ -3091,27 +3097,17 @@ void CdbEngine::handleExpression(const CdbCommandPtr &command, const Conditional // Is this a conditional breakpoint? const QString message = value ? tr("Value %1 obtained from evaluating the condition of breakpoint %2, stopping."). - arg(value).arg(cookie.id.toString()) : + arg(value).arg(id.toString()) : tr("Value 0 obtained from evaluating the condition of breakpoint %1, continuing."). - arg(cookie.id.toString()); + arg(id.toString()); showMessage(message, LogMisc); // Stop if evaluation is true, else continue if (value) - processStop(cookie.stopReason, true); + processStop(stopReason, true); else doContinueInferior(); } -void CdbEngine::evaluateExpression(QByteArray exp, const ConditionalBreakPointCookie &cookie) -{ - if (exp.contains(' ') && !exp.startsWith('"')) { - exp.prepend('"'); - exp.append('"'); - } - postExtensionCommand("expression", exp, 0, - [this, cookie](const CdbCommandPtr &r) { handleExpression(r, cookie); }); -} - void CdbEngine::dummyHandler(const CdbCommandPtr &command) { postCommandSequence(command->commandSequence); diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index b7f455161f..70055f2974 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -51,7 +51,6 @@ namespace Internal { class DisassemblerAgent; struct CdbCommand; struct MemoryViewCookie; -struct ConditionalBreakPointCookie; class ByteArrayInputStream; class GdbMi; @@ -215,14 +214,13 @@ private: DisassemblerAgent *agent); void postResolveSymbol(const QString &module, const QString &function, DisassemblerAgent *agent); - void evaluateExpression(QByteArray exp, const ConditionalBreakPointCookie &cookie); // Builtin commands void dummyHandler(const CdbCommandPtr &); void handleStackTrace(const CdbCommandPtr &); void handleRegisters(const CdbCommandPtr &); void handleDisassembler(const CdbCommandPtr &, DisassemblerAgent *agent); void handleJumpToLineAddressResolution(const CdbCommandPtr &, const ContextData &context); - void handleExpression(const CdbCommandPtr &, const ConditionalBreakPointCookie &cookie); + void handleExpression(const CdbCommandPtr &command, BreakpointModelId id, const GdbMi &stopReason); void handleResolveSymbol(const CdbCommandPtr &command, const QString &symbol, DisassemblerAgent *agent); void handleResolveSymbolHelper(const QList<quint64> &addresses, DisassemblerAgent *agent); void handleBreakInsert(const CdbCommandPtr &cmd); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index d79bee0df0..5c67aecaf0 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -1859,7 +1859,7 @@ void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp) if (found) break; - const int len = strlen(str); + const int len = int(strlen(str)); if (len == 0) break; str += len + 1; diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index f011a861db..334be7a606 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -148,7 +148,7 @@ void DebuggerItem::reinitializeFromFile() // Version if (ba.startsWith(("lldb version "))) { // Linux typically. - int pos1 = strlen("lldb version "); + int pos1 = int(strlen("lldb version ")); int pos2 = ba.indexOf(' ', pos1); m_version = QString::fromLatin1(ba.mid(pos1, pos2 - pos1)); } else if (ba.startsWith("lldb-") || ba.startsWith("LLDB-")) { // Mac typically. diff --git a/src/plugins/debugger/debuggerkitconfigwidget.cpp b/src/plugins/debugger/debuggerkitconfigwidget.cpp index 1812cb76e0..d97fb4f8ba 100644 --- a/src/plugins/debugger/debuggerkitconfigwidget.cpp +++ b/src/plugins/debugger/debuggerkitconfigwidget.cpp @@ -127,8 +127,7 @@ QWidget *DebuggerKitConfigWidget::mainWidget() const void DebuggerKitConfigWidget::manageDebuggers() { - Core::ICore::showOptionsDialog(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - ProjectExplorer::Constants::DEBUGGER_SETTINGS_PAGE_ID, + Core::ICore::showOptionsDialog(ProjectExplorer::Constants::DEBUGGER_SETTINGS_PAGE_ID, buttonWidget()); } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 581a27626d..193691d675 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -706,12 +706,8 @@ public: const QString &tracePointMessage = QString()); void onModeChanged(IMode *mode); void onCoreAboutToOpen(); - void showSettingsDialog(); void updateDebugWithoutDeployMenu(); - void debugProject(); - void debugProjectWithoutDeploy(); - void debugProjectBreakMain(); void startAndDebugApplication(); void startRemoteCdbSession(); void startRemoteServer(); @@ -819,7 +815,7 @@ public slots: void handleExecStep() { if (currentEngine()->state() == DebuggerNotReady) { - debugProjectBreakMain(); + ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain); } else { currentEngine()->resetLocation(); if (boolSetting(OperateByInstruction)) @@ -832,7 +828,7 @@ public slots: void handleExecNext() { if (currentEngine()->state() == DebuggerNotReady) { - debugProjectBreakMain(); + ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain); } else { currentEngine()->resetLocation(); if (boolSetting(OperateByInstruction)) @@ -903,15 +899,6 @@ public slots: } } - void slotDisassembleFunction() - { - const QAction *action = qobject_cast<const QAction *>(sender()); - QTC_ASSERT(action, return); - const StackFrame frame = action->data().value<StackFrame>(); - QTC_ASSERT(!frame.function.isEmpty(), return); - currentEngine()->openDisassemblerView(Location(frame)); - } - void handleAddToWatchWindow() { // Requires a selection, but that's the only case we want anyway. @@ -1336,21 +1323,6 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project) setProxyAction(m_visibleStartAction, Id(Constants::DEBUG)); } -void DebuggerPluginPrivate::debugProject() -{ - ProjectExplorerPlugin::runProject(SessionManager::startupProject(), DebugRunMode); -} - -void DebuggerPluginPrivate::debugProjectWithoutDeploy() -{ - ProjectExplorerPlugin::runProject(SessionManager::startupProject(), DebugRunMode, true); -} - -void DebuggerPluginPrivate::debugProjectBreakMain() -{ - ProjectExplorerPlugin::runProject(SessionManager::startupProject(), DebugRunModeWithBreakOnMain); -} - void DebuggerPluginPrivate::startAndDebugApplication() { DebuggerStartParameters sp; @@ -1738,18 +1710,18 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget, }); } // Disassemble current function in stopped state. - if (currentEngine()->state() == InferiorStopOk - && currentEngine()->hasCapability(DisassemblerCapability)) { + if (currentEngine()->hasCapability(DisassemblerCapability)) { StackFrame frame; - frame.function = cppFunctionAt(args.fileName, lineNumber); + frame.function = cppFunctionAt(args.fileName, lineNumber, 1); frame.line = 42; // trick gdb into mixed mode. if (!frame.function.isEmpty()) { const QString text = tr("Disassemble Function \"%1\"") .arg(frame.function); - QAction *disassembleAction = new QAction(text, menu); - disassembleAction->setData(QVariant::fromValue(frame)); - connect(disassembleAction, &QAction::triggered, this, &DebuggerPluginPrivate::slotDisassembleFunction); - menu->addAction(disassembleAction ); + auto act = new QAction(text, menu); + connect(act, &QAction::triggered, [this, frame] { + currentEngine()->openDisassemblerView(Location(frame)); + }); + menu->addAction(act); } } } @@ -2188,11 +2160,6 @@ void DebuggerPluginPrivate::onModeChanged(IMode *mode) m_toolTipManager.debugModeEntered(); } -void DebuggerPluginPrivate::showSettingsDialog() -{ - ICore::showOptionsDialog(DEBUGGER_SETTINGS_CATEGORY, DEBUGGER_COMMON_SETTINGS_ID); -} - void DebuggerPluginPrivate::updateDebugWithoutDeployMenu() { const bool state = ProjectExplorerPlugin::projectExplorerSettings().deployBeforeRun; @@ -2661,11 +2628,11 @@ void DebuggerPluginPrivate::extensionsInitialized() debuggerIcon.addFile(QLatin1String(":/projectexplorer/images/debugger_start.png")); act->setIcon(debuggerIcon); act->setText(tr("Start Debugging")); - connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::debugProject); + connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(DebugRunMode); }); act = m_debugWithoutDeployAction = new QAction(this); act->setText(tr("Start Debugging Without Deployment")); - connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::debugProjectWithoutDeploy); + connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(DebugRunMode, true); }); act = m_startAndDebugApplicationAction = new QAction(this); act->setText(tr("Start and Debug External Application...")); @@ -3017,7 +2984,7 @@ void DebuggerPluginPrivate::extensionsInitialized() // Application interaction connect(action(SettingsDialog), &QAction::triggered, - this, &DebuggerPluginPrivate::showSettingsDialog); + [] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); }); // QML Actions connect(action(ShowQmlObjectTree), &SavedAction::valueChanged, diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 286127892a..7621f31ae2 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -368,7 +368,7 @@ void GdbMi::fromStringMultiple(const QByteArray &ba) GdbMi GdbMi::operator[](const char *name) const { - for (int i = 0, n = m_children.size(); i < n; ++i) + for (int i = 0, n = int(m_children.size()); i < n; ++i) if (m_children.at(i).m_name == name) return m_children.at(i); return GdbMi(); diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index dd16bd116b..73aa8201b5 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -159,7 +159,7 @@ public: inline QByteArray data() const { return m_data; } inline const std::vector<GdbMi> &children() const { return m_children; } - inline int childCount() const { return m_children.size(); } + inline int childCount() const { return int(m_children.size()); } const GdbMi &childAt(int index) const { return m_children[index]; } GdbMi &childAt(int index) { return m_children[index]; } diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp index 1f9dfaa43e..8aa29de282 100644 --- a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp +++ b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp @@ -275,6 +275,7 @@ DebuggerSourcePathMappingWidget::DebuggerSourcePathMappingWidget(QWidget *parent editTargetLabel->setBuddy(m_targetChooser); m_targetChooser->setToolTip(targetToolTip); editLayout->addRow(editTargetLabel, m_targetChooser); + editLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); auto chooser = new Core::VariableChooser(this); chooser->addSupportedWidget(m_targetChooser->lineEdit()); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 6f877d6b4d..a960c2f57c 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2593,14 +2593,6 @@ void GdbEngine::handleBreakInsert2(const DebuggerResponse &response, Breakpoint } } -void GdbEngine::handleBreakDelete(const DebuggerResponse &response, Breakpoint bp) -{ - if (response.resultClass == ResultDone) - bp.notifyBreakpointRemoveOk(); - else - bp.notifyBreakpointRemoveFailed(); -} - void GdbEngine::handleBreakDisable(const DebuggerResponse &response, Breakpoint bp) { QTC_CHECK(response.resultClass == ResultDone); @@ -2882,8 +2874,14 @@ void GdbEngine::removeBreakpoint(Breakpoint bp) bp.notifyBreakpointRemoveProceeding(); showMessage(_("DELETING BP %1 IN %2").arg(br.id.toString()).arg(bp.fileName())); postCommand("-break-delete " + br.id.toByteArray(), - NeedsStop | RebuildBreakpointModel, - [this, bp](const DebuggerResponse &r) { handleBreakDelete(r, bp); }); + NeedsStop | RebuildBreakpointModel); + + // Pretend it succeeds without waiting for response. Feels better. + // Otherwise, clicking in the gutter leaves the breakpoint visible + // for quite some time, so the user assumes a mis-click and clicks + // again, effectivly re-introducing the breakpoint. + bp.notifyBreakpointRemoveOk(); + } else { // Breakpoint was scheduled to be inserted, but we haven't had // an answer so far. Postpone activity by doing nothing. @@ -3900,7 +3898,7 @@ void GdbEngine::handleFetchMemory(const DebuggerResponse &response, MemoryAgentC return; GdbMi memory0 = memory.children().at(0); // we asked for only one 'row' GdbMi data = memory0["data"]; - for (int i = 0, n = data.children().size(); i != n; ++i) { + for (int i = 0, n = int(data.children().size()); i != n; ++i) { const GdbMi &child = data.children().at(i); bool ok = true; unsigned char c = '?'; @@ -4426,8 +4424,7 @@ void GdbEngine::handleAdapterStartFailed(const QString &msg, Id settingsIdHint) if (!settingsIdHint.isValid()) { ICore::showWarningWithOptions(title, msg); } else { - ICore::showWarningWithOptions(title, msg, QString(), - Constants::DEBUGGER_SETTINGS_CATEGORY, settingsIdHint); + ICore::showWarningWithOptions(title, msg, QString(), settingsIdHint); } } notifyEngineSetupFailed(); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index eb48e45dfc..b76bac82a1 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -287,7 +287,6 @@ private: ////////// View & Data Stuff ////////// void handleBreakEnable(const DebuggerResponse &response, Breakpoint bp); void handleBreakInsert1(const DebuggerResponse &response, Breakpoint bp); void handleBreakInsert2(const DebuggerResponse &response, Breakpoint bp); - void handleBreakDelete(const DebuggerResponse &response, Breakpoint bp); void handleBreakCondition(const DebuggerResponse &response, Breakpoint bp); void handleBreakThreadSpec(const DebuggerResponse &response, Breakpoint bp); void handleBreakLineNumber(const DebuggerResponse &response, Breakpoint bp); diff --git a/src/plugins/debugger/gdb/termgdbadapter.h b/src/plugins/debugger/gdb/termgdbadapter.h index 2ffebbabb0..bafd2caad9 100644 --- a/src/plugins/debugger/gdb/termgdbadapter.h +++ b/src/plugins/debugger/gdb/termgdbadapter.h @@ -62,9 +62,9 @@ private: void handleStubAttached(const DebuggerResponse &response); - Q_SLOT void stubStarted(); - Q_SLOT void stubExited(); - Q_SLOT void stubError(const QString &msg); + void stubStarted(); + void stubExited(); + void stubError(const QString &msg); Utils::ConsoleProcess m_stubProc; }; diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 01c5d9651a..d2425f664c 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -312,6 +312,7 @@ void LldbEngine::setupInferior() showMessage(_("TAKING OWNERSHIP OF BREAKPOINT %1 IN STATE %2") .arg(bp.id().toString()).arg(bp.state())); bp.setEngine(this); + bp.notifyBreakpointInsertProceeding(); cmd.beginGroup(); bp.addToCommand(&cmd); cmd.endGroup(); @@ -459,6 +460,8 @@ void LldbEngine::handleResponse(const QByteArray &response) refreshMemory(item); else if (name == "full-backtrace") showFullBacktrace(item); + else if (name == "continuation") + handleContinuation(item); else if (name == "statusmessage") { QString msg = QString::fromUtf8(item.data()); if (msg.size()) @@ -468,6 +471,15 @@ void LldbEngine::handleResponse(const QByteArray &response) } } +void LldbEngine::handleContinuation(const GdbMi &data) +{ + if (data.data() == "updateLocals") { + updateLocals(); + return; + } + QTC_ASSERT(false, qDebug() << "Unknown continuation: " << data.data()); +} + void LldbEngine::showFullBacktrace(const GdbMi &data) { Internal::openTextEditor(_("Backtrace $"), @@ -523,10 +535,10 @@ void LldbEngine::activateFrame(int frameIndex) DebuggerCommand cmd("activateFrame"); cmd.arg("index", frameIndex); cmd.arg("thread", threadsHandler()->currentThread().raw()); + cmd.arg("continuation", "updateLocals"); runCommand(cmd); reloadRegisters(); - updateLocals(); } void LldbEngine::selectThread(ThreadId threadId) @@ -609,7 +621,7 @@ void LldbEngine::updateBreakpointData(const GdbMi &bkpt, bool added) response.lineNumber = bkpt["line"].toInt(); GdbMi locations = bkpt["locations"]; - const int numChild = locations.children().size(); + const int numChild = int(locations.children().size()); if (numChild > 1) { foreach (const GdbMi &location, locations.children()) { const int locid = location["locid"].toInt(); @@ -792,23 +804,19 @@ bool LldbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget void LldbEngine::updateAll() { reloadRegisters(); - updateStack(); - updateLocals(); -} -void LldbEngine::reloadFullStack() -{ DebuggerCommand cmd("reportStack"); cmd.arg("nativeMixed", isNativeMixedActive()); - cmd.arg("stacklimit", -1); + cmd.arg("stacklimit", action(MaximalStackDepth)->value().toInt()); + cmd.arg("continuation", "updateLocals"); runCommand(cmd); } -void LldbEngine::updateStack() +void LldbEngine::reloadFullStack() { DebuggerCommand cmd("reportStack"); cmd.arg("nativeMixed", isNativeMixedActive()); - cmd.arg("stacklimit", action(MaximalStackDepth)->value().toInt()); + cmd.arg("stacklimit", -1); runCommand(cmd); } diff --git a/src/plugins/debugger/lldb/lldbengine.h b/src/plugins/debugger/lldb/lldbengine.h index 02fef25d6e..ca9109d5fb 100644 --- a/src/plugins/debugger/lldb/lldbengine.h +++ b/src/plugins/debugger/lldb/lldbengine.h @@ -132,16 +132,17 @@ private: QString errorMessage(QProcess::ProcessError error) const; bool hasCapability(unsigned cap) const; - Q_SLOT void handleLldbFinished(int, QProcess::ExitStatus status); - Q_SLOT void handleLldbError(QProcess::ProcessError error); - Q_SLOT void readLldbStandardOutput(); - Q_SLOT void readLldbStandardError(); - Q_SLOT void handleResponse(const QByteArray &data); - Q_SLOT void updateAll(); - Q_SLOT void updateStack(); - Q_SLOT void updateLocals(); - Q_SLOT void createFullBacktrace(); + void handleLldbFinished(int, QProcess::ExitStatus status); + void handleLldbError(QProcess::ProcessError error); + void readLldbStandardOutput(); + void readLldbStandardError(); + void handleResponse(const QByteArray &data); + void updateAll(); + void updateLocals(); + void createFullBacktrace(); void doUpdateLocals(UpdateParameters params); + void handleContinuation(const GdbMi &data); + void refreshAll(const GdbMi &all); void refreshThreads(const GdbMi &threads); void refreshStack(const GdbMi &stack); diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index 3ca82f6dd3..72dcbb114f 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -462,7 +462,7 @@ void ThreadsHandler::updateThreads(const GdbMi &data) // } const std::vector<GdbMi> items = data["threads"].children(); - const int n = items.size(); + const int n = int(items.size()); for (int index = 0; index != n; ++index) { const GdbMi item = items[index]; const GdbMi frame = item["frame"]; diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 197677caf0..d010768c4f 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -665,7 +665,7 @@ void parseChildrenData(const WatchData &data0, const GdbMi &item, childtemplate.address = addressBase; arrayDecoder(childtemplate, mi.data(), encoding); } else { - for (int i = 0, n = children.children().size(); i != n; ++i) { + for (int i = 0, n = int(children.children().size()); i != n; ++i) { const GdbMi &child = children.children().at(i); WatchData data1 = childtemplate; data1.sortId = i; diff --git a/src/plugins/designer/codemodelhelpers.cpp b/src/plugins/designer/codemodelhelpers.cpp index 9b0bec8dcc..2d9a8b37d4 100644 --- a/src/plugins/designer/codemodelhelpers.cpp +++ b/src/plugins/designer/codemodelhelpers.cpp @@ -96,7 +96,7 @@ bool SearchFunction::visit(CPlusPlus::Function * f) if (const CPlusPlus::Name *name = f->name()) if (const CPlusPlus::Identifier *id = name->identifier()) if (id->size() == m_length) - if (!qstrncmp(m_name, id->chars(), m_length)) + if (!qstrncmp(m_name, id->chars(), uint(m_length))) m_matches.push_back(f); return true; } diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp index ab0cef6a97..69a3055421 100644 --- a/src/plugins/diffeditor/diffeditor.cpp +++ b/src/plugins/diffeditor/diffeditor.cpp @@ -32,8 +32,7 @@ #include "diffeditorconstants.h" #include "diffeditordocument.h" #include "diffeditorguicontroller.h" -#include "sidebysidediffeditorwidget.h" -#include "unifieddiffeditorwidget.h" +#include "diffview.h" #include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> @@ -44,6 +43,7 @@ #include <texteditor/displaysettings.h> #include <texteditor/marginsettings.h> +#include <utils/algorithm.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> @@ -61,8 +61,6 @@ static const char settingsGroupC[] = "DiffEditor"; static const char diffEditorTypeKeyC[] = "DiffEditorType"; -static const char sideBySideDiffEditorValueC[] = "SideBySide"; -static const char unifiedDiffEditorValueC[] = "Unified"; static const char legacySettingsGroupC[] = "Git"; static const char useDiffEditorKeyC[] = "UseDiffEditor"; @@ -204,9 +202,7 @@ DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc) : m_document(doc) , m_descriptionWidget(0) , m_stackedWidget(0) - , m_sideBySideEditor(0) - , m_unifiedEditor(0) - , m_currentEditor(0) + , m_currentViewIndex(-1) , m_guiController(0) , m_toolBar(0) , m_entriesComboBox(0) @@ -225,15 +221,11 @@ DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc) m_stackedWidget = new QStackedWidget(splitter); splitter->addWidget(m_stackedWidget); - m_sideBySideEditor = new SideBySideDiffEditorWidget(m_stackedWidget); - m_stackedWidget->addWidget(m_sideBySideEditor); - - m_unifiedEditor = new UnifiedDiffEditorWidget(m_stackedWidget); - m_stackedWidget->addWidget(m_unifiedEditor); + addView(new SideBySideView); + addView(new UnifiedView); setWidget(splitter); - DiffEditorController *control = controller(); m_guiController = new DiffEditorGuiController(control, this); @@ -254,7 +246,7 @@ DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc) slotDescriptionChanged(control->description()); slotDescriptionVisibilityChanged(); - showDiffEditor(readCurrentDiffEditorSetting()); + showDiffView(readCurrentDiffEditorSetting()); toolBar(); } @@ -283,12 +275,12 @@ Core::IDocument *DiffEditor::document() return m_document.data(); } -static QToolBar *createToolBar(const QWidget *someWidget) +static QToolBar *createToolBar(IDiffView *someView) { // Create QToolBar *toolBar = new QToolBar; toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); - const int size = someWidget->style()->pixelMetric(QStyle::PM_SmallIconSize); + const int size = someView->widget()->style()->pixelMetric(QStyle::PM_SmallIconSize); toolBar->setIconSize(QSize(size, size)); return toolBar; @@ -296,13 +288,15 @@ static QToolBar *createToolBar(const QWidget *someWidget) QWidget *DiffEditor::toolBar() { + QTC_ASSERT(!m_views.isEmpty(), return 0); + if (m_toolBar) return m_toolBar; DiffEditorController *control = controller(); // Create - m_toolBar = createToolBar(m_sideBySideEditor); + m_toolBar = createToolBar(m_views.at(0)); m_entriesComboBox = new QComboBox; m_entriesComboBox->setMinimumContentsLength(20); @@ -334,8 +328,7 @@ QWidget *DiffEditor::toolBar() m_contextSpinBoxAction = m_toolBar->addWidget(contextSpinBox); QToolButton *toggleDescription = new QToolButton(m_toolBar); - toggleDescription->setIcon( - QIcon(QLatin1String(Constants::ICON_TOP_BAR))); + toggleDescription->setIcon(QIcon(QLatin1String(Constants::ICON_TOP_BAR))); toggleDescription->setCheckable(true); toggleDescription->setChecked(m_guiController->isDescriptionVisible()); m_toggleDescriptionAction = m_toolBar->addWidget(toggleDescription); @@ -371,7 +364,7 @@ QWidget *DiffEditor::toolBar() connect(toggleDescription, &QAbstractButton::clicked, m_guiController, &DiffEditorGuiController::setDescriptionVisible); connect(m_diffEditorSwitcher, &QAbstractButton::clicked, - this, &DiffEditor::slotDiffEditorSwitched); + this, [this]() { showDiffView(nextView()); }); connect(reloadButton, &QAbstractButton::clicked, control, &DiffEditorController::requestReload); connect(control, &DiffEditorController::reloaderChanged, @@ -505,65 +498,70 @@ void DiffEditor::slotReloaderChanged() m_reloadAction->setVisible(reloader); } -void DiffEditor::slotDiffEditorSwitched() +void DiffEditor::updateDiffEditorSwitcher() { - QWidget *oldEditor = m_currentEditor; - QWidget *newEditor = 0; - if (oldEditor == m_sideBySideEditor) - newEditor = m_unifiedEditor; - else if (oldEditor == m_unifiedEditor) - newEditor = m_sideBySideEditor; - else - newEditor = readCurrentDiffEditorSetting(); + if (!m_diffEditorSwitcher) + return; - showDiffEditor(newEditor); + m_diffEditorSwitcher->setIcon(currentView()->icon()); + m_diffEditorSwitcher->setToolTip(currentView()->toolTip()); } -void DiffEditor::updateDiffEditorSwitcher() +void DiffEditor::addView(IDiffView *view) { - if (!m_diffEditorSwitcher) - return; + QTC_ASSERT(!m_views.contains(view), return); + m_views.append(view); + m_stackedWidget->addWidget(view->widget()); +} - QIcon actionIcon; - QString actionToolTip; - if (m_currentEditor == m_unifiedEditor) { - actionIcon = QIcon(QLatin1String(Constants::ICON_SIDE_BY_SIDE_DIFF)); - actionToolTip = tr("Switch to Side By Side Diff Editor"); - } else if (m_currentEditor == m_sideBySideEditor) { - actionIcon = QIcon(QLatin1String(Constants::ICON_UNIFIED_DIFF)); - actionToolTip = tr("Switch to Unified Diff Editor"); - } +IDiffView *DiffEditor::currentView() const +{ + if (m_currentViewIndex < 0) + return 0; + return m_views.at(m_currentViewIndex); +} - m_diffEditorSwitcher->setIcon(actionIcon); - m_diffEditorSwitcher->setToolTip(actionToolTip); +void DiffEditor::setCurrentView(IDiffView *view) +{ + const int pos = Utils::indexOf(m_views, [view](IDiffView *v) { return v == view; }); + QTC_ASSERT(pos >= 0 && pos < m_views.count(), return); + m_currentViewIndex = pos; } -void DiffEditor::showDiffEditor(QWidget *newEditor) +IDiffView *DiffEditor::nextView() { - if (m_currentEditor == newEditor) - return; + int pos = m_currentViewIndex + 1; + if (pos >= m_views.count()) + pos = 0; - if (m_currentEditor == m_sideBySideEditor) - m_sideBySideEditor->setDiffEditorGuiController(0); - else if (m_currentEditor == m_unifiedEditor) - m_unifiedEditor->setDiffEditorGuiController(0); + return m_views.at(pos); +} - m_currentEditor = newEditor; +void DiffEditor::showDiffView(IDiffView *newView) +{ + QTC_ASSERT(newView, return); - if (m_currentEditor == m_unifiedEditor) - m_unifiedEditor->setDiffEditorGuiController(m_guiController); - else if (m_currentEditor == m_sideBySideEditor) - m_sideBySideEditor->setDiffEditorGuiController(m_guiController); + if (currentView() == newView) + return; + + if (currentView()) // during initialization + currentView()->setDiffEditorGuiController(0); + setCurrentView(newView); + currentView()->setDiffEditorGuiController(m_guiController); - m_stackedWidget->setCurrentWidget(m_currentEditor); + m_stackedWidget->setCurrentWidget(currentView()->widget()); - writeCurrentDiffEditorSetting(m_currentEditor); + writeCurrentDiffEditorSetting(currentView()); updateDiffEditorSwitcher(); - widget()->setFocusProxy(m_currentEditor); + widget()->setFocusProxy(currentView()->widget()); } -QWidget *DiffEditor::readLegacyCurrentDiffEditorSetting() +// TODO: Remove in 3.6: +IDiffView *DiffEditor::readLegacyCurrentDiffEditorSetting() { + QTC_ASSERT(!m_views.isEmpty(), return 0); + QTC_ASSERT(m_views.count() == 2, return m_views.at(0)); + QSettings *s = Core::ICore::settings(); s->beginGroup(QLatin1String(legacySettingsGroupC)); @@ -574,43 +572,35 @@ QWidget *DiffEditor::readLegacyCurrentDiffEditorSetting() s->remove(QLatin1String(useDiffEditorKeyC)); s->endGroup(); - QWidget *currentEditor = m_sideBySideEditor; + IDiffView *currentEditor = m_views.at(0); if (!legacyEditor) - currentEditor = m_unifiedEditor; + currentEditor = m_views.at(1); - if (legacyExists && currentEditor == m_unifiedEditor) + if (legacyExists) writeCurrentDiffEditorSetting(currentEditor); return currentEditor; } -QWidget *DiffEditor::readCurrentDiffEditorSetting() +IDiffView *DiffEditor::readCurrentDiffEditorSetting() { // replace it with m_sideBySideEditor when dropping legacy stuff - QWidget *defaultEditor = readLegacyCurrentDiffEditorSetting(); + IDiffView *view = readLegacyCurrentDiffEditorSetting(); QSettings *s = Core::ICore::settings(); s->beginGroup(QLatin1String(settingsGroupC)); - const QString editorString = s->value( - QLatin1String(diffEditorTypeKeyC)).toString(); + const Core::Id id = Core::Id::fromSetting(s->value(QLatin1String(diffEditorTypeKeyC))); s->endGroup(); - if (editorString == QLatin1String(unifiedDiffEditorValueC)) - return m_unifiedEditor; - - if (editorString == QLatin1String(sideBySideDiffEditorValueC)) - return m_sideBySideEditor; - return defaultEditor; + return Utils::findOr(m_views, view, [id](IDiffView *v) { return v->id() == id; }); } -void DiffEditor::writeCurrentDiffEditorSetting(QWidget *currentEditor) +void DiffEditor::writeCurrentDiffEditorSetting(IDiffView *currentEditor) { - const QString editorString = currentEditor == m_unifiedEditor - ? QLatin1String(unifiedDiffEditorValueC) - : QLatin1String(sideBySideDiffEditorValueC); + QTC_ASSERT(currentEditor, return); QSettings *s = Core::ICore::settings(); s->beginGroup(QLatin1String(settingsGroupC)); - s->setValue(QLatin1String(diffEditorTypeKeyC), editorString); + s->setValue(QLatin1String(diffEditorTypeKeyC), currentEditor->id().toSetting()); s->endGroup(); } diff --git a/src/plugins/diffeditor/diffeditor.h b/src/plugins/diffeditor/diffeditor.h index c4c111d4f4..3a10abdbab 100644 --- a/src/plugins/diffeditor/diffeditor.h +++ b/src/plugins/diffeditor/diffeditor.h @@ -51,8 +51,7 @@ namespace Internal { class DescriptionEditorWidget; class DiffEditorDocument; class DiffEditorGuiController; -class UnifiedDiffEditorWidget; -class SideBySideDiffEditorWidget; +class IDiffView; class DiffEditor : public Core::IEditor { @@ -85,22 +84,24 @@ private slots: void slotDescriptionChanged(const QString &description); void slotDescriptionVisibilityChanged(); void slotReloaderChanged(); - void slotDiffEditorSwitched(); private: void updateEntryToolTip(); - void showDiffEditor(QWidget *newEditor); + void showDiffView(IDiffView *newEditor); void updateDiffEditorSwitcher(); - QWidget *readLegacyCurrentDiffEditorSetting(); - QWidget *readCurrentDiffEditorSetting(); - void writeCurrentDiffEditorSetting(QWidget *currentEditor); + void addView(IDiffView *view); + IDiffView *currentView() const; + void setCurrentView(IDiffView *view); + IDiffView *nextView(); + IDiffView *readLegacyCurrentDiffEditorSetting(); + IDiffView *readCurrentDiffEditorSetting(); + void writeCurrentDiffEditorSetting(IDiffView *currentEditor); QSharedPointer<DiffEditorDocument> m_document; DescriptionEditorWidget *m_descriptionWidget; QStackedWidget *m_stackedWidget; - SideBySideDiffEditorWidget *m_sideBySideEditor; - UnifiedDiffEditorWidget *m_unifiedEditor; - QWidget *m_currentEditor; + QVector<IDiffView *> m_views; + int m_currentViewIndex; DiffEditorGuiController *m_guiController; QToolBar *m_toolBar; QComboBox *m_entriesComboBox; diff --git a/src/plugins/diffeditor/diffeditor.pro b/src/plugins/diffeditor/diffeditor.pro index 801abc25c4..dd591992fc 100644 --- a/src/plugins/diffeditor/diffeditor.pro +++ b/src/plugins/diffeditor/diffeditor.pro @@ -13,6 +13,7 @@ HEADERS += diffeditor_global.h \ diffeditorreloader.h \ differ.h \ diffutils.h \ + diffview.h \ selectabletexteditorwidget.h \ sidebysidediffeditorwidget.h \ unifieddiffeditorwidget.h @@ -27,6 +28,7 @@ SOURCES += diffeditor.cpp \ diffeditorreloader.cpp \ differ.cpp \ diffutils.cpp \ + diffview.cpp \ selectabletexteditorwidget.cpp \ sidebysidediffeditorwidget.cpp \ unifieddiffeditorwidget.cpp diff --git a/src/plugins/diffeditor/diffeditor.qbs b/src/plugins/diffeditor/diffeditor.qbs index 4bf6a5d1d6..21a4600a48 100644 --- a/src/plugins/diffeditor/diffeditor.qbs +++ b/src/plugins/diffeditor/diffeditor.qbs @@ -34,6 +34,8 @@ QtcPlugin { "differ.h", "diffutils.cpp", "diffutils.h", + "diffview.cpp", + "diffview.h", "selectabletexteditorwidget.cpp", "selectabletexteditorwidget.h", "sidebysidediffeditorwidget.cpp", diff --git a/src/plugins/diffeditor/diffeditorconstants.h b/src/plugins/diffeditor/diffeditorconstants.h index 85daa92056..cb492cdd4e 100644 --- a/src/plugins/diffeditor/diffeditorconstants.h +++ b/src/plugins/diffeditor/diffeditorconstants.h @@ -41,8 +41,6 @@ const char DIFF_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("DiffEditor", "Diff Ed const char DIFF_EDITOR_MIMETYPE[] = "text/x-patch"; const char G_TOOLS_DIFF[] = "QtCreator.Group.Tools.Options"; -const char ICON_SIDE_BY_SIDE_DIFF[] = ":/diffeditor/images/sidebysidediff.png"; -const char ICON_UNIFIED_DIFF[] = ":/diffeditor/images/unifieddiff.png"; const char ICON_TOP_BAR[] = ":/diffeditor/images/topbar.png"; const char EXPAND_BRANCHES[] = "Branches: <Expand>"; diff --git a/src/plugins/diffeditor/diffview.cpp b/src/plugins/diffeditor/diffview.cpp new file mode 100644 index 0000000000..6be3133ac5 --- /dev/null +++ b/src/plugins/diffeditor/diffview.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://www.qt.io/licensing. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "diffview.h" + +#include "unifieddiffeditorwidget.h" +#include "sidebysidediffeditorwidget.h" + +#include <utils/qtcassert.h> + +namespace DiffEditor { +namespace Internal { + +QIcon IDiffView::icon() const +{ + return m_icon; +} + +QString IDiffView::toolTip() const +{ + return m_toolTip; +} + +Core::Id IDiffView::id() const +{ + return m_id; +} + +void IDiffView::setIcon(const QIcon &icon) +{ + m_icon = icon; +} + +void IDiffView::setToolTip(const QString &toolTip) +{ + m_toolTip = toolTip; +} + +void IDiffView::setId(const Core::Id &id) +{ + m_id = id; +} + +UnifiedView::UnifiedView() : m_widget(0) +{ + setId(UNIFIED_VIEW_ID); + setIcon(QIcon(QLatin1String(":/diffeditor/images/unifieddiff.png"))); + setToolTip(QCoreApplication::translate("DiffEditor::UnifiedView", "Switch to Unified Diff Editor")); +} + +QWidget *UnifiedView::widget() +{ + if (!m_widget) + m_widget = new UnifiedDiffEditorWidget; + return m_widget; +} + +void UnifiedView::setDiffEditorGuiController(DiffEditorGuiController *controller) +{ + QTC_ASSERT(m_widget, return); + m_widget->setDiffEditorGuiController(controller); +} + +SideBySideView::SideBySideView() : m_widget(0) +{ + setId(SIDE_BY_SIDE_VIEW_ID); + setIcon(QIcon(QLatin1String(":/diffeditor/images/sidebysidediff.png"))); + setToolTip(QCoreApplication::translate("DiffEditor::SideBySideView", + "Switch to Side By Side Diff Editor")); +} + +QWidget *SideBySideView::widget() +{ + if (!m_widget) + m_widget = new SideBySideDiffEditorWidget; + return m_widget; +} + +void SideBySideView::setDiffEditorGuiController(DiffEditorGuiController *controller) +{ + QTC_ASSERT(m_widget, return); + m_widget->setDiffEditorGuiController(controller); +} + +} // namespace Internal +} // namespace DiffEditor diff --git a/src/plugins/diffeditor/diffview.h b/src/plugins/diffeditor/diffview.h new file mode 100644 index 0000000000..cf46b0f433 --- /dev/null +++ b/src/plugins/diffeditor/diffview.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://www.qt.io/licensing. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef DIFFVIEW_H +#define DIFFVIEW_H + +#include <coreplugin/id.h> + +#include <QIcon> +#include <QString> +#include <QWidget> + +namespace DiffEditor { +namespace Internal { + +class DiffEditorGuiController; +class SideBySideDiffEditorWidget; +class UnifiedDiffEditorWidget; + +const char SIDE_BY_SIDE_VIEW_ID[] = "SideBySide"; +const char UNIFIED_VIEW_ID[] = "Unified"; + +class IDiffView +{ +public: + IDiffView() { } + virtual ~IDiffView() { } + + QIcon icon() const; + QString toolTip() const; + + Core::Id id() const; + virtual QWidget *widget() = 0; + virtual void setDiffEditorGuiController(DiffEditorGuiController *controller) = 0; + +protected: + void setIcon(const QIcon &icon); + void setToolTip(const QString &toolTip); + void setId(const Core::Id &id); + +private: + QIcon m_icon; + QString m_toolTip; + Core::Id m_id; +}; + +class UnifiedView : public IDiffView { +public: + UnifiedView(); + + QWidget *widget(); + void setDiffEditorGuiController(DiffEditorGuiController *controller); + +private: + UnifiedDiffEditorWidget *m_widget; +}; + +class SideBySideView : public IDiffView { +public: + SideBySideView(); + + QWidget *widget(); + void setDiffEditorGuiController(DiffEditorGuiController *controller); + +private: + SideBySideDiffEditorWidget *m_widget; +}; + +} // namespace Internal +} // namespace DiffEditor + +#endif // DIFFVIEW_H diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 453d8da465..2f2dc7ca81 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -57,6 +57,7 @@ #include <projectexplorer/projectexplorerconstants.h> +#include <texteditor/displaysettings.h> #include <texteditor/textdocumentlayout.h> #include <texteditor/texteditor.h> #include <texteditor/textmark.h> @@ -126,9 +127,9 @@ public: , m_eventFilter(0) , m_lastMessageLevel(MessageMode) { - connect(m_edit, SIGNAL(textEdited(QString)), SLOT(changed())); - connect(m_edit, SIGNAL(cursorPositionChanged(int,int)), SLOT(changed())); - connect(m_edit, SIGNAL(selectionChanged()), SLOT(changed())); + connect(m_edit, &QLineEdit::textEdited, this, &MiniBuffer::changed); + connect(m_edit, &QLineEdit::cursorPositionChanged, this, &MiniBuffer::changed); + connect(m_edit, &QLineEdit::selectionChanged, this, &MiniBuffer::changed); m_label->setTextInteractionFlags(Qt::TextSelectableByMouse); addWidget(m_label); @@ -136,7 +137,7 @@ public: m_hideTimer.setSingleShot(true); m_hideTimer.setInterval(8000); - connect(&m_hideTimer, SIGNAL(timeout()), SLOT(hide())); + connect(&m_hideTimer, &QTimer::timeout, this, &QWidget::hide); } void setContents(const QString &contents, int cursorPos, int anchorPos, @@ -212,7 +213,7 @@ public: signals: void edited(const QString &text, int cursorPos, int anchorPos); -private slots: +private: void changed() { const int cursorPos = m_edit->cursorPosition(); @@ -222,7 +223,6 @@ private slots: emit edited(m_edit->text(), cursorPos, anchorPos); } -private: QLabel *m_label; QLineEdit *m_edit; QObject *m_eventFilter; @@ -245,12 +245,18 @@ public: m_timerUpdate.setSingleShot(true); m_timerUpdate.setInterval(0); - connect(&m_timerUpdate, SIGNAL(timeout()), SLOT(followEditorLayout())); - updateOnSignal(m_editor, SIGNAL(cursorPositionChanged())); - updateOnSignal(m_editor->verticalScrollBar(), SIGNAL(valueChanged(int))); - updateOnSignal(m_editor->document(), SIGNAL(contentsChanged())); - updateOnSignal(TextEditorSettings::instance(), - SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings))); + connect(&m_timerUpdate, &QTimer::timeout, + this, &RelativeNumbersColumn::followEditorLayout); + + auto start = static_cast<void(QTimer::*)()>(&QTimer::start); + connect(m_editor, &QPlainTextEdit::cursorPositionChanged, + &m_timerUpdate, start); + connect(m_editor->verticalScrollBar(), &QAbstractSlider::valueChanged, + &m_timerUpdate, start); + connect(m_editor->document(), &QTextDocument::contentsChanged, + &m_timerUpdate, start); + connect(TextEditorSettings::instance(), &TextEditorSettings::displaySettingsChanged, + &m_timerUpdate, start); m_editor->installEventFilter(this); @@ -339,11 +345,6 @@ private slots: update(); } - void updateOnSignal(QObject *object, const char *signal) - { - connect(object, signal, &m_timerUpdate, SLOT(start())); - } - private: int m_currentPos; int m_lineSpacing; @@ -458,14 +459,14 @@ QWidget *FakeVimOptionPage::widget() m_group.insert(theFakeVimSetting(ConfigRelativeNumber), m_ui.checkBoxRelativeNumber); - connect(m_ui.pushButtonCopyTextEditorSettings, SIGNAL(clicked()), - SLOT(copyTextEditorSettings())); - connect(m_ui.pushButtonSetQtStyle, SIGNAL(clicked()), - SLOT(setQtStyle())); - connect(m_ui.pushButtonSetPlainStyle, SIGNAL(clicked()), - SLOT(setPlainStyle())); - connect(m_ui.checkBoxReadVimRc, SIGNAL(stateChanged(int)), - SLOT(updateVimRcWidgets())); + connect(m_ui.pushButtonCopyTextEditorSettings, &QAbstractButton::clicked, + this, &FakeVimOptionPage::copyTextEditorSettings); + connect(m_ui.pushButtonSetQtStyle, &QAbstractButton::clicked, + this, &FakeVimOptionPage::setQtStyle); + connect(m_ui.pushButtonSetPlainStyle, &QAbstractButton::clicked, + this, &FakeVimOptionPage::setPlainStyle); + connect(m_ui.checkBoxReadVimRc, &QCheckBox::stateChanged, + this, &FakeVimOptionPage::updateVimRcWidgets); updateVimRcWidgets(); } @@ -1015,7 +1016,6 @@ private slots: void fold(int depth, bool fold); void foldGoTo(int count, bool current); void jumpToGlobalMark(QChar mark, bool backTickMode, const QString &fileName); - void showSettingsDialog(); void maybeReadVimRc(); void disableBlockSelection(); void setBlockSelection(const QTextCursor&); @@ -1039,7 +1039,7 @@ private slots: void handleDelayedQuitAll(bool forced); void handleDelayedQuit(bool forced, Core::IEditor *editor); - void userActionTriggered(); + void userActionTriggered(int key); void switchToFile(int n); int currentFile() const; @@ -1157,8 +1157,8 @@ FakeVimPluginPrivate::~FakeVimPluginPrivate() void FakeVimPluginPrivate::onCoreAboutToClose() { // Don't attach to editors anymore. - disconnect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), - this, SLOT(editorOpened(Core::IEditor*))); + disconnect(EditorManager::instance(), &EditorManager::editorOpened, + this, &FakeVimPluginPrivate::editorOpened); } void FakeVimPluginPrivate::aboutToShutdown() @@ -1205,41 +1205,41 @@ bool FakeVimPluginPrivate::initialize() const Id base = "FakeVim.UserAction"; for (int i = 1; i < 10; ++i) { - QAction *act = new QAction(this); + auto act = new QAction(this); act->setText(Tr::tr("Execute User Action #%1").arg(i)); - act->setData(i); cmd = ActionManager::registerAction(act, base.withSuffix(i), globalcontext); cmd->setDefaultKeySequence(QKeySequence((UseMacShortcuts ? Tr::tr("Meta+V,%1") : Tr::tr("Alt+V,%1")).arg(i))); - connect(act, SIGNAL(triggered()), SLOT(userActionTriggered())); + connect(act, &QAction::triggered, this, [this, i] { userActionTriggered(i); }); } - connect(ICore::instance(), SIGNAL(coreAboutToClose()), this, SLOT(onCoreAboutToClose())); + connect(ICore::instance(), &ICore::coreAboutToClose, + this, &FakeVimPluginPrivate::onCoreAboutToClose); // EditorManager - connect(EditorManager::instance(), SIGNAL(editorAboutToClose(Core::IEditor*)), - this, SLOT(editorAboutToClose(Core::IEditor*))); - connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), - this, SLOT(editorOpened(Core::IEditor*))); - - connect(DocumentManager::instance(), SIGNAL(allDocumentsRenamed(QString,QString)), - this, SLOT(allDocumentsRenamed(QString,QString))); - connect(DocumentManager::instance(), SIGNAL(documentRenamed(Core::IDocument*,QString,QString)), - this, SLOT(documentRenamed(Core::IDocument*,QString,QString))); - - connect(theFakeVimSetting(ConfigUseFakeVim), SIGNAL(valueChanged(QVariant)), - this, SLOT(setUseFakeVim(QVariant))); - connect(theFakeVimSetting(ConfigReadVimRc), SIGNAL(valueChanged(QVariant)), - this, SLOT(maybeReadVimRc())); - connect(theFakeVimSetting(ConfigVimRcPath), SIGNAL(valueChanged(QVariant)), - this, SLOT(maybeReadVimRc())); - connect(theFakeVimSetting(ConfigRelativeNumber), SIGNAL(valueChanged(QVariant)), - this, SLOT(setShowRelativeLineNumbers(QVariant))); + connect(EditorManager::instance(), &EditorManager::editorAboutToClose, + this, &FakeVimPluginPrivate::editorAboutToClose); + connect(EditorManager::instance(), &EditorManager::editorOpened, + this, &FakeVimPluginPrivate::editorOpened); + + connect(DocumentManager::instance(), &DocumentManager::allDocumentsRenamed, + this, &FakeVimPluginPrivate::allDocumentsRenamed); + connect(DocumentManager::instance(), &DocumentManager::documentRenamed, + this, &FakeVimPluginPrivate::documentRenamed); + + connect(theFakeVimSetting(ConfigUseFakeVim), &Utils::SavedAction::valueChanged, + this, &FakeVimPluginPrivate::setUseFakeVim); + connect(theFakeVimSetting(ConfigReadVimRc), &Utils::SavedAction::valueChanged, + this, &FakeVimPluginPrivate::maybeReadVimRc); + connect(theFakeVimSetting(ConfigVimRcPath), &Utils::SavedAction::valueChanged, + this, &FakeVimPluginPrivate::maybeReadVimRc); + connect(theFakeVimSetting(ConfigRelativeNumber), &Utils::SavedAction::valueChanged, + this, &FakeVimPluginPrivate::setShowRelativeLineNumbers); // Delayed operations. - connect(this, SIGNAL(delayedQuitRequested(bool,Core::IEditor*)), - this, SLOT(handleDelayedQuit(bool,Core::IEditor*)), Qt::QueuedConnection); - connect(this, SIGNAL(delayedQuitAllRequested(bool)), - this, SLOT(handleDelayedQuitAll(bool)), Qt::QueuedConnection); + connect(this, &FakeVimPluginPrivate::delayedQuitRequested, + this, &FakeVimPluginPrivate::handleDelayedQuit, Qt::QueuedConnection); + connect(this, &FakeVimPluginPrivate::delayedQuitAllRequested, + this, &FakeVimPluginPrivate::handleDelayedQuitAll, Qt::QueuedConnection); // Vimrc can break test so don't source it if running tests. if (!ExtensionSystem::PluginManager::testRunRequested()) @@ -1249,14 +1249,8 @@ bool FakeVimPluginPrivate::initialize() return true; } -void FakeVimPluginPrivate::userActionTriggered() +void FakeVimPluginPrivate::userActionTriggered(int key) { - QAction *act = qobject_cast<QAction *>(sender()); - if (!act) - return; - const int key = act->data().toInt(); - if (!key) - return; IEditor *editor = EditorManager::currentEditor(); FakeVimHandler *handler = m_editorToHandler[editor]; if (handler) { @@ -1277,10 +1271,10 @@ void FakeVimPluginPrivate::createRelativeNumberWidget(IEditor *editor) { if (TextEditorWidget *textEditor = qobject_cast<TextEditorWidget *>(editor->widget())) { RelativeNumbersColumn *relativeNumbers = new RelativeNumbersColumn(textEditor); - connect(theFakeVimSetting(ConfigRelativeNumber), SIGNAL(valueChanged(QVariant)), - relativeNumbers, SLOT(deleteLater())); - connect(theFakeVimSetting(ConfigUseFakeVim), SIGNAL(valueChanged(QVariant)), - relativeNumbers, SLOT(deleteLater())); + connect(theFakeVimSetting(ConfigRelativeNumber), &Utils::SavedAction::valueChanged, + relativeNumbers, &QObject::deleteLater); + connect(theFakeVimSetting(ConfigUseFakeVim), &Utils::SavedAction::valueChanged, + relativeNumbers, &QObject::deleteLater); relativeNumbers->show(); } } @@ -1387,11 +1381,6 @@ void FakeVimPluginPrivate::maybeReadVimRc() //qDebug() << theFakeVimSetting(ConfigShiftWidth)->value(); } -void FakeVimPluginPrivate::showSettingsDialog() -{ - ICore::showOptionsDialog(SETTINGS_CATEGORY, SETTINGS_ID); -} - void FakeVimPluginPrivate::triggerAction(Id id) { Command *cmd = ActionManager::command(id); @@ -1761,54 +1750,54 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor) new DeferredDeleter(widget, handler); m_editorToHandler[editor] = handler; - connect(handler, SIGNAL(extraInformationChanged(QString)), - SLOT(showExtraInformation(QString))); - connect(handler, SIGNAL(commandBufferChanged(QString,int,int,int,QObject*)), - SLOT(showCommandBuffer(QString,int,int,int,QObject*))); - connect(handler, SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)), - SLOT(changeSelection(QList<QTextEdit::ExtraSelection>))); - connect(handler, SIGNAL(highlightMatches(QString)), - SLOT(highlightMatches(QString))); - connect(handler, SIGNAL(moveToMatchingParenthesis(bool*,bool*,QTextCursor*)), - SLOT(moveToMatchingParenthesis(bool*,bool*,QTextCursor*)), Qt::DirectConnection); - connect(handler, SIGNAL(indentRegion(int,int,QChar)), - SLOT(indentRegion(int,int,QChar))); - connect(handler, SIGNAL(checkForElectricCharacter(bool*,QChar)), - SLOT(checkForElectricCharacter(bool*,QChar)), Qt::DirectConnection); - connect(handler, SIGNAL(requestDisableBlockSelection()), - SLOT(disableBlockSelection())); - connect(handler, SIGNAL(requestSetBlockSelection(QTextCursor)), - SLOT(setBlockSelection(QTextCursor))); - connect(handler, SIGNAL(requestBlockSelection(QTextCursor*)), - SLOT(blockSelection(QTextCursor*)), Qt::DirectConnection); - connect(handler, SIGNAL(requestHasBlockSelection(bool*)), - SLOT(hasBlockSelection(bool*)), Qt::DirectConnection); - connect(handler, SIGNAL(completionRequested()), - SLOT(triggerCompletions())); - connect(handler, SIGNAL(simpleCompletionRequested(QString,bool)), - SLOT(triggerSimpleCompletions(QString,bool))); - connect(handler, SIGNAL(windowCommandRequested(QString,int)), - SLOT(windowCommand(QString,int))); - connect(handler, SIGNAL(findRequested(bool)), - SLOT(find(bool))); - connect(handler, SIGNAL(findNextRequested(bool)), - SLOT(findNext(bool))); - connect(handler, SIGNAL(foldToggle(int)), - SLOT(foldToggle(int))); - connect(handler, SIGNAL(foldAll(bool)), - SLOT(foldAll(bool))); - connect(handler, SIGNAL(fold(int,bool)), - SLOT(fold(int,bool))); - connect(handler, SIGNAL(foldGoTo(int,bool)), - SLOT(foldGoTo(int,bool))); - connect(handler, SIGNAL(jumpToGlobalMark(QChar,bool,QString)), - SLOT(jumpToGlobalMark(QChar,bool,QString))); - - connect(handler, SIGNAL(handleExCommandRequested(bool*,ExCommand)), - SLOT(handleExCommand(bool*,ExCommand)), Qt::DirectConnection); - - connect(ICore::instance(), SIGNAL(saveSettingsRequested()), - SLOT(writeSettings())); + connect(handler, &FakeVimHandler::extraInformationChanged, + this, &FakeVimPluginPrivate::showExtraInformation); + connect(handler, &FakeVimHandler::commandBufferChanged, + this, &FakeVimPluginPrivate::showCommandBuffer); + connect(handler, &FakeVimHandler::selectionChanged, + this, &FakeVimPluginPrivate::changeSelection); + connect(handler, &FakeVimHandler::highlightMatches, + this, &FakeVimPluginPrivate::highlightMatches); + connect(handler, &FakeVimHandler::moveToMatchingParenthesis, + this, &FakeVimPluginPrivate::moveToMatchingParenthesis, Qt::DirectConnection); + connect(handler, &FakeVimHandler::indentRegion, + this, &FakeVimPluginPrivate::indentRegion); + connect(handler, &FakeVimHandler::checkForElectricCharacter, + this, &FakeVimPluginPrivate::checkForElectricCharacter, Qt::DirectConnection); + connect(handler, &FakeVimHandler::requestDisableBlockSelection, + this, &FakeVimPluginPrivate::disableBlockSelection); + connect(handler, &FakeVimHandler::requestSetBlockSelection, + this, &FakeVimPluginPrivate::setBlockSelection); + connect(handler, &FakeVimHandler::requestBlockSelection, + this, &FakeVimPluginPrivate::blockSelection, Qt::DirectConnection); + connect(handler, &FakeVimHandler::requestHasBlockSelection, + this, &FakeVimPluginPrivate::hasBlockSelection, Qt::DirectConnection); + connect(handler, &FakeVimHandler::completionRequested, + this, &FakeVimPluginPrivate::triggerCompletions); + connect(handler, &FakeVimHandler::simpleCompletionRequested, + this, &FakeVimPluginPrivate::triggerSimpleCompletions); + connect(handler, &FakeVimHandler::windowCommandRequested, + this, &FakeVimPluginPrivate::windowCommand); + connect(handler, &FakeVimHandler::findRequested, + this, &FakeVimPluginPrivate::find); + connect(handler, &FakeVimHandler::findNextRequested, + this, &FakeVimPluginPrivate::findNext); + connect(handler, &FakeVimHandler::foldToggle, + this, &FakeVimPluginPrivate::foldToggle); + connect(handler, &FakeVimHandler::foldAll, + this, &FakeVimPluginPrivate::foldAll); + connect(handler, &FakeVimHandler::fold, + this, &FakeVimPluginPrivate::fold); + connect(handler, &FakeVimHandler::foldGoTo, + this, &FakeVimPluginPrivate::foldGoTo); + connect(handler, &FakeVimHandler::jumpToGlobalMark, + this, &FakeVimPluginPrivate::jumpToGlobalMark); + + connect(handler, &FakeVimHandler::handleExCommandRequested, + this, &FakeVimPluginPrivate::handleExCommand, Qt::DirectConnection); + + connect(ICore::instance(), &ICore::saveSettingsRequested, + this, &FakeVimPluginPrivate::writeSettings); handler->setCurrentFileName(editor->document()->filePath().toString()); handler->installEventFilter(); @@ -2012,7 +2001,7 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd) } else if (cmd.matches(_("se"), _("set"))) { if (cmd.args.isEmpty()) { // :se[t] - showSettingsDialog(); + ICore::showOptionsDialog(SETTINGS_ID); } else if (cmd.args == _("ic") || cmd.args == _("ignorecase")) { // :set nc setActionChecked(Core::Constants::CASE_SENSITIVE, false); diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index 06fc7418cc..32601b4725 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -374,8 +374,7 @@ void GerritPlugin::openView() while (!m_parameters->isValid()) { Core::AsynchronousMessageBox::warning(tr("Error"), tr("Invalid Gerrit configuration. Host, user and ssh binary are mandatory.")); - const Id group = VcsBase::Constants::VCS_SETTINGS_CATEGORY; - if (!ICore::showOptionsDialog(group, "Gerrit")) + if (!ICore::showOptionsDialog("Gerrit")) return; } GerritDialog *gd = new GerritDialog(m_parameters, ICore::mainWindow()); diff --git a/src/plugins/git/gerrit/gerritpushdialog.ui b/src/plugins/git/gerrit/gerritpushdialog.ui index 692cc3a316..806ea80a4a 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.ui +++ b/src/plugins/git/gerrit/gerritpushdialog.ui @@ -48,10 +48,13 @@ <property name="orientation"> <enum>Qt::Vertical</enum> </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>40</height> + <height>6</height> </size> </property> </spacer> diff --git a/src/plugins/git/gitsubmiteditor.cpp b/src/plugins/git/gitsubmiteditor.cpp index aac3ccabee..230751b128 100644 --- a/src/plugins/git/gitsubmiteditor.cpp +++ b/src/plugins/git/gitsubmiteditor.cpp @@ -276,7 +276,7 @@ QString GitSubmitEditor::amendSHA1() const QByteArray GitSubmitEditor::fileContents() const { - const QString &text = submitEditorWidget()->descriptionText(); + const QString &text = description(); // Do the encoding convert, When use user-defined encoding // e.g. git config --global i18n.commitencoding utf-8 diff --git a/src/plugins/git/settingspage.ui b/src/plugins/git/settingspage.ui index c546712093..0fb58a1943 100644 --- a/src/plugins/git/settingspage.ui +++ b/src/plugins/git/settingspage.ui @@ -139,6 +139,9 @@ <string>Gitk</string> </property> <layout class="QFormLayout" name="formLayout_2"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="gitkOptionsLabel"> <property name="text"> diff --git a/src/plugins/mercurial/optionspage.ui b/src/plugins/mercurial/optionspage.ui index 2a763c596b..1b329ce6f7 100644 --- a/src/plugins/mercurial/optionspage.ui +++ b/src/plugins/mercurial/optionspage.ui @@ -20,6 +20,9 @@ <string>Configuration</string> </property> <layout class="QFormLayout" name="formLayout_3"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="mercurialCommandLabel"> <property name="text"> @@ -39,6 +42,9 @@ <string>User</string> </property> <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="defaultUsernameLabel"> <property name="toolTip"> diff --git a/src/plugins/projectexplorer/configtaskhandler.cpp b/src/plugins/projectexplorer/configtaskhandler.cpp index 84eda58ff5..c4fec04b5f 100644 --- a/src/plugins/projectexplorer/configtaskhandler.cpp +++ b/src/plugins/projectexplorer/configtaskhandler.cpp @@ -42,9 +42,8 @@ using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; -ConfigTaskHandler::ConfigTaskHandler(const Task &pattern, Core::Id group, Core::Id page) : +ConfigTaskHandler::ConfigTaskHandler(const Task &pattern, Core::Id page) : m_pattern(pattern), - m_targetGroup(group), m_targetPage(page) { } @@ -57,7 +56,7 @@ bool ConfigTaskHandler::canHandle(const Task &task) const void ConfigTaskHandler::handle(const Task &task) { Q_UNUSED(task); - Core::ICore::showOptionsDialog(m_targetGroup, m_targetPage); + Core::ICore::showOptionsDialog(m_targetPage); } QAction *ConfigTaskHandler::createAction(QObject *parent) const diff --git a/src/plugins/projectexplorer/configtaskhandler.h b/src/plugins/projectexplorer/configtaskhandler.h index 08eb453f28..4de3b8c49f 100644 --- a/src/plugins/projectexplorer/configtaskhandler.h +++ b/src/plugins/projectexplorer/configtaskhandler.h @@ -43,7 +43,7 @@ class ConfigTaskHandler : public ITaskHandler Q_OBJECT public: - ConfigTaskHandler(const Task &pattern, Core::Id group, Core::Id page); + ConfigTaskHandler(const Task &pattern, Core::Id page); bool canHandle(const Task &task) const; void handle(const Task &task); @@ -51,8 +51,6 @@ public: private: const Task m_pattern; - - const Core::Id m_targetGroup; const Core::Id m_targetPage; }; diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.ui b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.ui index dfffa79cff..93ec664d4b 100644 --- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.ui +++ b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.ui @@ -72,6 +72,9 @@ <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> <layout class="QFormLayout" name="formLayout_2"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="deviceNameLabel"> <property name="text"> diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h index d6bafffc7a..ff7389d088 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h @@ -49,6 +49,7 @@ class JsonWizardFactory; class JsonWizardPageFactory; class JsonWizardGeneratorFactory; class ProjectExplorerPlugin; +class ProjectExplorerPluginPrivate; // Documentation inside. class PROJECTEXPLORER_EXPORT JsonWizardFactory : public Core::IWizardFactory @@ -116,6 +117,7 @@ private: static int m_verbose; friend class ProjectExplorerPlugin; + friend class ProjectExplorerPluginPrivate; }; } //namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp index 2d6c32d286..19297939e8 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp @@ -181,6 +181,10 @@ Utils::WizardPage *ProjectPageFactory::create(JsonWizard *wizard, Core::Id typeI JsonProjectPage *page = new JsonProjectPage; + QVariantMap tmp = data.toMap(); + QString description = tmp.value(QLatin1String("trDescription")).toString(); + page->setDescription(description); + return page; } @@ -189,9 +193,9 @@ bool ProjectPageFactory::validateData(Core::Id typeId, const QVariant &data, QSt Q_UNUSED(errorMessage); QTC_ASSERT(canCreate(typeId), return false); - if (!data.isNull() && (data.type() != QVariant::Map || !data.toMap().isEmpty())) { + if (data.isNull() || data.type() != QVariant::Map) { *errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", - "\"data\" for a \"Project\" page needs to be unset or an empty object."); + "\"data\" must be a JSON object for \"Project\" pages."); return false; } diff --git a/src/plugins/projectexplorer/kitchooser.cpp b/src/plugins/projectexplorer/kitchooser.cpp index 14ec8c5f90..b597d59166 100644 --- a/src/plugins/projectexplorer/kitchooser.cpp +++ b/src/plugins/projectexplorer/kitchooser.cpp @@ -67,8 +67,7 @@ KitChooser::KitChooser(QWidget *parent) : void KitChooser::onManageButtonClicked() { - Core::ICore::showOptionsDialog(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - Constants::KITS_SETTINGS_PAGE_ID, this); + Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, this); } void KitChooser::onCurrentIndexChanged(int index) diff --git a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp index 3ee0c42f02..1004c704c9 100644 --- a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp @@ -215,9 +215,7 @@ void ToolChainInformationConfigWidget::toolChainUpdated(ToolChain *tc) void ToolChainInformationConfigWidget::manageToolChains() { - ICore::showOptionsDialog(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - Constants::TOOLCHAIN_SETTINGS_PAGE_ID, - buttonWidget()); + ICore::showOptionsDialog(Constants::TOOLCHAIN_SETTINGS_PAGE_ID, buttonWidget()); } void ToolChainInformationConfigWidget::currentToolChainChanged(int idx) @@ -379,9 +377,7 @@ QWidget *DeviceInformationConfigWidget::buttonWidget() const void DeviceInformationConfigWidget::manageDevices() { - ICore::showOptionsDialog(Constants::DEVICE_SETTINGS_CATEGORY, - Constants::DEVICE_SETTINGS_PAGE_ID, - buttonWidget()); + ICore::showOptionsDialog(Constants::DEVICE_SETTINGS_PAGE_ID, buttonWidget()); } void DeviceInformationConfigWidget::modelAboutToReset() diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 2d928926d8..55afb59911 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -193,6 +193,8 @@ static Kit *currentKit() class ProjectExplorerPluginPrivate : public QObject { + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::ProjectExplorerPlugin) + public: ProjectExplorerPluginPrivate(); @@ -211,6 +213,83 @@ public: void updateDeployActions(); void updateRunWithoutDeployMenu(); + void buildQueueFinished(bool success); + + void buildStateChanged(ProjectExplorer::Project * pro); + void buildProjectOnly(); + void handleBuildProject(); + void buildProjectContextMenu(); + void buildSession(); + void rebuildProjectOnly(); + void rebuildProject(); + void rebuildProjectContextMenu(); + void rebuildSession(); + void deployProjectOnly(); + void deployProject(); + void deployProjectContextMenu(); + void deploySession(); + void cleanProjectOnly(); + void cleanProject(); + void cleanProjectContextMenu(); + void cleanSession(); + void cancelBuild(); + void loadAction(); + void handleUnloadProject(); + void unloadProjectContextMenu(); + void closeAllProjects(); + void newProject(); + void showSessionManager(); + void updateSessionMenu(); + void setSession(QAction *action); + + void determineSessionToRestoreAtStartup(); + void restoreSession(); + void loadSession(const QString &session); + void handleRunProject(); + void runProjectContextMenu(); + void runProjectWithoutDeploy(); + void savePersistentSettings(); + + void addNewFile(); + void handleAddExistingFiles(); + void addExistingDirectory(); + void addNewSubproject(); + void removeProject(); + void openFile(); + void searchOnFileSystem(); + void showInGraphicalShell(); + void removeFile(); + void deleteFile(); + void handleRenameFile(); + void handleSetStartupProject(); + void setStartupProject(ProjectExplorer::Project *project); + + void updateRecentProjectMenu(); + void clearRecentProjects(); + void openRecentProject(); + void updateUnloadProjectMenu(); + void openTerminalHere(); + + void invalidateProject(ProjectExplorer::Project *project); + + void projectAdded(ProjectExplorer::Project *pro); + void projectRemoved(ProjectExplorer::Project *pro); + void projectDisplayNameChanged(ProjectExplorer::Project *pro); + void startupProjectChanged(); // Calls updateRunAction + void activeTargetChanged(); + void activeRunConfigurationChanged(); + + void slotUpdateRunActions(); + + void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode); + void loadCustomWizards(); + + void updateWelcomePage(); + + void handleRunControlFinished(); + void runConfigurationConfigurationFinished(); + +public: QMenu *m_sessionMenu; QMenu *m_openWithMenu; @@ -352,6 +431,11 @@ ProjectExplorerPlugin *ProjectExplorerPlugin::instance() return m_instance; } +static void updateActions() +{ + dd->updateActions(); +} + bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error) { Q_UNUSED(error); @@ -405,42 +489,41 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er addAutoReleasedObject(new TaskHub); - connect(ICore::instance(), SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards())); + connect(ICore::instance(), &ICore::newItemsDialogRequested, + dd, &ProjectExplorerPluginPrivate::loadCustomWizards); dd->m_welcomePage = new ProjectWelcomePage; - connect(dd->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager())); + connect(dd->m_welcomePage, &ProjectWelcomePage::manageSessions, + dd, &ProjectExplorerPluginPrivate::showSessionManager); addObject(dd->m_welcomePage); - QObject *sessionManager = new SessionManager(this); - - connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)), - this, SIGNAL(fileListChanged())); - connect(sessionManager, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)), - this, SLOT(invalidateProject(ProjectExplorer::Project*))); - connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)), - this, SIGNAL(fileListChanged())); - connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)), - this, SLOT(projectAdded(ProjectExplorer::Project*))); - connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)), - this, SLOT(projectRemoved(ProjectExplorer::Project*))); - connect(sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), - this, SLOT(startupProjectChanged())); - connect(sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)), - this, SLOT(projectDisplayNameChanged(ProjectExplorer::Project*))); - connect(sessionManager, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)), - this, SLOT(updateActions())); - connect(sessionManager, SIGNAL(sessionLoaded(QString)), - this, SLOT(updateActions())); - connect(sessionManager, SIGNAL(sessionLoaded(QString)), - this, SLOT(updateWelcomePage())); + auto sessionManager = new SessionManager(this); + + connect(sessionManager, &SessionManager::projectAdded, + this, &ProjectExplorerPlugin::fileListChanged); + connect(sessionManager, &SessionManager::aboutToRemoveProject, + dd, &ProjectExplorerPluginPrivate::invalidateProject); + connect(sessionManager, &SessionManager::projectRemoved, + this, &ProjectExplorerPlugin::fileListChanged); + connect(sessionManager, &SessionManager::projectAdded, + dd, &ProjectExplorerPluginPrivate::projectAdded); + connect(sessionManager, &SessionManager::projectRemoved, + dd, &ProjectExplorerPluginPrivate::projectRemoved); + connect(sessionManager, &SessionManager::startupProjectChanged, + dd, &ProjectExplorerPluginPrivate::startupProjectChanged); + connect(sessionManager, &SessionManager::projectDisplayNameChanged, + dd, &ProjectExplorerPluginPrivate::projectDisplayNameChanged); + connect(sessionManager, &SessionManager::dependencyChanged, updateActions); + connect(sessionManager, &SessionManager::sessionLoaded, updateActions); + connect(sessionManager, &SessionManager::sessionLoaded, + dd, &ProjectExplorerPluginPrivate::updateWelcomePage); ProjectTree *tree = new ProjectTree(this); connect(tree, &ProjectTree::currentProjectChanged, dd, &ProjectExplorerPluginPrivate::updateContextMenuActions); connect(tree, &ProjectTree::currentNodeChanged, dd, &ProjectExplorerPluginPrivate::updateContextMenuActions); - connect(tree, &ProjectTree::currentProjectChanged, - dd, &ProjectExplorerPluginPrivate::updateActions); + connect(tree, &ProjectTree::currentProjectChanged, updateActions); addAutoReleasedObject(new CustomWizardMetaFactory<CustomProjectWizard>(IWizardFactory::ProjectWizard)); addAutoReleasedObject(new CustomWizardMetaFactory<CustomWizard>(IWizardFactory::FileWizard)); @@ -471,19 +554,18 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er addAutoReleasedObject(new VcsAnnotateTaskHandler); addAutoReleasedObject(new RemoveTaskHandler); addAutoReleasedObject(new ConfigTaskHandler(Task::compilerMissingTask(), - Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, Constants::KITS_SETTINGS_PAGE_ID)); addAutoReleasedObject(new CoreListener); dd->m_outputPane = new AppOutputPane; addAutoReleasedObject(dd->m_outputPane); - connect(SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), - dd->m_outputPane, SLOT(projectRemoved())); + connect(SessionManager::instance(), &SessionManager::projectRemoved, + dd->m_outputPane, &AppOutputPane::projectRemoved); - connect(dd->m_outputPane, SIGNAL(runControlStarted(ProjectExplorer::RunControl*)), - this, SIGNAL(runControlStarted(ProjectExplorer::RunControl*))); - connect(dd->m_outputPane, SIGNAL(runControlFinished(ProjectExplorer::RunControl*)), - this, SIGNAL(runControlFinished(ProjectExplorer::RunControl*))); + connect(dd->m_outputPane, &AppOutputPane::runControlStarted, + this, &ProjectExplorerPlugin::runControlStarted); + connect(dd->m_outputPane, &AppOutputPane::runControlFinished, + dd, &ProjectExplorerPluginPrivate::handleRunControlFinished); addAutoReleasedObject(new AllProjectsFilter); addAutoReleasedObject(new CurrentProjectFilter); @@ -639,8 +721,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_openWithMenu = openWith->menu(); dd->m_openWithMenu->setTitle(tr("Open With")); - connect(dd->m_openWithMenu, SIGNAL(triggered(QAction*)), - DocumentManager::instance(), SLOT(executeOpenWithMenuAction(QAction*))); + connect(dd->m_openWithMenu, &QMenu::triggered, + DocumentManager::instance(), &DocumentManager::executeOpenWithMenuAction); // // Separators @@ -713,8 +795,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mrecent->menu()->setTitle(tr("Recent P&rojects")); mrecent->setOnAllDisabledBehavior(ActionContainer::Show); mfile->addMenu(mrecent, Core::Constants::G_FILE_OPEN); - connect(mfile->menu(), SIGNAL(aboutToShow()), - this, SLOT(updateRecentProjectMenu())); + connect(mfile->menu(), &QMenu::aboutToShow, + dd, &ProjectExplorerPluginPrivate::updateRecentProjectMenu); // session menu ActionContainer *msession = ActionManager::createMenu(Constants::M_SESSION); @@ -722,8 +804,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er msession->setOnAllDisabledBehavior(ActionContainer::Show); mfile->addMenu(msession, Core::Constants::G_FILE_OPEN); dd->m_sessionMenu = msession->menu(); - connect(mfile->menu(), SIGNAL(aboutToShow()), - this, SLOT(updateSessionMenu())); + connect(mfile->menu(), &QMenu::aboutToShow, + dd, &ProjectExplorerPluginPrivate::updateSessionMenu); // session manager action dd->m_sessionManagerAction = new QAction(tr("Session Manager..."), this); @@ -745,8 +827,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er munload->menu()->setTitle(tr("Close Project")); munload->setOnAllDisabledBehavior(ActionContainer::Show); mfile->addMenu(munload, Core::Constants::G_FILE_PROJECT); - connect(mfile->menu(), SIGNAL(aboutToShow()), - this, SLOT(updateUnloadProjectMenu())); + connect(mfile->menu(), &QMenu::aboutToShow, + dd, &ProjectExplorerPluginPrivate::updateUnloadProjectMenu); // unload session action dd->m_closeAllProjects = new QAction(tr("Close All Projects and Editors"), this); @@ -990,13 +1072,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_projectSelectorAction->setEnabled(false); QWidget *mainWindow = ICore::mainWindow(); dd->m_targetSelector = new MiniProjectTargetSelector(dd->m_projectSelectorAction, mainWindow); - connect(dd->m_projectSelectorAction, SIGNAL(triggered()), dd->m_targetSelector, SLOT(show())); + connect(dd->m_projectSelectorAction, &QAction::triggered, dd->m_targetSelector, &QWidget::show); ModeManager::addProjectSelector(dd->m_projectSelectorAction); dd->m_projectSelectorActionMenu = new QAction(this); dd->m_projectSelectorActionMenu->setEnabled(false); dd->m_projectSelectorActionMenu->setText(tr("Open Build and Run Kit Selector...")); - connect(dd->m_projectSelectorActionMenu, SIGNAL(triggered()), dd->m_targetSelector, SLOT(toggleVisible())); + connect(dd->m_projectSelectorActionMenu, &QAction::triggered, dd->m_targetSelector, + &MiniProjectTargetSelector::toggleVisible); cmd = ActionManager::registerAction(dd->m_projectSelectorActionMenu, Constants::SELECTTARGET, globalcontext); mbuild->addAction(cmd, Constants::G_BUILD_RUN); @@ -1004,12 +1087,13 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_projectSelectorActionQuick = new QAction(this); dd->m_projectSelectorActionQuick->setEnabled(false); dd->m_projectSelectorActionQuick->setText(tr("Quick Switch Kit Selector")); - connect(dd->m_projectSelectorActionQuick, SIGNAL(triggered()), dd->m_targetSelector, SLOT(nextOrShow())); + connect(dd->m_projectSelectorActionQuick, &QAction::triggered, + dd->m_targetSelector, &MiniProjectTargetSelector::nextOrShow); cmd = ActionManager::registerAction(dd->m_projectSelectorActionQuick, Constants::SELECTTARGETQUICK, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+T"))); - connect(ICore::instance(), SIGNAL(saveSettingsRequested()), - this, SLOT(savePersistentSettings())); + connect(ICore::instance(), &ICore::saveSettingsRequested, + dd, &ProjectExplorerPluginPrivate::savePersistentSettings); addAutoReleasedObject(new ProjectTreeWidgetFactory); addAutoReleasedObject(new FolderNavigationWidgetFactory); @@ -1058,67 +1142,105 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er if (dd->m_projectExplorerSettings.environmentId.isNull()) dd->m_projectExplorerSettings.environmentId = QUuid::createUuid(); - connect(dd->m_sessionManagerAction, SIGNAL(triggered()), this, SLOT(showSessionManager())); - connect(dd->m_newAction, SIGNAL(triggered()), this, SLOT(newProject())); - connect(dd->m_loadAction, SIGNAL(triggered()), this, SLOT(loadAction())); - connect(dd->m_buildProjectOnlyAction, SIGNAL(triggered()), this, SLOT(buildProjectOnly())); - connect(dd->m_buildAction, SIGNAL(triggered()), this, SLOT(buildProject())); - connect(dd->m_buildActionContextMenu, SIGNAL(triggered()), this, SLOT(buildProjectContextMenu())); - connect(dd->m_buildSessionAction, SIGNAL(triggered()), this, SLOT(buildSession())); - connect(dd->m_rebuildProjectOnlyAction, SIGNAL(triggered()), this, SLOT(rebuildProjectOnly())); - connect(dd->m_rebuildAction, SIGNAL(triggered()), this, SLOT(rebuildProject())); - connect(dd->m_rebuildActionContextMenu, SIGNAL(triggered()), this, SLOT(rebuildProjectContextMenu())); - connect(dd->m_rebuildSessionAction, SIGNAL(triggered()), this, SLOT(rebuildSession())); - connect(dd->m_deployProjectOnlyAction, SIGNAL(triggered()), this, SLOT(deployProjectOnly())); - connect(dd->m_deployAction, SIGNAL(triggered()), this, SLOT(deployProject())); - connect(dd->m_deployActionContextMenu, SIGNAL(triggered()), this, SLOT(deployProjectContextMenu())); - connect(dd->m_deploySessionAction, SIGNAL(triggered()), this, SLOT(deploySession())); - connect(dd->m_cleanProjectOnlyAction, SIGNAL(triggered()), this, SLOT(cleanProjectOnly())); - connect(dd->m_cleanAction, SIGNAL(triggered()), this, SLOT(cleanProject())); - connect(dd->m_cleanActionContextMenu, SIGNAL(triggered()), this, SLOT(cleanProjectContextMenu())); - connect(dd->m_cleanSessionAction, SIGNAL(triggered()), this, SLOT(cleanSession())); - connect(dd->m_runAction, SIGNAL(triggered()), this, SLOT(runProject())); - connect(dd->m_runActionContextMenu, SIGNAL(triggered()), this, SLOT(runProjectContextMenu())); - connect(dd->m_runWithoutDeployAction, SIGNAL(triggered()), this, SLOT(runProjectWithoutDeploy())); - connect(dd->m_cancelBuildAction, SIGNAL(triggered()), this, SLOT(cancelBuild())); - connect(dd->m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject())); - connect(dd->m_unloadActionContextMenu, SIGNAL(triggered()), this, SLOT(unloadProjectContextMenu())); - connect(dd->m_closeAllProjects, SIGNAL(triggered()), this, SLOT(closeAllProjects())); - connect(dd->m_addNewFileAction, SIGNAL(triggered()), this, SLOT(addNewFile())); - connect(dd->m_addExistingFilesAction, SIGNAL(triggered()), this, SLOT(addExistingFiles())); - connect(dd->m_addExistingDirectoryAction, SIGNAL(triggered()), this, SLOT(addExistingDirectory())); - connect(dd->m_addNewSubprojectAction, SIGNAL(triggered()), this, SLOT(addNewSubproject())); - connect(dd->m_removeProjectAction, SIGNAL(triggered()), this, SLOT(removeProject())); - connect(dd->m_openFileAction, SIGNAL(triggered()), this, SLOT(openFile())); - connect(dd->m_searchOnFileSystem, SIGNAL(triggered()), this, SLOT(searchOnFileSystem())); - connect(dd->m_showInGraphicalShell, SIGNAL(triggered()), this, SLOT(showInGraphicalShell())); - connect(dd->m_openTerminalHere, SIGNAL(triggered()), this, SLOT(openTerminalHere())); - connect(dd->m_removeFileAction, SIGNAL(triggered()), this, SLOT(removeFile())); - connect(dd->m_deleteFileAction, SIGNAL(triggered()), this, SLOT(deleteFile())); - connect(dd->m_renameFileAction, SIGNAL(triggered()), this, SLOT(renameFile())); - connect(dd->m_setStartupProjectAction, SIGNAL(triggered()), this, SLOT(setStartupProject())); + connect(dd->m_sessionManagerAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::showSessionManager); + connect(dd->m_newAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::newProject); + connect(dd->m_loadAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::loadAction); + connect(dd->m_buildProjectOnlyAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::buildProjectOnly); + connect(dd->m_buildAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::handleBuildProject); + connect(dd->m_buildActionContextMenu, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::buildProjectContextMenu); + connect(dd->m_buildSessionAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::buildSession); + connect(dd->m_rebuildProjectOnlyAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::rebuildProjectOnly); + connect(dd->m_rebuildAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::rebuildProject); + connect(dd->m_rebuildActionContextMenu, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::rebuildProjectContextMenu); + connect(dd->m_rebuildSessionAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::rebuildSession); + connect(dd->m_deployProjectOnlyAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::deployProjectOnly); + connect(dd->m_deployAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::deployProject); + connect(dd->m_deployActionContextMenu, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::deployProjectContextMenu); + connect(dd->m_deploySessionAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::deploySession); + connect(dd->m_cleanProjectOnlyAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::cleanProjectOnly); + connect(dd->m_cleanAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::cleanProject); + connect(dd->m_cleanActionContextMenu, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::cleanProjectContextMenu); + connect(dd->m_cleanSessionAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::cleanSession); + connect(dd->m_runAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::handleRunProject); + connect(dd->m_runActionContextMenu, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::runProjectContextMenu); + connect(dd->m_runWithoutDeployAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::runProjectWithoutDeploy); + connect(dd->m_cancelBuildAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::cancelBuild); + connect(dd->m_unloadAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::handleUnloadProject); + connect(dd->m_unloadActionContextMenu, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::unloadProjectContextMenu); + connect(dd->m_closeAllProjects, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::closeAllProjects); + connect(dd->m_addNewFileAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::addNewFile); + connect(dd->m_addExistingFilesAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::handleAddExistingFiles); + connect(dd->m_addExistingDirectoryAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::addExistingDirectory); + connect(dd->m_addNewSubprojectAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::addNewSubproject); + connect(dd->m_removeProjectAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::removeProject); + connect(dd->m_openFileAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::openFile); + connect(dd->m_searchOnFileSystem, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::searchOnFileSystem); + connect(dd->m_showInGraphicalShell, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::showInGraphicalShell); + connect(dd->m_openTerminalHere, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::openTerminalHere); + connect(dd->m_removeFileAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::removeFile); + connect(dd->m_deleteFileAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::deleteFile); + connect(dd->m_renameFileAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::handleRenameFile); + connect(dd->m_setStartupProjectAction, &QAction::triggered, + dd, &ProjectExplorerPluginPrivate::handleSetStartupProject); connect(dd->m_projectTreeCollapseAllAction, &QAction::triggered, ProjectTree::instance(), &ProjectTree::collapseAll); - connect(this, SIGNAL(updateRunActions()), this, SLOT(slotUpdateRunActions())); + connect(this, &ProjectExplorerPlugin::updateRunActions, + dd, &ProjectExplorerPluginPrivate::slotUpdateRunActions); connect(this, &ProjectExplorerPlugin::settingsChanged, dd, &ProjectExplorerPluginPrivate::updateRunWithoutDeployMenu); - QObject *buildManager = new BuildManager(this, dd->m_cancelBuildAction); - connect(buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project*)), - this, SLOT(buildStateChanged(ProjectExplorer::Project*))); - connect(buildManager, SIGNAL(buildQueueFinished(bool)), - this, SLOT(buildQueueFinished(bool)), Qt::QueuedConnection); + auto buildManager = new BuildManager(this, dd->m_cancelBuildAction); + connect(buildManager, &BuildManager::buildStateChanged, + dd, &ProjectExplorerPluginPrivate::buildStateChanged); + connect(buildManager, &BuildManager::buildQueueFinished, + dd, &ProjectExplorerPluginPrivate::buildQueueFinished, Qt::QueuedConnection); - m_instance->updateActions(); + connect(ICore::instance(), &ICore::coreAboutToOpen, + dd, &ProjectExplorerPluginPrivate::determineSessionToRestoreAtStartup); + connect(ICore::instance(), &ICore::coreOpened, + dd, &ProjectExplorerPluginPrivate::restoreSession); + connect(ICore::instance(), &ICore::newItemDialogRunningChanged, updateActions); - connect(ICore::instance(), SIGNAL(coreAboutToOpen()), - this, SLOT(determineSessionToRestoreAtStartup())); - connect(ICore::instance(), SIGNAL(coreOpened()), this, SLOT(restoreSession())); - connect(ICore::instance(), SIGNAL(newItemDialogRunningChanged()), - this, SLOT(updateActions())); - - updateWelcomePage(); + dd->updateWelcomePage(); // FIXME: These are mostly "legacy"/"convenience" entries, relying on // the global entry point ProjectExplorer::currentProject(). They should @@ -1238,7 +1360,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er return true; } -void ProjectExplorerPlugin::loadAction() +void ProjectExplorerPluginPrivate::loadAction() { if (debug) qDebug() << "ProjectExplorerPlugin::loadAction"; @@ -1260,23 +1382,23 @@ void ProjectExplorerPlugin::loadAction() if (filename.isEmpty()) return; QString errorMessage; - openProject(filename, &errorMessage); + ProjectExplorerPlugin::openProject(filename, &errorMessage); if (!errorMessage.isEmpty()) QMessageBox::critical(ICore::mainWindow(), tr("Failed to open project."), errorMessage); updateActions(); } -void ProjectExplorerPlugin::unloadProjectContextMenu() +void ProjectExplorerPluginPrivate::unloadProjectContextMenu() { if (debug) qDebug() << "ProjectExplorerPlugin::unloadProjectContextMenu"; if (Project *p = ProjectTree::currentProject()) - unloadProject(p); + ProjectExplorerPlugin::unloadProject(p); } -void ProjectExplorerPlugin::unloadProject() +void ProjectExplorerPluginPrivate::handleUnloadProject() { if (debug) qDebug() << "ProjectExplorerPlugin::unloadProject"; @@ -1284,7 +1406,7 @@ void ProjectExplorerPlugin::unloadProject() QList<Project *> projects = SessionManager::projects(); QTC_ASSERT(!projects.isEmpty(), return); - unloadProject(projects.first()); + ProjectExplorerPlugin::unloadProject(projects.first()); } void ProjectExplorerPlugin::unloadProject(Project *project) @@ -1314,10 +1436,10 @@ void ProjectExplorerPlugin::unloadProject(Project *project) dd->addToRecentProjects(document->filePath().toString(), project->displayName()); SessionManager::removeProject(project); - m_instance->updateActions(); + updateActions(); } -void ProjectExplorerPlugin::closeAllProjects() +void ProjectExplorerPluginPrivate::closeAllProjects() { if (debug) qDebug() << "ProjectExplorerPlugin::closeAllProject"; @@ -1379,7 +1501,7 @@ void ProjectExplorerPlugin::extensionsInitialized() dd->m_kitManager->restoreKits(); } -void ProjectExplorerPlugin::loadCustomWizards() +void ProjectExplorerPluginPrivate::loadCustomWizards() { // Add custom wizards, for which other plugins might have registered // class factories @@ -1387,9 +1509,9 @@ void ProjectExplorerPlugin::loadCustomWizards() if (firstTime) { firstTime = false; foreach (IWizardFactory *cpw, CustomWizard::createWizards()) - addAutoReleasedObject(cpw); + m_instance->addAutoReleasedObject(cpw); foreach (IWizardFactory *cpw, JsonWizardFactory::createWizardFactories()) - addAutoReleasedObject(cpw); + m_instance->addAutoReleasedObject(cpw); } } @@ -1400,8 +1522,8 @@ void ProjectExplorerPluginPrivate::updateRunWithoutDeployMenu() ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown() { - disconnect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*,Core::IMode*)), - this, SLOT(currentModeChanged(Core::IMode*,Core::IMode*))); + disconnect(ModeManager::instance(), &ModeManager::currentModeChanged, + dd, &ProjectExplorerPluginPrivate::currentModeChanged); ProjectTree::aboutToShutDown(); dd->m_proWindow->aboutToShutdown(); // disconnect from session SessionManager::closeAllProjects(); @@ -1412,12 +1534,12 @@ ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown() // might shutdown asynchronously). if (dd->m_outputPane->closeTabs(AppOutputPane::CloseTabNoPrompt /* No prompt any more */)) return SynchronousShutdown; - connect(dd->m_outputPane, SIGNAL(allRunControlsFinished()), - this, SIGNAL(asynchronousShutdownFinished())); + connect(dd->m_outputPane, &AppOutputPane::allRunControlsFinished, + this, &IPlugin::asynchronousShutdownFinished); return AsynchronousShutdown; } -void ProjectExplorerPlugin::newProject() +void ProjectExplorerPluginPrivate::newProject() { if (debug) qDebug() << "ProjectExplorerPlugin::newProject"; @@ -1427,7 +1549,7 @@ void ProjectExplorerPlugin::newProject() updateActions(); } -void ProjectExplorerPlugin::showSessionManager() +void ProjectExplorerPluginPrivate::showSessionManager() { if (debug) qDebug() << "ProjectExplorerPlugin::showSessionManager"; @@ -1449,7 +1571,7 @@ void ProjectExplorerPlugin::showSessionManager() updateWelcomePage(); } -void ProjectExplorerPlugin::setStartupProject(Project *project) +void ProjectExplorerPluginPrivate::setStartupProject(Project *project) { if (debug) qDebug() << "ProjectExplorerPlugin::setStartupProject"; @@ -1460,7 +1582,7 @@ void ProjectExplorerPlugin::setStartupProject(Project *project) updateActions(); } -void ProjectExplorerPlugin::savePersistentSettings() +void ProjectExplorerPluginPrivate::savePersistentSettings() { if (debug) qDebug()<<"ProjectExplorerPlugin::savePersistentSettings()"; @@ -1586,7 +1708,8 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName QString tmp; if (Project *pro = manager->openProject(filePath, &tmp)) { if (pro->restoreSettings()) { - connect(pro, SIGNAL(fileListChanged()), m_instance, SIGNAL(fileListChanged())); + connect(pro, &Project::fileListChanged, + m_instance, &ProjectExplorerPlugin::fileListChanged); SessionManager::addProject(pro); openedPro += pro; } else { @@ -1612,7 +1735,7 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName if (fileNames.size() > 1) SessionManager::reportProjectLoadingProgress(); } - m_instance->updateActions(); + updateActions(); bool switchToProjectsMode = Utils::anyOf(openedPro, &Project::needsConfiguration); @@ -1627,12 +1750,12 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName return openedPro; } -void ProjectExplorerPlugin::updateWelcomePage() +void ProjectExplorerPluginPrivate::updateWelcomePage() { - dd->m_welcomePage->reloadWelcomeScreenData(); + m_welcomePage->reloadWelcomeScreenData(); } -void ProjectExplorerPlugin::currentModeChanged(IMode *mode, IMode *oldMode) +void ProjectExplorerPluginPrivate::currentModeChanged(IMode *mode, IMode *oldMode) { if (oldMode && oldMode->id() == Constants::MODE_SESSION) ICore::saveSettings(); @@ -1640,30 +1763,30 @@ void ProjectExplorerPlugin::currentModeChanged(IMode *mode, IMode *oldMode) updateWelcomePage(); } -void ProjectExplorerPlugin::determineSessionToRestoreAtStartup() +void ProjectExplorerPluginPrivate::determineSessionToRestoreAtStartup() { // Process command line arguments first: - if (pluginSpec()->arguments().contains(QLatin1String("-lastsession"))) - dd->m_sessionToRestoreAtStartup = SessionManager::lastSession(); + if (m_instance->pluginSpec()->arguments().contains(QLatin1String("-lastsession"))) + m_sessionToRestoreAtStartup = SessionManager::lastSession(); QStringList arguments = ExtensionSystem::PluginManager::arguments(); - if (dd->m_sessionToRestoreAtStartup.isNull()) { + if (m_sessionToRestoreAtStartup.isNull()) { QStringList sessions = SessionManager::sessions(); // We have command line arguments, try to find a session in them // Default to no session loading foreach (const QString &arg, arguments) { if (sessions.contains(arg)) { // Session argument - dd->m_sessionToRestoreAtStartup = arg; + m_sessionToRestoreAtStartup = arg; break; } } } // Handle settings only after command line arguments: - if (dd->m_sessionToRestoreAtStartup.isNull() - && dd->m_projectExplorerSettings.autorestoreLastSession) - dd->m_sessionToRestoreAtStartup = SessionManager::lastSession(); + if (m_sessionToRestoreAtStartup.isNull() + && m_projectExplorerSettings.autorestoreLastSession) + m_sessionToRestoreAtStartup = SessionManager::lastSession(); - if (!dd->m_sessionToRestoreAtStartup.isNull()) + if (!m_sessionToRestoreAtStartup.isNull()) ModeManager::activateMode(Core::Constants::MODE_EDIT); } @@ -1694,7 +1817,7 @@ void ProjectExplorerPlugin::updateContextMenuActions() default session and puts the list of recent projects and sessions onto the welcome page. */ -void ProjectExplorerPlugin::restoreSession() +void ProjectExplorerPluginPrivate::restoreSession() { if (debug) qDebug() << "ProjectExplorerPlugin::restoreSession"; @@ -1755,29 +1878,31 @@ void ProjectExplorerPlugin::restoreSession() SessionManager::loadSession(dd->m_sessionToRestoreAtStartup); // update welcome page - connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*,Core::IMode*)), - this, SLOT(currentModeChanged(Core::IMode*,Core::IMode*))); - connect(dd->m_welcomePage, SIGNAL(requestSession(QString)), this, SLOT(loadSession(QString))); - connect(dd->m_welcomePage, SIGNAL(requestProject(QString)), this, SLOT(openProjectWelcomePage(QString))); + connect(ModeManager::instance(), &ModeManager::currentModeChanged, + dd, &ProjectExplorerPluginPrivate::currentModeChanged); + connect(dd->m_welcomePage, &ProjectWelcomePage::requestSession, + dd, &ProjectExplorerPluginPrivate::loadSession); + connect(dd->m_welcomePage, &ProjectWelcomePage::requestProject, + m_instance, &ProjectExplorerPlugin::openProjectWelcomePage); dd->m_arguments = arguments; - QTimer::singleShot(0, this, SLOT(restoreSession2())); + QTimer::singleShot(0, m_instance, SLOT(restoreSession2())); updateActions(); } -void ProjectExplorerPlugin::restoreSession2() -{ - QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - ICore::openFiles(dd->m_arguments, ICore::OpenFilesFlags(ICore::CanContainLineNumbers | ICore::SwitchMode)); -} - -void ProjectExplorerPlugin::loadSession(const QString &session) +void ProjectExplorerPluginPrivate::loadSession(const QString &session) { if (debug) qDebug() << "ProjectExplorerPlugin::loadSession" << session; SessionManager::loadSession(session); } -void ProjectExplorerPlugin::buildStateChanged(Project * pro) +void ProjectExplorerPlugin::restoreSession2() +{ + QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + ICore::openFiles(dd->m_arguments, ICore::OpenFilesFlags(ICore::CanContainLineNumbers | ICore::SwitchMode)); +} + +void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro) { if (debug) { qDebug() << "buildStateChanged"; @@ -1806,8 +1931,8 @@ void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *run m_instance->showRunErrorMessage(errorMessage); return; } else if (state == RunConfiguration::Waiting) { - QObject::connect(runConfiguration, SIGNAL(configurationFinished()), - m_instance, SLOT(runConfigurationConfigurationFinished())); + connect(runConfiguration, &RunConfiguration::configurationFinished, + this, &ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished); m_delayedRunConfigurationForRun.append(qMakePair(runConfiguration, runMode)); return; } @@ -1839,6 +1964,11 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl, RunMode runM dd->startRunControl(runControl, runMode); } +void ProjectExplorerPluginPrivate::handleRunControlFinished() +{ + emit m_instance->updateRunActions(); +} + void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl, RunMode runMode) { m_outputPane->createNewOutputWindow(runControl); @@ -1848,17 +1978,18 @@ void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl, RunMo || ((runMode == DebugRunMode || runMode == DebugRunModeWithBreakOnMain) && m_projectExplorerSettings.showDebugOutput); m_outputPane->setBehaviorOnOutput(runControl, popup ? AppOutputPane::Popup : AppOutputPane::Flash); - QObject::connect(runControl, SIGNAL(finished()), m_instance, SLOT(runControlFinished())); + QObject::connect(runControl, &RunControl::finished, + this, &ProjectExplorerPluginPrivate::handleRunControlFinished); runControl->start(); emit m_instance->updateRunActions(); } void ProjectExplorerPlugin::initiateInlineRenaming() { - m_instance->renameFile(); + dd->handleRenameFile(); } -void ProjectExplorerPlugin::buildQueueFinished(bool success) +void ProjectExplorerPluginPrivate::buildQueueFinished(bool success) { if (debug) qDebug() << "buildQueueFinished()" << success; @@ -1866,45 +1997,45 @@ void ProjectExplorerPlugin::buildQueueFinished(bool success) updateActions(); bool ignoreErrors = true; - if (!dd->m_delayedRunConfiguration.isNull() && success && BuildManager::getErrorTaskCount() > 0) { + if (!m_delayedRunConfiguration.isNull() && success && BuildManager::getErrorTaskCount() > 0) { ignoreErrors = QMessageBox::question(ICore::dialogParent(), - tr("Ignore All Errors?"), - tr("Found some build errors in current task.\n" + ProjectExplorerPlugin::tr("Ignore All Errors?"), + ProjectExplorerPlugin::tr("Found some build errors in current task.\n" "Do you want to ignore them?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes; } - if (dd->m_delayedRunConfiguration.isNull() && dd->m_shouldHaveRunConfiguration) { + if (m_delayedRunConfiguration.isNull() && m_shouldHaveRunConfiguration) { QMessageBox::warning(ICore::dialogParent(), - tr("Run Configuration Removed"), - tr("The configuration that was supposed to run is no longer " + ProjectExplorerPlugin::tr("Run Configuration Removed"), + ProjectExplorerPlugin::tr("The configuration that was supposed to run is no longer " "available."), QMessageBox::Ok); } - if (success && ignoreErrors && !dd->m_delayedRunConfiguration.isNull()) { - dd->executeRunConfiguration(dd->m_delayedRunConfiguration.data(), dd->m_runMode); + if (success && ignoreErrors && !m_delayedRunConfiguration.isNull()) { + executeRunConfiguration(m_delayedRunConfiguration.data(), m_runMode); } else { if (BuildManager::tasksAvailable()) BuildManager::showTaskWindow(); } - dd->m_delayedRunConfiguration = 0; - dd->m_shouldHaveRunConfiguration = false; - dd->m_runMode = NoRunMode; + m_delayedRunConfiguration = 0; + m_shouldHaveRunConfiguration = false; + m_runMode = NoRunMode; } -void ProjectExplorerPlugin::runConfigurationConfigurationFinished() +void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished() { RunConfiguration *rc = qobject_cast<RunConfiguration *>(sender()); RunMode runMode = NoRunMode; - for (int i = 0; i < dd->m_delayedRunConfigurationForRun.size(); ++i) { - if (dd->m_delayedRunConfigurationForRun.at(i).first == rc) { - runMode = dd->m_delayedRunConfigurationForRun.at(i).second; - dd->m_delayedRunConfigurationForRun.removeAt(i); + for (int i = 0; i < m_delayedRunConfigurationForRun.size(); ++i) { + if (m_delayedRunConfigurationForRun.at(i).first == rc) { + runMode = m_delayedRunConfigurationForRun.at(i).second; + m_delayedRunConfigurationForRun.removeAt(i); break; } } if (runMode != NoRunMode && rc->isConfigured()) - dd->executeRunConfiguration(rc, runMode); + executeRunConfiguration(rc, runMode); } static QString pathOrDirectoryFor(Node *node, bool dir) @@ -1950,14 +2081,14 @@ static QString pathFor(Node *node) return pathOrDirectoryFor(node, false); } -QString ProjectExplorerPlugin::directoryFor(Node *node) +static QString directoryFor(Node *node) { return pathOrDirectoryFor(node, true); } -void ProjectExplorerPlugin::updateActions() +QString ProjectExplorerPlugin::directoryFor(Node *node) { - dd->updateActions(); + return ProjectExplorer::directoryFor(node); } void ProjectExplorerPluginPrivate::updateActions() @@ -2152,9 +2283,9 @@ int ProjectExplorerPluginPrivate::queue(QList<Project *> projects, QList<Id> ste return stepLists.count(); } -void ProjectExplorerPlugin::buildProjectOnly() +void ProjectExplorerPluginPrivate::buildProjectOnly() { - dd->queue(QList<Project *>() << SessionManager::startupProject(), QList<Id>() << Id(Constants::BUILDSTEPS_BUILD)); + queue(QList<Project *>() << SessionManager::startupProject(), QList<Id>() << Id(Constants::BUILDSTEPS_BUILD)); } void ProjectExplorerPlugin::buildProject(Project *p) @@ -2168,107 +2299,107 @@ void ProjectExplorerPlugin::requestProjectModeUpdate(Project *p) dd->m_proWindow->projectUpdated(p); } -void ProjectExplorerPlugin::buildProject() +void ProjectExplorerPluginPrivate::handleBuildProject() { - dd->queue(SessionManager::projectOrder(SessionManager::startupProject()), + queue(SessionManager::projectOrder(SessionManager::startupProject()), QList<Id>() << Id(Constants::BUILDSTEPS_BUILD)); } -void ProjectExplorerPlugin::buildProjectContextMenu() +void ProjectExplorerPluginPrivate::buildProjectContextMenu() { - dd->queue(QList<Project *>() << ProjectTree::currentProject(), + queue(QList<Project *>() << ProjectTree::currentProject(), QList<Id>() << Id(Constants::BUILDSTEPS_BUILD)); } -void ProjectExplorerPlugin::buildSession() +void ProjectExplorerPluginPrivate::buildSession() { - dd->queue(SessionManager::projectOrder(), + queue(SessionManager::projectOrder(), QList<Id>() << Id(Constants::BUILDSTEPS_BUILD)); } -void ProjectExplorerPlugin::rebuildProjectOnly() +void ProjectExplorerPluginPrivate::rebuildProjectOnly() { - dd->queue(QList<Project *>() << SessionManager::startupProject(), + queue(QList<Project *>() << SessionManager::startupProject(), QList<Id>() << Id(Constants::BUILDSTEPS_CLEAN) << Id(Constants::BUILDSTEPS_BUILD)); } -void ProjectExplorerPlugin::rebuildProject() +void ProjectExplorerPluginPrivate::rebuildProject() { - dd->queue(SessionManager::projectOrder(SessionManager::startupProject()), + queue(SessionManager::projectOrder(SessionManager::startupProject()), QList<Id>() << Id(Constants::BUILDSTEPS_CLEAN) << Id(Constants::BUILDSTEPS_BUILD)); } -void ProjectExplorerPlugin::rebuildProjectContextMenu() +void ProjectExplorerPluginPrivate::rebuildProjectContextMenu() { - dd->queue(QList<Project *>() << ProjectTree::currentProject(), + queue(QList<Project *>() << ProjectTree::currentProject(), QList<Id>() << Id(Constants::BUILDSTEPS_CLEAN) << Id(Constants::BUILDSTEPS_BUILD)); } -void ProjectExplorerPlugin::rebuildSession() +void ProjectExplorerPluginPrivate::rebuildSession() { - dd->queue(SessionManager::projectOrder(), + queue(SessionManager::projectOrder(), QList<Id>() << Id(Constants::BUILDSTEPS_CLEAN) << Id(Constants::BUILDSTEPS_BUILD)); } -void ProjectExplorerPlugin::deployProjectOnly() +void ProjectExplorerPluginPrivate::deployProjectOnly() { - dd->deploy(QList<Project *>() << SessionManager::startupProject()); + deploy(QList<Project *>() << SessionManager::startupProject()); } -void ProjectExplorerPlugin::deployProject() +void ProjectExplorerPluginPrivate::deployProject() { - dd->deploy(SessionManager::projectOrder(SessionManager::startupProject())); + deploy(SessionManager::projectOrder(SessionManager::startupProject())); } -void ProjectExplorerPlugin::deployProjectContextMenu() +void ProjectExplorerPluginPrivate::deployProjectContextMenu() { - dd->deploy(QList<Project *>() << ProjectTree::currentProject()); + deploy(QList<Project *>() << ProjectTree::currentProject()); } -void ProjectExplorerPlugin::deploySession() +void ProjectExplorerPluginPrivate::deploySession() { - dd->deploy(SessionManager::projectOrder()); + deploy(SessionManager::projectOrder()); } -void ProjectExplorerPlugin::cleanProjectOnly() +void ProjectExplorerPluginPrivate::cleanProjectOnly() { - dd->queue(QList<Project *>() << SessionManager::startupProject(), + queue(QList<Project *>() << SessionManager::startupProject(), QList<Id>() << Id(Constants::BUILDSTEPS_CLEAN)); } -void ProjectExplorerPlugin::cleanProject() +void ProjectExplorerPluginPrivate::cleanProject() { - dd->queue(SessionManager::projectOrder(SessionManager::startupProject()), + queue(SessionManager::projectOrder(SessionManager::startupProject()), QList<Id>() << Id(Constants::BUILDSTEPS_CLEAN)); } -void ProjectExplorerPlugin::cleanProjectContextMenu() +void ProjectExplorerPluginPrivate::cleanProjectContextMenu() { - dd->queue(QList<Project *>() << ProjectTree::currentProject(), + queue(QList<Project *>() << ProjectTree::currentProject(), QList<Id>() << Id(Constants::BUILDSTEPS_CLEAN)); } -void ProjectExplorerPlugin::cleanSession() +void ProjectExplorerPluginPrivate::cleanSession() { - dd->queue(SessionManager::projectOrder(), + queue(SessionManager::projectOrder(), QList<Id>() << Id(Constants::BUILDSTEPS_CLEAN)); } -void ProjectExplorerPlugin::runProject() +void ProjectExplorerPluginPrivate::handleRunProject() { - runProject(SessionManager::startupProject(), NormalRunMode); + m_instance->runStartupProject(NormalRunMode); } -void ProjectExplorerPlugin::runProjectWithoutDeploy() +void ProjectExplorerPluginPrivate::runProjectWithoutDeploy() { - runProject(SessionManager::startupProject(), NormalRunMode, true); + m_instance->runStartupProject(NormalRunMode, true); } -void ProjectExplorerPlugin::runProjectContextMenu() +void ProjectExplorerPluginPrivate::runProjectContextMenu() { ProjectNode *projectNode = dynamic_cast<ProjectNode*>(ProjectTree::currentNode()); if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) { - runProject(ProjectTree::currentProject(), NormalRunMode); + m_instance->runProject(ProjectTree::currentProject(), NormalRunMode); } else { QAction *act = qobject_cast<QAction *>(sender()); if (!act) @@ -2276,7 +2407,7 @@ void ProjectExplorerPlugin::runProjectContextMenu() RunConfiguration *rc = act->data().value<RunConfiguration *>(); if (!rc) return; - runRunConfiguration(rc, NormalRunMode); + m_instance->runRunConfiguration(rc, NormalRunMode); } } @@ -2390,6 +2521,11 @@ void ProjectExplorerPlugin::runProject(Project *pro, RunMode mode, const bool fo runRunConfiguration(rc, mode, forceSkipDeploy); } +void ProjectExplorerPlugin::runStartupProject(RunMode runMode, bool forceSkipDeploy) +{ + runProject(SessionManager::startupProject(), runMode, forceSkipDeploy); +} + void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, RunMode runMode, const bool forceSkipDeploy) @@ -2421,36 +2557,31 @@ void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, emit m_instance->updateRunActions(); } -void ProjectExplorerPlugin::runControlFinished() -{ - emit updateRunActions(); -} - -void ProjectExplorerPlugin::projectAdded(Project *pro) +void ProjectExplorerPluginPrivate::projectAdded(Project *pro) { - if (dd->m_projectsMode) - dd->m_projectsMode->setEnabled(true); + if (m_projectsMode) + m_projectsMode->setEnabled(true); // more specific action en and disabling ? - connect(pro, SIGNAL(buildConfigurationEnabledChanged()), - this, SLOT(updateActions())); + connect(pro, &Project::buildConfigurationEnabledChanged, + this, &ProjectExplorerPluginPrivate::updateActions); } -void ProjectExplorerPlugin::projectRemoved(Project * pro) +void ProjectExplorerPluginPrivate::projectRemoved(Project * pro) { - if (dd->m_projectsMode) - dd->m_projectsMode->setEnabled(SessionManager::hasProjects()); + if (m_projectsMode) + m_projectsMode->setEnabled(SessionManager::hasProjects()); // more specific action en and disabling ? - disconnect(pro, SIGNAL(buildConfigurationEnabledChanged()), - this, SLOT(updateActions())); + disconnect(pro, &Project::buildConfigurationEnabledChanged, + this, &ProjectExplorerPluginPrivate::updateActions); } -void ProjectExplorerPlugin::projectDisplayNameChanged(Project *pro) +void ProjectExplorerPluginPrivate::projectDisplayNameChanged(Project *pro) { - dd->addToRecentProjects(pro->projectFilePath().toString(), pro->displayName()); + addToRecentProjects(pro->projectFilePath().toString(), pro->displayName()); updateActions(); } -void ProjectExplorerPlugin::startupProjectChanged() +void ProjectExplorerPluginPrivate::startupProjectChanged() { static QPointer<Project> previousStartupProject = 0; Project *project = SessionManager::startupProject(); @@ -2458,22 +2589,22 @@ void ProjectExplorerPlugin::startupProjectChanged() return; if (previousStartupProject) { - disconnect(previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), - this, SLOT(activeTargetChanged())); + disconnect(previousStartupProject.data(), &Project::activeTargetChanged, + this, &ProjectExplorerPluginPrivate::activeTargetChanged); } previousStartupProject = project; if (project) { - connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), - this, SLOT(activeTargetChanged())); + connect(project, &Project::activeTargetChanged, + this, &ProjectExplorerPluginPrivate::activeTargetChanged); } activeTargetChanged(); updateActions(); } -void ProjectExplorerPlugin::activeTargetChanged() +void ProjectExplorerPluginPrivate::activeTargetChanged() { static QPointer<Target> previousTarget = 0; Target *target = 0; @@ -2484,20 +2615,20 @@ void ProjectExplorerPlugin::activeTargetChanged() return; if (previousTarget) { - disconnect(previousTarget, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), - this, SLOT(activeRunConfigurationChanged())); + disconnect(previousTarget.data(), &Target::activeRunConfigurationChanged, + this, &ProjectExplorerPluginPrivate::activeRunConfigurationChanged); } previousTarget = target; if (target) { - connect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), - this, SLOT(activeRunConfigurationChanged())); + connect(target, &Target::activeRunConfigurationChanged, + this, &ProjectExplorerPluginPrivate::activeRunConfigurationChanged); } activeRunConfigurationChanged(); - dd->updateDeployActions(); + updateDeployActions(); } -void ProjectExplorerPlugin::activeRunConfigurationChanged() +void ProjectExplorerPluginPrivate::activeRunConfigurationChanged() { static QPointer<RunConfiguration> previousRunConfiguration = 0; RunConfiguration *rc = 0; @@ -2507,15 +2638,15 @@ void ProjectExplorerPlugin::activeRunConfigurationChanged() if (rc == previousRunConfiguration) return; if (previousRunConfiguration) { - disconnect(previousRunConfiguration, SIGNAL(requestRunActionsUpdate()), - this, SIGNAL(updateRunActions())); + disconnect(previousRunConfiguration.data(), &RunConfiguration::requestRunActionsUpdate, + m_instance, &ProjectExplorerPlugin::updateRunActions); } previousRunConfiguration = rc; if (rc) { - connect(rc, SIGNAL(requestRunActionsUpdate()), - this, SIGNAL(updateRunActions())); + connect(rc, &RunConfiguration::requestRunActionsUpdate, + m_instance, &ProjectExplorerPlugin::updateRunActions); } - emit updateRunActions(); + emit m_instance->updateRunActions(); } void ProjectExplorerPluginPrivate::updateDeployActions() @@ -2630,17 +2761,17 @@ bool ProjectExplorerPlugin::canRun(Project *project, RunMode runMode, QString *w return true; } -void ProjectExplorerPlugin::slotUpdateRunActions() +void ProjectExplorerPluginPrivate::slotUpdateRunActions() { Project *project = SessionManager::startupProject(); QString whyNot; - const bool state = canRun(project, NormalRunMode, &whyNot); - dd->m_runAction->setEnabled(state); - dd->m_runAction->setToolTip(whyNot); - dd->m_runWithoutDeployAction->setEnabled(state); + const bool state = ProjectExplorerPlugin::canRun(project, NormalRunMode, &whyNot); + m_runAction->setEnabled(state); + m_runAction->setToolTip(whyNot); + m_runWithoutDeployAction->setEnabled(state); } -void ProjectExplorerPlugin::cancelBuild() +void ProjectExplorerPluginPrivate::cancelBuild() { if (debug) qDebug() << "ProjectExplorerPlugin::cancelBuild"; @@ -2673,7 +2804,7 @@ void ProjectExplorerPluginPrivate::addToRecentProjects(const QString &fileName, emit m_instance->recentProjectsChanged(); } -void ProjectExplorerPlugin::updateUnloadProjectMenu() +void ProjectExplorerPluginPrivate::updateUnloadProjectMenu() { ActionContainer *aci = ActionManager::actionContainer(Constants::M_UNLOADPROJECTS); QMenu *menu = aci->menu(); @@ -2681,11 +2812,11 @@ void ProjectExplorerPlugin::updateUnloadProjectMenu() foreach (Project *project, SessionManager::projects()) { QAction *action = menu->addAction(tr("Close Project \"%1\"").arg(project->displayName())); connect(action, &QAction::triggered, - this, [project, this](){ unloadProject(project); } ); + [project] { ProjectExplorerPlugin::unloadProject(project); } ); } } -void ProjectExplorerPlugin::updateRecentProjectMenu() +void ProjectExplorerPluginPrivate::updateRecentProjectMenu() { typedef QList<QPair<QString, QString> >::const_iterator StringPairListConstIterator; if (debug) @@ -2705,7 +2836,7 @@ void ProjectExplorerPlugin::updateRecentProjectMenu() continue; QAction *action = menu->addAction(Utils::withTildeHomePath(s.first)); action->setData(s.first); - connect(action, SIGNAL(triggered()), this, SLOT(openRecentProject())); + connect(action, &QAction::triggered, this, &ProjectExplorerPluginPrivate::openRecentProject); hasRecentProjects = true; } menu->setEnabled(hasRecentProjects); @@ -2715,18 +2846,18 @@ void ProjectExplorerPlugin::updateRecentProjectMenu() menu->addSeparator(); QAction *action = menu->addAction(QCoreApplication::translate( "Core", Core::Constants::TR_CLEAR_MENU)); - connect(action, SIGNAL(triggered()), this, SLOT(clearRecentProjects())); + connect(action, &QAction::triggered, this, &ProjectExplorerPluginPrivate::clearRecentProjects); } - emit recentProjectsChanged(); + emit m_instance->recentProjectsChanged(); } -void ProjectExplorerPlugin::clearRecentProjects() +void ProjectExplorerPluginPrivate::clearRecentProjects() { - dd->m_recentProjects.clear(); + m_recentProjects.clear(); updateWelcomePage(); } -void ProjectExplorerPlugin::openRecentProject() +void ProjectExplorerPluginPrivate::openRecentProject() { if (debug) qDebug() << "ProjectExplorerPlugin::openRecentProject()"; @@ -2737,18 +2868,18 @@ void ProjectExplorerPlugin::openRecentProject() QString fileName = a->data().toString(); if (!fileName.isEmpty()) { QString errorMessage; - openProject(fileName, &errorMessage); + ProjectExplorerPlugin::openProject(fileName, &errorMessage); if (!errorMessage.isEmpty()) QMessageBox::critical(ICore::mainWindow(), tr("Failed to open project."), errorMessage); } } -void ProjectExplorerPlugin::invalidateProject(Project *project) +void ProjectExplorerPluginPrivate::invalidateProject(Project *project) { if (debug) qDebug() << "ProjectExplorerPlugin::invalidateProject" << project->displayName(); - disconnect(project, SIGNAL(fileListChanged()), this, SIGNAL(fileListChanged())); + disconnect(project, &Project::fileListChanged, m_instance, &ProjectExplorerPlugin::fileListChanged); updateActions(); } @@ -2800,8 +2931,8 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() act->setData(QVariant::fromValue(rc)); act->setText(tr("Run %1").arg(rc->displayName())); runMenu->menu()->addAction(act); - connect(act, SIGNAL(triggered()), - m_instance, SLOT(runProjectContextMenu())); + connect(act, &QAction::triggered, + this, &ProjectExplorerPluginPrivate::runProjectContextMenu); } } } @@ -2857,7 +2988,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() } } -void ProjectExplorerPlugin::addNewFile() +void ProjectExplorerPluginPrivate::addNewFile() { QTC_ASSERT(ProjectTree::currentNode(), return); QString location = directoryFor(ProjectTree::currentNode()); @@ -2874,7 +3005,7 @@ void ProjectExplorerPlugin::addNewFile() location, map); } -void ProjectExplorerPlugin::addNewSubproject() +void ProjectExplorerPluginPrivate::addNewSubproject() { QTC_ASSERT(ProjectTree::currentNode(), return); Node *currentNode = ProjectTree::currentNode(); @@ -2896,7 +3027,7 @@ void ProjectExplorerPlugin::addNewSubproject() } } -void ProjectExplorerPlugin::addExistingFiles() +void ProjectExplorerPluginPrivate::handleAddExistingFiles() { QTC_ASSERT(ProjectTree::currentNode(), return); @@ -2904,17 +3035,17 @@ void ProjectExplorerPlugin::addExistingFiles() tr("Add Existing Files"), directoryFor(ProjectTree::currentNode())); if (fileNames.isEmpty()) return; - addExistingFiles(fileNames); + ProjectExplorerPlugin::addExistingFiles(fileNames); } -void ProjectExplorerPlugin::addExistingDirectory() +void ProjectExplorerPluginPrivate::addExistingDirectory() { QTC_ASSERT(ProjectTree::currentNode(), return); SelectableFilesDialogAddDirectory dialog(directoryFor(ProjectTree::currentNode()), QStringList(), ICore::mainWindow()); if (dialog.exec() == QDialog::Accepted) - addExistingFiles(dialog.selectedFiles()); + ProjectExplorerPlugin::addExistingFiles(dialog.selectedFiles()); } void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths) @@ -2946,7 +3077,7 @@ void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStri VcsManager::promptToAdd(dir, fileNames); } -void ProjectExplorerPlugin::removeProject() +void ProjectExplorerPluginPrivate::removeProject() { ProjectNode *subProjectNode = dynamic_cast<ProjectNode*>(ProjectTree::currentNode()->projectNode()); ProjectNode *projectNode = dynamic_cast<ProjectNode *>(subProjectNode->parentFolderNode()); @@ -2958,31 +3089,31 @@ void ProjectExplorerPlugin::removeProject() } } -void ProjectExplorerPlugin::openFile() +void ProjectExplorerPluginPrivate::openFile() { QTC_ASSERT(ProjectTree::currentNode(), return); EditorManager::openEditor(ProjectTree::currentNode()->path().toString()); } -void ProjectExplorerPlugin::searchOnFileSystem() +void ProjectExplorerPluginPrivate::searchOnFileSystem() { QTC_ASSERT(ProjectTree::currentNode(), return); TextEditor::FindInFiles::findOnFileSystem(pathFor(ProjectTree::currentNode())); } -void ProjectExplorerPlugin::showInGraphicalShell() +void ProjectExplorerPluginPrivate::showInGraphicalShell() { QTC_ASSERT(ProjectTree::currentNode(), return); FileUtils::showInGraphicalShell(ICore::mainWindow(), pathFor(ProjectTree::currentNode())); } -void ProjectExplorerPlugin::openTerminalHere() +void ProjectExplorerPluginPrivate::openTerminalHere() { QTC_ASSERT(ProjectTree::currentNode(), return); FileUtils::openTerminal(directoryFor(ProjectTree::currentNode())); } -void ProjectExplorerPlugin::removeFile() +void ProjectExplorerPluginPrivate::removeFile() { Node *currentNode = ProjectTree::currentNode(); QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return); @@ -3011,7 +3142,7 @@ void ProjectExplorerPlugin::removeFile() } } -void ProjectExplorerPlugin::deleteFile() +void ProjectExplorerPluginPrivate::deleteFile() { Node *currentNode = ProjectTree::currentNode(); QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return); @@ -3046,7 +3177,7 @@ void ProjectExplorerPlugin::deleteFile() DocumentManager::unexpectFileChange(filePath); } -void ProjectExplorerPlugin::renameFile() +void ProjectExplorerPluginPrivate::handleRenameFile() { QWidget *focusWidget = QApplication::focusWidget(); while (focusWidget) { @@ -3078,7 +3209,7 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &newFilePath) } } -void ProjectExplorerPlugin::setStartupProject() +void ProjectExplorerPluginPrivate::handleSetStartupProject() { setStartupProject(ProjectTree::currentProject()); } @@ -3088,11 +3219,11 @@ void ProjectExplorerPlugin::showRenameFileError() QMessageBox::warning(ICore::mainWindow(), tr("Project Editing Failed"), dd->m_renameFileError); } -void ProjectExplorerPlugin::updateSessionMenu() +void ProjectExplorerPluginPrivate::updateSessionMenu() { - dd->m_sessionMenu->clear(); - QActionGroup *ag = new QActionGroup(dd->m_sessionMenu); - connect(ag, SIGNAL(triggered(QAction*)), this, SLOT(setSession(QAction*))); + m_sessionMenu->clear(); + QActionGroup *ag = new QActionGroup(m_sessionMenu); + connect(ag, &QActionGroup::triggered, this, &ProjectExplorerPluginPrivate::setSession); const QString activeSession = SessionManager::activeSession(); foreach (const QString &session, SessionManager::sessions()) { QAction *act = ag->addAction(session); @@ -3100,11 +3231,11 @@ void ProjectExplorerPlugin::updateSessionMenu() if (session == activeSession) act->setChecked(true); } - dd->m_sessionMenu->addActions(ag->actions()); - dd->m_sessionMenu->setEnabled(true); + m_sessionMenu->addActions(ag->actions()); + m_sessionMenu->setEnabled(true); } -void ProjectExplorerPlugin::setSession(QAction *action) +void ProjectExplorerPluginPrivate::setSession(QAction *action) { QString session = action->text(); if (session != SessionManager::activeSession()) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index b1c17c633e..a4157c3622 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -99,6 +99,7 @@ public: static bool canRun(Project *pro, RunMode runMode, QString *whyNot = 0); static void runProject(Project *pro, RunMode, const bool forceSkipDeploy = false); + static void runStartupProject(RunMode runMode, bool forceSkipDeploy = false); static void runRunConfiguration(RunConfiguration *rc, RunMode runMode, const bool forceSkipDeploy = false); @@ -138,83 +139,7 @@ public slots: static void openOpenProjectDialog(); private slots: - void buildStateChanged(ProjectExplorer::Project * pro); - void buildQueueFinished(bool success); - void buildProjectOnly(); - void buildProject(); - void buildProjectContextMenu(); - void buildSession(); - void rebuildProjectOnly(); - void rebuildProject(); - void rebuildProjectContextMenu(); - void rebuildSession(); - void deployProjectOnly(); - void deployProject(); - void deployProjectContextMenu(); - void deploySession(); - void cleanProjectOnly(); - void cleanProject(); - void cleanProjectContextMenu(); - void cleanSession(); - void cancelBuild(); - void loadAction(); - void unloadProject(); - void unloadProjectContextMenu(); - void closeAllProjects(); - void newProject(); - void showSessionManager(); - void updateSessionMenu(); - void setSession(QAction *action); - - void determineSessionToRestoreAtStartup(); - void restoreSession(); void restoreSession2(); - void loadSession(const QString &session); - void runProject(); - void runProjectWithoutDeploy(); - void runProjectContextMenu(); - void savePersistentSettings(); - - void addNewFile(); - void addExistingFiles(); - void addExistingDirectory(); - void addNewSubproject(); - void removeProject(); - void openFile(); - void searchOnFileSystem(); - void showInGraphicalShell(); - void removeFile(); - void deleteFile(); - void renameFile(); - void setStartupProject(); - void setStartupProject(ProjectExplorer::Project *project); - - void updateRecentProjectMenu(); - void clearRecentProjects(); - void openRecentProject(); - void updateUnloadProjectMenu(); - void openTerminalHere(); - - void invalidateProject(ProjectExplorer::Project *project); - - void runControlFinished(); - - void projectAdded(ProjectExplorer::Project *pro); - void projectRemoved(ProjectExplorer::Project *pro); - void projectDisplayNameChanged(ProjectExplorer::Project *pro); - void startupProjectChanged(); // Calls updateRunAction - void activeTargetChanged(); - void activeRunConfigurationChanged(); - - void slotUpdateRunActions(); - - void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode); - void loadCustomWizards(); - - void updateWelcomePage(); - - void updateActions(); - void runConfigurationConfigurationFinished(); void showRenameFileError(); #ifdef WITH_TESTS diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 37818e8fb6..562713dddf 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -173,7 +173,7 @@ const char CPP_SOURCE_MIMETYPE[] = "text/x-c++src"; const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr"; const char LINGUIST_MIMETYPE[] = "text/vnd.trolltech.linguist"; const char FORM_MIMETYPE[] = "application/x-designer"; -const char QML_MIMETYPE[] = "application/x-qml"; // separate def also in qmljstoolsconstants.h +const char QML_MIMETYPE[] = "text/x-qml"; // separate def also in qmljstoolsconstants.h const char RESOURCE_MIMETYPE[] = "application/vnd.qt.xml.resource"; // Settings page diff --git a/src/plugins/projectexplorer/projectwizardpage.cpp b/src/plugins/projectexplorer/projectwizardpage.cpp index 7d257e5298..464df95ce2 100644 --- a/src/plugins/projectexplorer/projectwizardpage.cpp +++ b/src/plugins/projectexplorer/projectwizardpage.cpp @@ -584,9 +584,7 @@ void ProjectWizardPage::projectChanged(int index) void ProjectWizardPage::manageVcs() { - ICore::showOptionsDialog(VcsBase::Constants::VCS_SETTINGS_CATEGORY, - VcsBase::Constants::VCS_COMMON_SETTINGS_ID, - this); + ICore::showOptionsDialog(VcsBase::Constants::VCS_COMMON_SETTINGS_ID, this); } } // namespace Internal diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 656d20baad..7fda8969c4 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -132,21 +132,21 @@ SessionManager::SessionManager(QObject *parent) d->m_sessionNode = new SessionNode; - connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), - this, SLOT(saveActiveMode(Core::IMode*))); + connect(ModeManager::instance(), &ModeManager::currentModeChanged, + this, &SessionManager::saveActiveMode); connect(EditorManager::instance(), &EditorManager::editorCreated, this, &SessionManager::configureEditor); - connect(this, SIGNAL(projectAdded(ProjectExplorer::Project*)), - EditorManager::instance(), SLOT(updateWindowTitles())); - connect(this, SIGNAL(projectRemoved(ProjectExplorer::Project*)), - EditorManager::instance(), SLOT(updateWindowTitles())); - connect(this, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)), - EditorManager::instance(), SLOT(updateWindowTitles())); - connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), - this, SLOT(markSessionFileDirty())); - connect(EditorManager::instance(), SIGNAL(editorsClosed(QList<Core::IEditor*>)), - this, SLOT(markSessionFileDirty())); + connect(this, &SessionManager::projectAdded, + EditorManager::instance(), &EditorManager::updateWindowTitles); + connect(this, &SessionManager::projectRemoved, + EditorManager::instance(), &EditorManager::updateWindowTitles); + connect(this, &SessionManager::projectDisplayNameChanged, + EditorManager::instance(), &EditorManager::updateWindowTitles); + connect(EditorManager::instance(), &EditorManager::editorOpened, + [this] { markSessionFileDirty(); }); + connect(EditorManager::instance(), &EditorManager::editorsClosed, + [this] { markSessionFileDirty(); }); EditorManager::setWindowTitleAdditionHandler(&SessionManagerPrivate::windowTitleAddition); } @@ -310,11 +310,11 @@ void SessionManager::addProjects(const QList<Project*> &projects) d->m_projects.append(pro); d->m_sessionNode->addProjectNodes(QList<ProjectNode *>() << pro->rootProjectNode()); - connect(pro, SIGNAL(fileListChanged()), - m_instance, SLOT(clearProjectFileCache())); + connect(pro, &Project::fileListChanged, + m_instance, &SessionManager::clearProjectFileCache); - connect(pro, SIGNAL(displayNameChanged()), - m_instance, SLOT(projectDisplayNameChanged())); + connect(pro, &Project::displayNameChanged, + m_instance, &SessionManager::handleProjectDisplayNameChanged); if (debug) qDebug() << "SessionManager - adding project " << pro->displayName(); @@ -661,7 +661,8 @@ void SessionManager::removeProjects(QList<Project *> remove) if (pro == d->m_startupProject) setStartupProject(0); - disconnect(pro, SIGNAL(fileListChanged()), m_instance, SLOT(clearProjectFileCache())); + disconnect(pro, &Project::fileListChanged, + m_instance, &SessionManager::clearProjectFileCache); d->m_projectFileCache.remove(pro); if (debug) @@ -1008,7 +1009,7 @@ void SessionManagerPrivate::sessionLoadingProgress() QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); } -void SessionManager::projectDisplayNameChanged() +void SessionManager::handleProjectDisplayNameChanged() { Project *pro = qobject_cast<Project*>(m_instance->sender()); if (pro) { diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 3d6293489e..9f59f8c622 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -143,10 +143,10 @@ signals: private slots: static void saveActiveMode(Core::IMode *mode); - static void clearProjectFileCache(); + void clearProjectFileCache(); static void configureEditor(Core::IEditor *editor, const QString &fileName); static void markSessionFileDirty(bool makeDefaultVirginDirty = true); - static void projectDisplayNameChanged(); + static void handleProjectDisplayNameChanged(); private: static void configureEditors(Project *project); }; diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp index 376a8ef0aa..6a74229224 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.cpp +++ b/src/plugins/projectexplorer/targetsettingspanel.cpp @@ -644,9 +644,7 @@ void TargetSettingsPanelWidget::openTargetPreferences() if (KitOptionsPage *page = ExtensionSystem::PluginManager::getObject<KitOptionsPage>()) page->showKit(m_targets.at(targetIndex)->kit()); } - ICore::showOptionsDialog(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - Constants::KITS_SETTINGS_PAGE_ID, - this); + ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, this); } void TargetSettingsPanelWidget::importTarget() diff --git a/src/plugins/projectexplorer/targetsetuppage.cpp b/src/plugins/projectexplorer/targetsetuppage.cpp index 528224184e..f4195406b2 100644 --- a/src/plugins/projectexplorer/targetsetuppage.cpp +++ b/src/plugins/projectexplorer/targetsetuppage.cpp @@ -428,9 +428,7 @@ void TargetSetupPage::updateVisibility() void TargetSetupPage::openOptions() { - Core::ICore::instance()->showOptionsDialog(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - Constants::KITS_SETTINGS_PAGE_ID, - this); + Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, this); } void TargetSetupPage::import(const Utils::FileName &path) diff --git a/src/plugins/projectexplorer/targetsetupwidget.cpp b/src/plugins/projectexplorer/targetsetupwidget.cpp index 67b5aea7cc..bc2620c4c7 100644 --- a/src/plugins/projectexplorer/targetsetupwidget.cpp +++ b/src/plugins/projectexplorer/targetsetupwidget.cpp @@ -230,9 +230,7 @@ void TargetSetupWidget::manageKit() return; page->showKit(m_kit); - Core::ICore::showOptionsDialog(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - Constants::KITS_SETTINGS_PAGE_ID, - this->parentWidget()); + Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, parentWidget()); } void TargetSetupWidget::setProjectPath(const QString &projectPath) diff --git a/src/plugins/pythoneditor/tools/lexical/pythonformattoken.h b/src/plugins/pythoneditor/tools/lexical/pythonformattoken.h index 7d1aced58b..cdd17d28b3 100644 --- a/src/plugins/pythoneditor/tools/lexical/pythonformattoken.h +++ b/src/plugins/pythoneditor/tools/lexical/pythonformattoken.h @@ -61,8 +61,8 @@ public: FormatToken(Format format, size_t position, size_t length) :m_format(format) - ,m_position(position) - ,m_length(length) + ,m_position(int(position)) + ,m_length(int(length)) {} inline Format format() const { return m_format; } diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index 536ce0fdf5..97a82d9c59 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -36,6 +36,7 @@ #include <projectexplorer/toolchain.h> #include <projectexplorer/projectexplorerconstants.h> #include <qtsupport/baseqtversion.h> +#include <utils/hostosinfo.h> #include <utils/qtcassert.h> #include <qbs.h> @@ -231,6 +232,29 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor data.insert(QLatin1String(CPP_LINKERNAME), compilerName); } data.insert(QLatin1String(CPP_TOOLCHAINPATH), cxxFileInfo.absolutePath()); + + QVariantMap m; + if (toolchain.contains(QLatin1String("clang"))) { + m[QLatin1String("c")] = m[QLatin1String("objc")] = QLatin1String("clang"); + m[QLatin1String("cpp")] = m[QLatin1String("objcpp")] = QLatin1String("clang++"); + } else if (toolchain.contains(QLatin1String("gcc"))) { + m[QLatin1String("c")] = m[QLatin1String("objc")] = QLatin1String("gcc"); + m[QLatin1String("cpp")] = m[QLatin1String("objcpp")] = QLatin1String("g++"); + } + const QString fullPrefix = cxxFileInfo.absolutePath() + QLatin1Char('/') + toolchainPrefix; + for (auto it = m.begin(); it != m.end();) { + const QString filePath = Utils::HostOsInfo::withExecutableSuffix(fullPrefix + + it.value().toString()); + if (QFile::exists(filePath)) { + it.value() = filePath; + ++it; + } else { + it = m.erase(it); + } + } + if (!m.isEmpty()) + data.insert(QLatin1String(CPP_COMPILERPATHBYLANGUAGE), m); + if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2013Flavor) { const QLatin1String flags("/FS"); data.insert(QLatin1String(CPP_PLATFORMCFLAGS), flags); diff --git a/src/plugins/qbsprojectmanager/qbsconstants.h b/src/plugins/qbsprojectmanager/qbsconstants.h index 64aea58199..f988f46635 100644 --- a/src/plugins/qbsprojectmanager/qbsconstants.h +++ b/src/plugins/qbsprojectmanager/qbsconstants.h @@ -41,6 +41,7 @@ const char QBS_ARCHITECTURE[] = "qbs.architecture"; const char QBS_ENDIANNESS[] = "qbs.endianness"; const char QBS_TOOLCHAIN[] = "qbs.toolchain"; const char CPP_TOOLCHAINPATH[] = "cpp.toolchainInstallPath"; +const char CPP_COMPILERPATHBYLANGUAGE[] = "cpp.compilerPathByLanguage"; const char CPP_TOOLCHAINPREFIX[] = "cpp.toolchainPrefix"; const char CPP_COMPILERNAME[] = "cpp.compilerName"; const char CPP_LINKERNAME[] = "cpp.linkerName"; diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp index 4923f2b444..abebe79a87 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp @@ -550,7 +550,7 @@ QStringList QmakeBuildConfiguration::extractDeducedArguments(QString *args) return result; } -QStringList QmakeBuildConfiguration::deduceArgumnetsForTargetAbi(const ProjectExplorer::Abi &targetAbi, const BaseQtVersion *version) +QStringList QmakeBuildConfiguration::deduceArgumentsForTargetAbi(const ProjectExplorer::Abi &targetAbi, const BaseQtVersion *version) { QStringList arguments; if ((targetAbi.os() == ProjectExplorer::Abi::MacOS) diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.h b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.h index be178558f7..2d2d5997e0 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.h +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.h @@ -97,7 +97,7 @@ public: const QString &directory, const QtSupport::BaseQtVersion *version, QStringList *outArgs = 0); static QStringList extractDeducedArguments(QString *args); - static QStringList deduceArgumnetsForTargetAbi(const ProjectExplorer::Abi &targetAbi, const QtSupport::BaseQtVersion *version); + static QStringList deduceArgumentsForTargetAbi(const ProjectExplorer::Abi &targetAbi, const QtSupport::BaseQtVersion *version); QVariantMap toMap() const; diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index 97f46e74d4..92d279d671 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -538,6 +538,8 @@ void QmakeProject::updateCppCodeModel() // part->precompiledHeaders templatePart->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar)); + templatePart->updateLanguageFeatures(); + ProjectPart::Ptr cppPart = templatePart->copy(); { // C++ files: // part->files diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp index c49f0a31b1..9f41387929 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp @@ -148,7 +148,7 @@ QList<BuildInfo *> QmakeProjectImporter::import(const FileName &importPath, bool kitSpec = kitVersion->mkspecFor(tc); QStringList kitDeducedArguments; if (tc) - kitDeducedArguments = QmakeBuildConfiguration::deduceArgumnetsForTargetAbi(tc->targetAbi(), kitVersion); + kitDeducedArguments = QmakeBuildConfiguration::deduceArgumentsForTargetAbi(tc->targetAbi(), kitVersion); if (kitVersion == version && kitSpec == parsedSpec @@ -300,7 +300,7 @@ static ToolChain *preferredToolChain(BaseQtVersion *qtVersion, const FileName &m [&spec, &deducedArguments, &qtAbis](ToolChain *tc) -> bool{ return qtAbis.contains(tc->targetAbi()) && tc->suggestedMkspecList().contains(spec) - && QmakeBuildConfiguration::deduceArgumnetsForTargetAbi(tc->targetAbi(), 0) == deducedArguments; + && QmakeBuildConfiguration::deduceArgumentsForTargetAbi(tc->targetAbi(), 0) == deducedArguments; }); } diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index d3a82f6b3d..17b28225ca 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -177,7 +177,7 @@ QStringList QMakeStep::deducedArguments() // explicitly add architecture to CONFIG QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); - arguments << QmakeBuildConfiguration::deduceArgumnetsForTargetAbi(targetAbi, version); + arguments << QmakeBuildConfiguration::deduceArgumentsForTargetAbi(targetAbi, version); if (linkQmlDebuggingLibrary() && version && !useQtQuickCompiler()) { arguments << QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG); if (version->qtVersion().majorVersion >= 5) @@ -653,17 +653,18 @@ void QMakeStepConfigWidget::updateQmlDebuggingOption() { QString warningText; bool supported = QtSupport::BaseQtVersion::isQmlDebuggingSupported(m_step->target()->kit(), - &warningText) - && !m_step->useQtQuickCompiler(); + &warningText); m_ui->qmlDebuggingLibraryCheckBox->setEnabled(supported); - m_ui->debuggingLibraryLabel->setText(tr("Enable QML debugging:")); + m_ui->debuggingLibraryLabel->setText(tr("Enable QML debugging and profiling:")); if (supported && m_step->linkQmlDebuggingLibrary()) warningText = tr("Might make your application vulnerable. Only use in a safe environment."); m_ui->qmlDebuggingWarningText->setText(warningText); m_ui->qmlDebuggingWarningIcon->setVisible(!warningText.isEmpty()); + + updateQtQuickCompilerOption(); // show or clear compiler warning text } void QMakeStepConfigWidget::updateQtQuickCompilerOption() @@ -673,6 +674,10 @@ void QMakeStepConfigWidget::updateQtQuickCompilerOption() &warningText); m_ui->qtQuickCompilerCheckBox->setEnabled(supported); m_ui->qtQuickCompilerLabel->setText(tr("Enable Qt Quick Compiler:")); + + if (supported && m_step->useQtQuickCompiler() && m_step->linkQmlDebuggingLibrary()) + warningText = tr("Disables QML debugging. QML profiling will still work."); + m_ui->qtQuickCompilerWarningText->setText(warningText); m_ui->qtQuickCompilerWarningIcon->setVisible(!warningText.isEmpty()); } diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 44e1447095..b93f898ee8 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -377,7 +377,11 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command) void NodeInstanceServerProxy::processFinished(int exitCode, QProcess::ExitStatus exitStatus) { - qWarning() << "Process" << (exitStatus == QProcess::CrashExit ? "crashed:" : "finished:") << sender() << "exitCode:" << exitCode; + QProcess* finishedProcess = qobject_cast<QProcess*>(sender()); + if (finishedProcess) + qWarning() << "Process" << (exitStatus == QProcess::CrashExit ? "crashed:" : "finished:") << finishedProcess->arguments() << "exitCode:" << exitCode; + else + qWarning() << "Process" << (exitStatus == QProcess::CrashExit ? "crashed:" : "finished:") << sender() << "exitCode:" << exitCode; if (m_captureFileForTest.isOpen()) { m_captureFileForTest.close(); diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 0df41d50b5..8a2ec11d04 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -280,7 +280,7 @@ class PropertyMemberProcessor : public MemberProcessor public: PropertyMemberProcessor(const ContextPtr &context) : m_context(context) {} - bool processProperty(const QString &name, const Value *value, const PropertyInfo &) + bool processProperty(const QString &name, const Value *value, const QmlJS::PropertyInfo &) { PropertyName propertyName = name.toUtf8(); const ASTPropertyReference *ref = value_cast<ASTPropertyReference>(value); diff --git a/src/plugins/qmljstools/QmlJSTools.mimetypes.xml b/src/plugins/qmljstools/QmlJSTools.mimetypes.xml index e92b773542..575e3c6b1c 100644 --- a/src/plugins/qmljstools/QmlJSTools.mimetypes.xml +++ b/src/plugins/qmljstools/QmlJSTools.mimetypes.xml @@ -1,32 +1,33 @@ <?xml version="1.0"?> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> - <mime-type type="application/x-qml"> - <alias type="text/x-qml"/> + <mime-type type="text/x-qml"> + <alias type="application/x-qml"/> + <!-- sub class is missing in the freedesktop.org definition --> <sub-class-of type="text/plain"/> <comment>QML file</comment> <glob pattern="*.qml"/> </mime-type> <mime-type type="application/x-qt.qbs+qml"> <alias type="text/x-qt.qbs+qml"/> - <sub-class-of type="application/x-qml"/> + <sub-class-of type="text/x-qml"/> <comment>Qt Build Suite file</comment> <glob pattern="*.qbs"/> </mime-type> <mime-type type="application/x-qt.ui+qml"> <alias type="text/x-qt.ui+qml"/> - <sub-class-of type="application/x-qml"/> + <sub-class-of type="text/x-qml"/> <comment>QtQuick Designer ui file</comment> <glob pattern="*.ui.qml"/> </mime-type> <mime-type type="application/x-qmlproject"> <alias type="text/x-qmlproject"/> - <sub-class-of type="application/x-qml"/> + <sub-class-of type="text/x-qml"/> <comment>Qt Creator Qt UI project file</comment> <glob pattern="*.qmlproject"/> </mime-type> <mime-type type="application/x-qt.meta-info+qml"> <alias type="text/x-qt.meta-info+qml"/> - <sub-class-of type="application/x-qml"/> + <sub-class-of type="text/x-qml"/> <comment>QML file</comment> <glob pattern="*.qmltypes"/> </mime-type> diff --git a/src/plugins/qmljstools/qmljstoolsconstants.h b/src/plugins/qmljstools/qmljstoolsconstants.h index ce1d1f3b44..7570b3f0e4 100644 --- a/src/plugins/qmljstools/qmljstoolsconstants.h +++ b/src/plugins/qmljstools/qmljstoolsconstants.h @@ -36,7 +36,7 @@ namespace QmlJSTools { namespace Constants { -const char QML_MIMETYPE[] = "application/x-qml"; // separate def also in projectexplorerconstants.h +const char QML_MIMETYPE[] = "text/x-qml"; // separate def also in projectexplorerconstants.h const char QBS_MIMETYPE[] = "application/x-qt.qbs+qml"; const char QMLPROJECT_MIMETYPE[] = "application/x-qmlproject"; const char QMLTYPES_MIMETYPE[] = "application/x-qt.meta-info+qml"; diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index 0bf642b64e..80f1743da1 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -53,7 +53,6 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS Q_UNUSED(errorString) auto tool = new QmlProfilerTool(this); - auto toolStarter = [tool](StartMode mode) { return tool->startTool(mode); }; auto widgetCreator = [tool] { return tool->createWidgets(); }; auto runControlCreator = [tool](const AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration) { @@ -67,11 +66,11 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS "applications using QML."); action = new AnalyzerAction(this); - action->setActionId("QmlProfiler.Local"); + action->setActionId(QmlProfilerLocalActionId); action->setToolId(QmlProfilerToolId); action->setWidgetCreator(widgetCreator); action->setRunControlCreator(runControlCreator); - action->setToolStarter(toolStarter); + action->setToolStarter([tool] { tool->startLocalTool(); }); action->setRunMode(ProjectExplorer::QmlProfilerRunMode); action->setText(tr("QML Profiler")); action->setToolTip(description); @@ -80,11 +79,11 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS AnalyzerManager::addAction(action); action = new AnalyzerAction(this); - action->setActionId("QmlProfiler.Remote"); + action->setActionId(QmlProfilerRemoteActionId); action->setToolId(QmlProfilerToolId); action->setWidgetCreator(widgetCreator); action->setRunControlCreator(runControlCreator); - action->setToolStarter(toolStarter); + action->setToolStarter([tool] { tool->startRemoteTool(); }); action->setRunMode(ProjectExplorer::QmlProfilerRunMode); action->setText(tr("QML Profiler (External)")); action->setToolTip(description); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index c4e82c8695..33c1af157d 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -486,8 +486,31 @@ void QmlProfilerTool::clearDisplay() updateTimeDisplay(); } -static void startRemoteTool(QmlProfilerTool *tool, StartMode mode) +void QmlProfilerTool::startLocalTool() { + if (d->m_recordButton->isChecked()) { + if (!checkForUnsavedNotes()) + return; + clearData(); // clear right away to suppress second warning on server recording change + } + + // Make sure mode is shown. + AnalyzerManager::showMode(); + + // ### not sure if we're supposed to check if the RunConFiguration isEnabled + ProjectExplorerPlugin::runStartupProject(QmlProfilerRunMode); +} + +void QmlProfilerTool::startRemoteTool() +{ + if (d->m_recordButton->isChecked()) { + if (!checkForUnsavedNotes()) + return; + clearData(); // clear right away to suppress second warning on server recording change + } + + AnalyzerManager::showMode(); + Id kitId; quint16 port; Kit *kit = 0; @@ -514,7 +537,7 @@ static void startRemoteTool(QmlProfilerTool *tool, StartMode mode) } AnalyzerStartParameters sp; - sp.startMode = mode; + sp.startMode = StartRemote; IDevice::ConstPtr device = DeviceKitInformation::device(kit); if (device) { @@ -524,32 +547,10 @@ static void startRemoteTool(QmlProfilerTool *tool, StartMode mode) sp.sysroot = SysRootKitInformation::sysRoot(kit).toString(); sp.analyzerPort = port; - AnalyzerRunControl *rc = tool->createRunControl(sp, 0); - + AnalyzerRunControl *rc = createRunControl(sp, 0); ProjectExplorerPlugin::startRunControl(rc, QmlProfilerRunMode); } -void QmlProfilerTool::startTool(StartMode mode) -{ - if (d->m_recordButton->isChecked()) { - if (!checkForUnsavedNotes()) - return; - else - clearData(); // clear right away to suppress second warning on server recording change - } - - // Make sure mode is shown. - AnalyzerManager::showMode(); - - if (mode == StartLocal) { - // ### not sure if we're supposed to check if the RunConFiguration isEnabled - Project *pro = SessionManager::startupProject(); - ProjectExplorerPlugin::instance()->runProject(pro, QmlProfilerRunMode); - } else if (mode == StartRemote) { - Internal::startRemoteTool(this, mode); - } -} - void QmlProfilerTool::logState(const QString &msg) { MessageManager::write(msg, MessageManager::Flash); @@ -601,7 +602,7 @@ void QmlProfilerTool::showLoadDialog() if (ModeManager::currentMode()->id() != MODE_ANALYZE) AnalyzerManager::showMode(); - AnalyzerManager::selectTool("QmlProfiler", StartRemote); + AnalyzerManager::selectTool(QmlProfilerRemoteActionId); QString filename = QFileDialog::getOpenFileName(ICore::mainWindow(), tr("Load QML Trace"), QString(), tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension))); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 74c6b24174..924ab77edd 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -43,6 +43,8 @@ namespace QmlProfiler { namespace Internal { const char QmlProfilerToolId[] = "QmlProfiler"; +const char QmlProfilerLocalActionId[] = "QmlProfiler.Local"; +const char QmlProfilerRemoteActionId[] = "QmlProfiler.Remote"; class QmlProfilerTool : public QObject { @@ -56,7 +58,8 @@ public: ProjectExplorer::RunConfiguration *runConfiguration = 0); QWidget *createWidgets(); - void startTool(Analyzer::StartMode mode); + void startLocalTool(); + void startRemoteTool(); QList <QAction *> profilerContextMenuActions() const; diff --git a/src/plugins/qmlprojectmanager/QmlProjectManager.mimetypes.xml b/src/plugins/qmlprojectmanager/QmlProjectManager.mimetypes.xml index 0149926c12..812d1cb879 100644 --- a/src/plugins/qmlprojectmanager/QmlProjectManager.mimetypes.xml +++ b/src/plugins/qmlprojectmanager/QmlProjectManager.mimetypes.xml @@ -2,7 +2,7 @@ <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-type type="application/x-qmlproject"> - <sub-class-of type="application/x-qml"/> + <sub-class-of type="text/x-qml"/> <comment>QML Project file</comment> <glob pattern="*.qmlproject"/> </mime-type> diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 5ba76147ce..3da719d53b 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -269,7 +269,7 @@ void QmlProjectRunConfiguration::updateEnabled() IDocument *document = EditorManager::currentDocument(); if (document) { m_currentFileFilename = document->filePath().toString(); - if (mdb.mimeTypeForFile(mainScript()).matchesName(QLatin1String("application/x-qml"))) + if (mdb.mimeTypeForFile(mainScript()).matchesName(QLatin1String("text/x-qml"))) qmlFileFound = true; } if (!document @@ -280,7 +280,7 @@ void QmlProjectRunConfiguration::updateEnabled() const QFileInfo fi(filename); if (!filename.isEmpty() && fi.baseName()[0].isLower() - && mdb.mimeTypeForFile(fi).matchesName(QLatin1String("application/x-qml"))) + && mdb.mimeTypeForFile(fi).matchesName(QLatin1String("text/x-qml"))) { m_currentFileFilename = filename; qmlFileFound = true; diff --git a/src/plugins/qnx/blackberrypotentialkit.cpp b/src/plugins/qnx/blackberrypotentialkit.cpp index 32668afb20..6d53f225e5 100644 --- a/src/plugins/qnx/blackberrypotentialkit.cpp +++ b/src/plugins/qnx/blackberrypotentialkit.cpp @@ -80,9 +80,7 @@ bool BlackBerryPotentialKit::shouldShow() void BlackBerryPotentialKit::openSettings(QWidget *parent) { - Core::ICore::showOptionsDialog(Qnx::Constants::QNX_BB_CATEGORY, - Qnx::Constants::QNX_BB_SETUP_ID, - parent); + Core::ICore::showOptionsDialog(Qnx::Constants::QNX_BB_SETUP_ID, parent); } BlackBerryPotentialKitWidget::BlackBerryPotentialKitWidget(QWidget *parent) diff --git a/src/plugins/qtsupport/qtkitconfigwidget.cpp b/src/plugins/qtsupport/qtkitconfigwidget.cpp index 35dacde759..88c4bb8a42 100644 --- a/src/plugins/qtsupport/qtkitconfigwidget.cpp +++ b/src/plugins/qtsupport/qtkitconfigwidget.cpp @@ -139,9 +139,7 @@ void QtKitConfigWidget::versionsChanged(const QList<int> &added, const QList<int void QtKitConfigWidget::manageQtVersions() { - Core::ICore::showOptionsDialog(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, - Constants::QTVERSION_SETTINGS_PAGE_ID, - buttonWidget()); + Core::ICore::showOptionsDialog(Constants::QTVERSION_SETTINGS_PAGE_ID, buttonWidget()); } void QtKitConfigWidget::currentWasChanged(int idx) diff --git a/src/plugins/remotelinux/remotelinuxrunconfigurationfactory.cpp b/src/plugins/remotelinux/remotelinuxrunconfigurationfactory.cpp index 54d257dc25..6f326823b6 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfigurationfactory.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfigurationfactory.cpp @@ -52,7 +52,7 @@ QString stringFromId(Core::Id id) QByteArray idStr = id.name(); if (!idStr.startsWith(RemoteLinuxRunConfiguration::IdPrefix)) return QString(); - return QString::fromUtf8(idStr.mid(strlen(RemoteLinuxRunConfiguration::IdPrefix))); + return QString::fromUtf8(idStr.mid(int(strlen(RemoteLinuxRunConfiguration::IdPrefix)))); } } // namespace diff --git a/src/plugins/remotelinux/remotelinuxrunconfigurationwidget.cpp b/src/plugins/remotelinux/remotelinuxrunconfigurationwidget.cpp index a6f4fea7da..f364f133e8 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfigurationwidget.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfigurationwidget.cpp @@ -33,6 +33,7 @@ #include <coreplugin/coreconstants.h> #include <utils/detailswidget.h> +#include <utils/qtcprocess.h> #include <QCoreApplication> #include <QDir> @@ -150,7 +151,8 @@ void RemoteLinuxRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayou altRemoteExeLayout->addWidget(&d->useAlternateCommandBox); d->genericWidgetsLayout.addRow(tr("Alternate executable on device:"), altRemoteExeWidget); - d->argsLineEdit.setText(d->runConfiguration->arguments().join(QLatin1Char(' '))); + d->argsLineEdit.setText(Utils::QtcProcess::joinArgs(d->runConfiguration->arguments(), + Utils::OsTypeLinux)); d->genericWidgetsLayout.addRow(tr("Arguments:"), &d->argsLineEdit); d->workingDirLineEdit.setPlaceholderText(tr("<default>")); diff --git a/src/plugins/subversion/settingspage.ui b/src/plugins/subversion/settingspage.ui index c040ca41fa..0adcf1cc31 100644 --- a/src/plugins/subversion/settingspage.ui +++ b/src/plugins/subversion/settingspage.ui @@ -17,6 +17,9 @@ <string>Configuration</string> </property> <layout class="QFormLayout" name="formLayout_3"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="commandLabel"> <property name="text"> @@ -39,6 +42,9 @@ <bool>true</bool> </property> <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <item row="0" column="0"> <widget class="QLabel" name="usernameLabel"> <property name="text"> diff --git a/src/plugins/subversion/subversionsubmiteditor.cpp b/src/plugins/subversion/subversionsubmiteditor.cpp index 89baf7c5b7..d08e70824d 100644 --- a/src/plugins/subversion/subversionsubmiteditor.cpp +++ b/src/plugins/subversion/subversionsubmiteditor.cpp @@ -28,7 +28,6 @@ ** ****************************************************************************/ - #include "subversionsubmiteditor.h" #include <coreplugin/idocument.h> @@ -57,20 +56,13 @@ void SubversionSubmitEditor::setStatusList(const QList<StatusFilePair> &statusOu setFileModel(model, this->checkScriptWorkingDirectory()); } -/* -QStringList SubversionSubmitEditor::vcsFileListToFileList(const QStringList &rl) const +QByteArray SubversionSubmitEditor::fileContents() const { - QStringList files; - const QStringList::const_iterator cend = rl.constEnd(); - for (QStringList::const_iterator it = rl.constBegin(); it != cend; ++it) - files.push_back(SubversionSubmitEditor::fileFromStatusLine(*it)); - return files; + return description().toUtf8(); } -QString SubversionSubmitEditor::fileFromStatusLine(const QString &statusLine) +bool SubversionSubmitEditor::setFileContents(const QByteArray &contents) { - enum { filePos = 7 }; - return statusLine.mid(filePos, statusLine.size() - filePos); + setDescription(QString::fromUtf8(contents)); + return true; } - -*/ diff --git a/src/plugins/subversion/subversionsubmiteditor.h b/src/plugins/subversion/subversionsubmiteditor.h index 39e82ba1f8..afba027936 100644 --- a/src/plugins/subversion/subversionsubmiteditor.h +++ b/src/plugins/subversion/subversionsubmiteditor.h @@ -50,6 +50,9 @@ public: typedef QPair<QString, QString> StatusFilePair; void setStatusList(const QList<StatusFilePair> &statusOutput); + + QByteArray fileContents() const; + bool setFileContents(const QByteArray &contents); }; } // namespace Internal diff --git a/src/plugins/texteditor/behaviorsettingspage.cpp b/src/plugins/texteditor/behaviorsettingspage.cpp index a55538c332..4f2d6b4ae4 100644 --- a/src/plugins/texteditor/behaviorsettingspage.cpp +++ b/src/plugins/texteditor/behaviorsettingspage.cpp @@ -268,12 +268,10 @@ void BehaviorSettingsPage::openCodingStylePreferences(TabSettingsWidget::CodingS { switch (link) { case TabSettingsWidget::CppLink: - Core::ICore::showOptionsDialog(CppTools::Constants::CPP_SETTINGS_CATEGORY, - CppTools::Constants::CPP_CODE_STYLE_SETTINGS_ID); + Core::ICore::showOptionsDialog(CppTools::Constants::CPP_CODE_STYLE_SETTINGS_ID); break; case TabSettingsWidget::QtQuickLink: - Core::ICore::showOptionsDialog(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML, - QmlJSTools::Constants::QML_JS_CODE_STYLE_SETTINGS_ID); + Core::ICore::showOptionsDialog(QmlJSTools::Constants::QML_JS_CODE_STYLE_SETTINGS_ID); break; } } diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 632bb1c18c..bafc47481b 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -548,9 +548,7 @@ static void updateEditorInfoBar(TextEditorWidget *widget) "Would you like to try to find one?"), InfoBarEntry::GlobalSuppressionEnabled); info.setCustomButtonInfo(BaseTextEditor::tr("Show Highlighter Options..."), [widget]() { - ICore::showOptionsDialog(Constants::TEXT_EDITOR_SETTINGS_CATEGORY, - Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS, - widget); + ICore::showOptionsDialog(Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS, widget); }); infoBar->addInfo(info); diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 2dc03c7785..27771bafc5 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -150,7 +150,6 @@ public slots: void updateCostFormat(); void handleFilterProjectCosts(); - void handleShowCostsAction(); void handleShowCostsOfFunction(); void slotGoToOverview(); @@ -558,16 +557,18 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa return rc; } -void CallgrindTool::startTool(StartMode mode) +void CallgrindTool::startLocalTool() { - if (mode == StartLocal && checkForLocalStart(ReleaseMode)) { - Project *pro = SessionManager::startupProject(); - ProjectExplorerPlugin::instance()->runProject(pro, CallgrindRunMode); + if (checkForLocalStart(ReleaseMode)) { + ProjectExplorerPlugin::runStartupProject(CallgrindRunMode); d->setBusyCursor(true); } +} +void CallgrindTool::startRemoteTool() +{ AnalyzerStartParameters sp; - if (mode == StartRemote && checkForRemoteStart(&sp)) { + if (checkForRemoteStart(&sp)) { AnalyzerRunControl *rc = createRunControl(sp, 0); ProjectExplorerPlugin::startRunControl(rc, CallgrindRunMode); d->setBusyCursor(true); @@ -882,33 +883,15 @@ void CallgrindToolPrivate::editorOpened(IEditor *editor) void CallgrindToolPrivate::requestContextMenu(TextEditorWidget *widget, int line, QMenu *menu) { - // find callgrind text mark that corresponds to this editor's file and line number - const Function *func = 0; + // Find callgrind text mark that corresponds to this editor's file and line number foreach (CallgrindTextMark *textMark, m_textMarks) { if (textMark->fileName() == widget->textDocument()->filePath().toString() && textMark->lineNumber() == line) { - func = textMark->function(); + const Function *func = textMark->function(); + QAction *action = menu->addAction(tr("Select this Function in the Analyzer Output")); + connect(action, &QAction::triggered, this, [this, func] { selectFunction(func); }); break; } } - if (!func) - return; // no callgrind text mark under cursor, return - - // add our action to the context menu - QAction *action = new QAction(tr("Select this Function in the Analyzer Output"), menu); - connect(action, &QAction::triggered, this, &CallgrindToolPrivate::handleShowCostsAction); - action->setData(QVariant::fromValue<const Function *>(func)); - menu->addAction(action); -} - -void CallgrindToolPrivate::handleShowCostsAction() -{ - const QAction *action = qobject_cast<QAction *>(sender()); - QTC_ASSERT(action, return); - - const Function *func = action->data().value<const Function *>(); - QTC_ASSERT(func, return); - - selectFunction(func); } void CallgrindToolPrivate::handleShowCostsOfFunction() @@ -925,7 +908,7 @@ void CallgrindToolPrivate::handleShowCostsOfFunction() m_toggleCollectFunction = qualifiedFunctionName + QLatin1String("()"); - AnalyzerManager::selectTool(CallgrindToolId, StartLocal); + AnalyzerManager::selectTool(CallgrindLocalActionId); AnalyzerManager::startTool(); } diff --git a/src/plugins/valgrind/callgrindtool.h b/src/plugins/valgrind/callgrindtool.h index 809d0efe3c..0a72cd363a 100644 --- a/src/plugins/valgrind/callgrindtool.h +++ b/src/plugins/valgrind/callgrindtool.h @@ -37,6 +37,8 @@ namespace Valgrind { namespace Internal { const char CallgrindToolId[] = "Callgrind"; +const char CallgrindLocalActionId[] = "Callgrind.Local"; +const char CallgrindRemoteActionId[] = "Callgrind.Remote"; class CallgrindToolPrivate; @@ -52,7 +54,8 @@ public: ProjectExplorer::RunConfiguration *runConfiguration = 0); QWidget *createWidgets(); - void startTool(Analyzer::StartMode mode); + void startLocalTool(); + void startRemoteTool(); public slots: void handleShowCostsOfFunction(); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 4f18e98cd4..4365c077df 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -597,15 +597,16 @@ void MemcheckTool::setBusyCursor(bool busy) m_errorView->setCursor(cursor); } -void MemcheckTool::startTool(StartMode mode) +void MemcheckTool::startLocalTool() { - if (mode == StartLocal && checkForLocalStart(DebugMode)) { - Project *pro = SessionManager::startupProject(); - ProjectExplorerPlugin::instance()->runProject(pro, MemcheckRunMode); - } + if (checkForLocalStart(DebugMode)) + ProjectExplorerPlugin::runStartupProject(MemcheckRunMode); +} +void MemcheckTool::startRemoteTool() +{ AnalyzerStartParameters sp; - if (mode == StartRemote && checkForRemoteStart(&sp)) { + if (checkForRemoteStart(&sp)) { AnalyzerRunControl *rc = createRunControl(sp, 0); ProjectExplorerPlugin::startRunControl(rc, MemcheckRunMode); } @@ -617,15 +618,16 @@ MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) : setObjectName(QLatin1String("MemcheckWithGdbTool")); } -void MemcheckWithGdbTool::startTool(Analyzer::StartMode mode) +void MemcheckWithGdbTool::startLocalTool() { - if (mode == StartLocal && checkForLocalStart(DebugMode)) { - Project *pro = SessionManager::startupProject(); - ProjectExplorerPlugin::instance()->runProject(pro, MemcheckWithGdbRunMode); - } + if (checkForLocalStart(DebugMode)) + ProjectExplorerPlugin::runStartupProject(MemcheckWithGdbRunMode); +} +void MemcheckWithGdbTool::startRemoteTool() +{ AnalyzerStartParameters sp; - if (mode == StartRemote && checkForRemoteStart(&sp)) { + if (checkForRemoteStart(&sp)) { AnalyzerRunControl *rc = createRunControl(sp, 0); ProjectExplorerPlugin::startRunControl(rc, MemcheckWithGdbRunMode); } diff --git a/src/plugins/valgrind/memchecktool.h b/src/plugins/valgrind/memchecktool.h index ac242c614c..ae118178e3 100644 --- a/src/plugins/valgrind/memchecktool.h +++ b/src/plugins/valgrind/memchecktool.h @@ -83,11 +83,12 @@ class MemcheckTool : public QObject public: MemcheckTool(QObject *parent); - void startTool(Analyzer::StartMode mode); + void startLocalTool(); + void startRemoteTool(); QWidget *createWidgets(); Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, - ProjectExplorer::RunConfiguration *runConfiguration = 0); + ProjectExplorer::RunConfiguration *runConfiguration); private slots: void settingsDestroyed(QObject *settings); @@ -139,7 +140,8 @@ class MemcheckWithGdbTool : public MemcheckTool public: MemcheckWithGdbTool(QObject *parent); - void startTool(Analyzer::StartMode mode); + void startLocalTool(); + void startRemoteTool(); MemcheckRunControl *createMemcheckRunControl( const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration) Q_DECL_OVERRIDE; diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp index 7b0dfd0fac..a3bf8b2176 100644 --- a/src/plugins/valgrind/valgrindplugin.cpp +++ b/src/plugins/valgrind/valgrindplugin.cpp @@ -125,7 +125,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) "When a problem is detected, the application is interrupted and can be debugged"); MemcheckTool *mcTool = m_memcheckTool; - auto mcToolStarter = [mcTool](StartMode mode) { return mcTool->startTool(mode); }; auto mcWidgetCreator = [mcTool] { return mcTool->createWidgets(); }; auto mcRunControlCreator = [mcTool](const AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration) { @@ -133,7 +132,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) }; MemcheckWithGdbTool *mcgTool = m_memcheckWithGdbTool; - auto mcgToolStarter = [mcgTool](StartMode mode) { return mcgTool->startTool(mode); }; auto mcgWidgetCreator = [mcgTool] { return mcgTool->createWidgets(); }; auto mcgRunControlCreator = [mcgTool](const AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration) { @@ -141,7 +139,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) }; CallgrindTool *cgTool = m_callgrindTool; - auto cgToolStarter = [cgTool](StartMode mode) { return cgTool->startTool(mode); }; auto cgWidgetCreator = [cgTool] { return cgTool->createWidgets(); }; auto cgRunControlCreator = [cgTool](const AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration) { @@ -154,7 +151,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) action->setToolId("Memcheck"); action->setWidgetCreator(mcWidgetCreator); action->setRunControlCreator(mcRunControlCreator); - action->setToolStarter(mcToolStarter); + action->setToolStarter([mcTool] { mcTool->startLocalTool(); }); action->setRunMode(ProjectExplorer::MemcheckRunMode); action->setText(tr("Valgrind Memory Analyzer")); action->setToolTip(memcheckToolTip); @@ -168,7 +165,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) action->setToolId("MemcheckWithGdb"); action->setWidgetCreator(mcgWidgetCreator); action->setRunControlCreator(mcgRunControlCreator); - action->setToolStarter(mcgToolStarter); + action->setToolStarter([mcgTool] { mcgTool->startLocalTool(); }); action->setRunMode(ProjectExplorer::MemcheckWithGdbRunMode); action->setText(tr("Valgrind Memory Analyzer with GDB")); action->setToolTip(memcheckWithGdbToolTip); @@ -178,11 +175,11 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) AnalyzerManager::addAction(action); action = new AnalyzerAction(this); - action->setActionId("Callgrind.Local"); + action->setActionId(CallgrindLocalActionId); action->setToolId(CallgrindToolId); action->setWidgetCreator(cgWidgetCreator); action->setRunControlCreator(cgRunControlCreator); - action->setToolStarter(cgToolStarter); + action->setToolStarter([cgTool] { cgTool->startLocalTool(); }); action->setRunMode(ProjectExplorer::CallgrindRunMode); action->setText(tr("Valgrind Function Profiler")); action->setToolTip(callgrindToolTip); @@ -197,7 +194,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) action->setToolId("Memcheck"); action->setWidgetCreator(mcWidgetCreator); action->setRunControlCreator(mcRunControlCreator); - action->setToolStarter(mcToolStarter); + action->setToolStarter([mcTool] { mcTool->startRemoteTool(); }); action->setRunMode(ProjectExplorer::MemcheckRunMode); action->setText(tr("Valgrind Memory Analyzer (External Remote Application)")); action->setToolTip(memcheckToolTip); @@ -206,11 +203,11 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) AnalyzerManager::addAction(action); action = new AnalyzerAction(this); - action->setActionId("Callgrind.Remote"); + action->setActionId(CallgrindRemoteActionId); action->setToolId(CallgrindToolId); action->setWidgetCreator(cgWidgetCreator); action->setRunControlCreator(cgRunControlCreator); - action->setToolStarter(cgToolStarter); + action->setToolStarter([cgTool] { cgTool->startRemoteTool(); }); action->setRunMode(ProjectExplorer::CallgrindRunMode); action->setText(tr("Valgrind Function Profiler (External Remote Application)")); action->setToolTip(callgrindToolTip); diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index f39315b385..c383b0d648 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -236,17 +236,16 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa slotUpdateEditorSettings(settings); connect(VcsPlugin::instance(), &VcsPlugin::settingsChanged, this, &VcsBaseSubmitEditor::slotUpdateEditorSettings); - // Commit data refresh might lead to closing the editor, so use a queued connection connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, this, [this]() { if (Core::EditorManager::currentEditor() == this) updateFileModel(); - }, Qt::QueuedConnection); + }); connect(qApp, &QApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) { if (state == Qt::ApplicationActive) updateFileModel(); - }, Qt::QueuedConnection); + }); auto aggregate = new Aggregation::Aggregate; aggregate->add(new Core::BaseTextFind(descriptionEdit)); @@ -516,15 +515,25 @@ void VcsBaseSubmitEditor::slotDiffSelectedVcsFiles(const QList<int> &rawList) QByteArray VcsBaseSubmitEditor::fileContents() const { - return d->m_widget->descriptionText().toLocal8Bit(); + return description().toLocal8Bit(); } bool VcsBaseSubmitEditor::setFileContents(const QByteArray &contents) { - d->m_widget->setDescriptionText(QString::fromUtf8(contents)); + setDescription(QString::fromUtf8(contents)); return true; } +QString VcsBaseSubmitEditor::description() const +{ + return d->m_widget->descriptionText(); +} + +void VcsBaseSubmitEditor::setDescription(const QString &text) +{ + d->m_widget->setDescriptionText(text); +} + bool VcsBaseSubmitEditor::isDescriptionMandatory() const { return d->m_widget->isDescriptionMandatory(); diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h index 391205c87c..dfd92bf0f5 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.h +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h @@ -155,6 +155,9 @@ protected: virtual QByteArray fileContents() const; virtual bool setFileContents(const QByteArray &contents); + QString description() const; + void setDescription(const QString &text); + void setDescriptionMandatory(bool v); bool isDescriptionMandatory() const; diff --git a/src/plugins/vcsbase/wizard/vcsconfigurationpage.cpp b/src/plugins/vcsbase/wizard/vcsconfigurationpage.cpp index 62639eb73f..d0f88bfa5f 100644 --- a/src/plugins/vcsbase/wizard/vcsconfigurationpage.cpp +++ b/src/plugins/vcsbase/wizard/vcsconfigurationpage.cpp @@ -174,7 +174,7 @@ bool VcsConfigurationPage::isComplete() const void VcsConfigurationPage::openConfiguration() { - ICore::showOptionsDialog(Constants::VCS_SETTINGS_CATEGORY, d->m_versionControl->id(), this); + ICore::showOptionsDialog(d->m_versionControl->id(), this); } } // namespace VcsBase diff --git a/src/shared/qbs b/src/shared/qbs -Subproject 9567f37d9f7b5f47caa01ba2d0dca61314d4deb +Subproject 6b9b900b699f507d0e7914ebca7e56d9f643c07 |