Skip to content

优化 Treeland 全部 QML 代码以支持 Qt6 类型标注 C++ 编译优化#1143

Open
Groveer wants to merge 1 commit into
master-backup-20260717from
agent/developer/861ba581
Open

优化 Treeland 全部 QML 代码以支持 Qt6 类型标注 C++ 编译优化#1143
Groveer wants to merge 1 commit into
master-backup-20260717from
agent/developer/861ba581

Conversation

@Groveer

@Groveer Groveer commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

优化 Treeland 项目中全部 52 个 QML 文件的类型标注,使其支持 Qt6 QML 编译为 C++ 的优化,同时开启 qmllint 门禁防止后续新增阻塞性代码。

Changes

CMake 配置(4 个文件)

  • libtreelandlockscreenmultitaskview 分别添加了 IMPORTS 声明
  • 4 个模块各创建 .qmllint.initype/compiler/unqualified 设为 error
  • CMakeLists.txt 设置 QT_QMLLINT_ALL_TARGET 并添加 if(TARGET all_qmllint) 守卫的 add_dependencies

QML 类型优化(52 个文件)

  1. 全部 QML 文件添加 pragma ComponentBehavior.Bound
  2. property var → 具体类型转换(bool/int/real/Item/SurfaceWrapper/Window/locale 等)
  3. property QtObject → 命名类型,动态引用无法标注的保留并注释
  4. 所有函数补全参数和返回值类型标注

文件统计

类别 数量
QML 文件 52
CMakeLists.txt 3 + 1 根
.qmllint.ini 4
总计 60 files, +428/-145

Related: WM-81

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

Sorry @Groveer, 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
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Groveer

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

@Groveer
Groveer marked this pull request as draft July 14, 2026 09:44
@Groveer
Groveer force-pushed the agent/developer/861ba581 branch 3 times, most recently from 47ba4c8 to f4b9164 Compare July 15, 2026 02:08
@zccrs
zccrs marked this pull request as ready for review July 15, 2026 05:33

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

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

Please try again later or upgrade to continue using Sourcery

Comment thread src/core/qml/Animations/GeometryAnimation.qml Outdated
Comment thread src/core/qml/Animations/NewAnimation.qml Outdated
Comment thread src/core/qml/Effects/Blur.qml Outdated
Groveer added a commit that referenced this pull request Jul 16, 2026
1. GeometryAnimation.qml & NewAnimation.qml: revert blurComponent + onLoaded
   pattern back to simple sourceComponent: Blur {} with id-qualified access
   (root.surface.radius / root.target.radius) and qmllint disable directive.

2. Blur.qml and all other files: clarify qmllint disable comments by adding
   'qmllint directive' prefix to explanation text, making it explicit that
   these are directives for the qmllint tool, not human-facing comments.
@Groveer
Groveer force-pushed the agent/developer/861ba581 branch from f82a239 to f5d2c87 Compare July 16, 2026 05:43
1. Add pragma ComponentBehavior: Bound to all 52 production QML files
2. Replace property var with specific types (bool/int/real/Item etc.)
3. Replace property QtObject with named types where possible
4. Add type annotations to all QML functions and signal handlers
5. Refactor Loaders with sourceComponent to named Component binding
6. Add qmllint disable/enable annotations for cross-scope references
7. Add IMPORTS declarations to qt_add_qml_module for all modules
8. Create .qmllint.ini with type/compiler/unqualified at error level
9. Update SPDX copyright years for modified files
10. Remove unsupported default-parameter-with-type-annotation usage

Log: QML type annotations and qmllint configuration for compilation optimization

Influence:
1. Verify QML UIs render correctly after type annotation changes
2. Test Loader-based components with sourceComponent binding refactor
3. Run make <module>_qmllint to verify no new lint violations
4. Check pragma ComponentBehavior: Bound does not break dynamic behavior
5. Verify CI builds pass on all platforms

feat: 添加 QML 类型标注和 qmllint 配置

1. 为全部 52 个生产 QML 文件添加 pragma ComponentBehavior: Bound
2. 将 property var 替换为具体类型标注(bool/int/real/Item 等)
3. 将 property QtObject 替换为命名类型
4. 为所有 QML 函数和信号处理器添加类型标注
5. 重构 sourceComponent Loader 为命名 Component 绑定
6. 添加 qmllint disable/enable 标注处理跨作用域引用
7. 为各模块 qt_add_qml_module 添加 IMPORTS 声明
8. 创建 .qmllint.ini,将 type/compiler/unqualified 设为 error
9. 更新修改文件的 SPDX 版权年份
10. 移除 qmlcachegen 不支持的默认参数类型注解

Log: QML 类型标注和 qmllint 配置以支持编译优化

Influence:
1. 验证类型标注变更后 QML UI 渲染是否正常
2. 测试 sourceComponent Loader 重构后的组件行为
3. 运行 make <module>_qmllint 验证无新增 lint 违规
4. 检查 pragma ComponentBehavior: Bound 是否有动态行为异常
5. 验证 CI 构建在所有平台通过
@Groveer
Groveer force-pushed the agent/developer/861ba581 branch from f5d2c87 to c3215ba Compare July 16, 2026 06:03
@zccrs
zccrs requested a review from Copilot July 16, 2026 06:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

中文:本 PR 在 Treeland 的多个模块中系统性补全 QML 类型标注并启用 qmllint 门禁,以适配 Qt6 “QML 编译为 C++” 的优化路径,提升可静态检查性与编译期可优化程度。
English: This PR systematically tightens QML type annotations across Treeland modules and enables qmllint gating to better support Qt6 QML-to-C++ compilation optimizations, improving static checking and compile-time optimization opportunities.

Changes / 变更:

  • 为大量 QML 文件添加 pragma ComponentBehavior: Bound,并将 property var/函数参数/返回值补全为更具体类型。
    Add pragma ComponentBehavior: Bound broadly and replace dynamic var usage with more specific property/function types.
  • 为多个 QML 目录新增 .qmllint.ini 并将 type/unqualified/compiler 提升为 error,同时通过局部 qmllint disable 规避必要的外部作用域引用。
    Add .qmllint.ini with stricter rules (type/unqualified/compiler=error) and use scoped qmllint disable directives where needed.
  • 更新 qt_add_qml_module(...)IMPORTS,为 QML 静态分析/编译提供跨模块依赖信息。
    Update qt_add_qml_module(...) IMPORTS to declare cross-module dependencies for analysis/compilation.

Reviewed changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wallpaper-factory/Video.qml Add ComponentBehavior: Bound pragma / 添加 Bound pragma
wallpaper-factory/Image.qml Add ComponentBehavior: Bound pragma / 添加 Bound pragma
wallpaper-factory/.qmllint.ini Introduce qmllint policy for wallpaper-factory / 新增 qmllint 规则
src/plugins/multitaskview/qml/WorkspaceSelectionList.qml Add Bound pragma + typed required properties + scoped qmllint directives / 类型标注与局部指令
src/plugins/multitaskview/qml/WindowSelectionGrid.qml Add Bound pragma + type annotations + qmllint directives / 类型标注与指令(存在未成对 enable 的问题)
src/plugins/multitaskview/qml/MultitaskviewProxy.qml Add Bound pragma + scoped qmllint directives / 添加 Bound 与局部指令
src/plugins/multitaskview/qml/.qmllint.ini Introduce qmllint policy for multitaskview qml / 新增 qmllint 规则
src/plugins/multitaskview/CMakeLists.txt Declare QML module IMPORTS / 增加 QML 模块依赖声明
src/plugins/lockscreen/qml/UserList.qml Replace var props with concrete types + typed function signature + qmllint directives / 属性与函数类型补全
src/plugins/lockscreen/qml/UserInput.qml Add return types + typed Connections handler params / 为函数与信号处理补全类型
src/plugins/lockscreen/qml/TimeDateWidget.qml property varproperty locale / locale 类型收敛
src/plugins/lockscreen/qml/ShutdownView.qml Add Bound pragma / 添加 Bound pragma
src/plugins/lockscreen/qml/ShutdownButton.qml Add Bound pragma / 添加 Bound pragma
src/plugins/lockscreen/qml/SessionList.qml Add Bound pragma + scoped qmllint directives / 添加 Bound 与局部指令
src/plugins/lockscreen/qml/RoundBlur.qml Add Bound pragma / 添加 Bound pragma
src/plugins/lockscreen/qml/QuickAction.qml Add Bound pragma / 添加 Bound pragma
src/plugins/lockscreen/qml/PowerList.qml Add Bound pragma / 添加 Bound pragma
src/plugins/lockscreen/qml/LoginAnimation.qml Tighten target type + typed points + typed functions / target 与函数签名类型补全
src/plugins/lockscreen/qml/LockView.qml Add typed functions + scoped qmllint directives / 函数类型与局部指令
src/plugins/lockscreen/qml/HintLabel.qml Add Bound pragma / 添加 Bound pragma
src/plugins/lockscreen/qml/Greeter.qml Type annotations + outputItem typed as Item + scoped qmllint directives / 类型标注与局部指令
src/plugins/lockscreen/qml/ControlAction.qml Typed functions / 函数返回类型补全
src/plugins/lockscreen/qml/.qmllint.ini Introduce qmllint policy for lockscreen qml / 新增 qmllint 规则
src/plugins/lockscreen/CMakeLists.txt Declare QML module IMPORTS / 增加 QML 模块依赖声明
src/core/qml/XdgShadow.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/WorkspaceSwitcher.qml Add Bound pragma + typed required output + scoped qmllint directives / 类型标注与局部指令
src/core/qml/WorkspaceProxy.qml Refactor Loader sourceComponent to avoid outer-scope access + bind surface on load / 调整 Loader 绑定方式
src/core/qml/WorkSpaceMask.qml Add Bound pragma + scoped qmllint directives / 添加 Bound 与局部指令
src/core/qml/WindowPickerLayer.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/WindowMenu.qml Typed function parameters/return / 函数签名类型补全
src/core/qml/TitleBar.qml Add Bound pragma + scoped qmllint directives for inner components / 添加 Bound 与局部指令
src/core/qml/TaskWindowPreview.qml Add Bound pragma + scoped qmllint directives / 添加 Bound 与局部指令
src/core/qml/TaskSwitcher.qml Add Bound pragma + typed helper functions + scoped qmllint directives / 类型标注与局部指令(存在命名拼写建议)
src/core/qml/TaskBar.qml Add Bound pragma + typed required output / 类型标注
src/core/qml/SwitchViewHighlightDelegate.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/SwitchViewDelegate.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/SurfaceContent.qml Refactor blur Loader to satisfy type/outer-scope constraints + bindings on load / 调整 Blur Loader 绑定方式
src/core/qml/PrimaryOutput.qml Typed signal handler parameters + typed helpers / 信号与函数类型补全
src/core/qml/PrelaunchSplash.qml Add Bound pragma + document why iconBuffer stays var / 添加 Bound 与保留动态类型说明
src/core/qml/OutputMenuBar.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/LockScreenFallback.qml QtObjectItem for outputItem / 收敛 outputItem 类型
src/core/qml/FpsDisplay.qml Type targetWindow as Window / targetWindow 类型收敛
src/core/qml/FadeBehavior.qml Document dynamic/JS-array cases + scoped qmllint directives / 动态类型说明与局部指令
src/core/qml/Effects/LaunchpadCover.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/Effects/GlassEffect.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/Effects/Blur.qml Add Bound pragma + scoped qmllint directives inside effect components / 添加 Bound 与局部指令
src/core/qml/DockPreview.qml Add Bound pragma + extensive type annotations / 添加 Bound 与类型标注
src/core/qml/Decoration.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/CopyOutput.qml Typed timer properties + typed functions / 定时器属性与函数签名类型补全
src/core/qml/CaptureSelectorLayer.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/Border.qml Add Bound pragma / 添加 Bound pragma
src/core/qml/Animations/ShowDesktopAnimation.qml Type target as SurfaceWrapper + typed start() / target 与函数类型补全
src/core/qml/Animations/NewAnimation.qml Type direction/enableBlur + typed start() + scoped qmllint directives / 类型补全与局部指令
src/core/qml/Animations/MinimizeAnimation.qml Type target/direction + typed start() / 类型补全
src/core/qml/Animations/LayerShellAnimation.qml Type target/direction/position/enableBlur + typed start/stop / 类型补全
src/core/qml/Animations/LaunchpadAnimation.qml Type target/direction + typed start/stop / 类型补全
src/core/qml/Animations/GeometryAnimation.qml Type enableBlur + typed start() + qualify root.surface / 类型补全与限定访问
src/core/qml/.qmllint.ini Introduce qmllint policy for core qml / 新增 qmllint 规则
src/CMakeLists.txt Add qt_add_qml_module(libtreeland) IMPORTS / 增加 QML 模块依赖声明

// Copyright (C) 2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

pragma ComponentBehavior: Bound
Comment on lines +117 to 118
// qmllint disable unqualified: qmllint directive — surfaceModel and root are outer scope
id: surfaceRepeater
}

function previewPostion(surface, content) {
function previewPostion(surface: SurfaceWrapper, content: Item): var {
@deepin-bot

deepin-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.15
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1163

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.

4 participants