diff options
| author | Dilek Akcay <dilek.akcay@qt.io> | 2026-09-25 11:51:15 +0200 |
|---|---|---|
| committer | Dilek Akcay <dilek.akcay@qt.io> | 2026-10-01 05:11:17 +0000 |
| commit | 819000b162adb70643f09ba5c4f49259b81fef64 (patch) | |
| tree | 36898180a45af5ac7c25cb5c8753df312b2beffe | |
| parent | da546431040e659725e603984cab38eccbf67978 (diff) | |
StyleKit: Implement VerticalHeaderView and VerticalHeaderViewDelegate
Pick-to: 6.12
Change-Id: I3344b3f8f078ae50284486cb7db5e750943f3133
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
| -rw-r--r-- | src/labs/stylekit/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/labs/stylekit/VerticalHeaderView.qml | 18 | ||||
| -rw-r--r-- | src/labs/stylekit/VerticalHeaderViewDelegate.qml | 64 | ||||
| -rw-r--r-- | src/labs/stylekit/doc/snippets/ControlsSnippets.qml | 9 | ||||
| -rw-r--r-- | src/labs/stylekit/doc/snippets/ReferenceFallbackStyle.qml | 7 | ||||
| -rw-r--r-- | src/labs/stylekit/impl/FallbackStyle.qml | 7 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitcontrols.cpp | 11 | ||||
| -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.cpp | 91 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitreader_p.h | 3 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekittheme.cpp | 1 |
12 files changed, 175 insertions, 46 deletions
diff --git a/src/labs/stylekit/CMakeLists.txt b/src/labs/stylekit/CMakeLists.txt index 171a5606b9..9c4525b505 100644 --- a/src/labs/stylekit/CMakeLists.txt +++ b/src/labs/stylekit/CMakeLists.txt @@ -86,6 +86,8 @@ qt_internal_add_qml_module(LabsStyleKit Label.qml GroupBox.qml TextArea.qml + VerticalHeaderView.qml + VerticalHeaderViewDelegate.qml LIBRARIES Qt6::GuiPrivate Qt6::Qml diff --git a/src/labs/stylekit/VerticalHeaderView.qml b/src/labs/stylekit/VerticalHeaderView.qml new file mode 100644 index 0000000000..c2a8f83ad1 --- /dev/null +++ b/src/labs/stylekit/VerticalHeaderView.qml @@ -0,0 +1,18 @@ +// Copyright (C) 2026 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.VerticalHeaderView { + id: control + + implicitWidth: Math.max(1, contentWidth) + implicitHeight: syncView ? syncView.height : 0 + + delegate: VerticalHeaderViewDelegate { } +} diff --git a/src/labs/stylekit/VerticalHeaderViewDelegate.qml b/src/labs/stylekit/VerticalHeaderViewDelegate.qml new file mode 100644 index 0000000000..8326d3234b --- /dev/null +++ b/src/labs/stylekit/VerticalHeaderViewDelegate.qml @@ -0,0 +1,64 @@ +// Copyright (C) 2026 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.HeaderViewDelegate { + id: control + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + highlighted: control.selected + + leftPadding: styleReader.leftPadding + rightPadding: styleReader.rightPadding + topPadding: styleReader.topPadding + bottomPadding: styleReader.bottomPadding + + leftInset: styleReader.background.leftMargin + rightInset: styleReader.background.rightMargin + topInset: styleReader.background.topMargin + bottomInset: styleReader.background.bottomMargin + + spacing: styleReader.spacing + font: styleReader.font + + StyleVariation.controlType: styleReader.controlType + StyleReader { + id: styleReader + controlType: StyleReader.VerticalHeaderViewDelegate + enabled: control.enabled + checked: control.checked + hovered: control.hovered + pressed: control.pressed + highlighted: control.highlighted + palette: control.palette + } + + contentItem: Label { + color: styleReader.text.color + text: control.model[control.headerView.textRole] + font: styleReader.font + + horizontalAlignment: styleReader.text.alignment & Qt.AlignHorizontal_Mask + verticalAlignment: styleReader.text.alignment & Qt.AlignVertical_Mask + padding: styleReader.text.padding + leftPadding: styleReader.text.leftPadding + rightPadding: styleReader.text.rightPadding + bottomPadding: styleReader.text.bottomPadding + topPadding: styleReader.text.topPadding + } + + background: BackgroundDelegate { + quickControl: control + backgroundStyle: styleReader.background + } +} diff --git a/src/labs/stylekit/doc/snippets/ControlsSnippets.qml b/src/labs/stylekit/doc/snippets/ControlsSnippets.qml index 710f860a16..265fd940f7 100644 --- a/src/labs/stylekit/doc/snippets/ControlsSnippets.qml +++ b/src/labs/stylekit/doc/snippets/ControlsSnippets.qml @@ -957,6 +957,15 @@ ApplicationWindow { } //! [tumbler] + //! [verticalHeaderViewDelegate] + verticalHeaderViewDelegate { + background { + border.width: 1 + color: "#fafafa" + } + } + //! [verticalHeaderViewDelegate] + //! [theme] light: Theme { applicationWindow.background.color: "#f0f0f0" diff --git a/src/labs/stylekit/doc/snippets/ReferenceFallbackStyle.qml b/src/labs/stylekit/doc/snippets/ReferenceFallbackStyle.qml index a45b5136a5..26f69ad577 100644 --- a/src/labs/stylekit/doc/snippets/ReferenceFallbackStyle.qml +++ b/src/labs/stylekit/doc/snippets/ReferenceFallbackStyle.qml @@ -721,5 +721,12 @@ BaseStyle { border.width: 0 } } + + verticalHeaderViewDelegate { + background { + border.width: 1 + color: Qt.darker(__baseWhite, 1.05) + } + } } //! [1] diff --git a/src/labs/stylekit/impl/FallbackStyle.qml b/src/labs/stylekit/impl/FallbackStyle.qml index 4f7430363f..30d0b71803 100644 --- a/src/labs/stylekit/impl/FallbackStyle.qml +++ b/src/labs/stylekit/impl/FallbackStyle.qml @@ -781,4 +781,11 @@ BaseStyle { border.width: 0 } } + + verticalHeaderViewDelegate { + background { + border.width: 1 + color: Qt.darker(__baseWhite, 1.05) + } + } } diff --git a/src/labs/stylekit/qqstylekitcontrols.cpp b/src/labs/stylekit/qqstylekitcontrols.cpp index 31880a9482..7cd4d0de76 100644 --- a/src/labs/stylekit/qqstylekitcontrols.cpp +++ b/src/labs/stylekit/qqstylekitcontrols.cpp @@ -639,6 +639,16 @@ QT_BEGIN_NAMESPACE \snippet ControlsSnippets.qml tumbler */ +/* + \qmlproperty ControlStyle StylableControls::verticalHeaderViewDelegate + + Grouped property for styling \l [QtQuickControls]{VerticalHeaderViewDelegate}. + + Unset properties fall back to \l tableViewDelegate. + + \snippet ControlsSnippets.qml verticalHeaderViewDelegate +*/ + using namespace Qt::StringLiterals; QQStyleKitControls::QQStyleKitControls(QObject *parent) @@ -763,6 +773,7 @@ IMPLEMENT_ACCESSORS(menuBar, QQStyleKitReader::ControlType::MenuBar) IMPLEMENT_ACCESSORS(menuBarItem, QQStyleKitReader::ControlType::MenuBarItem) IMPLEMENT_ACCESSORS(menuItem, QQStyleKitReader::ControlType::MenuItem) IMPLEMENT_ACCESSORS(menuSeparator, QQStyleKitReader::ControlType::MenuSeparator) +IMPLEMENT_ACCESSORS(verticalHeaderViewDelegate, QQStyleKitReader::ControlType::VerticalHeaderViewDelegate) #undef IMPLEMENT_ACCESSORS diff --git a/src/labs/stylekit/qqstylekitcontrols_p.h b/src/labs/stylekit/qqstylekitcontrols_p.h index 019223028d..e19b753a73 100644 --- a/src/labs/stylekit/qqstylekitcontrols_p.h +++ b/src/labs/stylekit/qqstylekitcontrols_p.h @@ -82,6 +82,7 @@ class QQStyleKitControls : public QObject, public QQmlParserStatus Q_PROPERTY(QQStyleKitControl *menuBarItem READ menuBarItem WRITE set_menuBarItem NOTIFY menuBarItemChanged FINAL) Q_PROPERTY(QQStyleKitControl *menuItem READ menuItem WRITE set_menuItem NOTIFY menuItemChanged FINAL) Q_PROPERTY(QQStyleKitControl *menuSeparator READ menuSeparator WRITE set_menuSeparator NOTIFY menuSeparatorChanged FINAL) + Q_PROPERTY(QQStyleKitControl *verticalHeaderViewDelegate READ verticalHeaderViewDelegate WRITE set_verticalHeaderViewDelegate NOTIFY verticalHeaderViewDelegateChanged FINAL) QML_UNCREATABLE("This component is abstract, and cannot be instantiated") QML_NAMED_ELEMENT(StylableControls) @@ -146,6 +147,7 @@ public: IMPLEMENT_ACCESSORS(menuBarItem) IMPLEMENT_ACCESSORS(menuItem) IMPLEMENT_ACCESSORS(menuSeparator) + IMPLEMENT_ACCESSORS(verticalHeaderViewDelegate) #undef IMPLEMENT_ACCESSORS @@ -207,6 +209,7 @@ signals: void menuBarItemChanged(); void menuItemChanged(); void menuSeparatorChanged(); + void verticalHeaderViewDelegateChanged(); protected: void classBegin() override {} diff --git a/src/labs/stylekit/qqstylekitpropertyresolver.cpp b/src/labs/stylekit/qqstylekitpropertyresolver.cpp index d4d060a3d3..cc323642a5 100644 --- a/src/labs/stylekit/qqstylekitpropertyresolver.cpp +++ b/src/labs/stylekit/qqstylekitpropertyresolver.cpp @@ -95,6 +95,11 @@ const QList<QQStyleKitExtendableControlType> QQStyleKitPropertyResolver::baseTyp static QList<QQStyleKitExtendableControlType> t = { QQStyleKitReader::TextInput, QQStyleKitReader::Control }; return t; } + case QQStyleKitReader::VerticalHeaderViewDelegate: { + static QList<QQStyleKitExtendableControlType> t = + { QQStyleKitReader::TableViewDelegate, QQStyleKitReader::ItemDelegate, QQStyleKitReader::Control }; + return t; + } default: { static QList<QQStyleKitExtendableControlType> t = { QQStyleKitReader::Control }; diff --git a/src/labs/stylekit/qqstylekitreader.cpp b/src/labs/stylekit/qqstylekitreader.cpp index d61d314e96..796db09a1e 100644 --- a/src/labs/stylekit/qqstylekitreader.cpp +++ b/src/labs/stylekit/qqstylekitreader.cpp @@ -62,51 +62,52 @@ QT_BEGIN_NAMESPACE below, or to a \l {CustomControl::controlType}{custom control type} defined in the \l Style. - \value StyleReader.BusyIndicator \l {BusyIndicator} - \value StyleReader.Button \l {Button} - \value StyleReader.CheckBox \l {CheckBox} - \value StyleReader.CheckDelegate \l {CheckDelegate} - \value StyleReader.ComboBox \l {ComboBox} - \value StyleReader.DelayButton \l {DelayButton} - \value StyleReader.Dial \l {Dial} - \value StyleReader.Dialog \l {Dialog} - \value StyleReader.DialogButtonBox \l {DialogButtonBox} - \value StyleReader.Drawer \l {Drawer} - \value StyleReader.Frame \l {Frame} - \value StyleReader.GroupBox \l {GroupBox} - \value StyleReader.ItemDelegate \l {ItemDelegate} - \value StyleReader.Label \l {Label} - \value StyleReader.Menu \l {Menu} - \value StyleReader.MenuBar \l {MenuBar} - \value StyleReader.MenuBarItem \l {MenuBarItem} - \value StyleReader.MenuItem \l {MenuItem} - \value StyleReader.MenuSeparator \l {MenuSeparator} - \value StyleReader.Page \l {Page} - \value StyleReader.PageIndicator \l {PageIndicator} - \value StyleReader.Pane \l {Pane} - \value StyleReader.Popup \l {Popup} - \value StyleReader.ProgressBar \l {ProgressBar} - \value StyleReader.RadioButton \l {RadioButton} - \value StyleReader.RadioDelegate \l {RadioDelegate} - \value StyleReader.RoundButton \l {RoundButton} - \value StyleReader.ScrollBar \l {ScrollBar} - \value StyleReader.ScrollView \l {ScrollView} - \value StyleReader.SearchField \l {SearchField} - \value StyleReader.Slider \l {Slider} - \value StyleReader.SpinBox \l {SpinBox} - \value StyleReader.SwipeDelegate \l {SwipeDelegate} - \value StyleReader.Switch \l {Switch} - \value StyleReader.SwitchDelegate \l {SwitchDelegate} - \value StyleReader.TabBar \l {TabBar} - \value StyleReader.TabButton \l {TabButton} - \value StyleReader.TableViewDelegate \l {TableViewDelegate} - \value StyleReader.TextArea \l {TextArea} - \value StyleReader.TextField \l {TextField} - \value StyleReader.ToolBar \l {ToolBar} - \value StyleReader.ToolButton \l {ToolButton} - \value StyleReader.ToolSeparator \l {ToolSeparator} - \value StyleReader.ToolTip \l {ToolTip} - \value StyleReader.Tumbler \l {Tumbler} + \value StyleReader.BusyIndicator \l {BusyIndicator} + \value StyleReader.Button \l {Button} + \value StyleReader.CheckBox \l {CheckBox} + \value StyleReader.CheckDelegate \l {CheckDelegate} + \value StyleReader.ComboBox \l {ComboBox} + \value StyleReader.DelayButton \l {DelayButton} + \value StyleReader.Dial \l {Dial} + \value StyleReader.Dialog \l {Dialog} + \value StyleReader.DialogButtonBox \l {DialogButtonBox} + \value StyleReader.Drawer \l {Drawer} + \value StyleReader.Frame \l {Frame} + \value StyleReader.GroupBox \l {GroupBox} + \value StyleReader.ItemDelegate \l {ItemDelegate} + \value StyleReader.Label \l {Label} + \value StyleReader.Menu \l {Menu} + \value StyleReader.MenuBar \l {MenuBar} + \value StyleReader.MenuBarItem \l {MenuBarItem} + \value StyleReader.MenuItem \l {MenuItem} + \value StyleReader.MenuSeparator \l {MenuSeparator} + \value StyleReader.Page \l {Page} + \value StyleReader.PageIndicator \l {PageIndicator} + \value StyleReader.Pane \l {Pane} + \value StyleReader.Popup \l {Popup} + \value StyleReader.ProgressBar \l {ProgressBar} + \value StyleReader.RadioButton \l {RadioButton} + \value StyleReader.RadioDelegate \l {RadioDelegate} + \value StyleReader.RoundButton \l {RoundButton} + \value StyleReader.ScrollBar \l {ScrollBar} + \value StyleReader.ScrollView \l {ScrollView} + \value StyleReader.SearchField \l {SearchField} + \value StyleReader.Slider \l {Slider} + \value StyleReader.SpinBox \l {SpinBox} + \value StyleReader.SwipeDelegate \l {SwipeDelegate} + \value StyleReader.Switch \l {Switch} + \value StyleReader.SwitchDelegate \l {SwitchDelegate} + \value StyleReader.TabBar \l {TabBar} + \value StyleReader.TabButton \l {TabButton} + \value StyleReader.TableViewDelegate \l {TableViewDelegate} + \value StyleReader.TextArea \l {TextArea} + \value StyleReader.TextField \l {TextField} + \value StyleReader.ToolBar \l {ToolBar} + \value StyleReader.ToolButton \l {ToolButton} + \value StyleReader.ToolSeparator \l {ToolSeparator} + \value StyleReader.ToolTip \l {ToolTip} + \value StyleReader.Tumbler \l {Tumbler} + \value StyleReader.VerticalHeaderViewDelegate \l {VerticalHeaderViewDelegate} \sa {StyleVariation::controlType}{StyleVariation.controlType} */ diff --git a/src/labs/stylekit/qqstylekitreader_p.h b/src/labs/stylekit/qqstylekitreader_p.h index e022c99f06..86f497746e 100644 --- a/src/labs/stylekit/qqstylekitreader_p.h +++ b/src/labs/stylekit/qqstylekitreader_p.h @@ -102,7 +102,8 @@ public: PageIndicator, Frame, Label, - GroupBox + GroupBox, + VerticalHeaderViewDelegate }; Q_ENUM(ControlType) diff --git a/src/labs/stylekit/qqstylekittheme.cpp b/src/labs/stylekit/qqstylekittheme.cpp index cda990299a..bf078867c6 100644 --- a/src/labs/stylekit/qqstylekittheme.cpp +++ b/src/labs/stylekit/qqstylekittheme.cpp @@ -69,6 +69,7 @@ static QQuickTheme::Scope scopeForType(QQStyleKitExtendableControlType type) return QQuickTheme::GroupBox; case QQStyleKitReader::ControlType::ItemDelegate: case QQStyleKitReader::ControlType::TableViewDelegate: + case QQStyleKitReader::ControlType::VerticalHeaderViewDelegate: return QQuickTheme::ItemView; case QQStyleKitReader::ControlType::Label: return QQuickTheme::Label; |
