forked from maz-1/dukto-qt5
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathplatform.cpp
More file actions
623 lines (563 loc) · 19.3 KB
/
platform.cpp
File metadata and controls
623 lines (563 loc) · 19.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
/* DUKTO - A simple, fast and multi-platform file transfer tool for LAN users
* Copyright (C) 2011 Emanuele Colombo
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "platform.h"
#include <QString>
#include <QHostInfo>
#include <QFile>
#include <QDir>
#include <QRegularExpression>
#include <QStandardPaths>
#include <QImage>
#include <QProcessEnvironment>
#include <QGuiApplication>
#include <QStyleHints>
#include <QPalette>
#include "settings.h"
#if defined(Q_OS_MAC)
#include <QTemporaryFile>
#include <CoreServices/CoreServices.h>
#include <CoreFoundation/CoreFoundation.h>
#endif
#if defined(Q_OS_WIN)
#include <windows.h>
#include <shlobj.h>
#include <lmcons.h> // for UNLEN
#include <QLibrary>
// undocumented, starting from Win10 1809, replaced from 20H2
#define DWMWA_USE_IMMERSIVE_DARK_MODE_OLD 19
// starting from Win10 20H2
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
#endif
#endif
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
#include <QUrl>
#include <unistd.h>
#include <sys/types.h>
#define DBUS_PORTAL_SERVICE "org.freedesktop.portal.Desktop"
#define DBUS_PORTAL_PATH "/org/freedesktop/portal/desktop"
#define DBUS_PORTAL_SETTINGS_INTERFACE "org.freedesktop.portal.Settings"
#define PORTAL_SETTINGS_NAMESPACE "org.freedesktop.appearance"
#define COLOR_SCHEME_KEY "color-scheme"
#endif
#if defined(Q_OS_ANDROID)
#include "androidutils.h"
#endif
// Returns the buddy name
QString Platform::getUsername()
{
QString buddyName = gSettings->buddyName();
if (buddyName.isEmpty() == false) {
return buddyName;
}
return getSystemUsername();
}
// Returns the system username
QString Platform::getSystemUsername() {
// Save in a static variable so that It's always ready
static QString username;
if (!username.isEmpty()) return username;
#if defined(Q_OS_ANDROID)
username = "User";
#elif defined(Q_OS_WIN)
WCHAR buffer[UNLEN + 1] = {0};
DWORD len = UNLEN + 1;
if (GetUserName(buffer, &len) != 0) {
username = QString::fromWCharArray(buffer);
} else {
username = env("USERNAME");
}
#else
// Looking for the username
username = env("USER");
#endif
if (username.isEmpty()) {
username = "Unknown";
} else {
username = username.replace(0, 1, username.at(0).toUpper());
}
return username;
}
// Returns the hostname
QString Platform::getHostname()
{
// Save in a static variable so that It's always ready
static QString hostname;
if (!hostname.isEmpty()) return hostname;
#ifdef Q_OS_ANDROID
hostname = AndroidSettings::getStringValue(AndroidSettings::Global, "device_name");
if (hostname.isEmpty()) {
hostname = AndroidEnvironment::buildInfo("MODEL");
}
hostname.replace(QChar(' '), QChar('-'));
#else
// Get the hostname
// (replace ".local" for MacOSX)
hostname = QHostInfo::localHostName().replace(".local", "");
#endif
return hostname;
}
// Returns the platform name
QString Platform::getPlatformName()
{
#if defined(Q_OS_WIN)
return "Windows";
#elif defined(Q_OS_MAC)
return "Macintosh";
#elif defined(Q_OS_ANDROID)
return "Android";
#elif defined(Q_OS_LINUX)
return "Linux";
#else
return "Unknown";
#endif
}
// Returns the platform avatar path
QString Platform::getAvatarPath()
{
// user specified avatar
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
#else
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
#endif
QString avatarFile = dir.filePath("avatar.png");
QImage image(avatarFile);
if (image.isNull() == false) {
return avatarFile;
}
// default avatar
#if defined(Q_OS_WIN)
return getWinAvatarPath();
#elif defined(Q_OS_MAC)
return getMacTempAvatarPath();
#elif defined(Q_OS_ANDROID)
return "";
#elif defined(Q_OS_LINUX)
return getLinuxAvatarPath();
#else
return "";
#endif
}
// Returns the platform default output path
QString Platform::getDefaultPath()
{
// For Windows it's the Desktop folder
#if defined(Q_OS_WIN)
WCHAR dir[1024];
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, dir))) {
return QString::fromWCharArray(dir);
} else {
return env("USERPROFILE") + "\\Desktop";
}
#elif defined(Q_OS_MAC)
return env("HOME") + "/Desktop";
#elif defined(Q_OS_ANDROID)
return "";
#elif defined(Q_OS_UNIX)
return env("HOME");
#else
#error "Unknown default path for this platform"
#endif
}
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
// Special function for Linux
QString Platform::getLinuxAvatarPath()
{
QString path;
// Gnome2 / Xfce / KDE5 check
path = env("HOME") + "/.face";
if (QFile::exists(path)) return path;
// KDE5 check
path.append(".icon");
if (QFile::exists(path)) return path;
QString uid = QString::number(getuid());
auto getIconFromDbus = [&uid](const QString &service)->QString {
QDBusInterface iface(service, "/" + QString(service).replace(QChar('.'), QChar('/')) + "/User" + uid, service + ".User", QDBusConnection::systemBus());
if (iface.isValid()) {
QVariant iconFile = iface.property("IconFile");
if (iconFile.isValid()) {
QString path = iconFile.toString();
if (path.startsWith("file://")) {
path = QUrl(path).toLocalFile();
}
if (QFile::exists(path)) {
return path;
}
}
}
return QString();
};
// Deepin check
path = getIconFromDbus("com.deepin.daemon.Accounts");
if (!path.isEmpty()) {
return path;
}
// Gnome3 check
path = getIconFromDbus("org.freedesktop.Accounts");
if (!path.isEmpty()) {
return path;
}
// Not found
return "";
}
#endif
#if defined(Q_OS_MAC)
static QTemporaryFile macAvatar;
// Special function for OSX
QString Platform::getMacTempAvatarPath()
{
// Get image data from system
QByteArray qdata;
CSIdentityQueryRef query = CSIdentityQueryCreateForCurrentUser(kCFAllocatorSystemDefault);
if (query == NULL) {
return "";
}
if (CSIdentityQueryExecute(query, kCSIdentityQueryGenerateUpdateEvents, NULL)) {
CFArrayRef foundIds = CSIdentityQueryCopyResults(query);
if (foundIds != NULL) {
if (CFArrayGetCount(foundIds) == 1) {
CSIdentityRef userId = (CSIdentityRef) CFArrayGetValueAtIndex(foundIds, 0);
CFDataRef data = CSIdentityGetImageData(userId);
if (data != NULL) {
qdata.resize(CFDataGetLength(data));
CFDataGetBytes(data, CFRangeMake(0, CFDataGetLength(data)), reinterpret_cast<uint8*>(qdata.data()));
}
}
CFRelease(foundIds);
}
}
CFRelease(query);
if (qdata.isEmpty()) {
return "";
}
// Save it to a temporary file
macAvatar.open();
macAvatar.write(qdata);
macAvatar.close();
return macAvatar.fileName();
}
#endif
#if defined(Q_OS_WIN)
#include <objbase.h>
#ifndef ARRAYSIZE
#define ARRAYSIZE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif
// Undocumented function for Windows Vista+
// http://undoc.airesoft.co.uk/shell32.dll/SHGetUserPicturePathEx.php
typedef HRESULT (WINAPI*pfnSHGetUserPicturePathEx)(
LPCWSTR pwszUserOrPicName,
DWORD sguppFlags,
LPCWSTR pwszDesiredSrcExt,
LPWSTR pwszPicPath,
UINT picPathLen,
LPWSTR pwszSrcPath,
UINT srcLen
);
// Undocumented function for Windows XP/2003
// http://undoc.airesoft.co.uk/shell32.dll/SHGetUserPicturePath.php
typedef HRESULT (WINAPI*pfnSHGetUserPicturePathW)(
LPCWSTR pwszPicOrUserName,
DWORD sguppFlags,
LPWSTR pwszPicPath
);
#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
#endif
QString Platform::getWinAvatarPath() {
static const bool isVistaOrLater = ((LOBYTE(LOWORD(GetVersion()))) >= 6);
CoInitialize(NULL);
QString path;
HMODULE hMod = LoadLibraryEx(L"shell32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hMod != NULL) {
if (isVistaOrLater) {
// Vista+
pfnSHGetUserPicturePathEx SHGetUserPicturePathEx = (pfnSHGetUserPicturePathEx)GetProcAddress(hMod, (LPCSTR)810);
if (SHGetUserPicturePathEx != nullptr) {
WCHAR picPath[1024] = {0};
if (SHGetUserPicturePathEx(NULL, 0, NULL, picPath, ARRAYSIZE(picPath), NULL, 0) == S_OK) {
path = QString::fromWCharArray(picPath);
}
}
} else {
pfnSHGetUserPicturePathW SHGetUserPicturePathW = (pfnSHGetUserPicturePathW)GetProcAddress(hMod, (LPCSTR)233);
if (SHGetUserPicturePathW != nullptr) {
WCHAR picPath[1024] = {0};
if (SHGetUserPicturePathW(NULL, 0, picPath) == S_OK) {
path = QString::fromWCharArray(picPath);
}
}
}
FreeLibrary(hMod);
}
if (QFile::exists(path) == false) {
path.clear();
QStringList searchPaths;
QString userPic = getSystemUsername().replace("\\", "+") + ".bmp";
QString guestPic = "guest.bmp";
QString dir;
if (isVistaOrLater) {
WCHAR picPath[1024];
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, picPath))) {
dir = QString::fromWCharArray(picPath) + "\\Temp\\";
} else {
dir = env("LOCALAPPDATA") + "\\Temp\\";
}
searchPaths << dir + userPic;
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, picPath))) {
dir = QString::fromWCharArray(picPath) + "\\Microsoft\\User Account Pictures\\";
} else {
dir = env("ALLUSERSPROFILE") + "\\Microsoft\\User Account Pictures\\";
}
searchPaths << dir + guestPic;
} else {
WCHAR picPath[1024];
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, picPath))) {
dir = QString::fromWCharArray(picPath) + "\\Microsoft\\User Account Pictures\\";
} else {
dir = env("ALLUSERSPROFILE") + "\\Application Data\\Microsoft\\User Account Pictures\\";
}
searchPaths << dir + userPic;
searchPaths << dir + guestPic;
}
for (const QString &pic : searchPaths) {
if (QFile::exists(pic)) {
path = pic;
break;
}
}
}
CoUninitialize();
return path;
}
#endif
#if defined(Q_OS_WIN)
Platform::ThemeScheme Platform::getWinThemeScheme() {
ThemeScheme scheme = UnknownTheme;
HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
DWORD type, value, cbData = sizeof(value);
if (RegQueryValueEx(hKey, L"AppsUseLightTheme", NULL, &type, reinterpret_cast<BYTE*>(&value), &cbData) == ERROR_SUCCESS) {
// other types may also take effect, but we don't care
if (type == REG_DWORD) {
scheme = (value == 0 ? DarkTheme : LightTheme);
}
}
RegCloseKey(hKey);
}
return scheme;
}
#endif
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
Platform::ThemeScheme Platform::getLinuxThemeSchemeFromXdgPortal() {
// https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Settings.html
QDBusInterface iface(DBUS_PORTAL_SERVICE, DBUS_PORTAL_PATH, DBUS_PORTAL_SETTINGS_INTERFACE, QDBusConnection::sessionBus());
if (iface.isValid() == false) {
return UnknownTheme;
}
bool v1 = false;
QDBusMessage reply = iface.call("ReadOne", PORTAL_SETTINGS_NAMESPACE, COLOR_SCHEME_KEY);
if (reply.type() == QDBusMessage::ErrorMessage) {
QDBusError err(reply);
if (err.type() != QDBusError::UnknownMethod) {
return UnknownTheme;
}
// Deprecated method
reply = iface.call("Read", PORTAL_SETTINGS_NAMESPACE, COLOR_SCHEME_KEY);
if (reply.type() == QDBusMessage::ErrorMessage) {
return UnknownTheme;
}
v1 = true;
}
QVariantList args = reply.arguments();
if (args.isEmpty()) {
return UnknownTheme;
}
QVariant var;
if (v1) {
var = reply.arguments().at(0).value<QDBusVariant>().variant().value<QDBusVariant>().variant();
} else {
var = reply.arguments().at(0).value<QDBusVariant>().variant();
}
bool ok;
int value = var.toInt(&ok);
if (ok) {
// 0: No preference
// 1: Prefer dark
// 2: Prefer light
if (value == 1) {
return DarkTheme;
} else if (value == 2) {
return LightTheme;
}
}
return UnknownTheme;
}
#endif
#if defined(Q_OS_MAC)
Platform::ThemeScheme Platform::getMacThemeScheme() {
CFStringRef styleKey = CFSTR("AppleInterfaceStyle");
CFPropertyListRef styleValue = CFPreferencesCopyValue(styleKey, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if (styleValue == NULL) {
return LightTheme;
}
bool isDark = false;
if (CFGetTypeID(styleValue) == CFStringGetTypeID()) {
if (CFStringCompare((CFStringRef)styleValue, CFSTR("Dark"), 0) == kCFCompareEqualTo) {
isDark = true;
}
}
CFRelease(styleValue);
return isDark ? DarkTheme : UnknownTheme;
}
#endif
#if !defined(Q_OS_ANDROID)
QString Platform::env(const QString &name) {
static const QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
return env.value(name);
}
#endif
void Platform::setNonClientAreaMode(QWindow *win, bool darkMode) {
#if defined(Q_OS_WIN)
QLibrary lib("dwmapi.dll");
if (lib.load()) {
typedef HRESULT (WINAPI *fnDwmSetWindowAttribute)(HWND,DWORD,LPCVOID,DWORD); // WinVista+
fnDwmSetWindowAttribute DwmSetWindowAttribute = reinterpret_cast<fnDwmSetWindowAttribute>(lib.resolve("DwmSetWindowAttribute"));
if (DwmSetWindowAttribute != nullptr) {
HWND hWnd = reinterpret_cast<HWND>(win->winId());
BOOL value = darkMode ? TRUE : FALSE;
HRESULT ret = DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value));
if (ret != S_OK) {
ret = DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE_OLD, &value, sizeof(value));
}
if (ret == S_OK) {
// force redraw
RECT rect;
GetWindowRect(hWnd, &rect);
SetWindowPos(hWnd, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top + 1, SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
SetWindowPos(hWnd, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_DRAWFRAME|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
}
}
}
#elif defined(Q_OS_ANDROID)
Q_UNUSED(win)
AndroidTheme::setAppNightMode(darkMode);
#else
Q_UNUSED(win)
Q_UNUSED(darkMode)
#endif
}
bool Platform::isDarkTheme() {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
const QStyleHints *hints = QGuiApplication::styleHints();
const Qt::ColorScheme qtColorScheme = hints->colorScheme();
if (qtColorScheme == Qt::ColorScheme::Dark) {
return true;
} else if (qtColorScheme == Qt::ColorScheme::Light) {
return false;
}
#endif
#if defined(Q_OS_ANDROID)
return AndroidTheme::isNightMode();
#endif
ThemeScheme r = UnknownTheme;
#if defined(Q_OS_WIN)
r = getWinThemeScheme();
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
r = getLinuxThemeSchemeFromXdgPortal();
#elif defined(Q_OS_MAC)
r = getMacThemeScheme();
#endif
if (r != UnknownTheme) {
return r == DarkTheme;
}
return false;
}
#if defined(Q_OS_MAC)
PlatformObserver *obsInst = nullptr;
#endif
PlatformObserver::PlatformObserver(QObject *parent) : QObject(parent) {
observe();
}
PlatformObserver::~PlatformObserver() {
}
void PlatformObserver::observe() {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
const QStyleHints *hints = QGuiApplication::styleHints();
connect(hints, &QStyleHints::colorSchemeChanged, this, [this](Qt::ColorScheme cs) {
emit colorSchemeChanged(cs == Qt::ColorScheme::Dark);
});
#endif
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
QDBusConnection conn = QDBusConnection::sessionBus();
if (conn.isConnected()) {
conn.connect(DBUS_PORTAL_SERVICE, DBUS_PORTAL_PATH, DBUS_PORTAL_SETTINGS_INTERFACE, "SettingChanged", this, SLOT(dbusChanged(QString,QString,QDBusVariant)));
}
#endif
#if defined(Q_OS_MAC)
CFNotificationCenterRef nc = CFNotificationCenterGetDistributedCenter();
CFStringRef notification = CFSTR("AppleInterfaceThemeChangedNotification");
auto callback = [](CFNotificationCenterRef /*nc*/, void */*observer*/, CFStringRef /*notification*/, const void */*obj*/, CFDictionaryRef /*userInfo*/) {
Platform::ThemeScheme cs = Platform::getMacThemeScheme();
emit obsInst->colorSchemeChanged(cs == Platform::DarkTheme);
};
obsInst = this;
CFNotificationCenterAddObserver(nc, NULL, callback, notification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
#endif
}
#ifdef Q_OS_WIN
bool PlatformObserver::winEvent(MSG *message, void *result) {
Q_UNUSED(result);
if (message->message == WM_SETTINGCHANGE) {
LPTSTR str = reinterpret_cast<LPTSTR>(message->lParam);
if (lstrcmp(str, L"ImmersiveColorSet") == 0) {
emit colorSchemeChanged(Platform::getWinThemeScheme() == Platform::DarkTheme);
}
}
return false;
}
#endif
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
void PlatformObserver::dbusChanged(QString ns, QString key, QDBusVariant value) {
if (ns == PORTAL_SETTINGS_NAMESPACE && key == COLOR_SCHEME_KEY) {
QVariant variant = value.variant();
bool ok;
int v = variant.toInt(&ok);
if (!ok) {
return;
}
// 0: No preference
// 1: Prefer dark
// 2: Prefer light
emit colorSchemeChanged(v == 1);
} else if (ns == "org.kde.kdeglobals.General" && key == "ColorScheme") {
if (Platform::getLinuxThemeSchemeFromXdgPortal() == Platform::UnknownTheme) {
QString themeName = value.variant().toString();
if (themeName.endsWith("Dark", Qt::CaseInsensitive)) {
emit colorSchemeChanged(true);
} else {
emit colorSchemeChanged(false);
}
}
}
}
#endif