diff options
author | Kai Uwe Broulik <[email protected]> | 2025-01-30 18:10:28 +0100 |
---|---|---|
committer | Kai Uwe Broulik <[email protected]> | 2025-02-04 17:05:35 +0100 |
commit | acb8252d0abf5cf0c7166312f180d5d325f6ccd6 (patch) | |
tree | 7b84393da0e91bb42020b43319535d10cd94e505 | |
parent | 9afc899a300de35793e77d1ce080cf98c991d7c6 (diff) |
QStyleHints: Add menuSelectionWraps
This lifts QStyle::SH_Menu_SelectionWrap to Qt GUI so it
can also be honored from Qt Quick Controls.
Change-Id: I78eb2dd9fe6ad9329d40f7962bf7ad5f07dd4685
Reviewed-by: Richard Moe Gustavsen <[email protected]>
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.cpp | 14 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.mm | 2 | ||||
-rw-r--r-- | src/plugins/styles/mac/qmacstyle_mac.mm | 3 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 7 |
7 files changed, 31 insertions, 5 deletions
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index eb7a6074cf2..26cb075ca8d 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -122,6 +122,11 @@ QT_BEGIN_NAMESPACE \value ContextMenuOnMouseRelease (bool) Whether the context menu should be shown on mouse release. + \value MenuSelectionWraps (bool) Determines whether menu selection wraps. That is, whether key navigation moves + the selection to the first menu item again after the last menu item has been + reached, and vice versa. + This enum value was added in Qt 6.10. + \value TouchDoubleTapDistance (int) The maximum distance in logical pixels which a touchpoint can travel between taps in order for the tap sequence to be handled as a double tap. The default value is double the MouseDoubleClickDistance, or 10 logical pixels @@ -684,6 +689,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return true; case PreferFileIconFromTheme: return false; + case MenuSelectionWraps: + return true; } return QVariant(); diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index e86cb5269fb..a81d0624db3 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -99,6 +99,7 @@ public: UnderlineShortcut, ShowIconsInMenus, PreferFileIconFromTheme, + MenuSelectionWraps, }; Q_ENUM(ThemeHint) diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 73c61997330..174aa10be23 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -477,6 +477,20 @@ void QStyleHints::setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigge } /*! + \property QStyleHints::menuSelectionWraps + \since 6.10 + \brief menu selection wraps around. + + Returns \c true if menu selection wraps. That is, whether key navigation moves + the selection to the first menu item again after the last menu item has been + reached, and vice versa. +*/ +bool QStyleHints::menuSelectionWraps() const +{ + return themeableHint(QPlatformTheme::MenuSelectionWraps).toBool(); +} + +/*! \property QStyleHints::passwordMaskDelay \brief the time, in milliseconds, a typed letter is displayed unshrouded in a text input field in password mode. diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index 97ef59f3cf5..0f68f544ac6 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -56,6 +56,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject Q_PROPERTY(int touchDoubleTapDistance READ touchDoubleTapDistance STORED false CONSTANT FINAL) Q_PROPERTY(Qt::ColorScheme colorScheme READ colorScheme WRITE setColorScheme RESET unsetColorScheme NOTIFY colorSchemeChanged FINAL) + Q_PROPERTY(bool menuSelectionWraps READ menuSelectionWraps STORED false CONSTANT FINAL REVISION(6, 10)) public: void setMouseDoubleClickInterval(int mouseDoubleClickInterval); @@ -84,6 +85,7 @@ public: void setShowShortcutsInContextMenus(bool showShortcutsInContextMenus); Qt::ContextMenuTrigger contextMenuTrigger() const; void setContextMenuTrigger(Qt::ContextMenuTrigger contextMenuTrigger); + bool menuSelectionWraps() const; int passwordMaskDelay() const; QChar passwordMaskCharacter() const; qreal fontSmoothingGamma() const; diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 6d15e8e5d2c..507c5d775f9 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -466,6 +466,8 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const return 1.0 / NSEvent.keyRepeatInterval; case QPlatformTheme::ShowIconsInMenus: return false; + case QPlatformTheme::MenuSelectionWraps: + return false; default: break; } diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 7d2d4560703..30e729202f8 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2526,9 +2526,6 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_DialogButtonBox_ButtonsHaveIcons: ret = 0; break; - case SH_Menu_SelectionWrap: - ret = false; - break; case SH_Menu_KeyboardSearch: ret = true; break; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index de3b1cd60ec..4f78c8d7072 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5192,9 +5192,12 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = 75; break; - case SH_Menu_SelectionWrap: - ret = true; + case SH_Menu_SelectionWrap: { + const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); + ret = theme ? theme->themeHint(QPlatformTheme::MenuSelectionWraps).toInt() + : QPlatformTheme::defaultThemeHint(QPlatformTheme::MenuSelectionWraps).toInt(); break; + } case SH_Menu_FillScreenWithScroll: ret = true; |