Warning, /libraries/kirigami-addons/src/formcard/FormButtonDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright 2022 Devin Lin <devin@kde.org> 0003 * SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 import QtQuick 2.15 0007 import QtQuick.Controls 2.15 0008 import QtQuick.Layouts 1.15 0009 0010 import org.kde.kirigami 2.19 as Kirigami 0011 0012 import "private" as Private 0013 0014 /** 0015 * @brief A Form delegate that corresponds to a clickable button. 0016 * 0017 * Use the inherited QtQuick.Controls.AbstractButton.text property to define 0018 * the main text of the button. 0019 * 0020 * The trailing property (right-most side of the button) includes an arrow 0021 * pointing to the right by default and cannot be overridden. 0022 * 0023 * @since KirigamiAddons 0.11.0 0024 * 0025 * @inherit AbstractFormDelegate 0026 */ 0027 AbstractFormDelegate { 0028 id: root 0029 0030 /** 0031 * @brief A label containing secondary text that appears under the 0032 * inherited text property. 0033 * 0034 * This provides additional information shown in a faint gray color. 0035 * 0036 * This is supposed to be a short text and the API user should avoid 0037 * making it longer than two lines. 0038 */ 0039 property string description: "" 0040 0041 /** 0042 * @brief This property allows to override the internal description 0043 * item (a QtQuick.Controls.Label) with a custom component. 0044 */ 0045 property alias descriptionItem: internalDescriptionItem 0046 0047 /** 0048 * @brief This property holds an item that will be displayed to the 0049 * left of the delegate's contents. 0050 * 0051 * default: `null` 0052 */ 0053 property var leading: null 0054 0055 /** 0056 * @brief This property holds the padding after the leading item. 0057 * 0058 * It is recommended to use Kirigami.Units here instead of direct values. 0059 * 0060 * @see Kirigami.Units 0061 */ 0062 property real leadingPadding: Kirigami.Units.smallSpacing 0063 0064 focusPolicy: Qt.StrongFocus 0065 0066 contentItem: RowLayout { 0067 spacing: 0 0068 0069 Private.ContentItemLoader { 0070 Layout.rightMargin: visible ? root.leadingPadding : 0 0071 visible: root.leading 0072 implicitHeight: visible ? root.leading.implicitHeight : 0 0073 implicitWidth: visible ? root.leading.implicitWidth : 0 0074 contentItem: root.leading 0075 } 0076 0077 Kirigami.Icon { 0078 visible: root.icon.name !== "" 0079 source: root.icon.name 0080 color: root.icon.color 0081 Layout.rightMargin: (root.icon.name !== "") ? Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing : 0 0082 implicitWidth: (root.icon.name !== "") ? Kirigami.Units.iconSizes.small : 0 0083 implicitHeight: (root.icon.name !== "") ? Kirigami.Units.iconSizes.small : 0 0084 } 0085 0086 ColumnLayout { 0087 Layout.fillWidth: true 0088 spacing: Kirigami.Units.smallSpacing 0089 0090 Label { 0091 Layout.fillWidth: true 0092 text: root.text 0093 elide: Text.ElideRight 0094 wrapMode: Text.Wrap 0095 maximumLineCount: 2 0096 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor 0097 Accessible.ignored: true // base class sets this text on root already 0098 } 0099 0100 Label { 0101 id: internalDescriptionItem 0102 Layout.fillWidth: true 0103 text: root.description 0104 color: Kirigami.Theme.disabledTextColor 0105 elide: Text.ElideRight 0106 visible: root.description !== "" 0107 wrapMode: Text.Wrap 0108 Accessible.ignored: !visible 0109 } 0110 } 0111 0112 FormArrow { 0113 Layout.leftMargin: Kirigami.Units.smallSpacing 0114 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter 0115 direction: Qt.RightArrow 0116 } 0117 } 0118 0119 Accessible.onPressAction: action ? action.trigger() : root.clicked() 0120 }