From a57b9134505a593f1e5245bd7ad92f811319be46 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 10 Aug 2017 15:02:46 +1000 Subject: [PATCH] opt in to qt's full hidpi support doesn't seem to affect the webviews on Linux, so we need to keep the old zoom code around for now --- aqt/__init__.py | 3 +++ aqt/webview.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/aqt/__init__.py b/aqt/__init__.py index a0707a191..e8dadf58d 100644 --- a/aqt/__init__.py +++ b/aqt/__init__.py @@ -214,6 +214,9 @@ def _run(): import ctypes ctypes.CDLL('libGL.so.1', ctypes.RTLD_GLOBAL) + # opt in to full hidpi support + QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) + # create the app app = AnkiApp(sys.argv) QCoreApplication.setApplicationName("Anki") diff --git a/aqt/webview.py b/aqt/webview.py index 0a6341d26..09d438c81 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -6,7 +6,7 @@ import sys from anki.hooks import runHook from aqt.qt import * from aqt.utils import openLink -from anki.utils import isMac, isWin, devMode +from anki.utils import isMac, isWin, isLin, devMode # Page for debug messages ########################################################################## @@ -151,7 +151,10 @@ class AnkiWebView(QWebEngineView): if oldFocus: oldFocus.setFocus() + # need to do this manually for Linux as Qt doesn't automatically scale webview def zoomFactor(self): + if not isLin: + return 1 screen = QApplication.desktop().screen() dpi = screen.logicalDpiX() return max(1, dpi / 96.0)