From 16bde19fafb6bf677f75a47482806013107dd86c Mon Sep 17 00:00:00 2001 From: rumtid Date: Tue, 27 Sep 2022 14:12:40 +0800 Subject: [PATCH] Fix dpi scaling issues (#1424) --- src/filebrowser/file-browser-dialog.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/filebrowser/file-browser-dialog.cpp b/src/filebrowser/file-browser-dialog.cpp index 17bfb660b..d725fea4f 100644 --- a/src/filebrowser/file-browser-dialog.cpp +++ b/src/filebrowser/file-browser-dialog.cpp @@ -57,7 +57,20 @@ const int kSearchBarWidth = 250; void openFile(const QString& path) { +#if defined(Q_OS_WIN32) + // The QT_SCREEN_SCALE_FACTORS environment variable will be passed to the + // application invoked from here, which may cause scaling problems. + // So we temporary reset that and restore back. + const char *factors = g_getenv("QT_SCREEN_SCALE_FACTORS"); + g_setenv("QT_SCREEN_SCALE_FACTORS", "1", 1); +#endif + ::openInNativeExtension(path) || ::showInGraphicalShell(path); + +#if defined(Q_OS_WIN32) + g_setenv("QT_SCREEN_SCALE_FACTORS", factors, 1); +#endif + #ifdef Q_OS_MAC MacImageFilesWorkAround::instance()->fileOpened(path); #endif