[Pkg-owncloud-commits] [owncloud-client] 96/171: Windows: Fix HiDPI #3414

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Feb 17 09:36:55 UTC 2016


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to annotated tag upstream/2.1.1+dfsg
in repository owncloud-client.

commit 54c2c9ac4e897a5a1ebbdbfa15d94fc452b72ac5
Author: Jocelyn Turcotte <jturcotte at woboq.com>
Date:   Mon Jan 11 15:27:13 2016 +0100

    Windows: Fix HiDPI #3414
    
    Use QT_DEVICE_PIXEL_RATIO=auto on Qt<=5.5 to enable automatic
    scale factor settings on Windows. Also move the existing
    Qt::AA_EnableHighDpiScaling logic to use the equivalent
    QT_AUTO_SCREEN_SCALE_FACTOR=1 environment variable just to
    keep the 5.5 and >=5.6 code at the same place.
---
 src/gui/application.cpp |  6 +-----
 src/gui/main.cpp        | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index 301856e..af1764b 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -113,11 +113,7 @@ Application::Application(int &argc, char **argv) :
 #if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
     setAttribute(Qt::AA_UseHighDpiPixmaps, true);
 #endif
-#if QT_VERSION > QT_VERSION_CHECK(5, 6, 0)
-    // this may slightly break some styles until they
-    // get fixed, but will make dialogs readable.
-    setAttribute(Qt::AA_EnableHighDpiScaling, true);
-#endif
+
     parseOptions(arguments());
     //no need to waste time;
     if ( _helpOnly || _versionOnly ) return;
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index 83c3806..28a6858 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -47,11 +47,34 @@ int main(int argc, char **argv)
 {
     Q_INIT_RESOURCE(client);
 
+#ifdef Q_OS_WIN
+    // If the font size ratio is set on Windows, we need to
+    // enable the auto pixelRatio in Qt since we don't
+    // want to use sizes relative to the font size everywhere.
+    // This is automatic on OS X, but opt-in on Windows
+    // https://doc-snapshots.qt.io/qt5-5.6/highdpi.html#qt-support
+#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
+    qputenv("QT_DEVICE_PIXEL_RATIO", "auto");
+#else
+    qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
+#endif
+#endif // Q_OS_WIN
+
 #ifdef Q_OS_MAC
     Mac::CocoaInitializer cocoaInit; // RIIA
 #endif
     OCC::Application app(argc, argv);
 
+#ifdef Q_OS_WIN
+    // The Windows style still has pixelated elements with Qt 5.6,
+    // it's recommended to use the Fusion style in this case, even
+    // though it looks slightly less native. Check here after the
+    // QApplication was constructed, but before any QWidget is
+    // constructed.
+    if (app.devicePixelRatio() > 1)
+        QApplication::setStyle(QStringLiteral("fusion"));
+#endif // Q_OS_WIN
+
 #ifndef Q_OS_WIN
     signal(SIGPIPE, SIG_IGN);
 #endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list