Move completion settings page to TextEditor plugin.

Change-Id: I12b7828d23d599e5903237d0cc2a3c0440e1b07d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
David Schulz
2016-05-19 12:25:16 +02:00
parent 702fd2e62c
commit c422b81316
21 changed files with 166 additions and 158 deletions

View File

@@ -1,71 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "commentssettings.h"
#include <QSettings>
using namespace CppTools;
namespace {
const char kDocumentationCommentsGroup[] = "DocumentationComments";
const char kEnableDoxygenBlocks[] = "EnableDoxygenBlocks";
const char kGenerateBrief[] = "GenerateBrief";
const char kAddLeadingAsterisks[] = "AddLeadingAsterisks";
}
CommentsSettings::CommentsSettings()
: m_enableDoxygen(true)
, m_generateBrief(true)
, m_leadingAsterisks(true)
{}
void CommentsSettings::toSettings(const QString &category, 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->endGroup();
}
void CommentsSettings::fromSettings(const QString &category, 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->endGroup();
}
bool CommentsSettings::equals(const CommentsSettings &other) const
{
return m_enableDoxygen == other.m_enableDoxygen
&& m_generateBrief == other.m_generateBrief
&& m_leadingAsterisks == other.m_leadingAsterisks;
}

View File

@@ -1,57 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "cpptools_global.h"
QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
namespace CppTools {
class CPPTOOLS_EXPORT CommentsSettings
{
public:
CommentsSettings();
void toSettings(const QString &category, QSettings *s) const;
void fromSettings(const QString &category, QSettings *s);
bool equals(const CommentsSettings &other) const;
bool m_enableDoxygen;
bool m_generateBrief;
bool m_leadingAsterisks;
};
inline bool operator==(const CommentsSettings &a, const CommentsSettings &b)
{ return a.equals(b); }
inline bool operator!=(const CommentsSettings &a, const CommentsSettings &b)
{ return !(a == b); }
} // namespace CppTools

View File

@@ -1,189 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "completionsettingspage.h"
#include "ui_completionsettingspage.h"
#include "cpptoolssettings.h"
#include <coreplugin/icore.h>
#include <texteditor/texteditorsettings.h>
#include <QTextStream>
using namespace CppTools;
using namespace CppTools::Internal;
CompletionSettingsPage::CompletionSettingsPage(QObject *parent)
: TextEditor::TextEditorOptionsPage(parent)
, m_page(0)
{
setId("P.Completion");
setDisplayName(tr("Completion"));
}
CompletionSettingsPage::~CompletionSettingsPage()
{
delete m_page;
}
QWidget *CompletionSettingsPage::widget()
{
if (!m_widget) {
m_widget = new QWidget;
m_page = new Ui::CompletionSettingsPage;
m_page->setupUi(m_widget);
connect(m_page->completionTrigger,
static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &CompletionSettingsPage::onCompletionTriggerChanged);
const TextEditor::CompletionSettings &completionSettings =
TextEditor::TextEditorSettings::completionSettings();
int caseSensitivityIndex = 0;
switch (completionSettings.m_caseSensitivity) {
case TextEditor::CaseSensitive:
caseSensitivityIndex = 0;
break;
case TextEditor::CaseInsensitive:
caseSensitivityIndex = 1;
break;
case TextEditor::FirstLetterCaseSensitive:
caseSensitivityIndex = 2;
break;
}
int completionTriggerIndex = 0;
switch (completionSettings.m_completionTrigger) {
case TextEditor::ManualCompletion:
completionTriggerIndex = 0;
break;
case TextEditor::TriggeredCompletion:
completionTriggerIndex = 1;
break;
case TextEditor::AutomaticCompletion:
completionTriggerIndex = 2;
break;
}
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);
m_page->generateBriefCheckBox->setEnabled(m_page->enableDoxygenCheckBox->isChecked());
}
return m_widget;
}
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;
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);
}
TextEditor::CaseSensitivity CompletionSettingsPage::caseSensitivity() const
{
switch (m_page->caseSensitivity->currentIndex()) {
case 0: // Full
return TextEditor::CaseSensitive;
case 1: // None
return TextEditor::CaseInsensitive;
default: // First letter
return TextEditor::FirstLetterCaseSensitive;
}
}
TextEditor::CompletionTrigger CompletionSettingsPage::completionTrigger() const
{
switch (m_page->completionTrigger->currentIndex()) {
case 0:
return TextEditor::ManualCompletion;
case 1:
return TextEditor::TriggeredCompletion;
default:
return TextEditor::AutomaticCompletion;
}
}
void CompletionSettingsPage::onCompletionTriggerChanged()
{
const bool enableTimeoutWidgets = completionTrigger() == TextEditor::AutomaticCompletion;
m_page->automaticProposalTimeoutLabel->setEnabled(enableTimeoutWidgets);
m_page->automaticProposalTimeoutSpinBox->setEnabled(enableTimeoutWidgets);
}
void CompletionSettingsPage::finish()
{
delete m_widget;
if (!m_page) // page was never shown
return;
delete m_page;
m_page = 0;
}
bool CompletionSettingsPage::requireCommentsSettingsUpdate() const
{
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();
}

View File

@@ -1,68 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "commentssettings.h"
#include <texteditor/completionsettings.h>
#include <texteditor/texteditoroptionspage.h>
#include <QPointer>
namespace CppTools {
namespace Internal {
namespace Ui { class CompletionSettingsPage; }
// TODO: Move this class to the text editor plugin
class CompletionSettingsPage : public TextEditor::TextEditorOptionsPage
{
Q_OBJECT
public:
CompletionSettingsPage(QObject *parent);
~CompletionSettingsPage();
QWidget *widget();
void apply();
void finish();
private:
TextEditor::CaseSensitivity caseSensitivity() const;
TextEditor::CompletionTrigger completionTrigger() const;
void onCompletionTriggerChanged();
bool requireCommentsSettingsUpdate() const;
Ui::CompletionSettingsPage *m_page;
QPointer<QWidget> m_widget;
CommentsSettings m_commentsSettings;
};
} // namespace Internal
} // namespace CppTools

View File

@@ -1,328 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CppTools::Internal::CompletionSettingsPage</class>
<widget class="QWidget" name="CppTools::Internal::CompletionSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>511</width>
<height>420</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Behavior</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="completionTriggerLabel">
<property name="text">
<string>Activate completion:</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>70</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="caseSensitivityLabel">
<property name="text">
<string>&amp;Case-sensitivity:</string>
</property>
<property name="buddy">
<cstring>caseSensitivity</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="caseSensitivity">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Full</string>
</property>
</item>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>First Letter</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="completionTrigger">
<item>
<property name="text">
<string>Manually</string>
</property>
</item>
<item>
<property name="text">
<string>When Triggered</string>
</property>
</item>
<item>
<property name="text">
<string>Always</string>
</property>
</item>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="automaticProposalTimeoutLabel">
<property name="text">
<string>Timeout in ms:</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QSpinBox" name="automaticProposalTimeoutSpinBox">
<property name="maximum">
<number>500</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>400</number>
</property>
</widget>
</item>
<item row="1" column="5">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="partiallyComplete">
<property name="toolTip">
<string>Inserts the common prefix of available completion items.</string>
</property>
<property name="text">
<string>Autocomplete common &amp;prefix</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="autoSplitStrings">
<property name="toolTip">
<string>Splits a string into two lines by adding an end quote at the cursor position when you press Enter and a start quote to the next line, before the rest of the string.
In addition, Shift+Enter inserts an escape character at the cursor position and moves the rest of the string to the next line.</string>
</property>
<property name="text">
<string>Automatically split strings</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="autoInsertGroupBox">
<property name="title">
<string>&amp;Automatically insert matching characters</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="insertBrackets">
<property name="text">
<string>Insert opening or closing brackets</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="insertQuotes">
<property name="text">
<string>Insert closing quote</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="surroundBrackets">
<property name="toolTip">
<string>When typing a matching bracket and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters.</string>
</property>
<property name="text">
<string>Surround text selection with brackets</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="spaceAfterFunctionName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Insert &amp;space after function name</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="surroundQuotes">
<property name="toolTip">
<string>When typing a matching quote and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters.</string>
</property>
<property name="text">
<string>Surround text selection with quotes</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="docCommentsGroup">
<property name="title">
<string>Documentation Comments</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="enableDoxygenCheckBox">
<property name="toolTip">
<string>Automatically creates a Doxygen comment upon pressing enter after a '/**', '/*!', '//!' or '///'.</string>
</property>
<property name="text">
<string>Enable Doxygen blocks</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="generateBriefCheckBox">
<property name="toolTip">
<string>Generates a &lt;i&gt;brief&lt;/i&gt; command with an initial description for the corresponding declaration.</string>
</property>
<property name="text">
<string>Generate brief description</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="leadingAsterisksCheckBox">
<property name="toolTip">
<string>Adds leading asterisks when continuing C/C++ &quot;/*&quot;, Qt &quot;/*!&quot; and Java &quot;/**&quot; style comments on new lines.</string>
</property>
<property name="text">
<string>Add leading asterisks</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>caseSensitivity</tabstop>
<tabstop>completionTrigger</tabstop>
<tabstop>automaticProposalTimeoutSpinBox</tabstop>
<tabstop>partiallyComplete</tabstop>
<tabstop>autoSplitStrings</tabstop>
<tabstop>insertBrackets</tabstop>
<tabstop>insertQuotes</tabstop>
<tabstop>surroundBrackets</tabstop>
<tabstop>surroundQuotes</tabstop>
<tabstop>spaceAfterFunctionName</tabstop>
<tabstop>enableDoxygenCheckBox</tabstop>
<tabstop>generateBriefCheckBox</tabstop>
<tabstop>leadingAsterisksCheckBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>enableDoxygenCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>generateBriefCheckBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>174</x>
<y>294</y>
</hint>
<hint type="destinationlabel">
<x>262</x>
<y>321</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -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

View File

@@ -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",

View File

@@ -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()

View File

@@ -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);