Skip to content

fix(ui): show available space instead of total capacity in size info … - #220

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
GongHeng2017:202609091404-master-fix
Sep 9, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
GongHeng2017:202609091404-master-fix

Conversation

@GongHeng2017

@GongHeng2017 GongHeng2017 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

…widget

The capacity bar label in the disk/partition detail view was showing total capacity. Per product decision, change it to show available space with the label 'Available:' instead of the
partition path + 'Capacity:'.

Log: Update capacity bar legend to display available space
Bug: https://pms.uniontech.com/bug-view-376505.html

Summary by Sourcery

Show available space with an “Available:” label in the size information widget.

Bug Fixes:

  • Update the disk and partition detail size legend to show available space instead of total capacity.

Enhancements:

  • Apply available-space reporting consistently across partitions, logical volumes, devices, and decrypted LUKS volumes, including unavailable-size states.

Chores:

  • Update source copyright years.

…widget

The capacity bar label in the disk/partition detail view was showing
total capacity. Per product decision, change it to show available space
with the label 'Available:' instead of the
partition path + 'Capacity:'.

Log: Update capacity bar legend to display available space
Bug: https://pms.uniontech.com/bug-view-376505.html
@sourcery-ai

sourcery-ai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

The size information widget now derives and displays available space in its capacity-bar legend, including partition, logical-volume, and decrypted LUKS cases, while preserving placeholders for unavailable values and supporting both light and dark themes.

Flow diagram for available-space capacity legend

flowchart LR
    A["Partition, LV, or device data"] --> B["setData()"]
    B --> C["Format unused space"]
    C --> D["m_availableSize"]
    D --> E["paintEvent()"]
    E --> F["Available: <value>"]
Loading

File-Level Changes

Change Details Files
Track available-space values alongside used-space values for all supported storage types.
  • Populate available size from partition, logical-volume, and decrypted LUKS filesystem data.
  • Use a placeholder for unavailable or encrypted logical-volume/device data.
application/widgets/customcontrol/sizeinfowidget.cpp
application/widgets/customcontrol/sizeinfowidget.h
Update the capacity-bar legend to display available space instead of total capacity.
  • Replace the partition-path capacity label with the localized “Available:” label in both light and dark themes.
  • Render the available-size value and calculate its layout width accordingly.
application/widgets/customcontrol/sizeinfowidget.cpp
Update source ownership metadata and related comments.
  • Extend copyright years through 2026.
  • Revise comments to describe available-space display.
application/widgets/customcontrol/sizeinfowidget.cpp
application/widgets/customcontrol/sizeinfowidget.h

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, lzwind

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

AI 代码审查报告

项目: linuxdeepin/deepin-diskmanager
PR: #220
提交: 023fd39
分支: 202609091404-master-fix → master
分析模式: 全量分析
审查时间: 2026-09-09


总体评分

维度 得分 状态
语法逻辑 22/25 ✓
代码质量 21/25 ✓
代码性能 20/20 ✓
代码安全 30/30 ✓
总分 93/100 优秀

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个


提交概述

标题: fix(ui): show available space instead of total capacity in size info widget

描述: 磁盘/分区详情视图中的容量条标签之前显示的是总容量。根据产品决策,将其改为显示可用空间,标签从分区路径 + "Capacity:" 改为 "Available:"。

Bug: https://pms.uniontech.com/bug-view-376505.html

修改文件:

  1. application/widgets/customcontrol/sizeinfowidget.cpp
  2. application/widgets/customcontrol/sizeinfowidget.h

四维度分析

1. 语法逻辑 ✓ (22/25)

语法正确,逻辑清晰

问题列表:

  1. setData(PartitionInfo) 中 LUKS 未解密时缺少 else 分支设置 m_availableSize = "-",与 setData(LVInfo) 的处理不一致,可能导致加密未解密分区显示误导性的可用空间信息

    • 文件: application/widgets/customcontrol/sizeinfowidget.cpp
    • 行号: 61
    • 函数: setData(PartitionInfo)
    • 扣分: -3分(轻微问题)

    修复建议:

    if (luksInfo.isDecrypt) {
        qDebug() << "LUKS partition is decrypted, updating used/unused size.";
        m_usedSize = Utils::LVMFormatSize(luksInfo.m_mapper.m_fsUsed);
        m_availableSize = Utils::LVMFormatSize(luksInfo.m_mapper.m_fsUnused);
        m_noused = Utils::LVMSizeToUnit(luksInfo.m_mapper.m_fsUnused, SIZE_UNIT::UNIT_GIB);
        m_used = Utils::LVMSizeToUnit(luksInfo.m_mapper.m_fsUsed, SIZE_UNIT::UNIT_GIB);
    } else {
        m_availableSize = "-";
    }

2. 代码质量 ✓ (21/25)

代码结构清晰,注释完整

问题列表:

  1. paintEvent() 中直接修改成员变量 m_availableSize,paintEvent 应为只读渲染函数。contains("-") 检查会导致首次绘制后原始格式化值永久丢失,后续重绘时原始值已不可用

    • 文件: application/widgets/customcontrol/sizeinfowidget.cpp
    • 行号: 294
    • 函数: paintEvent
    • 扣分: -2分
    • 来源: OpenCodeReview

    修复建议:

    // 在 paintEvent 中使用局部变量替代
    QString availableSize = m_availableSize;
    if (availableSize.contains("-"))
        availableSize = "-";
    // 后续绘制使用 availableSize 而非 m_availableSize
  2. 三个 setData 重载中 LUKS 未解密场景的处理不一致:setData(LVInfo) 有 else 分支设置 m_availableSize = "-",setData(PartitionInfo) 和 setData(DeviceInfo) 缺少对应处理

    • 文件: application/widgets/customcontrol/sizeinfowidget.cpp
    • 行号: 61, 160
    • 函数: setData(PartitionInfo) / setData(DeviceInfo)
    • 扣分: -2分
    • 来源: OpenCodeReview

    修复建议: 统一所有 setData 重载中 LUKS 未解密时 m_availableSize 的处理方式,添加 else 分支设置 m_availableSize = "-"

3. 代码性能 ✓ (20/20)

性能良好,资源使用合理

本次变更仅涉及字符串赋值和显示逻辑调整,无性能问题。m_availableSize.contains("-") 为轻量级字符串操作,不影响性能。

4. 代码安全 ✓ (30/30)

存在0个安全漏洞

本次变更不涉及用户输入处理、网络通信、文件操作等安全敏感场景。新增的 m_availableSize 变量仅用于 UI 显示,数据来源为内部计算的磁盘空间信息,无安全风险。


OCR 审查结果

OpenCodeReview 共审查 2 个文件,发现 3 个问题(均为代码逻辑/质量问题,非安全漏洞):

序号 文件 行号 严重程度 描述
1 sizeinfowidget.cpp 294 medium paintEvent() 中直接修改成员变量 m_availableSize,应为只读渲染函数
2 sizeinfowidget.cpp 61 medium setData(PartitionInfo) 中 LUKS 未解密时缺少 else 分支设置 m_availableSize = "-"
3 sizeinfowidget.cpp 160 medium setData(DeviceInfo) 中 LUKS 未解密时未将 m_availableSize 重置为 "-"

审查结论

本次 PR 的目的是将磁盘/分区详情视图中的容量条标签从"总容量"改为"可用空间"。代码实现与 commit message 描述的需求一致,主要变更包括:

  1. 新增 m_availableSize 成员变量,在所有 setData 重载中正确初始化
  2. 在 paintEvent 中将显示从 m_totalSpaceSize 改为 m_availableSize
  3. 标签从分区路径 + "Capacity:" 改为 "Available:"
  4. 更新版权年份和相关注释

代码整体质量良好,正确实现了需求。存在 3 个轻微的代码质量问题(paintEvent 副作用、LUKS 未解密处理不一致),建议修复但不影响合并。

评分: 93/100 (优秀)

@GongHeng2017

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 208b6d2 into linuxdeepin:master Sep 9, 2026
17 checks passed
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