diff options
| author | Doris Verria <doris.verria@qt.io> | 2025-12-03 14:33:47 +0100 |
|---|---|---|
| committer | Doris Verria <doris.verria@qt.io> | 2025-12-04 14:54:03 +0100 |
| commit | eeab30992c487234064ede3814e7e932a23b0de9 (patch) | |
| tree | be51e733fd9478043550c943ba34ed12efebf53f /src | |
| parent | 318ba9c314d6e8a029cab324cb70fa1e970e6b88 (diff) | |
StyleKit: Add GroupBox control
Change-Id: I0177d20c381d83d2a816199a89b6fc9150fa4766
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/labs/stylekit/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/labs/stylekit/GroupBox.qml | 59 | ||||
| -rw-r--r-- | src/labs/stylekit/impl/FallbackStyle.qml | 6 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitcontrols.cpp | 1 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitcontrols_p.h | 3 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitpropertyresolver.cpp | 5 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitreader_p.h | 3 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitstyle.cpp | 2 |
8 files changed, 79 insertions, 1 deletions
diff --git a/src/labs/stylekit/CMakeLists.txt b/src/labs/stylekit/CMakeLists.txt index 25bdf59474..284e120194 100644 --- a/src/labs/stylekit/CMakeLists.txt +++ b/src/labs/stylekit/CMakeLists.txt @@ -52,6 +52,7 @@ qt_internal_add_qml_module(QtQuickStyleKit Pane.qml Popup.qml Label.qml + GroupBox.qml LIBRARIES Qt6::GuiPrivate Qt6::Quick diff --git a/src/labs/stylekit/GroupBox.qml b/src/labs/stylekit/GroupBox.qml new file mode 100644 index 0000000000..692aece2ed --- /dev/null +++ b/src/labs/stylekit/GroupBox.qml @@ -0,0 +1,59 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +// Qt-Security score:significant reason:default +import QtQuick +import QtQuick.Controls.impl +import QtQuick.Templates as T +import Qt.labs.StyleKit +import Qt.labs.StyleKit.impl + +T.GroupBox { + id: control + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding, + implicitLabelWidth) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + spacing: styleReader.spacing + + topPadding: styleReader.topPadding + implicitLabelWidth > 0 ? implicitLabelHeight + spacing : 0 + leftPadding: styleReader.leftPadding + rightPadding: styleReader.rightPadding + bottomPadding: styleReader.bottomPadding + + topInset: styleReader.background.topMargin + bottomInset: styleReader.background.bottomMargin + rightInset: styleReader.background.rightMargin + leftInset: styleReader.background.leftMargin + + StyleKitControl.controlType: styleReader.type + StyleKitReader { + id: styleReader + type: StyleKitReader.GroupBox + enabled: control.enabled + focused: control.activeFocus + hovered: control.hovered + palette: control.palette + } + + label: Text { + // leftPadding: styleReader.text.leftPadding + // rightPadding: styleReader.text.rightPadding + // bottomPadding: styleReader.text.bottomPadding + // topPadding: styleReader.text.topPadding + width: control.width + verticalAlignment: styleReader.text.alignment + horizontalAlignment: styleReader.text.alignment + text: control.title + color: styleReader.text.color + elide: Text.ElideRight + font: styleReader.font + } + + background: BackgroundDelegate { + parentControl: control + backgroundProperties: styleReader.background + } +} diff --git a/src/labs/stylekit/impl/FallbackStyle.qml b/src/labs/stylekit/impl/FallbackStyle.qml index 961e93f9c0..811ed30cf9 100644 --- a/src/labs/stylekit/impl/FallbackStyle.qml +++ b/src/labs/stylekit/impl/FallbackStyle.qml @@ -91,6 +91,12 @@ BaseStyle { background.color: style.palette.base } + groupBox { + spacing: 20 + padding: 12 + background.implicitHeight: 20 + } + flatButton { background.visible: false hovered.background.visible: true diff --git a/src/labs/stylekit/qqstylekitcontrols.cpp b/src/labs/stylekit/qqstylekitcontrols.cpp index cd2c37aafd..32273899ea 100644 --- a/src/labs/stylekit/qqstylekitcontrols.cpp +++ b/src/labs/stylekit/qqstylekitcontrols.cpp @@ -84,6 +84,7 @@ IMPLEMENT_ACCESSORS(pane, QQStyleKitReader::ControlType::Pane) IMPLEMENT_ACCESSORS(page, QQStyleKitReader::ControlType::Page) IMPLEMENT_ACCESSORS(frame, QQStyleKitReader::ControlType::Frame) IMPLEMENT_ACCESSORS(label, QQStyleKitReader::ControlType::Label) +IMPLEMENT_ACCESSORS(groupBox, QQStyleKitReader::ControlType::GroupBox) #undef IMPLEMENT_ACCESSORS diff --git a/src/labs/stylekit/qqstylekitcontrols_p.h b/src/labs/stylekit/qqstylekitcontrols_p.h index 8c44dd45c0..b8a135f63f 100644 --- a/src/labs/stylekit/qqstylekitcontrols_p.h +++ b/src/labs/stylekit/qqstylekitcontrols_p.h @@ -51,6 +51,7 @@ class QQStyleKitControls : public QObject, public QQmlParserStatus Q_PROPERTY(QQStyleKitControl *page READ page WRITE set_page NOTIFY pageChanged FINAL) Q_PROPERTY(QQStyleKitControl *frame READ frame WRITE set_frame NOTIFY frameChanged FINAL) Q_PROPERTY(QQStyleKitControl *label READ label WRITE set_label NOTIFY labelChanged FINAL) + Q_PROPERTY(QQStyleKitControl *groupBox READ groupBox WRITE set_groupBox NOTIFY groupBoxChanged FINAL) QML_UNCREATABLE("This component is abstract, and cannot be instantiated") QML_NAMED_ELEMENT(StyleKitControls) @@ -84,6 +85,7 @@ public: IMPLEMENT_ACCESSORS(page) IMPLEMENT_ACCESSORS(frame) IMPLEMENT_ACCESSORS(label) + IMPLEMENT_ACCESSORS(groupBox) #undef IMPLEMENT_ACCESSORS @@ -116,6 +118,7 @@ signals: void pageChanged(); void frameChanged(); void labelChanged(); + void groupBoxChanged(); protected: void classBegin() override {} diff --git a/src/labs/stylekit/qqstylekitpropertyresolver.cpp b/src/labs/stylekit/qqstylekitpropertyresolver.cpp index b823ba7e97..ca79a143fe 100644 --- a/src/labs/stylekit/qqstylekitpropertyresolver.cpp +++ b/src/labs/stylekit/qqstylekitpropertyresolver.cpp @@ -46,6 +46,11 @@ const QList<QQStyleKitExtendedControlType> QQStyleKitPropertyResolver::baseTypes static QList<QQStyleKitExtendedControlType> t = { QQStyleKitReader::Pane, QQStyleKitReader::Control }; return t; } + case QQStyleKitReader::GroupBox: { + static QList<QQStyleKitExtendedControlType> t = + { QQStyleKitReader::Frame, QQStyleKitReader::Pane, QQStyleKitReader::Control }; + return t; + } case QQStyleKitReader::TextField: case QQStyleKitReader::TextArea: { static QList<QQStyleKitExtendedControlType> t = diff --git a/src/labs/stylekit/qqstylekitreader_p.h b/src/labs/stylekit/qqstylekitreader_p.h index 2120fe59b3..3f282dd084 100644 --- a/src/labs/stylekit/qqstylekitreader_p.h +++ b/src/labs/stylekit/qqstylekitreader_p.h @@ -72,7 +72,8 @@ public: Pane, Page, Frame, - Label + Label, + GroupBox }; Q_ENUM(ControlType) diff --git a/src/labs/stylekit/qqstylekitstyle.cpp b/src/labs/stylekit/qqstylekitstyle.cpp index 26c0477330..553e9db23b 100644 --- a/src/labs/stylekit/qqstylekitstyle.cpp +++ b/src/labs/stylekit/qqstylekitstyle.cpp @@ -273,6 +273,8 @@ QFont QQStyleKitStyle::fontForReader(QQStyleKitReader *reader) const return m_theme->fonts()->checkBox(); case QQStyleKitReader::ControlType::ComboBox: return m_theme->fonts()->comboBox(); + case QQStyleKitReader::ControlType::GroupBox: + return m_theme->fonts()->groupBox(); case QQStyleKitReader::ControlType::RadioButton: return m_theme->fonts()->radioButton(); case QQStyleKitReader::ControlType::SpinBox: |
