Skip to content

feat: migrate user notice feature - #460

Open
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:feat/user-notice-task-396167
Open

yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:feat/user-notice-task-396167

Conversation

@yixinshark

@yixinshark yixinshark commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Migrate the v20 pre-login user notice to Qt6 and integrate the executable, greeter launch configuration, scripts, and DConfig settings.
  • Reconcile monitor associations across mirror/extended transitions and load background images safely using the ImageEffect1 endpoint.
  • Require notice content to load before acknowledgement and reject explicit window closure to keep the pre-login interface available.

Test plan

  • Release configuration and build of the dde-user-notice target passed.
  • Both shell scripts passed bash syntax checks; configuration JSON validation and git diff whitespace checks passed.
  • Simulated monitor transition and window reuse checks passed during development.
  • Full greeter integration and physical X11/Wayland multi-monitor behavior remain unverified.

Pms: TASK-396167

Summary by Sourcery

Migrate the pre-login user notice to Qt6 and integrate its configurable greeter startup and multi-monitor behavior.

New Features:

  • Add the Qt6 dde-user-notice application for displaying configurable pre-login user notices.
  • Integrate user-notice startup checks, greeter launch configuration, wrapper scripts, and DConfig settings.
  • Support multi-monitor notice presentation across mirror and extended display configurations.
  • Load and display notice backgrounds with cached wallpaper support and safe fallback handling.

Bug Fixes:

  • Prevent acknowledgement before notice content has loaded and ensure explicit window closure cannot dismiss the pre-login notice.

Enhancements:

  • Handle monitor changes by reusing notice windows and updating their screen associations.

Build:

  • Add the dde-user-notice target and installation rules to the project build.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Reviewer's Guide

Migrates the pre-login user notice to a new Qt6/Dtk executable, wiring it into the build and greeter launch path while providing asynchronous notice loading, acknowledgement gating, protected fullscreen presentation, safe background retrieval, and monitor transition handling.

Sequence diagram for loading and acknowledging the user notice

sequenceDiagram
    participant Greeter
    participant Notice as dde-user-notice
    participant Config as UserNoticeConfig
    participant Worker as QtConcurrent worker
    participant UI as PreLoginWindow

    Greeter->>Notice: start executable
    Notice->>Config: noticePath()
    Notice->>Worker: readNoticeContent(path)
    Worker-->>UI: notice content
    alt content loaded
        UI->>UI: enable acknowledge button
        UI-->>Greeter: display notice
        Greeter->>UI: acknowledge()
        UI->>Notice: quit()
    else content unavailable
        UI->>Notice: quit()
    end
Loading

Sequence diagram for monitor transitions and background rendering

sequenceDiagram
    participant Qt as QGuiApplication
    participant Manager as FullScreenManager
    participant Window as FullScreen
    participant ImageEffect as ImageEffect1
    participant Worker as QtConcurrent worker

    Qt->>Manager: screenCountChanged()
    Manager->>Manager: isCopyMode()
    Manager->>Manager: handleScreenChanged()
    Manager->>Window: setScreen(screen)
    Window->>Worker: getBackgroundImage(size, scale)
    Window->>Worker: getBlurBackgroundImage(size, scale)
    Worker->>ImageEffect: Get(background path)
    ImageEffect-->>Worker: blurred image path
    Worker-->>Window: background image
    Window->>Window: repaint()
Loading

File-Level Changes

Change Details Files
Adds the Qt6 user-notice executable and integrates it into the build and pre-greeter launch flow.
  • Registers a new CMake target with Qt6/Dtk dependencies and installation rules.
  • Installs greeter launch configuration and wrapper/check scripts.
  • Adds DConfig schema entries and reads notice display/path settings from the shared configuration.
CMakeLists.txt
dde-user-notice/CMakeLists.txt
dde-user-notice/misc/109_user_notice_conf.json
dde-user-notice/misc/dde_user_notice_warpper
dde-user-notice/misc/user_notice_check.sh
configs/org.deepin.dde.session.ui.json
Implements the pre-login notice UI with asynchronous content loading and acknowledgement-only dismissal.
  • Loads notice text off the GUI thread and keeps acknowledgement disabled until content is available.
  • Supports scaled, scrollable text presentation with fixed light text styling and localized button text.
  • Quits only after acknowledgement and ignores explicit window close events.
dde-user-notice/src/preLoginWindow.cpp
dde-user-notice/src/preLoginWindow.h
dde-user-notice/src/textBrowser.cpp
dde-user-notice/src/textBrowser.h
Adds fullscreen background rendering and monitor-aware window management for mirror and extended display configurations.
  • Creates reusable fullscreen frames and reconciles screen associations during hotplug and copy-mode transitions.
  • Debounces screen geometry changes and refreshes content placement per active screen.
  • Loads and scales a default background asynchronously, using ImageEffect1 for a validated blurred image with a solid-color fallback.
  • Handles Wayland/X11 window flags, stacking, and black-screen transition after authentication.
dde-user-notice/src/abstractfullbackgroundinterface.h
dde-user-notice/src/fullscreen.cpp
dde-user-notice/src/fullscreen.h
dde-user-notice/src/fullscreenmanager.cpp
dde-user-notice/src/fullscreenmanager.h
Adds application startup, palette, translation, logging, and notice-file validation initialization.
  • Configures the Dtk application environment, palette, translator, and journal logging.
  • Validates the configured notice file before starting the event loop and prevents quitting when no fullscreen window remains.
  • Creates the shared pre-login content instance and registers fullscreen frames through the screen manager.
dde-user-notice/src/main.cpp
dde-user-notice/src/noticeconfig.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

@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 found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="dde-user-notice/misc/user_notice_check.sh" line_range="17" />
<code_context>
+    exit 1
+fi
+
+if [ ! -s "${userNoticePath}" ]; then
+    echo "${userNoticePath} does not exist, don't need process userNotice"
+    exit 1
</code_context>
<issue_to_address>
**Unreadable notices are skipped**

When the configured notice file exists and is nonempty but is not readable by the launched process, the pre-greeter check accepts any nonempty file, but `main` exits when that file cannot be opened. The configured notice then never appears, so the user can continue without acknowledging it.

Make the pre-greeter check and launch behavior handle unreadable notice files consistently so an unreadable configured notice cannot silently bypass acknowledgement.

Also at `dde-user-notice/src/main.cpp:80-82`.
</issue_to_address>

### Comment 2
<location path="dde-user-notice/misc/user_notice_check.sh" line_range="7-8" />
<code_context>
+#
+# 供 greeter 的 pre-greeter 调用:返回 0 表示需要显示"用户须知"
+
+userNoticePath=$(dde-dconfig --get -a org.deepin.dde.session.ui -r org.deepin.dde.session.ui -k userNoticePath 2>/dev/null)
+showUserNotice=$(dde-dconfig --get -a org.deepin.dde.session.ui -r org.deepin.dde.session.ui -k showUserNotice 2>/dev/null)
+
+userNoticePath=${userNoticePath//\"/}
</code_context>
<issue_to_address>
**Config errors skip the notice**

When `dde-dconfig` is unavailable or fails to read the settings, the script discards `dde-dconfig` errors and treats empty output as ordinary configuration; the empty path then fails the `-s` check and exits nonzero, so the greeter does not launch the notice and operators do not see the underlying error.

Check and report DConfig command failures separately from an intentionally disabled notice, and define launch behavior for the failure case.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread dde-user-notice/misc/user_notice_check.sh Outdated
Comment thread dde-user-notice/misc/user_notice_check.sh Outdated
@yixinshark
yixinshark force-pushed the feat/user-notice-task-396167 branch 2 times, most recently from 66bf296 to bc05d4a Compare October 22, 2026 08:01
@yixinshark yixinshark changed the title feat: migrate pre-login user notice to Qt6 feat: migrate user notice feature Oct 22, 2026
@yixinshark
yixinshark force-pushed the feat/user-notice-task-396167 branch 2 times, most recently from 6a00ad3 to 6b35725 Compare October 22, 2026 09:35
Migrate dde-user-notice from the v20 session UI and integrate its build, installation, pre-greeter launcher, and DConfig settings with the Qt6 version.

- Restore screen associations across mirror and extended display transitions.
- Load background images using immutable worker inputs and the ImageEffect1 API.
- Enable acknowledgement only after notice content is installed and reject explicit window closure while preserving monitor hotplug behavior.
- Validate DConfig reads and notice readability before launching the notice.

从 v20 会话界面迁移 dde-user-notice,适配 Qt6,并接入构建安装、登录前启动脚本及 DConfig 配置。

- 修复镜像与扩展模式切换后的屏幕关联和窗口复用。
- 后台加载使用不可变输入,并更新为 ImageEffect1 接口。
- 内容显示后才允许确认,拦截显式关闭窗口,同时保留显示器热插拔行为。
- 启动前校验 DConfig 读取结果和用户须知文件可读性。

Log: migrate pre-login user notice to Qt6

Pms: TASK-396167
Change-Id: I5aec1b8955771ae37c2feecd0ec9c16659af6d0b
@yixinshark
yixinshark force-pushed the feat/user-notice-task-396167 branch from 6b35725 to 8af4dc2 Compare October 22, 2026 11:33
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交为新增"用户须知"功能模块,代码结构清晰,异步加载逻辑合理,安全无漏洞。语法逻辑正确,边界处理完善;代码质量良好,少量重复代码可优化;性能方面使用了线程池异步加载避免阻塞主线程,存在少量魔法数字;安全方面无漏洞,文件路径处理规范,无命令注入风险。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

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

建议: ['修正 main.cpp 中应用版本号为正确的版本', '在 FullScreen::setScreen() 中添加注释说明两个 QFutureWatcher 的优先级设计意图']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

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

建议: ['将 setupPalette() 中的重复调用重构为遍历颜色角色列表的循环', '为 loadBackgroundImage 等关键函数添加函数级注释', '统一 Doxygen 注释格式']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

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

建议: ['将魔法数字提取为命名常量或配置项,提升可维护性', '考虑将布局参数(间距、尺寸)集中管理']


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: ['建议对 DConfig 返回的 userNoticePath 进行基本的路径合法性校验(如禁止包含 .. 的路径遍历),虽然当前 DConfig 需系统权限修改,但作为纵深防御可考虑']


💡 改进建议代码示例

// main.cpp - 修正版本号
app.setApplicationVersion("1.0.0");

// main.cpp - 重构 setupPalette() 为循环
void setupPalette()
{
    DPalette pa = DGuiApplicationHelper::instance()->standardPalette(DGuiApplicationHelper::LightType);
    const QList<QPair<DPalette::ColorType, QColor>> colorOverrides = {
        {DPalette::WindowText, QColor("#FFFFFF")},
        {DPalette::Text, QColor("#FFFFFF")},
        {DPalette::AlternateBase, QColor(0, 0, 0, 76)},
        {DPalette::Button, QColor(255, 255, 255, 76)},
        {DPalette::Light, QColor(255, 255, 255, 76)},
        {DPalette::Dark, QColor(255, 255, 255, 76)},
        {DPalette::ButtonText, QColor("#FFFFFF")},
    };
    for (const auto &pair : colorOverrides) {
        pa.setColor(QPalette::Normal, pair.first, pair.second);
        DGuiApplicationHelper::generatePaletteColor(pa, pair.first, DGuiApplicationHelper::LightType);
    }
    DGuiApplicationHelper::instance()->setApplicationPalette(pa);
}

// preLoginWindow.cpp - 提取魔法数字为常量
namespace {
    constexpr int COMMIT_BUTTON_WIDTH = 214;
    constexpr int COMMIT_BUTTON_HEIGHT = 36;
    constexpr int REFERENCE_SCREEN_WIDTH = 1920;
    constexpr int CONTENT_LABEL_WIDTH = 800;
    constexpr int TOP_SPACING = 60;
    constexpr int MIDDLE_SPACING = 20;
}

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

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.

2 participants