mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 00:36:38 -04:00
option to disable qt's hidpi scaling
https://anki.tenderapp.com/discussions/beta-testing/765-problem-with-the-ui-of-anki
This commit is contained in:
parent
384a01e53b
commit
d530134218
2 changed files with 11 additions and 2 deletions
|
@ -223,6 +223,8 @@ 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():
|
||||||
|
@ -259,6 +261,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
|
||||||
|
|
|
@ -6,7 +6,7 @@ import sys
|
||||||
import math
|
import math
|
||||||
from anki.hooks import runHook
|
from anki.hooks import runHook
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.utils import openLink
|
from aqt.utils import openLink, showWarning
|
||||||
from anki.utils import isMac, isWin, isLin, devMode
|
from anki.utils import isMac, isWin, isLin, devMode
|
||||||
|
|
||||||
# Page for debug messages
|
# Page for debug messages
|
||||||
|
@ -73,6 +73,8 @@ class AnkiWebPage(QWebEnginePage):
|
||||||
# Main web view
|
# Main web view
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
dpiWarned = False
|
||||||
|
|
||||||
class AnkiWebView(QWebEngineView):
|
class AnkiWebView(QWebEngineView):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
@ -157,6 +159,7 @@ class AnkiWebView(QWebEngineView):
|
||||||
oldFocus.setFocus()
|
oldFocus.setFocus()
|
||||||
|
|
||||||
def zoomFactor(self):
|
def zoomFactor(self):
|
||||||
|
global dpiWarned
|
||||||
if isMac:
|
if isMac:
|
||||||
return 1
|
return 1
|
||||||
screen = QApplication.desktop().screen()
|
screen = QApplication.desktop().screen()
|
||||||
|
@ -167,6 +170,9 @@ class AnkiWebView(QWebEngineView):
|
||||||
return factor
|
return factor
|
||||||
# compensate for qt's integer scaling
|
# compensate for qt's integer scaling
|
||||||
# on windows
|
# 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()
|
qtIntScale = 72/screen.physicalDpiX()
|
||||||
desiredScale = factor * qtIntScale
|
desiredScale = factor * qtIntScale
|
||||||
newFactor = desiredScale / qtIntScale
|
newFactor = desiredScale / qtIntScale
|
||||||
|
|
Loading…
Reference in a new issue