Commit ca15d0aa authored by hjk's avatar hjk
Browse files

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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment