mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
Fix some issues
This commit is contained in:
parent
8964942305
commit
1346ffa526
3 changed files with 22 additions and 15 deletions
|
@ -150,9 +150,9 @@ class MainWebView(AnkiWebView):
|
||||||
return handled
|
return handled
|
||||||
|
|
||||||
if evt.type() == QEvent.Type.Leave:
|
if evt.type() == QEvent.Type.Leave:
|
||||||
if self.mw.pm.hide_top_bar():
|
|
||||||
# Show toolbar when mouse moves outside main webview
|
# Show toolbar when mouse moves outside main webview
|
||||||
# and automatically hide it with delay after mouse has entered again
|
# 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.toolbarWeb.show()
|
||||||
self.mw.bottomWeb.show()
|
self.mw.bottomWeb.show()
|
||||||
return True
|
return True
|
||||||
|
@ -161,9 +161,12 @@ class MainWebView(AnkiWebView):
|
||||||
if self.mw.pm.hide_top_bar():
|
if self.mw.pm.hide_top_bar():
|
||||||
self.mw.toolbarWeb.hide_timer.start()
|
self.mw.toolbarWeb.hide_timer.start()
|
||||||
self.mw.bottomWeb.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):
|
class AnkiQt(QMainWindow):
|
||||||
|
|
|
@ -325,7 +325,6 @@ class Reviewer:
|
||||||
self.web.allow_drops = True
|
self.web.allow_drops = True
|
||||||
self.web.eval("_blockDefaultDragDropBehavior();")
|
self.web.eval("_blockDefaultDragDropBehavior();")
|
||||||
# show answer / ease buttons
|
# show answer / ease buttons
|
||||||
self.bottom.web.show()
|
|
||||||
self.bottom.web.stdHtml(
|
self.bottom.web.stdHtml(
|
||||||
self._bottomHTML(),
|
self._bottomHTML(),
|
||||||
css=["css/toolbar-bottom.css", "css/reviewer-bottom.css"],
|
css=["css/toolbar-bottom.css", "css/reviewer-bottom.css"],
|
||||||
|
|
|
@ -50,19 +50,11 @@ class ToolbarWebView(AnkiWebView):
|
||||||
def show(self) -> None:
|
def show(self) -> None:
|
||||||
self.hidden = False
|
self.hidden = False
|
||||||
|
|
||||||
def hide_if_allowed(self) -> None:
|
|
||||||
if self.mw.state != "review":
|
|
||||||
return
|
|
||||||
|
|
||||||
if self.hide_condition():
|
|
||||||
self.hide()
|
|
||||||
|
|
||||||
|
|
||||||
class TopWebView(ToolbarWebView):
|
class TopWebView(ToolbarWebView):
|
||||||
def __init__(self, mw: aqt.AnkiQt, title: str) -> None:
|
def __init__(self, mw: aqt.AnkiQt, title: str) -> None:
|
||||||
super().__init__(mw, title=title)
|
super().__init__(mw, title=title)
|
||||||
self.web_height = 0
|
self.web_height = 0
|
||||||
self.hide_condition = self.mw.pm.hide_top_bar
|
|
||||||
qconnect(self.hide_timer.timeout, self.hide_if_allowed)
|
qconnect(self.hide_timer.timeout, self.hide_if_allowed)
|
||||||
|
|
||||||
def eventFilter(self, obj, evt):
|
def eventFilter(self, obj, evt):
|
||||||
|
@ -93,6 +85,13 @@ class TopWebView(ToolbarWebView):
|
||||||
super()._onHeight(qvar)
|
super()._onHeight(qvar)
|
||||||
self.web_height = int(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:
|
def hide(self) -> None:
|
||||||
super().hide()
|
super().hide()
|
||||||
|
|
||||||
|
@ -144,7 +143,6 @@ class TopWebView(ToolbarWebView):
|
||||||
class BottomWebView(ToolbarWebView):
|
class BottomWebView(ToolbarWebView):
|
||||||
def __init__(self, mw: aqt.AnkiQt, title: str) -> None:
|
def __init__(self, mw: aqt.AnkiQt, title: str) -> None:
|
||||||
super().__init__(mw, title=title)
|
super().__init__(mw, title=title)
|
||||||
self.hide_condition = self.mw.pm.hide_bottom_bar
|
|
||||||
qconnect(self.hide_timer.timeout, self.hide_if_allowed)
|
qconnect(self.hide_timer.timeout, self.hide_if_allowed)
|
||||||
|
|
||||||
def eventFilter(self, obj, evt):
|
def eventFilter(self, obj, evt):
|
||||||
|
@ -185,6 +183,13 @@ class BottomWebView(ToolbarWebView):
|
||||||
qconnect(self.animation.finished, lambda: self.setFixedHeight(int(qvar)))
|
qconnect(self.animation.finished, lambda: self.setFixedHeight(int(qvar)))
|
||||||
self.animation.start()
|
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:
|
def hide(self) -> None:
|
||||||
super().hide()
|
super().hide()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue