Commit c422b813 authored by David Schulz's avatar David Schulz

Move completion settings page to TextEditor plugin.

Change-Id: I12b7828d23d599e5903237d0cc2a3c0440e1b07d
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Riitta-Leena Miettinen's avatarLeena Miettinen <riitta-leena.miettinen@qt.io>
parent 702fd2e6
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
#include "cppautocompleter.h" #include "cppautocompleter.h"
#include <cpptools/cpptoolssettings.h> #include <cpptools/cpptoolssettings.h>
#include <cpptools/commentssettings.h>
#include <cpptools/doxygengenerator.h> #include <cpptools/doxygengenerator.h>
#include <texteditor/commentssettings.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include <cplusplus/MatchingText.h> #include <cplusplus/MatchingText.h>
...@@ -272,7 +273,7 @@ namespace Internal { ...@@ -272,7 +273,7 @@ namespace Internal {
bool trySplitComment(TextEditor::TextEditorWidget *editorWidget, bool trySplitComment(TextEditor::TextEditorWidget *editorWidget,
const CPlusPlus::Snapshot &snapshot) const CPlusPlus::Snapshot &snapshot)
{ {
const CommentsSettings &settings = CppToolsSettings::instance()->commentsSettings(); const TextEditor::CommentsSettings &settings = CppToolsSettings::instance()->commentsSettings();
if (!settings.m_enableDoxygen && !settings.m_leadingAsterisks) if (!settings.m_enableDoxygen && !settings.m_leadingAsterisks)
return false; return false;
......
...@@ -339,7 +339,7 @@ void DoxygenTest::testNoLeadingAsterisks() ...@@ -339,7 +339,7 @@ void DoxygenTest::testNoLeadingAsterisks()
QFETCH(QByteArray, given); QFETCH(QByteArray, given);
QFETCH(QByteArray, expected); QFETCH(QByteArray, expected);
CppTools::CommentsSettings injection; TextEditor::CommentsSettings injection;
injection.m_enableDoxygen = true; injection.m_enableDoxygen = true;
injection.m_leadingAsterisks = false; injection.m_leadingAsterisks = false;
...@@ -356,7 +356,7 @@ void DoxygenTest::verifyCleanState() const ...@@ -356,7 +356,7 @@ void DoxygenTest::verifyCleanState() const
/// The '|' in the input denotes the cursor position. /// The '|' in the input denotes the cursor position.
void DoxygenTest::runTest(const QByteArray &original, void DoxygenTest::runTest(const QByteArray &original,
const QByteArray &expected, const QByteArray &expected,
CppTools::CommentsSettings *settings, TextEditor::CommentsSettings *settings,
const TestDocuments &includedHeaderDocuments) const TestDocuments &includedHeaderDocuments)
{ {
// Write files to disk // Write files to disk
...@@ -381,7 +381,7 @@ void DoxygenTest::runTest(const QByteArray &original, ...@@ -381,7 +381,7 @@ void DoxygenTest::runTest(const QByteArray &original,
if (settings) { if (settings) {
auto *cts = CppTools::CppToolsSettings::instance(); auto *cts = CppTools::CppToolsSettings::instance();
oldSettings.reset(new CppTools::CommentsSettings(cts->commentsSettings())); oldSettings.reset(new TextEditor::CommentsSettings(cts->commentsSettings()));
cts->setCommentsSettings(*settings); cts->setCommentsSettings(*settings);
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "cppeditortestcase.h" #include "cppeditortestcase.h"
#include <cpptools/commentssettings.h> #include <texteditor/commentssettings.h>
#include <QObject> #include <QObject>
#include <QScopedPointer> #include <QScopedPointer>
...@@ -58,10 +58,10 @@ private: ...@@ -58,10 +58,10 @@ private:
void verifyCleanState() const; void verifyCleanState() const;
void runTest(const QByteArray &original, void runTest(const QByteArray &original,
const QByteArray &expected, const QByteArray &expected,
CppTools::CommentsSettings *settings = 0, TextEditor::CommentsSettings *settings = 0,
const TestDocuments &includedHeaderDocuments = TestDocuments()); const TestDocuments &includedHeaderDocuments = TestDocuments());
QScopedPointer<CppTools::CommentsSettings> oldSettings; QScopedPointer<TextEditor::CommentsSettings> oldSettings;
}; };
} // namespace Tests } // namespace Tests
......
...@@ -12,8 +12,6 @@ HEADERS += \ ...@@ -12,8 +12,6 @@ HEADERS += \
clangdiagnosticconfig.h \ clangdiagnosticconfig.h \
clangdiagnosticconfigsmodel.h \ clangdiagnosticconfigsmodel.h \
clangdiagnosticconfigswidget.h \ clangdiagnosticconfigswidget.h \
commentssettings.h \
completionsettingspage.h \
cppchecksymbols.h \ cppchecksymbols.h \
cppclassesfilter.h \ cppclassesfilter.h \
cppcodeformatter.h \ cppcodeformatter.h \
...@@ -90,8 +88,6 @@ SOURCES += \ ...@@ -90,8 +88,6 @@ SOURCES += \
clangdiagnosticconfig.cpp \ clangdiagnosticconfig.cpp \
clangdiagnosticconfigsmodel.cpp \ clangdiagnosticconfigsmodel.cpp \
clangdiagnosticconfigswidget.cpp \ clangdiagnosticconfigswidget.cpp \
commentssettings.cpp \
completionsettingspage.cpp \
cppchecksymbols.cpp \ cppchecksymbols.cpp \
cppclassesfilter.cpp \ cppclassesfilter.cpp \
cppcodeformatter.cpp \ cppcodeformatter.cpp \
...@@ -156,7 +152,6 @@ SOURCES += \ ...@@ -156,7 +152,6 @@ SOURCES += \
FORMS += \ FORMS += \
clangdiagnosticconfigswidget.ui \ clangdiagnosticconfigswidget.ui \
completionsettingspage.ui \
cppcodemodelsettingspage.ui \ cppcodemodelsettingspage.ui \
cppcodestylesettingspage.ui \ cppcodestylesettingspage.ui \
cppfilesettingspage.ui cppfilesettingspage.ui
......
...@@ -36,8 +36,6 @@ QtcPlugin { ...@@ -36,8 +36,6 @@ QtcPlugin {
"clangdiagnosticconfigswidget.cpp", "clangdiagnosticconfigswidget.h", "clangdiagnosticconfigswidget.cpp", "clangdiagnosticconfigswidget.h",
"clangdiagnosticconfigswidget.ui", "clangdiagnosticconfigswidget.ui",
"compileroptionsbuilder.cpp", "compileroptionsbuilder.h", "compileroptionsbuilder.cpp", "compileroptionsbuilder.h",
"commentssettings.cpp", "commentssettings.h",
"completionsettingspage.cpp", "completionsettingspage.h", "completionsettingspage.ui",
"cppchecksymbols.cpp", "cppchecksymbols.h", "cppchecksymbols.cpp", "cppchecksymbols.h",
"cppclassesfilter.cpp", "cppclassesfilter.h", "cppclassesfilter.cpp", "cppclassesfilter.h",
"cppcodeformatter.cpp", "cppcodeformatter.h", "cppcodeformatter.cpp", "cppcodeformatter.h",
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
#include "cpptoolsconstants.h" #include "cpptoolsconstants.h"
#include "cppcodestylepreferences.h" #include "cppcodestylepreferences.h"
#include "cppcodestylepreferencesfactory.h" #include "cppcodestylepreferencesfactory.h"
#include "commentssettings.h"
#include "completionsettingspage.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <texteditor/commentssettings.h>
#include <texteditor/completionsettingspage.h>
#include <texteditor/codestylepool.h> #include <texteditor/codestylepool.h>
#include <texteditor/tabsettings.h> #include <texteditor/tabsettings.h>
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
...@@ -57,12 +57,10 @@ class CppToolsSettingsPrivate ...@@ -57,12 +57,10 @@ class CppToolsSettingsPrivate
public: public:
CppToolsSettingsPrivate() CppToolsSettingsPrivate()
: m_globalCodeStyle(0) : m_globalCodeStyle(0)
, m_completionSettingsPage(0)
{} {}
CommentsSettings m_commentsSettings; CommentsSettings m_commentsSettings;
CppCodeStylePreferences *m_globalCodeStyle; CppCodeStylePreferences *m_globalCodeStyle;
CompletionSettingsPage *m_completionSettingsPage;
}; };
} // namespace Internal } // namespace Internal
...@@ -79,10 +77,9 @@ CppToolsSettings::CppToolsSettings(QObject *parent) ...@@ -79,10 +77,9 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
qRegisterMetaType<CppTools::CppCodeStyleSettings>("CppTools::CppCodeStyleSettings"); qRegisterMetaType<CppTools::CppCodeStyleSettings>("CppTools::CppCodeStyleSettings");
QSettings *s = ICore::settings(); d->m_commentsSettings = TextEditorSettings::commentsSettings();
d->m_commentsSettings.fromSettings(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP), s); connect(TextEditorSettings::instance(), &TextEditorSettings::commentsSettingsChanged,
d->m_completionSettingsPage = new CompletionSettingsPage(this); this, &CppToolsSettings::setCommentsSettings);
ExtensionSystem::PluginManager::addObject(d->m_completionSettingsPage);
// code style factory // code style factory
ICodeStylePreferencesFactory *factory = new CppCodeStylePreferencesFactory(); ICodeStylePreferencesFactory *factory = new CppCodeStylePreferencesFactory();
...@@ -163,6 +160,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent) ...@@ -163,6 +160,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
pool->loadCustomCodeStyles(); pool->loadCustomCodeStyles();
QSettings *s = ICore::settings();
// load global settings (after built-in settings are added to the pool) // load global settings (after built-in settings are added to the pool)
d->m_globalCodeStyle->fromSettings(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID), s); d->m_globalCodeStyle->fromSettings(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID), s);
...@@ -223,8 +221,6 @@ CppToolsSettings::CppToolsSettings(QObject *parent) ...@@ -223,8 +221,6 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
CppToolsSettings::~CppToolsSettings() CppToolsSettings::~CppToolsSettings()
{ {
ExtensionSystem::PluginManager::removeObject(d->m_completionSettingsPage);
TextEditorSettings::unregisterCodeStyle(Constants::CPP_SETTINGS_ID); TextEditorSettings::unregisterCodeStyle(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStylePool(Constants::CPP_SETTINGS_ID); TextEditorSettings::unregisterCodeStylePool(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStyleFactory(Constants::CPP_SETTINGS_ID); TextEditorSettings::unregisterCodeStyleFactory(Constants::CPP_SETTINGS_ID);
...@@ -251,12 +247,7 @@ const CommentsSettings &CppToolsSettings::commentsSettings() const ...@@ -251,12 +247,7 @@ const CommentsSettings &CppToolsSettings::commentsSettings() const
void CppToolsSettings::setCommentsSettings(const CommentsSettings &commentsSettings) void CppToolsSettings::setCommentsSettings(const CommentsSettings &commentsSettings)
{ {
if (d->m_commentsSettings == commentsSettings)
return;
d->m_commentsSettings = commentsSettings; d->m_commentsSettings = commentsSettings;
d->m_commentsSettings.toSettings(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP),
ICore::settings());
} }
static QString sortEditorDocumentOutlineKey() static QString sortEditorDocumentOutlineKey()
......
...@@ -29,10 +29,13 @@ ...@@ -29,10 +29,13 @@
#include <QObject> #include <QObject>
namespace TextEditor {
class CommentsSettings;
}
namespace CppTools namespace CppTools
{ {
class CppCodeStylePreferences; class CppCodeStylePreferences;
class CommentsSettings;
namespace Internal namespace Internal
{ {
...@@ -54,8 +57,8 @@ public: ...@@ -54,8 +57,8 @@ public:
CppCodeStylePreferences *cppCodeStyle() const; CppCodeStylePreferences *cppCodeStyle() const;
const CommentsSettings &commentsSettings() const; const TextEditor::CommentsSettings &commentsSettings() const;
void setCommentsSettings(const CommentsSettings &commentsSettings); void setCommentsSettings(const TextEditor::CommentsSettings &commentsSettings);
bool sortedEditorDocumentOutline() const; bool sortedEditorDocumentOutline() const;
void setSortedEditorDocumentOutline(bool sorted); void setSortedEditorDocumentOutline(bool sorted);
......
...@@ -127,6 +127,7 @@ CodeAssistantPrivate::CodeAssistantPrivate(CodeAssistant *assistant) ...@@ -127,6 +127,7 @@ CodeAssistantPrivate::CodeAssistantPrivate(CodeAssistant *assistant)
connect(&m_automaticProposalTimer, &QTimer::timeout, connect(&m_automaticProposalTimer, &QTimer::timeout,
this, &CodeAssistantPrivate::automaticProposalTimeout); this, &CodeAssistantPrivate::automaticProposalTimeout);
m_settings = TextEditorSettings::completionSettings();
connect(TextEditorSettings::instance(), &TextEditorSettings::completionSettingsChanged, connect(TextEditorSettings::instance(), &TextEditorSettings::completionSettingsChanged,
this, &CodeAssistantPrivate::updateFromCompletionSettings); this, &CodeAssistantPrivate::updateFromCompletionSettings);
...@@ -514,11 +515,6 @@ void CodeAssistant::configure(TextEditorWidget *editorWidget) ...@@ -514,11 +515,6 @@ void CodeAssistant::configure(TextEditorWidget *editorWidget)
d->configure(editorWidget); d->configure(editorWidget);
} }
void CodeAssistant::updateFromCompletionSettings(const CompletionSettings &settings)
{
d->updateFromCompletionSettings(settings);
}
void CodeAssistant::process() void CodeAssistant::process()
{ {
d->process(); d->process();
......
...@@ -47,7 +47,6 @@ public: ...@@ -47,7 +47,6 @@ public:
~CodeAssistant(); ~CodeAssistant();
void configure(TextEditorWidget *editorWidget); void configure(TextEditorWidget *editorWidget);
void updateFromCompletionSettings(const TextEditor::CompletionSettings &settings);
void process(); void process();
void notifyChange(); void notifyChange();
......
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
#include <QSettings> #include <QSettings>
using namespace CppTools; using namespace TextEditor;
namespace { namespace {
const char kDocumentationCommentsGroup[] = "DocumentationComments"; const char kDocumentationCommentsGroup[] = "CppToolsDocumentationComments";
const char kEnableDoxygenBlocks[] = "EnableDoxygenBlocks"; const char kEnableDoxygenBlocks[] = "EnableDoxygenBlocks";
const char kGenerateBrief[] = "GenerateBrief"; const char kGenerateBrief[] = "GenerateBrief";
const char kAddLeadingAsterisks[] = "AddLeadingAsterisks"; const char kAddLeadingAsterisks[] = "AddLeadingAsterisks";
...@@ -44,22 +44,21 @@ CommentsSettings::CommentsSettings() ...@@ -44,22 +44,21 @@ CommentsSettings::CommentsSettings()
, m_leadingAsterisks(true) , m_leadingAsterisks(true)
{} {}
void CommentsSettings::toSettings(const QString &category, QSettings *s) const void CommentsSettings::toSettings(QSettings *s) const
{ {
s->beginGroup(category + QLatin1String(kDocumentationCommentsGroup)); s->beginGroup(kDocumentationCommentsGroup);
s->setValue(QLatin1String(kEnableDoxygenBlocks), m_enableDoxygen); s->setValue(kEnableDoxygenBlocks, m_enableDoxygen);
s->setValue(QLatin1String(kGenerateBrief), m_generateBrief); s->setValue(kGenerateBrief, m_generateBrief);
s->setValue(QLatin1String(kAddLeadingAsterisks), m_leadingAsterisks); s->setValue(kAddLeadingAsterisks, m_leadingAsterisks);
s->endGroup(); s->endGroup();
} }
void CommentsSettings::fromSettings(const QString &category, QSettings *s) void CommentsSettings::fromSettings(QSettings *s)
{ {
s->beginGroup(category + QLatin1String(kDocumentationCommentsGroup)); s->beginGroup(kDocumentationCommentsGroup);
m_enableDoxygen = s->value(QLatin1String(kEnableDoxygenBlocks), true).toBool(); m_enableDoxygen = s->value(kEnableDoxygenBlocks, true).toBool();
m_generateBrief = m_enableDoxygen m_generateBrief = m_enableDoxygen && s->value(kGenerateBrief, true).toBool();
&& s->value(QLatin1String(kGenerateBrief), true).toBool(); m_leadingAsterisks = s->value(kAddLeadingAsterisks, true).toBool();
m_leadingAsterisks = s->value(QLatin1String(kAddLeadingAsterisks), true).toBool();
s->endGroup(); s->endGroup();
} }
......
...@@ -25,21 +25,21 @@ ...@@ -25,21 +25,21 @@
#pragma once #pragma once
#include "cpptools_global.h" #include "texteditor_global.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QSettings; class QSettings;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace CppTools { namespace TextEditor {
class CPPTOOLS_EXPORT CommentsSettings class TEXTEDITOR_EXPORT CommentsSettings
{ {
public: public:
CommentsSettings(); CommentsSettings();
void toSettings(const QString &category, QSettings *s) const; void toSettings(QSettings *s) const;
void fromSettings(const QString &category, QSettings *s); void fromSettings(QSettings *s);
bool equals(const CommentsSettings &other) const; bool equals(const CommentsSettings &other) const;
...@@ -54,4 +54,4 @@ inline bool operator==(const CommentsSettings &a, const CommentsSettings &b) ...@@ -54,4 +54,4 @@ inline bool operator==(const CommentsSettings &a, const CommentsSettings &b)
inline bool operator!=(const CommentsSettings &a, const CommentsSettings &b) inline bool operator!=(const CommentsSettings &a, const CommentsSettings &b)
{ return !(a == b); } { return !(a == b); }
} // namespace CppTools } // namespace TextEditor
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <QSettings> #include <QSettings>
static const char groupPostfix[] = "Completion"; static const char settingsGroup[] = "CppTools/Completion";
static const char caseSensitivityKey[] = "CaseSensitivity"; static const char caseSensitivityKey[] = "CaseSensitivity";
static const char completionTriggerKey[] = "CompletionTrigger"; static const char completionTriggerKey[] = "CompletionTrigger";
static const char automaticProposalTimeoutKey[] = "AutomaticProposalTimeout"; static const char automaticProposalTimeoutKey[] = "AutomaticProposalTimeout";
...@@ -41,13 +41,9 @@ static const char autoSplitStringsKey[] = "AutoSplitStrings"; ...@@ -41,13 +41,9 @@ static const char autoSplitStringsKey[] = "AutoSplitStrings";
using namespace TextEditor; using namespace TextEditor;
void CompletionSettings::toSettings(const QString &category, QSettings *s) const void CompletionSettings::toSettings(QSettings *s) const
{ {
QString group(groupPostfix); s->beginGroup(settingsGroup);
if (!category.isEmpty())
group.insert(0, category);
s->beginGroup(group);
s->setValue(caseSensitivityKey, (int) m_caseSensitivity); s->setValue(caseSensitivityKey, (int) m_caseSensitivity);
s->setValue(completionTriggerKey, (int) m_completionTrigger); s->setValue(completionTriggerKey, (int) m_completionTrigger);
s->setValue(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs); s->setValue(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs);
...@@ -61,35 +57,32 @@ void CompletionSettings::toSettings(const QString &category, QSettings *s) const ...@@ -61,35 +57,32 @@ void CompletionSettings::toSettings(const QString &category, QSettings *s) const
s->endGroup(); s->endGroup();
} }
void CompletionSettings::fromSettings(const QString &category, const QSettings *s) void CompletionSettings::fromSettings(QSettings *s)
{ {
QString group(groupPostfix);
if (!category.isEmpty())
group.insert(0, category);
group += '/';
*this = CompletionSettings(); // Assign defaults *this = CompletionSettings(); // Assign defaults
s->beginGroup(settingsGroup);
m_caseSensitivity = (CaseSensitivity) m_caseSensitivity = (CaseSensitivity)
s->value(group + caseSensitivityKey, m_caseSensitivity).toInt(); s->value(caseSensitivityKey, m_caseSensitivity).toInt();
m_completionTrigger = (CompletionTrigger) m_completionTrigger = (CompletionTrigger)
s->value(group + completionTriggerKey, m_completionTrigger).toInt(); s->value(completionTriggerKey, m_completionTrigger).toInt();
m_automaticProposalTimeoutInMs = m_automaticProposalTimeoutInMs =
s->value(group + automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs).toInt(); s->value(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs).toInt();
m_autoInsertBrackets = m_autoInsertBrackets =
s->value(group + autoInsertBracesKey, m_autoInsertBrackets).toBool(); s->value(autoInsertBracesKey, m_autoInsertBrackets).toBool();
m_surroundingAutoBrackets = m_surroundingAutoBrackets =
s->value(group + surroundingAutoBracketsKey, m_surroundingAutoBrackets).toBool(); s->value(surroundingAutoBracketsKey, m_surroundingAutoBrackets).toBool();
m_autoInsertQuotes = m_autoInsertQuotes =
s->value(group + autoInsertQuotesKey, m_autoInsertQuotes).toBool(); s->value(autoInsertQuotesKey, m_autoInsertQuotes).toBool();
m_surroundingAutoQuotes = m_surroundingAutoQuotes =
s->value(group + surroundingAutoQuotesKey, m_surroundingAutoQuotes).toBool(); s->value(surroundingAutoQuotesKey, m_surroundingAutoQuotes).toBool();
m_partiallyComplete = m_partiallyComplete =
s->value(group + partiallyCompleteKey, m_partiallyComplete).toBool(); s->value(partiallyCompleteKey, m_partiallyComplete).toBool();
m_spaceAfterFunctionName = m_spaceAfterFunctionName =
s->value(group + spaceAfterFunctionNameKey, m_spaceAfterFunctionName).toBool(); s->value(spaceAfterFunctionNameKey, m_spaceAfterFunctionName).toBool();
m_autoSplitStrings = m_autoSplitStrings =
s->value(group + autoSplitStringsKey, m_autoSplitStrings).toBool(); s->value(autoSplitStringsKey, m_autoSplitStrings).toBool();
s->endGroup();
} }
bool CompletionSettings::equals(const CompletionSettings &cs) const bool CompletionSettings::equals(const CompletionSettings &cs) const
......
...@@ -51,8 +51,8 @@ enum CompletionTrigger { ...@@ -51,8 +51,8 @@ enum CompletionTrigger {
class TEXTEDITOR_EXPORT CompletionSettings class TEXTEDITOR_EXPORT CompletionSettings
{ {
public: public:
void toSettings(const QString &category, QSettings *s) const; void toSettings(QSettings *s) const;
void fromSettings(const QString &category, const QSettings *s); void fromSettings(QSettings *s);
bool equals(const CompletionSettings &bs) const; bool equals(const CompletionSettings &bs) const;
......
...@@ -25,16 +25,17 @@ ...@@ -25,16 +25,17 @@
#include "completionsettingspage.h" #include "completionsettingspage.h"
#include "ui_completionsettingspage.h" #include "ui_completionsettingspage.h"
#include "texteditorsettings.h"
#include "cpptoolssettings.h" #include <cpptools/cpptoolssettings.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <texteditor/texteditorsettings.h>
#include <QTextStream> #include <QTextStream>
using namespace TextEditor;
using namespace TextEditor::Internal;
using namespace CppTools; using namespace CppTools;
using namespace CppTools::Internal;
CompletionSettingsPage::CompletionSettingsPage(QObject *parent) CompletionSettingsPage::CompletionSettingsPage(QObject *parent)
: TextEditor::TextEditorOptionsPage(parent) : TextEditor::TextEditorOptionsPage(parent)
...@@ -42,6 +43,10 @@ CompletionSettingsPage::CompletionSettingsPage(QObject *parent) ...@@ -42,6 +43,10 @@ CompletionSettingsPage::CompletionSettingsPage(QObject *parent)
{ {
setId("P.Completion"); setId("P.Completion");
setDisplayName(tr("Completion")); setDisplayName(tr("Completion"));
QSettings *s = Core::ICore::settings();
m_completionSettings.fromSettings(s);
m_commentsSettings.fromSettings(s);
} }
CompletionSettingsPage::~CompletionSettingsPage() CompletionSettingsPage::~CompletionSettingsPage()
...@@ -60,11 +65,8 @@ QWidget *CompletionSettingsPage::widget() ...@@ -60,11 +65,8 @@ QWidget *CompletionSettingsPage::widget()
static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &CompletionSettingsPage::onCompletionTriggerChanged); this, &CompletionSettingsPage::onCompletionTriggerChanged);
const TextEditor::CompletionSettings &completionSettings =
TextEditor::TextEditorSettings::completionSettings();
int caseSensitivityIndex = 0; int caseSensitivityIndex = 0;
switch (completionSettings.m_caseSensitivity) { switch (m_completionSettings.m_caseSensitivity) {
case TextEditor::CaseSensitive: case TextEditor::CaseSensitive:
caseSensitivityIndex = 0; caseSensitivityIndex = 0;
break; break;
...@@ -77,7 +79,7 @@ QWidget *CompletionSettingsPage::widget() ...@@ -77,7 +79,7 @@ QWidget *CompletionSettingsPage::widget()
} }
int completionTriggerIndex = 0; int completionTriggerIndex = 0;
switch (completionSettings.m_completionTrigger) { switch (m_completionSettings.m_completionTrigger) {
case TextEditor::ManualCompletion: case TextEditor::ManualCompletion:
completionTriggerIndex = 0; completionTriggerIndex = 0;
break; break;
...@@ -92,19 +94,18 @@ QWidget *CompletionSettingsPage::widget() ...@@ -92,19 +94,18 @@ QWidget *CompletionSettingsPage::widget()
m_page->caseSensitivity->setCurrentIndex(caseSensitivityIndex); m_page->caseSensitivity->setCurrentIndex(caseSensitivityIndex);
m_page->completionTrigger->setCurrentIndex(completionTriggerIndex); m_page->completionTrigger->setCurrentIndex(completionTriggerIndex);
m_page->automaticProposalTimeoutSpinBox m_page->automaticProposalTimeoutSpinBox
->setValue(completionSettings.m_automaticProposalTimeoutInMs); ->setValue(m_completionSettings.m_automaticProposalTimeoutInMs);
m_page->insertBrackets->setChecked(completionSettings.m_autoInsertBrackets); m_page->insertBrackets->setChecked(m_completionSettings.m_autoInsertBrackets);
m_page->surroundBrackets->setChecked(completionSettings.m_surroundingAutoBrackets); m_page->surroundBrackets->setChecked(m_completionSettings.m_surroundingAutoBrackets);
m_page->insertQuotes->setChecked(completionSettings.m_autoInsertQuotes); m_page->insertQuotes->setChecked(m_completionSettings.m_autoInsertQuotes);
m_page->surroundQuotes->setChecked(completionSettings.m_surroundingAutoQuotes); m_page->surroundQuotes->setChecked(m_completionSettings.m_surroundingAutoQuotes);
m_page->partiallyComplete->setChecked(completionSettings.m_partiallyComplete); m_page->partiallyComplete->setChecked(m_completionSettings.m_partiallyComplete);
m_page->spaceAfterFunctionName->setChecked(completionSettings.m_spaceAfterFunctionName); m_page->spaceAfterFunctionName->setChecked(m_completionSettings.m_spaceAfterFunctionName);