2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "texteditorsettings.h"
|
|
|
|
|
|
2015-02-26 13:22:35 +01:00
|
|
|
#include "fontsettings.h"
|
2014-09-26 09:14:03 +02:00
|
|
|
#include "texteditor.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"
|
2014-01-09 14:44:25 +01:00
|
|
|
#include "marginsettings.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"
|
2011-08-16 10:45:23 +02:00
|
|
|
#include "icodestylepreferences.h"
|
|
|
|
|
#include "icodestylepreferencesfactory.h"
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <texteditor/generichighlighter/highlightersettingspage.h>
|
|
|
|
|
#include <texteditor/snippets/snippetssettingspage.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>
|
2015-08-18 15:44:07 +03:00
|
|
|
#include <utils/fadingindicator.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
|
|
|
|
2012-11-21 21:47:17 +02:00
|
|
|
QMap<Core::Id, ICodeStylePreferencesFactory *> m_languageToFactory;
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2012-11-21 21:47:17 +02:00
|
|
|
QMap<Core::Id, ICodeStylePreferences *> m_languageToCodeStyle;
|
|
|
|
|
QMap<Core::Id, CodeStylePool *> m_languageToCodeStylePool;
|
|
|
|
|
QMap<QString, Core::Id> m_mimeTypeToLanguage;
|
2011-08-05 09:59:28 +02:00
|
|
|
|
2010-05-10 18:30:09 +02:00
|
|
|
CompletionSettings m_completionSettings;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace TextEditor
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
static TextEditorSettingsPrivate *d = 0;
|
|
|
|
|
static TextEditorSettings *m_instance = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-23 19:13:00 +01:00
|
|
|
TextEditorSettings::TextEditorSettings(QObject *parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
: QObject(parent)
|
|
|
|
|
{
|
2008-12-09 15:25:01 +01:00
|
|
|
QTC_ASSERT(!m_instance, return);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_instance = this;
|
2013-09-19 17:59:27 +02:00
|
|
|
d = new Internal::TextEditorSettingsPrivate;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Note: default background colors are coming from FormatDescription::background()
|
|
|
|
|
|
|
|
|
|
// Add font preference page
|
2012-08-27 10:55:13 +02:00
|
|
|
FormatDescriptions formatDescr;
|
2012-09-05 14:33:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_TEXT, tr("Text"), tr("Generic text.\nApplied to "
|
2012-08-27 10:55:13 +02:00
|
|
|
"text, if no other "
|
|
|
|
|
"rules matching.")));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Special categories
|
|
|
|
|
const QPalette p = QApplication::palette();
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_LINK, tr("Link"),
|
|
|
|
|
tr("Links that follow symbol under cursor."), Qt::blue));
|
|
|
|
|
formatDescr.append(FormatDescription(C_SELECTION, tr("Selection"), tr("Selected text."),
|
|
|
|
|
p.color(QPalette::HighlightedText)));
|
|
|
|
|
formatDescr.append(FormatDescription(C_LINE_NUMBER, tr("Line Number"),
|
|
|
|
|
tr("Line numbers located on the "
|
|
|
|
|
"left side of the editor.")));
|
|
|
|
|
formatDescr.append(FormatDescription(C_SEARCH_RESULT, tr("Search Result"),
|
|
|
|
|
tr("Highlighted search results inside the editor.")));
|
|
|
|
|
formatDescr.append(FormatDescription(C_SEARCH_SCOPE, tr("Search Scope"),
|
|
|
|
|
tr("Section where the pattern is searched in.")));
|
|
|
|
|
formatDescr.append(FormatDescription(C_PARENTHESES, tr("Parentheses"),
|
2012-09-05 14:33:13 +02:00
|
|
|
tr("Displayed when matching parentheses, square brackets "
|
2012-08-27 10:55:13 +02:00
|
|
|
"or curly brackets are found.")));
|
2015-04-28 11:04:07 +02:00
|
|
|
formatDescr.append(FormatDescription(C_PARENTHESES_MISMATCH, tr("Mismatched Parentheses"),
|
|
|
|
|
tr("Displayed when mismatched parentheses, "
|
|
|
|
|
"square brackets, or curly brackets are found.")));
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_CURRENT_LINE, tr("Current Line"),
|
|
|
|
|
tr("Line where the cursor is placed in.")));
|
|
|
|
|
|
|
|
|
|
FormatDescription currentLineNumber =
|
|
|
|
|
FormatDescription(C_CURRENT_LINE_NUMBER, tr("Current Line Number"),
|
|
|
|
|
tr("Line number located on the left side of the "
|
|
|
|
|
"editor where the cursor is placed in."), Qt::darkGray);
|
2009-06-12 15:28:51 +02:00
|
|
|
currentLineNumber.format().setBold(true);
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(currentLineNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-08-27 10:55:13 +02:00
|
|
|
|
|
|
|
|
formatDescr.append(FormatDescription(C_OCCURRENCES, tr("Occurrences"),
|
2012-09-05 14:33:13 +02:00
|
|
|
tr("Occurrences of the symbol under the cursor.\n"
|
|
|
|
|
"(Only the background will be applied.)")));
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_OCCURRENCES_UNUSED, tr("Unused Occurrence"),
|
2012-09-05 14:33:13 +02:00
|
|
|
tr("Occurrences of unused variables.")));
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_OCCURRENCES_RENAME, tr("Renaming Occurrence"),
|
2012-09-05 14:33:13 +02:00
|
|
|
tr("Occurrences of a symbol that will be renamed.")));
|
2009-07-14 10:34:17 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Standard categories
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_NUMBER, tr("Number"), tr("Number literal."),
|
|
|
|
|
Qt::darkBlue));
|
|
|
|
|
formatDescr.append(FormatDescription(C_STRING, tr("String"),
|
|
|
|
|
tr("Character and string literals."), Qt::darkGreen));
|
2014-06-21 14:31:06 +04:00
|
|
|
formatDescr.append(FormatDescription(C_PRIMITIVE_TYPE, tr("Primitive Type"),
|
2014-07-16 10:57:36 +02:00
|
|
|
tr("Name of a primitive data type."), Qt::darkYellow));
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_TYPE, tr("Type"), tr("Name of a type."),
|
|
|
|
|
Qt::darkMagenta));
|
|
|
|
|
formatDescr.append(FormatDescription(C_LOCAL, tr("Local"), tr("Local variables.")));
|
|
|
|
|
formatDescr.append(FormatDescription(C_FIELD, tr("Field"),
|
|
|
|
|
tr("Class' data members."), Qt::darkRed));
|
|
|
|
|
formatDescr.append(FormatDescription(C_ENUMERATION, tr("Enumeration"),
|
2013-02-08 10:39:45 +01:00
|
|
|
tr("Applied to enumeration items."), Qt::darkMagenta));
|
2012-04-26 14:17:42 +02:00
|
|
|
|
2012-07-12 12:47:33 +02:00
|
|
|
Format functionFormat;
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_FUNCTION, tr("Function"), tr("Name of a function."),
|
|
|
|
|
functionFormat));
|
2012-07-12 12:47:33 +02:00
|
|
|
functionFormat.setItalic(true);
|
2013-10-07 13:34:40 +02:00
|
|
|
formatDescr.append(FormatDescription(C_VIRTUAL_METHOD, tr("Virtual Function"),
|
|
|
|
|
tr("Name of function declared as virtual."),
|
2012-08-27 10:55:13 +02:00
|
|
|
functionFormat));
|
2010-08-09 14:34:57 +02:00
|
|
|
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_BINDING, tr("QML Binding"),
|
|
|
|
|
tr("QML item property, that allows a "
|
|
|
|
|
"binding to another property."),
|
|
|
|
|
Qt::darkRed));
|
2011-09-12 14:00:05 +02:00
|
|
|
|
2011-08-16 09:47:54 +02:00
|
|
|
Format qmlLocalNameFormat;
|
|
|
|
|
qmlLocalNameFormat.setItalic(true);
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_QML_LOCAL_ID, tr("QML Local Id"),
|
|
|
|
|
tr("QML item id within a QML file."), qmlLocalNameFormat));
|
|
|
|
|
formatDescr.append(FormatDescription(C_QML_ROOT_OBJECT_PROPERTY,
|
2013-02-08 10:39:45 +01:00
|
|
|
tr("QML Root Object Property"),
|
2012-08-27 10:55:13 +02:00
|
|
|
tr("QML property of a parent item."), qmlLocalNameFormat));
|
|
|
|
|
formatDescr.append(FormatDescription(C_QML_SCOPE_OBJECT_PROPERTY,
|
2013-02-08 10:39:45 +01:00
|
|
|
tr("QML Scope Object Property"),
|
2012-08-27 10:55:13 +02:00
|
|
|
tr("Property of the same QML item."), qmlLocalNameFormat));
|
|
|
|
|
formatDescr.append(FormatDescription(C_QML_STATE_NAME, tr("QML State Name"),
|
|
|
|
|
tr("Name of a QML state."), qmlLocalNameFormat));
|
|
|
|
|
|
|
|
|
|
formatDescr.append(FormatDescription(C_QML_TYPE_ID, tr("QML Type Name"),
|
|
|
|
|
tr("Name of a QML type."), Qt::darkMagenta));
|
2011-08-16 09:47:54 +02:00
|
|
|
|
|
|
|
|
Format qmlExternalNameFormat = qmlLocalNameFormat;
|
|
|
|
|
qmlExternalNameFormat.setForeground(Qt::darkBlue);
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_QML_EXTERNAL_ID, tr("QML External Id"),
|
|
|
|
|
tr("QML id defined in another QML file."),
|
|
|
|
|
qmlExternalNameFormat));
|
|
|
|
|
formatDescr.append(FormatDescription(C_QML_EXTERNAL_OBJECT_PROPERTY,
|
|
|
|
|
tr("QML External Object Property"),
|
|
|
|
|
tr("QML property defined in another QML file."),
|
|
|
|
|
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-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_JS_SCOPE_VAR, tr("JavaScript Scope Var"),
|
|
|
|
|
tr("Variables defined inside the JavaScript file."),
|
|
|
|
|
jsLocalFormat));
|
2011-08-30 12:40:36 +02:00
|
|
|
|
|
|
|
|
Format jsGlobalFormat;
|
|
|
|
|
jsGlobalFormat.setForeground(QColor(0, 85, 175)); // light blue
|
|
|
|
|
jsGlobalFormat.setItalic(true);
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_JS_IMPORT_VAR, tr("JavaScript Import"),
|
|
|
|
|
tr("Name of a JavaScript import inside a QML file."),
|
|
|
|
|
jsGlobalFormat));
|
|
|
|
|
formatDescr.append(FormatDescription(C_JS_GLOBAL_VAR, tr("JavaScript Global Variable"),
|
|
|
|
|
tr("Variables defined outside the script."),
|
|
|
|
|
jsGlobalFormat));
|
|
|
|
|
|
|
|
|
|
formatDescr.append(FormatDescription(C_KEYWORD, tr("Keyword"),
|
2014-06-21 14:31:06 +04:00
|
|
|
tr("Reserved keywords of the programming language except "
|
|
|
|
|
"keywords denoting primitive types."), Qt::darkYellow));
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_OPERATOR, tr("Operator"),
|
2014-03-13 09:55:53 +01:00
|
|
|
tr("Operators (for example operator++ or operator-=).")));
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_PREPROCESSOR, tr("Preprocessor"),
|
|
|
|
|
tr("Preprocessor directives."), Qt::darkBlue));
|
2012-09-07 15:04:26 +02:00
|
|
|
formatDescr.append(FormatDescription(C_LABEL, tr("Label"), tr("Labels for goto statements."),
|
2012-08-27 10:55:13 +02:00
|
|
|
Qt::darkRed));
|
|
|
|
|
formatDescr.append(FormatDescription(C_COMMENT, tr("Comment"),
|
|
|
|
|
tr("All style of comments except Doxygen comments."),
|
|
|
|
|
Qt::darkGreen));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DOXYGEN_COMMENT, tr("Doxygen Comment"),
|
|
|
|
|
tr("Doxygen comments."), Qt::darkBlue));
|
2013-02-08 10:39:45 +01:00
|
|
|
formatDescr.append(FormatDescription(C_DOXYGEN_TAG, tr("Doxygen Tag"), tr("Doxygen tags."),
|
2012-08-27 10:55:13 +02:00
|
|
|
Qt::blue));
|
|
|
|
|
formatDescr.append(FormatDescription(C_VISUAL_WHITESPACE, tr("Visual Whitespace"),
|
2014-03-13 09:55:53 +01:00
|
|
|
tr("Whitespace.\nWill not be applied to whitespace "
|
2012-08-27 10:55:13 +02:00
|
|
|
"in comments and strings."), Qt::lightGray));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DISABLED_CODE, tr("Disabled Code"),
|
|
|
|
|
tr("Code disabled by preprocessor directives.")));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Diff categories
|
2012-08-27 10:55:13 +02:00
|
|
|
formatDescr.append(FormatDescription(C_ADDED_LINE, tr("Added Line"),
|
2012-09-05 14:33:13 +02:00
|
|
|
tr("Applied to added lines in differences "
|
2012-08-27 10:55:13 +02:00
|
|
|
"(in diff editor)."), QColor(0, 170, 0)));
|
|
|
|
|
formatDescr.append(FormatDescription(C_REMOVED_LINE, tr("Removed Line"),
|
2012-09-05 14:33:13 +02:00
|
|
|
tr("Applied to removed lines "
|
2012-08-27 10:55:13 +02:00
|
|
|
"in differences (in diff editor)."), Qt::red));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DIFF_FILE, tr("Diff File"),
|
|
|
|
|
tr("Compared files (in diff editor)."), Qt::darkBlue));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DIFF_LOCATION, tr("Diff Location"),
|
|
|
|
|
tr("Location in the files where the difference is "
|
|
|
|
|
"(in diff editor)."), Qt::blue));
|
|
|
|
|
|
2013-06-05 15:25:42 +02:00
|
|
|
// New diff categories
|
|
|
|
|
formatDescr.append(FormatDescription(C_DIFF_FILE_LINE, tr("Diff File Line"),
|
|
|
|
|
tr("Applied to lines with file information "
|
|
|
|
|
"in differences (in side-by-side diff editor)."),
|
|
|
|
|
Format(QColor(), QColor(255, 255, 0))));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DIFF_CONTEXT_LINE, tr("Diff Context Line"),
|
|
|
|
|
tr("Applied to lines describing hidden context "
|
|
|
|
|
"in differences (in side-by-side diff editor)."),
|
|
|
|
|
Format(QColor(), QColor(175, 215, 231))));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DIFF_SOURCE_LINE, tr("Diff Source Line"),
|
|
|
|
|
tr("Applied to source lines with changes "
|
|
|
|
|
"in differences (in side-by-side diff editor)."),
|
|
|
|
|
Format(QColor(), QColor(255, 223, 223))));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DIFF_SOURCE_CHAR, tr("Diff Source Character"),
|
|
|
|
|
tr("Applied to removed characters "
|
|
|
|
|
"in differences (in side-by-side diff editor)."),
|
|
|
|
|
Format(QColor(), QColor(255, 175, 175))));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DIFF_DEST_LINE, tr("Diff Destination Line"),
|
|
|
|
|
tr("Applied to destination lines with changes "
|
|
|
|
|
"in differences (in side-by-side diff editor)."),
|
|
|
|
|
Format(QColor(), QColor(223, 255, 223))));
|
|
|
|
|
formatDescr.append(FormatDescription(C_DIFF_DEST_CHAR, tr("Diff Destination Character"),
|
|
|
|
|
tr("Applied to added characters "
|
|
|
|
|
"in differences (in side-by-side diff editor)."),
|
|
|
|
|
Format(QColor(), QColor(175, 255, 175))));
|
|
|
|
|
|
2015-03-25 10:30:24 +02:00
|
|
|
formatDescr.append(FormatDescription(C_LOG_CHANGE_LINE, tr("Log Change Line"),
|
2015-07-03 10:22:55 +02:00
|
|
|
tr("Applied to lines describing changes in VCS log."),
|
2015-03-25 10:30:24 +02:00
|
|
|
Format(QColor(192, 0, 0), QColor())));
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_fontSettingsPage = new FontSettingsPage(formatDescr,
|
2013-01-16 15:22:58 +01:00
|
|
|
Constants::TEXT_EDITOR_FONT_SETTINGS,
|
2010-05-10 18:30:09 +02:00
|
|
|
this);
|
2013-09-19 17:59:27 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(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
|
2015-02-03 23:46:35 +02:00
|
|
|
BehaviorSettingsPageParameters behaviorSettingsPageParameters;
|
2013-01-16 15:22:58 +01:00
|
|
|
behaviorSettingsPageParameters.id = 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");
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_behaviorSettingsPage = new BehaviorSettingsPage(behaviorSettingsPageParameters, this);
|
|
|
|
|
ExtensionSystem::PluginManager::addObject(d->m_behaviorSettingsPage);
|
2009-01-27 15:12:32 +01:00
|
|
|
|
2015-02-03 23:46:35 +02:00
|
|
|
DisplaySettingsPageParameters displaySettingsPageParameters;
|
2013-01-16 15:22:58 +01:00
|
|
|
displaySettingsPageParameters.id = 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");
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this);
|
|
|
|
|
ExtensionSystem::PluginManager::addObject(d->m_displaySettingsPage);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_highlighterSettingsPage =
|
2013-01-16 15:22:58 +01:00
|
|
|
new HighlighterSettingsPage(Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS, this);
|
2013-09-19 17:59:27 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(d->m_highlighterSettingsPage);
|
2010-05-26 10:58:44 +02:00
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_snippetsSettingsPage =
|
2013-01-16 15:22:58 +01:00
|
|
|
new SnippetsSettingsPage(Constants::TEXT_EDITOR_SNIPPETS_SETTINGS, this);
|
2013-09-19 17:59:27 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(d->m_snippetsSettingsPage);
|
2010-10-27 17:38:22 +02:00
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
connect(d->m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)));
|
2013-09-19 17:59:27 +02:00
|
|
|
connect(d->m_behaviorSettingsPage, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
|
2011-08-16 10:45:23 +02:00
|
|
|
this, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)));
|
2013-09-19 17:59:27 +02:00
|
|
|
connect(d->m_behaviorSettingsPage, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)));
|
2013-09-19 17:59:27 +02:00
|
|
|
connect(d->m_behaviorSettingsPage, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
|
2009-12-08 17:37:40 +01:00
|
|
|
this, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)));
|
2014-11-19 08:43:54 +01:00
|
|
|
connect(d->m_behaviorSettingsPage, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
|
|
|
|
|
this, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)));
|
2014-01-09 14:44:25 +01:00
|
|
|
connect(d->m_displaySettingsPage, SIGNAL(marginSettingsChanged(TextEditor::MarginSettings)),
|
|
|
|
|
this, SIGNAL(marginSettingsChanged(TextEditor::MarginSettings)));
|
2013-09-19 17:59:27 +02:00
|
|
|
connect(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
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_completionSettings.fromSettings(QLatin1String("CppTools/"), Core::ICore::settings());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextEditorSettings::~TextEditorSettings()
|
|
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
ExtensionSystem::PluginManager::removeObject(d->m_fontSettingsPage);
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(d->m_behaviorSettingsPage);
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(d->m_displaySettingsPage);
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(d->m_highlighterSettingsPage);
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(d->m_snippetsSettingsPage);
|
2010-05-10 18:30:09 +02:00
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
delete d;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextEditorSettings *TextEditorSettings::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
const FontSettings &TextEditorSettings::fontSettings()
|
2009-06-17 19:12:19 +02:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_fontSettingsPage->fontSettings();
|
2009-11-30 19:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
const TypingSettings &TextEditorSettings::typingSettings()
|
2011-08-16 10:45:23 +02:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_behaviorSettingsPage->typingSettings();
|
2011-08-16 10:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
const StorageSettings &TextEditorSettings::storageSettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_behaviorSettingsPage->storageSettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
const BehaviorSettings &TextEditorSettings::behaviorSettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_behaviorSettingsPage->behaviorSettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-09 14:44:25 +01:00
|
|
|
const MarginSettings &TextEditorSettings::marginSettings()
|
|
|
|
|
{
|
|
|
|
|
return d->m_displaySettingsPage->marginSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
const DisplaySettings &TextEditorSettings::displaySettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_displaySettingsPage->displaySettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
const CompletionSettings &TextEditorSettings::completionSettings()
|
2009-12-08 17:37:40 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_completionSettings;
|
2009-12-08 17:37:40 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
const HighlighterSettings &TextEditorSettings::highlighterSettings()
|
2010-05-26 10:58:44 +02:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_highlighterSettingsPage->highlighterSettings();
|
2010-05-26 10:58:44 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
const ExtraEncodingSettings &TextEditorSettings::extraEncodingSettings()
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_behaviorSettingsPage->extraEncodingSettings();
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:46:35 +02:00
|
|
|
void TextEditorSettings::setCompletionSettings(const CompletionSettings &settings)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
if (d->m_completionSettings == settings)
|
2010-05-10 18:30:09 +02:00
|
|
|
return;
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_completionSettings = settings;
|
|
|
|
|
d->m_completionSettings.toSettings(QLatin1String("CppTools/"), Core::ICore::settings());
|
2010-05-10 18:30:09 +02:00
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
emit m_instance->completionSettingsChanged(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)
|
|
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_languageToFactory.insert(factory->languageId(), factory);
|
2011-08-16 10:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-11 13:21:57 +01:00
|
|
|
void TextEditorSettings::unregisterCodeStyleFactory(Core::Id languageId)
|
|
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_languageToFactory.remove(languageId);
|
2013-03-11 13:21:57 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
QMap<Core::Id, ICodeStylePreferencesFactory *> TextEditorSettings::codeStyleFactories()
|
2011-08-16 10:45:23 +02:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_languageToFactory;
|
2011-08-16 10:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
ICodeStylePreferencesFactory *TextEditorSettings::codeStyleFactory(Core::Id languageId)
|
2011-08-16 10:45:23 +02:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_languageToFactory.value(languageId);
|
2011-08-16 10:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
ICodeStylePreferences *TextEditorSettings::codeStyle()
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_behaviorSettingsPage->codeStyle();
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
ICodeStylePreferences *TextEditorSettings::codeStyle(Core::Id languageId)
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_languageToCodeStyle.value(languageId, codeStyle());
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
QMap<Core::Id, ICodeStylePreferences *> TextEditorSettings::codeStyles()
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_languageToCodeStyle;
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2012-11-21 21:47:17 +02:00
|
|
|
void TextEditorSettings::registerCodeStyle(Core::Id languageId, ICodeStylePreferences *prefs)
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_languageToCodeStyle.insert(languageId, prefs);
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-11 13:21:57 +01:00
|
|
|
void TextEditorSettings::unregisterCodeStyle(Core::Id languageId)
|
|
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_languageToCodeStyle.remove(languageId);
|
2013-03-11 13:21:57 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
CodeStylePool *TextEditorSettings::codeStylePool()
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_behaviorSettingsPage->codeStylePool();
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
CodeStylePool *TextEditorSettings::codeStylePool(Core::Id languageId)
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
return d->m_languageToCodeStylePool.value(languageId);
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2012-11-21 21:47:17 +02:00
|
|
|
void TextEditorSettings::registerCodeStylePool(Core::Id languageId, CodeStylePool *pool)
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_languageToCodeStylePool.insert(languageId, pool);
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-11 13:21:57 +01:00
|
|
|
void TextEditorSettings::unregisterCodeStylePool(Core::Id languageId)
|
|
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_languageToCodeStylePool.remove(languageId);
|
2013-03-11 13:21:57 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 18:43:48 +02:00
|
|
|
void TextEditorSettings::registerMimeTypeForLanguageId(const char *mimeType, Core::Id languageId)
|
2011-08-05 09:59:28 +02:00
|
|
|
{
|
2013-09-19 18:43:48 +02:00
|
|
|
d->m_mimeTypeToLanguage.insert(QString::fromLatin1(mimeType), languageId);
|
2013-09-19 17:59:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Id TextEditorSettings::languageId(const QString &mimeType)
|
|
|
|
|
{
|
|
|
|
|
return d->m_mimeTypeToLanguage.value(mimeType);
|
2011-08-05 09:59:28 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
void TextEditorSettings::fontZoomRequested(int zoom)
|
2011-08-05 09:59:28 +02:00
|
|
|
{
|
2013-09-19 17:59:27 +02:00
|
|
|
FontSettings &fs = const_cast<FontSettings&>(d->m_fontSettingsPage->fontSettings());
|
2015-08-18 15:44:07 +03:00
|
|
|
const int previousZoom = fs.fontZoom();
|
|
|
|
|
const int newZoom = qMax(10, previousZoom + zoom);
|
|
|
|
|
if (newZoom == previousZoom)
|
|
|
|
|
return;
|
|
|
|
|
fs.setFontZoom(newZoom);
|
|
|
|
|
if (QWidget *editor = qobject_cast<QWidget *>(sender())) {
|
|
|
|
|
Utils::FadingIndicator::showText(editor,
|
|
|
|
|
tr("Zoom: %1%").arg(newZoom),
|
|
|
|
|
Utils::FadingIndicator::SmallText);
|
|
|
|
|
}
|
2013-09-19 17:59:27 +02:00
|
|
|
d->m_fontSettingsPage->saveSettings();
|
2011-08-05 09:59:28 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-19 17:59:27 +02:00
|
|
|
void TextEditorSettings::zoomResetRequested()
|
|
|
|
|
{
|
|
|
|
|
FontSettings &fs = const_cast<FontSettings&>(d->m_fontSettingsPage->fontSettings());
|
|
|
|
|
fs.setFontZoom(100);
|
|
|
|
|
d->m_fontSettingsPage->saveSettings();
|
|
|
|
|
}
|