From 63c2a09ef6760890c03be4bd83f613c03c512d1f Mon Sep 17 00:00:00 2001 From: Brayan Oliveira <69634269+BrayanDSO@users.noreply.github.com> Date: Mon, 3 Mar 2025 09:03:28 -0300 Subject: [PATCH] feat: add title to some of the sync dialogs (#3838) * refactor: accept window title in some dialog methods * feat: match sync initial title with state Sync iniates in the `Checked` state, so the initial title is changed to match it instead of using the generic `Anki` title * feat: use `Sync` as the tile of login screen Maybe a new string should be created for that. * feat: Use `Sync` as title of the sync conflict dialog Maybe a new string should be used for that * refactor: fix formatting * fix: alias in CONTRIBUTORS Even in 2025, the script isn't smart enough to handle different casing or use just the GitHub ID --- CONTRIBUTORS | 2 +- qt/aqt/progress.py | 3 ++- qt/aqt/sync.py | 4 +++- qt/aqt/taskman.py | 5 ++++- qt/aqt/utils.py | 2 ++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4c87854d2..0fb4726d2 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -98,7 +98,7 @@ gnnoh Sachin Govind Bruce Harris Patric Cunha -Brayan Oliveira +Brayan Oliveira Luka Warren wisherhxl dobefore <1432338032@qq.com> diff --git a/qt/aqt/progress.py b/qt/aqt/progress.py index 4d23b33f4..fbb0a7470 100644 --- a/qt/aqt/progress.py +++ b/qt/aqt/progress.py @@ -139,6 +139,7 @@ class ProgressManager: label: str | None = None, parent: QWidget | None = None, immediate: bool = False, + title: str = "Anki", ) -> ProgressDialog | None: self._levels += 1 if self._levels > 1: @@ -154,7 +155,7 @@ class ProgressManager: self._win.form.progressBar.setMaximum(max) self._win.form.progressBar.setTextVisible(False) self._win.form.label.setText(label) - self._win.setWindowTitle("Anki") + self._win.setWindowTitle(title) self._win.setWindowModality(Qt.WindowModality.ApplicationModal) self._win.setMinimumWidth(300) self._busy_cursor_timer = QTimer(self.mw) diff --git a/qt/aqt/sync.py b/qt/aqt/sync.py index 2b8bd59af..d044a70d4 100644 --- a/qt/aqt/sync.py +++ b/qt/aqt/sync.py @@ -131,6 +131,7 @@ def sync_collection(mw: aqt.main.AnkiQt, on_done: Callable[[], None]) -> None: on_future_done, label=tr.sync_checking(), immediate=True, + title=tr.sync_checking(), ) @@ -164,6 +165,7 @@ def full_sync( default_button=2, parent=mw, textFormat=Qt.TextFormat.MarkdownText, + title=tr.qt_misc_sync(), ) @@ -343,7 +345,7 @@ def get_id_and_pass_from_user( password: str = "", ) -> None: diag = QDialog(mw) - diag.setWindowTitle("Anki") + diag.setWindowTitle(tr.qt_misc_sync()) disable_help_button(diag) diag.setWindowModality(Qt.WindowModality.WindowModal) vbox = QVBoxLayout() diff --git a/qt/aqt/taskman.py b/qt/aqt/taskman.py index 8e38d0f97..b1e97637e 100644 --- a/qt/aqt/taskman.py +++ b/qt/aqt/taskman.py @@ -98,9 +98,12 @@ class TaskManager(QObject): label: str | None = None, immediate: bool = False, uses_collection=True, + title: str = "Anki", ) -> None: "Use QueryOp()/CollectionOp() in new code." - self.mw.progress.start(parent=parent, label=label, immediate=immediate) + self.mw.progress.start( + parent=parent, label=label, immediate=immediate, title=title + ) def wrapped_done(fut: Future) -> None: self.mw.progress.finish() diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index c53993372..19fd06b03 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -217,6 +217,7 @@ def ask_user_dialog( ) = None, default_button: int = 1, parent: QWidget | None = None, + title: str = "Anki", **kwargs: Any, ) -> MessageBox: "Shows a question to the user, passes the index of the button clicked to the callback." @@ -229,6 +230,7 @@ def ask_user_dialog( buttons=buttons, default_button=default_button, parent=parent, + title=title, **kwargs, )