Skip to content

Commit

Permalink
Merge pull request #177 from Yutsuten/bar-left-to-right
Browse files Browse the repository at this point in the history
Add option to invert bar movement
  • Loading branch information
Yutsuten authored Apr 18, 2024
2 parents c7cb6b8 + c106132 commit ea33da5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GlobalConf:
'globalSettingsShortcut', 'deckSettingsShortcut', 'pauseShortcut', 'recoverShortcut',
'behavUndo', 'behavBury', 'behavSuspend', 'stopOnLostFocus', 'shareDrain',
'barThresholdWarn', 'barFgColorWarn', 'barThresholdDanger', 'barFgColorDanger',
'startEmpty',
'startEmpty', 'invert',
}

def __init__(self, mw: AnkiQt):
Expand Down
4 changes: 3 additions & 1 deletion src/deck_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ def _update_progress_bar_style(self) -> None:
'borderRadius': conf['barBorderRadius'],
'text': conf['barText'],
'textColor': conf['barTextColor'],
'customStyle': conf['barStyle']}
'customStyle': conf['barStyle'],
'invert': conf['invert'],
}
if conf['enableBgColor']:
progress_bar_style['bgColor'] = conf['barBgColor']
self._progress_bar.set_style(progress_bar_style)
1 change: 1 addition & 0 deletions src/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'stopOnAnswer': False,
'stopOnLostFocus': True,
'startEmpty': False,
'invert': False,
'enable': True,
'enableBgColor': False,
'globalSettingsShortcut': 'Ctrl+Shift+L',
Expand Down
1 change: 1 addition & 0 deletions src/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def set_style(self, options: dict[str, Any]) -> None:
self._qprogressbar.setFormat(text_format['format'])
self._current_bar_color = ''
self._update_bar_color()
self._qprogressbar.setInvertedAppearance(options['invert'])

def dock_at(self, position_index: Literal[0, 1]) -> None:
"""Docks the bar at the specified position in the Anki window.
Expand Down
4 changes: 4 additions & 0 deletions src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def save() -> None:
'behavUndo': basic_tab.behavUndo.get_value(),
'behavBury': basic_tab.behavBury.get_value(),
'behavSuspend': basic_tab.behavSuspend.get_value(),
'invert': bar_style_tab.invert.get_value(),
'barPosition': bar_style_tab.positionList.get_value(),
'barHeight': bar_style_tab.heightInput.get_value(),
'barBorderRadius': bar_style_tab.borderRadiusInput.get_value(),
Expand Down Expand Up @@ -343,6 +344,8 @@ def _global_bar_style_tab(aqt: Any, conf: dict[str, Any]) -> Any:

def generate_form() -> Any:
tab = Form(aqt)
tab.check_box('invert', 'Invert bar movement',
'Reduce life from left to right instead of right to left.')
tab.combo_box('positionList', 'Position', POSITION_OPTIONS,
'Place to show the life bar.')
tab.spin_box('heightInput', 'Height', [1, 40],
Expand Down Expand Up @@ -373,6 +376,7 @@ def generate_form() -> Any:
return tab.widget

def load_data(widget: Any, conf: dict[str, Any]) -> None:
widget.invert.set_value(conf['invert'])
widget.positionList.set_value(conf['barPosition'])
widget.heightInput.set_value(conf['barHeight'])
widget.borderRadiusInput.set_value(conf['barBorderRadius'])
Expand Down

0 comments on commit ea33da5

Please sign in to comment.