Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native menubar on macOS, not elsewhere (i.e. Linux) #695

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/python/main/ayab/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# https://github.com/AllYarnsAreBeautiful/ayab-desktop

from __future__ import annotations
from PySide6.QtCore import QOperatingSystemVersion
from PySide6.QtWidgets import QMenuBar

from .menu_gui import Ui_MenuBar
Expand All @@ -38,6 +39,11 @@ class Menu(QMenuBar):

def __init__(self, parent: GuiMain):
super().__init__(parent)

# Use native menubar on macOS, not elsewhere (i.e. Linux)
if QOperatingSystemVersion.currentType() != QOperatingSystemVersion.OSType.MacOS:
self.setNativeMenuBar(False)

self.ui = Ui_MenuBar()
self.ui.setupUi(self)
self.setup()
Expand Down
12 changes: 9 additions & 3 deletions src/main/python/main/ayab/menu_gui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<ui version="4.0">
<class>MenuBar</class>
<widget class="QMenuBar" name="menubar">
<property name="nativeMenuBar">
<bool>False</bool>
</property>
<widget class="QMenu" name="menu_file">
<property name="title">
<string>File</string>
Expand Down Expand Up @@ -68,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 @@ -99,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 @@ -192,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