From d5301342187602fb4008a70e8930c47b6aca328a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 2 Oct 2017 16:19:34 +1000 Subject: [PATCH] option to disable qt's hidpi scaling https://anki.tenderapp.com/discussions/beta-testing/765-problem-with-the-ui-of-anki --- aqt/__init__.py | 5 ++++- aqt/webview.py | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/aqt/__init__.py b/aqt/__init__.py index ccfde23b3..113e5d80c 100644 --- a/aqt/__init__.py +++ b/aqt/__init__.py @@ -223,6 +223,8 @@ def parseArgs(argv): parser.add_option("-b", "--base", help="path to base folder") parser.add_option("-p", "--profile", help="profile name to load") parser.add_option("-l", "--lang", help="interface language (en, de, etc)") + parser.add_option("--lodpi", action="store_true", dest="lodpi", + help="disable Qt's high DPI support") return parser.parse_args(argv[1:]) def run(): @@ -259,7 +261,8 @@ def _run(argv=None, exec=True): ctypes.CDLL('libGL.so.1', ctypes.RTLD_GLOBAL) # opt in to full hidpi support - QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) + if not opts.lodpi: + QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) # create the app app = AnkiApp(argv) diff --git a/aqt/webview.py b/aqt/webview.py index c9a3acdf9..ab3085991 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -6,7 +6,7 @@ import sys import math from anki.hooks import runHook from aqt.qt import * -from aqt.utils import openLink +from aqt.utils import openLink, showWarning from anki.utils import isMac, isWin, isLin, devMode # Page for debug messages @@ -73,6 +73,8 @@ class AnkiWebPage(QWebEnginePage): # Main web view ########################################################################## +dpiWarned = False + class AnkiWebView(QWebEngineView): def __init__(self, parent=None): @@ -157,6 +159,7 @@ class AnkiWebView(QWebEngineView): oldFocus.setFocus() def zoomFactor(self): + global dpiWarned if isMac: return 1 screen = QApplication.desktop().screen() @@ -167,6 +170,9 @@ class AnkiWebView(QWebEngineView): return factor # compensate for qt's integer scaling # on windows + if isWin and screen.physicalDpiX() % 72 != 0 and not dpiWarned: + showWarning("Unexpected physical DPI - try starting Anki with --lodpi") + dpiWarned = True qtIntScale = 72/screen.physicalDpiX() desiredScale = factor * qtIntScale newFactor = desiredScale / qtIntScale