|
10 | 10 | #include <DLabel> |
11 | 11 | #include <DToolTip> |
12 | 12 |
|
| 13 | +#ifdef ENABLE_DSS_SNIPE |
| 14 | +#include <DSGApplication> |
| 15 | +#include <DUtil> |
| 16 | +#include <DDBusSender> |
| 17 | +#endif |
| 18 | + |
13 | 19 | #include <QHBoxLayout> |
14 | 20 |
|
15 | 21 | DWIDGET_USE_NAMESPACE |
16 | 22 |
|
| 23 | +#ifdef ENABLE_DSS_SNIPE |
| 24 | +#define AMDBUS_SERVICE "org.desktopspec.ApplicationManager1" |
| 25 | +#define AMDBUS_PATH_APP_PREFIX "/org/desktopspec/ApplicationManager1" |
| 26 | +#define AMDBUS_APP_INTERFACE "org.desktopspec.ApplicationManager1.Application" |
| 27 | +#endif |
| 28 | + |
17 | 29 | const int ButtonWidth = 200; |
18 | 30 | const int ButtonHeight = 64; |
19 | 31 | const int FIXED_INHIBITOR_WIDTH = 328; |
@@ -86,16 +98,41 @@ void InhibitWarnView::setInhibitorList(const QList<InhibitorData> &list) |
86 | 98 | for (const InhibitorData &inhibitor : list) { |
87 | 99 | QIcon icon; |
88 | 100 |
|
89 | | - if (inhibitor.icon.isEmpty() && inhibitor.pid) { |
| 101 | + if (inhibitor.icon.isEmpty()) { |
| 102 | + QString iconName; |
| 103 | +#ifdef ENABLE_DSS_SNIPE |
| 104 | + do { |
| 105 | + const auto appId = Dtk::Core::DSGApplication::getId(inhibitor.pid); |
| 106 | + if (appId.isEmpty()) |
| 107 | + break; |
| 108 | + const auto amDBusAppPath = QString("%1/%2").arg(AMDBUS_PATH_APP_PREFIX, DUtil::escapeToObjectPath(appId)); |
| 109 | + QDBusReply<QDBusVariant> reply = DDBusSender() |
| 110 | + .service(AMDBUS_SERVICE) |
| 111 | + .path(amDBusAppPath) |
| 112 | + .interface(AMDBUS_APP_INTERFACE) |
| 113 | + .property("Icons") |
| 114 | + .get(); |
| 115 | + if (reply.isValid()) { |
| 116 | + auto ret = qdbus_cast<QMap<QString, QString>>(reply.value().variant()); |
| 117 | + iconName = ret.value("Desktop Entry"); |
| 118 | + } else { |
| 119 | + qCWarning(DDE_SHELL) << "Get icon error:" << reply.error().message(); |
| 120 | + break; |
| 121 | + } |
| 122 | + } while(0); |
| 123 | +#endif |
| 124 | + |
| 125 | + if (iconName.isEmpty() && inhibitor.pid) { |
90 | 126 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
91 | | - QFileInfo executable_info(QFile::symLinkTarget(QString("/proc/%1/exe").arg(inhibitor.pid))); |
| 127 | + QFileInfo executable_info(QFile::symLinkTarget(QString("/proc/%1/exe").arg(inhibitor.pid))); |
92 | 128 | #else |
93 | | - QFileInfo executable_info(QFile::readLink(QString("/proc/%1/exe").arg(inhibitor.pid))); |
| 129 | + QFileInfo executable_info(QFile::readLink(QString("/proc/%1/exe").arg(inhibitor.pid))); |
94 | 130 | #endif |
95 | | - |
96 | | - if (executable_info.exists()) { |
97 | | - icon = QIcon::fromTheme(executable_info.fileName()); |
| 131 | + // 玲珑应用的exe指向的路径是容器内的路径,在容器外无法访问,因此不能判断文件是否存在 |
| 132 | + QString iconName = executable_info.fileName(); |
98 | 133 | } |
| 134 | + |
| 135 | + icon = QIcon::fromTheme(iconName); |
99 | 136 | } else { |
100 | 137 | icon = QIcon::fromTheme(inhibitor.icon, QIcon::fromTheme("application-x-desktop")); |
101 | 138 | } |
|
0 commit comments