From db30685b9ad02f858aa7cf47b41d3afb911c8ec4 Mon Sep 17 00:00:00 2001 From: Yuki <65764619+YukiNagat0@users.noreply.github.com> Date: Sun, 12 Jan 2025 07:46:20 +0300 Subject: [PATCH] Refactoring and comments (#3721) --- qt/aqt/main.py | 9 +++++++-- qt/aqt/toolbar.py | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/qt/aqt/main.py b/qt/aqt/main.py index 37876c2f7..cde6acbe6 100644 --- a/qt/aqt/main.py +++ b/qt/aqt/main.py @@ -800,15 +800,20 @@ class AnkiQt(QMainWindow): def _reviewState(self, oldState: MainWindowState) -> None: self.reviewer.show() - if self.fullscreen: - self.hide_menubar() + fullscreen_was_checked = False if self.pm.hide_top_bar(): self.toolbarWeb.hide_timer.setInterval(500) self.toolbarWeb.hide_timer.start() + + # check the `hide_if_allowed` method in `qt/aqt/toolbar.py` + fullscreen_was_checked = True else: self.toolbarWeb.flatten() + if not fullscreen_was_checked and self.fullscreen: + self.hide_menubar() + if self.pm.hide_bottom_bar(): self.bottomWeb.hide_timer.setInterval(500) self.bottomWeb.hide_timer.start() diff --git a/qt/aqt/toolbar.py b/qt/aqt/toolbar.py index ab40c510c..44f2ee66c 100644 --- a/qt/aqt/toolbar.py +++ b/qt/aqt/toolbar.py @@ -98,6 +98,9 @@ class TopWebView(ToolbarWebView): if self.mw.state != "review": return + # Invariant: The `hide_if_allowed` method ensures that the fullscreen state is checked + # and the menubar will be hidden if necessary + # Note: The `eventFilter` and `_reviewState` methods in `qt/aqt/main.py` rely on this invariant if self.mw.fullscreen: self.mw.hide_menubar()