Skip to content

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented Jan 31, 2026

  1. Updated copyright year from 2025 to 2025-2026 across multiple files
  2. Removed Chinese comments from abstract class header file (AbstractBiometricController.h) to maintain code consistency
  3. Fixed fingerprint enrollment error message - changed from empty string to "Scan suspended" when enrollment fails
  4. Added fingerprint image path update on enrollment failure to show appropriate visual feedback
  5. Added safety checks in timer and animation handlers to prevent unnecessary updates when enrollment is already in Fail or Success state
  6. Added dialog window active state handling to stop fingerprint enrollment when dialog becomes inactive during enrollment process

Log: Improved fingerprint enrollment error handling with proper visual feedback and state management

fix: 更新指纹录入错误处理和UI逻辑

  1. 将多个文件的版权年份从2025更新为2025-2026
  2. 从抽象类头文件中移除中文注释以保持代码一致性
  3. 修复指纹录入错误消息 - 当录入失败时从空字符串改为"扫描已暂停"
  4. 在录入失败时添加指纹图像路径更新以显示适当的视觉反馈
  5. 在定时器和动画处理程序中添加安全检查,防止在录入已处于失败或成功状态 时进行不必要的更新
  6. 添加对话框窗口活动状态处理,在录入过程中对话框变为非活动状态时停止指 纹录入

Log: 改进了指纹录入错误处理,提供适当的视觉反馈和状态管理

PMS: BUG-306585

Copy link

@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.

Sorry @mhduiy, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot
Copy link

deepin pr auto review

这段代码主要是关于指纹认证功能的修改,涉及到了版权年份更新、错误提示信息优化、状态逻辑修复以及对话框生命周期管理。以下是对代码的详细审查意见:

1. 整体评价

代码主要针对指纹录入流程中的异常处理和UI交互进行了优化。整体逻辑清晰,能够解决在特定场景下(如录入失败后)状态不一致或UI刷新异常的问题。

2. 详细审查意见

2.1 版权信息更新

位置: 所有文件头部

-//SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
+//SPDX-FileCopyrightText: 2025 - 2026 UnionTech Software Technology Co., Ltd.

意见:

  • 规范性: 符合SPDX规范,更新年份范围是正确的做法。
  • 建议: 无需修改。

2.2 错误提示文案优化

位置: src/plugin-authentication/operation/charamangermodel.cpp

-        QString msg = "";
+        QString msg = tr("Scan suspended");

意见:

  • 代码质量: 将空字符串替换为具体的提示信息 "Scan suspended"(扫描暂停/中止),提升了用户体验,避免了用户看到空白提示的困惑。
  • 国际化: 正确使用了 tr() 包裹字符串,支持国际化。
  • 建议: 无需修改。

2.3 失败状态下的UI资源处理

位置: src/plugin-authentication/operation/fingerprintauthcontroller.cpponFingerEnrollFailed 方法

+    m_fingertipImagePath = "user_biometric_fingerprint_lose";

意见:

  • 逻辑: 在录入失败时显式设置图标路径为失败图标,确保UI显示正确。
  • 代码质量: 增强了代码的健壮性,防止残留旧的图标路径。
  • 建议:
    • 检查资源文件中是否存在 user_biometric_fingerprint_lose 对应的图标资源,避免运行时加载图片失败。
    • 建议将此类字符串路径定义为常量或宏,统一管理,避免硬编码字符串散落在代码中(例如在类头文件中定义 static const QString ICON_FAIL)。

2.4 状态检查防止无效操作

位置: src/plugin-authentication/operation/fingerprintauthcontroller.cpponFingerLiftTimerTimeoutonFingerAniValueChanged

+    if (m_addStage == CharaMangerModel::Fail || m_addStage == CharaMangerModel::Success) {
+        return;
+    }

意见:

  • 逻辑:
    • 在定时器回调中增加了状态检查。如果流程已经结束(成功或失败),直接返回,不再更新提示语。这防止了流程结束后UI文字被重置的问题。
    • 在动画值变更回调中增加了状态检查。如果流程已失败,不再更新图标路径,防止覆盖了失败图标。
  • 代码质量: 很好的防御性编程实践。
  • 建议:
    • 考虑到多处需要判断 m_addStage 是否处于结束状态,建议在 CharaMangerModel 类中增加一个辅助内联函数,如 isFinished(),来统一判断逻辑,提高代码可读性。
    • 示例:
      // 在 CharaMangerModel 中
      inline bool isFinished() const { return m_addStage == Success || m_addStage == Fail; }
      // 使用处
      if (m_addStage.isFinished()) return;

2.5 对话框非活跃时停止录入

位置: src/plugin-authentication/qml/AddFingerDialog.qml

+    onActiveChanged: function() {
+        if (listview.currentIndex == 1 && !active) {
+            dccData.fingerprintController.stopEnroll()
+        }
+    }

意见:

  • 逻辑: 当对话框失去焦点(!active)且当前显示的是录入页面(currentIndex == 1)时,调用停止录入接口。
  • 代码质量:
    • 这是一个重要的资源释放逻辑,防止后台继续运行指纹扫描硬件,节省功耗并避免状态机冲突。
    • 使用了 QML 的信号处理机制,符合规范。
  • 性能与安全:
    • 性能: 避免了后台无用的硬件轮询,有益于性能。
    • 安全: 确保了在用户切换窗口或关闭对话框时,敏感的生物识别采集过程能够及时停止。
  • 建议:
    • 逻辑边界: 需确认 active 属性的行为。在某些窗口管理器中,对话框被最小化或遮挡时 active 可能会变化。如果用户仅仅是切换到其他窗口查看信息,指纹录入就被强制停止,体验可能不好。
    • 改进: 通常这种逻辑放在 visible 变化或 closing 信号中更为稳妥。如果确实需要在失去焦点时停止,建议确认这是符合产品预期的交互设计。如果是为了防止对话框关闭后后台继续运行,建议优先检查 visible 变为 false 的情况。

3. 总结

该次修改主要提升了指纹录入功能的稳定性和用户体验。

  1. 优点: 增加了状态判断,修复了流程结束后UI状态可能被错误刷新的问题;增加了对话框失焦时的资源清理逻辑;优化了错误提示。
  2. 风险点:
    • QML 中的 onActiveChanged 逻辑可能会过于激进地中断用户操作,建议测试在窗口切换场景下的用户体验。
    • 字符串资源路径建议常量化管理。

总体而言,代码改动是安全且必要的,逻辑清晰。建议在合并前重点关注 QML 部分的交互逻辑是否符合实际产品需求。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23, mhduiy

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

1. Updated copyright year from 2025 to 2025-2026 across multiple files
2. Removed Chinese comments from abstract class header file
(AbstractBiometricController.h) to maintain code consistency
3. Fixed fingerprint enrollment error message - changed from empty
string to "Scan suspended" when enrollment fails
4. Added fingerprint image path update on enrollment failure to show
appropriate visual feedback
5. Added safety checks in timer and animation handlers to prevent
unnecessary updates when enrollment is already in Fail or Success state
6. Added dialog window active state handling to stop fingerprint
enrollment when dialog becomes inactive during enrollment process

Log: Improved fingerprint enrollment error handling with proper visual
feedback and state management

fix: 更新指纹录入错误处理和UI逻辑

1. 将多个文件的版权年份从2025更新为2025-2026
2. 从抽象类头文件中移除中文注释以保持代码一致性
3. 修复指纹录入错误消息 - 当录入失败时从空字符串改为"扫描已暂停"
4. 在录入失败时添加指纹图像路径更新以显示适当的视觉反馈
5. 在定时器和动画处理程序中添加安全检查,防止在录入已处于失败或成功状态
时进行不必要的更新
6. 添加对话框窗口活动状态处理,在录入过程中对话框变为非活动状态时停止指
纹录入

Log: 改进了指纹录入错误处理,提供适当的视觉反馈和状态管理

PMS: BUG-306585
@mhduiy
Copy link
Contributor Author

mhduiy commented Jan 31, 2026

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Jan 31, 2026

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit bce9850 into linuxdeepin:master Jan 31, 2026
15 of 18 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