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 <richard.gustavsen@qt.io>
bb10
Noah Davis 2022-02-09 10:29:33 -05:00
parent 9beca76786
commit 97eeded5fc
2 changed files with 5 additions and 0 deletions

View File

@ -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<Qt::Key>) 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>({ Qt::Key_Space, Qt::Key_Select }));
}
return QVariant();
}

View File

@ -123,6 +123,7 @@ public:
InteractiveResizeAcrossScreens,
ShowDirectoriesFirst,
PreselectFirstFileInDirectory,
ButtonPressKeys
};
Q_ENUM(ThemeHint)