Restore rejected settings toggles

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2026-08-19 11:07:07 +08:00
parent 078317cfc8
commit 7d87312d8d
+10 -1
View File
@@ -215,10 +215,11 @@ class _ToggleSettingsCard(_SettingsCard):
):
"""Initialize a persistent binary setting card."""
self.settingName = settingName
self._callback = callback
self.checkBox = AppQSwitch()
self.checkBox.syncChecked(AppSettings.isStateON_(settingName))
self.checkBox.toggled.connect(callback)
self.checkBox.toggled.connect(self._requestedState)
super().__init__(
iconFileName,
@@ -229,6 +230,12 @@ class _ToggleSettingsCard(_SettingsCard):
parent=parent,
)
@QtCore.Slot(bool)
def _requestedState(self, checked: bool):
"""Apply a requested setting and restore persisted state on failure."""
if self._callback(checked) is False:
self.sync()
def sync(self):
"""Refresh the control from persistent state without applying it."""
self.checkBox.syncChecked(AppSettings.isStateON_(self.settingName))
@@ -405,6 +412,8 @@ class _LanguageSettingsCard(_SettingsCard):
def __init__(self, title='', description='', parent=None):
"""Initialize the stable language-name selector."""
# These are intentional native-language representations (for example,
# "Русский" and "简体中文"), not strings in the active UI locale.
self.comboBox = QComboBox()
self.comboBox.setObjectName('SettingsComboBox')
self.comboBox.setMinimumWidth(180)