Skip to content

fix: add sidebar entries for /media and /mnt in mount dialog - #237

Open
wangrong1069 wants to merge 1 commit into
linuxdeepin:masterfrom
wangrong1069:agent/agent/f4963331216e
Open

wangrong1069 wants to merge 1 commit into
linuxdeepin:masterfrom
wangrong1069:agent/agent/f4963331216e

Conversation

@wangrong1069

@wangrong1069 wangrong1069 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

The mount point selection dialog in deepin-diskmanager uses DFileChooserEdit in MountDialog::initUi(). Without setting QFileDialog::DontUseNativeDialog, the DDE platform theme plugin intercepts QFileDialog and routes it through D-Bus to the DDE native file dialog (dde-file-dialog). The native dialog's "Computer" view navigates to computer://, which only shows block devices and special locations — /media and /mnt are not visible. Additionally, setSidebarUrls() was never called, so no custom sidebar shortcuts exist for these directories. Key evidence: application/widgets/mountdialog.cpp:51-58 (no DontUseNativeDialog, no setSidebarUrls).

Fix

Set QFileDialog::DontUseNativeDialog to bypass the DDE native dialog and use the Qt built-in file dialog, then call setSidebarUrls() with file:///media and file:///mnt to add sidebar shortcuts. This is the minimal change — only 6 lines added, no existing code modified or deleted.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Target lines (51–58) are not a historical fix product for DontUseNativeDialog/setSidebarUrls; this change only appends code after setAcceptMode, does not revert any historical fix
  • No external callers affected (references list is empty, code graph unavailable)

Business Impact Scope

Affects the mount point selection dialog in the disk manager's mount functionality. After the change, the dialog uses Qt built-in style (instead of DDE native style) with /media and /mnt sidebar shortcuts. Users can directly navigate to these directories from the sidebar to select a valid mount point.

Verification Suggestion

Verify the mount point dialog opens correctly with /media and /mnt visible in the sidebar, and that selecting a directory from either path works without regression in the open/select/cancel flow.


根因分析

磁盘管理器挂载点选择对话框在 MountDialog::initUi() 中使用 DFileChooserEdit。由于未设置 QFileDialog::DontUseNativeDialog,DDE 平台主题插件拦截 QFileDialog 并通过 D-Bus 调用 DDE 原生文件对话框(dde-file-dialog)。原生对话框的"计算机"视图导航到 computer://,仅显示块设备和特殊位置,/media 和 /mnt 不可见。同时未调用 setSidebarUrls(),侧边栏无这两个目录的快捷入口。关键证据:application/widgets/mountdialog.cpp:51-58。

修复方案

设置 QFileDialog::DontUseNativeDialog 绕过 DDE 原生对话框,使用 Qt 内置文件对话框;调用 setSidebarUrls() 添加 file:///media 和 file:///mnt 侧边栏快捷入口。改动最小——仅新增 6 行,不修改或删除任何已有代码。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 目标行(51–58)非 DontUseNativeDialog/setSidebarUrls 相关历史修复产物;本次改动仅在 setAcceptMode 后追加代码,不撤销任何已有修复
  • 无外部调用者受影响(references 为空,代码图谱不可用)

业务影响范围

影响磁盘管理器挂载功能中的挂载点选择对话框。改动后对话框使用 Qt 内置风格(替代 DDE 原生风格),侧边栏新增 /media 和 /mnt 快捷入口。用户可从侧边栏直接导航到这些目录选择有效挂载点。

验证建议

验证挂载点对话框正常打开,侧边栏显示 /media 和 /mnt 入口,从侧边栏选择目录后挂载流程无回归。

PMS: BUG-355887

Summary by Sourcery

Make /media and /mnt directly accessible when selecting mount points.

New Features:

  • Add /media and /mnt shortcuts to the mount point selection dialog sidebar.

Bug Fixes:

  • Ensure the mount point dialog exposes /media and /mnt for directory selection.

Enhancements:

  • Use the Qt file dialog for mount point selection instead of the native dialog.

1. Root cause: DFileChooserEdit in MountDialog::initUi did not set
   DontUseNativeDialog, so DDE platform theme intercepted QFileDialog
   via D-Bus to dde-file-dialog; its "Computer" view (computer://) only
   shows block devices and special locations, hiding /media and /mnt
2. Fix: set QFileDialog::DontUseNativeDialog to use Qt built-in dialog,
   then call setSidebarUrls with file:///media and file:///mnt entries
3. Impact: mount point dialog switches from DDE native style to Qt
   built-in style; sidebar now shows /media and /mnt shortcuts

Log: Fix mount point dialog missing /media and /mnt access

Influence:
1. Test mount point dialog opens and sidebar shows /media and /mnt
2. Test navigating to /media and /mnt subdirectories from sidebar
3. Test dialog open/select/cancel flow has no regression

fix: 挂载点对话框添加 /media 和 /mnt 侧边栏入口

1. 根因:MountDialog::initUi 中 DFileChooserEdit 未设置
   DontUseNativeDialog,DDE 平台主题插件拦截 QFileDialog 通过 D-Bus
   调用 dde-file-dialog;其"计算机"视图(computer://)仅显示块设备和
   特殊位置,不显示 /media 和 /mnt
2. 方案:设置 QFileDialog::DontUseNativeDialog 使用 Qt 内置对话框,
   调用 setSidebarUrls 添加 file:///media 和 file:///mnt 侧边栏入口
3. 影响:挂载点对话框从 DDE 原生风格切换为 Qt 内置风格,侧边栏新增
   /media 和 /mnt 快捷入口

Log: 修复挂载点对话框无法访问 /media 和 /mnt 的问题

Influence:
1. 测试挂载点对话框打开后侧边栏显示 /media 和 /mnt 入口
2. 测试从侧边栏导航到 /media 和 /mnt 子目录并选择挂载点
3. 测试对话框打开/选择/取消流程无回归

PMS: BUG-355887
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wangrong1069

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 28, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The mount-point selection dialog now bypasses the DDE native file dialog and exposes /media and /mnt as sidebar locations, allowing users to reach these directories directly while preserving directory-only open selection behavior.

Sequence diagram for mount point directory selection

sequenceDiagram
    participant User
    participant MountDialog
    participant DFileChooserEdit
    participant QFileDialog

    MountDialog->>DFileChooserEdit: fileDialog()
    DFileChooserEdit->>QFileDialog: setOption(DontUseNativeDialog)
    DFileChooserEdit->>QFileDialog: setSidebarUrls(sidebarUrls)
    User->>QFileDialog: Select directory from /media or /mnt
    QFileDialog-->>MountDialog: Directory selection
Loading

File-Level Changes

Change Details Files
Switch the mount-point chooser to Qt’s non-native file dialog and add direct sidebar shortcuts for /media and /mnt.
  • Include the Qt container and URL types needed to construct sidebar entries.
  • Enable DontUseNativeDialog after configuring directory selection and open mode.
  • Build and apply sidebar URLs for file:///media and file:///mnt.
application/widgets/mountdialog.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 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交为挂载对话框文件选择器添加了 /media 和 /mnt 的侧边栏快捷入口,变更范围小、逻辑清晰、无安全漏洞。新增的 QList/QUrl 头文件包含正确,代码放置在 initUi() 中合适的位置,与既有代码风格一致。语法逻辑、代码质量、代码性能、代码安全四个维度均通过,启发式扫描与 OCR 审查均未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

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

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

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

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

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

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例


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

@deepin-bot

deepin-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.28
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #251

@deepin-bot

deepin-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.29
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #259

@deepin-bot

deepin-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.30
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #261

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