From f3ea6fbc7714f173033f99e92951cda032fdbf78 Mon Sep 17 00:00:00 2001 From: HanatoK Date: Sun, 12 Jan 2025 09:58:28 -0600 Subject: [PATCH 1/3] 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. --- src/main.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index 36a3718f5..af8f87c3a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -348,8 +348,11 @@ int main( int argc, char ** argv ) //high dpi screen support - qputenv( "QT_ENABLE_HIGHDPI_SCALING", "1" ); - QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough ); + 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 ); From 9c0a93a09d4bf5c910982ef60c49ce3a004501da Mon Sep 17 00:00:00 2001 From: HanatoK Date: Mon, 13 Jan 2025 09:06:27 -0600 Subject: [PATCH 2/3] fix: move setHighDpiScaleFactorRoundingPolicy out of the check of QT_ENABLE_HIGHDPI_SCALING --- src/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index af8f87c3a..bb777949e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -351,8 +351,8 @@ int main( int argc, char ** argv ) if (!qEnvironmentVariableIsSet("QT_ENABLE_HIGHDPI_SCALING") || qEnvironmentVariableIsEmpty("QT_ENABLE_HIGHDPI_SCALING")) { qputenv( "QT_ENABLE_HIGHDPI_SCALING", "1" ); - QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough ); } + QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough ); QHotkeyApplication app( "GoldenDict-ng", argc, argv ); From d943bad9beb4eeba52b1d0f3c20d43643e04a4dd Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:29:32 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- src/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index bb777949e..2ce5bd93d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -348,8 +348,8 @@ int main( int argc, char ** argv ) //high dpi screen support - if (!qEnvironmentVariableIsSet("QT_ENABLE_HIGHDPI_SCALING") || - qEnvironmentVariableIsEmpty("QT_ENABLE_HIGHDPI_SCALING")) { + if ( !qEnvironmentVariableIsSet( "QT_ENABLE_HIGHDPI_SCALING" ) + || qEnvironmentVariableIsEmpty( "QT_ENABLE_HIGHDPI_SCALING" ) ) { qputenv( "QT_ENABLE_HIGHDPI_SCALING", "1" ); } QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough );