2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "texteditorsettings.h"
|
2009-11-27 16:12:12 +01:00
|
|
|
#include "texteditorconstants.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-17 18:17:51 +01:00
|
|
|
#include "basetexteditor.h"
|
2009-12-08 17:37:40 +01:00
|
|
|
#include "behaviorsettings.h"
|
2009-01-27 15:12:32 +01:00
|
|
|
#include "behaviorsettingspage.h"
|
2010-05-10 18:30:09 +02:00
|
|
|
#include "completionsettings.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "displaysettings.h"
|
2009-01-27 15:12:32 +01:00
|
|
|
#include "displaysettingspage.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "fontsettingspage.h"
|
2011-08-16 10:45:23 +02:00
|
|
|
#include "typingsettings.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "storagesettings.h"
|
|
|
|
|
#include "tabsettings.h"
|
2011-02-01 14:13:54 +01:00
|
|
|
#include "extraencodingsettings.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "texteditorplugin.h"
|
2010-05-26 10:58:44 +02:00
|
|
|
#include "highlightersettingspage.h"
|
2010-10-27 17:38:22 +02:00
|
|
|
#include "snippetssettingspage.h"
|
2011-08-16 10:45:23 +02:00
|
|
|
#include "icodestylepreferences.h"
|
|
|
|
|
#include "icodestylepreferencesfactory.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2010-05-10 18:30:09 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QApplication>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
using namespace TextEditor::Constants;
|
2010-05-10 18:30:09 +02:00
|
|
|
using namespace TextEditor::Internal;
|
|
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class TextEditorSettingsPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FontSettingsPage *m_fontSettingsPage;
|
|
|
|
|
BehaviorSettingsPage *m_behaviorSettingsPage;
|
|
|
|
|
DisplaySettingsPage *m_displaySettingsPage;
|
2010-05-26 10:58:44 +02:00
|
|
|
HighlighterSettingsPage *m_highlighterSettingsPage;
|
2010-10-27 17:38:22 +02:00
|
|
|
SnippetsSettingsPage *m_snippetsSettingsPage;
|
2010-05-10 18:30:09 +02:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
QMap<QString, ICodeStylePreferencesFactory *> m_languageToFactory;
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
QMap<QString, ICodeStylePreferences *> m_languageToCodeStyle;
|
|
|
|
|
QMap<QString, CodeStylePool *> m_languageToCodeStylePool;
|
2011-08-05 09:59:28 +02:00
|
|
|
QMap<QString, QString> m_mimeTypeToLanguage;
|
|
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
CompletionSettings m_completionSettings;
|
|
|
|
|
|
|
|
|
|
void fontZoomRequested(int pointSize);
|
|
|
|
|
void zoomResetRequested();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TextEditorSettingsPrivate::fontZoomRequested(int zoom)
|
|
|
|
|
{
|
|
|
|
|
FontSettings &fs = const_cast<FontSettings&>(m_fontSettingsPage->fontSettings());
|
|
|
|
|
fs.setFontZoom(qMax(10, fs.fontZoom() + zoom));
|
|
|
|
|
m_fontSettingsPage->saveSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TextEditorSettingsPrivate::zoomResetRequested()
|
|
|
|
|
{
|
|
|
|
|
FontSettings &fs = const_cast<FontSettings&>(m_fontSettingsPage->fontSettings());
|
|
|
|
|
fs.setFontZoom(100);
|
|
|
|
|
m_fontSettingsPage->saveSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace TextEditor
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
TextEditorSettings *TextEditorSettings::m_instance = 0;
|
|
|
|
|
|
2009-01-23 19:13:00 +01:00
|
|
|
TextEditorSettings::TextEditorSettings(QObject *parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
: QObject(parent)
|
2010-05-10 18:30:09 +02:00
|
|
|
, m_d(new Internal::TextEditorSettingsPrivate)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-09 15:25:01 +01:00
|
|
|
QTC_ASSERT(!m_instance, return);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_instance = this;
|
|
|
|
|
|
|
|
|
|
// Note: default background colors are coming from FormatDescription::background()
|
|
|
|
|
|
|
|
|
|
// Add font preference page
|
|
|
|
|
FormatDescriptions formatDescriptions;
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_TEXT, tr("Text")));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Special categories
|
|
|
|
|
const QPalette p = QApplication::palette();
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_LINK, tr("Link"), Qt::blue));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_SELECTION, tr("Selection"), p.color(QPalette::HighlightedText)));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_LINE_NUMBER, tr("Line Number")));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_SEARCH_RESULT, tr("Search Result")));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_SEARCH_SCOPE, tr("Search Scope")));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_PARENTHESES, tr("Parentheses")));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_CURRENT_LINE, tr("Current Line")));
|
|
|
|
|
|
|
|
|
|
FormatDescription currentLineNumber = FormatDescription(C_CURRENT_LINE_NUMBER, tr("Current Line Number"), Qt::darkGray);
|
2009-06-12 15:28:51 +02:00
|
|
|
currentLineNumber.format().setBold(true);
|
2009-07-14 08:50:27 +02:00
|
|
|
formatDescriptions.append(currentLineNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_OCCURRENCES, tr("Occurrences")));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_OCCURRENCES_UNUSED, tr("Unused Occurrence")));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_OCCURRENCES_RENAME, tr("Renaming Occurrence")));
|
2009-07-14 10:34:17 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Standard categories
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_NUMBER, tr("Number"), Qt::darkBlue));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_STRING, tr("String"), Qt::darkGreen));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_TYPE, tr("Type"), Qt::darkMagenta));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_LOCAL, tr("Local")));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_FIELD, tr("Field"), Qt::darkRed));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_STATIC, tr("Static"), Qt::darkMagenta));
|
|
|
|
|
|
2012-07-12 12:47:33 +02:00
|
|
|
Format functionFormat;
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_FUNCTION, tr("Function"), functionFormat));
|
|
|
|
|
functionFormat.setItalic(true);
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_VIRTUAL_METHOD, tr("Virtual Method"), functionFormat));
|
2010-08-09 14:34:57 +02:00
|
|
|
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_BINDING, tr("QML Binding"), Qt::darkRed));
|
2011-09-12 14:00:05 +02:00
|
|
|
|
2011-08-16 09:47:54 +02:00
|
|
|
Format qmlLocalNameFormat;
|
|
|
|
|
qmlLocalNameFormat.setItalic(true);
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_QML_LOCAL_ID, tr("QML Local Id"), qmlLocalNameFormat));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_QML_ROOT_OBJECT_PROPERTY, tr("QML Root Object Property"), qmlLocalNameFormat));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_QML_SCOPE_OBJECT_PROPERTY, tr("QML Scope Object Property"), qmlLocalNameFormat));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_QML_STATE_NAME, tr("QML State Name"), qmlLocalNameFormat));
|
2011-08-16 09:47:54 +02:00
|
|
|
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_QML_TYPE_ID, tr("QML Type Name"), Qt::darkMagenta));
|
2011-08-16 09:47:54 +02:00
|
|
|
|
|
|
|
|
Format qmlExternalNameFormat = qmlLocalNameFormat;
|
|
|
|
|
qmlExternalNameFormat.setForeground(Qt::darkBlue);
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_QML_EXTERNAL_ID, tr("QML External Id"), qmlExternalNameFormat));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_QML_EXTERNAL_OBJECT_PROPERTY, tr("QML External Object Property"), qmlExternalNameFormat));
|
2011-08-16 09:47:54 +02:00
|
|
|
|
2011-08-30 12:40:36 +02:00
|
|
|
Format jsLocalFormat;
|
|
|
|
|
jsLocalFormat.setForeground(QColor(41, 133, 199)); // very light blue
|
|
|
|
|
jsLocalFormat.setItalic(true);
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_JS_SCOPE_VAR, tr("JavaScript Scope Var"), jsLocalFormat));
|
2011-08-30 12:40:36 +02:00
|
|
|
|
|
|
|
|
Format jsGlobalFormat;
|
|
|
|
|
jsGlobalFormat.setForeground(QColor(0, 85, 175)); // light blue
|
|
|
|
|
jsGlobalFormat.setItalic(true);
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_JS_IMPORT_VAR, tr("JavaScript Import"), jsGlobalFormat));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_JS_GLOBAL_VAR, tr("JavaScript Global Variable"), jsGlobalFormat));
|
|
|
|
|
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_KEYWORD, tr("Keyword"), Qt::darkYellow));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_OPERATOR, tr("Operator")));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_PREPROCESSOR, tr("Preprocessor"), Qt::darkBlue));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_LABEL, tr("Label"), Qt::darkRed));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_COMMENT, tr("Comment"), Qt::darkGreen));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_DOXYGEN_COMMENT, tr("Doxygen Comment"), Qt::darkBlue));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_DOXYGEN_TAG, tr("Doxygen Tag"), Qt::blue));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_VISUAL_WHITESPACE, tr("Visual Whitespace"), Qt::lightGray));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_DISABLED_CODE, tr("Disabled Code")));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Diff categories
|
2012-04-26 14:17:42 +02:00
|
|
|
formatDescriptions.append(FormatDescription(C_ADDED_LINE, tr("Added Line"), QColor(0, 170, 0)));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_REMOVED_LINE, tr("Removed Line"), Qt::red));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_DIFF_FILE, tr("Diff File"), Qt::darkBlue));
|
|
|
|
|
formatDescriptions.append(FormatDescription(C_DIFF_LOCATION, tr("Diff Location"), Qt::blue));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
m_d->m_fontSettingsPage = new FontSettingsPage(formatDescriptions,
|
2010-05-28 14:37:25 +02:00
|
|
|
QLatin1String(Constants::TEXT_EDITOR_FONT_SETTINGS),
|
2010-05-10 18:30:09 +02:00
|
|
|
this);
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(m_d->m_fontSettingsPage);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-27 15:12:32 +01:00
|
|
|
// Add the GUI used to configure the tab, storage and interaction settings
|
|
|
|
|
TextEditor::BehaviorSettingsPageParameters behaviorSettingsPageParameters;
|
2010-05-28 14:37:25 +02:00
|
|
|
behaviorSettingsPageParameters.id = QLatin1String(Constants::TEXT_EDITOR_BEHAVIOR_SETTINGS);
|
2010-01-07 18:17:24 +01:00
|
|
|
behaviorSettingsPageParameters.displayName = tr("Behavior");
|
2009-01-27 15:12:32 +01:00
|
|
|
behaviorSettingsPageParameters.settingsPrefix = QLatin1String("text");
|
2010-05-10 18:30:09 +02:00
|
|
|
m_d->m_behaviorSettingsPage = new BehaviorSettingsPage(behaviorSettingsPageParameters, this);
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(m_d->m_behaviorSettingsPage);
|
2009-01-27 15:12:32 +01:00
|
|
|
|
|
|
|
|
TextEditor::DisplaySettingsPageParameters displaySettingsPageParameters;
|
2010-05-28 14:37:25 +02:00
|
|
|
displaySettingsPageParameters.id = QLatin1String(Constants::TEXT_EDITOR_DISPLAY_SETTINGS),
|
2010-01-07 18:17:24 +01:00
|
|
|
displaySettingsPageParameters.displayName = tr("Display");
|
2009-01-27 15:12:32 +01:00
|
|
|
displaySettingsPageParameters.settingsPrefix = QLatin1String("text");
|
2010-05-10 18:30:09 +02:00
|
|
|
m_d->m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this);
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(m_d->m_displaySettingsPage);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-26 10:58:44 +02:00
|
|
|
m_d->m_highlighterSettingsPage =
|
2010-05-28 14:37:25 +02:00
|
|
|
new HighlighterSettingsPage(QLatin1String(Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS), this);
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(m_d->m_highlighterSettingsPage);
|
2010-05-26 10:58:44 +02:00
|
|
|
|
2010-10-27 17:38:22 +02:00
|
|
|
m_d->m_snippetsSettingsPage =
|
|
|
|
|
new SnippetsSettingsPage(QLatin1String(Constants::TEXT_EDITOR_SNIPPETS_SETTINGS), this);
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(m_d->m_snippetsSettingsPage);
|
2010-10-27 17:38:22 +02:00
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
connect(m_d->m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)));
|
2011-08-16 10:45:23 +02:00
|
|
|
connect(m_d->m_behaviorSettingsPage, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
|
|
|
|
|
this, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)));
|
2010-05-10 18:30:09 +02:00
|
|
|
connect(m_d->m_behaviorSettingsPage, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)));
|
2010-05-10 18:30:09 +02:00
|
|
|
connect(m_d->m_behaviorSettingsPage, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
|
2009-12-08 17:37:40 +01:00
|
|
|
this, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)));
|
2010-05-10 18:30:09 +02:00
|
|
|
connect(m_d->m_displaySettingsPage, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)));
|
2010-05-10 18:30:09 +02:00
|
|
|
|
|
|
|
|
// TODO: Move these settings to TextEditor category
|
2012-01-24 15:36:40 +01:00
|
|
|
if (QSettings *s = Core::ICore::settings())
|
2010-05-10 18:30:09 +02:00
|
|
|
m_d->m_completionSettings.fromSettings(QLatin1String("CppTools/"), s);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextEditorSettings::~TextEditorSettings()
|
|
|
|
|
{
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::removeObject(m_d->m_fontSettingsPage);
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(m_d->m_behaviorSettingsPage);
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(m_d->m_displaySettingsPage);
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(m_d->m_highlighterSettingsPage);
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(m_d->m_snippetsSettingsPage);
|
2010-05-10 18:30:09 +02:00
|
|
|
|
|
|
|
|
delete m_d;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextEditorSettings *TextEditorSettings::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-17 18:17:51 +01:00
|
|
|
/**
|
|
|
|
|
* Initializes editor settings. Also connects signals to keep them up to date
|
|
|
|
|
* when they are changed.
|
|
|
|
|
*/
|
2011-02-21 16:02:26 +01:00
|
|
|
void TextEditorSettings::initializeEditor(BaseTextEditorWidget *editor)
|
2009-03-17 18:17:51 +01:00
|
|
|
{
|
|
|
|
|
// Connect to settings change signals
|
|
|
|
|
connect(this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
|
2009-09-23 18:06:59 +02:00
|
|
|
editor, SLOT(setFontSettingsIfVisible(TextEditor::FontSettings)));
|
2011-08-16 10:45:23 +02:00
|
|
|
connect(this, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
|
|
|
|
|
editor, SLOT(setTypingSettings(TextEditor::TypingSettings)));
|
2009-03-17 18:17:51 +01:00
|
|
|
connect(this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
|
|
|
|
|
editor, SLOT(setStorageSettings(TextEditor::StorageSettings)));
|
2009-12-08 17:37:40 +01:00
|
|
|
connect(this, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
|
|
|
|
|
editor, SLOT(setBehaviorSettings(TextEditor::BehaviorSettings)));
|
2009-03-17 18:17:51 +01:00
|
|
|
connect(this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
|
|
|
|
|
editor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
|
2010-05-11 11:33:31 +02:00
|
|
|
connect(this, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)),
|
|
|
|
|
editor, SLOT(setCompletionSettings(TextEditor::CompletionSettings)));
|
2011-02-01 14:13:54 +01:00
|
|
|
connect(this, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
|
|
|
|
|
editor, SLOT(setExtraEncodingSettings(TextEditor::ExtraEncodingSettings)));
|
2009-03-17 18:17:51 +01:00
|
|
|
|
2009-11-30 19:00:36 +01:00
|
|
|
connect(editor, SIGNAL(requestFontZoom(int)),
|
|
|
|
|
this, SLOT(fontZoomRequested(int)));
|
|
|
|
|
connect(editor, SIGNAL(requestZoomReset()),
|
|
|
|
|
this, SLOT(zoomResetRequested()));
|
2009-06-17 19:12:19 +02:00
|
|
|
|
2009-03-17 18:17:51 +01:00
|
|
|
// Apply current settings (tab settings depend on font settings)
|
|
|
|
|
editor->setFontSettings(fontSettings());
|
2011-08-16 10:45:23 +02:00
|
|
|
editor->setTabSettings(codeStyle()->tabSettings());
|
|
|
|
|
editor->setTypingSettings(typingSettings());
|
2009-03-17 18:17:51 +01:00
|
|
|
editor->setStorageSettings(storageSettings());
|
2009-12-08 17:37:40 +01:00
|
|
|
editor->setBehaviorSettings(behaviorSettings());
|
2009-03-17 18:17:51 +01:00
|
|
|
editor->setDisplaySettings(displaySettings());
|
2010-05-11 11:33:31 +02:00
|
|
|
editor->setCompletionSettings(completionSettings());
|
2011-02-01 14:13:54 +01:00
|
|
|
editor->setExtraEncodingSettings(extraEncodingSettings());
|
2011-08-16 10:45:23 +02:00
|
|
|
editor->setCodeStyle(codeStyle(editor->languageSettingsId()));
|
2009-03-17 18:17:51 +01:00
|
|
|
}
|
|
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
const FontSettings &TextEditorSettings::fontSettings() const
|
2009-06-17 19:12:19 +02:00
|
|
|
{
|
2010-05-10 18:30:09 +02:00
|
|
|
return m_d->m_fontSettingsPage->fontSettings();
|
2009-11-30 19:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
const TypingSettings &TextEditorSettings::typingSettings() const
|
|
|
|
|
{
|
|
|
|
|
return m_d->m_behaviorSettingsPage->typingSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
const StorageSettings &TextEditorSettings::storageSettings() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-05-10 18:30:09 +02:00
|
|
|
return m_d->m_behaviorSettingsPage->storageSettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
const BehaviorSettings &TextEditorSettings::behaviorSettings() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-05-10 18:30:09 +02:00
|
|
|
return m_d->m_behaviorSettingsPage->behaviorSettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
const DisplaySettings &TextEditorSettings::displaySettings() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-05-10 18:30:09 +02:00
|
|
|
return m_d->m_displaySettingsPage->displaySettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
const CompletionSettings &TextEditorSettings::completionSettings() const
|
2009-12-08 17:37:40 +01:00
|
|
|
{
|
2010-05-10 18:30:09 +02:00
|
|
|
return m_d->m_completionSettings;
|
2009-12-08 17:37:40 +01:00
|
|
|
}
|
|
|
|
|
|
2010-05-26 10:58:44 +02:00
|
|
|
const HighlighterSettings &TextEditorSettings::highlighterSettings() const
|
|
|
|
|
{
|
|
|
|
|
return m_d->m_highlighterSettingsPage->highlighterSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
const ExtraEncodingSettings &TextEditorSettings::extraEncodingSettings() const
|
|
|
|
|
{
|
|
|
|
|
return m_d->m_behaviorSettingsPage->extraEncodingSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
void TextEditorSettings::setCompletionSettings(const TextEditor::CompletionSettings &settings)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-05-10 18:30:09 +02:00
|
|
|
if (m_d->m_completionSettings == settings)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_d->m_completionSettings = settings;
|
2012-01-24 15:36:40 +01:00
|
|
|
if (QSettings *s = Core::ICore::settings())
|
2010-05-10 18:30:09 +02:00
|
|
|
m_d->m_completionSettings.toSettings(QLatin1String("CppTools/"), s);
|
|
|
|
|
|
|
|
|
|
emit completionSettingsChanged(m_d->m_completionSettings);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-05-10 18:30:09 +02:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
void TextEditorSettings::registerCodeStyleFactory(ICodeStylePreferencesFactory *factory)
|
|
|
|
|
{
|
|
|
|
|
m_d->m_languageToFactory.insert(factory->languageId(), factory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMap<QString, ICodeStylePreferencesFactory *> TextEditorSettings::codeStyleFactories() const
|
|
|
|
|
{
|
|
|
|
|
return m_d->m_languageToFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ICodeStylePreferencesFactory *TextEditorSettings::codeStyleFactory(const QString &languageId) const
|
|
|
|
|
{
|
|
|
|
|
return m_d->m_languageToFactory.value(languageId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ICodeStylePreferences *TextEditorSettings::codeStyle() const
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
return m_d->m_behaviorSettingsPage->codeStyle();
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
ICodeStylePreferences *TextEditorSettings::codeStyle(const QString &languageId) const
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-11-07 13:02:13 +01:00
|
|
|
return m_d->m_languageToCodeStyle.value(languageId, codeStyle());
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
QMap<QString, ICodeStylePreferences *> TextEditorSettings::codeStyles() const
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
return m_d->m_languageToCodeStyle;
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
void TextEditorSettings::registerCodeStyle(const QString &languageId, ICodeStylePreferences *prefs)
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
m_d->m_languageToCodeStyle.insert(languageId, prefs);
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
CodeStylePool *TextEditorSettings::codeStylePool() const
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
return m_d->m_behaviorSettingsPage->codeStylePool();
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
CodeStylePool *TextEditorSettings::codeStylePool(const QString &languageId) const
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
return m_d->m_languageToCodeStylePool.value(languageId);
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
void TextEditorSettings::registerCodeStylePool(const QString &languageId, CodeStylePool *pool)
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
m_d->m_languageToCodeStylePool.insert(languageId, pool);
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-05 09:59:28 +02:00
|
|
|
void TextEditorSettings::registerMimeTypeForLanguageId(const QString &mimeType, const QString &languageId)
|
|
|
|
|
{
|
|
|
|
|
m_d->m_mimeTypeToLanguage.insert(mimeType, languageId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString TextEditorSettings::languageId(const QString &mimeType) const
|
|
|
|
|
{
|
|
|
|
|
return m_d->m_mimeTypeToLanguage.value(mimeType);
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
#include "moc_texteditorsettings.cpp"
|