Commit ca15d0aa authored by hjk's avatar hjk

Apply static pattern to TextEditorSetting

Change-Id: I4e6f573d893c0aa2bb4ca9812fc8db2961dac172
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent bd10688a
......@@ -52,6 +52,6 @@ AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent)
Core::IEditor *AndroidManifestEditorFactory::createEditor(QWidget *parent)
{
AndroidManifestEditorWidget *editor = new AndroidManifestEditorWidget(parent, m_actionHandler);
TextEditor::TextEditorSettings::instance()->initializeEditor(editor);
TextEditor::TextEditorSettings::initializeEditor(editor);
return editor->editor();
}
......@@ -49,8 +49,7 @@ namespace Internal {
// Retrieve the comment char format from the text editor.
static QTextCharFormat commentFormat()
{
const TextEditor::FontSettings settings = TextEditor::TextEditorSettings::instance()->fontSettings();
return settings.toTextCharFormat(TextEditor::C_COMMENT);
return TextEditor::TextEditorSettings::fontSettings().toTextCharFormat(TextEditor::C_COMMENT);
}
// Highlighter for Bazaar submit messages. Make the first line bold, indicates
......
......@@ -109,9 +109,9 @@ BinEditorWidget::BinEditorWidget(QWidget *parent)
setFrameStyle(QFrame::Plain);
// Font settings
TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
setFontSettings(settings->fontSettings());
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
setFontSettings(TextEditor::TextEditorSettings::fontSettings());
connect(TextEditor::TextEditorSettings::instance(),
SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
this, SLOT(setFontSettings(TextEditor::FontSettings)));
}
......
......@@ -70,7 +70,7 @@ Core::IEditor *CMakeEditor::duplicate(QWidget *parent)
CMakeEditorWidget *w = qobject_cast<CMakeEditorWidget*>(widget());
CMakeEditorWidget *ret = new CMakeEditorWidget(parent, w->factory(), w->actionHandler());
ret->duplicateFrom(w);
TextEditor::TextEditorSettings::instance()->initializeEditor(ret);
TextEditor::TextEditorSettings::initializeEditor(ret);
return ret->editor();
}
......
......@@ -73,6 +73,6 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent)
{
CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this, m_actionHandler);
TextEditor::TextEditorSettings::instance()->initializeEditor(rc);
TextEditor::TextEditorSettings::initializeEditor(rc);
return rc->editor();
}
......@@ -124,7 +124,7 @@ void CppEditorPlugin::initializeEditor(CPPEditorWidget *editor)
m_actionHandler->setupActions(editor);
editor->setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID);
TextEditor::TextEditorSettings::instance()->initializeEditor(editor);
TextEditor::TextEditorSettings::initializeEditor(editor);
// method combo box sorting
connect(this, SIGNAL(outlineSortingChanged(bool)),
......
......@@ -4410,8 +4410,7 @@ public:
m_factory->classFunctionModel->clear();
Overview printer = CppCodeStyleSettings::currentProjectCodeStyleOverview();
printer.showFunctionSignatures = true;
const TextEditor::FontSettings &fs =
TextEditor::TextEditorSettings::instance()->fontSettings();
const TextEditor::FontSettings &fs = TextEditor::TextEditorSettings::fontSettings();
const Format formatReimpFunc = fs.formatFor(C_DISABLED_CODE);
foreach (const Class *clazz, baseClasses) {
QStandardItem *itemBase = new QStandardItem(printer.prettyName(clazz->name()));
......
......@@ -63,7 +63,7 @@ QWidget *CompletionSettingsPage::createPage(QWidget *parent)
m_page->setupUi(w);
const TextEditor::CompletionSettings &settings =
TextEditor::TextEditorSettings::instance()->completionSettings();
TextEditor::TextEditorSettings::completionSettings();
int caseSensitivityIndex = 0;
switch (settings.m_caseSensitivity) {
......@@ -131,7 +131,7 @@ void CompletionSettingsPage::apply()
settings.m_partiallyComplete = m_page->partiallyComplete->isChecked();
settings.m_spaceAfterFunctionName = m_page->spaceAfterFunctionName->isChecked();
TextEditor::TextEditorSettings::instance()->setCompletionSettings(settings);
TextEditor::TextEditorSettings::setCompletionSettings(settings);
if (!requireCommentsSettingsUpdate())
return;
......
......@@ -275,9 +275,8 @@ CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
for (int i = 0; i < m_previews.size(); ++i)
m_previews[i]->setPlainText(QLatin1String(defaultCodeStyleSnippets[i]));
TextEditor::TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
decorateEditors(textEditorSettings->fontSettings());
connect(textEditorSettings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
decorateEditors(TextEditorSettings::fontSettings());
connect(TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
this, SLOT(decorateEditors(TextEditor::FontSettings)));
setVisualizeWhitespace(true);
......@@ -575,8 +574,7 @@ QWidget *CppCodeStyleSettingsPage::createPage(QWidget *parent)
m_pageCppCodeStylePreferences->setCurrentDelegate(originalCodeStylePreferences->currentDelegate());
// we set id so that it won't be possible to set delegate to the original prefs
m_pageCppCodeStylePreferences->setId(originalCodeStylePreferences->id());
TextEditorSettings *settings = TextEditorSettings::instance();
m_widget = new CodeStyleEditor(settings->codeStyleFactory(CppTools::Constants::CPP_SETTINGS_ID),
m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(CppTools::Constants::CPP_SETTINGS_ID),
m_pageCppCodeStylePreferences, parent);
return m_widget;
......
......@@ -210,8 +210,7 @@ void CppAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *e
} else {
toInsert = text();
const CompletionSettings &completionSettings =
TextEditorSettings::instance()->completionSettings();
const CompletionSettings &completionSettings = TextEditorSettings::completionSettings();
const bool autoInsertBrackets = completionSettings.m_autoInsertBrackets;
if (autoInsertBrackets && symbol && symbol->type()) {
......
......@@ -50,7 +50,7 @@ static const char idKey[] = "CppGlobal";
using namespace CppTools;
using namespace CppTools::Internal;
using TextEditor::TabSettings;
using namespace TextEditor;
namespace CppTools {
namespace Internal {
......@@ -89,15 +89,13 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
this,
SIGNAL(commentsSettingsChanged(CppTools::CommentsSettings)));
TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
// code style factory
TextEditor::ICodeStylePreferencesFactory *factory = new CppTools::CppCodeStylePreferencesFactory();
textEditorSettings->registerCodeStyleFactory(factory);
ICodeStylePreferencesFactory *factory = new CppTools::CppCodeStylePreferencesFactory();
TextEditorSettings::registerCodeStyleFactory(factory);
// code style pool
TextEditor::CodeStylePool *pool = new TextEditor::CodeStylePool(factory, this);
textEditorSettings->registerCodeStylePool(Constants::CPP_SETTINGS_ID, pool);
CodeStylePool *pool = new CodeStylePool(factory, this);
TextEditorSettings::registerCodeStylePool(Constants::CPP_SETTINGS_ID, pool);
// global code style settings
d->m_globalCodeStyle = new CppCodeStylePreferences(this);
......@@ -105,7 +103,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
d->m_globalCodeStyle->setDisplayName(tr("Global", "Settings"));
d->m_globalCodeStyle->setId(QLatin1String(idKey));
pool->addCodeStyle(d->m_globalCodeStyle);
textEditorSettings->registerCodeStyle(CppTools::Constants::CPP_SETTINGS_ID, d->m_globalCodeStyle);
TextEditorSettings::registerCodeStyle(CppTools::Constants::CPP_SETTINGS_ID, d->m_globalCodeStyle);
/*
For every language we have exactly 1 pool. The pool contains:
......@@ -203,7 +201,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
QString(), s, &legacyTabSettings);
} else {
// delegating to global
legacyTabSettings = textEditorSettings->codeStyle()->currentTabSettings();
legacyTabSettings = TextEditorSettings::codeStyle()->currentTabSettings();
}
// create custom code style out of old settings
......@@ -224,16 +222,16 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
// mimetypes to be handled
textEditorSettings->registerMimeTypeForLanguageId(
TextEditorSettings::registerMimeTypeForLanguageId(
QLatin1String(Constants::C_SOURCE_MIMETYPE),
Constants::CPP_SETTINGS_ID);
textEditorSettings->registerMimeTypeForLanguageId(
TextEditorSettings::registerMimeTypeForLanguageId(
QLatin1String(Constants::C_HEADER_MIMETYPE),
Constants::CPP_SETTINGS_ID);
textEditorSettings->registerMimeTypeForLanguageId(
TextEditorSettings::registerMimeTypeForLanguageId(
QLatin1String(Constants::CPP_SOURCE_MIMETYPE),
Constants::CPP_SETTINGS_ID);
textEditorSettings->registerMimeTypeForLanguageId(
TextEditorSettings::registerMimeTypeForLanguageId(
QLatin1String(Constants::CPP_HEADER_MIMETYPE),
Constants::CPP_SETTINGS_ID);
}
......@@ -242,10 +240,9 @@ CppToolsSettings::~CppToolsSettings()
{
ExtensionSystem::PluginManager::removeObject(d->m_completionSettingsPage);
TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
textEditorSettings->unregisterCodeStyle(Constants::CPP_SETTINGS_ID);
textEditorSettings->unregisterCodeStylePool(Constants::CPP_SETTINGS_ID);
textEditorSettings->unregisterCodeStyleFactory(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStyle(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStylePool(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStyleFactory(Constants::CPP_SETTINGS_ID);
delete d;
......
......@@ -701,7 +701,7 @@ EditorData FormEditorW::createEditor(QWidget *parent)
#endif
data.widgetHost = new SharedTools::WidgetHost( /* parent */ 0, form);
DesignerXmlEditorWidget *xmlEditor = new DesignerXmlEditorWidget(form, parent);
TextEditor::TextEditorSettings::instance()->initializeEditor(xmlEditor);
TextEditor::TextEditorSettings::initializeEditor(xmlEditor);
data.formWindowEditor = xmlEditor->designerEditor();
connect(data.widgetHost, SIGNAL(formWindowSizeChanged(int,int)),
xmlEditor, SIGNAL(changed()));
......
......@@ -722,30 +722,31 @@ DiffEditorWidget::DiffEditorWidget(QWidget *parent)
m_syncScrollBars(true),
m_foldingBlocker(false)
{
TextEditor::TextEditorSettings *settings = TextEditorSettings::instance();
m_leftEditor = new DiffViewEditorWidget(this);
m_leftEditor->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_leftEditor->setReadOnly(true);
connect(settings, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
connect(TextEditorSettings::instance(),
SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
m_leftEditor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
m_leftEditor->setDisplaySettings(settings->displaySettings());
m_leftEditor->setCodeStyle(settings->codeStyle());
m_leftEditor->setDisplaySettings(TextEditorSettings::displaySettings());
m_leftEditor->setCodeStyle(TextEditorSettings::codeStyle());
connect(m_leftEditor, SIGNAL(jumpToOriginalFileRequested(int,int,int)),
this, SLOT(slotLeftJumpToOriginalFileRequested(int,int,int)));
m_rightEditor = new DiffViewEditorWidget(this);
m_rightEditor->setReadOnly(true);
connect(settings, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
connect(TextEditorSettings::instance(),
SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
m_rightEditor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
m_rightEditor->setDisplaySettings(settings->displaySettings());
m_rightEditor->setCodeStyle(settings->codeStyle());
m_rightEditor->setDisplaySettings(TextEditorSettings::displaySettings());
m_rightEditor->setCodeStyle(TextEditorSettings::codeStyle());
connect(m_rightEditor, SIGNAL(jumpToOriginalFileRequested(int,int,int)),
this, SLOT(slotRightJumpToOriginalFileRequested(int,int,int)));
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
connect(TextEditorSettings::instance(),
SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
this, SLOT(setFontSettings(TextEditor::FontSettings)));
setFontSettings(settings->fontSettings());
setFontSettings(TextEditorSettings::fontSettings());
connect(m_leftEditor->verticalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(leftVSliderChanged()));
......
......@@ -118,14 +118,13 @@ DiffShowEditor::DiffShowEditor(DiffEditorWidget *editorWidget)
splitter->addWidget(editorWidget);
setWidget(splitter);
TextEditorSettings *settings = TextEditorSettings::instance();
connect(settings, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
connect(TextEditorSettings::instance(), SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
m_diffShowWidget, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
connect(TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
m_diffShowWidget, SLOT(setFontSettings(TextEditor::FontSettings)));
m_diffShowWidget->setDisplaySettings(settings->displaySettings());
m_diffShowWidget->setCodeStyle(settings->codeStyle());
m_diffShowWidget->setFontSettings(settings->fontSettings());
m_diffShowWidget->setDisplaySettings(TextEditorSettings::displaySettings());
m_diffShowWidget->setCodeStyle(TextEditorSettings::codeStyle());
m_diffShowWidget->setFontSettings(TextEditorSettings::fontSettings());
}
DiffShowEditor::~DiffShowEditor()
......
......@@ -359,8 +359,8 @@ QWidget *FakeVimOptionPage::createPage(QWidget *parent)
void FakeVimOptionPage::copyTextEditorSettings()
{
TabSettings ts = TextEditorSettings::instance()->codeStyle()->tabSettings();
TypingSettings tps = TextEditorSettings::instance()->typingSettings();
TabSettings ts = TextEditorSettings::codeStyle()->tabSettings();
TypingSettings tps = TextEditorSettings::typingSettings();
m_ui.checkBoxExpandTab->setChecked(ts.m_tabPolicy != TabSettings::TabsOnlyTabPolicy);
m_ui.spinBoxTabStop->setValue(ts.m_tabSize);
m_ui.spinBoxShiftWidth->setValue(ts.m_indentSize);
......
......@@ -64,7 +64,7 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager, TextEditorActionHandl
Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent)
{
ProjectFilesEditorWidget *ed = new ProjectFilesEditorWidget(parent, this, m_actionHandler);
TextEditorSettings::instance()->initializeEditor(ed);
TextEditorSettings::initializeEditor(ed);
return ed->editor();
}
......@@ -96,7 +96,7 @@ Core::IEditor *ProjectFilesEditor::duplicate(QWidget *parent)
ProjectFilesEditorWidget *editor = new ProjectFilesEditorWidget(parent,
parentEditor->factory(),
parentEditor->actionHandler());
TextEditorSettings::instance()->initializeEditor(editor);
TextEditorSettings::initializeEditor(editor);
return editor->editor();
}
......
......@@ -239,7 +239,7 @@ void GLSLEditorPlugin::initializeEditor(GLSLTextEditorWidget *editor)
{
QTC_CHECK(m_instance);
dd->m_actionHandler->setupActions(editor);
TextEditorSettings::instance()->initializeEditor(editor);
TextEditorSettings::initializeEditor(editor);
}
static QByteArray glslFile(const QString &fileName)
......
......@@ -50,8 +50,7 @@ namespace Internal {
// Retrieve the comment char format from the text editor.
static QTextCharFormat commentFormat()
{
const TextEditor::FontSettings settings = TextEditor::TextEditorSettings::instance()->fontSettings();
return settings.toTextCharFormat(TextEditor::C_COMMENT);
return TextEditor::TextEditorSettings::fontSettings().toTextCharFormat(TextEditor::C_COMMENT);
}
// Highlighter for Mercurial submit messages. Make the first line bold, indicates
......
......@@ -301,7 +301,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
this, SLOT(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)));
Utils::OutputFormatter *formatter = rc->outputFormatter();
formatter->setFont(TextEditor::TextEditorSettings::instance()->fontSettings().font());
formatter->setFont(TextEditor::TextEditorSettings::fontSettings().font());
// First look if we can reuse a tab
const int size = m_runControlTabs.size();
......
......@@ -75,7 +75,7 @@ CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : QWidget(),
const EditorConfiguration *config = m_project->editorConfiguration();
QMap<Core::Id, ICodeStylePreferencesFactory *> factories
= TextEditor::TextEditorSettings::instance()->codeStyleFactories();
= TextEditor::TextEditorSettings::codeStyleFactories();
QMapIterator<Core::Id, ICodeStylePreferencesFactory *> it(factories);
while (it.hasNext()) {
it.next();
......
......@@ -82,7 +82,7 @@ public:
private slots:
void fontSettingsChanged()
{
setFont(TextEditor::TextEditorSettings::instance()->fontSettings().font());
setFont(TextEditor::TextEditorSettings::fontSettings().font());
}
protected:
......
......@@ -63,10 +63,10 @@ struct EditorConfigurationPrivate
{
EditorConfigurationPrivate()
: m_useGlobal(true)
, m_typingSettings(TextEditorSettings::instance()->typingSettings())
, m_storageSettings(TextEditorSettings::instance()->storageSettings())
, m_behaviorSettings(TextEditorSettings::instance()->behaviorSettings())
, m_extraEncodingSettings(TextEditorSettings::instance()->extraEncodingSettings())
, m_typingSettings(TextEditorSettings::typingSettings())
, m_storageSettings(TextEditorSettings::storageSettings())
, m_behaviorSettings(TextEditorSettings::behaviorSettings())
, m_extraEncodingSettings(TextEditorSettings::extraEncodingSettings())
, m_textCodec(Core::EditorManager::defaultTextCodec())
{
}
......@@ -84,17 +84,15 @@ struct EditorConfigurationPrivate
EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate)
{
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
const QMap<Core::Id, ICodeStylePreferences *> languageCodeStylePreferences = textEditorSettings->codeStyles();
const QMap<Core::Id, ICodeStylePreferences *> languageCodeStylePreferences = TextEditorSettings::codeStyles();
QMapIterator<Core::Id, ICodeStylePreferences *> itCodeStyle(languageCodeStylePreferences);
while (itCodeStyle.hasNext()) {
itCodeStyle.next();
Core::Id languageId = itCodeStyle.key();
ICodeStylePreferences *originalPreferences = itCodeStyle.value();
ICodeStylePreferencesFactory *factory = textEditorSettings->codeStyleFactory(languageId);
ICodeStylePreferencesFactory *factory = TextEditorSettings::codeStyleFactory(languageId);
ICodeStylePreferences *preferences = factory->createCodeStyle();
preferences->setDelegatingPool(textEditorSettings->codeStylePool(languageId));
preferences->setDelegatingPool(TextEditorSettings::codeStylePool(languageId));
preferences->setId(languageId.toString() + QLatin1String("Project"));
preferences->setDisplayName(tr("Project %1", "Settings, %1 is a language (C++ or QML)").arg(factory->displayName()));
preferences->setCurrentDelegate(originalPreferences);
......@@ -102,11 +100,10 @@ EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate)
}
d->m_defaultCodeStyle = new SimpleCodeStylePreferences(this);
d->m_defaultCodeStyle->setDelegatingPool(textEditorSettings->codeStylePool());
d->m_defaultCodeStyle->setDelegatingPool(TextEditorSettings::codeStylePool());
d->m_defaultCodeStyle->setDisplayName(tr("Project", "Settings"));
d->m_defaultCodeStyle->setId(kId);
d->m_defaultCodeStyle->setCurrentDelegate(d->m_useGlobal
? TextEditorSettings::instance()->codeStyle() : 0);
d->m_defaultCodeStyle->setCurrentDelegate(d->m_useGlobal ? TextEditorSettings::codeStyle() : 0);
}
EditorConfiguration::~EditorConfiguration()
......@@ -122,13 +119,11 @@ bool EditorConfiguration::useGlobalSettings() const
void EditorConfiguration::cloneGlobalSettings()
{
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
d->m_defaultCodeStyle->setTabSettings(textEditorSettings->codeStyle()->tabSettings());
setTypingSettings(textEditorSettings->typingSettings());
setStorageSettings(textEditorSettings->storageSettings());
setBehaviorSettings(textEditorSettings->behaviorSettings());
setExtraEncodingSettings(textEditorSettings->extraEncodingSettings());
d->m_defaultCodeStyle->setTabSettings(TextEditorSettings::codeStyle()->tabSettings());
setTypingSettings(TextEditorSettings::typingSettings());
setStorageSettings(TextEditorSettings::storageSettings());
setBehaviorSettings(TextEditorSettings::behaviorSettings());
setExtraEncodingSettings(TextEditorSettings::extraEncodingSettings());
d->m_textCodec = Core::EditorManager::defaultTextCodec();
}
......@@ -247,7 +242,7 @@ void EditorConfiguration::setUseGlobalSettings(bool use)
{
d->m_useGlobal = use;
d->m_defaultCodeStyle->setCurrentDelegate(d->m_useGlobal
? TextEditorSettings::instance()->codeStyle() : 0);
? TextEditorSettings::codeStyle() : 0);
QList<Core::IEditor *> opened = Core::EditorManager::documentModel()->editorsForDocuments(
Core::EditorManager::documentModel()->openedDocuments());
foreach (Core::IEditor *editor, opened) {
......@@ -259,43 +254,45 @@ void EditorConfiguration::setUseGlobalSettings(bool use)
}
}
void EditorConfiguration::switchSettings(BaseTextEditorWidget *baseTextEditor) const
{
if (d->m_useGlobal)
switchSettings_helper(TextEditorSettings::instance(), this, baseTextEditor);
else
switchSettings_helper(this, TextEditorSettings::instance(), baseTextEditor);
}
template <class NewSenderT, class OldSenderT>
void EditorConfiguration::switchSettings_helper(const NewSenderT *newSender,
const OldSenderT *oldSender,
BaseTextEditorWidget *baseTextEditor) const
static void switchSettings_helper(const QObject *newSender, const QObject *oldSender,
BaseTextEditorWidget *baseTextEditor)
{
baseTextEditor->setTypingSettings(newSender->typingSettings());
baseTextEditor->setStorageSettings(newSender->storageSettings());
baseTextEditor->setBehaviorSettings(newSender->behaviorSettings());
baseTextEditor->setExtraEncodingSettings(newSender->extraEncodingSettings());
disconnect(oldSender, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
QObject::disconnect(oldSender, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
baseTextEditor, SLOT(setTypingSettings(TextEditor::TypingSettings)));
disconnect(oldSender, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
QObject::disconnect(oldSender, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
baseTextEditor, SLOT(setStorageSettings(TextEditor::StorageSettings)));
disconnect(oldSender, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
QObject::disconnect(oldSender, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
baseTextEditor, SLOT(setBehaviorSettings(TextEditor::BehaviorSettings)));
disconnect(oldSender, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
QObject::disconnect(oldSender, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
baseTextEditor, SLOT(setExtraEncodingSettings(TextEditor::ExtraEncodingSettings)));
connect(newSender, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
QObject::connect(newSender, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
baseTextEditor, SLOT(setTypingSettings(TextEditor::TypingSettings)));
connect(newSender, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
QObject::connect(newSender, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
baseTextEditor, SLOT(setStorageSettings(TextEditor::StorageSettings)));
connect(newSender, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
QObject::connect(newSender, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
baseTextEditor, SLOT(setBehaviorSettings(TextEditor::BehaviorSettings)));
connect(newSender, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
QObject::connect(newSender, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
baseTextEditor, SLOT(setExtraEncodingSettings(TextEditor::ExtraEncodingSettings)));
}
void EditorConfiguration::switchSettings(BaseTextEditorWidget *baseTextEditor) const
{
if (d->m_useGlobal) {
baseTextEditor->setTypingSettings(TextEditorSettings::typingSettings());
baseTextEditor->setStorageSettings(TextEditorSettings::storageSettings());
baseTextEditor->setBehaviorSettings(TextEditorSettings::behaviorSettings());
baseTextEditor->setExtraEncodingSettings(TextEditorSettings::extraEncodingSettings());
switchSettings_helper(TextEditorSettings::instance(), this, baseTextEditor);
} else {
baseTextEditor->setTypingSettings(typingSettings());
baseTextEditor->setStorageSettings(storageSettings());
baseTextEditor->setBehaviorSettings(behaviorSettings());
baseTextEditor->setExtraEncodingSettings(extraEncodingSettings());
switchSettings_helper(this, TextEditorSettings::instance(), baseTextEditor);
}
}
void EditorConfiguration::setTypingSettings(const TextEditor::TypingSettings &settings)
{
d->m_typingSettings = settings;
......@@ -331,7 +328,7 @@ TabSettings actualTabSettings(const QString &fileName, const BaseTextEditorWidge
return baseTextEditor->tabSettings();
if (Project *project = SessionManager::projectForFile(fileName))
return project->editorConfiguration()->codeStyle()->tabSettings();
return TextEditorSettings::instance()->codeStyle()->tabSettings();
return TextEditorSettings::codeStyle()->tabSettings();
}
} // ProjectExplorer
......@@ -98,10 +98,6 @@ private slots:
private:
void switchSettings(TextEditor::BaseTextEditorWidget *baseTextEditor) const;
template <class NewSenderT, class OldSenderT>
void switchSettings_helper(const NewSenderT *newSender,
const OldSenderT *oldSender,
TextEditor::BaseTextEditorWidget *baseTextEditor) const;
EditorConfigurationPrivate *d;
};
......
......@@ -71,8 +71,7 @@ EnvironmentItemsWidget::EnvironmentItemsWidget(QWidget *parent) :
QWidget(parent), d(new EnvironmentItemsWidgetPrivate)
{
d->m_editor = new TextEditor::SnippetEditorWidget(this);
TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
d->m_editor->setFontSettings(settings->fontSettings());
d->m_editor->setFontSettings(TextEditor::TextEditorSettings::fontSettings());
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(d->m_editor);
}
......
......@@ -538,7 +538,7 @@ static TextEditor::ICodeStylePreferences *codeStylePreferences(ProjectExplorer::
if (project)
return project->editorConfiguration()->codeStyle(languageId);
return TextEditor::TextEditorSettings::instance()->codeStyle(languageId);
return TextEditor::TextEditorSettings::codeStyle(languageId);
}
void ProjectFileWizardExtension::applyCodeStyle(Core::GeneratedFile *file) const
......@@ -547,7 +547,7 @@ void ProjectFileWizardExtension::applyCodeStyle(Core::GeneratedFile *file) const
return; // nothing to do
Core::MimeType mt = Core::MimeDatabase::findByFile(QFileInfo(file->path()));
Core::Id languageId = TextEditor::TextEditorSettings::instance()->languageId(mt.type());
Core::Id languageId = TextEditor::TextEditorSettings::languageId(mt.type());
if (!languageId.isValid())
return; // don't modify files like *.ui *.pro
......@@ -560,7 +560,7 @@ void ProjectFileWizardExtension::applyCodeStyle(Core::GeneratedFile *file) const
Project *baseProject = SessionManager::projectForNode(project);
TextEditor::ICodeStylePreferencesFactory *factory
= TextEditor::TextEditorSettings::instance()->codeStyleFactory(languageId);
= TextEditor::TextEditorSettings::codeStyleFactory(languageId);
TextEditor::Indenter *indenter = 0;
if (factory)
......@@ -575,7 +575,7 @@ void ProjectFileWizardExtension::applyCodeStyle(Core::GeneratedFile *file) const
cursor.select(QTextCursor::Document);
indenter->indent(&doc, cursor, QChar::Null, codeStylePrefs->currentTabSettings());
delete indenter;
if (TextEditor::TextEditorSettings::instance()->storageSettings().m_cleanWhitespace) {
if (TextEditor::TextEditorSettings::storageSettings().m_cleanWhitespace) {
QTextBlock block = doc.firstBlock();
while (block.isValid()) {
codeStylePrefs->currentTabSettings().removeTrailingWhitespace(cursor, block);
......
......@@ -250,7 +250,7 @@ void PythonEditorPlugin::extensionsInitialized()
void PythonEditorPlugin::initializeEditor(EditorWidget *widget)
{
instance()->m_actionHandler->setupActions(widget);
TextEditor::TextEditorSettings::instance()->initializeEditor(widget);
TextEditor::TextEditorSettings::initializeEditor(widget);
}
QSet<QString> PythonEditorPlugin::keywords()
......
......@@ -364,9 +364,8 @@ void QmlJSAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor
QString content = text();
int cursorOffset = 0;
const CompletionSettings &completionSettings =
TextEditorSettings::instance()->completionSettings();