forked from qt-creator/qt-creator
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:
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
#include <languageclient/languageclientmanager.h>
|
#include <languageclient/languageclientmanager.h>
|
||||||
|
|
||||||
#include <projectexplorer/projectpanelfactory.h>
|
|
||||||
|
|
||||||
#include <texteditor/textdocumentlayout.h>
|
#include <texteditor/textdocumentlayout.h>
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
|
|
||||||
@@ -129,11 +127,7 @@ void CopilotPlugin::initialize()
|
|||||||
toggleButton->setDefaultAction(toggleAction.contextAction());
|
toggleButton->setDefaultAction(toggleAction.contextAction());
|
||||||
StatusBarManager::addStatusBarWidget(toggleButton, StatusBarManager::RightCorner);
|
StatusBarManager::addStatusBarWidget(toggleButton, StatusBarManager::RightCorner);
|
||||||
|
|
||||||
auto panelFactory = new ProjectPanelFactory;
|
setupCopilotProjectPanel();
|
||||||
panelFactory->setPriority(1000);
|
|
||||||
panelFactory->setDisplayName(Tr::tr("Copilot"));
|
|
||||||
panelFactory->setCreateWidgetFunction(&Internal::createCopilotProjectPanel);
|
|
||||||
ProjectPanelFactory::registerFactory(panelFactory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CopilotPlugin::delayedInitialize()
|
bool CopilotPlugin::delayedInitialize()
|
||||||
|
|||||||
@@ -2,21 +2,22 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "copilotprojectpanel.h"
|
#include "copilotprojectpanel.h"
|
||||||
|
|
||||||
#include "copilotconstants.h"
|
#include "copilotconstants.h"
|
||||||
#include "copilotsettings.h"
|
#include "copilotsettings.h"
|
||||||
|
#include "copilottr.h"
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectpanelfactory.h>
|
||||||
#include <projectexplorer/projectsettingswidget.h>
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
namespace Copilot::Internal {
|
namespace Copilot::Internal {
|
||||||
|
|
||||||
class CopilotProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
class CopilotProjectSettingsWidget final : public ProjectSettingsWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CopilotProjectSettingsWidget()
|
CopilotProjectSettingsWidget()
|
||||||
@@ -26,10 +27,9 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectSettingsWidget *createCopilotProjectPanel(Project *project)
|
static ProjectSettingsWidget *createCopilotProjectPanel(Project *project)
|
||||||
{
|
{
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
using namespace ProjectExplorer;
|
|
||||||
|
|
||||||
auto widget = new CopilotProjectSettingsWidget;
|
auto widget = new CopilotProjectSettingsWidget;
|
||||||
auto settings = new CopilotProjectSettings(project);
|
auto settings = new CopilotProjectSettings(project);
|
||||||
@@ -57,4 +57,21 @@ ProjectSettingsWidget *createCopilotProjectPanel(Project *project)
|
|||||||
return widget;
|
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
|
} // namespace Copilot::Internal
|
||||||
|
|||||||
@@ -3,13 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
|
||||||
class ProjectSettingsWidget;
|
|
||||||
class Project;
|
|
||||||
} // namespace ProjectExplorer
|
|
||||||
|
|
||||||
namespace Copilot::Internal {
|
namespace Copilot::Internal {
|
||||||
|
|
||||||
ProjectExplorer::ProjectSettingsWidget *createCopilotProjectPanel(ProjectExplorer::Project *project);
|
void setupCopilotProjectPanel();
|
||||||
|
|
||||||
} // namespace Copilot::Internal
|
} // Copilot::Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user