From 5af0177c9e446a683163b04b7f3b8776b0977e94 Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Thu, 13 Oct 2022 12:34:20 +0200 Subject: [PATCH] Add a platform theme option to affect SH_UnderlineShortcut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The style hint SH_UnderlineShortcut can now be turned on/off via the platform theme. No change in functionality so far on any platform, this behaves the same way it did before the change. The change just adds a possibility for platforms to redefine the default underlining behavior. Task-number: QTBUG-76587 Change-Id: Ibda104f1b733371da19825b96e73c22f42faf853 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformintegration.cpp | 2 ++ src/gui/kernel/qplatformintegration.h | 3 ++- src/gui/kernel/qplatformtheme.cpp | 5 +++++ src/gui/kernel/qplatformtheme.h | 3 ++- src/widgets/styles/qcommonstyle.cpp | 7 +++++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index c95742b34d..b7117b121d 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -416,6 +416,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickMaximumVelocity); case FlickDeceleration: return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickDeceleration); + case UnderlineShortcut: + return true; } return 0; diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 3d43395767..393845012a 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -164,7 +164,8 @@ public: MouseDoubleClickDistance, FlickStartDistance, FlickMaximumVelocity, - FlickDeceleration + FlickDeceleration, + UnderlineShortcut, }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 498ecac2cd..1639003f5f 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -525,6 +525,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickMaximumVelocity); case QPlatformTheme::FlickDeceleration: return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickDeceleration); + case QPlatformTheme::UnderlineShortcut: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UnderlineShortcut); default: return QPlatformTheme::defaultThemeHint(hint); } @@ -637,7 +639,10 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return QVariant(QString()); case MouseCursorSize: return QVariant(QSize(16, 16)); + case UnderlineShortcut: + return true; } + return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 10a3246da8..c06823addf 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -95,7 +95,8 @@ public: FlickDeceleration, MenuBarFocusOnAltPressRelease, MouseCursorTheme, - MouseCursorSize + MouseCursorSize, + UnderlineShortcut, }; Q_ENUM(ThemeHint) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index b4866a84ec..fb6b415f59 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5156,9 +5156,12 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = 1; break; - case SH_UnderlineShortcut: - ret = 1; + case SH_UnderlineShortcut: { + const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); + ret = theme ? theme->themeHint(QPlatformTheme::UnderlineShortcut).toInt() + : QPlatformTheme::defaultThemeHint(QPlatformTheme::UnderlineShortcut).toInt(); break; + } case SH_SpinBox_ClickAutoRepeatRate: ret = 150;