File tree Expand file tree Collapse file tree 4 files changed +25
-10
lines changed
Expand file tree Collapse file tree 4 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ static QString versionInfo()
7373
7474int main (int argc, char *argv[])
7575{
76- PlatformInfo::enableHiDPISupport ();
76+ const auto &dpiInfo = PlatformInfo::enableHiDPISupport ();
7777 QScopedPointer<QRealApplication> app (new QRealApplication (argc, argv));
7878
7979 if (app->arguments ().contains (" --clear-conf" )) {
@@ -124,6 +124,7 @@ int main(int argc, char *argv[])
124124 << " / Kernel: " << QSysInfo::kernelType () << QSysInfo::kernelVersion ();
125125 QLOG_INFO () << " Arguments:" << app->arguments ();
126126 QLOG_INFO () << " Setting default locale to" << QLocale ().name ();
127+ for (auto &&i: dpiInfo) { QLOG_INFO () << i ; }
127128
128129 QApplication::setStyle (QStyleFactory::create (" Fusion" ));
129130
Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ MainWindow::MainWindow(const QString &fileToOpen)
114114 , mSceneCustomizer(new SceneCustomizer())
115115 , mInitialFileToOpen(fileToOpen)
116116{
117+ QLOG_INFO () << " MainWindow: screen DPI is" << logicalDpiX ();
117118 mUi ->setupUi (this );
118119 mUi ->paletteTree ->initMainWindow (this );
119120 setWindowTitle (" QReal" );
Original file line number Diff line number Diff line change @@ -119,13 +119,25 @@ bool PlatformInfo::isX64()
119119 return cpuArchitecture ().contains (" 64" );
120120}
121121
122- void PlatformInfo::enableHiDPISupport ()
122+ QStringList PlatformInfo::enableHiDPISupport ()
123123{
124- if (!qEnvironmentVariableIsSet (" QT_DEVICE_PIXEL_RATIO" )
125- && !qEnvironmentVariableIsSet (" QT_AUTO_SCREEN_SCALE_FACTOR" )
126- && !qEnvironmentVariableIsSet (" QT_SCALE_FACTOR" )
127- && !qEnvironmentVariableIsSet (" QT_SCREEN_SCALE_FACTORS" )) {
128- // Only if there is no attempt to set from the system environment
129- QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
124+ static const QList<const char *> envVars { " QT_DEVICE_PIXEL_RATIO"
125+ , " QT_AUTO_SCREEN_SCALE_FACTOR"
126+ , " QT_SCALE_FACTOR"
127+ , " QT_SCREEN_SCALE_FACTORS"
128+ };
129+ bool anyIsSet = false ;
130+ QStringList result;
131+ for (auto &&e: envVars) {
132+ if (qEnvironmentVariableIsSet (e)) {
133+ result << QString (" Scaling variable %1=%2" ).arg (e, qEnvironmentVariable (e));
134+ anyIsSet = true ;
135+ }
136+ }
137+ if (!anyIsSet) {
138+ // Only if there is no attempt to set from the system environment
139+ QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
140+ result << " Using Qt::AA_EnableHighDpiScaling" ;
130141 }
142+ return result;
131143}
Original file line number Diff line number Diff line change 1515#pragma once
1616
1717#include < qrkernel/kernelDeclSpec.h>
18+ #include < QStringList>
1819
1920namespace qReal {
2021
@@ -49,8 +50,8 @@ class QRKERNEL_EXPORT PlatformInfo
4950 // / Returns true if current OS and process architecture reported by currentCpuArchitecture contains '64'.
5051 static bool isX64 ();
5152
52- // / Designed to make an attempt to set proper flags for HiDPI screens
53- static void enableHiDPISupport ();
53+ // / Designed to make an attempt to set proper flags for HiDPI screens, returns info for logging
54+ static QStringList enableHiDPISupport ();
5455};
5556
5657}
You can’t perform that action at this time.
0 commit comments