forked from qt-creator/qt-creator
TextEditor: Cleanup text styles
So far there were different settings for different mix-ins. There was no technical reason why we limit the user. So you can set now the color, the relative saturation and value, the font, underline, italic and bold. The relative saturation and value are disabled if the color is set. The settings are reordered too so the order reflects the semantic meaning much better. Change-Id: I440967d6729f720816d2bc028ff9fe8e8868074e Task-number: QTCREATORBUG-21105 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -278,6 +278,7 @@ void ColorSchemeEdit::updateForegroundControls()
|
|||||||
|
|
||||||
bool isVisible = formatDescription.showControl(FormatDescription::ShowForegroundControl);
|
bool isVisible = formatDescription.showControl(FormatDescription::ShowForegroundControl);
|
||||||
|
|
||||||
|
m_ui->relativeForegroundHeadline->setEnabled(isVisible);
|
||||||
m_ui->foregroundLabel->setVisible(isVisible);
|
m_ui->foregroundLabel->setVisible(isVisible);
|
||||||
m_ui->foregroundToolButton->setVisible(isVisible);
|
m_ui->foregroundToolButton->setVisible(isVisible);
|
||||||
m_ui->eraseForegroundToolButton->setVisible(isVisible);
|
m_ui->eraseForegroundToolButton->setVisible(isVisible);
|
||||||
@@ -296,6 +297,7 @@ void ColorSchemeEdit::updateBackgroundControls()
|
|||||||
|
|
||||||
bool isVisible = formatDescription.showControl(FormatDescription::ShowBackgroundControl);
|
bool isVisible = formatDescription.showControl(FormatDescription::ShowBackgroundControl);
|
||||||
|
|
||||||
|
m_ui->relativeBackgroundHeadline->setVisible(isVisible);
|
||||||
m_ui->backgroundLabel->setVisible(isVisible);
|
m_ui->backgroundLabel->setVisible(isVisible);
|
||||||
m_ui->backgroundToolButton->setVisible(isVisible);
|
m_ui->backgroundToolButton->setVisible(isVisible);
|
||||||
m_ui->eraseBackgroundToolButton->setVisible(isVisible);
|
m_ui->eraseBackgroundToolButton->setVisible(isVisible);
|
||||||
@@ -326,6 +328,14 @@ void ColorSchemeEdit::updateRelativeForegroundControls()
|
|||||||
m_ui->relativeForegroundSpacer2->setVisible(isVisible);
|
m_ui->relativeForegroundSpacer2->setVisible(isVisible);
|
||||||
m_ui->relativeForegroundSpacer3->setVisible(isVisible);
|
m_ui->relativeForegroundSpacer3->setVisible(isVisible);
|
||||||
|
|
||||||
|
bool isEnabled = !m_readOnly && !format.foreground().isValid();
|
||||||
|
|
||||||
|
m_ui->relativeForegroundHeadline->setEnabled(isEnabled);
|
||||||
|
m_ui->foregroundSaturationLabel->setEnabled(isEnabled);
|
||||||
|
m_ui->foregroundLightnessLabel->setEnabled(isEnabled);
|
||||||
|
m_ui->foregroundSaturationSpinBox->setEnabled(isEnabled);
|
||||||
|
m_ui->foregroundLightnessSpinBox->setEnabled(isEnabled);
|
||||||
|
|
||||||
m_ui->foregroundSaturationSpinBox->setValue(format.relativeForegroundSaturation());
|
m_ui->foregroundSaturationSpinBox->setValue(format.relativeForegroundSaturation());
|
||||||
m_ui->foregroundLightnessSpinBox->setValue(format.relativeForegroundLightness());
|
m_ui->foregroundLightnessSpinBox->setValue(format.relativeForegroundLightness());
|
||||||
}
|
}
|
||||||
@@ -349,6 +359,14 @@ void ColorSchemeEdit::updateRelativeBackgroundControls()
|
|||||||
m_ui->relativeBackgroundSpacer2->setVisible(isVisible);
|
m_ui->relativeBackgroundSpacer2->setVisible(isVisible);
|
||||||
m_ui->relativeBackgroundSpacer3->setVisible(isVisible);
|
m_ui->relativeBackgroundSpacer3->setVisible(isVisible);
|
||||||
|
|
||||||
|
bool isEnabled = !m_readOnly && !format.background().isValid();
|
||||||
|
|
||||||
|
m_ui->relativeBackgroundHeadline->setEnabled(isEnabled);
|
||||||
|
m_ui->backgroundSaturationLabel->setEnabled(isEnabled);
|
||||||
|
m_ui->backgroundLightnessLabel->setEnabled(isEnabled);
|
||||||
|
m_ui->backgroundSaturationSpinBox->setEnabled(isEnabled);
|
||||||
|
m_ui->backgroundLightnessSpinBox->setEnabled(isEnabled);
|
||||||
|
|
||||||
m_ui->backgroundSaturationSpinBox->setValue(format.relativeBackgroundSaturation());
|
m_ui->backgroundSaturationSpinBox->setValue(format.relativeBackgroundSaturation());
|
||||||
m_ui->backgroundLightnessSpinBox->setValue(format.relativeBackgroundLightness());
|
m_ui->backgroundLightnessSpinBox->setValue(format.relativeBackgroundLightness());
|
||||||
}
|
}
|
||||||
@@ -415,6 +433,8 @@ void ColorSchemeEdit::changeForeColor()
|
|||||||
m_scheme.formatFor(category).setForeground(newColor);
|
m_scheme.formatFor(category).setForeground(newColor);
|
||||||
m_formatsModel->emitDataChanged(index);
|
m_formatsModel->emitDataChanged(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorSchemeEdit::changeBackColor()
|
void ColorSchemeEdit::changeBackColor()
|
||||||
@@ -436,6 +456,8 @@ void ColorSchemeEdit::changeBackColor()
|
|||||||
if (index.row() == 0)
|
if (index.row() == 0)
|
||||||
setItemListBackground(newColor);
|
setItemListBackground(newColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorSchemeEdit::eraseBackColor()
|
void ColorSchemeEdit::eraseBackColor()
|
||||||
@@ -451,6 +473,8 @@ void ColorSchemeEdit::eraseBackColor()
|
|||||||
m_scheme.formatFor(category).setBackground(newColor);
|
m_scheme.formatFor(category).setBackground(newColor);
|
||||||
m_formatsModel->emitDataChanged(index);
|
m_formatsModel->emitDataChanged(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorSchemeEdit::eraseForeColor()
|
void ColorSchemeEdit::eraseForeColor()
|
||||||
@@ -466,6 +490,8 @@ void ColorSchemeEdit::eraseForeColor()
|
|||||||
m_scheme.formatFor(category).setForeground(newColor);
|
m_scheme.formatFor(category).setForeground(newColor);
|
||||||
m_formatsModel->emitDataChanged(index);
|
m_formatsModel->emitDataChanged(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorSchemeEdit::changeRelativeForeColor()
|
void ColorSchemeEdit::changeRelativeForeColor()
|
||||||
|
|||||||
@@ -58,36 +58,40 @@ public:
|
|||||||
ShowUnderlineControl = 0x8,
|
ShowUnderlineControl = 0x8,
|
||||||
ShowRelativeForegroundControl = 0x10,
|
ShowRelativeForegroundControl = 0x10,
|
||||||
ShowRelativeBackgroundControl = 0x20,
|
ShowRelativeBackgroundControl = 0x20,
|
||||||
|
ShowRelativeControls = ShowRelativeForegroundControl | ShowRelativeBackgroundControl,
|
||||||
ShowFontUnderlineAndRelativeControls = ShowFontControls
|
ShowFontUnderlineAndRelativeControls = ShowFontControls
|
||||||
| ShowUnderlineControl
|
| ShowUnderlineControl
|
||||||
| ShowRelativeForegroundControl
|
| ShowRelativeControls,
|
||||||
| ShowRelativeBackgroundControl,
|
ShowAllAbsoluteControls = ShowForegroundControl
|
||||||
AllControls = 0xF,
|
| ShowBackgroundControl
|
||||||
AllControlsExceptUnderline = AllControls & ~ShowUnderlineControl,
|
| ShowFontControls
|
||||||
|
| ShowUnderlineControl,
|
||||||
|
ShowAllAbsoluteControlsExceptUnderline = ShowAllAbsoluteControls & ~ShowUnderlineControl,
|
||||||
|
ShowAllControls = ShowAllAbsoluteControls | ShowRelativeControls
|
||||||
};
|
};
|
||||||
FormatDescription() = default;
|
FormatDescription() = default;
|
||||||
|
|
||||||
FormatDescription(TextStyle id,
|
FormatDescription(TextStyle id,
|
||||||
const QString &displayName,
|
const QString &displayName,
|
||||||
const QString &tooltipText,
|
const QString &tooltipText,
|
||||||
ShowControls showControls = AllControls);
|
ShowControls showControls = ShowAllAbsoluteControls);
|
||||||
|
|
||||||
FormatDescription(TextStyle id,
|
FormatDescription(TextStyle id,
|
||||||
const QString &displayName,
|
const QString &displayName,
|
||||||
const QString &tooltipText,
|
const QString &tooltipText,
|
||||||
const QColor &foreground,
|
const QColor &foreground,
|
||||||
ShowControls showControls = AllControls);
|
ShowControls showControls = ShowAllAbsoluteControls);
|
||||||
FormatDescription(TextStyle id,
|
FormatDescription(TextStyle id,
|
||||||
const QString &displayName,
|
const QString &displayName,
|
||||||
const QString &tooltipText,
|
const QString &tooltipText,
|
||||||
const Format &format,
|
const Format &format,
|
||||||
ShowControls showControls = AllControls);
|
ShowControls showControls = ShowAllAbsoluteControls);
|
||||||
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);
|
ShowControls showControls = ShowAllAbsoluteControls);
|
||||||
|
|
||||||
TextStyle id() const { return m_id; }
|
TextStyle id() const { return m_id; }
|
||||||
|
|
||||||
@@ -110,7 +114,7 @@ private:
|
|||||||
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;
|
ShowControls m_showControls = ShowAllAbsoluteControls;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<FormatDescription> FormatDescriptions;
|
typedef std::vector<FormatDescription> FormatDescriptions;
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ TextEditorSettings::TextEditorSettings()
|
|||||||
p.color(QPalette::HighlightedText));
|
p.color(QPalette::HighlightedText));
|
||||||
formatDescr.emplace_back(C_LINE_NUMBER, tr("Line Number"),
|
formatDescr.emplace_back(C_LINE_NUMBER, tr("Line Number"),
|
||||||
tr("Line numbers located on the left side of the editor."),
|
tr("Line numbers located on the left side of the editor."),
|
||||||
FormatDescription::AllControlsExceptUnderline);
|
FormatDescription::ShowAllAbsoluteControlsExceptUnderline);
|
||||||
formatDescr.emplace_back(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."),
|
||||||
FormatDescription::ShowBackgroundControl);
|
FormatDescription::ShowBackgroundControl);
|
||||||
@@ -128,7 +128,7 @@ TextEditorSettings::TextEditorSettings()
|
|||||||
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."),
|
"editor where the cursor is placed in."),
|
||||||
Qt::darkGray,
|
Qt::darkGray,
|
||||||
FormatDescription::AllControlsExceptUnderline);
|
FormatDescription::ShowAllAbsoluteControlsExceptUnderline);
|
||||||
currentLineNumber.format().setBold(true);
|
currentLineNumber.format().setBold(true);
|
||||||
formatDescr.push_back(std::move(currentLineNumber));
|
formatDescr.push_back(std::move(currentLineNumber));
|
||||||
|
|
||||||
@@ -168,6 +168,18 @@ TextEditorSettings::TextEditorSettings()
|
|||||||
functionFormat.setForeground(QColor(0, 103, 124));
|
functionFormat.setForeground(QColor(0, 103, 124));
|
||||||
formatDescr.emplace_back(C_FUNCTION, tr("Function"), tr("Name of a function."),
|
formatDescr.emplace_back(C_FUNCTION, tr("Function"), tr("Name of a function."),
|
||||||
functionFormat);
|
functionFormat);
|
||||||
|
Format declarationFormat = Format::createMixinFormat();
|
||||||
|
declarationFormat.setBold(true);
|
||||||
|
formatDescr.emplace_back(C_DECLARATION,
|
||||||
|
tr("Function Declaration"),
|
||||||
|
tr("Style adjustments to (function) declarations."),
|
||||||
|
declarationFormat,
|
||||||
|
FormatDescription::ShowAllControls);
|
||||||
|
formatDescr.emplace_back(C_FUNCTION_DEFINITION,
|
||||||
|
tr("Function Definition"),
|
||||||
|
tr("Name of function at its definition."),
|
||||||
|
Format::createMixinFormat(),
|
||||||
|
FormatDescription::ShowAllControls);
|
||||||
functionFormat.setItalic(true);
|
functionFormat.setItalic(true);
|
||||||
formatDescr.emplace_back(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."),
|
||||||
@@ -229,11 +241,13 @@ TextEditorSettings::TextEditorSettings()
|
|||||||
formatDescr.emplace_back(C_OPERATOR, tr("Operator"),
|
formatDescr.emplace_back(C_OPERATOR, tr("Operator"),
|
||||||
tr("Non user-defined language operators.\n"
|
tr("Non user-defined language operators.\n"
|
||||||
"To style user-defined operators, use Overloaded Operator."),
|
"To style user-defined operators, use Overloaded Operator."),
|
||||||
Format::createMixinFormat());
|
Format::createMixinFormat(),
|
||||||
|
FormatDescription::ShowAllControls);
|
||||||
formatDescr.emplace_back(C_OVERLOADED_OPERATOR,
|
formatDescr.emplace_back(C_OVERLOADED_OPERATOR,
|
||||||
tr("Overloaded Operators"),
|
tr("Overloaded Operators"),
|
||||||
tr("Calls and declarations of overloaded (user-defined) operators."),
|
tr("Calls and declarations of overloaded (user-defined) operators."),
|
||||||
Format::createMixinFormat());
|
Format::createMixinFormat(),
|
||||||
|
FormatDescription::ShowAllControls);
|
||||||
formatDescr.emplace_back(C_PREPROCESSOR, tr("Preprocessor"),
|
formatDescr.emplace_back(C_PREPROCESSOR, tr("Preprocessor"),
|
||||||
tr("Preprocessor directives."), Qt::darkBlue);
|
tr("Preprocessor directives."), Qt::darkBlue);
|
||||||
formatDescr.emplace_back(C_LABEL, tr("Label"), tr("Labels for goto statements."),
|
formatDescr.emplace_back(C_LABEL, tr("Label"), tr("Labels for goto statements."),
|
||||||
@@ -301,43 +315,32 @@ TextEditorSettings::TextEditorSettings()
|
|||||||
tr("Underline color of error diagnostics."),
|
tr("Underline color of error diagnostics."),
|
||||||
QColor(255,0, 0),
|
QColor(255,0, 0),
|
||||||
QTextCharFormat::SingleUnderline,
|
QTextCharFormat::SingleUnderline,
|
||||||
FormatDescription::ShowUnderlineControl);
|
FormatDescription::ShowAllControls);
|
||||||
formatDescr.emplace_back(C_ERROR_CONTEXT,
|
formatDescr.emplace_back(C_ERROR_CONTEXT,
|
||||||
tr("Error Context"),
|
tr("Error Context"),
|
||||||
tr("Underline color of the contexts of error diagnostics."),
|
tr("Underline color of the contexts of error diagnostics."),
|
||||||
QColor(255,0, 0),
|
QColor(255,0, 0),
|
||||||
QTextCharFormat::DotLine,
|
QTextCharFormat::DotLine,
|
||||||
FormatDescription::ShowUnderlineControl);
|
FormatDescription::ShowAllControls);
|
||||||
formatDescr.emplace_back(C_WARNING,
|
formatDescr.emplace_back(C_WARNING,
|
||||||
tr("Warning"),
|
tr("Warning"),
|
||||||
tr("Underline color of warning diagnostics."),
|
tr("Underline color of warning diagnostics."),
|
||||||
QColor(255, 190, 0),
|
QColor(255, 190, 0),
|
||||||
QTextCharFormat::SingleUnderline,
|
QTextCharFormat::SingleUnderline,
|
||||||
FormatDescription::ShowUnderlineControl);
|
FormatDescription::ShowAllControls);
|
||||||
formatDescr.emplace_back(C_WARNING_CONTEXT,
|
formatDescr.emplace_back(C_WARNING_CONTEXT,
|
||||||
tr("Warning Context"),
|
tr("Warning Context"),
|
||||||
tr("Underline color of the contexts of warning diagnostics."),
|
tr("Underline color of the contexts of warning diagnostics."),
|
||||||
QColor(255, 190, 0),
|
QColor(255, 190, 0),
|
||||||
QTextCharFormat::DotLine,
|
QTextCharFormat::DotLine,
|
||||||
FormatDescription::ShowUnderlineControl);
|
FormatDescription::ShowAllControls);
|
||||||
Format declarationFormat = Format::createMixinFormat();
|
|
||||||
declarationFormat.setBold(true);
|
|
||||||
formatDescr.emplace_back(C_DECLARATION,
|
|
||||||
tr("Function Declaration"),
|
|
||||||
tr("Style adjustments to (function) declarations."),
|
|
||||||
declarationFormat,
|
|
||||||
FormatDescription::ShowFontUnderlineAndRelativeControls);
|
|
||||||
formatDescr.emplace_back(C_FUNCTION_DEFINITION,
|
|
||||||
tr("Function Definition"),
|
|
||||||
tr("Name of function at its definition."),
|
|
||||||
Format::createMixinFormat());
|
|
||||||
Format outputArgumentFormat = Format::createMixinFormat();
|
Format outputArgumentFormat = Format::createMixinFormat();
|
||||||
outputArgumentFormat.setItalic(true);
|
outputArgumentFormat.setItalic(true);
|
||||||
formatDescr.emplace_back(C_OUTPUT_ARGUMENT,
|
formatDescr.emplace_back(C_OUTPUT_ARGUMENT,
|
||||||
tr("Output Argument"),
|
tr("Output Argument"),
|
||||||
tr("Writable arguments of a function call."),
|
tr("Writable arguments of a function call."),
|
||||||
outputArgumentFormat,
|
outputArgumentFormat,
|
||||||
FormatDescription::ShowFontUnderlineAndRelativeControls);
|
FormatDescription::ShowAllControls);
|
||||||
|
|
||||||
d->m_fontSettingsPage = new FontSettingsPage(formatDescr,
|
d->m_fontSettingsPage = new FontSettingsPage(formatDescr,
|
||||||
Constants::TEXT_EDITOR_FONT_SETTINGS,
|
Constants::TEXT_EDITOR_FONT_SETTINGS,
|
||||||
|
|||||||
Reference in New Issue
Block a user