Plasma-framework

ListSectionHeader.qml
1/*
2 * SPDX-FileCopyrightText: 2019 Björn Feber <bfeber@protonmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7import QtQuick
8import QtQuick.Layouts
9import org.kde.kirigami as Kirigami
10import org.kde.ksvg as KSvg
11import org.kde.plasma.components as PlasmaComponents
12
13/**
14 * @brief A section delegate for the primitive ListView component.
15 *
16 * It's intended to make all listviews look coherent, mirroring the style
17 * of the Kirigami version, but with the separator line being an SVG from the
18 * Plasma theme rather than a simple line.
19 *
20 * Any additional content items will be positioned in a row at the trailing side
21 * of this component.
22 *
23 *
24 * Example usage:
25 * @code
26 * import QtQuick
27 * import org.kde.plasma.components as PlasmaComponents
28 * import org.kde.plasma.extras as PlasmaExtras
29 *
30 * ListView {
31 * section.delegate: PlasmaExtras.ListSectionHeader {
32 * label: section
33 *
34 * PlasmaComponents.Button {
35 * text: "Button 1"
36 * }
37 * PlasmaComponents.Button {
38 * text: "Button 2"
39 * }
40 * }
41 * }
42 * @endcode
43 */
44PlasmaComponents.ItemDelegate {
45 id: listSection
46
47 /**
48 * @brief This property sets the text of the ListView's section header.
49 * @property string label
50 */
51 property alias label: listSection.text
52
53 default property alias _contents: rowLayout.data
54
55 hoverEnabled: false
56
57 activeFocusOnTab: false
58
59 // we do not need a background
60 background: null
61
62 topPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
63
64 contentItem: RowLayout {
65 id: rowLayout
66 spacing: Kirigami.Units.largeSpacing
67
68 Kirigami.Heading {
69 Layout.maximumWidth: rowLayout.width
70 Layout.alignment: Qt.AlignVCenter
71
72 opacity: 0.7
73 level: 5
74 type: Kirigami.Heading.Primary
75 text: listSection.text
76 elide: Text.ElideRight
77
78 // we override the Primary type's font weight (DemiBold) for Bold for contrast with small text
79 font.weight: Font.Bold
80
81 Accessible.ignored: true
82 }
83
84 KSvg.SvgItem {
85 Layout.fillWidth: true
86 Layout.alignment: Qt.AlignVCenter
87
88 imagePath: "widgets/line"
89 elementId: "horizontal-line"
90
91 Accessible.ignored: true
92 }
93 }
94}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.