forked from qt-creator/qt-creator
TextEditor: De-noise ICodeStylePreferences setup a bit
Change-Id: I6c3fcbb6ef17c7ca5771326b1444f057cc150e3d Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -27,11 +27,11 @@
|
||||
|
||||
using namespace CppTools;
|
||||
|
||||
static const char settingsSuffixKey[] = "CodeStyleSettings";
|
||||
|
||||
CppCodeStylePreferences::CppCodeStylePreferences(QObject *parent) :
|
||||
ICodeStylePreferences(parent)
|
||||
{
|
||||
setSettingsSuffix("CodeStyleSettings");
|
||||
|
||||
connect(this, &CppCodeStylePreferences::currentValueChanged,
|
||||
this, &CppCodeStylePreferences::slotCurrentValueChanged);
|
||||
}
|
||||
@@ -89,11 +89,6 @@ void CppCodeStylePreferences::slotCurrentValueChanged(const QVariant &value)
|
||||
emit currentCodeStyleSettingsChanged(value.value<CppCodeStyleSettings>());
|
||||
}
|
||||
|
||||
QString CppCodeStylePreferences::settingsSuffix() const
|
||||
{
|
||||
return QLatin1String(settingsSuffixKey);
|
||||
}
|
||||
|
||||
void CppCodeStylePreferences::toMap(const QString &prefix, QVariantMap *map) const
|
||||
{
|
||||
ICodeStylePreferences::toMap(prefix, map);
|
||||
|
||||
@@ -57,9 +57,6 @@ signals:
|
||||
void codeStyleSettingsChanged(const CppTools::CppCodeStyleSettings &);
|
||||
void currentCodeStyleSettingsChanged(const CppTools::CppCodeStyleSettings &);
|
||||
|
||||
protected:
|
||||
QString settingsSuffix() const override;
|
||||
|
||||
private:
|
||||
void slotCurrentValueChanged(const QVariant &);
|
||||
|
||||
|
||||
@@ -27,14 +27,8 @@
|
||||
|
||||
#include <texteditor/textindenter.h>
|
||||
|
||||
namespace TextEditor {
|
||||
class SimpleCodeStylePreferences;
|
||||
}
|
||||
|
||||
namespace Nim {
|
||||
|
||||
class NimLexer;
|
||||
|
||||
class NimIndenter : public TextEditor::TextIndenter
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -45,7 +45,7 @@ class NimCodeStyleSettingsWidget : public Core::IOptionsPageWidget
|
||||
public:
|
||||
NimCodeStyleSettingsWidget()
|
||||
{
|
||||
auto originalTabPreferences = qobject_cast<SimpleCodeStylePreferences *>(NimSettings::globalCodeStyle());
|
||||
auto originalTabPreferences = NimSettings::globalCodeStyle();
|
||||
m_nimCodeStylePreferences = new SimpleCodeStylePreferences(this);
|
||||
m_nimCodeStylePreferences->setDelegatingPool(originalTabPreferences->delegatingPool());
|
||||
m_nimCodeStylePreferences->setTabSettings(originalTabPreferences->tabSettings());
|
||||
|
||||
@@ -27,15 +27,8 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace TextEditor {
|
||||
class CodeStyleEditor;
|
||||
class SimpleCodeStylePreferences;
|
||||
}
|
||||
|
||||
namespace Nim {
|
||||
|
||||
class NimCodeStylePreferences;
|
||||
|
||||
class NimCodeStyleSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -46,9 +46,9 @@ public:
|
||||
QByteArray m_id;
|
||||
QString m_displayName;
|
||||
bool m_readOnly = false;
|
||||
QString m_settingsSuffix;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ICodeStylePreferences::ICodeStylePreferences(QObject *parent) :
|
||||
@@ -206,14 +206,19 @@ void ICodeStylePreferences::setCurrentDelegate(const QByteArray &id)
|
||||
setCurrentDelegate(d->m_pool->codeStyle(id));
|
||||
}
|
||||
|
||||
void ICodeStylePreferences::setSettingsSuffix(const QString &suffix)
|
||||
{
|
||||
d->m_settingsSuffix = suffix;
|
||||
}
|
||||
|
||||
void ICodeStylePreferences::toSettings(const QString &category, QSettings *s) const
|
||||
{
|
||||
Utils::toSettings(settingsSuffix(), category, s, this);
|
||||
Utils::toSettings(d->m_settingsSuffix, category, s, this);
|
||||
}
|
||||
|
||||
void ICodeStylePreferences::fromSettings(const QString &category, const QSettings *s)
|
||||
{
|
||||
Utils::fromSettings(settingsSuffix(), category, s, this);
|
||||
Utils::fromSettings(d->m_settingsSuffix, category, s, this);
|
||||
}
|
||||
|
||||
void ICodeStylePreferences::toMap(const QString &prefix, QVariantMap *map) const
|
||||
@@ -268,3 +273,4 @@ void ICodeStylePreferences::codeStyleRemoved(ICodeStylePreferences *preferences)
|
||||
}
|
||||
}
|
||||
|
||||
} // TextEditor
|
||||
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
QByteArray currentDelegateId() const;
|
||||
void setCurrentDelegate(const QByteArray &id);
|
||||
|
||||
void setSettingsSuffix(const QString &suffix);
|
||||
void toSettings(const QString &category, QSettings *s) const;
|
||||
void fromSettings(const QString &category, const QSettings *s);
|
||||
|
||||
@@ -95,9 +96,6 @@ signals:
|
||||
void currentPreferencesChanged(TextEditor::ICodeStylePreferences *currentPreferences);
|
||||
void displayNameChanged(const QString &newName);
|
||||
|
||||
protected:
|
||||
virtual QString settingsSuffix() const = 0;
|
||||
|
||||
private:
|
||||
void codeStyleRemoved(ICodeStylePreferences *preferences);
|
||||
|
||||
|
||||
@@ -27,14 +27,12 @@
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
static const char settingsSuffixKey[] = "TabPreferences";
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
SimpleCodeStylePreferences::SimpleCodeStylePreferences(QObject *parent)
|
||||
: ICodeStylePreferences(parent)
|
||||
{
|
||||
setSettingsSuffix("TabPreferences");
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +46,4 @@ void SimpleCodeStylePreferences::setValue(const QVariant &value)
|
||||
Q_UNUSED(value)
|
||||
}
|
||||
|
||||
QString SimpleCodeStylePreferences::settingsSuffix() const
|
||||
{
|
||||
return QLatin1String(settingsSuffixKey);
|
||||
}
|
||||
|
||||
|
||||
} // TextEditor
|
||||
|
||||
@@ -31,16 +31,11 @@ namespace TextEditor {
|
||||
|
||||
class TEXTEDITOR_EXPORT SimpleCodeStylePreferences : public ICodeStylePreferences
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SimpleCodeStylePreferences(QObject *parentObject = nullptr);
|
||||
|
||||
QVariant value() const override;
|
||||
void setValue(const QVariant &) override;
|
||||
|
||||
protected:
|
||||
QString settingsSuffix() const override;
|
||||
|
||||
};
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
Reference in New Issue
Block a user