Kirigami-addons

SubtitleContentItem.qml
1// SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
3
4import QtQuick
5import QtQuick.Layouts
6import QtQuick.Controls as QQC2
7import QtQuick.Templates as T
8import org.kde.kirigami as Kirigami
9
10RowLayout {
11 id: root
12
13 required property T.ItemDelegate itemDelegate
14 required property string subtitle
15 property bool bold: false
16
17 readonly property alias labelItem: labelItem
18 readonly property alias subtitleItem: subtitleItem
19 readonly property alias iconItem: iconItem
20
21 spacing: Kirigami.Units.smallSpacing
22
23 Kirigami.Icon {
24 id: iconItem
25 Layout.alignment: Qt.AlignVCenter
26 visible: itemDelegate.icon.name.length > 0 || itemDelegate.icon.source.toString().length > 0
27 source: itemDelegate.icon.name.length > 0 ? itemDelegate.icon.name : itemDelegate.icon.source
28
29 Layout.preferredHeight: itemDelegate.icon.width
30 Layout.preferredWidth: itemDelegate.icon.height
31 Layout.leftMargin: Kirigami.Units.smallSpacing
32 Layout.rightMargin: Kirigami.Units.smallSpacing
33 }
34
35 ColumnLayout {
36 Layout.fillWidth: true
37 spacing: 0
38
39 QQC2.Label {
40 id: labelItem
41
42 leftPadding: itemDelegate.mirrored ? (itemDelegate.indicator ? itemDelegate.indicator.width : 0) + itemDelegate.spacing : 0
43 rightPadding: !itemDelegate.mirrored ? (itemDelegate.indicator ? itemDelegate.indicator.width : 0) + itemDelegate.spacing : 0
44
45 text: itemDelegate.text
46 font: itemDelegate.font
47 color: itemDelegate.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
48 elide: Text.ElideRight
49 visible: itemDelegate.text
50 horizontalAlignment: Text.AlignLeft
51 verticalAlignment: Text.AlignVCenter
52
53 Layout.fillWidth: true
54 Layout.alignment: subtitleItem.visible ? Qt.AlignLeft | Qt.AlignBottom : Qt.AlignLeft | Qt.AlignVCenter
55 }
56
57 QQC2.Label {
58 id: subtitleItem
59
60 color: itemDelegate.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
61 text: root.subtitle
62
63 elide: Text.ElideRight
64 font: Kirigami.Theme.smallFont
65 opacity: root.bold ? 0.9 : 0.7
66 visible: text.length > 0
67
68 Layout.fillWidth: true
69 Layout.alignment: visible ? Qt.AlignLeft | Qt.AlignTop : Qt.AlignLeft | Qt.AlignVCenter
70 }
71 }
72}
73
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.