Skip to content

Commit

Permalink
Merge pull request #107 from Alexhuszagh/issue_106
Browse files Browse the repository at this point in the history
Improve handling of stylesheet aliases.
  • Loading branch information
Alexhuszagh authored Sep 8, 2024
2 parents d850c32 + 513a4d8 commit 467e679
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"*.qss.in": "qss",
"*.svg.in": "xml",
"stdexcept": "cpp"
}
}
},
"cmake.ignoreCMakeListsMissing": true
}
20 changes: 15 additions & 5 deletions example/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,28 @@ def parse_args(parser):
os.environ['XDG_SESSION_TYPE'] = 'x11'
os.environ['QT_QPA_PLATFORM'] = 'xcb'

args.stylesheet = normalize_stylesheet(args.stylesheet)
return args, unknown


def normalize_stylesheet(stylesheet):
'''Normalize the stylesheet, removing and normalizing any aliases.'''

# now we need to normalize our theme
if args.stylesheet.startswith('auto'):
if stylesheet.startswith('auto'):
theme = breeze_theme.get_theme()
if theme == breeze_theme.Theme.DARK:
args.stylesheet = args.stylesheet.replace('auto', 'dark', 1)
stylesheet = stylesheet.replace('auto', 'dark', 1)
elif theme == breeze_theme.Theme.LIGHT:
args.stylesheet = args.stylesheet.replace('auto', 'light', 1)
stylesheet = stylesheet.replace('auto', 'light', 1)
else:
logging.warning('Unknown an unknown system theme, falling back to the system native theme.')
args.stylesheet = 'native'
stylesheet = 'native'

return args, unknown
# Needed so we remove any aliases. See #106.
if stylesheet in ('dark-blue', 'light-blue'):
stylesheet = stylesheet[: len('-blue') - 1]
return stylesheet


def is_qt6(args):
Expand Down

0 comments on commit 467e679

Please sign in to comment.