aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/copilot
diff options
context:
space:
mode:
authorhjk <[email protected]>2023-11-15 09:08:13 +0100
committerhjk <[email protected]>2023-11-16 10:32:00 +0000
commit9f0198d8ed83eec0fd97ef635e4ca850efa63a21 (patch)
treec75ba81d6a703e2342a4ccc35fb6fa3b137b1b30 /src/plugins/copilot
parent9967877b7a88878448146c16d6312cc574543c08 (diff)
Copilot: Use new construction pattern for project panel factory
Change-Id: Id703f377f353390e63535a0c98078c66909cbdd4 Reviewed-by: <[email protected]> Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/plugins/copilot')
-rw-r--r--src/plugins/copilot/copilotplugin.cpp8
-rw-r--r--src/plugins/copilot/copilotprojectpanel.cpp27
-rw-r--r--src/plugins/copilot/copilotprojectpanel.h9
3 files changed, 25 insertions, 19 deletions
diff --git a/src/plugins/copilot/copilotplugin.cpp b/src/plugins/copilot/copilotplugin.cpp
index fdbdaac553b..2ad525f5f37 100644
--- a/src/plugins/copilot/copilotplugin.cpp
+++ b/src/plugins/copilot/copilotplugin.cpp
@@ -17,8 +17,6 @@
#include <languageclient/languageclientmanager.h>
-#include <projectexplorer/projectpanelfactory.h>
-
#include <texteditor/textdocumentlayout.h>
#include <texteditor/texteditor.h>
@@ -129,11 +127,7 @@ void CopilotPlugin::initialize()
toggleButton->setDefaultAction(toggleAction.contextAction());
StatusBarManager::addStatusBarWidget(toggleButton, StatusBarManager::RightCorner);
- auto panelFactory = new ProjectPanelFactory;
- panelFactory->setPriority(1000);
- panelFactory->setDisplayName(Tr::tr("Copilot"));
- panelFactory->setCreateWidgetFunction(&Internal::createCopilotProjectPanel);
- ProjectPanelFactory::registerFactory(panelFactory);
+ setupCopilotProjectPanel();
}
bool CopilotPlugin::delayedInitialize()
diff --git a/src/plugins/copilot/copilotprojectpanel.cpp b/src/plugins/copilot/copilotprojectpanel.cpp
index 034e43bc2dc..5b570a0de26 100644
--- a/src/plugins/copilot/copilotprojectpanel.cpp
+++ b/src/plugins/copilot/copilotprojectpanel.cpp
@@ -2,21 +2,22 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "copilotprojectpanel.h"
+
#include "copilotconstants.h"
#include "copilotsettings.h"
+#include "copilottr.h"
#include <projectexplorer/project.h>
+#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/projectsettingswidget.h>
#include <utils/layoutbuilder.h>
-#include <QWidget>
-
using namespace ProjectExplorer;
namespace Copilot::Internal {
-class CopilotProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
+class CopilotProjectSettingsWidget final : public ProjectSettingsWidget
{
public:
CopilotProjectSettingsWidget()
@@ -26,10 +27,9 @@ public:
}
};
-ProjectSettingsWidget *createCopilotProjectPanel(Project *project)
+static ProjectSettingsWidget *createCopilotProjectPanel(Project *project)
{
using namespace Layouting;
- using namespace ProjectExplorer;
auto widget = new CopilotProjectSettingsWidget;
auto settings = new CopilotProjectSettings(project);
@@ -57,4 +57,21 @@ ProjectSettingsWidget *createCopilotProjectPanel(Project *project)
return widget;
}
+class CopilotProjectPanelFactory final : public ProjectPanelFactory
+{
+public:
+ CopilotProjectPanelFactory()
+ {
+ setPriority(1000);
+ setDisplayName(Tr::tr("Copilot"));
+ setCreateWidgetFunction(&createCopilotProjectPanel);
+ ProjectPanelFactory::registerFactory(this);
+ }
+};
+
+void setupCopilotProjectPanel()
+{
+ static CopilotProjectPanelFactory theCopilotProjectPanelFactory;
+}
+
} // namespace Copilot::Internal
diff --git a/src/plugins/copilot/copilotprojectpanel.h b/src/plugins/copilot/copilotprojectpanel.h
index 2f4be6d6f9c..4db9c087d5d 100644
--- a/src/plugins/copilot/copilotprojectpanel.h
+++ b/src/plugins/copilot/copilotprojectpanel.h
@@ -3,13 +3,8 @@
#pragma once
-namespace ProjectExplorer {
-class ProjectSettingsWidget;
-class Project;
-} // namespace ProjectExplorer
-
namespace Copilot::Internal {
-ProjectExplorer::ProjectSettingsWidget *createCopilotProjectPanel(ProjectExplorer::Project *project);
+void setupCopilotProjectPanel();
-} // namespace Copilot::Internal
+} // Copilot::Internal