Skip to content

fix: keep the device list usable while the scanners are enumerated - #47

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
re2zero:bugfix-316711-device-list
Oct 12, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
re2zero:bugfix-316711-device-list

Conversation

@re2zero

@re2zero re2zero commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

fix: keep the device list usable while the scanners are enumerated

The device list was covered by a modal loading overlay until the SANE
enumeration returned, so nothing was usable for as long as the backend needed.
The overlay is a child widget now and follows the window, the cameras are
listed immediately while the scanning state moves to the title row, and the
empty state appears only when no enumeration is in flight. The four
maintainable .ts files were refreshed.

设备列表原本被模态加载浮层挡住,SANE 枚举返回前界面完全不可用。现改为窗口内的子控件浮层并随
窗口移动,本地摄像头立即列出、"正在搜索"移到标题行,只有枚举全部结束才显示空状态;同时刷新
四个可维护的 .ts 翻译文件。

Log: 加载设备列表期间界面不再阻塞,进入扫描管理器即可见本地设备
PMS: BUG-316711
Influence: 加载期间窗口可拖动、列表可交互、无摄像头时不再与"正在加载设备..."同时显示"未找到设备";打包构建不再产生 translations/ 的改动。

Summary by Sourcery

Keep the device manager interactive while scanner devices are being discovered.

New Features:

  • Show locally available cameras immediately while scanner enumeration is still in progress.
  • Display scanner discovery progress in the device-list title row.

Bug Fixes:

  • Keep the device list and main window usable during slow scanner enumeration.
  • Prevent the empty state from appearing until scanner discovery has completed.
  • Avoid opening a device multiple times while another loading operation is active.

Enhancements:

  • Make the loading overlay a movable child of the main window that remains centered during resizing.
  • Add timing and failure diagnostics for SANE device enumeration.

Chores:

  • Refresh the maintained translation files and update translated device-list status messages.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR keeps the scanner manager responsive during slow SANE discovery by presenting local cameras immediately, replacing the modal loader with a parented movable overlay, and representing scanner enumeration in the title row until completion; it also adds diagnostics and refreshes the maintained translation catalogs.

Sequence diagram for responsive device enumeration

sequenceDiagram
    actor User
    participant MainWindow
    participant ScannersWidget
    participant ScannerDevice
    participant ScannerWorker
    participant SANE

    User->>MainWindow: updateDeviceList()
    MainWindow->>ScannersWidget: setScannerSearching(true)
    MainWindow->>ScannersWidget: updateDeviceList(scanner, webcam)
    ScannersWidget->>ScannersWidget: rebuildList()
    ScannersWidget-->>User: Show local cameras and searching state
    MainWindow->>ScannerDevice: requestAvailableDevices()
    ScannerDevice->>ScannerWorker: doGetAvailableDevices()
    ScannerWorker->>SANE: sane_get_devices()
    Note over User,ScannersWidget: Window and camera entries remain usable while enumeration runs
    SANE-->>ScannerWorker: device list
    ScannerWorker-->>ScannerDevice: availableDevicesReady(deviceNames)
    ScannerDevice-->>MainWindow: availableDevicesReady(deviceNames)
    MainWindow->>ScannersWidget: setScannerSearching(false)
    MainWindow->>ScannersWidget: updateDeviceList(scanner, webcam)
    ScannersWidget->>ScannersWidget: rebuildList()
    ScannersWidget-->>User: Show scanners and final empty state if needed
Loading

File-Level Changes

Change Details Files
Make device enumeration non-blocking to the device-list UI and expose timing/failure diagnostics.
  • Log SANE enumeration duration and failures.
  • Show the initial device list immediately, retry scanner discovery once after a delay, and keep the searching state until the retry completes.
src/device/scannerdevice.cpp
src/mainwindow.cpp
Replace the modal loading window with a movable, parented overlay that tracks the main window.
  • Convert the loading dialog to a hidden child widget without modality or always-on-top window flags.
  • Recenter the overlay on parent resize and prevent opening another device while loading.
src/ui/loadingdialog.cpp
src/ui/loadingdialog.h
src/mainwindow.cpp
Move scanner discovery feedback into the list title row while preserving usable local camera entries and a correct empty state.
  • Add a title-row spinner and loading label.
  • Disable refresh during scanner enumeration.
  • Suppress the empty placeholder while enumeration is pending and add it only after enumeration finishes.
src/ui/scannerswidget.cpp
src/ui/scannerswidget.h
Refresh translation catalogs to match relocated and newly generated source strings.
  • Update source locations and add translations for current messages across the four maintained catalogs.
  • Move the device-loading string to the ScannersWidget context and mark obsolete entries as vanished.
translations/deepin-scanner_en_US.ts
translations/deepin-scanner_zh_CN.ts
translations/deepin-scanner_zh_HK.ts
translations/deepin-scanner_zh_TW.ts

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 ✨

The device list was covered by a modal loading overlay until the SANE
enumeration returned, so nothing was usable for as long as the backend needed.
The overlay is a child widget now and follows the window, the cameras are
listed immediately while the scanning state moves to the title row, and the
empty state appears only when no enumeration is in flight. The four
maintainable .ts files were refreshed.

设备列表原本被模态加载浮层挡住,SANE 枚举返回前界面完全不可用。现改为窗口内的子控件浮层并随
窗口移动,本地摄像头立即列出、"正在搜索"移到标题行,只有枚举全部结束才显示空状态;同时刷新
四个可维护的 .ts 翻译文件。

Log: 加载设备列表期间界面不再阻塞,进入扫描管理器即可见本地设备
PMS: BUG-316711
Influence: 加载期间窗口可拖动、列表可交互、无摄像头时不再与"正在加载设备..."同时显示"未找到设备";打包构建不再产生 translations/ 的改动。
@re2zero
re2zero force-pushed the bugfix-316711-device-list branch from d2078e9 to 4827ed4 Compare October 12, 2026 06:15
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Fail


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全漏洞,代码结构清晰,性能良好。修复了设备列表在扫描仪枚举期间不可用的问题,移除了阻塞式模态加载对话框,改为非阻塞式子组件覆盖层,设备列表立即可用并显示搜索状态指示器。代码注释详尽,设计合理。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 代码逻辑整体正确,边界条件处理完善。availableDevicesReady 回调中的重试机制设计合理,showScanView 中的防重复打开检查正确。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: 注释质量优秀,每个改动都附有详尽的设计理由说明。addPlaceholder() 方法的提取消除了代码重复。LoadingDialog 从模态对话框改为子组件覆盖层的设计合理。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 本次修改显著提升了用户体验性能:移除了阻塞式模态加载对话框和首次运行3秒延迟,设备列表立即可用。QElapsedTimer 诊断计时开销可忽略不计。eventFilter 仅在可见时响应 Resize 事件,设计高效。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 本次修改不涉及用户输入处理、网络操作、文件路径操作等安全敏感场景。新增的日志输出仅包含设备枚举耗时和设备数量,不泄露敏感信息。


💡 改进建议代码示例

// 暂无代码示例

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

@re2zero

re2zero commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@re2zero

re2zero commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot

deepin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

This pr cannot be merged! (status: unstable)

@re2zero

re2zero commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit aca63af into linuxdeepin:master Oct 12, 2026
14 of 15 checks passed
@re2zero
re2zero deleted the bugfix-316711-device-list branch October 12, 2026 06:42
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