Set locked status on window title when locked. Don't exit on incorrect key, let it be tried again
All checks were successful
CI / test (push) Successful in 4m35s
Lint / test (push) Successful in 31s
Trivy / test (push) Successful in 23s

This commit is contained in:
Miguel Jacq 2025-11-25 10:46:11 +11:00
parent 648031786a
commit 26737fbfb2
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
7 changed files with 11 additions and 21 deletions

View file

@ -1,6 +1,8 @@
# 0.4.6
* More Italian translations, thank you @mdaleo404
* Set locked status on window title when locked
* Don't exit on incorrect key, let it be tried again
# 0.4.5

View file

@ -85,7 +85,7 @@
"history_dialog_delete": "&Delete revision",
"history_dialog_delete_failed": "Could not delete revision",
"key_prompt_enter_key": "Enter key",
"lock_overlay_locked_due_to_inactivity": "Locked due to inactivity",
"lock_overlay_locked": "Locked",
"lock_overlay_unlock": "Unlock",
"main_window_lock_screen_accessibility": "&Lock screen",
"main_window_ready": "Ready",

View file

@ -69,7 +69,7 @@
"history_dialog_revert_to_selected": "Revenir à la sélection",
"history_dialog_revert_failed": "Échec de la restauration",
"key_prompt_enter_key": "Saisir la clé",
"lock_overlay_locked_due_to_inactivity": "Verrouillé pour cause dinactivité",
"lock_overlay_locked": "Verrouillé",
"lock_overlay_unlock": "Déverrouiller",
"main_window_ready": "Prêt",
"main_window_save_a_version": "Enregistrer une version",

View file

@ -69,7 +69,7 @@
"history_dialog_revert_to_selected": "Ripristina alla versione selezionata",
"history_dialog_revert_failed": "Ripristino fallito",
"key_prompt_enter_key": "Inserisci la chiave",
"lock_overlay_locked_due_to_inactivity": "Bloccato per inattività",
"lock_overlay_locked": "Bloccato",
"lock_overlay_unlock": "Sblocca",
"main_window_ready": "Pronto",
"main_window_save_a_version": "Salva versione",

View file

@ -21,7 +21,7 @@ class LockOverlay(QWidget):
lay = QVBoxLayout(self)
lay.addStretch(1)
msg = QLabel(strings._("lock_overlay_locked_due_to_inactivity"), self)
msg = QLabel(strings._("lock_overlay_locked"), self)
msg.setObjectName("lockLabel")
msg.setAlignment(Qt.AlignCenter)

View file

@ -371,7 +371,7 @@ class MainWindow(QMainWindow):
else:
error = str(e)
QMessageBox.critical(self, strings._("db_database_error"), error)
sys.exit(1)
return False
def _prompt_for_key_until_valid(self, first_time: bool) -> bool:
"""
@ -1691,6 +1691,8 @@ class MainWindow(QMainWindow):
tb.hide()
self._lock_overlay.show()
self._lock_overlay.raise_()
lock_msg = strings._("lock_overlay_locked")
self.setWindowTitle(f"{APP_NAME} ({lock_msg})")
@Slot()
def _on_unlock_clicked(self):
@ -1717,6 +1719,7 @@ class MainWindow(QMainWindow):
tb.show()
self._idle_timer.start()
QTimer.singleShot(0, self._focus_editor_now)
self.setWindowTitle(APP_NAME)
# ----------------- Close handlers ----------------- #
def closeEvent(self, event):

View file

@ -470,23 +470,8 @@ def test_try_connect_maps_errors(
mwmod.QMessageBox, "critical", staticmethod(fake_critical), raising=True
)
# Intercept sys.exit so the test process doesn't actually die
exited = {}
def fake_exit(code=0):
exited["code"] = code
# mimic real behaviour: raise SystemExit so callers see a fatal exit
raise SystemExit(code)
monkeypatch.setattr(mwmod.sys, "exit", fake_exit, raising=True)
# _try_connect should now raise SystemExit instead of returning
with pytest.raises(SystemExit):
w._try_connect()
# We attempted to exit with code 1
assert exited["code"] == 1
# And we still showed the right error message
assert "database" in shown["title"].lower()
if expect_key_msg: