diff options
author | hjk <hjk@qt.io> | 2019-08-02 12:00:39 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-08-02 11:32:44 +0000 |
commit | ca67d3016c8477d038add8c7d9b952e998375e69 (patch) | |
tree | b3f74e23581e2acc1ef92b7dc29944760053198d | |
parent | 1dfa84c362db5a23841e0e5e893bc8f6e5c46129 (diff) | |
download | qt-creator-ca67d3016c8477d038add8c7d9b952e998375e69.tar.gz |
ProjectExplorer: Use direct calls to signal update wishes
Change-Id: I73d4a417f23bcf7fd8c9e16640e920100a6cce5a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | src/plugins/projectexplorer/buildconfiguration.cpp | 8 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 29 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.h | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runconfiguration.cpp | 17 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runconfiguration.h | 1 |
5 files changed, 27 insertions, 30 deletions
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 4d2bc709d2..c7d0ce24f4 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -39,6 +39,7 @@ #include "projectmacroexpander.h" #include "projecttree.h" #include "target.h" +#include "session.h" #include <coreplugin/idocument.h> @@ -104,6 +105,13 @@ BuildConfiguration::BuildConfiguration(Target *target, Core::Id id) m_buildDirectoryAspect->setEnvironment(environment()); this->target()->buildEnvironmentChanged(this); }); + + connect(this, &BuildConfiguration::enabledChanged, this, [this] { + if (isActive() && project() == SessionManager::startupProject()) { + ProjectExplorerPlugin::updateActions(); + emit ProjectExplorerPlugin::instance()->updateRunActions(); + } + }); } Utils::FilePath BuildConfiguration::buildDirectory() const diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 59e3f2e36b..0148933084 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -357,7 +357,6 @@ public: void buildQueueFinished(bool success); - void buildStateChanged(ProjectExplorer::Project * pro); void loadAction(); void handleUnloadProject(); void unloadProjectContextMenu(); @@ -1390,7 +1389,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er auto buildManager = new BuildManager(this, dd->m_cancelBuildAction); connect(buildManager, &BuildManager::buildStateChanged, - dd, &ProjectExplorerPluginPrivate::buildStateChanged); + dd, &ProjectExplorerPluginPrivate::updateActions); connect(buildManager, &BuildManager::buildQueueFinished, dd, &ProjectExplorerPluginPrivate::buildQueueFinished, Qt::QueuedConnection); @@ -2254,12 +2253,6 @@ void ProjectExplorerPluginPrivate::restoreSession() updateActions(); } -void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro) -{ - Q_UNUSED(pro) - updateActions(); -} - void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *runConfiguration, Core::Id runMode) { if (!runConfiguration->isConfigured()) { @@ -2895,21 +2888,8 @@ QList<QPair<Runnable, Utils::ProcessHandle>> ProjectExplorerPlugin::runningRunCo void ProjectExplorerPluginPrivate::projectAdded(Project *pro) { + Q_UNUSED(pro) m_projectsMode.setEnabled(true); - - // more specific action en and disabling ? - pro->subscribeSignal(&BuildConfiguration::enabledChanged, this, [this]() { - auto bc = qobject_cast<BuildConfiguration *>(sender()); - if (bc && bc->isActive() && bc->project() == SessionManager::startupProject()) { - updateActions(); - emit m_instance->updateRunActions(); - } - }); - pro->subscribeSignal(&RunConfiguration::requestRunActionsUpdate, this, [this]() { - auto rc = qobject_cast<RunConfiguration *>(sender()); - if (rc && rc->isActive() && rc->project() == SessionManager::startupProject()) - emit m_instance->updateRunActions(); - }); } void ProjectExplorerPluginPrivate::projectRemoved(Project *pro) @@ -3938,6 +3918,11 @@ QString ProjectExplorerPlugin::defaultBuildDirectoryTemplate() return QString(Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE); } +void ProjectExplorerPlugin::updateActions() +{ + dd->updateActions(); +} + QList<QPair<QString, QString> > ProjectExplorerPlugin::recentProjects() { return dd->recentProjects(); diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 23c2098216..6babd79d89 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -172,6 +172,8 @@ public: static QString buildDirectoryTemplate(); static QString defaultBuildDirectoryTemplate(); + static void updateActions(); + signals: void finishedInitialization(); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index c0d1ce73c8..fe9772cb62 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -25,17 +25,18 @@ #include "runconfiguration.h" -#include "project.h" -#include "runcontrol.h" -#include "target.h" -#include "toolchain.h" #include "abi.h" #include "buildconfiguration.h" #include "environmentaspect.h" #include "kitinformation.h" +#include "kitinformation.h" +#include "project.h" +#include "projectexplorer.h" #include "runconfigurationaspects.h" +#include "runcontrol.h" #include "session.h" -#include "kitinformation.h" +#include "target.h" +#include "toolchain.h" #include <utils/algorithm.h> #include <utils/checkablemessagebox.h> @@ -172,8 +173,10 @@ RunConfiguration::RunConfiguration(Target *target, Core::Id id) updateEnabledState(); }); - connect(this, &RunConfiguration::enabledChanged, - this, &RunConfiguration::requestRunActionsUpdate); + connect(this, &RunConfiguration::enabledChanged, this, [this] { + if (isActive() && project() == SessionManager::startupProject()) + emit ProjectExplorerPlugin::instance()->updateRunActions(); + }); Utils::MacroExpander *expander = macroExpander(); expander->setDisplayName(tr("Run Settings")); diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index e83c4e29a4..018f2546c7 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -185,7 +185,6 @@ public: } signals: - void requestRunActionsUpdate(); void configurationFinished(); void enabledChanged(); |