From ade0368f100dddcad2a0ced78e285cc3d561ce58 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 20 Oct 2021 21:43:36 +0200 Subject: [PATCH] GUI: Windows: use pass through high DPI scaling factor rounding policy Means fractional scaling factors such as Windows' 175% will no longer use 200% (integer rounding) etc. This is the default on Qt 6 anyway. Implements #3043. --- NEWS.md | 5 +++++ src/mkvtoolnix-gui/mkvtoolnix_gui.cpp | 10 ++++++++-- src/mkvtoolnix-gui/util/system_information.cpp | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 78afedef4..a7428d942 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,11 @@ * mkvmerge: AC-3 parser: E-AC-3 with BSID values > 10 and ≤ 15 are recognized now, too. Implements #3211. +* MKVToolNix GUI: only on Windows: when compiled with Qt ≥ 5.14 and < 6 (which + is the case for the officially provided binaries) fractional screen scaling + will be enabled. This means that the GUI will be scaled appropriately if + Windows is set to 125%, 150% or 175% instead of being too small or too + large. Implements #3043. ## Bug fixes diff --git a/src/mkvtoolnix-gui/mkvtoolnix_gui.cpp b/src/mkvtoolnix-gui/mkvtoolnix_gui.cpp index 8f9c50ab1..d72a0ec50 100644 --- a/src/mkvtoolnix-gui/mkvtoolnix_gui.cpp +++ b/src/mkvtoolnix-gui/mkvtoolnix_gui.cpp @@ -30,8 +30,14 @@ enableOrDisableHighDPIScaling() { auto reg = Util::Settings::registry(); reg->beginGroup(s_grpSettings); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (!reg->value(s_valUiDisableHighDPIScaling).toBool()) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + if (reg->value(s_valUiDisableHighDPIScaling).toBool()) + return; + + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); +# if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); +# endif #endif } diff --git a/src/mkvtoolnix-gui/util/system_information.cpp b/src/mkvtoolnix-gui/util/system_information.cpp index a2749c63e..afbc01eba 100644 --- a/src/mkvtoolnix-gui/util/system_information.cpp +++ b/src/mkvtoolnix-gui/util/system_information.cpp @@ -133,7 +133,7 @@ void gatherEnvironmentVariables(QStringList &info) { info << Q("") << Q("## Environment variables") << Q(""); - auto keys = QStringList{} << Q("QT_AUTO_SCREEN_SCALE_FACTOR") << Q("QT_SCALE_FACTOR") << Q("QT_SCREEN_SCALE_FACTORS") << Q("QT_DEVICE_PIXEL_RATIO") + auto keys = QStringList{} << Q("QT_AUTO_SCREEN_SCALE_FACTOR") << Q("QT_SCALE_FACTOR") << Q("QT_SCREEN_SCALE_FACTORS") << Q("QT_DEVICE_PIXEL_RATIO") << Q("QT_SCALE_FACTOR_ROUNDING_POLICY") << Q("MTX_LOGGER") << Q("MTX_DEBUG") << Q("MKVTOOLNIX_DEBUG") << Q("MKVMERGE_DEBUG") << Q("LC_ALL") << Q("LC_MESSAGES") << Q("LC_CTYPE") << Q("LANG") << Q("LANGUAGE"); keys.sort();