summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/clangcodemodel/clangcodemodelplugin.cpp7
-rw-r--r--src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp25
-rw-r--r--src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h9
-rw-r--r--src/plugins/projectexplorer/codestylesettingspropertiespage.cpp25
-rw-r--r--src/plugins/projectexplorer/codestylesettingspropertiespage.h11
-rw-r--r--src/plugins/projectexplorer/dependenciespanel.cpp29
-rw-r--r--src/plugins/projectexplorer/dependenciespanel.h12
-rw-r--r--src/plugins/projectexplorer/editorsettingspropertiespage.cpp25
-rw-r--r--src/plugins/projectexplorer/editorsettingspropertiespage.h9
-rw-r--r--src/plugins/projectexplorer/iprojectproperties.cpp84
-rw-r--r--src/plugins/projectexplorer/iprojectproperties.h51
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp39
-rw-r--r--src/plugins/projectexplorer/projectexplorer.pro3
-rw-r--r--src/plugins/projectexplorer/projectexplorer.qbs2
-rw-r--r--src/plugins/projectexplorer/unconfiguredprojectpanel.cpp30
-rw-r--r--src/plugins/projectexplorer/unconfiguredprojectpanel.h11
16 files changed, 171 insertions, 201 deletions
diff --git a/src/plugins/clangcodemodel/clangcodemodelplugin.cpp b/src/plugins/clangcodemodel/clangcodemodelplugin.cpp
index 637921a84e..1816387b85 100644
--- a/src/plugins/clangcodemodel/clangcodemodelplugin.cpp
+++ b/src/plugins/clangcodemodel/clangcodemodelplugin.cpp
@@ -54,7 +54,12 @@ bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *err
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
- addAutoReleasedObject(new ClangProjectSettingsPanelFactory);
+ auto panelFactory = new ProjectExplorer::IProjectPanelFactory();
+ panelFactory->setPriority(60);
+ panelFactory->setDisplayName(ClangProjectSettingsWidget::tr("Clang Settings"));
+ panelFactory->setSimpleCreatePanelFunction<ClangProjectSettingsWidget>(QIcon());
+
+ addAutoReleasedObject(panelFactory);
ClangCodeModel::Internal::initializeClang();
diff --git a/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp
index fe994b11b5..f9032d5367 100644
--- a/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp
+++ b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp
@@ -38,31 +38,6 @@
using namespace ProjectExplorer;
using namespace ClangCodeModel::Internal;
-QString ClangProjectSettingsPanelFactory::displayName() const
-{
- return ClangProjectSettingsWidget::tr("Clang Settings");
-}
-
-int ClangProjectSettingsPanelFactory::priority() const
-{
- return 60;
-}
-
-bool ClangProjectSettingsPanelFactory::supports(Project *project)
-{
- Q_UNUSED(project);
-
- return true;
-}
-
-PropertiesPanel *ClangProjectSettingsPanelFactory::createPanel(Project *project)
-{
- PropertiesPanel *panel = new PropertiesPanel;
- panel->setDisplayName(ClangProjectSettingsWidget::tr("Clang Settings"));
- panel->setWidget(new ClangProjectSettingsWidget(project));
- return panel;
-}
-
ClangProjectSettingsWidget::ClangProjectSettingsWidget(Project *project)
: m_project(project)
{
diff --git a/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h
index 623301c8c5..823af73883 100644
--- a/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h
+++ b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h
@@ -39,15 +39,6 @@
namespace ClangCodeModel {
namespace Internal {
-class ClangProjectSettingsPanelFactory: public ProjectExplorer::IProjectPanelFactory
-{
-public:
- QString displayName() const;
- int priority() const;
- bool supports(ProjectExplorer::Project *project);
- ProjectExplorer::PropertiesPanel *createPanel(ProjectExplorer::Project *project);
-};
-
class ClangProjectSettingsWidget: public QWidget
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/codestylesettingspropertiespage.cpp b/src/plugins/projectexplorer/codestylesettingspropertiespage.cpp
index 8b320c5047..10c90f7950 100644
--- a/src/plugins/projectexplorer/codestylesettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/codestylesettingspropertiespage.cpp
@@ -38,31 +38,6 @@ using namespace TextEditor;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
-QString CodeStyleSettingsPanelFactory::displayName() const
-{
- return QCoreApplication::translate("CodeStyleSettingsPanelFactory", "Code Style");
-}
-
-int CodeStyleSettingsPanelFactory::priority() const
-{
- return 40;
-}
-
-bool CodeStyleSettingsPanelFactory::supports(Project *project)
-{
- Q_UNUSED(project);
- return true;
-}
-
-PropertiesPanel *CodeStyleSettingsPanelFactory::createPanel(Project *project)
-{
- PropertiesPanel *panel = new PropertiesPanel;
- panel->setWidget(new CodeStyleSettingsWidget(project));
- panel->setIcon(QIcon(QLatin1String(":/projectexplorer/images/CodeStyleSettings.png")));
- panel->setDisplayName(QCoreApplication::translate("CodeStyleSettingsPanel", "Code Style"));
- return panel;
-}
-
CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : QWidget(), m_project(project)
{
m_ui.setupUi(this);
diff --git a/src/plugins/projectexplorer/codestylesettingspropertiespage.h b/src/plugins/projectexplorer/codestylesettingspropertiespage.h
index c5945590ca..840fe0e7b7 100644
--- a/src/plugins/projectexplorer/codestylesettingspropertiespage.h
+++ b/src/plugins/projectexplorer/codestylesettingspropertiespage.h
@@ -39,17 +39,6 @@ class EditorConfiguration;
namespace Internal {
-class CodeStyleSettingsPanelFactory : public IProjectPanelFactory
-{
-public:
- QString displayName() const;
- int priority() const;
- PropertiesPanel *createPanel(Project *project);
- bool supports(Project *project);
-};
-
-class CodeStyleSettingsWidget;
-
class CodeStyleSettingsWidget : public QWidget
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/dependenciespanel.cpp b/src/plugins/projectexplorer/dependenciespanel.cpp
index 1fbb99df51..5fcf24725e 100644
--- a/src/plugins/projectexplorer/dependenciespanel.cpp
+++ b/src/plugins/projectexplorer/dependenciespanel.cpp
@@ -231,34 +231,5 @@ DependenciesWidget::DependenciesWidget(Project *project, QWidget *parent)
layout->addSpacerItem(new QSpacerItem(0, 0 , QSizePolicy::Expanding, QSizePolicy::Fixed));
}
-//
-// DependenciesPanelFactory
-//
-
-QString DependenciesPanelFactory::displayName() const
-{
- return QCoreApplication::translate("DependenciesPanelFactory", "Dependencies");
-}
-
-int DependenciesPanelFactory::priority() const
-{
- return 50;
-}
-
-bool DependenciesPanelFactory::supports(Project *project)
-{
- Q_UNUSED(project);
- return true;
-}
-
-PropertiesPanel *DependenciesPanelFactory::createPanel(Project *project)
-{
- PropertiesPanel *panel = new PropertiesPanel;
- panel->setWidget(new DependenciesWidget(project));
- panel->setIcon(QIcon(QLatin1String(":/projectexplorer/images/ProjectDependencies.png")));
- panel->setDisplayName(QCoreApplication::translate("DependenciesPanel", "Dependencies"));
- return panel;
-}
-
} // namespace Internal
} // namespace ProjectExplorer
diff --git a/src/plugins/projectexplorer/dependenciespanel.h b/src/plugins/projectexplorer/dependenciespanel.h
index 3116bcb778..47fe49cbba 100644
--- a/src/plugins/projectexplorer/dependenciespanel.h
+++ b/src/plugins/projectexplorer/dependenciespanel.h
@@ -44,18 +44,6 @@ class Project;
namespace Internal {
-class DependenciesPanelFactory : public IProjectPanelFactory
-{
-public:
- DependenciesPanelFactory() {}
-
- QString displayName() const;
- int priority() const;
- bool supports(Project *project);
- PropertiesPanel *createPanel(Project *project);
-};
-
-
//
// DependenciesModel
//
diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.cpp b/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
index e26311d25e..5bb1065ca1 100644
--- a/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
@@ -37,31 +37,6 @@
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
-QString EditorSettingsPanelFactory::displayName() const
-{
- return QCoreApplication::translate("EditorSettingsPanelFactory", "Editor");
-}
-
-int EditorSettingsPanelFactory::priority() const
-{
- return 30;
-}
-
-bool EditorSettingsPanelFactory::supports(Project *project)
-{
- Q_UNUSED(project);
- return true;
-}
-
-PropertiesPanel *EditorSettingsPanelFactory::createPanel(Project *project)
-{
- PropertiesPanel *panel = new PropertiesPanel;
- panel->setDisplayName(QCoreApplication::translate("EditorSettingsPanel", "Editor"));
- panel->setWidget(new EditorSettingsWidget(project)),
- panel->setIcon(QIcon(QLatin1String(":/projectexplorer/images/EditorSettings.png")));
- return panel;
-}
-
EditorSettingsWidget::EditorSettingsWidget(Project *project) : QWidget(), m_project(project)
{
m_ui.setupUi(this);
diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.h b/src/plugins/projectexplorer/editorsettingspropertiespage.h
index 3848da1024..ab23f31abe 100644
--- a/src/plugins/projectexplorer/editorsettingspropertiespage.h
+++ b/src/plugins/projectexplorer/editorsettingspropertiespage.h
@@ -39,15 +39,6 @@ class EditorConfiguration;
namespace Internal {
-class EditorSettingsPanelFactory : public IProjectPanelFactory
-{
-public:
- QString displayName() const;
- int priority() const;
- PropertiesPanel *createPanel(Project *project);
- bool supports(Project *project);
-};
-
class EditorSettingsWidget : public QWidget
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/iprojectproperties.cpp b/src/plugins/projectexplorer/iprojectproperties.cpp
new file mode 100644
index 0000000000..ca6937b99e
--- /dev/null
+++ b/src/plugins/projectexplorer/iprojectproperties.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** 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://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: 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 "iprojectproperties.h"
+
+using namespace ProjectExplorer;
+
+
+IProjectPanelFactory::IProjectPanelFactory()
+ : m_priority(0),
+ m_supportsFunction(&supportsAllProjects)
+{}
+
+int IProjectPanelFactory::priority() const
+{
+ return m_priority;
+}
+
+void IProjectPanelFactory::setPriority(int priority)
+{
+ m_priority = priority;
+}
+
+QString IProjectPanelFactory::displayName() const
+{
+ return m_displayName;
+}
+
+void IProjectPanelFactory::setDisplayName(const QString &name)
+{
+ m_displayName = name;
+}
+
+bool IProjectPanelFactory::prioritySort(IProjectPanelFactory *a, IProjectPanelFactory *b)
+{
+ return (a->priority() == b->priority() && a < b)
+ || a->priority() < b->priority();
+}
+
+bool IProjectPanelFactory::supportsAllProjects(Project *)
+{
+ return true;
+}
+
+bool IProjectPanelFactory::supports(Project *project)
+{
+ return m_supportsFunction(project);
+}
+
+void IProjectPanelFactory::setSupportsFunction(std::function<bool (Project *)> function)
+{
+ m_supportsFunction = function;
+}
+
+PropertiesPanel *IProjectPanelFactory::createPanel(Project *project)
+{
+ return m_createPanelFunction(project);
+}
diff --git a/src/plugins/projectexplorer/iprojectproperties.h b/src/plugins/projectexplorer/iprojectproperties.h
index 369de59dd7..b50c2e186e 100644
--- a/src/plugins/projectexplorer/iprojectproperties.h
+++ b/src/plugins/projectexplorer/iprojectproperties.h
@@ -70,14 +70,49 @@ class PROJECTEXPLORER_EXPORT IProjectPanelFactory : public QObject
{
Q_OBJECT
public:
- virtual bool supports(Project *project) = 0;
- virtual PropertiesPanel *createPanel(Project *project) = 0;
-
- virtual QString displayName() const = 0;
- virtual int priority() const = 0;
- static bool prioritySort(IProjectPanelFactory *a, IProjectPanelFactory *b)
- { return (a->priority() == b->priority() && a < b)
- || a->priority() < b->priority(); }
+ IProjectPanelFactory();
+ // simple properties
+ QString displayName() const;
+ void setDisplayName(const QString &name);
+ int priority() const;
+ void setPriority(int priority);
+
+ // helper to sort by priority
+ static bool prioritySort(IProjectPanelFactory *a, IProjectPanelFactory *b);
+
+ // interface for users of IProjectPanelFactory
+ bool supports(Project *project);
+ ProjectExplorer::PropertiesPanel *createPanel(ProjectExplorer::Project *project);
+
+ // interface for "implementations" of IProjectPanelFactory
+ // by default all projects are supported, only set a custom supports function
+ // if you need something different
+ void setSupportsFunction(std::function<bool (Project *)> function);
+
+ // the simpleCreatePanelFunction creates new instance of T
+ // wraps that into a PropertiesPanel
+ // sets the passed in icon on it
+ // and uses displayName() for the displayname
+ // Note: call setDisplayName before calling this
+ template<typename T>
+ void setSimpleCreatePanelFunction(const QIcon &icon)
+ {
+ m_createPanelFunction = [icon, this](Project *project) -> PropertiesPanel * {
+ PropertiesPanel *panel = new PropertiesPanel;
+ panel->setDisplayName(this->displayName());
+ panel->setWidget(new T(project)),
+ panel->setIcon(icon);
+ return panel;
+ };
+ }
+
+ static bool supportsAllProjects(Project *);
+
+private:
+ int m_priority;
+ QString m_displayName;
+ std::function<bool (Project *)> m_supportsFunction;
+ std::function<ProjectExplorer::PropertiesPanel *(Project *)> m_createPanelFunction;
};
class PROJECTEXPLORER_EXPORT ITargetPanelFactory : public QObject
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index edb5f31b5f..846a94d603 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -469,12 +469,43 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
addAutoReleasedObject(new BuildSettingsPanelFactory);
addAutoReleasedObject(new RunSettingsPanelFactory);
- addAutoReleasedObject(new EditorSettingsPanelFactory);
- addAutoReleasedObject(new CodeStyleSettingsPanelFactory);
- addAutoReleasedObject(new DependenciesPanelFactory);
+
+ // ProjectPanelFactories
+ auto editorSettingsPanelFactory = new IProjectPanelFactory;
+ editorSettingsPanelFactory->setPriority(30);
+ QString displayName = QCoreApplication::translate("EditorSettingsPanelFactory", "Editor");
+ editorSettingsPanelFactory->setDisplayName(displayName);
+ QIcon icon = QIcon(QLatin1String(":/projectexplorer/images/EditorSettings.png"));
+ editorSettingsPanelFactory->setSimpleCreatePanelFunction<EditorSettingsWidget>(icon);
+ addAutoReleasedObject(editorSettingsPanelFactory);
+
+ auto codeStyleSettingsPanelFactory = new IProjectPanelFactory;
+ codeStyleSettingsPanelFactory->setPriority(40);
+ displayName = QCoreApplication::translate("CodeStyleSettingsPanelFactory", "Code Style");
+ codeStyleSettingsPanelFactory->setDisplayName(displayName);
+ icon = QIcon(QLatin1String(":/projectexplorer/images/CodeStyleSettings.png"));
+ codeStyleSettingsPanelFactory->setSimpleCreatePanelFunction<CodeStyleSettingsWidget>(icon);
+ addAutoReleasedObject(codeStyleSettingsPanelFactory);
+
+ auto dependenciesPanelFactory = new IProjectPanelFactory;
+ dependenciesPanelFactory->setPriority(50);
+ displayName = QCoreApplication::translate("DependenciesPanelFactory", "Dependencies");
+ dependenciesPanelFactory->setDisplayName(displayName);
+ icon = QIcon(QLatin1String(":/projectexplorer/images/ProjectDependencies.png"));
+ dependenciesPanelFactory->setSimpleCreatePanelFunction<DependenciesWidget>(icon);
+ addAutoReleasedObject(dependenciesPanelFactory);
+
+ auto unconfiguredProjectPanel = new IProjectPanelFactory;
+ unconfiguredProjectPanel->setPriority(-10);
+ unconfiguredProjectPanel->setDisplayName(tr("Configure Project"));
+ unconfiguredProjectPanel->setSupportsFunction([](Project *project){
+ return project->targets().isEmpty() && !project->requiresTargetPanel();
+ });
+ icon = QIcon(QLatin1String(":/projectexplorer/images/unconfigured.png"));
+ unconfiguredProjectPanel->setSimpleCreatePanelFunction<TargetSetupPageWrapper>(icon);
+ addAutoReleasedObject(unconfiguredProjectPanel);
addAutoReleasedObject(new ProcessStepFactory);
- addAutoReleasedObject(new UnconfiguredProjectPanel);
addAutoReleasedObject(new AllProjectsFind);
addAutoReleasedObject(new CurrentProjectFind);
diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro
index 94173369c3..1766bd159b 100644
--- a/src/plugins/projectexplorer/projectexplorer.pro
+++ b/src/plugins/projectexplorer/projectexplorer.pro
@@ -281,7 +281,8 @@ SOURCES += projectexplorer.cpp \
ipotentialkit.cpp \
selectablefilesmodel.cpp \
addnewmodel.cpp \
- xcodebuildparser.cpp
+ xcodebuildparser.cpp \
+ iprojectproperties.cpp
FORMS += processstep.ui \
editorsettingspropertiespage.ui \
diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs
index e1e148ad10..3654826532 100644
--- a/src/plugins/projectexplorer/projectexplorer.qbs
+++ b/src/plugins/projectexplorer/projectexplorer.qbs
@@ -85,7 +85,7 @@ QtcPlugin {
"ipotentialkit.cpp",
"ipotentialkit.h",
"iprojectmanager.h",
- "iprojectproperties.h",
+ "iprojectproperties.cpp", "iprojectproperties.h",
"itaskhandler.h",
"kit.cpp", "kit.h",
"kitchooser.cpp", "kitchooser.h",
diff --git a/src/plugins/projectexplorer/unconfiguredprojectpanel.cpp b/src/plugins/projectexplorer/unconfiguredprojectpanel.cpp
index 5ad194c257..4f3c21b627 100644
--- a/src/plugins/projectexplorer/unconfiguredprojectpanel.cpp
+++ b/src/plugins/projectexplorer/unconfiguredprojectpanel.cpp
@@ -48,36 +48,6 @@
namespace ProjectExplorer {
namespace Internal {
-UnconfiguredProjectPanel::UnconfiguredProjectPanel()
-{
-}
-
-QString UnconfiguredProjectPanel::displayName() const
-{
- return tr("Configure Project");
-}
-
-int UnconfiguredProjectPanel::priority() const
-{
- return -10;
-}
-
-bool UnconfiguredProjectPanel::supports(Project *project)
-{
- return project->targets().isEmpty() && !project->requiresTargetPanel();
-}
-
-PropertiesPanel *UnconfiguredProjectPanel::createPanel(Project *project)
-{
- PropertiesPanel *panel = new PropertiesPanel;
- panel->setDisplayName(displayName());
- panel->setIcon(QIcon(QLatin1String(":/projectexplorer/images/unconfigured.png")));
-
- TargetSetupPageWrapper *w = new TargetSetupPageWrapper(project);
- panel->setWidget(w);
- return panel;
-}
-
/////////
/// TargetSetupPageWrapper
////////
diff --git a/src/plugins/projectexplorer/unconfiguredprojectpanel.h b/src/plugins/projectexplorer/unconfiguredprojectpanel.h
index b50bbe5b0e..0da4bedd8b 100644
--- a/src/plugins/projectexplorer/unconfiguredprojectpanel.h
+++ b/src/plugins/projectexplorer/unconfiguredprojectpanel.h
@@ -42,17 +42,6 @@ class TargetSetupPage;
namespace Internal {
-class UnconfiguredProjectPanel : public IProjectPanelFactory
-{
- Q_OBJECT
-public:
- UnconfiguredProjectPanel();
- virtual QString displayName() const;
- int priority() const;
- virtual bool supports(Project *project);
- virtual PropertiesPanel *createPanel(Project *project);
-};
-
class TargetSetupPageWrapper : public QWidget
{
Q_OBJECT