feat: add color blind mode to preferences

This commit is contained in:
David Brenn 2025-08-06 16:12:07 +02:00
parent d3dad32067
commit cdeaf3875a
2 changed files with 24 additions and 0 deletions

View file

@ -146,6 +146,7 @@ class Preferences(QDialog):
form.render_latex.setChecked(editing.render_latex)
form.default_search_text.setText(editing.default_search_text)
form.backup_explanation.setText(
anki.lang.with_collapsed_whitespace(tr.preferences_backup_explanation())
)
@ -221,6 +222,7 @@ class Preferences(QDialog):
self.form.check_for_updates.setChecked(self.mw.pm.check_for_updates())
qconnect(self.form.check_for_updates.stateChanged, self.mw.pm.set_update_check)
self.update_login_status()
qconnect(self.form.syncLogout.clicked, self.sync_logout)
qconnect(self.form.syncLogin.clicked, self.sync_login)
@ -358,6 +360,8 @@ class Preferences(QDialog):
self.form.theme.setCurrentIndex(self.mw.pm.theme().value)
qconnect(self.form.theme.currentIndexChanged, self.on_theme_changed)
self.form.styleComboBox.addItems(["Anki"] + (["Native"] if not is_win else []))
self.form.styleComboBox.setCurrentIndex(self.mw.pm.get_widget_style())
qconnect(
@ -368,11 +372,25 @@ class Preferences(QDialog):
self.form.styleComboBox.setVisible(not is_win)
qconnect(self.form.resetWindowSizes.clicked, self.on_reset_window_sizes)
self.form.color_blind.setChecked(self.mw.pm.color_blind())
qconnect(self.form.color_blind.stateChanged, self.on_my_checkbox_changed)
self.setup_language()
self.setup_video_driver()
self.setupOptions()
def on_my_checkbox_changed(self, state: int) -> None:
print("color_blind state changed", state)
if state == 2:
# checkbox is checked
self.mw.pm.set_color_blind(True)
else:
# checkbox is unchecked
self.mw.pm.set_color_blind(False)
def update_global(self) -> None:
restart_required = False

View file

@ -535,6 +535,12 @@ create table if not exists profiles
def setUiScale(self, scale: float) -> None:
self.meta["uiScale"] = scale
def set_color_blind(self, value: bool) -> None:
self.meta["color_blind"] = value
def color_blind(self) -> bool:
return self.meta.get("color_blind", False)
def reduce_motion(self) -> bool:
return self.meta.get("reduce_motion", True)