From 1346ffa5264ef83438ebf4bdc1910a457c7d0867 Mon Sep 17 00:00:00 2001 From: Matthias Metelka <62722460+kleinerpirat@users.noreply.github.com> Date: Sat, 14 Jan 2023 03:38:47 +0100 Subject: [PATCH] Fix some issues --- qt/aqt/main.py | 13 ++++++++----- qt/aqt/reviewer.py | 1 - qt/aqt/toolbar.py | 23 ++++++++++++++--------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/qt/aqt/main.py b/qt/aqt/main.py index 11724da9a..9d4bbc62f 100644 --- a/qt/aqt/main.py +++ b/qt/aqt/main.py @@ -150,9 +150,9 @@ class MainWebView(AnkiWebView): return handled if evt.type() == QEvent.Type.Leave: - if self.mw.pm.hide_top_bar(): - # Show toolbar when mouse moves outside main webview - # and automatically hide it with delay after mouse has entered again + # Show toolbar when mouse moves outside main webview + # and automatically hide it with delay after mouse has entered again + if self.mw.pm.hide_top_bar() or self.mw.pm.hide_bottom_bar(): self.mw.toolbarWeb.show() self.mw.bottomWeb.show() return True @@ -161,9 +161,12 @@ class MainWebView(AnkiWebView): if self.mw.pm.hide_top_bar(): self.mw.toolbarWeb.hide_timer.start() self.mw.bottomWeb.hide_timer.start() - return True + handled = True + if self.mw.pm.hide_bottom_bar(): + self.mw.bottomWeb.hide_timer.start() + handled = True - return False + return handled class AnkiQt(QMainWindow): diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index 2a6a5ec8f..eb7e1232a 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -325,7 +325,6 @@ class Reviewer: self.web.allow_drops = True self.web.eval("_blockDefaultDragDropBehavior();") # show answer / ease buttons - self.bottom.web.show() self.bottom.web.stdHtml( self._bottomHTML(), css=["css/toolbar-bottom.css", "css/reviewer-bottom.css"], diff --git a/qt/aqt/toolbar.py b/qt/aqt/toolbar.py index 476093a27..ab862daec 100644 --- a/qt/aqt/toolbar.py +++ b/qt/aqt/toolbar.py @@ -50,19 +50,11 @@ class ToolbarWebView(AnkiWebView): def show(self) -> None: self.hidden = False - def hide_if_allowed(self) -> None: - if self.mw.state != "review": - return - - if self.hide_condition(): - self.hide() - class TopWebView(ToolbarWebView): def __init__(self, mw: aqt.AnkiQt, title: str) -> None: super().__init__(mw, title=title) self.web_height = 0 - self.hide_condition = self.mw.pm.hide_top_bar qconnect(self.hide_timer.timeout, self.hide_if_allowed) def eventFilter(self, obj, evt): @@ -93,6 +85,13 @@ class TopWebView(ToolbarWebView): super()._onHeight(qvar) self.web_height = int(qvar) + def hide_if_allowed(self) -> None: + if self.mw.state != "review": + return + + if self.mw.pm.hide_top_bar(): + self.hide() + def hide(self) -> None: super().hide() @@ -144,7 +143,6 @@ class TopWebView(ToolbarWebView): class BottomWebView(ToolbarWebView): def __init__(self, mw: aqt.AnkiQt, title: str) -> None: super().__init__(mw, title=title) - self.hide_condition = self.mw.pm.hide_bottom_bar qconnect(self.hide_timer.timeout, self.hide_if_allowed) def eventFilter(self, obj, evt): @@ -185,6 +183,13 @@ class BottomWebView(ToolbarWebView): qconnect(self.animation.finished, lambda: self.setFixedHeight(int(qvar))) self.animation.start() + def hide_if_allowed(self) -> None: + if self.mw.state != "review": + return + + if self.mw.pm.hide_bottom_bar(): + self.hide() + def hide(self) -> None: super().hide()