Warning, /libraries/kirigami-addons/src/delegates/DefaultContentItem.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Layouts 1.15
0006 import QtQuick.Controls 2.15 as QQC2
0007 import QtQuick.Templates 2.15 as T
0008 import org.kde.kirigami 2.20 as Kirigami
0009 
0010 /**
0011  * Content item which is used by default in the RoundedItemDelegate and IndicatorItemDelegate. Provides a label and an icon.
0012  *
0013  * This can be used directly as contentItem or inside a RowLayout if you need to put some content before or after this item.
0014  *
0015  * @since KirigamiAddons 0.10.0
0016  */
0017 RowLayout {
0018     id: root
0019 
0020     /**
0021      * This required property holds the item delegate corresponding to this content item.
0022      *
0023      * @since KirigamiAddons 0.10.0
0024      */
0025     required property T.AbstractButton itemDelegate
0026 
0027     /**
0028      * This property holds the Label containing the text of the item delegate.
0029      *
0030      * @since KirigamiAddons 0.10.1
0031      */
0032     readonly property alias labelItem: labelItem
0033 
0034     /**
0035      * This property holds the Kirigami.Icon containing the icon of the item delegate.
0036      *
0037      * @since KirigamiAddons 0.10.1
0038      */
0039     readonly property alias iconItem: iconItem
0040 
0041     spacing: Kirigami.Units.smallSpacing
0042 
0043     Kirigami.Icon {
0044         id: iconItem
0045 
0046         Layout.alignment: Qt.AlignVCenter
0047         visible: itemDelegate.icon.name.length > 0 || itemDelegate.icon.source.toString().length > 0
0048         source: itemDelegate.icon.name.length > 0 ? itemDelegate.icon.name : itemDelegate.icon.source
0049         Layout.preferredHeight: itemDelegate.icon.width
0050         Layout.preferredWidth: itemDelegate.icon.height
0051     }
0052 
0053     QQC2.Label {
0054         id: labelItem
0055 
0056         leftPadding: itemDelegate.mirrored ? (itemDelegate.indicator ? itemDelegate.indicator.width : 0) + itemDelegate.spacing : 0
0057         rightPadding: !itemDelegate.mirrored ? (itemDelegate.indicator ? itemDelegate.indicator.width : 0) + itemDelegate.spacing : 0
0058 
0059         text: root.itemDelegate.text
0060         font: root.itemDelegate.font
0061         color: root.itemDelegate.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
0062         elide: Text.ElideRight
0063         visible: itemDelegate.text && itemDelegate.display !== QQC2.AbstractButton.IconOnly
0064         horizontalAlignment: Text.AlignLeft
0065         verticalAlignment: Text.AlignVCenter
0066         Layout.alignment: Qt.AlignLeft
0067         Layout.fillWidth: true
0068     }
0069 }
0070