Skip to content

Commit

Permalink
Merge pull request #185 from Yutsuten/fix-style-index-error
Browse files Browse the repository at this point in the history
Use default bar style if custom style isn't found
  • Loading branch information
Yutsuten authored Dec 3, 2024
2 parents d7a8903 + 4f172fe commit 1e73ab9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,14 @@ def _update_bar_color(self) -> None:
return

self._current_bar_color = bar_color
if options['customStyle']:
available_styles = ['default', *self._qt.QStyleFactory.keys()]
custom_style = available_styles[options['customStyle']]
available_styles = self._qt.QStyleFactory.keys()

qstyle = self._qt.QStyleFactory.create(custom_style)
if options['customStyle'] and options['customStyle'] <= len(available_styles):
qstyle = self._qt.QStyleFactory.create(available_styles[options['customStyle'] - 1])
self._qprogressbar.setStyle(qstyle)

palette = self._qt.QPalette()
fg_color = self._qt.QColor(bar_color)
palette.setColor(self._qt.QPalette.ColorRole.Highlight, fg_color)
palette.setColor(self._qt.QPalette.ColorRole.Highlight, self._qt.QColor(bar_color))

if 'bgColor' in options:
bg_color = self._qt.QColor(options['bgColor'])
Expand Down
2 changes: 1 addition & 1 deletion src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def generate_form() -> Any:
tab.spin_box('borderRadiusInput', 'Border radius', [0, 20],
'Add a rounded border to the life bar.')
tab.combo_box('styleList', 'Style', ['Default', *aqt.QStyleFactory.keys()], '''Style of \
the life bar.''')
the life bar. Custom styles coloring may only work after a restart.''')
tab.color_select('fgColor', 'Bar color (default)',
"Color of the life bar's foreground.")
tab.spin_box('thresholdWarn', 'Warn threshold (%)', [0, 99],
Expand Down

0 comments on commit 1e73ab9

Please sign in to comment.