Skip to content

Commit 5c9ba25

Browse files
committed
Merge branch 'me/hidpi_win' into junior
2 parents fdd5c2d + a91d444 commit 5c9ba25

File tree

3 files changed

+56
-22
lines changed

3 files changed

+56
-22
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" manifestVersion="1.0">
3+
4+
<!-- Enable use of version 6 of the common controls (Win XP and later) -->
5+
<!--
6+
<dependency>
7+
<dependentAssembly>
8+
<assemblyIdentity type="win32"
9+
name="Microsoft.Windows.Common-Controls"
10+
version="6.0.0.0"
11+
processorArchitecture="*"
12+
publicKeyToken="6595b64144ccf1df"
13+
language="*" />
14+
</dependentAssembly>
15+
</dependency>
16+
-->
17+
18+
<!-- Indicate UAC compliance, with no need for elevated privileges (Win Vista and later) -->
19+
<!-- (if you need enhanced privileges, set the level to "highestAvailable" or "requireAdministrator") -->
20+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
21+
<security>
22+
<requestedPrivileges>
23+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
24+
</requestedPrivileges>
25+
</security>
26+
</trustInfo>
27+
28+
<!-- Indicate high API awareness (Win Vista and later) -->
29+
<!-- (if you support per-monitor high DPI, set this to "True/PM") -->
30+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
31+
<windowsSettings>
32+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
33+
<gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling>
34+
</windowsSettings>
35+
</application>
36+
37+
<!-- Declare support for various versions of Windows -->
38+
<ms_compatibility:compatibility xmlns:ms_compatibility="urn:schemas-microsoft-com:compatibility.v1" xmlns="urn:schemas-microsoft-com:compatibility.v1">
39+
<ms_compatibility:application>
40+
<!-- Windows 7/Server 2008 R2 -->
41+
<ms_compatibility:supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
42+
<!-- Windows 8/Server 2012 -->
43+
<ms_compatibility:supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
44+
<!-- Windows 8.1/Server 2012 R2 -->
45+
<ms_compatibility:supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
46+
<!-- Windows 10 -->
47+
<ms_compatibility:supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
48+
</ms_compatibility:application>
49+
</ms_compatibility:compatibility>
50+
</assembly>

qrgui/mainWindow/mainWindow.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ RESOURCES = $$PWD/mainWindow.qrc
155155

156156
win32 {
157157
RC_FILE = $$PWD/mainWindow.rc
158+
QMAKE_MANIFEST = $$PWD/application.exe.manifest
159+
DISTFILES += $$QMAKE_MANIFEST
158160
}
159161

160162
macx {
161-
ICON = icon.icns
163+
ICON = icon.icns
162164
}
163165

164166
include(scriptAPI/scriptAPI.pri)

qrkernel/platformInfo.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
#include <QLibrary>
2323
#include <qrkernel/settingsManager.h>
2424
#include <QsLog.h>
25-
26-
#ifdef Q_OS_WIN
27-
#define WIN32_LEAN_AND_MEAN
28-
#include <windows.h> // for SetProcessDPIAware in PlaformInfo::enableHiDPISupport
29-
#endif
25+
#include <QOperatingSystemVersion>
3026

3127
using namespace qReal;
3228

@@ -129,21 +125,7 @@ void PlatformInfo::enableHiDPISupport()
129125
&& !qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR")
130126
&& !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
131127
&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
132-
// Only if there is no attempt to set from the system environment
133-
#ifdef Q_OS_WIN
134-
typedef BOOL (WINAPI *SetProcessDPIAware_t)();
135-
// Let Windows decide.
136-
if(auto SetProcessDPIAware_ = (SetProcessDPIAware_t)QLibrary::resolve("user32", "SetProcessDPIAware")) {
137-
if(SetProcessDPIAware_()) {
138-
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", QByteArray("1"));
139-
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
140-
} else {
141-
auto err = GetLastError();
142-
QLOG_ERROR() << "Failed to SetDpiAware() with error" << err;
143-
}
144-
return;
145-
}
146-
#endif
147-
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
128+
// Only if there is no attempt to set from the system environment
129+
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
148130
}
149131
}

0 commit comments

Comments
 (0)