From 1f9ae50457a3750f03fbe1be16dcb870af961d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 1 Jun 2012 10:32:17 +0200 Subject: [PATCH] Added SpellCheckUnderlineStyle theme hint. Task-number: QTBUG-25115 Change-Id: I70abbed426ad8bebca51823ed5ce16f2f300b5cc Reviewed-by: Friedemann Kleint --- src/gui/kernel/qplatformtheme.h | 3 ++- src/gui/kernel/qplatformtheme_qpa.cpp | 6 ++++++ src/gui/painting/qpainter.cpp | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 971c0102141..f80f9e59d8b 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -86,7 +86,8 @@ public: DialogButtonBoxButtonsHaveIcons, UseFullScreenForPopupMenu, KeyboardScheme, - UiEffects + UiEffects, + SpellCheckUnderlineStyle }; enum DialogType { diff --git a/src/gui/kernel/qplatformtheme_qpa.cpp b/src/gui/kernel/qplatformtheme_qpa.cpp index 32204e6a264..1038eb2826b 100644 --- a/src/gui/kernel/qplatformtheme_qpa.cpp +++ b/src/gui/kernel/qplatformtheme_qpa.cpp @@ -44,6 +44,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -101,6 +102,9 @@ QT_BEGIN_NAMESPACE \value UiEffects (int) A flag value consisting of UiEffect values specifying the enabled UI animations. + \value SpellCheckUnderlineStyle (int) A QTextCharFormat::UnderlineStyle specifying + the underline style used misspelled words when spell checking. + \sa themeHint(), QStyle::pixelMetric() */ @@ -167,6 +171,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const return QVariant(int(WindowsKeyboardScheme)); case UiEffects: return QVariant(int(0)); + case SpellCheckUnderlineStyle: + return QVariant(int(QTextCharFormat::SpellCheckUnderline)); } return QVariant(); } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index ed08162c1cb..f49b4d92b15 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -61,6 +61,8 @@ #include "qstatictext.h" #include "qglyphrun.h" +#include + #include #include #include @@ -6180,7 +6182,9 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const const qreal underlinePos = pos.y() + qCeil(underlineOffset); if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { - underlineStyle = QTextCharFormat::SpellCheckUnderline; // ### Qt5 QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle)); + QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); + if (theme) + underlineStyle = QTextCharFormat::UnderlineStyle(theme->themeHint(QPlatformTheme::SpellCheckUnderlineStyle).toInt()); } if (underlineStyle == QTextCharFormat::WaveUnderline) {