fix(plugin): set DTK palette for loaded plugin components#3050
fix(plugin): set DTK palette for loaded plugin components#3050add-uos wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos 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 |
Reviewer's GuideEnsure all plugin UI components loaded in the control center use the DTK palette and improve visual feedback based on window activation, while also updating some QML imports and SPDX year ranges. Sequence diagram for applying DTK palette when loading plugin componentssequenceDiagram
actor User
participant ControlCenter
participant DccLoader
participant PluginComponent
participant DTK as D_DTK
User ->> ControlCenter: openPlugin(moduleId)
ControlCenter ->> DccLoader: set dccObj(moduleId)
DccLoader ->> DccLoader: updateDccObjItem()
DccLoader ->> PluginComponent: load()
PluginComponent -->> DccLoader: onLoaded(item)
alt item has palette property
DccLoader ->> DTK: access DTK.palette
DTK -->> DccLoader: palette
DccLoader ->> PluginComponent: item.palette = DTK.palette
else item has no palette property
DccLoader ->> DccLoader: skip palette assignment
end
PluginComponent -->> User: display with DTK theming
Class diagram for updated QML components and DTK palette usageclassDiagram
class DccLoader {
+var dccObj
+var dccObjItem
+function updateDccObjItem()
+onDccObjChanged()
+onDccObjItemChanged()
+Component_onCompleted()
+onLoaded()
}
class DccRightView {
+bool empty
+bool isGroup
+real margin
+bool scrollBarVisible
+palette palette
}
class Crumb {
+var model
+palette palette
+signal clicked(model)
+function updateLayout()
}
class SecondPageSidebarItem {
+bool windowActive
+real opacity
+bool checked
+bool cascadeSelected
}
class DccWindowLeftActionButton {
+bool windowActive
+real opacity
+palette windowText
}
class D_DTK {
+palette palette
}
class D_ColorSelector {
+color textColor
}
DccLoader --> D_DTK : uses palette
DccRightView --> D_DTK : uses palette
Crumb --> D_DTK : uses palette
DccWindowLeftActionButton --> D_ColorSelector : uses textColor
SecondPageSidebarItem <.. DccRightView : contained delegate
DccWindowLeftActionButton <.. DccWindow : contained action button
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
Crumb.qmlyou setpalette: D.DTK.palettebut there is noimport org.deepin.dtk 1.0 as D, which will cause a runtime error; add the DTK import as you did inDccRightView.qml. - In
DccLoader.qmlyou assignitem.palette = D.DTK.paletteonce inonLoaded, meaning it will not follow palette changes at runtime; consider using a binding (e.g.item.palette = Qt.binding(function() { return D.DTK.palette })) so loaded plugins track theme updates automatically.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `Crumb.qml` you set `palette: D.DTK.palette` but there is no `import org.deepin.dtk 1.0 as D`, which will cause a runtime error; add the DTK import as you did in `DccRightView.qml`.
- In `DccLoader.qml` you assign `item.palette = D.DTK.palette` once in `onLoaded`, meaning it will not follow palette changes at runtime; consider using a binding (e.g. `item.palette = Qt.binding(function() { return D.DTK.palette })`) so loaded plugins track theme updates automatically.
## Individual Comments
### Comment 1
<location path="src/dde-control-center/plugin/DccRightView.qml" line_range="16" />
<code_context>
property alias model: repeater.model
signal clicked(var model)
+ palette: D.DTK.palette
function updateLayout() {
let totalWidth = width
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `palette` on `Flickable` is likely invalid and will cause a QML error.
In QtQuick, `Flickable` doesn’t have a `palette` property (that belongs to `QtQuick.Controls::Control` and its subclasses). Unless you have a custom `Flickable` type defining `palette`, this will fail with an invalid property assignment at load time. If you need the DTK palette here, apply it on a `Control`-derived child or wrap the content in a `Control` that owns the palette instead.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| autoHideOnFullscreen: true | ||
| focus: true | ||
| leftContent: D.ActionButton { | ||
| property bool windowActive: Window.window ? Window.window.active : true |
There was a problem hiding this comment.
DCI彩色图标,没有inactive状态,需要单独设置
| Component.onCompleted: updateDccObjItem() | ||
| onLoaded: { | ||
| if (item && item.palette !== undefined) { | ||
| item.palette = D.DTK.palette |
|
TAG Bot New tag: 6.1.75 |
133e060 to
f0a5879
Compare
Automatically set DTK palette for all plugin components loaded via DccLoader to ensure consistent theming across all modules. 为通过DccLoader加载的插件组件自动设置DTK调色板,确保所有模块的主题一致性。 Log: 修复插件加载时未设置调色板的问题 PMS: BUG-298841, BUG-338393 Influence: 所有加载的插件组件现在都会正确使用DTK调色板,确保界面颜色主题统一,提升视觉一致性。
f0a5879 to
6d8d88f
Compare
deepin pr auto review这份代码修改主要涉及QML文件的版权年份更新、Qt版本导入方式的变更,以及针对DTK(Deepin Tool Kit)主题适配和窗口激活状态的视觉反馈优化。以下是对代码的详细审查意见: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与建议
|
Automatically set DTK palette for all plugin components loaded via DccLoader to ensure consistent theming across all modules.
为通过DccLoader加载的插件组件自动设置DTK调色板,确保所有模块的主题一致性。
Log: 修复插件加载时未设置调色板的问题
PMS: BUG-298841, BUG-338393
Influence: 所有加载的插件组件现在都会正确使用DTK调色板,确保界面颜色主题统一,提升视觉一致性。