Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions src/widgets/inhibitwarnview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@
#include <DStyle>
#include <DFontSizeManager>
#include <DSpinner>
#include <DLabel>

Check warning on line 10 in src/widgets/inhibitwarnview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DLabel> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DToolTip>

Check warning on line 11 in src/widgets/inhibitwarnview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DToolTip> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#ifdef ENABLE_DSS_SNIPE
#include <DSGApplication>

Check warning on line 14 in src/widgets/inhibitwarnview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DSGApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DUtil>

Check warning on line 15 in src/widgets/inhibitwarnview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DUtil> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DDBusSender>

Check warning on line 16 in src/widgets/inhibitwarnview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DDBusSender> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif

#include <QHBoxLayout>

Check warning on line 19 in src/widgets/inhibitwarnview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QHBoxLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DWIDGET_USE_NAMESPACE

#ifdef ENABLE_DSS_SNIPE
#define AMDBUS_SERVICE "org.desktopspec.ApplicationManager1"
#define AMDBUS_PATH_APP_PREFIX "/org/desktopspec/ApplicationManager1"
#define AMDBUS_APP_INTERFACE "org.desktopspec.ApplicationManager1.Application"
#endif

const int ButtonWidth = 200;
const int ButtonHeight = 64;
const int FIXED_INHIBITOR_WIDTH = 328;
Expand Down Expand Up @@ -86,16 +98,41 @@
for (const InhibitorData &inhibitor : list) {
QIcon icon;

if (inhibitor.icon.isEmpty() && inhibitor.pid) {
if (inhibitor.icon.isEmpty()) {
QString iconName;
#ifdef ENABLE_DSS_SNIPE
do {
const auto appId = Dtk::Core::DSGApplication::getId(inhibitor.pid);
if (appId.isEmpty())
break;
const auto amDBusAppPath = QString("%1/%2").arg(AMDBUS_PATH_APP_PREFIX, DUtil::escapeToObjectPath(appId));
QDBusReply<QDBusVariant> reply = DDBusSender()
.service(AMDBUS_SERVICE)
.path(amDBusAppPath)
.interface(AMDBUS_APP_INTERFACE)
.property("Icons")
.get();
if (reply.isValid()) {
auto ret = qdbus_cast<QMap<QString, QString>>(reply.value().variant());
iconName = ret.value("Desktop Entry");
} else {
qCWarning(DDE_SHELL) << "Get icon error:" << reply.error().message();
break;
}
} while(0);
#endif

if (iconName.isEmpty() && inhibitor.pid) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QFileInfo executable_info(QFile::symLinkTarget(QString("/proc/%1/exe").arg(inhibitor.pid)));
QFileInfo executable_info(QFile::symLinkTarget(QString("/proc/%1/exe").arg(inhibitor.pid)));
#else
QFileInfo executable_info(QFile::readLink(QString("/proc/%1/exe").arg(inhibitor.pid)));
QFileInfo executable_info(QFile::readLink(QString("/proc/%1/exe").arg(inhibitor.pid)));
#endif

if (executable_info.exists()) {
icon = QIcon::fromTheme(executable_info.fileName());
// 玲珑应用的exe指向的路径是容器内的路径,在容器外无法访问,因此不能判断文件是否存在
QString iconName = executable_info.fileName();
}

icon = QIcon::fromTheme(iconName);
} else {
icon = QIcon::fromTheme(inhibitor.icon, QIcon::fromTheme("application-x-desktop"));
}
Expand Down
Loading