Warning, /libraries/kirigami-addons/src/formcard/FormRadioDelegate.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.Templates 2.15 as T 0008 import QtQuick.Controls 2.15 as Controls 0009 import QtQuick.Layouts 1.15 0010 0011 import org.kde.kirigami 2.19 as Kirigami 0012 0013 import "private" as Private 0014 0015 /** 0016 * @brief A Form delegate that corresponds to a radio button. 0017 * 0018 * This component is used for creating multiple on/off toggles for the same 0019 * setting. In other words, by grouping multiple radio buttons under the same 0020 * parent, only one of the radio buttons should be checkable and applied to a 0021 * setting. 0022 * 0023 * Use the inherited QtQuick.Controls.AbstractButton.text property to define 0024 * the main text of the radio button. 0025 * 0026 * If you need multiple values for the same setting, use a 0027 * FormComboBoxDelegate instead. 0028 * 0029 * If you need a purely on/off toggle for a single setting, use a 0030 * FormSwitchDelegate instead. 0031 * 0032 * If you need an on/off/tristate toggle, use a FormCheckDelegate instead. 0033 * 0034 * @since KirigamiAddons 0.11.0 0035 * 0036 * @see QtQuick.Controls.AbstractButton 0037 * @see FormSwitchDelegate 0038 * @see FormCheckDelegate 0039 * @see FormComboBoxDelegate 0040 * 0041 * @inherit QtQuick.Controls.RadioDelegate 0042 */ 0043 T.RadioDelegate { 0044 id: root 0045 0046 /** 0047 * @brief A label containing secondary text that appears under the 0048 * inherited text property. 0049 * 0050 * This provides additional information shown in a faint gray color. 0051 */ 0052 property string description: "" 0053 0054 /** 0055 * @brief This property holds an item that will be displayed to the left of the delegate's contents. 0056 */ 0057 property var leading: null 0058 0059 /** 0060 * @brief This property holds the padding after the leading item. 0061 */ 0062 property real leadingPadding: Kirigami.Units.smallSpacing 0063 0064 /** 0065 * @brief This property holds an item that will be displayed after the 0066 * delegate's contents. 0067 */ 0068 property var trailing: null 0069 0070 /** 0071 * @brief This property holds the padding before the trailing item. 0072 */ 0073 property real trailingPadding: Kirigami.Units.smallSpacing 0074 0075 leftPadding: Kirigami.Units.gridUnit 0076 topPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing 0077 bottomPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing 0078 rightPadding: Kirigami.Units.gridUnit 0079 0080 implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding 0081 implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding 0082 0083 focusPolicy: Qt.StrongFocus 0084 hoverEnabled: true 0085 background: FormDelegateBackground { control: root } 0086 0087 Layout.fillWidth: true 0088 0089 contentItem: RowLayout { 0090 spacing: 0 0091 0092 Private.ContentItemLoader { 0093 Layout.rightMargin: visible ? root.leadingPadding : 0 0094 visible: root.leading 0095 implicitHeight: visible ? root.leading.implicitHeight : 0 0096 implicitWidth: visible ? root.leading.implicitWidth : 0 0097 contentItem: root.leading 0098 } 0099 0100 Controls.RadioButton { 0101 id: radioButtonItem 0102 focusPolicy: Qt.NoFocus // provided by delegate 0103 Layout.rightMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing 0104 0105 enabled: root.enabled 0106 checked: root.checked 0107 0108 onToggled: root.toggled() 0109 onClicked: root.clicked() 0110 onPressAndHold: root.pressAndHold() 0111 onDoubleClicked: root.doubleClicked() 0112 0113 onCheckedChanged: { 0114 root.checked = checked; 0115 checked = Qt.binding(() => root.checked); 0116 } 0117 } 0118 0119 ColumnLayout { 0120 Layout.fillWidth: true 0121 spacing: Kirigami.Units.smallSpacing 0122 0123 Controls.Label { 0124 Layout.fillWidth: true 0125 text: root.text 0126 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor 0127 elide: Text.ElideRight 0128 wrapMode: Text.Wrap 0129 maximumLineCount: 2 0130 } 0131 0132 Controls.Label { 0133 visible: root.description !== "" 0134 Layout.fillWidth: true 0135 text: root.description 0136 color: Kirigami.Theme.disabledTextColor 0137 wrapMode: Text.Wrap 0138 } 0139 } 0140 0141 Private.ContentItemLoader { 0142 Layout.leftMargin: visible ? root.trailingPadding : 0 0143 visible: root.trailing 0144 implicitHeight: visible ? root.trailing.implicitHeight : 0 0145 implicitWidth: visible ? root.trailing.implicitWidth : 0 0146 contentItem: root.trailing 0147 } 0148 } 0149 } 0150 0151