app: Use HighDPI application attribute instead of environment variable.

Set Qt::AA_EnableHighDpiScaling introduced in Qt 5.6.

Amend change f4e5210cda which apparently
was broken by qtbase:add58edcdbd986e68cdd65a2a935b76d85d5b639.

Change-Id: I0a9337f17b02704e36915f78b1321287e4112378
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
Friedemann Kleint
2015-11-10 15:51:57 +01:00
parent 2a42ad08a3
commit 9c945faa20

View File

@@ -159,7 +159,7 @@ static inline int askMsgSendFailed()
QMessageBox::Retry); QMessageBox::Retry);
} }
static const char* setHighDpiEnvirnonmentVariable() static const char *setHighDpiEnvironmentVariable()
{ {
const char* envVarName = 0; const char* envVarName = 0;
static const char ENV_VAR_QT_DEVICE_PIXEL_RATIO[] = "QT_DEVICE_PIXEL_RATIO"; static const char ENV_VAR_QT_DEVICE_PIXEL_RATIO[] = "QT_DEVICE_PIXEL_RATIO";
@@ -170,14 +170,12 @@ static const char* setHighDpiEnvirnonmentVariable()
qputenv(envVarName, "auto"); qputenv(envVarName, "auto");
} }
#else #else
static const char ENV_VAR_QT_AUTO_SCREEN_SCALE_FACTOR[] = "QT_AUTO_SCREEN_SCALE_FACTOR";
if (Utils::HostOsInfo().isWindowsHost() if (Utils::HostOsInfo().isWindowsHost()
&& !qEnvironmentVariableIsSet(ENV_VAR_QT_DEVICE_PIXEL_RATIO) // legacy in 5.6, but still functional && !qEnvironmentVariableIsSet(ENV_VAR_QT_DEVICE_PIXEL_RATIO) // legacy in 5.6, but still functional
&& !qEnvironmentVariableIsSet(ENV_VAR_QT_AUTO_SCREEN_SCALE_FACTOR) && !qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR")
&& !qEnvironmentVariableIsSet("QT_SCALE_FACTOR") && !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) { && !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
envVarName = ENV_VAR_QT_AUTO_SCREEN_SCALE_FACTOR; QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
qputenv(envVarName, "true");
} }
#endif // < Qt 5.6 #endif // < Qt 5.6
return envVarName; return envVarName;
@@ -304,7 +302,7 @@ static const char *SHARE_PATH =
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const char *highDpiEnvironmentVariable = setHighDpiEnvirnonmentVariable(); const char *highDpiEnvironmentVariable = setHighDpiEnvironmentVariable();
QLoggingCategory::setFilterRules(QLatin1String("qtc.*.debug=false")); QLoggingCategory::setFilterRules(QLatin1String("qtc.*.debug=false"));
#ifdef Q_OS_MAC #ifdef Q_OS_MAC