Skip to content

Conversation

@BLumia
Copy link
Member

@BLumia BLumia commented Sep 1, 2025

修正 GroupBox 标签文本的背景颜色总是白色的问题,会导致在暗色主题下文字无法被看清楚.

注:采取了给 Rectangle 加颜色而不是移除 Rectangle 的形式,以免哪天需要给 GroupBox 加 border。 最终决定还是以删除现有 Rectangle 的形式。

当前修改的实际效果(参考命令 LD_LIBRARY_PATH=/home/blumia/Sources/dtkdeclarative/build/qt6/src ./build/examples/qml-inspect/qml-inspect):

image

background 加了 border.color: control.palette.windowText 的效果(此 PR 并未添加,只是作为参考):

image

Summary by Sourcery

Fix theming issue where the GroupBox header background was always white and add a new GroupBox example to the qml-inspect tool for demonstration purposes

New Features:

  • Add a GroupBox tab and Example_GroupBox.qml to the qml-inspect example

Bug Fixes:

  • Use control.palette.window for the GroupBox header background instead of a hardcoded white

Enhancements:

  • Include the new GroupBox example in the qml-inspect application UI for visual testing

@BLumia BLumia requested a review from 18202781743 September 1, 2025 07:23
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Sep 1, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#523
@sourcery-ai
Copy link

sourcery-ai bot commented Sep 1, 2025

Reviewer's Guide

This PR fixes the GroupBox label background color by assigning the theme’s window color to its background rectangle and adds a new QML Inspect example for GroupBox to verify the change.

Class diagram for updated GroupBox QML component

classDiagram
    class GroupBox {
        +title: string
        background: Rectangle
    }
    class Rectangle {
        +color: control.palette.window
    }
    GroupBox "1" *-- "1" Rectangle: background
Loading

Class diagram for new Example_GroupBox QML component

classDiagram
    class Example_GroupBox {
        Flow
        Row
        GroupBox
        ColumnLayout
        CheckBox
        Label
    }
    Example_GroupBox "1" *-- "1" Flow
    Flow "1" *-- "1" Row
    Row "1" *-- "2" GroupBox
    GroupBox "1" *-- "1" ColumnLayout
    ColumnLayout "1" *-- "3" CheckBox
    GroupBox "1" *-- "1" Label
Loading

File-Level Changes

Change Details Files
Fix GroupBox label background to respect theme palette
  • Set Rectangle color to control.palette.window in GroupBox label background
  • Applied change in both qt6 and src QML implementations
qt6/src/qml/GroupBox.qml
src/qml/GroupBox.qml
Add GroupBox example to QML Inspect tool
  • Created Example_GroupBox.qml with two sample GroupBox usages
  • Updated main.qml to include a GroupBox tab and load the new example
examples/qml-inspect/main.qml
examples/qml-inspect/Example_GroupBox.qml

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


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.

修正 GroupBox 标签文本的背景颜色总是白色的问题,会导致在暗色主题下
文字无法被看清楚.

注:只改了 qt 6 的版本.

Log:
@BLumia BLumia force-pushed the fix-groupbox-label-bg branch from b8f1e82 to 02d2aad Compare September 1, 2025 07:47
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Sep 1, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#523
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

代码审查意见

Example_GroupBox.qml

语法逻辑

  1. 代码整体结构清晰,使用了Flow布局来组织两个GroupBox,符合QML规范。
  2. 建议为GroupBox添加明确的width属性,以确保在不同屏幕尺寸下的一致性。

代码质量

  1. 缺少注释说明这个示例的具体用途和实现目标。
  2. 第二个GroupBox中的Label没有设置任何布局属性,可能导致内容显示不够美观。
  3. 建议为控件添加适当的padding/margin,以提高视觉层次和可读性。

代码性能

  1. 当前实现较为简单,没有明显的性能问题。
  2. 如果GroupBox内容较多,建议考虑使用ListView等虚拟化控件以提高性能。

代码安全

  1. 没有发现明显的安全问题。

改进建议

// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

import QtQuick 2.0
import QtQuick.Layouts 1.11
import org.deepin.dtk 1.0

// GroupBox示例,展示GroupBox的基本用法和布局
Flow {
    id: control
    spacing: 20
    width: parent.width // 添加宽度属性

    Row {
        spacing: 20
        width: parent.width

        GroupBox {
            title: "GroupBox"
            width: 200 // 添加固定宽度
            ColumnLayout {
                anchors.fill: parent
                anchors.margins: 5 // 添加边距
                CheckBox { text: "E-mail" }
                CheckBox { text: "Super Fancy Calendar" }
                CheckBox { text: "Contacts" }
            }
        }

        GroupBox {
            title: "GroupBox 2"
            width: 200 // 添加固定宽度
            ColumnLayout {
                anchors.fill: parent
                anchors.margins: 5 // 添加边距
                Label {
                    text: "GroupBox Content"
                    Layout.alignment: Qt.AlignCenter // 添加对齐方式
                }
            }
        }
    }
}

main.qml

语法逻辑

  1. 添加GroupBox标签和对应的页面引用逻辑正确。
  2. TabButton的文本使用qsTr()进行国际化处理,符合最佳实践。

代码质量

  1. 代码结构清晰,符合项目规范。
  2. 建议为GroupBox标签添加注释,说明其用途。

代码性能

  1. 添加新标签不会显著影响性能。

代码安全

  1. 没有发现明显的安全问题。

改进建议

V2.TabButton {
    text: qsTr("GroupBox") // 添加注释说明这是GroupBox示例
    // 用于展示GroupBox控件的基本用法和布局
}

qml.qrc

语法逻辑

  1. 资源文件配置正确,添加了新的Example_GroupBox.qml文件。

代码质量

  1. 资源文件组织有序。

代码性能

  1. 资源文件配置不会影响运行时性能。

代码安全

  1. 没有发现明显的安全问题。

改进建议

无特别建议,当前配置已经很好。

qt6/src/qml/GroupBox.qml

语法逻辑

  1. 代码结构清晰,继承自T.GroupBox。
  2. 移除了不必要的background属性,简化了代码。

代码质量

  1. 代码简洁明了。
  2. 文本对齐和省略号设置合理。

代码性能

  1. 实现简单,性能良好。

代码安全

  1. 没有发现明显的安全问题。

改进建议

无特别建议,当前实现已经很好。

总结

  1. 整体代码质量良好,符合QML开发规范。
  2. 主要改进点集中在Example_GroupBox.qml中,建议添加适当的尺寸设置和布局属性,以提高UI的一致性和美观度。
  3. 建议为代码添加更多注释,以增强可维护性。

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

@BLumia BLumia merged commit e9f15d2 into linuxdeepin:master Sep 1, 2025
19 of 20 checks passed
BLumia pushed a commit to linuxdeepin/dtk6declarative that referenced this pull request Sep 1, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#523
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.

3 participants