forked from qt-creator/qt-creator
Editor: link global settings in tab settings button
Change-Id: I5ca9f3a2191e9146d5517dc8cccf6932e2c21032 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "cppcodestylepreferences.h"
|
||||
#include "cppeditorconstants.h"
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -11,6 +12,7 @@ CppCodeStylePreferences::CppCodeStylePreferences(QObject *parent) :
|
||||
ICodeStylePreferences(parent)
|
||||
{
|
||||
setSettingsSuffix("CodeStyleSettings");
|
||||
setGlobalSettingsCategory(Constants::CPP_CODE_STYLE_SETTINGS_ID);
|
||||
|
||||
connect(this, &CppCodeStylePreferences::currentValueChanged,
|
||||
this, &CppCodeStylePreferences::slotCurrentValueChanged);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmljscodestylepreferences.h"
|
||||
#include "qmljstoolsconstants.h"
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -11,6 +12,7 @@ QmlJSCodeStylePreferences::QmlJSCodeStylePreferences(QObject *parent) :
|
||||
ICodeStylePreferences(parent)
|
||||
{
|
||||
setSettingsSuffix("CodeStyleSettings");
|
||||
setGlobalSettingsCategory(Constants::QML_JS_CODE_STYLE_SETTINGS_ID);
|
||||
|
||||
connect(this, &QmlJSCodeStylePreferences::currentValueChanged,
|
||||
this, &QmlJSCodeStylePreferences::slotCurrentValueChanged);
|
||||
|
@@ -19,6 +19,7 @@ class ICodeStylePreferencesPrivate
|
||||
public:
|
||||
CodeStylePool *m_pool = nullptr;
|
||||
ICodeStylePreferences *m_currentDelegate = nullptr;
|
||||
Utils::Id m_globalSettingsCategory;
|
||||
TabSettings m_tabSettings;
|
||||
QByteArray m_id;
|
||||
QString m_displayName;
|
||||
@@ -249,6 +250,16 @@ void ICodeStylePreferences::fromMap(const Store &map)
|
||||
}
|
||||
}
|
||||
|
||||
Id ICodeStylePreferences::globalSettingsCategory()
|
||||
{
|
||||
return d->m_globalSettingsCategory;
|
||||
}
|
||||
|
||||
void ICodeStylePreferences::setGlobalSettingsCategory(const Utils::Id &id)
|
||||
{
|
||||
d->m_globalSettingsCategory = id;
|
||||
}
|
||||
|
||||
void ICodeStylePreferences::codeStyleRemoved(ICodeStylePreferences *preferences)
|
||||
{
|
||||
if (currentDelegate() == preferences) {
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "texteditor_global.h"
|
||||
|
||||
#include <utils/id.h>
|
||||
#include <utils/store.h>
|
||||
|
||||
#include <QObject>
|
||||
@@ -75,6 +76,9 @@ public:
|
||||
virtual Utils::Store toMap() const;
|
||||
virtual void fromMap(const Utils::Store &map);
|
||||
|
||||
Utils::Id globalSettingsCategory();
|
||||
void setGlobalSettingsCategory(const Utils::Id &id);
|
||||
|
||||
signals:
|
||||
void tabSettingsChanged(const TextEditor::TabSettings &settings);
|
||||
void currentTabSettingsChanged(const TextEditor::TabSettings &settings);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "simplecodestylepreferences.h"
|
||||
#include "texteditorconstants.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
@@ -11,9 +12,9 @@ SimpleCodeStylePreferences::SimpleCodeStylePreferences(QObject *parent)
|
||||
: ICodeStylePreferences(parent)
|
||||
{
|
||||
setSettingsSuffix("TabPreferences");
|
||||
setGlobalSettingsCategory(Constants::TEXT_EDITOR_BEHAVIOR_SETTINGS);
|
||||
}
|
||||
|
||||
|
||||
QVariant SimpleCodeStylePreferences::value() const
|
||||
{
|
||||
return QVariant();
|
||||
|
@@ -479,6 +479,11 @@ void TextDocument::setCodeStyle(ICodeStylePreferences *preferences)
|
||||
}
|
||||
}
|
||||
|
||||
ICodeStylePreferences *TextDocument::codeStyle() const
|
||||
{
|
||||
return d->m_codeStylePreferences;
|
||||
}
|
||||
|
||||
void TextDocument::applyFontSettings()
|
||||
{
|
||||
d->m_fontSettingsNeedsApply = false;
|
||||
|
@@ -140,6 +140,7 @@ public:
|
||||
virtual IAssistProvider *quickFixAssistProvider() const;
|
||||
|
||||
void setCodeStyle(ICodeStylePreferences *preferences);
|
||||
ICodeStylePreferences *codeStyle() const;
|
||||
void setTabSettings(const TextEditor::TabSettings &tabSettings);
|
||||
void setFontSettings(const TextEditor::FontSettings &fontSettings);
|
||||
|
||||
|
@@ -360,6 +360,15 @@ private:
|
||||
}
|
||||
tabSize->addActions(tabSizeGroup->actions());
|
||||
|
||||
Id globalSettingsCategory;
|
||||
if (auto codeStyle = m_doc->codeStyle())
|
||||
globalSettingsCategory = codeStyle->globalSettingsCategory();
|
||||
if (!globalSettingsCategory.isValid())
|
||||
globalSettingsCategory = Constants::TEXT_EDITOR_BEHAVIOR_SETTINGS;
|
||||
menu->addAction(Tr::tr("Global Settings..."), [globalSettingsCategory] {
|
||||
Core::ICore::showOptionsDialog(globalSettingsCategory);
|
||||
});
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user