Warning, /frameworks/kirigami/src/controls/ListSectionHeader.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2019 Björn Feber <bfeber@protonmail.com>
0003 *
0004 * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick
0008 import QtQuick.Controls
0009 import QtQuick.Layouts
0010 import org.kde.kirigami as Kirigami
0011
0012 /**
0013 * @brief A section delegate for the primitive ListView component.
0014 *
0015 * It's intended to make all listviews look coherent.
0016 *
0017 * Example usage:
0018 * @code
0019 * import QtQuick 2.5
0020 * import QtQuick.Controls 2.5 as QQC2
0021 *
0022 * import org.kde.kirigami 2.10 as Kirigami
0023 *
0024 * ListView {
0025 * [...]
0026 * section.delegate: Kirigami.ListSectionHeader {
0027 * label: section
0028 *
0029 * QQC2.Button {
0030 * text: "Button 1"
0031 * }
0032 * QQC2.Button {
0033 * text: "Button 2"
0034 * }
0035 * }
0036 * [...]
0037 * }
0038 * @endcode
0039 */
0040 ItemDelegate {
0041 id: listSection
0042
0043 /**
0044 * @brief This property sets the text of the ListView's section header.
0045 * @property string label
0046 */
0047 property alias label: listSection.text
0048
0049 default property alias _contents: rowLayout.data
0050
0051 hoverEnabled: false
0052
0053 activeFocusOnTab: false
0054
0055 // we do not need a background
0056 background: Item {}
0057
0058 topPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0059
0060 contentItem: RowLayout {
0061 id: rowLayout
0062 spacing: Kirigami.Units.largeSpacing
0063
0064 Kirigami.Heading {
0065 Layout.maximumWidth: rowLayout.width
0066 Layout.alignment: Qt.AlignVCenter
0067
0068 opacity: 0.7
0069 level: 5
0070 type: Kirigami.Heading.Primary
0071 text: listSection.text
0072 elide: Text.ElideRight
0073
0074 // we override the Primary type's font weight (DemiBold) for Bold for contrast with small text
0075 font.weight: Font.Bold
0076
0077 Accessible.ignored: true
0078 }
0079
0080 Kirigami.Separator {
0081 Layout.fillWidth: true
0082 Layout.alignment: Qt.AlignVCenter
0083 Accessible.ignored: true
0084 }
0085 }
0086 }