forked from qt-creator/qt-creator
LanguageClient: Use new construction pattern for project panel
Change-Id: If3fa41d33a5d9b39d2596d619251bff3cfdf4b5d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -11,8 +11,6 @@
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
@@ -40,12 +38,7 @@ void LanguageClientPlugin::initialize()
|
||||
{
|
||||
using namespace Core;
|
||||
|
||||
auto panelFactory = new ProjectExplorer::ProjectPanelFactory;
|
||||
panelFactory->setPriority(35);
|
||||
panelFactory->setDisplayName(Tr::tr("Language Server"));
|
||||
panelFactory->setCreateWidgetFunction(
|
||||
[](ProjectExplorer::Project *project) { return new ProjectSettingsWidget(project); });
|
||||
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
|
||||
setupLanguageClientProjectPanel();
|
||||
|
||||
LanguageClientManager::init();
|
||||
LanguageClientSettings::registerClientType({Constants::LANGUAGECLIENT_STDIO_SETTINGS_ID,
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <projectexplorer/projectsettingswidget.h>
|
||||
|
||||
#include <texteditor/plaintexteditorfactory.h>
|
||||
#include <texteditor/textmark.h>
|
||||
@@ -66,6 +68,7 @@ constexpr char typedClientsKey[] = "typedClients";
|
||||
constexpr char outlineSortedKey[] = "outlineSorted";
|
||||
constexpr char mimeType[] = "application/language.client.setting";
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace LanguageClient {
|
||||
@@ -1105,9 +1108,12 @@ void ProjectSettings::setJson(const QByteArray &json)
|
||||
LanguageClientManager::updateWorkspaceConfiguration(m_project, newConfig);
|
||||
}
|
||||
|
||||
ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project)
|
||||
: m_settings(project)
|
||||
class LanguageClientProjectSettingsWidget : public ProjectSettingsWidget
|
||||
{
|
||||
public:
|
||||
explicit LanguageClientProjectSettingsWidget(Project *project)
|
||||
: m_settings(project)
|
||||
{
|
||||
setUseGlobalSettingsCheckBoxVisible(false);
|
||||
setGlobalSettingsId(Constants::LANGUAGECLIENT_SETTINGS_PAGE);
|
||||
setExpanding(true);
|
||||
@@ -1129,6 +1135,29 @@ ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project)
|
||||
&TextEditor::TextDocument::contentsChanged,
|
||||
this,
|
||||
[=]() { m_settings.setJson(editor->document()->contents()); });
|
||||
}
|
||||
|
||||
private:
|
||||
ProjectSettings m_settings;
|
||||
};
|
||||
|
||||
class LanguageClientProjectPanelFactory : public ProjectPanelFactory
|
||||
{
|
||||
public:
|
||||
LanguageClientProjectPanelFactory()
|
||||
{
|
||||
setPriority(35);
|
||||
setDisplayName(Tr::tr("Language Server"));
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new LanguageClientProjectSettingsWidget(project);
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
void setupLanguageClientProjectPanel()
|
||||
{
|
||||
static LanguageClientProjectPanelFactory theLanguageClientProjectPanelFactory;
|
||||
}
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <projectexplorer/projectsettingswidget.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QCoreApplication>
|
||||
#include <QJsonObject>
|
||||
@@ -208,15 +206,8 @@ private:
|
||||
QByteArray m_json;
|
||||
};
|
||||
|
||||
class ProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||
{
|
||||
public:
|
||||
explicit ProjectSettingsWidget(ProjectExplorer::Project *project);
|
||||
|
||||
private:
|
||||
ProjectSettings m_settings;
|
||||
};
|
||||
|
||||
LANGUAGECLIENT_EXPORT TextEditor::BaseTextEditor *jsonEditor();
|
||||
|
||||
void setupLanguageClientProjectPanel();
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
||||
Reference in New Issue
Block a user