Add QPlatformTheme::MenuBarFocusOnAltPressRelease

On Windows, pressing and releasing the Alt key moves focus to the
menubar. This is implemented in widgets, but not in Qt Quick.

Add a new theme hint so that we can make Qt behave natively on all
platforms, and make the common style's respective styleHint default to
the theme hint.

Change-Id: I101bec56afd51e81ebb128c288f8a1e9b7efedb4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Volker Hilsheimer 2022-10-21 22:42:36 +02:00
parent c3e2a624fb
commit a8c6958a87
4 changed files with 10 additions and 2 deletions

View File

@ -625,6 +625,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
return QVariant(2500);
case FlickDeceleration:
return QVariant(5000);
case MenuBarFocusOnAltPressRelease:
return false;
}
return QVariant();
}

View File

@ -91,7 +91,8 @@ public:
SetFocusOnTouchRelease,
FlickStartDistance,
FlickMaximumVelocity,
FlickDeceleration
FlickDeceleration,
MenuBarFocusOnAltPressRelease
};
Q_ENUM(ThemeHint)

View File

@ -558,6 +558,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
}
case MouseDoubleClickDistance:
return GetSystemMetrics(SM_CXDOUBLECLK);
case MenuBarFocusOnAltPressRelease:
return true;
default:
break;
}

View File

@ -5384,7 +5384,6 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_Menu_AllowActiveAndDisabled:
case SH_Menu_SpaceActivatesItem:
case SH_ScrollView_FrameOnlyAroundContents:
case SH_MenuBar_AltKeyNavigation:
case SH_ComboBox_ListMouseTracking:
case SH_Menu_MouseTracking:
case SH_MenuBar_MouseTracking:
@ -5410,6 +5409,10 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_Table_AlwaysDrawLeftTopGridLines:
ret = false;
break;
case SH_MenuBar_AltKeyNavigation:
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
ret = theme->themeHint(QPlatformTheme::MenuBarFocusOnAltPressRelease).toBool();
break;
case SH_CustomBase:
// Added to get compiler errors when a style hint is missing
ret = false;