Fix menubar in fullscreen (#3710)

* Fix/menubar in fullscreen

* CONTRIBUTORS file

* Fix/menubar in fullscreen

* CONTRIBUTORS file

* Fix and add Type hints
This commit is contained in:
Yuki 2025-01-10 12:18:32 +03:00 committed by GitHub
parent 53be365678
commit 9460911d90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 5 deletions

View file

@ -206,6 +206,8 @@ Lukas Sommer <sommerluk@gmail.com>
Niclas Heinz <nheinz@hpost.net>
Omar Kohl <omarkohl@posteo.net>
David Elizalde <david.elizalde.r.a@gmail.com>
Yuki <https://github.com/YukiNagat0>
********************
The text of the 3 clause BSD license follows:

View file

@ -147,17 +147,27 @@ class MainWebView(AnkiWebView):
return
# Main webview specific event handling
def eventFilter(self, obj, evt):
def eventFilter(self, obj: QObject | None, evt: QEvent | None) -> bool:
if handled := super().eventFilter(obj, evt):
return handled
if evt.type() == QEvent.Type.Leave:
handled_leave = False
# Show menubar when mouse moves outside main webview in fullscreen
if self.mw.fullscreen:
self.mw.show_menubar()
handled_leave = True
# Show toolbar when mouse moves outside main webview
# and automatically hide it with delay after mouse has entered again
# The toolbar's hide timer will also trigger menubar hiding when in fullscreen mode
if self.mw.pm.hide_top_bar() or self.mw.pm.hide_bottom_bar():
self.mw.toolbarWeb.show()
self.mw.bottomWeb.show()
return True
handled_leave = True
return handled_leave
if evt.type() == QEvent.Type.Enter:
self.mw.toolbarWeb.hide_timer.start()
@ -790,6 +800,9 @@ class AnkiQt(QMainWindow):
def _reviewState(self, oldState: MainWindowState) -> None:
self.reviewer.show()
if self.fullscreen:
self.hide_menubar()
if self.pm.hide_top_bar():
self.toolbarWeb.hide_timer.setInterval(500)
self.toolbarWeb.hide_timer.start()

View file

@ -98,6 +98,9 @@ class TopWebView(ToolbarWebView):
if self.mw.state != "review":
return
if self.mw.fullscreen:
self.mw.hide_menubar()
if self.mw.pm.hide_top_bar():
if (
self.mw.pm.top_bar_hide_mode() == HideMode.FULLSCREEN
@ -115,14 +118,11 @@ class TopWebView(ToolbarWebView):
self.eval(
"""document.body.classList.add("hidden"); """,
)
if self.mw.fullscreen:
self.mw.hide_menubar()
def show(self) -> None:
super().show()
self.eval("""document.body.classList.remove("hidden"); """)
self.mw.show_menubar()
def flatten(self) -> None:
self.eval("""document.body.classList.add("flat"); """)