pass opts to main window; force zoom factor to 1 on lodpi

This commit is contained in:
Damien Elmes 2017-10-03 12:12:57 +10:00
parent 3407feeceb
commit e1a4c52175
3 changed files with 6 additions and 8 deletions

View file

@ -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:

View file

@ -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

View file

@ -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