Skip to content

Commit

Permalink
Add menu roles for better mac menus
Browse files Browse the repository at this point in the history
Adding "menuRole" properties to standard menu actions (About,
Preferences, Quit) lets Qt move them to their standard place in the
macOS menu bar (without having to rely on their text content, which
breaks when localizing). This also automatically sets the "Preferences"
shortcut to the standard "Cmd+," instead of "Cmd+P".

This should have no impact on other platforms.

See https://doc.qt.io/qt-6/qmenubar.html#qmenubar-as-a-global-menu-bar
  • Loading branch information
jonathanperret committed Aug 1, 2024
1 parent 17a4703 commit bda83d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/python/main/ayab/menu_gui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<property name="shortcut">
<string notr="true">Ctrl+Q</string>
</property>
<property name="menuRole">
<enum>QAction::QuitRole</enum>
</property>
</action>
<action name="action_load_AYAB_firmware">
<property name="text">
Expand Down Expand Up @@ -96,6 +99,9 @@
<property name="text">
<string>Help – About</string>
</property>
<property name="menuRole">
<enum>QAction::AboutRole</enum>
</property>
</action>
<action name="action_help">
<property name="text">
Expand Down Expand Up @@ -189,6 +195,9 @@
<property name="shortcut">
<string notr="true">Ctrl+P</string>
</property>
<property name="menuRole">
<enum>QAction::PreferencesRole</enum>
</property>
</action>
</widget>
<resources/>
Expand Down

0 comments on commit bda83d4

Please sign in to comment.