mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Fix bottom toolbar animating on startup
Also fix bottom toolbar not appearing when unchecking hide mode in reviewer.
This commit is contained in:
parent
84bd035dc8
commit
274914f2e1
3 changed files with 17 additions and 16 deletions
|
@ -708,7 +708,7 @@ class AnkiQt(QMainWindow):
|
|||
gui_hooks.state_will_change(state, oldState)
|
||||
getattr(self, f"_{state}State", lambda *_: None)(oldState, *args)
|
||||
if state != "resetRequired":
|
||||
self.bottomWeb.show()
|
||||
self.bottomWeb.adjustHeightToFit()
|
||||
gui_hooks.state_did_change(state, oldState)
|
||||
|
||||
def _deckBrowserState(self, oldState: MainWindowState) -> None:
|
||||
|
|
|
@ -552,6 +552,7 @@ create table if not exists profiles
|
|||
|
||||
def set_hide_bottom_bar(self, on: bool) -> None:
|
||||
self.meta["hide_bottom_bar"] = on
|
||||
gui_hooks.body_classes_need_update()
|
||||
|
||||
def bottom_bar_hide_mode(self) -> HideMode:
|
||||
return self.meta.get("bottom_bar_hide_mode", HideMode.FULLSCREEN)
|
||||
|
|
|
@ -77,7 +77,6 @@ class TopWebView(ToolbarWebView):
|
|||
|
||||
def on_body_classes_need_update(self) -> None:
|
||||
super().on_body_classes_need_update()
|
||||
self.adjustHeightToFit()
|
||||
|
||||
if self.mw.state == "review":
|
||||
if self.mw.pm.hide_top_bar():
|
||||
|
@ -194,19 +193,14 @@ class BottomWebView(ToolbarWebView):
|
|||
|
||||
def on_body_classes_need_update(self) -> None:
|
||||
super().on_body_classes_need_update()
|
||||
if self.mw.state == "review":
|
||||
self.show()
|
||||
|
||||
self.adjustHeightToFit()
|
||||
self.show()
|
||||
|
||||
def _onHeight(self, qvar: Optional[int]) -> None:
|
||||
self.web_height = int(qvar)
|
||||
|
||||
if qvar is None:
|
||||
self.mw.progress.single_shot(1000, self.mw.reset)
|
||||
return
|
||||
def animate_height(self, height: int) -> None:
|
||||
self.web_height = height
|
||||
|
||||
if self.mw.pm.reduce_motion():
|
||||
self.setFixedHeight(int(qvar))
|
||||
self.setFixedHeight(height)
|
||||
else:
|
||||
# Collapse/Expand animation
|
||||
self.setMinimumHeight(0)
|
||||
|
@ -215,8 +209,8 @@ class BottomWebView(ToolbarWebView):
|
|||
)
|
||||
self.animation.setDuration(int(theme_manager.var(props.TRANSITION)))
|
||||
self.animation.setStartValue(self.height())
|
||||
self.animation.setEndValue(int(qvar))
|
||||
qconnect(self.animation.finished, lambda: self.setFixedHeight(int(qvar)))
|
||||
self.animation.setEndValue(height)
|
||||
qconnect(self.animation.finished, lambda: self.setFixedHeight(height))
|
||||
self.animation.start()
|
||||
|
||||
def hide_if_allowed(self) -> None:
|
||||
|
@ -236,13 +230,19 @@ class BottomWebView(ToolbarWebView):
|
|||
def hide(self) -> None:
|
||||
super().hide()
|
||||
|
||||
self._onHeight(1)
|
||||
self.hidden = True
|
||||
self.animate_height(1)
|
||||
|
||||
def show(self) -> None:
|
||||
super().show()
|
||||
|
||||
self.hidden = False
|
||||
self.adjustHeightToFit()
|
||||
if self.mw.state == "review":
|
||||
self.evalWithCallback(
|
||||
"document.documentElement.offsetHeight", self.animate_height
|
||||
)
|
||||
else:
|
||||
self.adjustHeightToFit()
|
||||
|
||||
|
||||
class Toolbar:
|
||||
|
|
Loading…
Reference in a new issue