Kirigami-addons

DefaultContentItem.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
10/**
11 * Content item which is used by default in the RoundedItemDelegate and IndicatorItemDelegate. Provides a label and an icon.
12 *
13 * This can be used directly as contentItem or inside a RowLayout if you need to put some content before or after this item.
14 *
15 * @since KirigamiAddons 0.10.0
16 */
17RowLayout {
18 id: root
19
20 /**
21 * This required property holds the item delegate corresponding to this content item.
22 *
23 * @since KirigamiAddons 0.10.0
24 */
25 required property T.AbstractButton itemDelegate
26
27 /**
28 * This property holds the Label containing the text of the item delegate.
29 *
30 * @since KirigamiAddons 0.10.1
31 */
32 readonly property alias labelItem: labelItem
33
34 /**
35 * This property holds the Kirigami.Icon containing the icon of the item delegate.
36 *
37 * @since KirigamiAddons 0.10.1
38 */
39 readonly property alias iconItem: iconItem
40
41 spacing: Kirigami.Units.smallSpacing
42
43 Kirigami.Icon {
44 id: iconItem
45
46 Layout.alignment: Qt.AlignVCenter
47 visible: itemDelegate.icon.name.length > 0 || itemDelegate.icon.source.toString().length > 0
48 source: itemDelegate.icon.name.length > 0 ? itemDelegate.icon.name : itemDelegate.icon.source
49 Layout.preferredHeight: itemDelegate.icon.width
50 Layout.preferredWidth: itemDelegate.icon.height
51 }
52
53 QQC2.Label {
54 id: labelItem
55
56 leftPadding: itemDelegate.mirrored ? (itemDelegate.indicator ? itemDelegate.indicator.width : 0) + itemDelegate.spacing : 0
57 rightPadding: !itemDelegate.mirrored ? (itemDelegate.indicator ? itemDelegate.indicator.width : 0) + itemDelegate.spacing : 0
58
59 text: root.itemDelegate.text
60 font: root.itemDelegate.font
61 color: root.itemDelegate.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
62 elide: Text.ElideRight
63 visible: itemDelegate.text && itemDelegate.display !== QQC2.AbstractButton.IconOnly
64 horizontalAlignment: Text.AlignLeft
65 verticalAlignment: Text.AlignVCenter
66 Layout.alignment: Qt.AlignLeft
67 Layout.fillWidth: true
68
69 Accessible.ignored: true
70 }
71}
72
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:46:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.