diff --git a/src/plugins/axivion/axivionplugin.cpp b/src/plugins/axivion/axivionplugin.cpp index bec3718b466..ef253e9c0d5 100644 --- a/src/plugins/axivion/axivionplugin.cpp +++ b/src/plugins/axivion/axivionplugin.cpp @@ -96,9 +96,7 @@ void AxivionPlugin::initialize() auto panelFactory = new ProjectExplorer::ProjectPanelFactory; panelFactory->setPriority(250); panelFactory->setDisplayName(Tr::tr("Axivion")); - panelFactory->setCreateWidgetFunction([](ProjectExplorer::Project *project){ - return new AxivionProjectSettingsWidget(project); - }); + panelFactory->setCreateWidgetFunction(&AxivionProjectSettings::createSettingsWidget); ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory); connect(ProjectExplorer::ProjectManager::instance(), &ProjectExplorer::ProjectManager::startupProjectChanged, diff --git a/src/plugins/axivion/axivionprojectsettings.cpp b/src/plugins/axivion/axivionprojectsettings.cpp index 58ec2eecd5e..d92a601435d 100644 --- a/src/plugins/axivion/axivionprojectsettings.cpp +++ b/src/plugins/axivion/axivionprojectsettings.cpp @@ -10,6 +10,8 @@ #include "axiviontr.h" #include +#include + #include #include @@ -24,6 +26,8 @@ namespace Axivion::Internal { const char PSK_PROJECTNAME[] = "Axivion.ProjectName"; +// AxivionProjectSettingsHandler + class AxivionProjectSettingsHandler : public QObject { public: @@ -50,6 +54,8 @@ static AxivionProjectSettingsHandler &projectSettingsHandler() return theProjectSettingsHandler; } +// AxivionProjectSettings + AxivionProjectSettings::AxivionProjectSettings(ProjectExplorer::Project *project) : m_project{project} { @@ -80,10 +86,33 @@ void AxivionProjectSettings::save() m_project->setNamedSettings(PSK_PROJECTNAME, m_dashboardProjectName); } -AxivionProjectSettingsWidget::AxivionProjectSettingsWidget(ProjectExplorer::Project *project, - QWidget *parent) - : ProjectExplorer::ProjectSettingsWidget{parent} - , m_projectSettings(projectSettingsHandler().projectSettings(project)) +// AxivionProjectSettingsWidget + +class AxivionProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget +{ +public: + explicit AxivionProjectSettingsWidget(ProjectExplorer::Project *project); + +private: + void fetchProjects(); + void onDashboardInfoReceived(const DashboardInfo &info); + void onSettingsChanged(); + void linkProject(); + void unlinkProject(); + void updateUi(); + void updateEnabledStates(); + + AxivionProjectSettings *m_projectSettings = nullptr; + QLabel *m_linkedProject = nullptr; + QTreeWidget *m_dashboardProjects = nullptr; + QPushButton *m_fetchProjects = nullptr; + QPushButton *m_link = nullptr; + QPushButton *m_unlink = nullptr; + Utils::InfoLabel *m_infoLabel = nullptr; +}; + +AxivionProjectSettingsWidget::AxivionProjectSettingsWidget(ProjectExplorer::Project *project) + : m_projectSettings(projectSettingsHandler().projectSettings(project)) { setUseGlobalSettingsCheckBoxVisible(false); setUseGlobalSettingsLabelVisible(true); @@ -219,4 +248,9 @@ void AxivionProjectSettingsWidget::updateEnabledStates() } } +ProjectSettingsWidget *AxivionProjectSettings::createSettingsWidget(ProjectExplorer::Project *project) +{ + return new AxivionProjectSettingsWidget(project); +} + } // Axivion::Internal diff --git a/src/plugins/axivion/axivionprojectsettings.h b/src/plugins/axivion/axivionprojectsettings.h index e3d37210260..d11b001d9f3 100644 --- a/src/plugins/axivion/axivionprojectsettings.h +++ b/src/plugins/axivion/axivionprojectsettings.h @@ -3,24 +3,15 @@ #pragma once -#include - #include -QT_BEGIN_NAMESPACE -class QLabel; -class QPushButton; -class QTreeWidget; -QT_END_NAMESPACE - -namespace ProjectExplorer { class Project; } - -namespace Utils { class InfoLabel; } +namespace ProjectExplorer { +class Project; +class ProjectSettingsWidget; +} namespace Axivion::Internal { -class DashboardInfo; - class AxivionProjectSettings : public QObject { public: @@ -31,6 +22,7 @@ public: static AxivionProjectSettings *projectSettings(ProjectExplorer::Project *project); static void destroyProjectSettings(); + static ProjectExplorer::ProjectSettingsWidget *createSettingsWidget(ProjectExplorer::Project *project); private: void load(); @@ -40,28 +32,4 @@ private: QString m_dashboardProjectName; }; -class AxivionProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget -{ -public: - explicit AxivionProjectSettingsWidget(ProjectExplorer::Project *project, - QWidget *parent = nullptr); - -private: - void fetchProjects(); - void onDashboardInfoReceived(const DashboardInfo &info); - void onSettingsChanged(); - void linkProject(); - void unlinkProject(); - void updateUi(); - void updateEnabledStates(); - - AxivionProjectSettings *m_projectSettings = nullptr; - QLabel *m_linkedProject = nullptr; - QTreeWidget *m_dashboardProjects = nullptr; - QPushButton *m_fetchProjects = nullptr; - QPushButton *m_link = nullptr; - QPushButton *m_unlink = nullptr; - Utils::InfoLabel *m_infoLabel = nullptr; -}; - } // Axivion::Internal