From 9f0198d8ed83eec0fd97ef635e4ca850efa63a21 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 15 Nov 2023 09:08:13 +0100 Subject: Copilot: Use new construction pattern for project panel factory Change-Id: Id703f377f353390e63535a0c98078c66909cbdd4 Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/copilot/copilotplugin.cpp | 8 +------- src/plugins/copilot/copilotprojectpanel.cpp | 27 ++++++++++++++++++++++----- src/plugins/copilot/copilotprojectpanel.h | 9 ++------- 3 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src/plugins/copilot') 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 -#include - #include #include @@ -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 +#include #include #include -#include - 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 -- cgit v1.2.3