优化 Treeland 全部 QML 代码以支持 Qt6 类型标注 C++ 编译优化#1143
Conversation
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
47ba4c8 to
f4b9164
Compare
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.
f82a239 to
f5d2c87
Compare
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 构建在所有平台通过
f5d2c87 to
c3215ba
Compare
There was a problem hiding this comment.
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/函数参数/返回值补全为更具体类型。
Addpragma ComponentBehavior: Boundbroadly and replace dynamicvarusage with more specific property/function types. - 为多个 QML 目录新增
.qmllint.ini并将type/unqualified/compiler提升为error,同时通过局部qmllint disable规避必要的外部作用域引用。
Add.qmllint.iniwith stricter rules (type/unqualified/compiler=error) and use scopedqmllint disabledirectives where needed. - 更新
qt_add_qml_module(...)的IMPORTS,为 QML 静态分析/编译提供跨模块依赖信息。
Updateqt_add_qml_module(...)IMPORTSto 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 var → property 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 |
QtObject → Item 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 |
| // qmllint disable unqualified: qmllint directive — surfaceModel and root are outer scope | ||
| id: surfaceRepeater |
| } | ||
|
|
||
| function previewPostion(surface, content) { | ||
| function previewPostion(surface: SurfaceWrapper, content: Item): var { |
|
TAG Bot New tag: 0.8.15 |
Summary
优化 Treeland 项目中全部 52 个 QML 文件的类型标注,使其支持 Qt6 QML 编译为 C++ 的优化,同时开启 qmllint 门禁防止后续新增阻塞性代码。
Changes
CMake 配置(4 个文件)
libtreeland、lockscreen、multitaskview分别添加了IMPORTS声明.qmllint.ini,type/compiler/unqualified设为errorCMakeLists.txt设置QT_QMLLINT_ALL_TARGET并添加if(TARGET all_qmllint)守卫的add_dependenciesQML 类型优化(52 个文件)
pragma ComponentBehavior.Boundproperty var→ 具体类型转换(bool/int/real/Item/SurfaceWrapper/Window/locale等)property QtObject→ 命名类型,动态引用无法标注的保留并注释文件统计
Related: WM-81