TextEditor: Remove defaults from Format

The default caused strange bugs because it was expected that no color was
set.

Task-number: QTCREATORBUG-21282
Change-Id: I3b520b944ffcb87838ba3e7b02e1d28b0f757679
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Marco Bubke
2018-10-11 14:19:54 +02:00
parent 352ac2ccf4
commit f2bd50c466
2 changed files with 8 additions and 12 deletions

View File

@@ -46,10 +46,6 @@ public:
Format() = default;
Format(const QColor &foreground, const QColor &background);
static Format createMixinFormat() {
return Format(QColor(), QColor());
}
QColor foreground() const { return m_foreground; }
void setForeground(const QColor &foreground);
@@ -86,8 +82,8 @@ public:
bool fromString(const QString &str);
private:
QColor m_foreground = Qt::black;
QColor m_background = Qt::white;
QColor m_foreground;
QColor m_background;
QColor m_underlineColor;
double m_relativeForegroundSaturation = 0.0;
double m_relativeForegroundLightness = 0.0;

View File

@@ -92,8 +92,10 @@ TextEditorSettings::TextEditorSettings()
// Add font preference page
FormatDescriptions formatDescr;
formatDescr.reserve(C_LAST_STYLE_SENTINEL);
formatDescr.emplace_back(C_TEXT, tr("Text"), tr("Generic text and punctuation tokens.\n"
"Applied to text that matched no other rule."));
formatDescr.emplace_back(C_TEXT, tr("Text"),
tr("Generic text and punctuation tokens.\n"
"Applied to text that matched no other rule."),
Format{QColor{}, Qt::white});
// Special categories
const QPalette p = QApplication::palette();
@@ -168,7 +170,7 @@ TextEditorSettings::TextEditorSettings()
functionFormat.setForeground(QColor(0, 103, 124));
formatDescr.emplace_back(C_FUNCTION, tr("Function"), tr("Name of a function."),
functionFormat);
Format declarationFormat = Format::createMixinFormat();
Format declarationFormat;
declarationFormat.setBold(true);
formatDescr.emplace_back(C_DECLARATION,
tr("Function Declaration"),
@@ -178,7 +180,6 @@ TextEditorSettings::TextEditorSettings()
formatDescr.emplace_back(C_FUNCTION_DEFINITION,
tr("Function Definition"),
tr("Name of function at its definition."),
Format::createMixinFormat(),
FormatDescription::ShowAllControls);
Format virtualFunctionFormat(functionFormat);
virtualFunctionFormat.setItalic(true);
@@ -242,7 +243,6 @@ TextEditorSettings::TextEditorSettings()
formatDescr.emplace_back(C_OPERATOR, tr("Operator"),
tr("Non user-defined language operators.\n"
"To style user-defined operators, use Overloaded Operator."),
Format::createMixinFormat(),
FormatDescription::ShowAllControls);
formatDescr.emplace_back(C_OVERLOADED_OPERATOR,
tr("Overloaded Operators"),
@@ -335,7 +335,7 @@ TextEditorSettings::TextEditorSettings()
QColor(255, 190, 0),
QTextCharFormat::DotLine,
FormatDescription::ShowAllControls);
Format outputArgumentFormat = Format::createMixinFormat();
Format outputArgumentFormat;
outputArgumentFormat.setItalic(true);
formatDescr.emplace_back(C_OUTPUT_ARGUMENT,
tr("Output Argument"),