Skip to content

fix(footer): skip background blur when using default cover image#670

Merged
max-lvs merged 1 commit into
linuxdeepin:release/eaglefrom
Resurgamz:release/eagle
Apr 22, 2026
Merged

fix(footer): skip background blur when using default cover image#670
max-lvs merged 1 commit into
linuxdeepin:release/eaglefrom
Resurgamz:release/eagle

Conversation

@Resurgamz
Copy link
Copy Markdown

@Resurgamz Resurgamz commented Apr 21, 2026

When no actual cover exists, clear background instead of using default cover.

当无实际封面时,清空背景而非使用默认封面图片。

Log: 无实际封面时不设置背景
PMS: BUG-357677
Influence: 当音乐无封面图片时,底部工具栏不再显示默认封面的模糊背景,界面更加简洁。

Summary by Sourcery

Bug Fixes:

  • Ensure the footer background is cleared instead of using a default blurred cover image when the current track has no real cover artwork.

@deepin-ci-robot
Copy link
Copy Markdown

Hi @Resurgamz. Thanks for your PR. 😃

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

CLA Assistant Lite bot:
提交邮箱中包含我们的合作伙伴,但您似乎并非合作伙伴的成员或对接人,请联系相关对接人将您添加至组织之中,或由其重新发起 Pull Request。
The commit email domain belongs to one of our partners, but it seems you are not yet a member of the current organization, please contact the contact person to add you to the organization or let them submit the Pull Request.

zhangjiarui seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 21, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the footer background refresh logic so that the blurred background is only generated when an actual cover image file exists; otherwise the background is cleared, avoiding use of the default built-in cover image.

Sequence diagram for updated footer background refresh logic

sequenceDiagram
    actor User
    participant Player
    participant FooterWidget
    participant FileSystem
    participant ForwardWidget as m_forwardWidget

    User->>Player: Change active track
    Player-->>FooterWidget: activeMeta updated
    FooterWidget->>FooterWidget: slotFlushBackground()
    FooterWidget->>FileSystem: Check imagesDirPath exists
    alt Cover image file does not exist
        FooterWidget->>ForwardWidget: setSourceImage(empty QImage)
        FooterWidget->>ForwardWidget: update()
        FooterWidget-->>FooterWidget: return (no blur background)
    else Cover image file exists
        FooterWidget->>FileSystem: Load QImage(imagesDirPath)
        FooterWidget->>FooterWidget: Compute windowScale and imageWidth
        FooterWidget->>FooterWidget: Crop or fill coverImage based on play queue state
        FooterWidget->>ForwardWidget: setSourceImage(coverImage)
        FooterWidget->>ForwardWidget: update()
    end
Loading

Class diagram for FooterWidget background handling changes

classDiagram
    class FooterWidget {
        +void resizeEvent(QResizeEvent* event)
        +void slotFlushBackground()
        -QWidget* m_forwardWidget
        -QAbstractButton* m_btPlayQueue
    }

    class Player {
        +static Player* getInstance()
        +Meta getActiveMeta()
    }

    class Meta {
        +QString hash
    }

    class Global {
        +static QString cacheDir()
    }

    class QImage {
        +QImage()
        +QImage(QString filePath)
        +int width()
        +int height()
        +void fill(QColor color)
        +QImage copy(int x, int y, int width, int height)
    }

    class QFileInfo {
        +QFileInfo(QString filePath)
        +bool exists()
    }

    class ForwardWidget {
        +void setSourceImage(QImage image)
        +void update()
    }

    FooterWidget --> ForwardWidget : uses
    FooterWidget --> Player : queries activeMeta
    FooterWidget --> Global : uses cacheDir
    FooterWidget --> QFileInfo : checks cover file
    FooterWidget --> QImage : loads and processes cover
    Player --> Meta : returns
    Meta --> hash : field
    FooterWidget --> QAbstractButton : uses m_btPlayQueue to alter background
Loading

File-Level Changes

Change Details Files
Only apply blurred background when a real cover image file exists; otherwise clear the footer background.
  • Remove use of the built-in default cover image as the initial background source.
  • Check for existence of the cached cover image file derived from the active track metadata hash.
  • If the cover image file does not exist, reset the forward widget background by setting an empty QImage and triggering an update, then return early.
  • If the cover file exists, load it from disk and proceed with existing scaling and cropping logic, including the special handling when the play queue is open.
src/music-player/mainFrame/footerwidget.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
Copy Markdown

@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 - I've found 1 issue, and left some high level feedback:

  • In slotFlushBackground, consider also handling the case where the cover file exists but QImage imagesDirPath fails to load (e.g., corrupt file) by falling back to clearing the background instead of proceeding with an invalid image.
  • When clearing the background for the no-cover case, verify whether m_forwardWidget maintains any cached blur/transition state and, if so, reset that state alongside setSourceImage(QImage()) to avoid visual artifacts from a previous track.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `slotFlushBackground`, consider also handling the case where the cover file exists but `QImage imagesDirPath` fails to load (e.g., corrupt file) by falling back to clearing the background instead of proceeding with an invalid image.
- When clearing the background for the no-cover case, verify whether `m_forwardWidget` maintains any cached blur/transition state and, if so, reset that state alongside `setSourceImage(QImage())` to avoid visual artifacts from a previous track.

## Individual Comments

### Comment 1
<location path="src/music-player/mainFrame/footerwidget.cpp" line_range="935-942" />
<code_context>
-        cover = QImage(Global::cacheDir() + "/images/" + Player::getInstance()->getActiveMeta().hash + ".jpg");
+
+    // 如果没有实际封面图片,清空背景
+    if (!file.exists()) {
+        m_forwardWidget->setSourceImage(QImage());
+        m_forwardWidget->update();
+        return;
     }

+    // 加载实际封面图片
+    QImage cover = QImage(imagesDirPath);
     double windowScale = (width() * 1.0) / height();
     int imageWidth = static_cast<int>(cover.height() * windowScale);
</code_context>
<issue_to_address>
**issue:** Handle the case where the image file exists but fails to load (e.g., corrupt file).

With this change, `cover` is only set from the jpg. If `QImage(imagesDirPath)` fails (e.g. corrupt/unsupported file), `cover` will be null and later dimension-dependent logic may misbehave. Consider checking `cover.isNull()` after loading and, if true, either clear the background (as in the `!file.exists()` branch) or fall back to a default image.
</issue_to_address>

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.

Comment thread src/music-player/mainFrame/footerwidget.cpp Outdated
@Resurgamz Resurgamz force-pushed the release/eagle branch 2 times, most recently from 98803e5 to 10f6042 Compare April 21, 2026 11:50
@deepin-ci-robot
Copy link
Copy Markdown

Hi @Resurgamz. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Resurgamz Resurgamz force-pushed the release/eagle branch 2 times, most recently from f2649b3 to d266fa1 Compare April 21, 2026 12:29
{
QImage cover = QImage(":/icons/deepin/builtin/actions/info_cover_142px.svg");
// 直接检查实际封面文件是否存在
QString imagesDirPath = Global::cacheDir() + "/images/" + Player::getInstance()->getActiveMeta().hash + ".jpg";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

缺少对 Global::cacheDir() 空路径的处理,如果 Global::cacheDir() 返回空字符串,路径拼接可能产生意外结果。建议:添加防御性检查

// 加载实际封面图片
QImage cover = QImage(imagesDirPath);
// 如果图片加载失败(文件损坏或格式不支持),清空背景
if (cover.isNull() || cover.width() == 0 || cover.height() == 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

cover.width() == 0 || cover.height() == 0 会不会过渡检查了


// 如果没有实际封面图片,清空背景
if (!file.exists()) {
m_forwardWidget->setSourceImage(QImage());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

这段代码出现了两次,建议:提取为辅助函数或使用 lambda

Copy link
Copy Markdown

@max-lvs max-lvs left a comment

Choose a reason for hiding this comment

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

-1

When no actual cover exists, clear background instead of using default cover.

当无实际封面时,清空背景而非使用默认封面图片。

Log: 无实际封面时不设置背景
PMS: https://pms.uniontech.com/bug-view-357677.html
Influence: 当音乐无封面图片时,底部工具栏不再显示默认封面的模糊背景,界面更加简洁。
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: max-lvs, Resurgamz

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

@max-lvs max-lvs merged commit 481cebe into linuxdeepin:release/eagle Apr 22, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants