Skip to content

Conversation

@pengfeixx
Copy link
Contributor

Fix the issue where the time does not follow the regional format

Log: Fix the issue where the time does not follow the regional format
pms: BUG-342705

deepin-ci-robot added a commit to linuxdeepin/dde-session-shell-snipe that referenced this pull request Dec 23, 2025
Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#54
@BLumia BLumia requested a review from yixinshark December 24, 2025 02:47
Fix the issue where the time does not follow the regional format

Log: Fix the issue where the time does not follow the regional format
pms: BUG-342705
deepin-ci-robot added a commit to linuxdeepin/dde-session-shell-snipe that referenced this pull request Dec 24, 2025
Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#54
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个代码变更进行审查:

  1. 代码逻辑和语法:
  • 代码语法正确,符合C++规范
  • 条件编译指令 #ifdef ENABLE_DSS_SNIPE 使用正确
  • 新增的 getUserLocale() 函数实现逻辑清晰
  1. 代码质量:
    优点:
  • 将重复的locale获取逻辑抽取成独立函数 getUserLocale(),提高了代码复用性
  • 函数命名清晰,符合命名规范
  • 适当的空指针检查

改进建议:

  • getUserLocale() 函数可以考虑添加对返回值的空字符串检查
  • 建议在函数头添加注释说明函数的功能和参数说明
  1. 代码性能:
  • 新增的函数调用不会带来明显的性能开销
  • D-Bus 调用次数保持不变,没有增加性能负担
  1. 代码安全:
  • 对空指针进行了适当检查
  • 对返回值进行了空字符串检查
  • 使用了常量引用传递参数,避免不必要的拷贝

具体改进建议:

  1. getUserLocale() 函数添加文档注释:
/**
 * @brief 获取用户的语言环境设置
 * @param user 用户对象指针
 * @return 返回用户的locale字符串,如果获取失败则返回系统默认locale
 */
QString CenterTopWidget::getUserLocale(const User *user) const
  1. 添加对返回值的额外检查:
QString CenterTopWidget::getUserLocale(const User *user) const
{
    if (!user)
        return QLocale::system().name();

    if (qApp->applicationName() == "dde-lock")
        return QLocale::system().name();

    QString userConfigDbusPath = getRegionFormatConfigPath(user);
    QString localeName = getRegionFormatValue(userConfigDbusPath, localeNameKey);
    if (localeName.isEmpty()) {
        localeName = user->locale();
    }
    // 确保返回值不为空
    return localeName.isEmpty() ? QLocale::system().name() : localeName;
}
  1. 考虑将 localeNameKey 定义为类的常量成员,避免魔法字符串:
private:
    static const QString LOCALE_NAME_KEY; // 在cpp文件中初始化

总体来说,这是一个良好的代码重构,提高了代码的可维护性和复用性,同时没有引入额外的性能或安全问题。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx, yixinshark

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

@pengfeixx
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 25, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 9da746c into linuxdeepin:master Dec 25, 2025
14 of 15 checks passed
@pengfeixx pengfeixx deleted the fix-fix-342705 branch December 25, 2025 01:18
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