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 @@
#include "cppautocompleter.h"
#include <cpptools/cpptoolssettings.h>
#include <cpptools/commentssettings.h>
#include <cpptools/doxygengenerator.h>
#include <texteditor/commentssettings.h>
#include <texteditor/texteditor.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/textdocument.h>
#include <cplusplus/MatchingText.h>
......@@ -272,7 +273,7 @@ namespace Internal {
bool trySplitComment(TextEditor::TextEditorWidget *editorWidget,
const CPlusPlus::Snapshot &snapshot)
{
const CommentsSettings &settings = CppToolsSettings::instance()->commentsSettings();
const TextEditor::CommentsSettings &settings = CppToolsSettings::instance()->commentsSettings();
if (!settings.m_enableDoxygen && !settings.m_leadingAsterisks)
return false;
......
......@@ -339,7 +339,7 @@ void DoxygenTest::testNoLeadingAsterisks()
QFETCH(QByteArray, given);
QFETCH(QByteArray, expected);
CppTools::CommentsSettings injection;
TextEditor::CommentsSettings injection;
injection.m_enableDoxygen = true;
injection.m_leadingAsterisks = false;
......@@ -356,7 +356,7 @@ void DoxygenTest::verifyCleanState() const
/// The '|' in the input denotes the cursor position.
void DoxygenTest::runTest(const QByteArray &original,
const QByteArray &expected,
CppTools::CommentsSettings *settings,
TextEditor::CommentsSettings *settings,
const TestDocuments &includedHeaderDocuments)
{
// Write files to disk
......@@ -381,7 +381,7 @@ void DoxygenTest::runTest(const QByteArray &original,
if (settings) {
auto *cts = CppTools::CppToolsSettings::instance();
oldSettings.reset(new CppTools::CommentsSettings(cts->commentsSettings()));
oldSettings.reset(new TextEditor::CommentsSettings(cts->commentsSettings()));
cts->setCommentsSettings(*settings);
}
......
......@@ -27,7 +27,7 @@
#include "cppeditortestcase.h"
#include <cpptools/commentssettings.h>
#include <texteditor/commentssettings.h>
#include <QObject>
#include <QScopedPointer>
......@@ -58,10 +58,10 @@ private:
void verifyCleanState() const;
void runTest(const QByteArray &original,
const QByteArray &expected,
CppTools::CommentsSettings *settings = 0,
TextEditor::CommentsSettings *settings = 0,
const TestDocuments &includedHeaderDocuments = TestDocuments());
QScopedPointer<CppTools::CommentsSettings> oldSettings;
QScopedPointer<TextEditor::CommentsSettings> oldSettings;
};
} // namespace Tests
......
......@@ -12,8 +12,6 @@ HEADERS += \
clangdiagnosticconfig.h \
clangdiagnosticconfigsmodel.h \
clangdiagnosticconfigswidget.h \
commentssettings.h \
completionsettingspage.h \
cppchecksymbols.h \
cppclassesfilter.h \
cppcodeformatter.h \
......@@ -90,8 +88,6 @@ SOURCES += \
clangdiagnosticconfig.cpp \
clangdiagnosticconfigsmodel.cpp \
clangdiagnosticconfigswidget.cpp \
commentssettings.cpp \
completionsettingspage.cpp \
cppchecksymbols.cpp \
cppclassesfilter.cpp \
cppcodeformatter.cpp \
......@@ -156,7 +152,6 @@ SOURCES += \
FORMS += \
clangdiagnosticconfigswidget.ui \
completionsettingspage.ui \
cppcodemodelsettingspage.ui \
cppcodestylesettingspage.ui \
cppfilesettingspage.ui
......
......@@ -36,8 +36,6 @@ QtcPlugin {
"clangdiagnosticconfigswidget.cpp", "clangdiagnosticconfigswidget.h",
"clangdiagnosticconfigswidget.ui",
"compileroptionsbuilder.cpp", "compileroptionsbuilder.h",
"commentssettings.cpp", "commentssettings.h",
"completionsettingspage.cpp", "completionsettingspage.h", "completionsettingspage.ui",
"cppchecksymbols.cpp", "cppchecksymbols.h",
"cppclassesfilter.cpp", "cppclassesfilter.h",
"cppcodeformatter.cpp", "cppcodeformatter.h",
......
......@@ -28,10 +28,10 @@
#include "cpptoolsconstants.h"
#include "cppcodestylepreferences.h"
#include "cppcodestylepreferencesfactory.h"
#include "commentssettings.h"
#include "completionsettingspage.h"
#include <coreplugin/icore.h>
#include <texteditor/commentssettings.h>
#include <texteditor/completionsettingspage.h>
#include <texteditor/codestylepool.h>
#include <texteditor/tabsettings.h>
#include <texteditor/texteditorsettings.h>
......@@ -57,12 +57,10 @@ class CppToolsSettingsPrivate
public:
CppToolsSettingsPrivate()
: m_globalCodeStyle(0)
, m_completionSettingsPage(0)
{}
CommentsSettings m_commentsSettings;
CppCodeStylePreferences *m_globalCodeStyle;
CompletionSettingsPage *m_completionSettingsPage;
};
} // namespace Internal
......@@ -79,10 +77,9 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
qRegisterMetaType<CppTools::CppCodeStyleSettings>("CppTools::CppCodeStyleSettings");
QSettings *s = ICore::settings();
d->m_commentsSettings.fromSettings(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP), s);
d->m_completionSettingsPage = new CompletionSettingsPage(this);
ExtensionSystem::PluginManager::addObject(d->m_completionSettingsPage);
d->m_commentsSettings = TextEditorSettings::commentsSettings();
connect(TextEditorSettings::instance(), &TextEditorSettings::commentsSettingsChanged,
this, &CppToolsSettings::setCommentsSettings);
// code style factory
ICodeStylePreferencesFactory *factory = new CppCodeStylePreferencesFactory();
......@@ -163,6 +160,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
pool->loadCustomCodeStyles();
QSettings *s = ICore::settings();
// load global settings (after built-in settings are added to the pool)
d->m_globalCodeStyle->fromSettings(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID), s);
......@@ -223,8 +221,6 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
CppToolsSettings::~CppToolsSettings()
{
ExtensionSystem::PluginManager::removeObject(d->m_completionSettingsPage);
TextEditorSettings::unregisterCodeStyle(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStylePool(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStyleFactory(Constants::CPP_SETTINGS_ID);
......@@ -251,12 +247,7 @@ const CommentsSettings &CppToolsSettings::commentsSettings() const
void CppToolsSettings::setCommentsSettings(const CommentsSettings &commentsSettings)
{
if (d->m_commentsSettings == commentsSettings)
return;
d->m_commentsSettings = commentsSettings;
d->m_commentsSettings.toSettings(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP),
ICore::settings());
}
static QString sortEditorDocumentOutlineKey()
......
......@@ -29,10 +29,13 @@
#include <QObject>
namespace TextEditor {
class CommentsSettings;
}
namespace CppTools
{
class CppCodeStylePreferences;
class CommentsSettings;
namespace Internal
{
......@@ -54,8 +57,8 @@ public:
CppCodeStylePreferences *cppCodeStyle() const;
const CommentsSettings &commentsSettings() const;
void setCommentsSettings(const CommentsSettings &commentsSettings);
const TextEditor::CommentsSettings &commentsSettings() const;
void setCommentsSettings(const TextEditor::CommentsSettings &commentsSettings);
bool sortedEditorDocumentOutline() const;
void setSortedEditorDocumentOutline(bool sorted);
......
......@@ -127,6 +127,7 @@ CodeAssistantPrivate::CodeAssistantPrivate(CodeAssistant *assistant)
connect(&m_automaticProposalTimer, &QTimer::timeout,
this, &CodeAssistantPrivate::automaticProposalTimeout);
m_settings = TextEditorSettings::completionSettings();
connect(TextEditorSettings::instance(), &TextEditorSettings::completionSettingsChanged,
this, &CodeAssistantPrivate::updateFromCompletionSettings);
......@@ -514,11 +515,6 @@ void CodeAssistant::configure(TextEditorWidget *editorWidget)
d->configure(editorWidget);
}
void CodeAssistant::updateFromCompletionSettings(const CompletionSettings &settings)
{
d->updateFromCompletionSettings(settings);
}
void CodeAssistant::process()
{
d->process();
......
......@@ -47,7 +47,6 @@ public:
~CodeAssistant();
void configure(TextEditorWidget *editorWidget);
void updateFromCompletionSettings(const TextEditor::CompletionSettings &settings);
void process();
void notifyChange();
......
......@@ -27,11 +27,11 @@
#include <QSettings>
using namespace CppTools;
using namespace TextEditor;
namespace {
const char kDocumentationCommentsGroup[] = "DocumentationComments";
const char kDocumentationCommentsGroup[] = "CppToolsDocumentationComments";
const char kEnableDoxygenBlocks[] = "EnableDoxygenBlocks";
const char kGenerateBrief[] = "GenerateBrief";
const char kAddLeadingAsterisks[] = "AddLeadingAsterisks";
......@@ -44,22 +44,21 @@ CommentsSettings::CommentsSettings()
, m_leadingAsterisks(true)
{}
void CommentsSettings::toSettings(const QString &category, QSettings *s) const
void CommentsSettings::toSettings(QSettings *s) const
{
s->beginGroup(category + QLatin1String(kDocumentationCommentsGroup));
s->setValue(QLatin1String(kEnableDoxygenBlocks), m_enableDoxygen);
s->setValue(QLatin1String(kGenerateBrief), m_generateBrief);
s->setValue(QLatin1String(kAddLeadingAsterisks), m_leadingAsterisks);
s->beginGroup(kDocumentationCommentsGroup);
s->setValue(kEnableDoxygenBlocks, m_enableDoxygen);
s->setValue(kGenerateBrief, m_generateBrief);
s->setValue(kAddLeadingAsterisks, m_leadingAsterisks);
s->endGroup();
}
void CommentsSettings::fromSettings(const QString &category, QSettings *s)
void CommentsSettings::fromSettings(QSettings *s)
{
s->beginGroup(category + QLatin1String(kDocumentationCommentsGroup));
m_enableDoxygen = s->value(QLatin1String(kEnableDoxygenBlocks), true).toBool();
m_generateBrief = m_enableDoxygen
&& s->value(QLatin1String(kGenerateBrief), true).toBool();
m_leadingAsterisks = s->value(QLatin1String(kAddLeadingAsterisks), true).toBool();
s->beginGroup(kDocumentationCommentsGroup);
m_enableDoxygen = s->value(kEnableDoxygenBlocks, true).toBool();
m_generateBrief = m_enableDoxygen && s->value(kGenerateBrief, true).toBool();
m_leadingAsterisks = s->value(kAddLeadingAsterisks, true).toBool();
s->endGroup();
}
......
......@@ -25,21 +25,21 @@
#pragma once
#include "cpptools_global.h"
#include "texteditor_global.h"
QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
namespace CppTools {
namespace TextEditor {
class CPPTOOLS_EXPORT CommentsSettings
class TEXTEDITOR_EXPORT CommentsSettings
{
public:
CommentsSettings();
void toSettings(const QString &category, QSettings *s) const;
void fromSettings(const QString &category, QSettings *s);
void toSettings(QSettings *s) const;
void fromSettings(QSettings *s);
bool equals(const CommentsSettings &other) const;
......@@ -54,4 +54,4 @@ inline bool operator==(const CommentsSettings &a, const CommentsSettings &b)
inline bool operator!=(const CommentsSettings &a, const CommentsSettings &b)
{ return !(a == b); }
} // namespace CppTools
} // namespace TextEditor
......@@ -27,7 +27,7 @@
#include <QSettings>
static const char groupPostfix[] = "Completion";
static const char settingsGroup[] = "CppTools/Completion";
static const char caseSensitivityKey[] = "CaseSensitivity";
static const char completionTriggerKey[] = "CompletionTrigger";
static const char automaticProposalTimeoutKey[] = "AutomaticProposalTimeout";
......@@ -41,13 +41,9 @@ static const char autoSplitStringsKey[] = "AutoSplitStrings";
using namespace TextEditor;
void CompletionSettings::toSettings(const QString &category, QSettings *s) const
void CompletionSettings::toSettings(QSettings *s) const
{
QString group(groupPostfix);
if (!category.isEmpty())
group.insert(0, category);
s->beginGroup(group);
s->beginGroup(settingsGroup);
s->setValue(caseSensitivityKey, (int) m_caseSensitivity);
s->setValue(completionTriggerKey, (int) m_completionTrigger);
s->setValue(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs);
......@@ -61,35 +57,32 @@ void CompletionSettings::toSettings(const QString &category, QSettings *s) const
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
s->beginGroup(settingsGroup);
m_caseSensitivity = (CaseSensitivity)
s->value(group + caseSensitivityKey, m_caseSensitivity).toInt();
s->value(caseSensitivityKey, m_caseSensitivity).toInt();
m_completionTrigger = (CompletionTrigger)
s->value(group + completionTriggerKey, m_completionTrigger).toInt();
s->value(completionTriggerKey, m_completionTrigger).toInt();
m_automaticProposalTimeoutInMs =
s->value(group + automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs).toInt();
s->value(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs).toInt();
m_autoInsertBrackets =
s->value(group + autoInsertBracesKey, m_autoInsertBrackets).toBool();
s->value(autoInsertBracesKey, m_autoInsertBrackets).toBool();
m_surroundingAutoBrackets =
s->value(group + surroundingAutoBracketsKey, m_surroundingAutoBrackets).toBool();
s->value(surroundingAutoBracketsKey, m_surroundingAutoBrackets).toBool();
m_autoInsertQuotes =
s->value(group + autoInsertQuotesKey, m_autoInsertQuotes).toBool();
s->value(autoInsertQuotesKey, m_autoInsertQuotes).toBool();
m_surroundingAutoQuotes =
s->value(group + surroundingAutoQuotesKey, m_surroundingAutoQuotes).toBool();
s->value(surroundingAutoQuotesKey, m_surroundingAutoQuotes).toBool();
m_partiallyComplete =
s->value(group + partiallyCompleteKey, m_partiallyComplete).toBool();
s->value(partiallyCompleteKey, m_partiallyComplete).toBool();
m_spaceAfterFunctionName =
s->value(group + spaceAfterFunctionNameKey, m_spaceAfterFunctionName).toBool();
s->value(spaceAfterFunctionNameKey, m_spaceAfterFunctionName).toBool();
m_autoSplitStrings =
s->value(group + autoSplitStringsKey, m_autoSplitStrings).toBool();
s->value(autoSplitStringsKey, m_autoSplitStrings).toBool();
s->endGroup();
}
bool CompletionSettings::equals(const CompletionSettings &cs) const
......
......@@ -51,8 +51,8 @@ enum CompletionTrigger {
class TEXTEDITOR_EXPORT CompletionSettings
{
public:
void toSettings(const QString &category, QSettings *s) const;
void fromSettings(const QString &category, const QSettings *s);
void toSettings(QSettings *s) const;
void fromSettings(QSettings *s);
bool equals(const CompletionSettings &bs) const;
......
......@@ -25,16 +25,17 @@
#include "completionsettingspage.h"
#include "ui_completionsettingspage.h"
#include "texteditorsettings.h"
#include "cpptoolssettings.h"
#include <cpptools/cpptoolssettings.h>
#include <coreplugin/icore.h>
#include <texteditor/texteditorsettings.h>
#include <QTextStream>
using namespace TextEditor;
using namespace TextEditor::Internal;
using namespace CppTools;
using namespace CppTools::Internal;
CompletionSettingsPage::CompletionSettingsPage(QObject *parent)
: TextEditor::TextEditorOptionsPage(parent)
......@@ -42,6 +43,10 @@ CompletionSettingsPage::CompletionSettingsPage(QObject *parent)
{
setId("P.Completion");
setDisplayName(tr("Completion"));
QSettings *s = Core::ICore::settings();
m_completionSettings.fromSettings(s);
m_commentsSettings.fromSettings(s);
}
CompletionSettingsPage::~CompletionSettingsPage()
......@@ -60,11 +65,8 @@ QWidget *CompletionSettingsPage::widget()
static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &CompletionSettingsPage::onCompletionTriggerChanged);
const TextEditor::CompletionSettings &completionSettings =
TextEditor::TextEditorSettings::completionSettings();
int caseSensitivityIndex = 0;
switch (completionSettings.m_caseSensitivity) {
switch (m_completionSettings.m_caseSensitivity) {
case TextEditor::CaseSensitive:
caseSensitivityIndex = 0;
break;
......@@ -77,7 +79,7 @@ QWidget *CompletionSettingsPage::widget()
}
int completionTriggerIndex = 0;
switch (completionSettings.m_completionTrigger) {
switch (m_completionSettings.m_completionTrigger) {
case TextEditor::ManualCompletion:
completionTriggerIndex = 0;
break;
......@@ -92,19 +94,18 @@ QWidget *CompletionSettingsPage::widget()
m_page->caseSensitivity->setCurrentIndex(caseSensitivityIndex);
m_page->completionTrigger->setCurrentIndex(completionTriggerIndex);
m_page->automaticProposalTimeoutSpinBox
->setValue(completionSettings.m_automaticProposalTimeoutInMs);
m_page->insertBrackets->setChecked(completionSettings.m_autoInsertBrackets);
m_page->surroundBrackets->setChecked(completionSettings.m_surroundingAutoBrackets);
m_page->insertQuotes->setChecked(completionSettings.m_autoInsertQuotes);
m_page->surroundQuotes->setChecked(completionSettings.m_surroundingAutoQuotes);
m_page->partiallyComplete->setChecked(completionSettings.m_partiallyComplete);
m_page->spaceAfterFunctionName->setChecked(completionSettings.m_spaceAfterFunctionName);
m_page->autoSplitStrings->setChecked(completionSettings.m_autoSplitStrings);
const CommentsSettings &commentsSettings = CppToolsSettings::instance()->commentsSettings();
m_page->enableDoxygenCheckBox->setChecked(commentsSettings.m_enableDoxygen);
m_page->generateBriefCheckBox->setChecked(commentsSettings.m_generateBrief);
m_page->leadingAsterisksCheckBox->setChecked(commentsSettings.m_leadingAsterisks);
->setValue(m_completionSettings.m_automaticProposalTimeoutInMs);
m_page->insertBrackets->setChecked(m_completionSettings.m_autoInsertBrackets);
m_page->surroundBrackets->setChecked(m_completionSettings.m_surroundingAutoBrackets);
m_page->insertQuotes->setChecked(m_completionSettings.m_autoInsertQuotes);
m_page->surroundQuotes->setChecked(m_completionSettings.m_surroundingAutoQuotes);
m_page->partiallyComplete->setChecked(m_completionSettings.m_partiallyComplete);
m_page->spaceAfterFunctionName->setChecked(m_completionSettings.m_spaceAfterFunctionName);
m_page->autoSplitStrings->setChecked(m_completionSettings.m_autoSplitStrings);
m_page->enableDoxygenCheckBox->setChecked(m_commentsSettings.m_enableDoxygen);
m_page->generateBriefCheckBox->setChecked(m_commentsSettings.m_generateBrief);
m_page->leadingAsterisksCheckBox->setChecked(m_commentsSettings.m_leadingAsterisks);
m_page->generateBriefCheckBox->setEnabled(m_page->enableDoxygenCheckBox->isChecked());
}
......@@ -116,28 +117,22 @@ void CompletionSettingsPage::apply()
if (!m_page) // page was never shown
return;
TextEditor::CompletionSettings completionSettings;
completionSettings.m_caseSensitivity = caseSensitivity();
completionSettings.m_completionTrigger = completionTrigger();
completionSettings.m_automaticProposalTimeoutInMs
= m_page->automaticProposalTimeoutSpinBox->value();
completionSettings.m_autoInsertBrackets = m_page->insertBrackets->isChecked();
completionSettings.m_surroundingAutoBrackets = m_page->surroundBrackets->isChecked();
completionSettings.m_autoInsertQuotes = m_page->insertQuotes->isChecked();
completionSettings.m_surroundingAutoQuotes = m_page->surroundQuotes->isChecked();
completionSettings.m_partiallyComplete = m_page->partiallyComplete->isChecked();
completionSettings.m_spaceAfterFunctionName = m_page->spaceAfterFunctionName->isChecked();
completionSettings.m_autoSplitStrings = m_page->autoSplitStrings->isChecked();
TextEditor::TextEditorSettings::setCompletionSettings(completionSettings);
if (!requireCommentsSettingsUpdate())
return;
CompletionSettings completionSettings;
CommentsSettings commentsSettings;
commentsSettings.m_enableDoxygen = m_page->enableDoxygenCheckBox->isChecked();
commentsSettings.m_generateBrief = m_page->generateBriefCheckBox->isChecked();
commentsSettings.m_leadingAsterisks = m_page->leadingAsterisksCheckBox->isChecked();
CppToolsSettings::instance()->setCommentsSettings(commentsSettings);
settingsFromUi(completionSettings, commentsSettings);
if (m_completionSettings != completionSettings) {
m_completionSettings = completionSettings;
m_completionSettings.toSettings(Core::ICore::settings());
emit completionSettingsChanged(completionSettings);
}
if (m_commentsSettings != commentsSettings) {
m_commentsSettings = commentsSettings;
m_commentsSettings.toSettings(Core::ICore::settings());
emit commentsSettingsChanged(commentsSettings);
}
}
TextEditor::CaseSensitivity CompletionSettingsPage::caseSensitivity() const
......@@ -164,6 +159,28 @@ TextEditor::CompletionTrigger CompletionSettingsPage::completionTrigger() const
}
}
void CompletionSettingsPage::settingsFromUi(CompletionSettings &completion, CommentsSettings &comment) const
{
if (!m_page)
return;
completion.m_caseSensitivity = caseSensitivity();
completion.m_completionTrigger = completionTrigger();
completion.m_automaticProposalTimeoutInMs
= m_page->automaticProposalTimeoutSpinBox->value();
completion.m_autoInsertBrackets = m_page->insertBrackets->isChecked();
completion.m_surroundingAutoBrackets = m_page->surroundBrackets->isChecked();
completion.m_autoInsertQuotes = m_page->insertQuotes->isChecked();
completion.m_surroundingAutoQuotes = m_page->surroundQuotes->isChecked();
completion.m_partiallyComplete = m_page->partiallyComplete->isChecked();
completion.m_spaceAfterFunctionName = m_page->spaceAfterFunctionName->isChecked();
completion.m_autoSplitStrings = m_page->autoSplitStrings->isChecked();
comment.m_enableDoxygen = m_page->enableDoxygenCheckBox->isChecked();
comment.m_generateBrief = m_page->generateBriefCheckBox->isChecked();
comment.m_leadingAsterisks = m_page->leadingAsterisksCheckBox->isChecked();
}
void CompletionSettingsPage::onCompletionTriggerChanged()
{
const bool enableTimeoutWidgets = completionTrigger() == TextEditor::AutomaticCompletion;
......@@ -180,10 +197,12 @@ void CompletionSettingsPage::finish()
m_page = 0;
}
bool CompletionSettingsPage::requireCommentsSettingsUpdate() const
const CompletionSettings &CompletionSettingsPage::completionSettings()
{
return m_completionSettings;
}
const CommentsSettings &CompletionSettingsPage::commentsSettings()
{
const CommentsSettings &commentsSettings = CppToolsSettings::instance()->commentsSettings();
return commentsSettings.m_enableDoxygen != m_page->enableDoxygenCheckBox->isChecked()
|| commentsSettings.m_generateBrief != m_page->generateBriefCheckBox->isChecked()
|| commentsSettings.m_leadingAsterisks != m_page->leadingAsterisksCheckBox->isChecked();
return m_commentsSettings;
}
......@@ -26,20 +26,18 @@
#pragma once
#include "commentssettings.h"
#include "completionsettings.h"
#include "texteditoroptionspage.h"
#include <texteditor/completionsettings.h>
#include <texteditor/texteditoroptionspage.h>
#include <QPointer>
namespace CppTools {
namespace TextEditor {
namespace Internal {
namespace Ui { class CompletionSettingsPage; }
// TODO: Move this class to the text editor plugin
class CompletionSettingsPage : public TextEditor::TextEditorOptionsPage
class CompletionSettingsPage : public TextEditorOptionsPage
{
Q_OBJECT
......@@ -51,18 +49,25 @@ public:
void apply();
void finish();
const CompletionSettings & completionSettings();
const CommentsSettings & commentsSettings();
signals:
void completionSettingsChanged(const CompletionSettings &);
void commentsSettingsChanged(const CommentsSettings &);
private:
TextEditor::CaseSensitivity caseSensitivity() const;
TextEditor::CompletionTrigger completionTrigger() const;
CaseSensitivity caseSensitivity() const;
CompletionTrigger completionTrigger() const;
void settingsFromUi(CompletionSettings &completion, CommentsSettings &comment) const;
void onCompletionTriggerChanged();
bool requireCommentsSettingsUpdate() const;
Ui::CompletionSettingsPage *m_page;
QPointer<QWidget> m_widget;
CommentsSettings m_commentsSettings;
CompletionSettings m_completionSettings;
};
} // namespace Internal
} // namespace CppTools
} // namespace TextEditor
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CppTools::Internal::CompletionSettingsPage</class>
<class>TextEditor::Internal::CompletionSettingsPage</class>
<widget class="QWidget" name="CppTools::Internal::CompletionSettingsPage">
<property name="geometry">
<rect>
......
......@@ -6549,7 +6549,6 @@ void TextEditorWidget::setCompletionSettings(const CompletionSettings &completio
d->m_autoCompleter->setSurroundWithBracketsEnabled(completionSettings.m_surroundingAutoBrackets);
d->m_autoCompleter->setAutoInsertQuotesEnabled(completionSettings.m_autoInsertQuotes);
d->m_autoCompleter->setSurroundWithQuotesEnabled(completionSettings.m_surroundingAutoQuotes);
d->m_codeAssistant.updateFromCompletionSettings(completionSettings);
}
void TextEditorWidget::setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings)
......
......@@ -102,6 +102,8 @@ SOURCES += texteditorplugin.cpp \
circularclipboardassist.cpp \
textmark.cpp \
codeassist/keywordscompletionassist.cpp \
completionsettingspage.cpp \
commentssettings.cpp \
marginsettings.cpp
HEADERS += texteditorplugin.h \
......@@ -217,6 +219,8 @@ HEADERS += texteditorplugin.h \
textmarkregistry.h \
marginsettings.h \
blockrange.h \
completionsettingspage.h \
commentssettings.h \
textstyles.h
FORMS += \
......@@ -229,6 +233,7 @@ FORMS += \
behaviorsettingswidget.ui \
behaviorsettingspage.ui \
tabsettingswidget.ui \
completionsettingspage.ui \
codestyleselectorwidget.ui
RESOURCES += texteditor.qrc
......
......@@ -48,8 +48,13 @@ QtcPlugin {
"colorschemeedit.cpp",
"colorschemeedit.h",
"colorschemeedit.ui",
"commentssettings.cpp",
"commentssettings.h",
"completionsettings.cpp",
"completionsettings.h",
"completionsettingspage.cpp",
"completionsettingspage.h",
"completionsettingspage.ui",
"convenience.cpp",
"convenience.h",
"displaysettings.cpp",
......
......@@ -40,6 +40,7 @@
#include "extraencodingsettings.h"
#include "icodestylepreferences.h"
#include "icodestylepreferencesfactory.h"
#include "completionsettingspage.h"
#include <texteditor/generichighlighter/highlightersettingspage.h>
#include <texteditor/snippets/snippetssettingspage.h>
......@@ -64,14 +65,13 @@ public:
DisplaySettingsPage *m_displaySettingsPage;
HighlighterSettingsPage *m_highlighterSettingsPage;
SnippetsSettingsPage *m_snippetsSettingsPage;