From fd42f8172da2a3d3c5d1c6c5b152ae46e66692fe Mon Sep 17 00:00:00 2001 From: HanatoK Date: Mon, 13 Jan 2025 21:57:47 -0600 Subject: [PATCH] fix: respect the setting of QT_ENABLE_HIGHDPI_SCALING of the system (#2077) * fix: respect the setting of QT_ENABLE_HIGHDPI_SCALING of the system Setting QT_ENABLE_HIGHDPI_SCALING to 1 might not work well in some cases. Instead of hard-coding it to 1, this commit checks if it is already set, and if it is empty or not set, then set it to 1. This allows overriding the QT_ENABLE_HIGHDPI_SCALING to 0 by respecting the system-wide setting of environment variables. * fix: move setHighDpiScaleFactorRoundingPolicy out of the check of QT_ENABLE_HIGHDPI_SCALING * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/main.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index 36a3718f5..2ce5bd93d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -348,7 +348,10 @@ int main( int argc, char ** argv ) //high dpi screen support - qputenv( "QT_ENABLE_HIGHDPI_SCALING", "1" ); + if ( !qEnvironmentVariableIsSet( "QT_ENABLE_HIGHDPI_SCALING" ) + || qEnvironmentVariableIsEmpty( "QT_ENABLE_HIGHDPI_SCALING" ) ) { + qputenv( "QT_ENABLE_HIGHDPI_SCALING", "1" ); + } QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough ); QHotkeyApplication app( "GoldenDict-ng", argc, argv );