Skip to content

Commit 1e73ab9

Browse files
authored
Merge pull request #185 from Yutsuten/fix-style-index-error
Use default bar style if custom style isn't found
2 parents d7a8903 + 4f172fe commit 1e73ab9

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/progress_bar.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,14 @@ def _update_bar_color(self) -> None:
185185
return
186186

187187
self._current_bar_color = bar_color
188-
if options['customStyle']:
189-
available_styles = ['default', *self._qt.QStyleFactory.keys()]
190-
custom_style = available_styles[options['customStyle']]
188+
available_styles = self._qt.QStyleFactory.keys()
191189

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

195194
palette = self._qt.QPalette()
196-
fg_color = self._qt.QColor(bar_color)
197-
palette.setColor(self._qt.QPalette.ColorRole.Highlight, fg_color)
195+
palette.setColor(self._qt.QPalette.ColorRole.Highlight, self._qt.QColor(bar_color))
198196

199197
if 'bgColor' in options:
200198
bg_color = self._qt.QColor(options['bgColor'])

src/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def generate_form() -> Any:
381381
tab.spin_box('borderRadiusInput', 'Border radius', [0, 20],
382382
'Add a rounded border to the life bar.')
383383
tab.combo_box('styleList', 'Style', ['Default', *aqt.QStyleFactory.keys()], '''Style of \
384-
the life bar.''')
384+
the life bar. Custom styles coloring may only work after a restart.''')
385385
tab.color_select('fgColor', 'Bar color (default)',
386386
"Color of the life bar's foreground.")
387387
tab.spin_box('thresholdWarn', 'Warn threshold (%)', [0, 99],

0 commit comments

Comments
 (0)