Skip to content

Conversation

@deepin-mozart
Copy link
Contributor

@deepin-mozart deepin-mozart commented Nov 6, 2025

Log:
Change-Id: I3b0e46adb702f8190b1c178e819ccadcc5581e44

Summary by Sourcery

Enhance translation handling in CMake and fix runtime library path configuration for plugin loading

Bug Fixes:

  • Add custom library paths for dependencies and plugins to QCoreApplication to ensure correct plugin loading at runtime

Enhancements:

  • Enforce Qt LinguistTools as a required package in CMake
  • Unify translation generation using qt5_add_translation or qt6_add_translation and add a custom translations target with dependencies

Chores:

  • Remove unused setCurrentPlugin slot from UI controller

Log:
Change-Id: I3b0e46adb702f8190b1c178e819ccadcc5581e44
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepin-mozart

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

  • 检测到debian目录文件有变更: debian/rules

  • 检测到敏感词export变动

详情
    {
    "export": {
        "debian/rules": {
            "a": [
                "export DEB_CFLAGS_MAINT_APPEND = -Wall -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=1 -fPIC",
                "export DEB_CXXFLAGS_MAINT_APPEND = -Wall -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=1 -fPIC"
            ],
            "b": [
                "export DEB_CFLAGS_MAINT_APPEND = -Wall -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC",
                "export DEB_CXXFLAGS_MAINT_APPEND = -Wall -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIC"
            ]
        }
    }
}

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 6, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR corrects runtime plugin library loading by dynamically configuring library paths in main.cpp, revamps the CMake translation workflow for both Qt5/Qt6 (including mandatory LinguistTools, TS collection, translation targets, and installation), and removes obsolete code in the UI controller header.

Sequence diagram for updated plugin library path setup at runtime

sequenceDiagram
    participant App as "Application Startup"
    participant CustomPaths as "CustomPaths"
    participant QCoreApp as "QCoreApplication"
    participant LifeCycle as "LifeCycle"
    App->>CustomPaths: global(DependLibs)
    CustomPaths-->>App: dependlibs path
    App->>QCoreApp: addLibraryPath(dependlibs)
    App->>QCoreApp: addLibraryPath(pluginsPath)
    App->>LifeCycle: setPluginPaths({pluginsPath})
    App->>QCoreApp: libraryPaths()
    App->>LifeCycle: pluginPaths()
Loading

Class diagram for updated UIController (controller.h)

classDiagram
    class UIController {
        +void raiseMode(QString mode)
        +void registerWidgetToMode(QString name, AbstractWidget* abstractWidget, QString mode, Position pos, bool replace, bool isVisible)
        +void registerWidget(QString name, AbstractWidget* abstractWidget)
        +void registerWidgetCreator(QString name, function<AbstractWidget*()> &widgetCreateFunc)
    }
    class AbstractWidget
    UIController --> AbstractWidget
Loading

File-Level Changes

Change Details Files
Revamped CMake translation pipeline and Qt find_package requirement
  • Marked Qt LinguistTools as REQUIRED
  • Defined TS_DIR and collected .ts files for translation
  • Set source file output location for TS files
  • Switched to qt5_add_translation/qt6_add_translation for generating .qm files
  • Added custom target for translations and project dependency
  • Ensured installation of generated .qm files
assets/CMakeLists.txt
Enhanced runtime library path setup in main application
  • Fetched dependency library path from CustomPaths
  • Added dependency and plugin directories to QApplication library paths
  • Updated log message to display current library paths
src/app/main.cpp
Removed obsolete slot declaration in UI controller header
  • Deleted setCurrentPlugin slot
src/plugins/core/uicontroller/controller.h

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

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这段代码变更进行详细审查:

  1. CMakeLists.txt 变更:
  • 改进:添加了 REQUIRED 到 find_package 中,这是一个好的实践,可以确保在 Qt LinguistTools 不可用时构建失败
  • 改进:重构了翻译文件处理逻辑,使用 qt5/qt6_add_translation 替代了原来的手动处理,更加标准化和可靠
  • 改进:添加了自定义翻译目标,并建立了依赖关系,确保翻译文件在主程序构建前生成
  • 建议:SOURCES_INSTALL_RPEFIX 有拼写错误,应该是 PREFIX
  1. debian/rules 变更:
  • 改进:将 _FORTIFY_SOURCE 从 1 升级到 2,提供了更强的缓冲区溢出保护
  • 改进:保持了良好的编译器安全标志设置,包括 PIE、栈保护等
  1. main.cpp 变更:
  • 改进:添加了显式的库路径设置,使用 CustomPaths::global 获取依赖库路径
  • 改进:同时添加了插件路径到库路径中,确保插件能正确加载
  • 建议:可以考虑添加错误检查,确保路径存在且可访问
  1. controller.h 变更:
  • 改进:移除了 setCurrentPlugin 函数,这可能是为了简化插件管理逻辑
  • 建议:如果移除了这个函数,需要确保没有其他代码依赖它

总体建议:

  1. 安全性:代码变更整体上提高了安全性,特别是编译器标志的改进
  2. 可维护性:翻译处理的重构使代码更加标准化和易于维护
  3. 性能:变更对性能影响较小,主要是功能改进
  4. 错误处理:建议在关键路径添加更多的错误检查和日志记录

建议添加的错误处理示例:

QString dependlibs = CustomPaths::global(CustomPaths::DependLibs);
if (!QDir(dependlibs).exists()) {
    qWarning() << "Dependency library path does not exist:" << dependlibs;
}
QCoreApplication::addLibraryPath(dependlibs);

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.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-mozart
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Nov 6, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit a6d0b5b into linuxdeepin:master Nov 6, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants