diff --git a/src/plugins/qmljstools/qmljscodestylesettingspage.cpp b/src/plugins/qmljstools/qmljscodestylesettingspage.cpp index 6168d3b20fa..00f93458f40 100644 --- a/src/plugins/qmljstools/qmljscodestylesettingspage.cpp +++ b/src/plugins/qmljstools/qmljscodestylesettingspage.cpp @@ -177,7 +177,7 @@ QmlJSCodeStyleSettingsPage::QmlJSCodeStyleSettingsPage(/*QSharedPointerqmlJSCodeStyle(); + = QmlJSToolsSettings::globalCodeStyle(); m_pageTabPreferences = new TextEditor::SimpleCodeStylePreferences(m_widget); m_pageTabPreferences->setDelegatingPool(originalTabPreferences->delegatingPool()); m_pageTabPreferences->setTabSettings(originalTabPreferences->tabSettings()); @@ -195,7 +195,7 @@ void QmlJSCodeStyleSettingsPage::apply() if (m_widget) { QSettings *s = Core::ICore::settings(); - TextEditor::SimpleCodeStylePreferences *originalTabPreferences = QmlJSToolsSettings::instance()->qmlJSCodeStyle(); + TextEditor::SimpleCodeStylePreferences *originalTabPreferences = QmlJSToolsSettings::globalCodeStyle(); if (originalTabPreferences->tabSettings() != m_pageTabPreferences->tabSettings()) { originalTabPreferences->setTabSettings(m_pageTabPreferences->tabSettings()); if (s) diff --git a/src/plugins/qmljstools/qmljstoolssettings.cpp b/src/plugins/qmljstools/qmljstoolssettings.cpp index 442365bc2c2..5a2cee87173 100644 --- a/src/plugins/qmljstools/qmljstoolssettings.cpp +++ b/src/plugins/qmljstools/qmljstoolssettings.cpp @@ -43,53 +43,40 @@ #include -static const char *idKey = "QmlJSGlobal"; - -using namespace QmlJSTools; -using TextEditor::TabSettings; +using namespace TextEditor; namespace QmlJSTools { -namespace Internal { -class QmlJSToolsSettingsPrivate -{ -public: - TextEditor::SimpleCodeStylePreferences *m_globalCodeStyle; -}; +const char idKey[] = "QmlJSGlobal"; -} // namespace Internal -} // namespace QmlJSTools - -QmlJSToolsSettings *QmlJSToolsSettings::m_instance = 0; +static TextEditor::SimpleCodeStylePreferences *m_globalCodeStyle = 0; QmlJSToolsSettings::QmlJSToolsSettings(QObject *parent) : QObject(parent) - , d(new Internal::QmlJSToolsSettingsPrivate) { - QTC_ASSERT(!m_instance, return); - m_instance = this; + QTC_ASSERT(!m_globalCodeStyle, return); - TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance(); + TextEditorSettings *textEditorSettings = TextEditorSettings::instance(); // code style factory - TextEditor::ICodeStylePreferencesFactory *factory = new QmlJSTools::QmlJSCodeStylePreferencesFactory(); + ICodeStylePreferencesFactory *factory = new QmlJSCodeStylePreferencesFactory(); textEditorSettings->registerCodeStyleFactory(factory); // code style pool - TextEditor::CodeStylePool *pool = new TextEditor::CodeStylePool(factory, this); + CodeStylePool *pool = new CodeStylePool(factory, this); textEditorSettings->registerCodeStylePool(Constants::QML_JS_SETTINGS_ID, pool); // global code style settings - d->m_globalCodeStyle = new TextEditor::SimpleCodeStylePreferences(this); - d->m_globalCodeStyle->setDelegatingPool(pool); - d->m_globalCodeStyle->setDisplayName(tr("Global", "Settings")); - d->m_globalCodeStyle->setId(idKey); - pool->addCodeStyle(d->m_globalCodeStyle); - textEditorSettings->registerCodeStyle(QmlJSTools::Constants::QML_JS_SETTINGS_ID, d->m_globalCodeStyle); + m_globalCodeStyle = new SimpleCodeStylePreferences(this); + m_globalCodeStyle->setDelegatingPool(pool); + m_globalCodeStyle->setDisplayName(tr("Global", "Settings")); + m_globalCodeStyle->setId(idKey); + pool->addCodeStyle(m_globalCodeStyle); + textEditorSettings->registerCodeStyle(QmlJSTools::Constants::QML_JS_SETTINGS_ID, m_globalCodeStyle); // built-in settings // Qt style - TextEditor::SimpleCodeStylePreferences *qtCodeStyle = new TextEditor::SimpleCodeStylePreferences(); + SimpleCodeStylePreferences *qtCodeStyle = new SimpleCodeStylePreferences(); qtCodeStyle->setId(QLatin1String("qt")); qtCodeStyle->setDisplayName(tr("Qt")); qtCodeStyle->setReadOnly(true); @@ -102,13 +89,13 @@ QmlJSToolsSettings::QmlJSToolsSettings(QObject *parent) pool->addCodeStyle(qtCodeStyle); // default delegate for global preferences - d->m_globalCodeStyle->setCurrentDelegate(qtCodeStyle); + m_globalCodeStyle->setCurrentDelegate(qtCodeStyle); pool->loadCustomCodeStyles(); // load global settings (after built-in settings are added to the pool) QSettings *s = Core::ICore::settings(); - d->m_globalCodeStyle->fromSettings(QmlJSTools::Constants::QML_JS_SETTINGS_ID, s); + m_globalCodeStyle->fromSettings(QmlJSTools::Constants::QML_JS_SETTINGS_ID, s); // legacy handling start (Qt Creator Version < 2.4) const bool legacyTransformed = @@ -137,13 +124,13 @@ QmlJSToolsSettings::QmlJSToolsSettings(QObject *parent) } // create custom code style out of old settings - TextEditor::ICodeStylePreferences *oldCreator = pool->createCodeStyle( + ICodeStylePreferences *oldCreator = pool->createCodeStyle( QLatin1String("legacy"), legacyTabSettings, QVariant(), tr("Old Creator")); // change the current delegate and save - d->m_globalCodeStyle->setCurrentDelegate(oldCreator); - d->m_globalCodeStyle->toSettings(QmlJSTools::Constants::QML_JS_SETTINGS_ID, s); + m_globalCodeStyle->setCurrentDelegate(oldCreator); + m_globalCodeStyle->toSettings(QmlJSTools::Constants::QML_JS_SETTINGS_ID, s); } // mark old settings as transformed s->setValue(QLatin1String("QmlJSTabPreferences/LegacyTransformed"), true); @@ -164,19 +151,13 @@ QmlJSToolsSettings::QmlJSToolsSettings(QObject *parent) QmlJSToolsSettings::~QmlJSToolsSettings() { - delete d; - - m_instance = 0; + delete m_globalCodeStyle; + m_globalCodeStyle = 0; } -QmlJSToolsSettings *QmlJSToolsSettings::instance() +SimpleCodeStylePreferences *QmlJSToolsSettings::globalCodeStyle() { - return m_instance; + return m_globalCodeStyle; } -TextEditor::SimpleCodeStylePreferences *QmlJSToolsSettings::qmlJSCodeStyle() const -{ - return d->m_globalCodeStyle; -} - - +} // namespace QmlJSTools diff --git a/src/plugins/qmljstools/qmljstoolssettings.h b/src/plugins/qmljstools/qmljstoolssettings.h index b80f309d102..1d6a405613f 100644 --- a/src/plugins/qmljstools/qmljstoolssettings.h +++ b/src/plugins/qmljstools/qmljstoolssettings.h @@ -35,18 +35,9 @@ #include -namespace TextEditor -{ -class SimpleCodeStylePreferences; -} +namespace TextEditor { class SimpleCodeStylePreferences; } -namespace QmlJSTools -{ - -namespace Internal -{ -class QmlJSToolsSettingsPrivate; -} +namespace QmlJSTools { /** * This class provides a central place for cpp tools settings. @@ -59,14 +50,7 @@ public: explicit QmlJSToolsSettings(QObject *parent); ~QmlJSToolsSettings(); - static QmlJSToolsSettings *instance(); - - TextEditor::SimpleCodeStylePreferences *qmlJSCodeStyle() const; - -private: - Internal::QmlJSToolsSettingsPrivate *d; - - static QmlJSToolsSettings *m_instance; + static TextEditor::SimpleCodeStylePreferences *globalCodeStyle(); }; } // namespace QmlJSTools