Skip to content

sync: from linuxdeepin/dtkwidget#175

Merged
18202781743 merged 1 commit intomasterfrom
sync-pr-691-nosync
Nov 6, 2025
Merged

sync: from linuxdeepin/dtkwidget#175
18202781743 merged 1 commit intomasterfrom
sync-pr-691-nosync

Conversation

@deepin-ci-robot
Copy link
Contributor

Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#691

@18202781743
Copy link
Contributor

/topic dtk-cpv20

@deepin-ci-robot
Copy link
Contributor Author

Add topic: dtk-cpv20 successed.

@deepin-ci-robot
Copy link
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-ci-robot

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

Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#691
@deepin-ci-robot
Copy link
Contributor Author

deepin pr auto review

我将对这个 git diff 进行详细的代码审查。这个 diff 包含了多个文件的修改和新增,涉及界面组件、打印预览、图标资源等多个方面。我将从代码质量、性能、安全性等方面进行分析。

  1. 新增的 DBlurEffectWithBorderWidget 类
class DBlurEffectWithBorderWidget : public DBlurEffectWidget
{
    Q_OBJECT
public:
    explicit DBlurEffectWithBorderWidget(QWidget *parent = nullptr);

protected:
    void paintEvent(QPaintEvent *e) override;

private:
    D_DECLARE_PRIVATE(DBlurEffectWithBorderWidget)
};

改进建议:

  • 缺少文档注释,建议添加类的功能说明和使用示例
  • paintEvent 方法应该标记为 const,因为它不应该修改对象状态
  • 考虑添加边框宽度和颜色的配置接口,而不是硬编码
  1. DPasswordEdit 类修改
bool eventFilter(QObject* watcher, QEvent* event) override;

改进建议:

  • eventFilter 的实现应该添加空指针检查
  • 建议使用 QKeyEvent::key() == Qt::Key_Return || QKeyEvent::key() == Qt::Key_Enter 的判断方式更清晰
  • 可以考虑使用 QSignalMapper 或者新的信号槽语法来简化代码
  1. 打印预览相关修改
colorModeCombo->addItems(QStringList() << qApp->translate("DPrintPreviewDialogPrivate", "Full Color") << qApp->translate("DPrintPreviewDialogPrivate", "Grayscale"));

改进建议:

  • 翻译字符串应该使用 tr() 函数而不是 qApp->translate()
  • "Full Color" 的翻译可能需要考虑其他语言的本地化
  1. 图标资源修改
  • SVG 图标的修改主要是位置调整和样式优化
  • 建议确保所有图标的 viewBox 和尺寸保持一致
  • 考虑使用 symbol 元素来减少重复的路径定义
  1. 性能优化建议:
  • DBlurEffectWithBorderWidget 的 paintEvent 中可以考虑使用 QPixmapCache 来缓存绘制结果
  • 打印预览对话框的初始化可以考虑延迟加载
  • 频繁调用的绘制函数应该考虑使用 QPainter 的优化选项
  1. 安全性建议:
  • DPasswordEdit 的事件过滤应该添加更严格的类型检查
  • 打印预览中的文件路径处理应该添加路径验证
  • 配置文件的读写应该添加错误处理
  1. 代码质量建议:
  • 新增的类应该添加单元测试
  • 复杂的函数应该拆分成更小的函数
  • 魔法数字应该定义为常量
  • 添加更多的错误处理和日志记录
  1. 其他建议:
  • 考虑使用 Q_PROPERTY 来暴露一些关键属性
  • 添加更多的文档注释
  • 考虑使用现代 C++ 特性来简化代码
  • 确保所有的资源文件都有适当的许可证信息

这些修改总体上看起来是合理的,但建议按照上述建议进行改进,以提高代码质量和可维护性。

@18202781743 18202781743 merged commit 72a1022 into master Nov 6, 2025
14 of 17 checks passed
@18202781743 18202781743 deleted the sync-pr-691-nosync branch November 6, 2025 02:37
@github-project-automation github-project-automation bot moved this to Done in dtk-cpv20 Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants