From f46aade946eacbcf8cf10a83d413440b0f3b5670 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 26 Aug 2016 20:28:52 +0530 Subject: [PATCH] Turn on high DPI scaling automatically based on the DPI of the monitor. Note that this will only work for Qt >= 5.6 so actual testing will have to wait for calibre 3.0 --- src/calibre/gui2/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index d0180702a1..6cd7c71f76 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -873,6 +873,18 @@ class Application(QApplication): self.headless = headless qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args] self.pi = plugins['progress_indicator'][0] + if not isosx and not headless and hasattr(Qt, 'AA_EnableHighDpiScaling'): + # On OS X high dpi scaling is turned on automatically by the OS, so we dont need to set it explicitly + # This requires Qt >= 5.6 + for v in ('QT_AUTO_SCREEN_SCALE_FACTOR', 'QT_SCALE_FACTOR', 'QT_SCREEN_SCALE_FACTORS', 'QT_DEVICE_PIXEL_RATIO'): + if os.environ.get(v): + break + else: + # Should probably make a preference to allow the user to + # control this, if needed. + # Could have options: auto, off, 0.75, 1, 1.25, 1.5, 1.75, 2, + # 2.25, 2.5 + QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) QApplication.__init__(self, qargs) self.setAttribute(Qt.AA_UseHighDpiPixmaps) if not iswindows: