TextEditorSettings::TextEditorSettings(QObject *parent) : QObject(parent) { QTC_ASSERT(!m_instance, return); m_instance = this; d = new Internal::TextEditorSettingsPrivate; // Note: default background colors are coming from FormatDescription::background() // Add font preference page FormatDescriptions formatDescr; formatDescr.reserve(C_LAST_STYLE_SENTINEL); formatDescr.emplace_back(C_TEXT, tr("Text"), tr("Generic text.\nApplied to " "text, if no other " "rules matching.")); // Special categories const QPalette p = QApplication::palette(); formatDescr.emplace_back(C_LINK, tr("Link"), tr("Links that follow symbol under cursor."), Qt::blue); formatDescr.emplace_back(C_SELECTION, tr("Selection"), tr("Selected text."), p.color(QPalette::HighlightedText)); formatDescr.emplace_back(C_LINE_NUMBER, tr("Line Number"), tr("Line numbers located on the left side of the editor."), FormatDescription::AllControlsExceptUnderline); formatDescr.emplace_back(C_SEARCH_RESULT, tr("Search Result"), tr("Highlighted search results inside the editor."), FormatDescription::ShowBackgroundControl); formatDescr.emplace_back(C_SEARCH_SCOPE, tr("Search Scope"), tr("Section where the pattern is searched in."), FormatDescription::ShowBackgroundControl); formatDescr.emplace_back(C_PARENTHESES, tr("Parentheses"), tr("Displayed when matching parentheses, square brackets " "or curly brackets are found.")); formatDescr.emplace_back(C_PARENTHESES_MISMATCH, tr("Mismatched Parentheses"), tr("Displayed when mismatched parentheses, " "square brackets, or curly brackets are found.")); formatDescr.emplace_back(C_CURRENT_LINE, tr("Current Line"), tr("Line where the cursor is placed in."), FormatDescription::ShowBackgroundControl); FormatDescription currentLineNumber(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, FormatDescription::AllControlsExceptUnderline); currentLineNumber.format().setBold(true); formatDescr.push_back(std::move(currentLineNumber)); formatDescr.emplace_back(C_OCCURRENCES, tr("Occurrences"), tr("Occurrences of the symbol under the cursor.\n" "(Only the background will be applied.)"), FormatDescription::ShowBackgroundControl); formatDescr.emplace_back(C_OCCURRENCES_UNUSED, tr("Unused Occurrence"), tr("Occurrences of unused variables."), Qt::darkYellow, QTextCharFormat::SingleUnderline); formatDescr.emplace_back(C_OCCURRENCES_RENAME, tr("Renaming Occurrence"), tr("Occurrences of a symbol that will be renamed."), FormatDescription::ShowBackgroundControl); // Standard categories formatDescr.emplace_back(C_NUMBER, tr("Number"), tr("Number literal."), Qt::darkBlue); formatDescr.emplace_back(C_STRING, tr("String"), tr("Character and string literals."), Qt::darkGreen); formatDescr.emplace_back(C_PRIMITIVE_TYPE, tr("Primitive Type"), tr("Name of a primitive data type."), Qt::darkYellow); formatDescr.emplace_back(C_TYPE, tr("Type"), tr("Name of a type."), Qt::darkMagenta); formatDescr.emplace_back(C_LOCAL, tr("Local"), tr("Local variables.")); formatDescr.emplace_back(C_FIELD, tr("Field"), tr("Class' data members."), Qt::darkRed); formatDescr.emplace_back(C_ENUMERATION, tr("Enumeration"), tr("Applied to enumeration items."), Qt::darkMagenta); Format functionFormat; formatDescr.emplace_back(C_FUNCTION, tr("Function"), tr("Name of a function."), functionFormat); functionFormat.setItalic(true); formatDescr.emplace_back(C_VIRTUAL_METHOD, tr("Virtual Function"), tr("Name of function declared as virtual."), functionFormat); formatDescr.emplace_back(C_BINDING, tr("QML Binding"), tr("QML item property, that allows a " "binding to another property."), Qt::darkRed); Format qmlLocalNameFormat; qmlLocalNameFormat.setItalic(true); formatDescr.emplace_back(C_QML_LOCAL_ID, tr("QML Local Id"), tr("QML item id within a QML file."), qmlLocalNameFormat); formatDescr.emplace_back(C_QML_ROOT_OBJECT_PROPERTY, tr("QML Root Object Property"), tr("QML property of a parent item."), qmlLocalNameFormat); formatDescr.emplace_back(C_QML_SCOPE_OBJECT_PROPERTY, tr("QML Scope Object Property"), tr("Property of the same QML item."), qmlLocalNameFormat); formatDescr.emplace_back(C_QML_STATE_NAME, tr("QML State Name"), tr("Name of a QML state."), qmlLocalNameFormat); formatDescr.emplace_back(C_QML_TYPE_ID, tr("QML Type Name"), tr("Name of a QML type."), Qt::darkMagenta); Format qmlExternalNameFormat = qmlLocalNameFormat; qmlExternalNameFormat.setForeground(Qt::darkBlue); formatDescr.emplace_back(C_QML_EXTERNAL_ID, tr("QML External Id"), tr("QML id defined in another QML file."), qmlExternalNameFormat); formatDescr.emplace_back(C_QML_EXTERNAL_OBJECT_PROPERTY, tr("QML External Object Property"), tr("QML property defined in another QML file."), qmlExternalNameFormat); Format jsLocalFormat; jsLocalFormat.setForeground(QColor(41, 133, 199)); // very light blue jsLocalFormat.setItalic(true); formatDescr.emplace_back(C_JS_SCOPE_VAR, tr("JavaScript Scope Var"), tr("Variables defined inside the JavaScript file."), jsLocalFormat); Format jsGlobalFormat; jsGlobalFormat.setForeground(QColor(0, 85, 175)); // light blue jsGlobalFormat.setItalic(true); formatDescr.emplace_back(C_JS_IMPORT_VAR, tr("JavaScript Import"), tr("Name of a JavaScript import inside a QML file."), jsGlobalFormat); formatDescr.emplace_back(C_JS_GLOBAL_VAR, tr("JavaScript Global Variable"), tr("Variables defined outside the script."), jsGlobalFormat); formatDescr.emplace_back(C_KEYWORD, tr("Keyword"), tr("Reserved keywords of the programming language except " "keywords denoting primitive types."), Qt::darkYellow); formatDescr.emplace_back(C_OPERATOR, tr("Operator"), tr("Operators (for example operator++ or operator-=).")); formatDescr.emplace_back(C_PREPROCESSOR, tr("Preprocessor"), tr("Preprocessor directives."), Qt::darkBlue); formatDescr.emplace_back(C_LABEL, tr("Label"), tr("Labels for goto statements."), Qt::darkRed); formatDescr.emplace_back(C_COMMENT, tr("Comment"), tr("All style of comments except Doxygen comments."), Qt::darkGreen); formatDescr.emplace_back(C_DOXYGEN_COMMENT, tr("Doxygen Comment"), tr("Doxygen comments."), Qt::darkBlue); formatDescr.emplace_back(C_DOXYGEN_TAG, tr("Doxygen Tag"), tr("Doxygen tags."), Qt::blue); formatDescr.emplace_back(C_VISUAL_WHITESPACE, tr("Visual Whitespace"), tr("Whitespace.\nWill not be applied to whitespace " "in comments and strings."), Qt::lightGray); formatDescr.emplace_back(C_DISABLED_CODE, tr("Disabled Code"), tr("Code disabled by preprocessor directives.")); // Diff categories formatDescr.emplace_back(C_ADDED_LINE, tr("Added Line"), tr("Applied to added lines in differences (in diff editor)."), QColor(0, 170, 0)); formatDescr.emplace_back(C_REMOVED_LINE, tr("Removed Line"), tr("Applied to removed lines in differences (in diff editor)."), Qt::red); formatDescr.emplace_back(C_DIFF_FILE, tr("Diff File"), tr("Compared files (in diff editor)."), Qt::darkBlue); formatDescr.emplace_back(C_DIFF_LOCATION, tr("Diff Location"), tr("Location in the files where the difference is " "(in diff editor)."), Qt::blue); // New diff categories formatDescr.emplace_back(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.emplace_back(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.emplace_back(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.emplace_back(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.emplace_back(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.emplace_back(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))); formatDescr.emplace_back(C_LOG_CHANGE_LINE, tr("Log Change Line"), tr("Applied to lines describing changes in VCS log."), Format(QColor(192, 0, 0), QColor())); formatDescr.emplace_back(C_ERROR, tr("Error"), tr("Underline color of error diagnostics."), QColor(255,0, 0), QTextCharFormat::SingleUnderline, FormatDescription::ShowUnderlineControl); formatDescr.emplace_back(C_ERROR_CONTEXT, tr("Error Context"), tr("Underline color of the contexts of error diagnostics."), QColor(255,0, 0), QTextCharFormat::DotLine, FormatDescription::ShowUnderlineControl); formatDescr.emplace_back(C_WARNING, tr("Warning"), tr("Underline color of warning diagnostics."), QColor(255, 190, 0), QTextCharFormat::SingleUnderline, FormatDescription::ShowUnderlineControl); formatDescr.emplace_back(C_WARNING_CONTEXT, tr("Warning Context"), tr("Underline color of the contexts of warning diagnostics."), QColor(255, 190, 0), QTextCharFormat::DotLine, FormatDescription::ShowUnderlineControl); d->m_fontSettingsPage = new FontSettingsPage(formatDescr, Constants::TEXT_EDITOR_FONT_SETTINGS, this); ExtensionSystem::PluginManager::addObject(d->m_fontSettingsPage); // Add the GUI used to configure the tab, storage and interaction settings BehaviorSettingsPageParameters behaviorSettingsPageParameters; behaviorSettingsPageParameters.id = Constants::TEXT_EDITOR_BEHAVIOR_SETTINGS; behaviorSettingsPageParameters.displayName = tr("Behavior"); behaviorSettingsPageParameters.settingsPrefix = QLatin1String("text"); d->m_behaviorSettingsPage = new BehaviorSettingsPage(behaviorSettingsPageParameters, this); ExtensionSystem::PluginManager::addObject(d->m_behaviorSettingsPage); DisplaySettingsPageParameters displaySettingsPageParameters; displaySettingsPageParameters.id = Constants::TEXT_EDITOR_DISPLAY_SETTINGS; displaySettingsPageParameters.displayName = tr("Display"); displaySettingsPageParameters.settingsPrefix = QLatin1String("text"); d->m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this); ExtensionSystem::PluginManager::addObject(d->m_displaySettingsPage); d->m_highlighterSettingsPage = new HighlighterSettingsPage(Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS, this); ExtensionSystem::PluginManager::addObject(d->m_highlighterSettingsPage); d->m_snippetsSettingsPage = new SnippetsSettingsPage(Constants::TEXT_EDITOR_SNIPPETS_SETTINGS, this); ExtensionSystem::PluginManager::addObject(d->m_snippetsSettingsPage); connect(d->m_fontSettingsPage, &FontSettingsPage::changed, this, &TextEditorSettings::fontSettingsChanged); connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::typingSettingsChanged, this, &TextEditorSettings::typingSettingsChanged); connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::storageSettingsChanged, this, &TextEditorSettings::storageSettingsChanged); connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::behaviorSettingsChanged, this, &TextEditorSettings::behaviorSettingsChanged); connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::extraEncodingSettingsChanged, this, &TextEditorSettings::extraEncodingSettingsChanged); connect(d->m_displaySettingsPage, &DisplaySettingsPage::marginSettingsChanged, this, &TextEditorSettings::marginSettingsChanged); connect(d->m_displaySettingsPage, &DisplaySettingsPage::displaySettingsChanged, this, &TextEditorSettings::displaySettingsChanged); // TODO: Move these settings to TextEditor category d->m_completionSettings.fromSettings(QLatin1String("CppTools/"), Core::ICore::settings()); }
TextEditorSettings::TextEditorSettings(QObject *parent) : QObject(parent) , m_d(new Internal::TextEditorSettingsPrivate) { QTC_ASSERT(!m_instance, return); m_instance = this; // Note: default background colors are coming from FormatDescription::background() // Add font preference page FormatDescriptions formatDescr; formatDescr.append(FormatDescription(C_TEXT, tr("Text"), tr("Generic text.\nApplied to " "text, if no other " "rules matching."))); // Special categories const QPalette p = QApplication::palette(); 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"), tr("Displayed when matching parentheses, square brackets " "or curly brackets are found."))); 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); currentLineNumber.format().setBold(true); formatDescr.append(currentLineNumber); formatDescr.append(FormatDescription(C_OCCURRENCES, tr("Occurrences"), tr("Occurrences of the symbol under the cursor.\n" "(Only the background will be applied.)"))); formatDescr.append(FormatDescription(C_OCCURRENCES_UNUSED, tr("Unused Occurrence"), tr("Occurrences of unused variables."))); formatDescr.append(FormatDescription(C_OCCURRENCES_RENAME, tr("Renaming Occurrence"), tr("Occurrences of a symbol that will be renamed."))); // Standard categories 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)); 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"), tr("Applied to Enumeration Items."), Qt::darkMagenta)); Format functionFormat; formatDescr.append(FormatDescription(C_FUNCTION, tr("Function"), tr("Name of a function."), functionFormat)); functionFormat.setItalic(true); formatDescr.append(FormatDescription(C_VIRTUAL_METHOD, tr("Virtual Method"), tr("Name of method declared as virtual."), functionFormat)); formatDescr.append(FormatDescription(C_BINDING, tr("QML Binding"), tr("QML item property, that allows a " "binding to another property."), Qt::darkRed)); Format qmlLocalNameFormat; qmlLocalNameFormat.setItalic(true); 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, tr("QML root Object Property"), tr("QML property of a parent item."), qmlLocalNameFormat)); formatDescr.append(FormatDescription(C_QML_SCOPE_OBJECT_PROPERTY, tr("QML scope Object Property"), 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)); Format qmlExternalNameFormat = qmlLocalNameFormat; qmlExternalNameFormat.setForeground(Qt::darkBlue); 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)); Format jsLocalFormat; jsLocalFormat.setForeground(QColor(41, 133, 199)); // very light blue jsLocalFormat.setItalic(true); formatDescr.append(FormatDescription(C_JS_SCOPE_VAR, tr("JavaScript Scope Var"), tr("Variables defined inside the JavaScript file."), jsLocalFormat)); Format jsGlobalFormat; jsGlobalFormat.setForeground(QColor(0, 85, 175)); // light blue jsGlobalFormat.setItalic(true); 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"), tr("Reserved keywords of the programming language."), Qt::darkYellow)); formatDescr.append(FormatDescription(C_OPERATOR, tr("Operator"), tr("Operators. (for example operator++ operator-=)"))); formatDescr.append(FormatDescription(C_PREPROCESSOR, tr("Preprocessor"), tr("Preprocessor directives."), Qt::darkBlue)); formatDescr.append(FormatDescription(C_LABEL, tr("Label"), tr("Labels for goto statements."), 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)); formatDescr.append(FormatDescription(C_DOXYGEN_TAG, tr("Doxygen Tag"), tr("Doxygen tags"), Qt::blue)); formatDescr.append(FormatDescription(C_VISUAL_WHITESPACE, tr("Visual Whitespace"), tr("Whitespace\nWill not be applied to whitespace " "in comments and strings."), Qt::lightGray)); formatDescr.append(FormatDescription(C_DISABLED_CODE, tr("Disabled Code"), tr("Code disabled by preprocessor directives."))); // Diff categories formatDescr.append(FormatDescription(C_ADDED_LINE, tr("Added Line"), tr("Applied to added lines in differences " "(in diff editor)."), QColor(0, 170, 0))); formatDescr.append(FormatDescription(C_REMOVED_LINE, tr("Removed Line"), tr("Applied to removed lines " "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)); m_d->m_fontSettingsPage = new FontSettingsPage(formatDescr, QLatin1String(Constants::TEXT_EDITOR_FONT_SETTINGS), this); ExtensionSystem::PluginManager::addObject(m_d->m_fontSettingsPage); // Add the GUI used to configure the tab, storage and interaction settings TextEditor::BehaviorSettingsPageParameters behaviorSettingsPageParameters; behaviorSettingsPageParameters.id = QLatin1String(Constants::TEXT_EDITOR_BEHAVIOR_SETTINGS); behaviorSettingsPageParameters.displayName = tr("Behavior"); behaviorSettingsPageParameters.settingsPrefix = QLatin1String("text"); m_d->m_behaviorSettingsPage = new BehaviorSettingsPage(behaviorSettingsPageParameters, this); ExtensionSystem::PluginManager::addObject(m_d->m_behaviorSettingsPage); TextEditor::DisplaySettingsPageParameters displaySettingsPageParameters; displaySettingsPageParameters.id = QLatin1String(Constants::TEXT_EDITOR_DISPLAY_SETTINGS), displaySettingsPageParameters.displayName = tr("Display"); displaySettingsPageParameters.settingsPrefix = QLatin1String("text"); m_d->m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this); ExtensionSystem::PluginManager::addObject(m_d->m_displaySettingsPage); m_d->m_highlighterSettingsPage = new HighlighterSettingsPage(QLatin1String(Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS), this); ExtensionSystem::PluginManager::addObject(m_d->m_highlighterSettingsPage); m_d->m_snippetsSettingsPage = new SnippetsSettingsPage(QLatin1String(Constants::TEXT_EDITOR_SNIPPETS_SETTINGS), this); ExtensionSystem::PluginManager::addObject(m_d->m_snippetsSettingsPage); connect(m_d->m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)), this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)), this, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)), this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)), this, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings))); connect(m_d->m_displaySettingsPage, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings))); // TODO: Move these settings to TextEditor category m_d->m_completionSettings.fromSettings(QLatin1String("CppTools/"), Core::ICore::settings()); }
TextEditorSettings::TextEditorSettings(QObject *parent) : QObject(parent) , m_d(new Internal::TextEditorSettingsPrivate) { QTC_ASSERT(!m_instance, return); m_instance = this; ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); // Note: default background colors are coming from FormatDescription::background() // Add font preference page FormatDescriptions formatDescriptions; formatDescriptions.append(FormatDescription(QLatin1String(C_TEXT), tr("Text"))); // Special categories const QPalette p = QApplication::palette(); formatDescriptions.append(FormatDescription(QLatin1String(C_LINK), tr("Link"), Qt::blue)); formatDescriptions.append(FormatDescription(QLatin1String(C_SELECTION), tr("Selection"), p.color(QPalette::HighlightedText))); formatDescriptions.append(FormatDescription(QLatin1String(C_LINE_NUMBER), tr("Line Number"))); formatDescriptions.append(FormatDescription(QLatin1String(C_SEARCH_RESULT), tr("Search Result"))); formatDescriptions.append(FormatDescription(QLatin1String(C_SEARCH_SCOPE), tr("Search Scope"))); formatDescriptions.append(FormatDescription(QLatin1String(C_PARENTHESES), tr("Parentheses"))); formatDescriptions.append(FormatDescription(QLatin1String(C_CURRENT_LINE), tr("Current Line"))); FormatDescription currentLineNumber = FormatDescription(QLatin1String(C_CURRENT_LINE_NUMBER), tr("Current Line Number"), Qt::darkGray); currentLineNumber.format().setBold(true); formatDescriptions.append(currentLineNumber); formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES), tr("Occurrences"))); formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES_UNUSED), tr("Unused Occurrence"))); formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES_RENAME), tr("Renaming Occurrence"))); // Standard categories formatDescriptions.append(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_STRING), tr("String"), Qt::darkGreen)); formatDescriptions.append(FormatDescription(QLatin1String(C_TYPE), tr("Type"), Qt::darkMagenta)); formatDescriptions.append(FormatDescription(QLatin1String(C_LOCAL), tr("Local"))); formatDescriptions.append(FormatDescription(QLatin1String(C_FIELD), tr("Field"), Qt::darkRed)); formatDescriptions.append(FormatDescription(QLatin1String(C_STATIC), tr("Static"), Qt::darkMagenta)); FormatDescription virtualMethodFormatDescriptor(QLatin1String(C_VIRTUAL_METHOD), tr("Virtual Method")); virtualMethodFormatDescriptor.format().setItalic(true); formatDescriptions.append(virtualMethodFormatDescriptor); formatDescriptions.append(FormatDescription(QLatin1String(C_KEYWORD), tr("Keyword"), Qt::darkYellow)); formatDescriptions.append(FormatDescription(QLatin1String(C_OPERATOR), tr("Operator"))); formatDescriptions.append(FormatDescription(QLatin1String(C_PREPROCESSOR), tr("Preprocessor"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_LABEL), tr("Label"), Qt::darkRed)); formatDescriptions.append(FormatDescription(QLatin1String(C_COMMENT), tr("Comment"), Qt::darkGreen)); formatDescriptions.append(FormatDescription(QLatin1String(C_DOXYGEN_COMMENT), tr("Doxygen Comment"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_DOXYGEN_TAG), tr("Doxygen Tag"), Qt::blue)); formatDescriptions.append(FormatDescription(QLatin1String(C_VISUAL_WHITESPACE), tr("Visual Whitespace"), Qt::lightGray)); formatDescriptions.append(FormatDescription(QLatin1String(C_DISABLED_CODE), tr("Disabled Code"))); // Diff categories formatDescriptions.append(FormatDescription(QLatin1String(C_ADDED_LINE), tr("Added Line"), QColor(0, 170, 0))); formatDescriptions.append(FormatDescription(QLatin1String(C_REMOVED_LINE), tr("Removed Line"), Qt::red)); formatDescriptions.append(FormatDescription(QLatin1String(C_DIFF_FILE), tr("Diff File"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_DIFF_LOCATION), tr("Diff Location"), Qt::blue)); m_d->m_fontSettingsPage = new FontSettingsPage(formatDescriptions, QLatin1String(Constants::TEXT_EDITOR_FONT_SETTINGS), this); pm->addObject(m_d->m_fontSettingsPage); // Add the GUI used to configure the tab, storage and interaction settings TextEditor::BehaviorSettingsPageParameters behaviorSettingsPageParameters; behaviorSettingsPageParameters.id = QLatin1String(Constants::TEXT_EDITOR_BEHAVIOR_SETTINGS); behaviorSettingsPageParameters.displayName = tr("Behavior"); behaviorSettingsPageParameters.settingsPrefix = QLatin1String("text"); m_d->m_behaviorSettingsPage = new BehaviorSettingsPage(behaviorSettingsPageParameters, this); pm->addObject(m_d->m_behaviorSettingsPage); TextEditor::DisplaySettingsPageParameters displaySettingsPageParameters; displaySettingsPageParameters.id = QLatin1String(Constants::TEXT_EDITOR_DISPLAY_SETTINGS), displaySettingsPageParameters.displayName = tr("Display"); displaySettingsPageParameters.settingsPrefix = QLatin1String("text"); m_d->m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this); pm->addObject(m_d->m_displaySettingsPage); m_d->m_highlighterSettingsPage = new HighlighterSettingsPage(QLatin1String(Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS), this); pm->addObject(m_d->m_highlighterSettingsPage); m_d->m_snippetsSettingsPage = new SnippetsSettingsPage(QLatin1String(Constants::TEXT_EDITOR_SNIPPETS_SETTINGS), this); pm->addObject(m_d->m_snippetsSettingsPage); connect(m_d->m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)), this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(tabSettingsChanged(TextEditor::TabSettings)), this, SIGNAL(tabSettingsChanged(TextEditor::TabSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)), this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings))); connect(m_d->m_behaviorSettingsPage, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)), this, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings))); connect(m_d->m_displaySettingsPage, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings))); // TODO: Move these settings to TextEditor category if (QSettings *s = Core::ICore::instance()->settings()) m_d->m_completionSettings.fromSettings(QLatin1String("CppTools/"), s); }
TextEditorSettings::TextEditorSettings(QObject *parent) : QObject(parent) { QTC_ASSERT(!m_instance, return); m_instance = this; ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); // Note: default background colors are coming from FormatDescription::background() // Add font preference page FormatDescriptions formatDescriptions; formatDescriptions.push_back(FormatDescription(QLatin1String(C_TEXT), tr("Text"))); // Special categories const QPalette p = QApplication::palette(); formatDescriptions.push_back(FormatDescription(QLatin1String(C_LINK), tr("Link"), Qt::blue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_SELECTION), tr("Selection"), p.color(QPalette::HighlightedText))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_LINE_NUMBER), tr("Line Number"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_SEARCH_RESULT), tr("Search Result"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_SEARCH_SCOPE), tr("Search Scope"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_PARENTHESES), tr("Parentheses"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_CURRENT_LINE), tr("Current Line"))); // Standard categories formatDescriptions.push_back(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_STRING), tr("String"), Qt::darkGreen)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_TYPE), tr("Type"), Qt::darkMagenta)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_KEYWORD), tr("Keyword"), Qt::darkYellow)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_OPERATOR), tr("Operator"))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_PREPROCESSOR), tr("Preprocessor"), Qt::darkBlue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_LABEL), tr("Label"), Qt::darkRed)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_COMMENT), tr("Comment"), Qt::darkGreen)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DOXYGEN_COMMENT), tr("Doxygen Comment"), Qt::darkBlue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DOXYGEN_TAG), tr("Doxygen Tag"), Qt::blue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DISABLED_CODE), tr("Disabled Code"), Qt::gray)); // Diff categories formatDescriptions.push_back(FormatDescription(QLatin1String(C_ADDED_LINE), tr("Added Line"), QColor(0, 170, 0))); formatDescriptions.push_back(FormatDescription(QLatin1String(C_REMOVED_LINE), tr("Removed Line"), Qt::red)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DIFF_FILE), tr("Diff File"), Qt::darkBlue)); formatDescriptions.push_back(FormatDescription(QLatin1String(C_DIFF_LOCATION), tr("Diff Location"), Qt::blue)); m_fontSettingsPage = new FontSettingsPage(formatDescriptions, QLatin1String("TextEditor"), tr("Text Editor"), this); pm->addObject(m_fontSettingsPage); // Add the GUI used to configure the tab, storage and interaction settings TextEditor::BehaviorSettingsPageParameters behaviorSettingsPageParameters; behaviorSettingsPageParameters.name = tr("Behavior"); behaviorSettingsPageParameters.category = QLatin1String("TextEditor"); behaviorSettingsPageParameters.trCategory = tr("Text Editor"); behaviorSettingsPageParameters.settingsPrefix = QLatin1String("text"); m_behaviorSettingsPage = new BehaviorSettingsPage(behaviorSettingsPageParameters, this); pm->addObject(m_behaviorSettingsPage); TextEditor::DisplaySettingsPageParameters displaySettingsPageParameters; displaySettingsPageParameters.name = tr("Display"); displaySettingsPageParameters.category = QLatin1String("TextEditor"); displaySettingsPageParameters.trCategory = tr("Text Editor"); displaySettingsPageParameters.settingsPrefix = QLatin1String("text"); m_displaySettingsPage = new DisplaySettingsPage(displaySettingsPageParameters, this); pm->addObject(m_displaySettingsPage); connect(m_fontSettingsPage, SIGNAL(changed(TextEditor::FontSettings)), this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings))); connect(m_behaviorSettingsPage, SIGNAL(tabSettingsChanged(TextEditor::TabSettings)), this, SIGNAL(tabSettingsChanged(TextEditor::TabSettings))); connect(m_behaviorSettingsPage, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)), this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings))); connect(m_displaySettingsPage, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)), this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings))); }