forked from linuxdeepin/dde-launchpad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappmgr.cpp
More file actions
618 lines (532 loc) · 22.4 KB
/
appmgr.cpp
File metadata and controls
618 lines (532 loc) · 22.4 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
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "appmgr.h"
#include "AppManager1Application.h"
#include "AppManager1ApplicationObjectManager.h"
#include <DConfig>
#include <DExpected>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(logDdeIntegration)
DCORE_USE_NAMESPACE
using AppManager1Application = __AppManager1Application;
using AppManager1ApplicationObjectManager = __AppManager1ApplicationObjectManager;
Q_CONSTRUCTOR_FUNCTION(registerComplexDbusType);
static QString parseDisplayName(const QStringMap &source)
{
static QString key = QLocale::system().name();
const QString & defaultValue = source.value(u8"default");
return source.value(key, key.contains('_') ? source.value(key.split('_')[0], defaultValue) : defaultValue);
}
static QString parseName(const QStringMap &source)
{
return source.value(u8"default");
}
static QString parseIcon(const QStringMap &source)
{
return source.value(u8"Desktop Entry");
}
template<class T>
static DExpected<T> parseDBusField(const QVariantMap &map, const QString &key)
{
if (!map.contains(key))
return {};
const auto value = map.value(key);
return DExpected<T>{qdbus_cast<T>(value)};
}
static QString getDisplayName(const bool isDeepin, const QStringMap &name, const QStringMap &genericName)
{
if (isDeepin) {
const auto tmp = parseDisplayName(genericName);
if (!tmp.isEmpty())
return tmp;
}
return parseDisplayName(name);
}
static AppMgr::AppItem *parseDBus2AppItem(const ObjectInterfaceMap &source)
{
const QVariantMap appInfo = source.value("org.desktopspec.ApplicationManager1.Application");
if (appInfo.isEmpty())
return nullptr;
const auto nodisplay = parseDBusField<bool>(appInfo, u8"NoDisplay");
if (!nodisplay || nodisplay.value()) {
return nullptr;
}
AppMgr::AppItem *item = nullptr;
if (auto value = parseDBusField<QString>(appInfo, u8"ID")) {
item = new AppMgr::AppItem();
item->id = value.value() + ".desktop";
item->appId = value.value();
}
if (!item) {
qCWarning(logDdeIntegration) << "Failed to create AppItem";
return nullptr;
}
if (auto value = parseDBusField<QStringList>(appInfo, u8"Categories")) {
item->categories = value.value();
}
// fallback to Name if GenericName is empty, only for X_Deepin_Vendor equals to "deepin".
const auto deepinVendor = parseDBusField<QString>(appInfo, u8"X_Deepin_Vendor");
item->vendor = deepinVendor ? deepinVendor.value() : QString();
// Get GenericName field
const auto genericNameMap = parseDBusField<QStringMap>(appInfo, u8"GenericName");
item->genericName = genericNameMap ? parseName(genericNameMap.value()) : QString();
item->displayName = getDisplayName(deepinVendor && deepinVendor.value() == QStringLiteral("deepin"),
parseDBusField<QStringMap>(appInfo, u8"Name").value(),
parseDBusField<QStringMap>(appInfo, u8"GenericName").value());
// just in case the entry is ill-formed, doesn't have a valid display name, fallback to use its desktop-id instead.
if (item->displayName.isEmpty()) {
item->displayName = item->id;
}
if (auto value = parseDBusField<QStringMap>(appInfo, u8"Name")) {
item->name = parseName(value.value());
}
if (auto value = parseDBusField<QStringMap>(appInfo, u8"Icons")) {
item->iconName = parseIcon(value.value());
}
if (auto value = parseDBusField<qint64>(appInfo, u8"InstalledTime")) {
item->installedTime = value.value();
}
if (auto value = parseDBusField<qint64>(appInfo, u8"LastLaunchedTime")) {
item->lastLaunchedTime = value.value();
}
if (auto value = parseDBusField<bool>(appInfo, u8"AutoStart")) {
item->isAutoStart = value.value();
}
return item;
}
AppMgr::AppMgr(QObject *parent)
: QObject(parent)
, m_objectManager(new AppManager1ApplicationObjectManager("org.desktopspec.ApplicationManager1",
"/org/desktopspec/ApplicationManager1",
QDBusConnection::sessionBus(), this))
, m_checkTimer(new QTimer(this))
, m_checkCount(0)
{
m_checkTimer->setInterval(3000); // 3 second interval
connect(m_checkTimer, &QTimer::timeout, this, &AppMgr::checkPendingAppItems);
initObjectManager();
}
AppMgr::~AppMgr()
{
for (auto item : std::as_const(m_appItems)) {
if (auto handler = item->handler) {
qCDebug(logDdeIntegration) << "Deleting handler for app:" << item->id;
handler->deleteLater();
}
}
qDeleteAll(m_appItems);
}
AppManager1Application * createAM1AppIfaceByPath(const QString &dbusPath)
{
AppManager1Application * amAppIface = new AppManager1Application(QLatin1String("org.desktopspec.ApplicationManager1"),
dbusPath,
QDBusConnection::sessionBus());
if (!amAppIface->isValid()) {
qCWarning(logDdeIntegration) << "D-Bus interface not exist or failed to connect to" << dbusPath;
return nullptr;
}
return amAppIface;
}
AppManager1Application * createAM1AppIface(const QString &desktopId)
{
auto appItem = AppMgr::instance()->appItem(desktopId);
if (!appItem) {
qCWarning(logDdeIntegration) << "Can't find appItem for the desktopId" << desktopId;
return nullptr;
}
qCDebug(logDdeIntegration) << "Get app interface for the desktopId" << desktopId;
return appItem->handler;
}
// if return false, it means the launch is not even started.
// if return true, it means we attempted to launch it via AM, but not sure if it's succeed.
bool AppMgr::launchApp(const QString &desktopId)
{
qCInfo(logDdeIntegration) << "Launching app:" << desktopId;
AppManager1Application * amAppIface = createAM1AppIface(desktopId);
if (!amAppIface) {
qCWarning(logDdeIntegration) << "Failed to get interface for desktop ID:" << desktopId;
return false;
}
const auto path = amAppIface->path();
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
process.start("dde-am", {"--by-user", path});
if (!process.waitForFinished()) {
qCWarning(logDdeIntegration) << "Failed to launch the desktopId:" << desktopId << process.errorString();
return false;
} else if (process.exitCode() != 0) {
qCWarning(logDdeIntegration) << "Failed to launch the desktopId:" << desktopId << process.readAll();
return false;
}
qCInfo(logDdeIntegration) << "Successfully launched desktop ID:" << desktopId;
return true;
}
bool AppMgr::autoStart(const QString &desktopId)
{
AppManager1Application * amAppIface = createAM1AppIface(desktopId);
if (!amAppIface) {
qCWarning(logDdeIntegration) << "Failed to get interface for desktop ID:" << desktopId;
return false;
}
return amAppIface->autoStart();
}
void AppMgr::setAutoStart(const QString &desktopId, bool autoStart)
{
AppManager1Application * amAppIface = createAM1AppIface(desktopId);
if (!amAppIface) {
qCWarning(logDdeIntegration) << "Failed to get interface for desktop ID:" << desktopId;
return;
}
amAppIface->setAutoStart(autoStart);
qCDebug(logDdeIntegration) << "Successfully set autoStart for" << desktopId << "to:" << autoStart;
}
static const QStringList DisabledScaleEnvironments {
"DEEPIN_WINE_SCALE=1",
"QT_SCALE_FACTOR=1",
"GDK_SCALE=1",
"GDK_DPI_SCALE=1",
"D_DXCB_DISABLE_OVERRIDE_HIDPI=1"
};
bool AppMgr::disableScale(const QString &desktopId)
{
AppManager1Application * amAppIface = createAM1AppIface(desktopId);
if (!amAppIface) {
qCWarning(logDdeIntegration) << "Failed to get interface for desktop ID:" << desktopId;
return false;
}
const auto environ = amAppIface->environ();
const QStringList envs(environ.split(';'));
// return true if envs contains any one of DisabledScaleEnvironments.
auto iter = std::find_if(envs.begin(), envs.end(), [] (const QString &env) {
return DisabledScaleEnvironments.contains(env);
});
return iter != envs.end();
}
void AppMgr::setDisableScale(const QString &desktopId, bool disableScale)
{
AppManager1Application * amAppIface = createAM1AppIface(desktopId);
if (!amAppIface) {
qCWarning(logDdeIntegration) << "Failed to get interface for desktop ID:" << desktopId;
return;
}
QString environ = amAppIface->environ();
QStringList envs(environ.split(';', Qt::SkipEmptyParts));
if (disableScale) {
// remove all ScaleEnvironments, avoid other caller has set it manually.
envs.removeIf([] (const QString &env) {
auto iter = std::find_if(DisabledScaleEnvironments.begin(), DisabledScaleEnvironments.end(),
[env] (const QString &item) {
const auto left = item.split('=');
const auto right = env.split('=');
return !right.isEmpty() && left.at(0) == right.at(0);
});
return iter != DisabledScaleEnvironments.end();
});
envs << DisabledScaleEnvironments;
} else {
// remove all DisabledScaleEnvironments.
envs.removeIf([] (const QString &env) {
return DisabledScaleEnvironments.contains(env);
});
}
environ = envs.join(';');
qCDebug(logDdeIntegration) << "Update environ for the desktopId" << desktopId << ", env:" << environ;
amAppIface->setEnviron(environ);
}
bool AppMgr::isOnDesktop(const QString &desktopId)
{
AppManager1Application * amAppIface = createAM1AppIface(desktopId);
if (!amAppIface) {
qCWarning(logDdeIntegration) << "Failed to get interface for desktop ID:" << desktopId;
return false;
}
return amAppIface->isOnDesktop();
}
bool AppMgr::sendToDesktop(const QString &desktopId)
{
AppManager1Application * amAppIface = createAM1AppIface(desktopId);
if (!amAppIface) {
qCWarning(logDdeIntegration) << "Failed to get interface for desktop ID:" << desktopId;
return false;
}
QDBusPendingReply<bool> reply = amAppIface->SendToDesktop();
reply.waitForFinished();
if (reply.isError()) {
qCWarning(logDdeIntegration) << "SendToDesktop failed:" << reply.error();
return false;
}
const bool result = reply.value();
qCInfo(logDdeIntegration) << "SendToDesktop result for" << desktopId << ":" << result;
return result;
}
bool AppMgr::removeFromDesktop(const QString &desktopId)
{
AppManager1Application * amAppIface = createAM1AppIface(desktopId);
if (!amAppIface) {
qCWarning(logDdeIntegration) << "Failed to get interface for desktop ID:" << desktopId;
return false;
}
QDBusPendingReply<bool> reply = amAppIface->RemoveFromDesktop();
reply.waitForFinished();
if (reply.isError()) {
qCWarning(logDdeIntegration) << "RemoveFromDesktop failed:" << reply.error();
return false;
}
return reply.value();
}
bool AppMgr::isValid() const
{
return m_objectManager->isValid();
}
QList<AppMgr::AppItem *> AppMgr::allAppInfosShouldBeShown() const
{
return m_appItems.values();
}
AppMgr::AppItem *AppMgr::appItem(const QString &id) const
{
const auto items = m_appItems.values();
auto iter = std::find_if(items.begin(), items.end(), [id](AppItem *item) {
return item->id == id;
});
return iter != items.end() ? *iter : nullptr;
}
void AppMgr::watchingAppItemPropertyChanged(const QString &key, AppMgr::AppItem *appItem)
{
AppManager1Application * amAppIface = createAM1AppIfaceByPath(key);
if (!amAppIface)
return;
Q_ASSERT(appItem->handler == nullptr);
appItem->handler = amAppIface;
connect(amAppIface, &AppManager1Application::CategoriesChanged, this, [this, appItem](const QStringList & value) {
qCDebug(logDdeIntegration) << "CategoriesChanged by AM, desktopId" << appItem->id;
appItem->categories = value;
Q_EMIT itemDataChanged(appItem->id);
});
connect(amAppIface, &AppManager1Application::IconsChanged, this, [this, appItem](const QStringMap & value) {
qCDebug(logDdeIntegration) << "IconsChanged by AM, desktopId" << appItem->id;
appItem->iconName = parseIcon(value);
Q_EMIT itemDataChanged(appItem->id);
});
connect(amAppIface, &AppManager1Application::X_Deepin_VendorChanged, this, [this, appItem, amAppIface](const QString & value) {
qCDebug(logDdeIntegration) << "X_Deepin_VendorChanged by AM, desktopId" << appItem->id;
appItem->displayName = getDisplayName(!value.isEmpty(), amAppIface->name(), amAppIface->genericName());
Q_EMIT itemDataChanged(appItem->id);
});
connect(amAppIface, &AppManager1Application::GenericNameChanged, this, [this, appItem, amAppIface](const QStringMap & value) {
qCDebug(logDdeIntegration) << "GenericNameChanged by AM, desktopId" << appItem->id;
appItem->displayName = getDisplayName(!amAppIface->x_Deepin_Vendor().isEmpty(), amAppIface->name(), value);
Q_EMIT itemDataChanged(appItem->id);
});
connect(amAppIface, &AppManager1Application::NameChanged, this, [this, appItem, amAppIface](const QStringMap & value) {
qCDebug(logDdeIntegration) << "NameChanged by AM, desktopId" << appItem->id;
appItem->name = parseName(value);
appItem->displayName = getDisplayName(!amAppIface->x_Deepin_Vendor().isEmpty(), value, amAppIface->genericName());
Q_EMIT itemDataChanged(appItem->id);
});
connect(amAppIface, &AppManager1Application::InstalledTimeChanged, this, [this, appItem](const qint64 & value) {
qCDebug(logDdeIntegration) << "InstalledTimeChanged by AM, desktopId" << appItem->id;
appItem->installedTime = value;
Q_EMIT itemDataChanged(appItem->id);
});
connect(amAppIface, &AppManager1Application::LastLaunchedTimeChanged, this, [this, appItem](const qint64 & value) {
qCDebug(logDdeIntegration) << "LastLaunchedTimeChanged by AM, desktopId" << appItem->id;
appItem->lastLaunchedTime = value;
Q_EMIT itemDataChanged(appItem->id);
});
connect(amAppIface, &AppManager1Application::AutoStartChanged, this, [this, appItem](bool value) {
qCDebug(logDdeIntegration) << "AutoStartChanged by AM, desktopId" << appItem->id;
appItem->isAutoStart = value;
Q_EMIT itemDataChanged(appItem->id);
});
}
void AppMgr::updateAppsLaunchedTimes(const QVariantMap &appsLaunchedTimes)
{
// need to update times for removed and updated.
const auto &appItems = m_appItems.values();
for (const auto item : std::as_const(appItems)) {
auto iter = appsLaunchedTimes.find(item->appId);
qint64 times = 0;
if (iter != appsLaunchedTimes.cend())
times = iter->toLongLong();
// including reset and increase times.
if (item->launchedTimes != times) {
qCDebug(logDdeIntegration) << "LaunchedTimesChanged by DConfig, desktopId" << item->id << "from" << item->launchedTimes << "to" << times;
item->launchedTimes = times;
Q_EMIT itemDataChanged(item->id);
}
}
}
void AppMgr::initObjectManager()
{
if (!isValid()) {
qCWarning(logDdeIntegration) << "Object manager is not valid, aborting initialization";
return;
}
connect(m_objectManager, &AppManager1ApplicationObjectManager::InterfacesAdded, this,
[this](const QDBusObjectPath &objPath, ObjectInterfaceMap interfacesAndProperties) {
const QString key(objPath.path());
qCDebug(logDdeIntegration) << "InterfacesAdded by AM, path:" << key;
if (m_appItems.contains(objPath.path())) {
qWarning() << "App already exists for the path:" << key;
return;
}
// Reset check count when new app is added
m_checkCount = 0;
if (auto appItem = parseDBus2AppItem(interfacesAndProperties)) {
qCDebug(logDdeIntegration) << "App item added, desktopId" << appItem->id;
watchingAppItemAdded(key, appItem);
}
});
connect(m_objectManager, &AppManager1ApplicationObjectManager::InterfacesRemoved, this,
[this](const QDBusObjectPath &objPath, const QStringList &interfaces) {
Q_UNUSED(interfaces)
const QString key(objPath.path());
qCDebug(logDdeIntegration) << "InterfacesRemoved by AM, path:" << key;
watchingAppItemRemoved(key);
});
fetchAppItems();
DConfig *config = DConfig::create("org.deepin.dde.application-manager", "org.deepin.dde.am", "", this);
if (!config->isValid()) {
qCWarning(logDdeIntegration) << "DConfig is invalid when getting launched times.";
} else {
static const QString AppsLaunchedTimes(u8"appsLaunchedTimes");
const auto &value = config->value(AppsLaunchedTimes).toMap();
updateAppsLaunchedTimes(value);
QObject::connect(config, &DConfig::valueChanged, this, [this, config](const QString &key) {
if (key != AppsLaunchedTimes) {
qCDebug(logDdeIntegration) << "Ignoring non-appsLaunchedTimes key:" << key;
return;
}
qCInfo(logDdeIntegration) << "appsLaunchedTimes of DConfig changed, updating";
const auto &value = config->value(AppsLaunchedTimes).toMap();
updateAppsLaunchedTimes(value);
});
}
}
void AppMgr::fetchAppItems()
{
qCDebug(logDdeIntegration) << "Begin to fetch apps.";
const auto reply = m_objectManager->GetManagedObjects();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *call){
QDBusPendingReply<ObjectMap> reply = *call;
if (reply.isError()) {
qWarning() << "Failed to get apps from AM, " << reply.error();
call->deleteLater();
return;
}
qCDebug(logDdeIntegration) << "Fetched all AppItem, and start parsing data.";
QMap<QString, AppMgr::AppItem *> items;
const auto objects = reply.value();
for (auto iter = objects.cbegin(); iter != objects.cend(); ++iter) {
const auto &objPath = iter.key();
const ObjectInterfaceMap &objs = iter.value();
auto appItem = parseDBus2AppItem(objs);
if (!appItem) {
continue;
}
items[objPath.path()] = appItem;
watchingAppItemPropertyChanged(objPath.path(), appItem);
}
call->deleteLater();
qCDebug(logDdeIntegration) << "Fetched all AppItem, and end up parsing data.";
m_appItems = items;
Q_EMIT changed();
});
// TODO async to fetch apps.
watcher->waitForFinished();
}
void AppMgr::watchingAppItemAdded(const QString &key, AppItem *appItem)
{
// Check if iconName is an absolute path and if the file exists
if (isAbsolutePathIcon(appItem->iconName)) {
QFileInfo fileInfo(appItem->iconName);
if (!fileInfo.exists()) {
// File doesn't exist, add to pending container
m_pendingAppItems[key] = appItem;
// Start timer if not already running
if (!m_checkTimer->isActive()) {
m_checkTimer->start();
}
return;
}
}
// Icon exists or is a system icon, proceed with normal logic
m_appItems[key] = appItem;
watchingAppItemPropertyChanged(key, appItem);
Q_EMIT changed();
}
void AppMgr::watchingAppItemRemoved(const QString &key)
{
auto appItem = m_appItems.value(key);
if (!appItem) {
qCWarning(logDdeIntegration) << "App item not found for key:" << key;
return;
}
qCDebug(logDdeIntegration) << "App item removed, desktopId" << appItem->id;
if (auto handler = appItem->handler) {
qCDebug(logDdeIntegration) << "Deleting handler for removed app:" << appItem->id;
handler->disconnect(this);
handler->deleteLater();
}
m_appItems.remove(key);
delete appItem;
Q_EMIT changed();
}
void AppMgr::checkPendingAppItems()
{
m_checkCount++;
if (m_pendingAppItems.isEmpty()) {
m_checkTimer->stop();
return;
}
QList<QPair<QString, AppItem *>> itemsToProcess;
// Check all pending items
for (auto it = m_pendingAppItems.begin(); it != m_pendingAppItems.end(); ) {
const QString &key = it.key();
AppItem *appItem = it.value();
if (isAbsolutePathIcon(appItem->iconName)) {
QFileInfo fileInfo(appItem->iconName);
if (fileInfo.exists()) {
// File now exists, add to main container
itemsToProcess.append(qMakePair(key, appItem));
it = m_pendingAppItems.erase(it);
continue;
}
}
++it;
}
// Process items whose icons now exist
for (const auto &itemPair : itemsToProcess) {
const QString &key = itemPair.first;
AppItem *appItem = itemPair.second;
m_appItems[key] = appItem;
watchingAppItemPropertyChanged(key, appItem);
Q_EMIT changed();
}
// Check if timeout reached (60 seconds)
if (m_checkCount >= 20 && !m_pendingAppItems.isEmpty()) {
// Force process all remaining pending items
for (auto it = m_pendingAppItems.begin(); it != m_pendingAppItems.end(); ) {
const QString &key = it.key();
AppItem *appItem = it.value();
m_appItems[key] = appItem;
watchingAppItemPropertyChanged(key, appItem);
Q_EMIT changed();
it = m_pendingAppItems.erase(it);
}
m_checkTimer->stop();
} else if (m_pendingAppItems.isEmpty()) {
m_checkTimer->stop();
}
}
bool AppMgr::isAbsolutePathIcon(const QString &iconName) const
{
// Check if the icon name is an absolute path (starts with /)
return iconName.startsWith('/');
}
AppMgr *AppMgr::instance() {
static AppMgr gInstance;
return &gInstance;
}