Skip to content

Conversation

@deepin-ci-robot
Copy link
Contributor

@deepin-ci-robot deepin-ci-robot commented May 20, 2025

Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#9

Summary by Sourcery

Implement a fallback mechanism in InhibitWarnView to retrieve application icons via the Dtk ApplicationManager1 D-Bus service when the executable path is inaccessible or theme icons are missing

Bug Fixes:

  • Fix missing icons for containerized applications whose executable paths are inaccessible

Enhancements:

  • Introduce Dtk::Core::DSGApplication, DUtil, and DDBusSender includes to support D-Bus icon queries
  • Define AMDBUS_SERVICE, AMDBUS_PATH_APP_PREFIX, and AMDBUS_APP_INTERFACE constants for the ApplicationManager1 interface
  • Add conditional logic under ENABLE_DSS_SNIPE to fetch icon names from the ApplicationManager1 service when QIcon::hasThemeIcon fails

@sourcery-ai
Copy link

sourcery-ai bot commented May 20, 2025

Reviewer's Guide

Synchronized inhibitor warning view implementation to support containerized applications by removing local file existence checks and integrating a DBus-based fallback for icon retrieval, along with the necessary header and constant additions.

Sequence Diagram for Icon Retrieval with DBus Fallback

sequenceDiagram
    participant IWV as InhibitWarnView
    participant DUtil
    participant DSGA as "Dtk::Core::DSGApplication"
    participant DDBS as DDBusSender
    participant AM as "org.desktopspec.ApplicationManager1"

    Note over IWV: In setInhibitorList(), for an inhibitor (e.g., containerized app)
    IWV->>IWV: iconName = executable_info.fileName()
    opt If icon not found in theme AND ENABLE_DSS_SNIPE defined
        IWV->>DSGA: getId(inhibitor.pid)
        DSGA-->>IWV: appId
        IWV->>DUtil: escapeToObjectPath(appId)
        DUtil-->>IWV: escapedAppIdPathSegment
        IWV->>IWV: amDBusAppPath = AMDBUS_PATH_APP_PREFIX + "/" + escapedAppIdPathSegment
        IWV->>DDBS: Create DDBusSender for AMDBUS_SERVICE
        DDBS->>DDBS: path(amDBusAppPath)
        DDBS->>DDBS: interface(AMDBUS_APP_INTERFACE)
        DDBS->>DDBS: property("Icons")
        DDBS->>AM: get()
        AM-->>DDBS: QDBusReply (Icons data)
        DDBS-->>IWV: reply
        alt reply.isValid()
            IWV->>IWV: iconName = extract from reply.value()
        else
            IWV->>IWV: Log error(reply.error().message())
        end
    end
    IWV->>IWV: icon = QIcon::fromTheme(iconName)
Loading

File-Level Changes

Change Details Files
Enhanced icon resolution with DBus fallback for containerized apps
  • Added headers for DSGApplication, DUtil, and DDBusSender
  • Defined AMDBUS_SERVICE, AMDBUS_PATH_APP_PREFIX, and AMDBUS_APP_INTERFACE constants
  • Removed executable file existence check (container paths may be inaccessible)
  • Under ENABLE_DSS_SNIPE, query the ApplicationManager service over DBus to fetch the “Icons” property and extract the Desktop Entry
  • Logged warnings on DBus retrieval failure and always call QIcon::fromTheme(iconName)
src/widgets/inhibitwarnview.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @deepin-ci-robot - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link
Contributor Author

deepin pr auto review

关键摘要:

  • #ifdef ENABLE_DSS_SNIPE#endif块中重复包含了相同的头文件,建议将这些头文件移到条件编译块之外。
  • do { ... } while(0);的使用可能不是必要的,因为if语句已经足够控制代码的执行路径。
  • qCWarning的使用应该确保日志级别和消息内容能够清晰表达问题。
  • QDBusSender的使用没有错误处理,如果DBus服务不可用,可能会导致程序异常。
  • QDBusReply<QDBusVariant>isValid()检查后没有进行相应的处理,如果DBus调用失败,应该有相应的错误处理逻辑。
  • QMap<QString, QString>value()方法可能抛出异常,应该使用value()的重载版本,并检查键是否存在。
  • QIcon::fromTheme在找不到图标时使用了默认图标,这是一个好的做法,但应该确保默认图标是正确的。

是否建议立即修改:

@mhduiy mhduiy closed this May 28, 2025
@mhduiy mhduiy force-pushed the sync-pr-9-nosync branch from 0c4be43 to 179fc48 Compare May 28, 2025 08:30
@deepin-ci-robot
Copy link
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-ci-robot

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants