forked from qt-creator/qt-creator
Move Code from ProjectWindow to IProjectProperties
Change-Id: Ib2ad82c8bbbb62dd72b3a2497a7e213206613654 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
|
||||
IProjectPanelFactory::IProjectPanelFactory()
|
||||
: m_priority(0),
|
||||
m_supportsFunction(&supportsAllProjects)
|
||||
@@ -78,7 +77,7 @@ void IProjectPanelFactory::setSupportsFunction(std::function<bool (Project *)> f
|
||||
m_supportsFunction = function;
|
||||
}
|
||||
|
||||
PropertiesPanel *IProjectPanelFactory::createPanel(Project *project)
|
||||
QWidget *IProjectPanelFactory::createWidget(Project *project)
|
||||
{
|
||||
return m_createPanelFunction(project);
|
||||
return m_createWidgetFunction(project);
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
// interface for users of IProjectPanelFactory
|
||||
bool supports(Project *project);
|
||||
ProjectExplorer::PropertiesPanel *createPanel(ProjectExplorer::Project *project);
|
||||
QWidget *createWidget(ProjectExplorer::Project *project);
|
||||
|
||||
// interface for "implementations" of IProjectPanelFactory
|
||||
// by default all projects are supported, only set a custom supports function
|
||||
@@ -71,14 +71,16 @@ public:
|
||||
// and uses displayName() for the displayname
|
||||
// Note: call setDisplayName before calling this
|
||||
template<typename T>
|
||||
void setSimpleCreatePanelFunction(const QIcon &icon)
|
||||
void setSimpleCreateWidgetFunction(const QIcon &icon)
|
||||
{
|
||||
m_createPanelFunction = [icon, this](Project *project) -> PropertiesPanel * {
|
||||
m_createWidgetFunction = [icon, this](Project *project) -> QWidget * {
|
||||
PropertiesPanel *panel = new PropertiesPanel;
|
||||
panel->setDisplayName(this->displayName());
|
||||
panel->setWidget(new T(project)),
|
||||
panel->setIcon(icon);
|
||||
return panel;
|
||||
PanelsWidget *panelsWidget = new PanelsWidget();
|
||||
panelsWidget->addPropertiesPanel(panel);
|
||||
return panelsWidget;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,7 +90,7 @@ private:
|
||||
int m_priority;
|
||||
QString m_displayName;
|
||||
std::function<bool (Project *)> m_supportsFunction;
|
||||
std::function<ProjectExplorer::PropertiesPanel *(Project *)> m_createPanelFunction;
|
||||
std::function<QWidget *(Project *)> m_createWidgetFunction;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT ITargetPanelFactory : public QObject
|
||||
|
@@ -476,7 +476,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
QString displayName = QCoreApplication::translate("EditorSettingsPanelFactory", "Editor");
|
||||
editorSettingsPanelFactory->setDisplayName(displayName);
|
||||
QIcon icon = QIcon(QLatin1String(":/projectexplorer/images/EditorSettings.png"));
|
||||
editorSettingsPanelFactory->setSimpleCreatePanelFunction<EditorSettingsWidget>(icon);
|
||||
editorSettingsPanelFactory->setSimpleCreateWidgetFunction<EditorSettingsWidget>(icon);
|
||||
addAutoReleasedObject(editorSettingsPanelFactory);
|
||||
|
||||
auto codeStyleSettingsPanelFactory = new IProjectPanelFactory;
|
||||
@@ -484,7 +484,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
displayName = QCoreApplication::translate("CodeStyleSettingsPanelFactory", "Code Style");
|
||||
codeStyleSettingsPanelFactory->setDisplayName(displayName);
|
||||
icon = QIcon(QLatin1String(":/projectexplorer/images/CodeStyleSettings.png"));
|
||||
codeStyleSettingsPanelFactory->setSimpleCreatePanelFunction<CodeStyleSettingsWidget>(icon);
|
||||
codeStyleSettingsPanelFactory->setSimpleCreateWidgetFunction<CodeStyleSettingsWidget>(icon);
|
||||
addAutoReleasedObject(codeStyleSettingsPanelFactory);
|
||||
|
||||
auto dependenciesPanelFactory = new IProjectPanelFactory;
|
||||
@@ -492,7 +492,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
displayName = QCoreApplication::translate("DependenciesPanelFactory", "Dependencies");
|
||||
dependenciesPanelFactory->setDisplayName(displayName);
|
||||
icon = QIcon(QLatin1String(":/projectexplorer/images/ProjectDependencies.png"));
|
||||
dependenciesPanelFactory->setSimpleCreatePanelFunction<DependenciesWidget>(icon);
|
||||
dependenciesPanelFactory->setSimpleCreateWidgetFunction<DependenciesWidget>(icon);
|
||||
addAutoReleasedObject(dependenciesPanelFactory);
|
||||
|
||||
auto unconfiguredProjectPanel = new IProjectPanelFactory;
|
||||
@@ -502,7 +502,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
return project->targets().isEmpty() && !project->requiresTargetPanel();
|
||||
});
|
||||
icon = QIcon(QLatin1String(":/projectexplorer/images/unconfigured.png"));
|
||||
unconfiguredProjectPanel->setSimpleCreatePanelFunction<TargetSetupPageWrapper>(icon);
|
||||
unconfiguredProjectPanel->setSimpleCreateWidgetFunction<TargetSetupPageWrapper>(icon);
|
||||
addAutoReleasedObject(unconfiguredProjectPanel);
|
||||
|
||||
addAutoReleasedObject(new ProcessStepFactory);
|
||||
|
@@ -243,12 +243,10 @@ void ProjectWindow::showProperties(int index, int subIndex)
|
||||
if (fac) {
|
||||
removeCurrentWidget();
|
||||
|
||||
PropertiesPanel *panel = fac->createPanel(project);
|
||||
Q_ASSERT(panel);
|
||||
QWidget *widget = fac->createWidget(project);
|
||||
Q_ASSERT(widget);
|
||||
|
||||
PanelsWidget *panelsWidget = new PanelsWidget(m_centralWidget);
|
||||
panelsWidget->addPropertiesPanel(panel);
|
||||
m_currentWidget = panelsWidget;
|
||||
m_currentWidget = widget;
|
||||
m_centralWidget->addWidget(m_currentWidget);
|
||||
m_centralWidget->setCurrentWidget(m_currentWidget);
|
||||
|
||||
|
Reference in New Issue
Block a user