feat: add DesktopSourcePath property to Application DBus interface#338
feat: add DesktopSourcePath property to Application DBus interface#338deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
1. Added new DBus property "DesktopSourcePath" to expose the source path of desktop files 2. Extended the ApplicationService class with getter method and change signal 3. Updated DBus XML interface definition to include the new property 4. The property provides read-only access to the desktop file source path for external applications feat: 为应用DBus接口添加DesktopSourcePath属性 1. 新增DBus属性"DesktopSourcePath"以暴露桌面文件的源路径 2. 扩展ApplicationService类,添加获取方法和变更信号 3. 更新DBus XML接口定义以包含新属性 4. 该属性为外部应用提供对桌面文件源路径的只读访问 PMS: BUG-351621
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a new read-only DBus property DesktopSourcePath to the Application DBus interface, wiring it through ApplicationService, emitting a change signal on desktop entry reset, and exposing it in the DBus XML interface. Sequence diagram for reading DesktopSourcePath via DBussequenceDiagram
actor ExternalApplication
participant DbusClientProxy
participant ApplicationService
participant DesktopSource
ExternalApplication->>DbusClientProxy: getProperty DesktopSourcePath
DbusClientProxy->>ApplicationService: desktopSourcePath()
ApplicationService->>DesktopSource: sourcePath()
DesktopSource-->>ApplicationService: path : QString
ApplicationService-->>DbusClientProxy: path : QString
DbusClientProxy-->>ExternalApplication: path : QString
Sequence diagram for DesktopSourcePath change notificationsequenceDiagram
participant ApplicationManager1Service
participant ApplicationService
participant DesktopSource
actor ExternalApplication
ApplicationManager1Service->>ApplicationService: resetEntry(newEntry)
ApplicationService->>DesktopSource: updateFromEntry(newEntry)
ApplicationService->>ApplicationService: emit desktopSourcePathChanged()
ApplicationService-->>ExternalApplication: DBus signal desktopSourcePathChanged
Updated class diagram for ApplicationService with DesktopSourcePathclassDiagram
class ApplicationService {
+QString X_CreatedBy()
+QString desktopSourcePath()
+QDBusObjectPath findInstance(QString instanceId)
+const QString & getLauncher()
+void xDeepinCreatedByChanged()
+void execsChanged()
+void xCreatedByChanged()
+void desktopSourcePathChanged()
}
class DesktopSource {
+QString sourcePath()
+void updateFromEntry(DesktopEntry newEntry)
}
class DesktopEntry {
}
ApplicationService --> DesktopSource : m_desktopSource
DesktopSource --> DesktopEntry : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- If
m_desktopSourcecan ever be null or otherwise invalid,desktopSourcePath()beingnoexceptwhile directly dereferencing it could hide failures; consider guarding access or droppingnoexceptto avoid undefined behavior. - You only emit
desktopSourcePathChanged()fromresetEntry; ifm_desktopSourcecan change through other code paths, you may want to emit the signal there as well to keep the DBus property in sync.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- If `m_desktopSource` can ever be null or otherwise invalid, `desktopSourcePath()` being `noexcept` while directly dereferencing it could hide failures; consider guarding access or dropping `noexcept` to avoid undefined behavior.
- You only emit `desktopSourcePathChanged()` from `resetEntry`; if `m_desktopSource` can change through other code paths, you may want to emit the signal there as well to keep the DBus property in sync.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review这段代码主要是在 D-Bus 接口中添加了一个名为 1. 语法逻辑审查代码语法正确,符合 C++ 和 Qt 的规范。
潜在逻辑问题:
2. 代码质量审查代码整体质量良好,但有以下改进空间:
3. 代码性能审查
4. 代码安全审查
改进建议代码以下是针对上述问题的改进版本: XML 文件<property name="DesktopSourcePath" type="s" access="read"/>头文件/**
* @brief 获取 desktop 文件的源路径
* @return 返回 desktop 文件的绝对路径,如果无效则返回空字符串
*/
Q_PROPERTY(QString DesktopSourcePath READ desktopSourcePath NOTIFY desktopSourcePathChanged)
[[nodiscard]] QString desktopSourcePath() const noexcept;实现文件QString ApplicationService::desktopSourcePath() const noexcept
{
// 假设 m_desktopSource.sourcePath() 已确保返回有效路径或空字符串
return m_desktopSource.sourcePath();
}
void ApplicationService::resetEntry(DesktopEntry *newEntry) noexcept
{
// ... 其他代码 ...
const QString newPath = m_desktopSource.sourcePath();
if (m_oldPath != newPath) { // 假设 m_oldPath 是成员变量,用于缓存旧值
m_oldPath = newPath;
emit desktopSourcePathChanged();
}
}其他建议
总结代码整体实现正确,但建议优化信号触发逻辑、添加注释,并考虑安全性和性能细节。改进后的代码可以减少不必要的开销并提高可维护性。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
feat: 为应用DBus接口添加DesktopSourcePath属性
PMS: BUG-351621
Summary by Sourcery
Expose the desktop file source path via the application DBus interface.
New Features:
Enhancements: