Skip to content

Commit 2074ee7

Browse files
committed
feat: provide the dbus attribute of Execs and X_CreatedBy
dde-control-center requirements pms: TASK-372065
1 parent 45e789a commit 2074ee7

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

api/dbus/org.desktopspec.ApplicationManager1.Application.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@
165165

166166
<property name="X_Deepin_CreateBy" type="s" access="read"/>
167167

168+
<property name="Execs" type="a{ss}" access="read">
169+
<annotation
170+
name="org.freedesktop.DBus.Description"
171+
value="Display the exec content of all actions"
172+
/>
173+
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QStringMap"/>
174+
</property>
175+
176+
<property name="X_CreatedBy" type="s" access="read"/>
177+
168178
<method name="SendToDesktop">
169179
<arg type="b" name="success" direction="out"/>
170180
</method>

src/dbus/applicationservice.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,33 @@ QString ApplicationService::X_Deepin_CreateBy() const noexcept
607607
return findEntryValue(DesktopFileEntryKey, "X-Deepin-CreateBy", EntryValueType::String).toString();
608608
}
609609

610+
QStringMap ApplicationService::execs() const noexcept
611+
{
612+
QStringMap ret;
613+
614+
auto mainExec = m_entry->value(DesktopFileEntryKey, "Exec");
615+
if (mainExec.has_value()) {
616+
ret.insert(DesktopFileEntryKey, mainExec->value<QString>());
617+
}
618+
619+
auto actionList = actions();
620+
for (const auto &action : actionList) {
621+
auto actionKey = QString{action}.prepend(DesktopFileActionKey);
622+
auto value = m_entry->value(actionKey, "Exec");
623+
if (!value.has_value()) {
624+
continue;
625+
}
626+
ret.insert(actionKey, value->value<QString>());
627+
}
628+
629+
return ret;
630+
}
631+
632+
QString ApplicationService::X_CreatedBy() const noexcept
633+
{
634+
return findEntryValue(DesktopFileEntryKey, "X-Created-By", EntryValueType::String).toString();
635+
}
636+
610637
bool ApplicationService::terminal() const noexcept
611638
{
612639
auto val = findEntryValue(DesktopFileEntryKey, "Terminal", EntryValueType::String);
@@ -958,6 +985,9 @@ void ApplicationService::resetEntry(DesktopEntry *newEntry) noexcept
958985
emit environChanged();
959986
emit launchedTimesChanged();
960987
emit startupWMClassChanged();
988+
emit xDeepinCreatedByChanged();
989+
emit execsChanged();
990+
emit xCreatedByChanged();
961991
}
962992

963993
std::optional<QStringList> ApplicationService::unescapeExecArgs(const QString &str) noexcept

src/dbus/applicationservice.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,15 @@ class ApplicationService : public QObject, protected QDBusContext
109109
Q_PROPERTY(bool NoDisplay READ noDisplay NOTIFY noDisplayChanged)
110110
[[nodiscard]] bool noDisplay() const noexcept;
111111

112-
Q_PROPERTY(QString X_Deepin_CreateBy READ X_Deepin_CreateBy NOTIFY noDisplayChanged)
112+
Q_PROPERTY(QString X_Deepin_CreateBy READ X_Deepin_CreateBy NOTIFY xDeepinCreatedByChanged)
113113
[[nodiscard]] QString X_Deepin_CreateBy() const noexcept;
114114

115+
Q_PROPERTY(QStringMap Execs READ execs NOTIFY execsChanged)
116+
[[nodiscard]] QStringMap execs() const noexcept;
117+
118+
Q_PROPERTY(QString X_CreatedBy READ X_CreatedBy NOTIFY xCreatedByChanged)
119+
[[nodiscard]] QString X_CreatedBy() const noexcept;
120+
115121
[[nodiscard]] QDBusObjectPath findInstance(const QString &instanceId) const;
116122

117123
[[nodiscard]] const QString &getLauncher() const noexcept { return m_launcher; }
@@ -172,6 +178,9 @@ public Q_SLOTS:
172178
void environChanged();
173179
void launchedTimesChanged();
174180
void startupWMClassChanged();
181+
void xDeepinCreatedByChanged();
182+
void execsChanged();
183+
void xCreatedByChanged();
175184

176185
private:
177186
friend class ApplicationManager1Service;

0 commit comments

Comments
 (0)