diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-05-10 18:30:09 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-05-11 15:11:12 +0200 |
commit | e53b5bc9a106f961a79e2a9c94b5dd10f05845d4 (patch) | |
tree | 9cf0387ee6007cdf2b6147dbcb68c073cfdc80ad /src/plugins/cpptools/cpptoolsplugin.cpp | |
parent | b8f7d44753dc70838ac74e2262b606b5f0b363a7 (diff) | |
download | qt-creator-e53b5bc9a106f961a79e2a9c94b5dd10f05845d4.tar.gz |
Fixed completion settings to also apply to the QML code completion
By moving the completion settings into the TextEditor plugin, so that
both the CppTools and the QmlJSEditor plugins can access the settings.
The user-interface to edit the settings is still in the CppTools plugin,
since we're in string freeze at the moment. It should be moved to the
TextEditor plugin later.
For now the QML completion only supports the case-sensitivity and
partial completion options, since there is no automatic insertion of
brackets.
Task-number: QTCREATORBUG-1327
Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp')
-rw-r--r-- | src/plugins/cpptools/cpptoolsplugin.cpp | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index 19f986a8b9..61173c8e5f 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -51,6 +51,7 @@ #include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/vcsmanager.h> #include <coreplugin/filemanager.h> +#include <texteditor/texteditorsettings.h> #include <cppeditor/cppeditorconstants.h> #include <QtCore/QtConcurrentRun> @@ -109,8 +110,8 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) m_modelManager, SLOT(updateSourceFiles(QStringList))); addAutoReleasedObject(m_modelManager); - m_completion = new CppCodeCompletion(m_modelManager); - addAutoReleasedObject(m_completion); + CppCodeCompletion *completion = new CppCodeCompletion(m_modelManager); + addAutoReleasedObject(completion); CppLocatorFilter *locatorFilter = new CppLocatorFilter(m_modelManager, core->editorManager()); @@ -118,7 +119,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) addAutoReleasedObject(new CppClassesFilter(m_modelManager, core->editorManager())); addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, core->editorManager())); addAutoReleasedObject(new CppCurrentDocumentFilter(m_modelManager, core->editorManager())); - addAutoReleasedObject(new CompletionSettingsPage(m_completion)); + addAutoReleasedObject(new CompletionSettingsPage); addAutoReleasedObject(new CppFileSettingsPage(m_fileSettings)); // Menus @@ -139,17 +140,11 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) mcpptools->addAction(command); connect(switchAction, SIGNAL(triggered()), this, SLOT(switchHeaderSource())); - // Restore settings - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(QLatin1String("CppTools")); - settings->beginGroup(QLatin1String("Completion")); - const int caseSensitivity = settings->value(QLatin1String("CaseSensitivity"), m_completion->caseSensitivity()).toInt(); - m_completion->setCaseSensitivity((CppCodeCompletion::CaseSensitivity) caseSensitivity); - m_completion->setAutoInsertBrackets(settings->value(QLatin1String("AutoInsertBraces"), true).toBool()); - m_completion->setPartialCompletionEnabled(settings->value(QLatin1String("PartiallyComplete"), true).toBool()); - m_completion->setSpaceAfterFunctionName(settings->value(QLatin1String("SpaceAfterFunctionName"), false).toBool()); - settings->endGroup(); - settings->endGroup(); + // Set completion settings and keep them up to date + TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance(); + completion->setCompletionSettings(textEditorSettings->completionSettings()); + connect(textEditorSettings, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)), + completion, SLOT(setCompletionSettings(TextEditor::CompletionSettings))); return true; } @@ -170,16 +165,6 @@ void CppToolsPlugin::extensionsInitialized() void CppToolsPlugin::aboutToShutdown() { - // Save settings - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(QLatin1String("CppTools")); - settings->beginGroup(QLatin1String("Completion")); - settings->setValue(QLatin1String("CaseSensitivity"), (int) m_completion->caseSensitivity()); - settings->setValue(QLatin1String("AutoInsertBraces"), m_completion->autoInsertBrackets()); - settings->setValue(QLatin1String("PartiallyComplete"), m_completion->isPartialCompletionEnabled()); - settings->setValue(QLatin1String("SpaceAfterFunctionName"), m_completion->isSpaceAfterFunctionName()); - settings->endGroup(); - settings->endGroup(); } void CppToolsPlugin::switchHeaderSource() |