Warning, /office/klevernotes/src/contents/ui/sharedComponents/ExpendingFormSwitch.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2023 Louis Schul <schul9louis@gmail.com>
0003
0004 /*
0005 * BASED ON FormSwitchDelegate :
0006 * Copyright 2022 Devin Lin <devin@kde.org>
0007 * SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009
0010 import QtQuick 2.15
0011 import QtQuick.Templates 2.15 as T
0012 import QtQuick.Controls 2.15 as Controls
0013 import QtQuick.Layouts 1.15
0014
0015 import org.kde.kirigami 2.19 as Kirigami
0016 import org.kde.kirigamiaddons.formcard 1.0
0017
0018 T.SwitchDelegate {
0019 id: root
0020
0021 default property alias delegates: internalColumn.children
0022 /**
0023 * @brief A label containing secondary text that appears under the
0024 * inherited text property.
0025 *
0026 * This provides additional information shown in a faint gray color.
0027 */
0028 property string description: ""
0029
0030 /**
0031 * @brief This property holds the padding after the leading item.
0032 */
0033 property real leadingPadding: Kirigami.Units.smallSpacing
0034
0035 /**
0036 * @brief This property holds the padding before the trailing item.
0037 */
0038 property real trailingPadding: Kirigami.Units.smallSpacing
0039
0040 /**
0041 * @brief This property allows to override the internal description
0042 * item (a QtQuick.Controls.Label) with a custom component.
0043 */
0044 property alias descriptionItem: internalDescriptionItem
0045
0046 leftPadding: Kirigami.Units.gridUnit
0047 topPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0048 bottomPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0049 rightPadding: Kirigami.Units.gridUnit
0050
0051 implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
0052 implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding
0053
0054 focusPolicy: Qt.StrongFocus
0055 hoverEnabled: true
0056 background: FormDelegateBackground { control: root }
0057
0058 contentItem: ColumnLayout {
0059 spacing: 0
0060 RowLayout {
0061 spacing: 0
0062
0063 ColumnLayout {
0064 spacing: Kirigami.Units.smallSpacing
0065 Layout.fillWidth: true
0066
0067 Controls.Label {
0068 text: root.text
0069 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
0070 elide: Text.ElideRight
0071 wrapMode: Text.Wrap
0072 maximumLineCount: 2
0073
0074 Layout.fillWidth: true
0075 }
0076
0077 Controls.Label {
0078 id: internalDescriptionItem
0079
0080 text: root.description
0081 color: Kirigami.Theme.disabledTextColor
0082 visible: root.description !== ""
0083 wrapMode: Text.Wrap
0084 textFormat: Text.StyledText // This way we can display a link to the supported Highlighters
0085 onLinkActivated: function (link) {
0086 Qt.openUrlExternally(link)
0087 }
0088
0089 Layout.fillWidth: true
0090 }
0091 }
0092
0093 Controls.Switch {
0094 id: switchItem
0095 focusPolicy: Qt.NoFocus // provided by delegate
0096 Layout.leftMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0097
0098 enabled: root.enabled
0099 checked: root.checked
0100
0101 onToggled: root.toggled()
0102 onClicked: root.clicked()
0103 onPressAndHold: root.pressAndHold()
0104 onDoubleClicked: root.doubleClicked()
0105
0106 onCheckedChanged: {
0107 root.checked = checked;
0108 checked = Qt.binding(() => root.checked);
0109 }
0110 }
0111 }
0112
0113 ColumnLayout {
0114 id: internalColumn
0115
0116 spacing: 0
0117 visible: switchItem.checked
0118
0119 Layout.topMargin: Kirigami.Units.smallSpacing
0120 }
0121 }
0122
0123 Layout.fillWidth: true
0124 }