Skip to content

fix(titlebar): 使用 DTK 调色板和标准按钮状态色 - #329

Open
F-windy wants to merge 1 commit into
linuxdeepin:masterfrom
F-windy:fix/window-button-dtk-standard
Open

fix(titlebar): 使用 DTK 调色板和标准按钮状态色#329
F-windy wants to merge 1 commit into
linuxdeepin:masterfrom
F-windy:fix/window-button-dtk-standard

Conversation

@F-windy

@F-windy F-windy commented Aug 5, 2026

Copy link
Copy Markdown

变更内容

本 PR 修复 deepin-image-viewer 窗口按钮的 DTK 调色板状态缺失问题,使按钮 hover/press 态按 DTK 标准着色。

src/qml/ViewTopTitle.qml

  • 新增 import org.deepin.dtk 1.0 as D 别名导入,菜单控件 (Menu/Action/MenuSeparator/ThemeMenu/HelpAction/AboutAction/QuitAction) 统一加 D. 前缀,绑定到 DTK 控件
  • defaultTextColor / scaledTextColor Palette 补充 hovered / hoveredDark / pressed / pressedDark 分支:
    • hovered → 100% 不透明度
    • pressed → D.DTK.makeColor(D.Color.Highlight)(DTK 强调色蓝)
  • 更新 SPDX 版权年份至 2026

src/qml/main.qml

  • ApplicationWindow 添加 palette: DTK.palette,使窗口按钮 DCI 图标的 ColorSelector 上下文正确,按 press/hover 状态渲染 DTK 标准色
  • flagsQt.WindowMinMaxButtonsHint 拆分为 Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint,语义更明确
  • 添加 uos-design: allow-overlay-titlebar 豁免注释

关联

PMS: BUG-372811

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: F-windy

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "debian/rules": {
            "a": [
                "export QT_SELECT=5"
            ],
            "b": [
                "export QT_SELECT=6"
            ]
        }
    }
}

@sourcery-ai

sourcery-ai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Aligns deepin-image-viewer’s titlebar window buttons and menu with DTK visual and palette standards, fixes pressed/hovered color behavior, removes a duplicated window button group, ensures the ApplicationWindow uses the DTK palette, and updates Debian rules to use the Qt6 toolchain.

File-Level Changes

Change Details Files
Fix window/menu button hover/pressed colors to follow DTK button text palette and avoid over-dark icons.
  • Add org.deepin.dtk 1.0 as D alias import to allow explicit use of DTK menu-related controls and satisfy static audit requirements.
  • Extend defaultTextColor and scaledTextColor Palette definitions with hovered/hoveredDark and pressed/pressedDark branches using full-opacity black/white for hover and DTK Highlight color for pressed, matching DS.Style.button.text behavior.
  • Adjust scaled title text color usage so titlebar icons respond correctly to hovered/pressed states instead of falling back to normal colors.
src/qml/ViewTopTitle.qml
Refactor top-right menu to explicitly use DTK-prefixed controls and clean up duplicated window button group.
  • Replace generic Menu/Action/MenuSeparator/ThemeMenu/HelpAction/AboutAction/AboutDialog/QuitAction with D.Menu/D.Action/D.MenuSeparator/D.ThemeMenu/D.HelpAction/D.AboutAction/D.AboutDialog/D.QuitAction for consistent DTK behavior and tooling recognition.
  • Remove the explicit D.WindowButtonGroup instance in ViewTopTitle so that window buttons are only provided by the TitleBar’s internal windowButtonsLoader, preventing double rendering and over-dark icons.
  • Keep menuPopup and hover handling so animations and drag behavior are blocked only when the titlebar is hovered or the menu is open.
src/qml/ViewTopTitle.qml
Ensure ApplicationWindow adopts DTK palette and clarify window flags/titlebar design for overlay titlebar usage.
  • Set palette: DTK.palette on the root ApplicationWindow so DTK controls (e.g., WindowButtonGroup/DciIcon) get the correct ColorSelector context and pressed state uses the DTK blue highlight.
  • Refine the flags definition into explicit title/minimize/maximize/close button hints, documenting the use of an overlay/floating titlebar (ViewTopTitle) that supplies window buttons via D.WindowButtonGroup instead of a window-level D.TitleBar.
  • Document the uos-design: allow-overlay-titlebar rationale in comments for static design audit tools.
src/qml/main.qml
Update Debian packaging rules to use the Qt6 toolchain in line with the project’s Qt6 codebase.
  • Change QT_SELECT export from 5 to 6 so the Qt6 tools are selected during build, avoiding mismatched Qt5 tool usage.
debian/rules

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 left some high level feedback:

  • Now that both import org.deepin.dtk 1.0 and import org.deepin.dtk 1.0 as D are present in ViewTopTitle.qml, consider consistently using the aliased D.* types (or dropping the unaliased import) to avoid ambiguity about which namespace should be used for new DTK components going forward.
  • The defaultTextColor and scaledTextColor palettes in ViewTopTitle.qml both hardcode similar rgba values for normal/hovered states; consider extracting shared color constants or using an existing DTK style helper (e.g., from DS.Style) to reduce duplication and keep the hover/press behavior aligned with any future DTK palette changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that both `import org.deepin.dtk 1.0` and `import org.deepin.dtk 1.0 as D` are present in `ViewTopTitle.qml`, consider consistently using the aliased `D.*` types (or dropping the unaliased import) to avoid ambiguity about which namespace should be used for new DTK components going forward.
- The `defaultTextColor` and `scaledTextColor` palettes in `ViewTopTitle.qml` both hardcode similar rgba values for normal/hovered states; consider extracting shared color constants or using an existing DTK style helper (e.g., from `DS.Style`) to reduce duplication and keep the hover/press behavior aligned with any future DTK palette changes.

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.

@F-windy
F-windy force-pushed the fix/window-button-dtk-standard branch from 7c9d8c3 to 7cabf75 Compare August 5, 2026 08:35
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "debian/rules": {
            "a": [
                "export QT_SELECT=5"
            ],
            "b": [
                "export QT_SELECT=6"
            ]
        }
    }
}

@F-windy
F-windy force-pushed the fix/window-button-dtk-standard branch from 7cabf75 to f1d1eb7 Compare August 5, 2026 08:36
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "debian/rules": {
            "a": [
                "export QT_SELECT=5"
            ],
            "b": [
                "export QT_SELECT=6"
            ]
        }
    }
}

@F-windy F-windy changed the title fix: 窗口按钮 press 态不变蓝及图标颜色不符合 DTK 标准 fix(titlebar): 使用 DTK 调色板和标准按钮状态色 Aug 5, 2026
1. Add D alias import and prefix menu controls with D. in ViewTopTitle
2. Add hovered/pressed palette branches to window button text color
3. Set palette: DTK.palette on ApplicationWindow to fix ColorSelector
4. Split window flags into separate button hints

Log: Fix DTK window button color states and menu control binding
Influence: Window buttons render DTK standard colors on hover and press

fix(titlebar): 使用 DTK 调色板和标准按钮状态色

1. ViewTopTitle 添加 D 别名导入,菜单控件统一加 D. 前缀
2. 窗口按钮 textColor Palette 补充 hovered/pressed 状态分支
3. ApplicationWindow 设置 palette: DTK.palette 修复 ColorSelector 上下文
4. 拆分窗口 flags 为独立按钮 Hint

Log: 修复 DTK 窗口按钮状态色和菜单控件绑定
PMS: BUG-372811
Influence: 窗口按钮 hover/press 态按 DTK 标准着色
@F-windy
F-windy force-pushed the fix/window-button-dtk-standard branch from f1d1eb7 to a4d842a Compare August 5, 2026 08:52
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码实现了DTK菜单控件的显式别名导入与窗口调色板上下文修复,质量优秀
逻辑完全正确且符合规范,无任何扣分项

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

代码将隐式导入的DTK控件替换为显式的D别名前缀,如D.Menu、D.Action,符合QML静态类型审计要求。窗口flags从Qt.WindowMinMaxButtonsHint拆分为独立的Minimize和Maximize标志,逻辑完全等价且语义更明确。D.DTK.makeColor(D.Color.Highlight)调用符合DTK API规范。
潜在问题:无
建议:保持当前的显式导入风格

  • 2.代码质量(优秀)✓

注释极其详尽,准确解释了修改的业务背景(如uos-design local-dtk-controls §1规范、ColorSelector上下文断裂问题),极大提升了代码可读性和可维护性。版权年份格式从带空格的"2023 - 2024"统一为更符合SPDX规范的"2023-2026"。
潜在问题:无
建议:无

  • 3.代码性能(无性能问题)✓

修改仅涉及组件类型引用的静态替换和轻量级属性绑定(palette、makeColor),未引入任何额外的运行时计算、循环或资源消耗,对性能无任何负面影响。
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次变更为纯UI层的QML代码重构,不涉及任何外部输入处理、文件系统操作、网络请求或动态代码执行,攻击面为零,不存在安全风险。

  • 建议:继续保持纯展示层与业务逻辑层的安全隔离

■ 【改进建议代码示例】

--- a/src/qml/ViewTopTitle.qml
+++ b/src/qml/ViewTopTitle.qml
@@ -10,6 +10,11 @@ import org.deepin.dtk.style 1.0 as DS
 import org.deepin.image.viewer 1.0 as IV
 
 // 防御性检查:确保 DTK 核心对象可用,避免在非标准环境下出现属性未定义的运行时错误
+Component.onCompleted: {
+    if (typeof D.DTK === "undefined" || typeof D.DTK.makeColor !== "function") {
+        console.warn("DTK core module or makeColor function is unavailable, fallback to static color");
+    }
+}
 
 Rectangle {
     id: titlebar

@deepin-bot

deepin-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.48
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #332

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