From 8e9a065f16c6c381a22ee9089db757ae19ca56da Mon Sep 17 00:00:00 2001 From: initramfs Date: Wed, 4 May 2016 18:31:24 +0800 Subject: [PATCH] refactor(hidpi): enable HiDPI support if Qt supports it Previously HiDPI support is conditionally enabled based on compilation parameters as well as environmental variables which makes binary distribution difficult. This commit automatically enables runtime DPI scaling if Qt supports it (version 5.6 and beyond). --- qtox.pro | 5 ----- src/main.cpp | 10 ++++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/qtox.pro b/qtox.pro index 5f6ec00b6..8d66279fe 100644 --- a/qtox.pro +++ b/qtox.pro @@ -108,11 +108,6 @@ contains(DISABLE_FILTER_AUDIO, NO) { DEFINES += QTOX_FILTER_AUDIO } -contains(HIGH_DPI, YES) { - QT_DEVICE_PIXEL_RATIO= auto - DEFINES += HIGH_DPI -} - contains(JENKINS,YES) { INCLUDEPATH += ./libs/include/ } else { diff --git a/src/main.cpp b/src/main.cpp index b48623f98..77f6d9268 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,6 +117,12 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QSt int main(int argc, char *argv[]) { + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif + qInstallMessageHandler(logMessageHandler); QApplication a(argc, argv); @@ -129,10 +135,6 @@ int main(int argc, char *argv[]) osx::migrateProfiles(); #endif -#ifdef HIGH_DPI - a.setAttribute(Qt::AA_UseHighDpiPixmaps, true); -#endif - qsrand(time(0)); Settings::getInstance(); Translator::translate();