Skip to content

fix: archive icon missing for jar and tar.bz2 - #502

Closed
pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/bug/02b1195c57e5
Closed

pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/bug/02b1195c57e5

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

fix: archive icon missing for jar and tar.bz2

  1. Root cause: QFileIconProvider depends on the system icon theme
    which lacks entries for jar and tar.bz2, returning empty icons
  2. Fix: add UiTools::getArchiveIcon() with three-level fallback:
    QFileIconProvider -> QMimeDatabase/QIcon::fromTheme -> generic
    archive icon; replace both call sites in compresssettingpage
    and progresspage
  3. Impact: jar and tar.bz2 archive icons now display correctly in
    preview and progress pages; no behavior change for other formats

Log: Fix archive icon not showing for jar and tar.bz2 formats

Influence:

  1. Test jar format compression preview icon display
  2. Test tar.bz2 format compression preview icon display
  3. Test zip, 7z, tar.gz formats still display correctly
  4. Verify archive icon on progress page after compression

fix: 修复jar和tar.bz2压缩格式图标不显示问题

  1. 根因:QFileIconProvider 依赖系统图标主题,jar 和 tar.bz2 格式
    缺少对应图标资源导致返回空图标
  2. 方案:新增 UiTools::getArchiveIcon() 三级回退方法:
    QFileIconProvider → QMimeDatabase/QIcon::fromTheme → 通用
    压缩包图标,替换压缩设置页和进度页两处调用点
  3. 影响:jar 和 tar.bz2 压缩格式图标恢复正常显示,其他格式
    无行为变化

Log: 修复jar和tar.bz2压缩格式图标不显示问题

Influence:

  1. 测试jar格式压缩时预览图标显示
  2. 测试tar.bz2格式压缩时预览图标显示
  3. 测试zip、7z、tar.gz格式图标显示正常无回归
  4. 验证压缩完成后进度页文件图标显示

PMS: BUG-378903

Summary by Sourcery

Ensure archive icons display consistently in compression preview and progress pages.

Bug Fixes:

  • Restore archive icons for JAR and TAR.BZ2 files when the system icon theme does not provide format-specific icons.

Enhancements:

  • Centralize archive icon resolution with fallbacks while preserving existing icon behavior for supported archive formats.

1. Root cause: QFileIconProvider depends on the system icon theme
   which lacks entries for jar and tar.bz2, returning empty icons
2. Fix: add UiTools::getArchiveIcon() with three-level fallback:
   QFileIconProvider -> QMimeDatabase/QIcon::fromTheme -> generic
   archive icon; replace both call sites in compresssettingpage
   and progresspage
3. Impact: jar and tar.bz2 archive icons now display correctly in
   preview and progress pages; no behavior change for other formats

Log: Fix archive icon not showing for jar and tar.bz2 formats

Influence:
1. Test jar format compression preview icon display
2. Test tar.bz2 format compression preview icon display
3. Test zip, 7z, tar.gz formats still display correctly
4. Verify archive icon on progress page after compression

fix: 修复jar和tar.bz2压缩格式图标不显示问题

1. 根因:QFileIconProvider 依赖系统图标主题,jar 和 tar.bz2 格式
   缺少对应图标资源导致返回空图标
2. 方案:新增 UiTools::getArchiveIcon() 三级回退方法:
   QFileIconProvider → QMimeDatabase/QIcon::fromTheme → 通用
   压缩包图标,替换压缩设置页和进度页两处调用点
3. 影响:jar 和 tar.bz2 压缩格式图标恢复正常显示,其他格式
   无行为变化

Log: 修复jar和tar.bz2压缩格式图标不显示问题

Influence:
1. 测试jar格式压缩时预览图标显示
2. 测试tar.bz2格式压缩时预览图标显示
3. 测试zip、7z、tar.gz格式图标显示正常无回归
4. 验证压缩完成后进度页文件图标显示

PMS: BUG-378903
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx

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

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes missing jar and tar.bz2 icons by replacing direct QFileIconProvider calls with a shared UiTools helper that falls back through MIME theme resolution to a generic archive icon, covering both compression preview and progress pages.

Sequence diagram for archive icon fallback resolution

sequenceDiagram
    participant Page as CompressionPage
    participant UiTools
    participant FileIcons as QFileIconProvider
    participant MimeDB as QMimeDatabase
    participant Theme as QIconTheme

    Page->>UiTools: getArchiveIcon(fileName)
    UiTools->>FileIcons: icon(QFileInfo(fileName))
    alt icon available
        FileIcons-->>UiTools: archive icon
    else icon missing
        UiTools->>MimeDB: mimeTypeForFile(fileName, MatchExtension)
        MimeDB-->>UiTools: QMimeType.iconName()
        UiTools->>Theme: fromTheme(iconName)
        alt MIME icon available
            Theme-->>UiTools: MIME archive icon
        else MIME icon missing
            UiTools->>Theme: fromTheme(application-x-archive)
            Theme-->>UiTools: generic archive icon
        end
    end
    UiTools-->>Page: QIcon
Loading

File-Level Changes

Change Details Files
Centralize archive icon resolution with layered fallbacks for missing system theme entries.
  • Add a shared helper that tries QFileIconProvider, MIME-derived theme icons, and a generic archive theme icon.
  • Use the helper for archive previews and progress-page icons.
  • Retain existing behavior for formats whose provider icons resolve successfully.
src/source/common/uitools.cpp
src/source/common/uitools.h
src/source/page/compresssettingpage.cpp
src/source/page/progresspage.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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 96 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 96 分,大于 70 分通过阈值。本次提交通过提取公共函数 getArchiveIcon 实现了图标获取逻辑的统一管理,三级回退机制设计合理,消除了代码重复,代码质量良好。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 语法正确,逻辑清晰。三级回退机制(QFileIconProvider → QMimeDatabase → 通用归档图标)设计合理,icon.isNull() 与 icon.availableSizes().isEmpty() 双重检查确保图标有效性。


2. 代码质量 ✅

评价: 良好 ✅ 通过

潜在问题:

  1. src/source/common/uitools.cpp:113 - qDebug() 在工具函数 getArchiveIcon 中输出日志,虽然与项目现有风格一致,但在频繁调用的工具函数中可能产生不必要的日志噪音,建议使用 QLoggingCategory 按模块控制日志级别

建议: 代码结构清晰,注释完整。建议在 release 构建中通过 Qt 日志级别控制减少 qDebug 输出,或使用 QtLoggingCategory 按模块控制日志级别。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,资源使用合理。QFileIconProvider 和 QMimeDatabase 均为栈对象,生命周期短,不会造成资源泄漏。三级回退按效率从高到低排列,仅在必要时触发后续回退。QIcon 返回值利用 Qt 隐式共享机制,无额外拷贝开销。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 存在0个安全漏洞。代码仅涉及图标查询操作,无文件读写、网络请求或命令执行,无安全风险。


💡 改进建议代码示例

// 建议使用 QLoggingCategory 控制工具函数日志级别
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(uiToolsCategory, "uitools", QtWarningMsg)

QIcon UiTools::getArchiveIcon(const QString &fileName)
{
    qCDebug(uiToolsCategory) << "Getting archive icon for:" << fileName;
    QFileIconProvider provider;
    QIcon icon = provider.icon(QFileInfo(fileName));

    if (icon.isNull() || icon.availableSizes().isEmpty()) {
        QMimeDatabase mimeDb;
        QMimeType mimeType = mimeDb.mimeTypeForFile(fileName, QMimeDatabase::MatchExtension);
        QString iconName = mimeType.iconName();
        if (!iconName.isEmpty()) {
            icon = QIcon::fromTheme(iconName);
        }
    }

    if (icon.isNull() || icon.availableSizes().isEmpty()) {
        icon = QIcon::fromTheme(QStringLiteral("application-x-archive"));
    }

    return icon;
}

本报告由 AI 代码审查工具自动生成

@deepin-bot

deepin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.5.36
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #505

@pengfeixx pengfeixx closed this Oct 14, 2026
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.

2 participants