From 97eeded5fc8c8ebb476ed4a10d8726dd4d46f181 Mon Sep 17 00:00:00 2001 From: Noah Davis Date: Wed, 9 Feb 2022 10:29:33 -0500 Subject: [PATCH] QPA: add ButtonPressKeys ThemeHint Platforms should allow more than just Qt::Key_Space and Qt::Key_Select to press buttons. KDE Plasma developers want to be able to press buttons with Return/Enter. GTK allows buttons to be pressed with Return/Enter, so this should be considered the native behavior for GNOME as well. Adding this ThemeHint allows customizing the keys that can press a button via a QPlatformTheme subclass. Change-Id: I73284e9b73590fbdd0b94a0cb4557e94b3722af9 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qplatformtheme.cpp | 4 ++++ src/gui/kernel/qplatformtheme.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 01a5e2c806..a675ff1dc5 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -175,6 +175,8 @@ QT_BEGIN_NAMESPACE should be automatically selected when a file dialog opens. This enum value was added in Qt 6.3. + \value ButtonPressKeys (QList) A list of keys that can be used to press buttons via keyboard input. + \sa themeHint(), QStyle::pixelMetric() */ @@ -586,6 +588,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return true; case PreselectFirstFileInDirectory: return false; + case ButtonPressKeys: + return QVariant::fromValue(QList({ Qt::Key_Space, Qt::Key_Select })); } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index a6b3709548..398ea2eae1 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -123,6 +123,7 @@ public: InteractiveResizeAcrossScreens, ShowDirectoriesFirst, PreselectFirstFileInDirectory, + ButtonPressKeys }; Q_ENUM(ThemeHint)