Warning, /office/klevernotes/src/contents/ui/todoEditor/TodoDelegate.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 import QtQuick 2.15
0005 import QtQuick.Layouts 1.15
0006 import QtQuick.Controls 2.15 as Controls
0007
0008 import org.kde.kirigami 2.20 as Kirigami
0009 import org.kde.kirigamiaddons.formcard 1.0 as FormCard
0010
0011 Kirigami.AbstractCard {
0012 id: card
0013
0014 padding: 0
0015 implicitWidth: cardsView.width
0016
0017 contentItem: RowLayout {
0018 spacing: 0
0019 // Tried to used a FormCheckDelegate with a custom trailing, doesn't work :/
0020 FormCard.AbstractFormDelegate {
0021 id: check
0022
0023 Layout.fillHeight: true
0024 Layout.fillWidth: true
0025 Layout.preferredWidth: parent.width - editButton.width
0026 Layout.alignment: Qt.AlignTop
0027 Layout.margins: 0
0028
0029 contentItem: RowLayout {
0030 Controls.CheckBox {
0031 id: checkbox
0032
0033 checked: todoChecked
0034 Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
0035
0036 onCheckedChanged: {
0037 todoModel.setProperty(index, "todoChecked", checked)
0038 root.saveTodos()
0039 }
0040 }
0041
0042 ColumnLayout {
0043 Layout.fillWidth: true
0044 Kirigami.Heading {
0045 id: displayTitle
0046
0047 text: todoTitle
0048 level: 1
0049 elide: Text.ElideRight
0050
0051 Layout.fillWidth: true
0052 }
0053
0054 Kirigami.Separator {
0055 id: centralSeperator
0056
0057 Layout.fillWidth: true
0058 }
0059
0060 Controls.Label {
0061 id: descriptionLabel
0062
0063 text: todoDesc
0064 elide: Text.ElideRight
0065 wrapMode: Text.WrapAnywhere
0066 maximumLineCount: 1
0067
0068 // Both are required the center part of the whole delegate goes crazy without this
0069 Layout.fillWidth: true
0070
0071 Behavior on maximumLineCount {
0072 NumberAnimation { duration: Kirigami.Units.shortDuration }
0073 }
0074 }
0075 }
0076 }
0077
0078 onClicked: {
0079 checkbox.checked = !checkbox.checked
0080 }
0081 }
0082
0083 FormCard.AbstractFormDelegate {
0084 id: editButton
0085
0086 Layout.fillHeight: true
0087 Layout.preferredWidth: Kirigami.Units.iconSizes.large
0088
0089 // Can't put the icon directly, won't let me change the size
0090 contentItem: Item {
0091 anchors.fill: parent
0092 Kirigami.Icon {
0093 x: width / 2
0094 y: Math.round((parent.height - width) / 2)
0095 width: Math.round(parent.width / 2)
0096 height: Math.round(parent.width / 2)
0097
0098 source: "edit-entry"
0099 }
0100 }
0101
0102 onClicked: {
0103 todoDialog.callerModelIndex = index
0104 todoDialog.name = displayTitle.text
0105 todoDialog.description = descriptionLabel.text
0106 todoDialog.open()
0107 }
0108 }
0109 }
0110
0111 footer: FormCard.AbstractFormDelegate {
0112 focusPolicy: Qt.StrongFocus
0113 visible: descriptionLabel.truncated || descriptionLabel.maximumLineCount > 1
0114
0115 contentItem: RowLayout {
0116 spacing: 0
0117
0118 FormCard.FormArrow {
0119 direction: descriptionLabel.truncated ? Qt.DownArrow : Qt.UpArrow
0120 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
0121 }
0122 }
0123
0124 Accessible.onPressAction: action ? action.trigger() : root.clicked()
0125
0126 onClicked: {
0127 descriptionLabel.maximumLineCount = descriptionLabel.truncated
0128 ? 12
0129 : 1
0130 }
0131 }
0132 }