Copilot: Use new construction pattern for project panel factory

Change-Id: Id703f377f353390e63535a0c98078c66909cbdd4
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-11-15 09:08:13 +01:00
parent 9967877b7a
commit 9f0198d8ed
3 changed files with 25 additions and 19 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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