From e1a4c5217537411b7e704f400cd0863394d63eee Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 3 Oct 2017 12:12:57 +1000 Subject: [PATCH] pass opts to main window; force zoom factor to 1 on lodpi --- aqt/__init__.py | 2 +- aqt/main.py | 3 ++- aqt/webview.py | 9 +++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/aqt/__init__.py b/aqt/__init__.py index 113e5d80c..3134df8d4 100644 --- a/aqt/__init__.py +++ b/aqt/__init__.py @@ -299,7 +299,7 @@ environment points to a valid, writable folder.""") # load the main window import aqt.main - mw = aqt.main.AnkiQt(app, pm, args) + mw = aqt.main.AnkiQt(app, pm, opts, args) if exec: app.exec() else: diff --git a/aqt/main.py b/aqt/main.py index eff067e99..b96040b4f 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -32,9 +32,10 @@ from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \ import sip class AnkiQt(QMainWindow): - def __init__(self, app, profileManager, args): + def __init__(self, app, profileManager, opts, args): QMainWindow.__init__(self) self.state = "startup" + self.opts = opts aqt.mw = self self.app = app self.pm = profileManager diff --git a/aqt/webview.py b/aqt/webview.py index ab3085991..5c141e589 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -73,8 +73,6 @@ class AnkiWebPage(QWebEnginePage): # Main web view ########################################################################## -dpiWarned = False - class AnkiWebView(QWebEngineView): def __init__(self, parent=None): @@ -159,9 +157,11 @@ class AnkiWebView(QWebEngineView): oldFocus.setFocus() def zoomFactor(self): - global dpiWarned + from aqt import mw if isMac: return 1 + if isWin and mw.opts.lodpi: + return 1 screen = QApplication.desktop().screen() dpi = screen.logicalDpiX() factor = dpi / 96.0 @@ -170,9 +170,6 @@ 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