mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
remove lodpi hack, don't assume physical DPI is always 72
This commit is contained in:
parent
3840f012be
commit
33c5b5f9e7
2 changed files with 20 additions and 10 deletions
|
@ -223,8 +223,6 @@ def parseArgs(argv):
|
||||||
parser.add_option("-b", "--base", help="path to base folder")
|
parser.add_option("-b", "--base", help="path to base folder")
|
||||||
parser.add_option("-p", "--profile", help="profile name to load")
|
parser.add_option("-p", "--profile", help="profile name to load")
|
||||||
parser.add_option("-l", "--lang", help="interface language (en, de, etc)")
|
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:])
|
return parser.parse_args(argv[1:])
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
@ -261,8 +259,7 @@ def _run(argv=None, exec=True):
|
||||||
ctypes.CDLL('libGL.so.1', ctypes.RTLD_GLOBAL)
|
ctypes.CDLL('libGL.so.1', ctypes.RTLD_GLOBAL)
|
||||||
|
|
||||||
# opt in to full hidpi support
|
# opt in to full hidpi support
|
||||||
if not opts.lodpi:
|
QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
||||||
QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
|
||||||
|
|
||||||
# create the app
|
# create the app
|
||||||
app = AnkiApp(argv)
|
app = AnkiApp(argv)
|
||||||
|
|
|
@ -160,20 +160,33 @@ class AnkiWebView(QWebEngineView):
|
||||||
from aqt import mw
|
from aqt import mw
|
||||||
if isMac:
|
if isMac:
|
||||||
return 1
|
return 1
|
||||||
if isWin and mw.opts.lodpi:
|
|
||||||
return 1
|
|
||||||
screen = QApplication.desktop().screen()
|
screen = QApplication.desktop().screen()
|
||||||
dpi = screen.logicalDpiX()
|
dpi = screen.logicalDpiX()
|
||||||
factor = dpi / 96.0
|
factor = dpi / 96.0
|
||||||
if isLin:
|
if isLin:
|
||||||
factor = max(1, factor)
|
factor = max(1, factor)
|
||||||
return factor
|
return factor
|
||||||
# compensate for qt's integer scaling
|
# compensate for qt's integer scaling on windows
|
||||||
# on windows
|
qtIntScale = self._getQtIntScale(screen)
|
||||||
qtIntScale = 72/screen.physicalDpiX()
|
|
||||||
desiredScale = factor * qtIntScale
|
desiredScale = factor * qtIntScale
|
||||||
newFactor = desiredScale / qtIntScale
|
newFactor = desiredScale / qtIntScale
|
||||||
return newFactor
|
return max(1, newFactor)
|
||||||
|
|
||||||
|
def _getQtIntScale(self, screen):
|
||||||
|
# try to detect if Qt has scaled the screen
|
||||||
|
# - qt will round the scale factor to a whole number, so a dpi of 125% = 1x,
|
||||||
|
# and a dpi of 150% = 2x
|
||||||
|
# - a screen with a normal physical dpi of 72 will have a dpi of 32
|
||||||
|
# if the scale factor has been rounded to 2x
|
||||||
|
# - different screens have different physical DPIs (eg 72, 93, 102)
|
||||||
|
# - until a better solution presents itself, assume a physical DPI at
|
||||||
|
# or above 70 is unscaled
|
||||||
|
if screen.physicalDpiX() > 70:
|
||||||
|
return 1
|
||||||
|
elif screen.physicalDpiX() > 35:
|
||||||
|
return 2
|
||||||
|
else:
|
||||||
|
return 3
|
||||||
|
|
||||||
def stdHtml(self, body, css=[], js=["jquery.js"], head=""):
|
def stdHtml(self, body, css=[], js=["jquery.js"], head=""):
|
||||||
if isWin:
|
if isWin:
|
||||||
|
|
Loading…
Reference in a new issue