forked from qt-creator/qt-creator
qmlls: link new settings page from old settings page
Add a button from the old settings page that opens up the new qmlls settings page, for both global and project specific settings. Task-number: QTCREATORBUG-31897 Change-Id: Ib6b83d7b2427aea99b7be0eec6219ba2fb0c2e59 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Constants {
|
||||
|
||||
const char LANGUAGECLIENT_SETTINGS_CATEGORY[] = "ZY.LanguageClient";
|
||||
const char LANGUAGECLIENT_SETTINGS_PAGE[] = "LanguageClient.General";
|
||||
const char LANGUAGECLIENT_SETTINGS_PANEL[] = "LanguageClient.General";
|
||||
const char LANGUAGECLIENT_STDIO_SETTINGS_ID[] = "LanguageClient::StdIOSettingsID";
|
||||
const char LANGUAGECLIENT_SETTINGS_TR[] = QT_TRANSLATE_NOOP("QtC::LanguageClient", "Language Client");
|
||||
const char LANGUAGECLIENT_DOCUMENT_FILTER_ID[] = "Current Document Symbols";
|
||||
|
@@ -1344,6 +1344,7 @@ public:
|
||||
{
|
||||
setPriority(35);
|
||||
setDisplayName(Tr::tr("Language Server"));
|
||||
setId(Constants::LANGUAGECLIENT_SETTINGS_PANEL);
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new LanguageClientProjectSettingsWidget(project);
|
||||
});
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include <languageclient/languageclientmanager.h>
|
||||
#include <languageclient/languageclientsettings.h>
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <projectexplorer/projectsettingswidget.h>
|
||||
@@ -41,6 +42,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QLoggingCategory>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
#include <QTextStream>
|
||||
#include <QTreeView>
|
||||
|
||||
@@ -259,6 +261,7 @@ public:
|
||||
analyzerMessagesView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(analyzerMessagesView, &QTreeView::customContextMenuRequested,
|
||||
this, &QmlJsEditingSettingsPageWidget::showContextMenu);
|
||||
|
||||
using namespace Layouting;
|
||||
// clang-format off
|
||||
QWidget *formattingGroup = nullptr;
|
||||
@@ -290,9 +293,15 @@ public:
|
||||
Row { s.uiQmlOpenMode, st }
|
||||
},
|
||||
},
|
||||
Group{
|
||||
Group {
|
||||
title(Tr::tr("QML Language Server")),
|
||||
// TODO: link to new settings
|
||||
Row {
|
||||
PushButton {
|
||||
text(Tr::tr("Open Language Server preferences...")),
|
||||
onClicked(this, [] { Core::ICore::showOptionsDialog(LanguageClient::Constants::LANGUAGECLIENT_SETTINGS_PAGE); })
|
||||
},
|
||||
st
|
||||
},
|
||||
},
|
||||
Group {
|
||||
title(Tr::tr("Static Analyzer")),
|
||||
@@ -375,77 +384,33 @@ QmlJsEditingSettingsPage::QmlJsEditingSettingsPage()
|
||||
setSettingsProvider([] { return &settings(); });
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings(Project *project)
|
||||
{
|
||||
setAutoApply(true);
|
||||
|
||||
const Key group = QmlJSEditor::Constants::SETTINGS_CATEGORY_QML;
|
||||
|
||||
useQmlls.setSettingsKey(group, USE_QMLLS);
|
||||
useQmlls.setDefaultValue(true);
|
||||
useQmlls.setLabelText(Tr::tr("Turn on"));
|
||||
useQmlls.setToolTip(Tr::tr("Enable QML Language Server on this project."));
|
||||
|
||||
useGlobalSettings.setSettingsKey(group, USE_GLOBAL_SETTINGS);
|
||||
useGlobalSettings.setDefaultValue(true);
|
||||
|
||||
Store map = storeFromVariant(project->namedSettings(SETTINGS_KEY_MAIN));
|
||||
fromMap(map);
|
||||
|
||||
useQmlls.addOnChanged(this, [this, project] { save(project); });
|
||||
useGlobalSettings.addOnChanged(this, [this, project] { save(project); });
|
||||
}
|
||||
|
||||
void ProjectSettings::save(Project *project)
|
||||
{
|
||||
Store map;
|
||||
toMap(map);
|
||||
project->setNamedSettings(SETTINGS_KEY_MAIN, variantFromStore(map));
|
||||
|
||||
// TODO: this does not do anything for now. Either force re-apply when the functionality
|
||||
// is available in LanguageClient (tracked in QTCREATORBUG-32015) or remove ProjectSettings
|
||||
// class completely in favor of the LanguageClient project specific settings implementation
|
||||
// (tracked in QTCREATORBUG-31987).
|
||||
LanguageClientManager::applySettings();
|
||||
}
|
||||
|
||||
class QmlJsEditingProjectSettingsWidget final : public ProjectSettingsWidget
|
||||
{
|
||||
public:
|
||||
explicit QmlJsEditingProjectSettingsWidget(Project *project)
|
||||
: m_settings{project}
|
||||
explicit QmlJsEditingProjectSettingsWidget(Project *)
|
||||
{
|
||||
setUseGlobalSettingsCheckBoxVisible(true);
|
||||
setUseGlobalSettingsCheckBoxVisible(false);
|
||||
setGlobalSettingsId(SETTINGS_PAGE);
|
||||
setExpanding(true);
|
||||
|
||||
setUseGlobalSettings(m_settings.useGlobalSettings());
|
||||
|
||||
setEnabled(!m_settings.useGlobalSettings());
|
||||
|
||||
using namespace Layouting;
|
||||
// clang-format off
|
||||
Column {
|
||||
Group {
|
||||
title(Tr::tr("QML Language Server")),
|
||||
Column {
|
||||
&m_settings.useQmlls,
|
||||
Row {
|
||||
PushButton {
|
||||
text(Tr::tr("Open Language Server preferences...")),
|
||||
onClicked(this, [] { ProjectExplorerPlugin::activateProjectPanel(LanguageClient::Constants::LANGUAGECLIENT_SETTINGS_PANEL); })
|
||||
},
|
||||
st,
|
||||
},
|
||||
},
|
||||
tight,
|
||||
st,
|
||||
}.attachTo(this);
|
||||
// clang-format on
|
||||
|
||||
connect(
|
||||
this, &ProjectSettingsWidget::useGlobalSettingsChanged, this, [this](bool newUseGlobal) {
|
||||
setEnabled(!newUseGlobal);
|
||||
m_settings.useGlobalSettings.setValue(newUseGlobal);
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
ProjectSettings m_settings;
|
||||
};
|
||||
|
||||
class QmlJsEditingProjectPanelFactory : public ProjectPanelFactory
|
||||
|
@@ -44,17 +44,6 @@ public:
|
||||
QmlJsEditingSettingsPage();
|
||||
};
|
||||
|
||||
class ProjectSettings : public Utils::AspectContainer
|
||||
{
|
||||
public:
|
||||
ProjectSettings(ProjectExplorer::Project *project);
|
||||
|
||||
Utils::BoolAspect useQmlls{this};
|
||||
Utils::BoolAspect useGlobalSettings{this};
|
||||
|
||||
void save(ProjectExplorer::Project *project);
|
||||
};
|
||||
|
||||
void setupQmlJsEditingProjectPanel();
|
||||
|
||||
} // QmlJSEditor::Internal
|
||||
|
Reference in New Issue
Block a user