diff --git a/picard/tagger.py b/picard/tagger.py index 7b47b6d85..005b32242 100644 --- a/picard/tagger.py +++ b/picard/tagger.py @@ -192,7 +192,6 @@ class Tagger(QtWidgets.QApplication): self.__class__.__instance = self setup_config(self, picard_args.config_file) config = get_config() - self.setStyle(OverrideStyle()) theme.setup(self) self._cmdline_files = picard_args.FILE @@ -1051,19 +1050,6 @@ def process_picard_args(): return parser.parse_known_args()[0] -class OverrideStyle(QtWidgets.QProxyStyle): - """Override the default style to fix some platform specific issues""" - - def styleHint(self, hint, option, widget, returnData): - # This is disabled on macOS, but prevents collapsing tree view items easily with - # left arrow key. Enable this consistently on all platforms. - # See https://tickets.metabrainz.org/browse/PICARD-2417 - # and https://bugreports.qt.io/browse/QTBUG-100305 - if hint == QtWidgets.QStyle.StyleHint.SH_ItemView_ArrowKeysNavigateIntoChildren: - return True - return super().styleHint(hint, option, widget, returnData) - - def main(localedir=None, autoupdate=True): # Some libs (ie. Phonon) require those to be set QtWidgets.QApplication.setApplicationName(PICARD_APP_NAME) diff --git a/picard/ui/theme.py b/picard/ui/theme.py index 8784e1f6d..e7bd564e6 100644 --- a/picard/ui/theme.py +++ b/picard/ui/theme.py @@ -27,6 +27,7 @@ from enum import Enum from PyQt5 import ( QtCore, QtGui, + QtWidgets, ) from picard import log @@ -91,6 +92,19 @@ dark_syntax_theme = SyntaxTheme( ) +class MacOverrideStyle(QtWidgets.QProxyStyle): + """Override the default style to fix some platform specific issues""" + + def styleHint(self, hint, option, widget, returnData): + # This is disabled on macOS, but prevents collapsing tree view items easily with + # left arrow key. Enable this consistently on all platforms. + # See https://tickets.metabrainz.org/browse/PICARD-2417 + # and https://bugreports.qt.io/browse/QTBUG-100305 + if hint == QtWidgets.QStyle.StyleHint.SH_ItemView_ArrowKeysNavigateIntoChildren: + return True + return super().styleHint(hint, option, widget, returnData) + + class BaseTheme: def __init__(self): self._dark_theme = False @@ -104,6 +118,8 @@ class BaseTheme: # across all OSes. if not IS_MACOS and not IS_HAIKU and self._loaded_config_theme != UiTheme.SYSTEM: app.setStyle('Fusion') + elif IS_MACOS: + app.setStyle(MacOverrideStyle(app.style())) app.setStyleSheet( 'QGroupBox::title { /* PICARD-1206, Qt bug workaround */ }'