aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/gitlab
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-11-14 17:47:02 +0100
committerhjk <hjk@qt.io>2023-11-16 09:37:13 +0000
commit8a727b594895ac548ec82e2756ad3d055b0890ab (patch)
treedbe87326569dfb8c9b01ccbc02b896e38772818b /src/plugins/gitlab
parent6a8d7edd6fc84543d86c4dc4d788df141a9eb72e (diff)
GitLab: Use new construction pattern for project panel factory
Change-Id: I7a52d1a914daf64cb74214628c7f4728d32dbf5d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/gitlab')
-rw-r--r--src/plugins/gitlab/gitlabplugin.cpp10
-rw-r--r--src/plugins/gitlab/gitlabprojectsettings.cpp54
-rw-r--r--src/plugins/gitlab/gitlabprojectsettings.h37
3 files changed, 54 insertions, 47 deletions
diff --git a/src/plugins/gitlab/gitlabplugin.cpp b/src/plugins/gitlab/gitlabplugin.cpp
index 5ae4df682b6..73e726c9807 100644
--- a/src/plugins/gitlab/gitlabplugin.cpp
+++ b/src/plugins/gitlab/gitlabplugin.cpp
@@ -81,13 +81,9 @@ void GitLabPlugin::initialize()
{
dd = new GitLabPluginPrivate;
dd->parameters.fromSettings(Core::ICore::settings());
- auto panelFactory = new ProjectExplorer::ProjectPanelFactory;
- panelFactory->setPriority(999);
- panelFactory->setDisplayName(Tr::tr("GitLab"));
- panelFactory->setCreateWidgetFunction([](ProjectExplorer::Project *project) {
- return new GitLabProjectSettingsWidget(project);
- });
- ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
+
+ setupGitlabProjectPanel();
+
QAction *openViewAction = new QAction(Tr::tr("GitLab..."), this);
auto gitlabCommand = Core::ActionManager::registerAction(openViewAction,
Constants::GITLAB_OPEN_VIEW);
diff --git a/src/plugins/gitlab/gitlabprojectsettings.cpp b/src/plugins/gitlab/gitlabprojectsettings.cpp
index b5bb12942b4..6b4a09c0ade 100644
--- a/src/plugins/gitlab/gitlabprojectsettings.cpp
+++ b/src/plugins/gitlab/gitlabprojectsettings.cpp
@@ -10,7 +10,11 @@
#include "resultparser.h"
#include <git/gitclient.h>
+
#include <projectexplorer/project.h>
+#include <projectexplorer/projectpanelfactory.h>
+#include <projectexplorer/projectsettingswidget.h>
+
#include <utils/infolabel.h>
#include <utils/qtcassert.h>
@@ -107,10 +111,33 @@ void GitLabProjectSettings::save()
m_project->setNamedSettings(PSK_LAST_REQ, m_lastRequest);
}
-GitLabProjectSettingsWidget::GitLabProjectSettingsWidget(ProjectExplorer::Project *project,
- QWidget *parent)
- : ProjectExplorer::ProjectSettingsWidget(parent)
- , m_projectSettings(GitLabPlugin::projectSettings(project))
+class GitLabProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
+{
+public:
+ explicit GitLabProjectSettingsWidget(ProjectExplorer::Project *project);
+
+private:
+ enum CheckMode { Connection, Link };
+
+ void unlink();
+ void checkConnection(CheckMode mode);
+ void onConnectionChecked(const Project &project, const Utils::Id &serverId,
+ const QString &remote, const QString &projName);
+ void updateUi();
+ void updateEnabledStates();
+
+ GitLabProjectSettings *m_projectSettings = nullptr;
+ QComboBox *m_linkedGitLabServer = nullptr;
+ QComboBox *m_hostCB = nullptr;
+ QPushButton *m_linkWithGitLab = nullptr;
+ QPushButton *m_unlink = nullptr;
+ QPushButton *m_checkConnection = nullptr;
+ Utils::InfoLabel *m_infoLabel = nullptr;
+ CheckMode m_checkMode = Connection;
+};
+
+GitLabProjectSettingsWidget::GitLabProjectSettingsWidget(ProjectExplorer::Project *project)
+ : m_projectSettings(GitLabPlugin::projectSettings(project))
{
setUseGlobalSettingsCheckBoxVisible(false);
setUseGlobalSettingsLabelVisible(true);
@@ -302,4 +329,23 @@ void GitLabProjectSettingsWidget::updateEnabledStates()
}
}
+class GitlabProjectPanelFactory final : public ProjectExplorer::ProjectPanelFactory
+{
+public:
+ GitlabProjectPanelFactory()
+ {
+ setPriority(999);
+ setDisplayName(Tr::tr("GitLab"));
+ setCreateWidgetFunction([](ProjectExplorer::Project *project) {
+ return new GitLabProjectSettingsWidget(project);
+ });
+ ProjectExplorer::ProjectPanelFactory::registerFactory(this);
+ }
+};
+
+void setupGitlabProjectPanel()
+{
+ static GitlabProjectPanelFactory theGitlabProjectPanelFactory;
+}
+
} // namespace GitLab
diff --git a/src/plugins/gitlab/gitlabprojectsettings.h b/src/plugins/gitlab/gitlabprojectsettings.h
index 19b4c1fea92..9064f3394e9 100644
--- a/src/plugins/gitlab/gitlabprojectsettings.h
+++ b/src/plugins/gitlab/gitlabprojectsettings.h
@@ -3,19 +3,10 @@
#pragma once
-#include <projectexplorer/projectsettingswidget.h>
#include <utils/id.h>
#include <QDateTime>
#include <QObject>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QPushButton;
-QT_END_NAMESPACE
-
-#include <utility>
namespace ProjectExplorer { class Project; }
@@ -56,32 +47,6 @@ private:
bool m_linked = false;
};
-class GitLabProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
-{
- Q_OBJECT
-public:
- explicit GitLabProjectSettingsWidget(ProjectExplorer::Project *project,
- QWidget *parent = nullptr);
-
-private:
- enum CheckMode { Connection, Link };
-
- void unlink();
- void checkConnection(CheckMode mode);
- void onConnectionChecked(const Project &project, const Utils::Id &serverId,
- const QString &remote, const QString &projName);
- void updateUi();
- void updateEnabledStates();
-
- GitLabProjectSettings *m_projectSettings = nullptr;
- QComboBox *m_linkedGitLabServer = nullptr;
- QComboBox *m_hostCB = nullptr;
- QPushButton *m_linkWithGitLab = nullptr;
- QPushButton *m_unlink = nullptr;
- QPushButton *m_checkConnection = nullptr;
- Utils::InfoLabel *m_infoLabel = nullptr;
- CheckMode m_checkMode = Connection;
-};
+void setupGitlabProjectPanel();
} // namespace GitLab
-