Fix some issues

This commit is contained in:
Matthias Metelka 2023-01-14 03:38:47 +01:00
parent 8964942305
commit 1346ffa526
3 changed files with 22 additions and 15 deletions

View file

@ -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):

View file

@ -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"],

View file

@ -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()