Skip to content

Commit 6206652

Browse files
committed
Fix tray icon and menu theming on macOS
1 parent 71d9bd3 commit 6206652

2 files changed

Lines changed: 28 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Fix webview blank page on macOS (#269 by @cantunborn)
1313
- Fix bundled compressonator on Linux (by @WillyJL)
1414
- Improve responsiveness when resuming drawing (by @cantunborn)
15+
- Fix tray icon and menu theming on macOS (by @cantunborn & @WillyJL)
1516

1617
### Removed:
1718
- Nothing

modules/gui.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -636,27 +636,28 @@ def refresh_styles(self):
636636
_ = \
637637
imgui.style.colors[imgui.COLOR_TEXT_DISABLED] = \
638638
globals.settings.style_text_dim
639-
self.qt_app.setStyleSheet(f"""
640-
QMenu {{
641-
padding: 5px;
642-
background-color: {colors.rgba_0_1_to_hex(globals.settings.style_bg)[:-2]};
643-
}}
644-
QMenu::item {{
645-
margin: 1px;
646-
padding: 2px 7px 2px 7px;
647-
border-radius: {globals.settings.style_corner_radius};
648-
color: {colors.rgba_0_1_to_hex(globals.settings.style_text)[:-2]};
649-
}}
650-
QMenu::item:disabled {{
651-
color: {colors.rgba_0_1_to_hex(globals.settings.style_text_dim)[:-2]};
652-
}}
653-
QMenu::item:selected:enabled {{
654-
background-color: {colors.rgba_0_1_to_hex(globals.settings.style_accent)[:-2]};
655-
}}
656-
QMenu::icon {{
657-
padding-left: 7px;
658-
}}
659-
""")
639+
if globals.os is not Os.MacOS:
640+
self.qt_app.setStyleSheet(f"""
641+
QMenu {{
642+
padding: 5px;
643+
background-color: {colors.rgba_0_1_to_hex(globals.settings.style_bg)[:-2]};
644+
}}
645+
QMenu::item {{
646+
margin: 1px;
647+
padding: 2px 7px 2px 7px;
648+
border-radius: {globals.settings.style_corner_radius};
649+
color: {colors.rgba_0_1_to_hex(globals.settings.style_text)[:-2]};
650+
}}
651+
QMenu::item:disabled {{
652+
color: {colors.rgba_0_1_to_hex(globals.settings.style_text_dim)[:-2]};
653+
}}
654+
QMenu::item:selected:enabled {{
655+
background-color: {colors.rgba_0_1_to_hex(globals.settings.style_accent)[:-2]};
656+
}}
657+
QMenu::icon {{
658+
padding-left: 7px;
659+
}}
660+
""")
660661

661662
def refresh_fonts(self):
662663
imgui.io.fonts.clear()
@@ -5361,7 +5362,8 @@ def update_pause(*_):
53615362
self.menu.addAction(self.toggle_pause)
53625363
self.menu.addAction(self.toggle_gui)
53635364
self.menu.addAction(self.quit)
5364-
self.setContextMenu(self.menu)
5365+
if globals.os is not Os.MacOS:
5366+
self.setContextMenu(self.menu)
53655367
self.menu_open = False
53665368
self.menu.aboutToShow.connect(self.showing_menu)
53675369
self.menu.aboutToHide.connect(self.hiding_menu)
@@ -5431,5 +5433,7 @@ def update_status(self, *_):
54315433
self.update_icon()
54325434

54335435
def activated_filter(self, reason: QtWidgets.QSystemTrayIcon.ActivationReason):
5434-
if reason in self.show_gui_events:
5436+
if globals.os is Os.MacOS and reason == QtWidgets.QSystemTrayIcon.ActivationReason.Context:
5437+
self.menu.popup(QtGui.QCursor.pos())
5438+
elif reason in self.show_gui_events:
54355439
self.main_gui.show()

0 commit comments

Comments
 (0)