From 49dec8d08992f72292ff72320f05696d0015a7bb Mon Sep 17 00:00:00 2001 From: eumagga0x2a Date: Sun, 31 Mar 2019 14:38:03 +0200 Subject: [PATCH] [Qt] Enable automatic application scaling for recent Qt versions on Windows to deal with HiDPI displays This should save users the hassle to set environment variable QT_AUTO_SCREEN_SCALE_FACTOR to achieve the same effect. --- avidemux/qt4/ADM_jobs/src/ADM_jobControl.cpp | 3 +++ avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/avidemux/qt4/ADM_jobs/src/ADM_jobControl.cpp b/avidemux/qt4/ADM_jobs/src/ADM_jobControl.cpp index 54b0ac6397..e3645e67d4 100644 --- a/avidemux/qt4/ADM_jobs/src/ADM_jobControl.cpp +++ b/avidemux/qt4/ADM_jobs/src/ADM_jobControl.cpp @@ -207,6 +207,9 @@ bool jobWindow::popup(const char *errorMessage) bool jobRun(int ac,char **av) { initTranslator(); +#if defined(_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5,11,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif QApplication *app=new QApplication(ac,av,0); Q_INIT_RESOURCE(jobs); loadTranslator(); diff --git a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp index b523a52349..096bddeb2d 100644 --- a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp +++ b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp @@ -1647,7 +1647,11 @@ int UI_Init(int nargc, char **nargv) global_argc=nargc; global_argv=nargv; ADM_renderLibInit(&UI_Hooks); - +#if defined(_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5,11,0) + // Despite HiDPI scaling being supported from Qt 5.6 on, important aspects + // like OpenGL support were fixed only in much later versions. + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif myApplication=new myQApplication (global_argc, global_argv); myApplication->connect(myApplication, SIGNAL(lastWindowClosed()), myApplication, SLOT(quit())); myApplication->connect(myApplication, SIGNAL(aboutToQuit()), myApplication, SLOT(cleanup()));