TextEditor: Add fine control over the color scheme settings

You have seen always all setting but some settings had no meaning
because
only the foreground color is used. Now you can disable this settings so
it
is more clear what you can change.

Change-Id: I0fdd2ac6f40e27b5160a2c54a512289457674dae
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-09-21 13:12:36 +02:00
committed by David Schulz
parent b8ae9fd46d
commit 51ed0da5a9
6 changed files with 312 additions and 192 deletions

View File

@@ -83,7 +83,7 @@ public:
int rowCount(const QModelIndex &parent) const int rowCount(const QModelIndex &parent) const
{ {
return (parent.isValid() || !m_descriptions) ? 0 : m_descriptions->size(); return (parent.isValid() || !m_descriptions) ? 0 : int(m_descriptions->size());
} }
QVariant data(const QModelIndex &index, int role) const QVariant data(const QModelIndex &index, int role) const
@@ -132,7 +132,7 @@ public:
// If the text category changes, all indexes might have changed // If the text category changes, all indexes might have changed
if (i.row() == 0) if (i.row() == 0)
emit dataChanged(i, index(m_descriptions->size() - 1)); emit dataChanged(i, index(int(m_descriptions->size()) - 1));
else else
emit dataChanged(i, i); emit dataChanged(i, i);
} }
@@ -244,28 +244,83 @@ void ColorSchemeEdit::currentItemChanged(const QModelIndex &index)
void ColorSchemeEdit::updateControls() void ColorSchemeEdit::updateControls()
{ {
const Format &format = m_scheme.formatFor(m_descriptions[m_curItem].id()); updateForegroundControls();
m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(format.foreground())); updateBackgroundControls();
m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(format.background())); updateFontControls();
updateUnderlineControls();
}
m_ui->eraseBackgroundToolButton->setEnabled(!m_readOnly void ColorSchemeEdit::updateForegroundControls()
&& m_curItem > 0 {
&& format.background().isValid()); const auto &formatDescription = m_descriptions[m_curItem];
const Format &format = m_scheme.formatFor(formatDescription.id());
bool isVisble = formatDescription.showControl(FormatDescription::ShowForegroundControl);
m_ui->foregroundLabel->setVisible(isVisble);
m_ui->foregroundToolButton->setVisible(isVisble);
m_ui->eraseForegroundToolButton->setVisible(isVisble);
m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(format.foreground()));
m_ui->eraseForegroundToolButton->setEnabled(!m_readOnly m_ui->eraseForegroundToolButton->setEnabled(!m_readOnly
&& m_curItem > 0 && m_curItem > 0
&& format.foreground().isValid()); && format.foreground().isValid());
}
void ColorSchemeEdit::updateBackgroundControls()
{
const auto formatDescription = m_descriptions[m_curItem];
const Format &format = m_scheme.formatFor(formatDescription.id());
bool isVisble = formatDescription.showControl(FormatDescription::ShowBackgroundControl);
m_ui->backgroundLabel->setVisible(isVisble);
m_ui->backgroundToolButton->setVisible(isVisble);
m_ui->eraseBackgroundToolButton->setVisible(isVisble);
m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(format.background()));
m_ui->eraseBackgroundToolButton->setEnabled(!m_readOnly
&& m_curItem > 0
&& format.background().isValid());
}
void ColorSchemeEdit::updateFontControls()
{
const auto formatDescription = m_descriptions[m_curItem];
const Format &format = m_scheme.formatFor(formatDescription.id());
QSignalBlocker boldSignalBlocker(m_ui->boldCheckBox); QSignalBlocker boldSignalBlocker(m_ui->boldCheckBox);
m_ui->boldCheckBox->setChecked(format.bold());
QSignalBlocker italicSignalBlocker(m_ui->italicCheckBox); QSignalBlocker italicSignalBlocker(m_ui->italicCheckBox);
bool isVisble= formatDescription.showControl(FormatDescription::ShowFontControls);
m_ui->boldCheckBox->setVisible(isVisble);
m_ui->italicCheckBox->setVisible(isVisble);
m_ui->boldCheckBox->setChecked(format.bold());
m_ui->italicCheckBox->setChecked(format.italic()); m_ui->italicCheckBox->setChecked(format.italic());
}
void ColorSchemeEdit::updateUnderlineControls()
{
const auto formatDescription = m_descriptions[m_curItem];
const Format &format = m_scheme.formatFor(formatDescription.id());
QSignalBlocker comboBoxSignalBlocker(m_ui->underlineComboBox);
bool isVisble= formatDescription.showControl(FormatDescription::ShowFontControls);
m_ui->underlineLabel->setVisible(isVisble);
m_ui->underlineColorToolButton->setVisible(isVisble);
m_ui->eraseUnderlineColorToolButton->setVisible(isVisble);
m_ui->underlineComboBox->setVisible(isVisble);
m_ui->underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(format.underlineColor())); m_ui->underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(format.underlineColor()));
m_ui->eraseUnderlineColorToolButton->setEnabled(!m_readOnly m_ui->eraseUnderlineColorToolButton->setEnabled(!m_readOnly
&& m_curItem > 0 && m_curItem > 0
&& format.underlineColor().isValid()); && format.underlineColor().isValid());
int index = m_ui->underlineComboBox->findData(QVariant::fromValue(int(format.underlineStyle()))); int index = m_ui->underlineComboBox->findData(QVariant::fromValue(int(format.underlineStyle())));
QSignalBlocker comboBoxSignalBlocker(m_ui->underlineComboBox);
m_ui->underlineComboBox->setCurrentIndex(index); m_ui->underlineComboBox->setCurrentIndex(index);
} }

View File

@@ -78,6 +78,10 @@ private slots:
private: private:
void updateControls(); void updateControls();
void updateForegroundControls();
void updateBackgroundControls();
void updateFontControls();
void updateUnderlineControls();
void setItemListBackground(const QColor &color); void setItemListBackground(const QColor &color);
void populateUnderlineStyleComboBox(); void populateUnderlineStyleComboBox();

View File

@@ -56,7 +56,7 @@ class FormatDescription;
class TEXTEDITOR_EXPORT FontSettings class TEXTEDITOR_EXPORT FontSettings
{ {
public: public:
typedef QList<FormatDescription> FormatDescriptions; typedef std::vector<FormatDescription> FormatDescriptions;
FontSettings(); FontSettings();
void clear(); void clear();

View File

@@ -227,19 +227,29 @@ FontSettingsPagePrivate::~FontSettingsPagePrivate()
// ------- FormatDescription // ------- FormatDescription
FormatDescription::FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const QColor &foreground) : FormatDescription::FormatDescription(TextStyle id,
m_id(id), const QString &displayName,
m_displayName(displayName), const QString &tooltipText,
m_tooltipText(tooltipText) const QColor &foreground,
FormatDescription::ShowControls showControls)
: m_id(id),
m_displayName(displayName),
m_tooltipText(tooltipText),
m_showControls(showControls)
{ {
m_format.setForeground(foreground); m_format.setForeground(foreground);
} }
FormatDescription::FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const Format &format) : FormatDescription::FormatDescription(TextStyle id,
m_id(id), const QString &displayName,
m_format(format), const QString &tooltipText,
m_displayName(displayName), const Format &format,
m_tooltipText(tooltipText) FormatDescription::ShowControls showControls)
: m_id(id),
m_format(format),
m_displayName(displayName),
m_tooltipText(tooltipText),
m_showControls(showControls)
{ {
} }
@@ -247,10 +257,12 @@ FormatDescription::FormatDescription(TextStyle id,
const QString &displayName, const QString &displayName,
const QString &tooltipText, const QString &tooltipText,
const QColor &underlineColor, const QColor &underlineColor,
const QTextCharFormat::UnderlineStyle underlineStyle) const QTextCharFormat::UnderlineStyle underlineStyle,
FormatDescription::ShowControls showControls)
: m_id(id), : m_id(id),
m_displayName(displayName), m_displayName(displayName),
m_tooltipText(tooltipText) m_tooltipText(tooltipText),
m_showControls(showControls)
{ {
m_format.setForeground(QColor()); m_format.setForeground(QColor());
m_format.setBackground(QColor()); m_format.setBackground(QColor());
@@ -258,6 +270,17 @@ FormatDescription::FormatDescription(TextStyle id,
m_format.setUnderlineStyle(underlineStyle); m_format.setUnderlineStyle(underlineStyle);
} }
FormatDescription::FormatDescription(TextStyle id,
const QString &displayName,
const QString &tooltipText,
FormatDescription::ShowControls showControls)
: m_id(id),
m_displayName(displayName),
m_tooltipText(tooltipText),
m_showControls(showControls)
{
}
QColor FormatDescription::foreground() const QColor FormatDescription::foreground() const
{ {
if (m_id == C_LINE_NUMBER) { if (m_id == C_LINE_NUMBER) {
@@ -331,6 +354,11 @@ QColor FormatDescription::background() const
return QColor(); // invalid color return QColor(); // invalid color
} }
bool FormatDescription::showControl(FormatDescription::ShowControls showControl) const
{
return m_showControls & showControl;
}
// ------------ FontSettingsPage // ------------ FontSettingsPage
FontSettingsPage::FontSettingsPage(const FormatDescriptions &fd, FontSettingsPage::FontSettingsPage(const FormatDescriptions &fd,
Core::Id id, Core::Id id,

View File

@@ -57,19 +57,37 @@ namespace Internal { class FontSettingsPagePrivate; }
class TEXTEDITOR_EXPORT FormatDescription class TEXTEDITOR_EXPORT FormatDescription
{ {
public: public:
enum ShowControls {
ShowForegroundControl = 0x1,
ShowBackgroundControl = 0x2,
ShowFontControls = 0x4,
ShowUnderlineControl = 0x8,
AllControls = 0xF,
AllControlsExceptUnderline = AllControls & ~ShowUnderlineControl,
};
FormatDescription() = default;
FormatDescription(TextStyle id, FormatDescription(TextStyle id,
const QString &displayName, const QString &displayName,
const QString &tooltipText, const QString &tooltipText,
const QColor &foreground = Qt::black); ShowControls showControls = AllControls);
FormatDescription(TextStyle id, FormatDescription(TextStyle id,
const QString &displayName, const QString &displayName,
const QString &tooltipText, const QString &tooltipText,
const Format &format); const QColor &foreground,
ShowControls showControls = AllControls);
FormatDescription(TextStyle id,
const QString &displayName,
const QString &tooltipText,
const Format &format,
ShowControls showControls = AllControls);
FormatDescription(TextStyle id, FormatDescription(TextStyle id,
const QString &displayName, const QString &displayName,
const QString &tooltipText, const QString &tooltipText,
const QColor &underlineColor, const QColor &underlineColor,
const QTextCharFormat::UnderlineStyle underlineStyle); const QTextCharFormat::UnderlineStyle underlineStyle,
ShowControls showControls = AllControls);
TextStyle id() const { return m_id; } TextStyle id() const { return m_id; }
@@ -85,14 +103,17 @@ public:
QString tooltipText() const QString tooltipText() const
{ return m_tooltipText; } { return m_tooltipText; }
bool showControl(ShowControls showControl) const;
private: private:
TextStyle m_id; // Name of the category TextStyle m_id; // Name of the category
Format m_format; // Default format Format m_format; // Default format
QString m_displayName; // Displayed name of the category QString m_displayName; // Displayed name of the category
QString m_tooltipText; // Description text for category QString m_tooltipText; // Description text for category
ShowControls m_showControls = AllControls;
}; };
typedef QList<FormatDescription> FormatDescriptions; typedef std::vector<FormatDescription> FormatDescriptions;
class TEXTEDITOR_EXPORT FontSettingsPage : public TextEditorOptionsPage class TEXTEDITOR_EXPORT FontSettingsPage : public TextEditorOptionsPage
{ {

View File

@@ -98,207 +98,219 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
// Add font preference page // Add font preference page
FormatDescriptions formatDescr; FormatDescriptions formatDescr;
formatDescr.append(FormatDescription(C_TEXT, tr("Text"), tr("Generic text.\nApplied to " formatDescr.reserve(C_LAST_STYLE_SENTINEL);
"text, if no other " formatDescr.emplace_back(C_TEXT, tr("Text"), tr("Generic text.\nApplied to "
"rules matching."))); "text, if no other "
"rules matching."));
// Special categories // Special categories
const QPalette p = QApplication::palette(); const QPalette p = QApplication::palette();
formatDescr.append(FormatDescription(C_LINK, tr("Link"), formatDescr.emplace_back(C_LINK, tr("Link"),
tr("Links that follow symbol under cursor."), Qt::blue)); tr("Links that follow symbol under cursor."), Qt::blue);
formatDescr.append(FormatDescription(C_SELECTION, tr("Selection"), tr("Selected text."), formatDescr.emplace_back(C_SELECTION, tr("Selection"), tr("Selected text."),
p.color(QPalette::HighlightedText))); p.color(QPalette::HighlightedText));
formatDescr.append(FormatDescription(C_LINE_NUMBER, tr("Line Number"), formatDescr.emplace_back(C_LINE_NUMBER, tr("Line Number"),
tr("Line numbers located on the " tr("Line numbers located on the left side of the editor."),
"left side of the editor."))); FormatDescription::AllControlsExceptUnderline);
formatDescr.append(FormatDescription(C_SEARCH_RESULT, tr("Search Result"), formatDescr.emplace_back(C_SEARCH_RESULT, tr("Search Result"),
tr("Highlighted search results inside the editor."))); tr("Highlighted search results inside the editor."),
formatDescr.append(FormatDescription(C_SEARCH_SCOPE, tr("Search Scope"), FormatDescription::ShowBackgroundControl);
tr("Section where the pattern is searched in."))); formatDescr.emplace_back(C_SEARCH_SCOPE, tr("Search Scope"),
formatDescr.append(FormatDescription(C_PARENTHESES, tr("Parentheses"), tr("Section where the pattern is searched in."),
tr("Displayed when matching parentheses, square brackets " FormatDescription::ShowBackgroundControl);
"or curly brackets are found."))); formatDescr.emplace_back(C_PARENTHESES, tr("Parentheses"),
formatDescr.append(FormatDescription(C_PARENTHESES_MISMATCH, tr("Mismatched Parentheses"), tr("Displayed when matching parentheses, square brackets "
tr("Displayed when mismatched parentheses, " "or curly brackets are found."));
"square brackets, or curly brackets are found."))); formatDescr.emplace_back(C_PARENTHESES_MISMATCH, tr("Mismatched Parentheses"),
formatDescr.append(FormatDescription(C_CURRENT_LINE, tr("Current Line"), tr("Displayed when mismatched parentheses, "
tr("Line where the cursor is placed in."))); "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 = FormatDescription currentLineNumber(C_CURRENT_LINE_NUMBER,
FormatDescription(C_CURRENT_LINE_NUMBER, tr("Current Line Number"), tr("Current Line Number"),
tr("Line number located on the left side of the " tr("Line number located on the left side of the "
"editor where the cursor is placed in."), Qt::darkGray); "editor where the cursor is placed in."),
Qt::darkGray,
FormatDescription::AllControlsExceptUnderline);
currentLineNumber.format().setBold(true); currentLineNumber.format().setBold(true);
formatDescr.append(currentLineNumber); formatDescr.push_back(std::move(currentLineNumber));
formatDescr.append(FormatDescription(C_OCCURRENCES, tr("Occurrences"), formatDescr.emplace_back(C_OCCURRENCES, tr("Occurrences"),
tr("Occurrences of the symbol under the cursor.\n" tr("Occurrences of the symbol under the cursor.\n"
"(Only the background will be applied.)"))); "(Only the background will be applied.)"),
formatDescr.append(FormatDescription(C_OCCURRENCES_UNUSED, FormatDescription::ShowBackgroundControl);
tr("Unused Occurrence"), formatDescr.emplace_back(C_OCCURRENCES_UNUSED,
tr("Occurrences of unused variables."), tr("Unused Occurrence"),
Qt::darkYellow, tr("Occurrences of unused variables."),
QTextCharFormat::SingleUnderline)); Qt::darkYellow,
formatDescr.append(FormatDescription(C_OCCURRENCES_RENAME, tr("Renaming Occurrence"), QTextCharFormat::SingleUnderline);
tr("Occurrences of a symbol that will be renamed."))); formatDescr.emplace_back(C_OCCURRENCES_RENAME, tr("Renaming Occurrence"),
tr("Occurrences of a symbol that will be renamed."),
FormatDescription::ShowBackgroundControl);
// Standard categories // Standard categories
formatDescr.append(FormatDescription(C_NUMBER, tr("Number"), tr("Number literal."), formatDescr.emplace_back(C_NUMBER, tr("Number"), tr("Number literal."),
Qt::darkBlue)); Qt::darkBlue);
formatDescr.append(FormatDescription(C_STRING, tr("String"), formatDescr.emplace_back(C_STRING, tr("String"),
tr("Character and string literals."), Qt::darkGreen)); tr("Character and string literals."), Qt::darkGreen);
formatDescr.append(FormatDescription(C_PRIMITIVE_TYPE, tr("Primitive Type"), formatDescr.emplace_back(C_PRIMITIVE_TYPE, tr("Primitive Type"),
tr("Name of a primitive data type."), Qt::darkYellow)); tr("Name of a primitive data type."), Qt::darkYellow);
formatDescr.append(FormatDescription(C_TYPE, tr("Type"), tr("Name of a type."), formatDescr.emplace_back(C_TYPE, tr("Type"), tr("Name of a type."),
Qt::darkMagenta)); Qt::darkMagenta);
formatDescr.append(FormatDescription(C_LOCAL, tr("Local"), tr("Local variables."))); formatDescr.emplace_back(C_LOCAL, tr("Local"), tr("Local variables."));
formatDescr.append(FormatDescription(C_FIELD, tr("Field"), formatDescr.emplace_back(C_FIELD, tr("Field"),
tr("Class' data members."), Qt::darkRed)); tr("Class' data members."), Qt::darkRed);
formatDescr.append(FormatDescription(C_ENUMERATION, tr("Enumeration"), formatDescr.emplace_back(C_ENUMERATION, tr("Enumeration"),
tr("Applied to enumeration items."), Qt::darkMagenta)); tr("Applied to enumeration items."), Qt::darkMagenta);
Format functionFormat; Format functionFormat;
formatDescr.append(FormatDescription(C_FUNCTION, tr("Function"), tr("Name of a function."), formatDescr.emplace_back(C_FUNCTION, tr("Function"), tr("Name of a function."),
functionFormat)); functionFormat);
functionFormat.setItalic(true); functionFormat.setItalic(true);
formatDescr.append(FormatDescription(C_VIRTUAL_METHOD, tr("Virtual Function"), formatDescr.emplace_back(C_VIRTUAL_METHOD, tr("Virtual Function"),
tr("Name of function declared as virtual."), tr("Name of function declared as virtual."),
functionFormat)); functionFormat);
formatDescr.append(FormatDescription(C_BINDING, tr("QML Binding"), formatDescr.emplace_back(C_BINDING, tr("QML Binding"),
tr("QML item property, that allows a " tr("QML item property, that allows a "
"binding to another property."), "binding to another property."),
Qt::darkRed)); Qt::darkRed);
Format qmlLocalNameFormat; Format qmlLocalNameFormat;
qmlLocalNameFormat.setItalic(true); qmlLocalNameFormat.setItalic(true);
formatDescr.append(FormatDescription(C_QML_LOCAL_ID, tr("QML Local Id"), formatDescr.emplace_back(C_QML_LOCAL_ID, tr("QML Local Id"),
tr("QML item id within a QML file."), qmlLocalNameFormat)); tr("QML item id within a QML file."), qmlLocalNameFormat);
formatDescr.append(FormatDescription(C_QML_ROOT_OBJECT_PROPERTY, formatDescr.emplace_back(C_QML_ROOT_OBJECT_PROPERTY,
tr("QML Root Object Property"), tr("QML Root Object Property"),
tr("QML property of a parent item."), qmlLocalNameFormat)); tr("QML property of a parent item."), qmlLocalNameFormat);
formatDescr.append(FormatDescription(C_QML_SCOPE_OBJECT_PROPERTY, formatDescr.emplace_back(C_QML_SCOPE_OBJECT_PROPERTY,
tr("QML Scope Object Property"), tr("QML Scope Object Property"),
tr("Property of the same QML item."), qmlLocalNameFormat)); tr("Property of the same QML item."), qmlLocalNameFormat);
formatDescr.append(FormatDescription(C_QML_STATE_NAME, tr("QML State Name"), formatDescr.emplace_back(C_QML_STATE_NAME, tr("QML State Name"),
tr("Name of a QML state."), qmlLocalNameFormat)); tr("Name of a QML state."), qmlLocalNameFormat);
formatDescr.append(FormatDescription(C_QML_TYPE_ID, tr("QML Type Name"), formatDescr.emplace_back(C_QML_TYPE_ID, tr("QML Type Name"),
tr("Name of a QML type."), Qt::darkMagenta)); tr("Name of a QML type."), Qt::darkMagenta);
Format qmlExternalNameFormat = qmlLocalNameFormat; Format qmlExternalNameFormat = qmlLocalNameFormat;
qmlExternalNameFormat.setForeground(Qt::darkBlue); qmlExternalNameFormat.setForeground(Qt::darkBlue);
formatDescr.append(FormatDescription(C_QML_EXTERNAL_ID, tr("QML External Id"), formatDescr.emplace_back(C_QML_EXTERNAL_ID, tr("QML External Id"),
tr("QML id defined in another QML file."), tr("QML id defined in another QML file."),
qmlExternalNameFormat)); qmlExternalNameFormat);
formatDescr.append(FormatDescription(C_QML_EXTERNAL_OBJECT_PROPERTY, formatDescr.emplace_back(C_QML_EXTERNAL_OBJECT_PROPERTY,
tr("QML External Object Property"), tr("QML External Object Property"),
tr("QML property defined in another QML file."), tr("QML property defined in another QML file."),
qmlExternalNameFormat)); qmlExternalNameFormat);
Format jsLocalFormat; Format jsLocalFormat;
jsLocalFormat.setForeground(QColor(41, 133, 199)); // very light blue jsLocalFormat.setForeground(QColor(41, 133, 199)); // very light blue
jsLocalFormat.setItalic(true); jsLocalFormat.setItalic(true);
formatDescr.append(FormatDescription(C_JS_SCOPE_VAR, tr("JavaScript Scope Var"), formatDescr.emplace_back(C_JS_SCOPE_VAR, tr("JavaScript Scope Var"),
tr("Variables defined inside the JavaScript file."), tr("Variables defined inside the JavaScript file."),
jsLocalFormat)); jsLocalFormat);
Format jsGlobalFormat; Format jsGlobalFormat;
jsGlobalFormat.setForeground(QColor(0, 85, 175)); // light blue jsGlobalFormat.setForeground(QColor(0, 85, 175)); // light blue
jsGlobalFormat.setItalic(true); jsGlobalFormat.setItalic(true);
formatDescr.append(FormatDescription(C_JS_IMPORT_VAR, tr("JavaScript Import"), formatDescr.emplace_back(C_JS_IMPORT_VAR, tr("JavaScript Import"),
tr("Name of a JavaScript import inside a QML file."), tr("Name of a JavaScript import inside a QML file."),
jsGlobalFormat)); jsGlobalFormat);
formatDescr.append(FormatDescription(C_JS_GLOBAL_VAR, tr("JavaScript Global Variable"), formatDescr.emplace_back(C_JS_GLOBAL_VAR, tr("JavaScript Global Variable"),
tr("Variables defined outside the script."), tr("Variables defined outside the script."),
jsGlobalFormat)); jsGlobalFormat);
formatDescr.append(FormatDescription(C_KEYWORD, tr("Keyword"), formatDescr.emplace_back(C_KEYWORD, tr("Keyword"),
tr("Reserved keywords of the programming language except " tr("Reserved keywords of the programming language except "
"keywords denoting primitive types."), Qt::darkYellow)); "keywords denoting primitive types."), Qt::darkYellow);
formatDescr.append(FormatDescription(C_OPERATOR, tr("Operator"), formatDescr.emplace_back(C_OPERATOR, tr("Operator"),
tr("Operators (for example operator++ or operator-=)."))); tr("Operators (for example operator++ or operator-=)."));
formatDescr.append(FormatDescription(C_PREPROCESSOR, tr("Preprocessor"), formatDescr.emplace_back(C_PREPROCESSOR, tr("Preprocessor"),
tr("Preprocessor directives."), Qt::darkBlue)); tr("Preprocessor directives."), Qt::darkBlue);
formatDescr.append(FormatDescription(C_LABEL, tr("Label"), tr("Labels for goto statements."), formatDescr.emplace_back(C_LABEL, tr("Label"), tr("Labels for goto statements."),
Qt::darkRed)); Qt::darkRed);
formatDescr.append(FormatDescription(C_COMMENT, tr("Comment"), formatDescr.emplace_back(C_COMMENT, tr("Comment"),
tr("All style of comments except Doxygen comments."), tr("All style of comments except Doxygen comments."),
Qt::darkGreen)); Qt::darkGreen);
formatDescr.append(FormatDescription(C_DOXYGEN_COMMENT, tr("Doxygen Comment"), formatDescr.emplace_back(C_DOXYGEN_COMMENT, tr("Doxygen Comment"),
tr("Doxygen comments."), Qt::darkBlue)); tr("Doxygen comments."), Qt::darkBlue);
formatDescr.append(FormatDescription(C_DOXYGEN_TAG, tr("Doxygen Tag"), tr("Doxygen tags."), formatDescr.emplace_back(C_DOXYGEN_TAG, tr("Doxygen Tag"), tr("Doxygen tags."),
Qt::blue)); Qt::blue);
formatDescr.append(FormatDescription(C_VISUAL_WHITESPACE, tr("Visual Whitespace"), formatDescr.emplace_back(C_VISUAL_WHITESPACE, tr("Visual Whitespace"),
tr("Whitespace.\nWill not be applied to whitespace " tr("Whitespace.\nWill not be applied to whitespace "
"in comments and strings."), Qt::lightGray)); "in comments and strings."), Qt::lightGray);
formatDescr.append(FormatDescription(C_DISABLED_CODE, tr("Disabled Code"), formatDescr.emplace_back(C_DISABLED_CODE, tr("Disabled Code"),
tr("Code disabled by preprocessor directives."))); tr("Code disabled by preprocessor directives."));
// Diff categories // Diff categories
formatDescr.append(FormatDescription(C_ADDED_LINE, tr("Added Line"), formatDescr.emplace_back(C_ADDED_LINE, tr("Added Line"),
tr("Applied to added lines in differences " tr("Applied to added lines in differences (in diff editor)."),
"(in diff editor)."), QColor(0, 170, 0))); QColor(0, 170, 0));
formatDescr.append(FormatDescription(C_REMOVED_LINE, tr("Removed Line"), formatDescr.emplace_back(C_REMOVED_LINE, tr("Removed Line"),
tr("Applied to removed lines " tr("Applied to removed lines in differences (in diff editor)."),
"in differences (in diff editor)."), Qt::red)); Qt::red);
formatDescr.append(FormatDescription(C_DIFF_FILE, tr("Diff File"), formatDescr.emplace_back(C_DIFF_FILE, tr("Diff File"),
tr("Compared files (in diff editor)."), Qt::darkBlue)); tr("Compared files (in diff editor)."), Qt::darkBlue);
formatDescr.append(FormatDescription(C_DIFF_LOCATION, tr("Diff Location"), formatDescr.emplace_back(C_DIFF_LOCATION, tr("Diff Location"),
tr("Location in the files where the difference is " tr("Location in the files where the difference is "
"(in diff editor)."), Qt::blue)); "(in diff editor)."), Qt::blue);
// New diff categories // New diff categories
formatDescr.append(FormatDescription(C_DIFF_FILE_LINE, tr("Diff File Line"), formatDescr.emplace_back(C_DIFF_FILE_LINE, tr("Diff File Line"),
tr("Applied to lines with file information " tr("Applied to lines with file information "
"in differences (in side-by-side diff editor)."), "in differences (in side-by-side diff editor)."),
Format(QColor(), QColor(255, 255, 0)))); Format(QColor(), QColor(255, 255, 0)));
formatDescr.append(FormatDescription(C_DIFF_CONTEXT_LINE, tr("Diff Context Line"), formatDescr.emplace_back(C_DIFF_CONTEXT_LINE, tr("Diff Context Line"),
tr("Applied to lines describing hidden context " tr("Applied to lines describing hidden context "
"in differences (in side-by-side diff editor)."), "in differences (in side-by-side diff editor)."),
Format(QColor(), QColor(175, 215, 231)))); Format(QColor(), QColor(175, 215, 231)));
formatDescr.append(FormatDescription(C_DIFF_SOURCE_LINE, tr("Diff Source Line"), formatDescr.emplace_back(C_DIFF_SOURCE_LINE, tr("Diff Source Line"),
tr("Applied to source lines with changes " tr("Applied to source lines with changes "
"in differences (in side-by-side diff editor)."), "in differences (in side-by-side diff editor)."),
Format(QColor(), QColor(255, 223, 223)))); Format(QColor(), QColor(255, 223, 223)));
formatDescr.append(FormatDescription(C_DIFF_SOURCE_CHAR, tr("Diff Source Character"), formatDescr.emplace_back(C_DIFF_SOURCE_CHAR, tr("Diff Source Character"),
tr("Applied to removed characters " tr("Applied to removed characters "
"in differences (in side-by-side diff editor)."), "in differences (in side-by-side diff editor)."),
Format(QColor(), QColor(255, 175, 175)))); Format(QColor(), QColor(255, 175, 175)));
formatDescr.append(FormatDescription(C_DIFF_DEST_LINE, tr("Diff Destination Line"), formatDescr.emplace_back(C_DIFF_DEST_LINE, tr("Diff Destination Line"),
tr("Applied to destination lines with changes " tr("Applied to destination lines with changes "
"in differences (in side-by-side diff editor)."), "in differences (in side-by-side diff editor)."),
Format(QColor(), QColor(223, 255, 223)))); Format(QColor(), QColor(223, 255, 223)));
formatDescr.append(FormatDescription(C_DIFF_DEST_CHAR, tr("Diff Destination Character"), formatDescr.emplace_back(C_DIFF_DEST_CHAR, tr("Diff Destination Character"),
tr("Applied to added characters " tr("Applied to added characters "
"in differences (in side-by-side diff editor)."), "in differences (in side-by-side diff editor)."),
Format(QColor(), QColor(175, 255, 175)))); Format(QColor(), QColor(175, 255, 175)));
formatDescr.append(FormatDescription(C_LOG_CHANGE_LINE, tr("Log Change Line"), formatDescr.emplace_back(C_LOG_CHANGE_LINE, tr("Log Change Line"),
tr("Applied to lines describing changes in VCS log."), tr("Applied to lines describing changes in VCS log."),
Format(QColor(192, 0, 0), QColor()))); Format(QColor(192, 0, 0), QColor()));
formatDescr.append(FormatDescription(C_ERROR, formatDescr.emplace_back(C_ERROR,
tr("Error"), tr("Error"),
tr("Underline color of error diagnostics."), tr("Underline color of error diagnostics."),
{255,0, 0}, QColor(255,0, 0),
QTextCharFormat::SingleUnderline)); QTextCharFormat::SingleUnderline,
formatDescr.append(FormatDescription(C_ERROR_CONTEXT, FormatDescription::ShowUnderlineControl);
tr("Error Context"), formatDescr.emplace_back(C_ERROR_CONTEXT,
tr("Underline color of the contexts of error diagnostics."), tr("Error Context"),
{255,0, 0}, tr("Underline color of the contexts of error diagnostics."),
QTextCharFormat::DotLine)); QColor(255,0, 0),
formatDescr.append(FormatDescription(C_WARNING, QTextCharFormat::DotLine,
tr("Warning"), FormatDescription::ShowUnderlineControl);
tr("Underline color of warning diagnostics."), formatDescr.emplace_back(C_WARNING,
{255, 190, 0}, tr("Warning"),
QTextCharFormat::SingleUnderline)); tr("Underline color of warning diagnostics."),
formatDescr.append(FormatDescription(C_WARNING_CONTEXT, QColor(255, 190, 0),
tr("Warning Context"), QTextCharFormat::SingleUnderline,
tr("Underline color of the contexts of warning diagnostics."), FormatDescription::ShowUnderlineControl);
{255, 190, 0}, formatDescr.emplace_back(C_WARNING_CONTEXT,
QTextCharFormat::DotLine)); 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, d->m_fontSettingsPage = new FontSettingsPage(formatDescr,