From 1e12e53e0d6afc26e42099dcf840dbda46f4574e Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Fri, 11 Jul 2014 18:13:03 +0200 Subject: [PATCH] ProjectWindow: Remove special handling for TargetSettingsPanelWidget Instead hide it in a standard IProjectPanelFactory Change-Id: I7e49b7be00e26c5f33e32d692079e2b82cbfe087 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/iprojectproperties.h | 5 +++++ src/plugins/projectexplorer/projectexplorer.cpp | 14 ++++++++++++++ src/plugins/projectexplorer/projectwindow.cpp | 16 ---------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/plugins/projectexplorer/iprojectproperties.h b/src/plugins/projectexplorer/iprojectproperties.h index 880becd9053..8ef360b12ce 100644 --- a/src/plugins/projectexplorer/iprojectproperties.h +++ b/src/plugins/projectexplorer/iprojectproperties.h @@ -84,6 +84,11 @@ public: }; } + void setCreateWidgetFunction(std::function function) + { + m_createWidgetFunction = function; + } + static bool supportsAllProjects(Project *); private: diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 26c7a59cc3c..aa164826368 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -83,6 +83,7 @@ #include "devicesupport/desktopdevicefactory.h" #include "devicesupport/devicemanager.h" #include "devicesupport/devicesettingspage.h" +#include "targetsettingspanel.h" #ifdef Q_OS_WIN # include "windebuginterface.h" @@ -505,6 +506,19 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er unconfiguredProjectPanel->setSimpleCreateWidgetFunction(icon); addAutoReleasedObject(unconfiguredProjectPanel); + auto targetSettingsPanelFactory = new IProjectPanelFactory; + targetSettingsPanelFactory->setPriority(-10); + displayName = QCoreApplication::translate("TargetSettingsPanelFactory", "Build & Run"); + targetSettingsPanelFactory->setDisplayName(displayName); + targetSettingsPanelFactory->setSupportsFunction([](Project *project) { + return !project->targets().isEmpty() + || project->requiresTargetPanel(); + }); + targetSettingsPanelFactory->setCreateWidgetFunction([](Project *project) { + return new TargetSettingsPanelWidget(project); + }); + addAutoReleasedObject(targetSettingsPanelFactory); + addAutoReleasedObject(new ProcessStepFactory); addAutoReleasedObject(new AllProjectsFind); diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 6ef504c9d2b..712e18f6c13 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -37,7 +37,6 @@ #include "projectexplorer.h" #include "session.h" #include "iprojectproperties.h" -#include "targetsettingspanel.h" #include "target.h" #include @@ -165,9 +164,6 @@ void ProjectWindow::registerProject(ProjectExplorer::Project *project) bool projectHasTarget = hasTarget(project); m_hasTarget.insert(project, projectHasTarget); - if (projectHasTarget || project->requiresTargetPanel()) // Use the Targets page - subtabs << QCoreApplication::translate("TargetSettingsPanelFactory", "Build & Run"); - // Add the project specific pages QList factories = ExtensionSystem::PluginManager::getObjects(); Utils::sort(factories, &IProjectPanelFactory::prioritySort); @@ -216,18 +212,6 @@ void ProjectWindow::showProperties(int index, int subIndex) int pos = 0; IProjectPanelFactory *fac = 0; - if (m_hasTarget.value(project) || project->requiresTargetPanel()) { - if (subIndex == 0) { - // Targets page - removeCurrentWidget(); - TargetSettingsPanelWidget *panelWidget = new TargetSettingsPanelWidget(project); - m_currentWidget = panelWidget; - m_centralWidget->addWidget(m_currentWidget); - m_centralWidget->setCurrentWidget(m_currentWidget); - } - ++pos; - } - QList factories = ExtensionSystem::PluginManager::getObjects(); Utils::sort(factories, &IProjectPanelFactory::prioritySort); foreach (IProjectPanelFactory *panelFactory, factories) {