MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / updateQtDisplayEnvironment

Function updateQtDisplayEnvironment

QKeyMapper/main.cpp:75–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73
74#if 0
75void updateQtDisplayEnvironment(void)
76{
77 int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
78 // HWND hwd = GetDesktopWindow();
79 HDC hdc = GetDC(NULL);
80 int width = GetDeviceCaps(hdc, DESKTOPHORZRES);
81 int height = GetDeviceCaps(hdc, DESKTOPVERTRES);
82 Q_UNUSED(height);
83 double dWidth = static_cast<double>(width);
84 double dScreenWidth = static_cast<double>(nScreenWidth);
85 double scale = dWidth / dScreenWidth;
86 ReleaseDC(NULL, hdc);
87
88#ifdef DEBUG_LOGOUT_ON
89 qDebug() << "Original QT_SCALE_FACTOR ->" << qgetenv("QT_SCALE_FACTOR");
90#endif
91
92 bool Flag_4K = false;
93
94 if (scale < 1.10) {
95 if (dWidth >= 3840) {
96 qputenv("QT_SCALE_FACTOR", "1.5");
97 qputenv("WINDOWS_SCALE_FACTOR", "4K_1.0");
98 Flag_4K = true;
99#ifdef DEBUG_LOGOUT_ON
100 qDebug() << "Set QT_SCALE_FACTOR to [1.5] for screen ->" << width << "*" << height;
101#endif
102 }
103 else if (dWidth >= 2560) {
104 qputenv("QT_SCALE_FACTOR", "1.25");
105 qputenv("WINDOWS_SCALE_FACTOR", "2K_1.0");
106#ifdef DEBUG_LOGOUT_ON
107 qDebug() << "Set QT_SCALE_FACTOR to [1.25] for screen ->" << width << "*" << height;
108#endif
109 }
110 else {
111 qputenv("QT_SCALE_FACTOR", "1");
112 qputenv("WINDOWS_SCALE_FACTOR", "1K_1.0");
113#ifdef DEBUG_LOGOUT_ON
114 qDebug() << "set QT_SCALE_FACTOR to [1] for screen ->" << width << "*" << height;
115#endif
116 }
117 }
118 else if (1.24 <= scale && scale <= 1.26) {
119 if (dWidth >= 3840) {
120 Flag_4K = true;
121 qunsetenv("QT_SCALE_FACTOR");
122 qputenv("WINDOWS_SCALE_FACTOR", "4K_1.25");
123 }
124 else if (dWidth >= 2560) {
125 qunsetenv("QT_SCALE_FACTOR");
126 qputenv("WINDOWS_SCALE_FACTOR", "2K_1.25");
127 }
128 else {
129 qunsetenv("QT_SCALE_FACTOR");
130 qputenv("WINDOWS_SCALE_FACTOR", "1K_1.25");
131 }
132#ifdef DEBUG_LOGOUT_ON

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected