From 7327f77dec3701ddeb18dd186c0f8bef86d43e5f Mon Sep 17 00:00:00 2001 From: Matthias Metelka <62722460+kleinerpirat@users.noreply.github.com> Date: Sun, 15 Jan 2023 17:58:35 +0100 Subject: [PATCH] Fix top toolbar getting huge when switching modes The issue was caused by the min-height hack to align the background images. A call to web.adjustHeightToFit would set the toolbar to the same height as the main webview, as the function makes use of document.offsetHeight. --- qt/aqt/toolbar.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qt/aqt/toolbar.py b/qt/aqt/toolbar.py index c9a7b9e7e..9364701ba 100644 --- a/qt/aqt/toolbar.py +++ b/qt/aqt/toolbar.py @@ -153,7 +153,6 @@ class TopWebView(ToolbarWebView): f"""document.body.style.setProperty("background-position-y", "-{self.web_height}px"); """ ) - self.mw.web.evalWithCallback( """window.getComputedStyle(document.body).background; """, set_background, @@ -163,7 +162,11 @@ class TopWebView(ToolbarWebView): self.eval( f"""document.body.style.setProperty("min-height", "{self.mw.web.height()}px"); """ ) - + + def adjustHeightToFit(self) -> None: + self.eval("""document.body.style.setProperty("min-height", "0px"); """) + self.evalWithCallback("document.documentElement.offsetHeight", self._onHeight) + def resizeEvent(self, event: QResizeEvent) -> None: super().resizeEvent(event)