From 1bf5470778364369a7b519ca5d074ca73529e7e4 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 28 Sep 2022 16:21:59 +0300 Subject: Make SetFocusOnTouchRelease style hint themeable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So it could be set by e.g. Plasma Mobile. Change-Id: I067bd1356a61dbbf330530ef82565486d2e862a6 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformintegration.cpp | 2 +- src/gui/kernel/qplatformtheme.cpp | 8 ++++++++ src/gui/kernel/qplatformtheme.h | 3 ++- src/gui/kernel/qstylehints.cpp | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 4d4f501ae4..29dfba8155 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -393,7 +393,7 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const case UseRtlExtensions: return QVariant(false); case SetFocusOnTouchRelease: - return QVariant(false); + return QPlatformTheme::defaultThemeHint(QPlatformTheme::SetFocusOnTouchRelease); case MousePressAndHoldInterval: return QPlatformTheme::defaultThemeHint(QPlatformTheme::MousePressAndHoldInterval); case TabFocusBehavior: diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 993836fa59..10cf8e0ca4 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -143,6 +143,10 @@ QT_BEGIN_NAMESPACE \value ButtonPressKeys (QList) A list of keys that can be used to press buttons via keyboard input. + \value SetFocusOnTouchRelease (bool) Whether focus objects (line edits etc) should receive + input focus after a touch/mouse release. + This enum value has been added in Qt 6.5. + \sa themeHint(), QStyle::pixelMetric() */ @@ -507,6 +511,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects); case QPlatformTheme::ShowShortcutsInContextMenus: return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus); + case QPlatformTheme::SetFocusOnTouchRelease: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SetFocusOnTouchRelease); default: return QPlatformTheme::defaultThemeHint(hint); } @@ -605,6 +611,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return false; case ButtonPressKeys: return QVariant::fromValue(QList({ Qt::Key_Space, Qt::Key_Select })); + case SetFocusOnTouchRelease: + return false; } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 94d9a82fd3..11f57dab20 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -87,7 +87,8 @@ public: InteractiveResizeAcrossScreens, ShowDirectoriesFirst, PreselectFirstFileInDirectory, - ButtonPressKeys + ButtonPressKeys, + SetFocusOnTouchRelease }; Q_ENUM(ThemeHint) diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 8374379d5a..f932caaae5 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -445,7 +445,7 @@ bool QStyleHints::useRtlExtensions() const */ bool QStyleHints::setFocusOnTouchRelease() const { - return hint(QPlatformIntegration::SetFocusOnTouchRelease).toBool(); + return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool(); } /*! -- cgit v1.2.3