Axivion: Hide ProjectSettingsWidget

Change-Id: Iaf5b0645953f31744fbf29995771d3e9d994c29b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-08-17 16:35:08 +02:00
parent 48bb019027
commit 7b0a3e7e28
3 changed files with 44 additions and 44 deletions

View File

@@ -96,9 +96,7 @@ void AxivionPlugin::initialize()
auto panelFactory = new ProjectExplorer::ProjectPanelFactory; auto panelFactory = new ProjectExplorer::ProjectPanelFactory;
panelFactory->setPriority(250); panelFactory->setPriority(250);
panelFactory->setDisplayName(Tr::tr("Axivion")); panelFactory->setDisplayName(Tr::tr("Axivion"));
panelFactory->setCreateWidgetFunction([](ProjectExplorer::Project *project){ panelFactory->setCreateWidgetFunction(&AxivionProjectSettings::createSettingsWidget);
return new AxivionProjectSettingsWidget(project);
});
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory); ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
connect(ProjectExplorer::ProjectManager::instance(), connect(ProjectExplorer::ProjectManager::instance(),
&ProjectExplorer::ProjectManager::startupProjectChanged, &ProjectExplorer::ProjectManager::startupProjectChanged,

View File

@@ -10,6 +10,8 @@
#include "axiviontr.h" #include "axiviontr.h"
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectsettingswidget.h>
#include <utils/infolabel.h> #include <utils/infolabel.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -24,6 +26,8 @@ namespace Axivion::Internal {
const char PSK_PROJECTNAME[] = "Axivion.ProjectName"; const char PSK_PROJECTNAME[] = "Axivion.ProjectName";
// AxivionProjectSettingsHandler
class AxivionProjectSettingsHandler : public QObject class AxivionProjectSettingsHandler : public QObject
{ {
public: public:
@@ -50,6 +54,8 @@ static AxivionProjectSettingsHandler &projectSettingsHandler()
return theProjectSettingsHandler; return theProjectSettingsHandler;
} }
// AxivionProjectSettings
AxivionProjectSettings::AxivionProjectSettings(ProjectExplorer::Project *project) AxivionProjectSettings::AxivionProjectSettings(ProjectExplorer::Project *project)
: m_project{project} : m_project{project}
{ {
@@ -80,10 +86,33 @@ void AxivionProjectSettings::save()
m_project->setNamedSettings(PSK_PROJECTNAME, m_dashboardProjectName); m_project->setNamedSettings(PSK_PROJECTNAME, m_dashboardProjectName);
} }
AxivionProjectSettingsWidget::AxivionProjectSettingsWidget(ProjectExplorer::Project *project, // AxivionProjectSettingsWidget
QWidget *parent)
: ProjectExplorer::ProjectSettingsWidget{parent} class AxivionProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
, m_projectSettings(projectSettingsHandler().projectSettings(project)) {
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); setUseGlobalSettingsCheckBoxVisible(false);
setUseGlobalSettingsLabelVisible(true); setUseGlobalSettingsLabelVisible(true);
@@ -219,4 +248,9 @@ void AxivionProjectSettingsWidget::updateEnabledStates()
} }
} }
ProjectSettingsWidget *AxivionProjectSettings::createSettingsWidget(ProjectExplorer::Project *project)
{
return new AxivionProjectSettingsWidget(project);
}
} // Axivion::Internal } // Axivion::Internal

View File

@@ -3,24 +3,15 @@
#pragma once #pragma once
#include <projectexplorer/projectsettingswidget.h>
#include <QObject> #include <QObject>
QT_BEGIN_NAMESPACE namespace ProjectExplorer {
class QLabel; class Project;
class QPushButton; class ProjectSettingsWidget;
class QTreeWidget; }
QT_END_NAMESPACE
namespace ProjectExplorer { class Project; }
namespace Utils { class InfoLabel; }
namespace Axivion::Internal { namespace Axivion::Internal {
class DashboardInfo;
class AxivionProjectSettings : public QObject class AxivionProjectSettings : public QObject
{ {
public: public:
@@ -31,6 +22,7 @@ public:
static AxivionProjectSettings *projectSettings(ProjectExplorer::Project *project); static AxivionProjectSettings *projectSettings(ProjectExplorer::Project *project);
static void destroyProjectSettings(); static void destroyProjectSettings();
static ProjectExplorer::ProjectSettingsWidget *createSettingsWidget(ProjectExplorer::Project *project);
private: private:
void load(); void load();
@@ -40,28 +32,4 @@ private:
QString m_dashboardProjectName; 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 } // Axivion::Internal