TextEdit: Add underline support to text settings

Underlines colors was hard coded to the foreground color of some settings.
With this patch you can set the underline color and the underline style
to your taste.

Change-Id: Ibc64c2d2c89bf1827a2cadaf6aee9d50d08cd1ee
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-09-10 14:18:37 +02:00
committed by David Schulz
parent 0d20d56183
commit 331e9d8878
11 changed files with 318 additions and 72 deletions

View File

@@ -192,6 +192,8 @@ FontSettingsPagePrivate::FontSettingsPagePrivate(const FormatDescriptions &fd,
format.setBackground(f.background());
format.setBold(f.format().bold());
format.setItalic(f.format().italic());
format.setUnderlineColor(f.format().underlineColor());
format.setUnderlineStyle(f.format().underlineStyle());
}
} else if (m_value.colorSchemeFileName().isEmpty()) {
// No color scheme was loaded, but one might be imported from the ini file
@@ -202,6 +204,8 @@ FontSettingsPagePrivate::FontSettingsPagePrivate(const FormatDescriptions &fd,
format.setBackground(f.background());
format.setBold(f.format().bold());
format.setItalic(f.format().italic());
format.setUnderlineColor(f.format().underlineColor());
format.setUnderlineStyle(f.format().underlineStyle());
}
if (m_value.colorScheme() != defaultScheme) {
// Save it as a color scheme file
@@ -239,6 +243,21 @@ FormatDescription::FormatDescription(TextStyle id, const QString &displayName, c
{
}
FormatDescription::FormatDescription(TextStyle id,
const QString &displayName,
const QString &tooltipText,
const QColor &underlineColor,
const QTextCharFormat::UnderlineStyle underlineStyle)
: m_id(id),
m_displayName(displayName),
m_tooltipText(tooltipText)
{
m_format.setForeground(QColor());
m_format.setBackground(QColor());
m_format.setUnderlineColor(underlineColor);
m_format.setUnderlineStyle(underlineStyle);
}
QColor FormatDescription::foreground() const
{
if (m_id == C_LINE_NUMBER) {
@@ -253,8 +272,6 @@ QColor FormatDescription::foreground() const
return QApplication::palette().foreground().color();
else
return m_format.foreground();
} else if (m_id == C_OCCURRENCES_UNUSED) {
return Qt::darkYellow;
} else if (m_id == C_PARENTHESES) {
return QColor(Qt::red);
}
@@ -314,7 +331,6 @@ QColor FormatDescription::background() const
return QColor(); // invalid color
}
// ------------ FontSettingsPage
FontSettingsPage::FontSettingsPage(const FormatDescriptions &fd,
Core::Id id,