Warning, /network/tokodon/src/content/ui/EditListPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 import QtQuick 0005 import org.kde.kirigami 2 as Kirigami 0006 import QtQuick.Controls 2 as QQC2 0007 import QtQuick.Layouts 0008 import QtQml.Models 0009 0010 import org.kde.kirigamiaddons.formcard 1 as FormCard 0011 import org.kde.kirigamiaddons.components 1 as Components 0012 0013 import org.kde.tokodon 0014 0015 FormCard.FormCardPage { 0016 id: root 0017 0018 enum Purpose { 0019 New, 0020 Edit 0021 } 0022 0023 property var purpose 0024 property string listId 0025 0026 readonly property bool isValid: titleField.text.length > 0 0027 0028 title: purpose === EditListPage.New ? i18nc("@title:window", "Create List") : i18nc("@title:window", "Edit List") 0029 0030 property ListEditorBackend backend: ListEditorBackend { 0031 listId: root.listId 0032 title: titleField.text 0033 exclusive: exclusiveField.checked 0034 } 0035 0036 data: Connections { 0037 target: backend 0038 0039 function onLoadingChanged() { 0040 // If we loaded data, then overwrite the fields 0041 titleField.text = backend.title; 0042 exclusiveField.checked = backend.exclusive; 0043 repliesPolicyField.currentIndex = backend.replyPolicyIndex(); 0044 } 0045 0046 function onDone() { 0047 pageStack.layers.pop(); 0048 } 0049 } 0050 0051 Component.onCompleted: titleField.forceActiveFocus() 0052 0053 FormCard.FormCard { 0054 enabled: !backend.loading 0055 0056 Layout.topMargin: Kirigami.Units.largeSpacing 0057 0058 FormCard.FormTextFieldDelegate { 0059 id: titleField 0060 label: i18nc("@label:textbox List title", "Title") 0061 onAccepted: exclusiveField.forceActiveFocus() 0062 } 0063 0064 FormCard.FormDelegateSeparator {} 0065 0066 FormCard.FormComboBoxDelegate { 0067 id: repliesPolicyField 0068 text: i18nc("@label", "Show replies for") 0069 model: backend.replyPolicies() 0070 currentIndex: 0 0071 onCurrentIndexChanged: backend.setReplyPolicyIndex(currentIndex) 0072 0073 Layout.fillWidth: true 0074 } 0075 0076 FormCard.FormDelegateSeparator {} 0077 0078 FormCard.FormCheckDelegate { 0079 id: exclusiveField 0080 text: i18nc("@label If the list is exclusive", "Exclusive") 0081 description: i18n("Posts in an exclusive list are excluded from the Home timeline.") 0082 } 0083 } 0084 0085 FormCard.FormCard { 0086 enabled: !backend.loading 0087 0088 Layout.topMargin: Kirigami.Units.largeSpacing 0089 0090 FormCard.FormButtonDelegate { 0091 id: createButton 0092 enabled: root.isValid 0093 icon.name: { 0094 if (root.purpose === EditListPage.New) { 0095 return "gtk-add"; 0096 } else { 0097 return "edit-rename"; 0098 } 0099 } 0100 text: { 0101 if (root.purpose === EditListPage.New) { 0102 return i18nc("@action:button Create the list", "Create"); 0103 } else { 0104 return i18nc("@action:button Edit the list", "Edit"); 0105 } 0106 } 0107 onClicked: backend.submit() 0108 } 0109 0110 FormCard.FormDelegateSeparator { 0111 visible: deleteButton.visible 0112 } 0113 0114 FormCard.FormButtonDelegate { 0115 id: deleteButton 0116 visible: root.purpose === EditListPage.Edit 0117 text: i18nc("@action:button Delete the list", "Delete") 0118 icon.name: "edit-delete" 0119 onClicked: removeListPrompt.open() 0120 0121 Kirigami.PromptDialog { 0122 id: removeListPrompt 0123 0124 title: i18nc("@title", "Deleting List") 0125 subtitle: i18nc("@label", "Are you sure you want to delete this list?") 0126 standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel 0127 showCloseButton: false 0128 0129 onAccepted: backend.deleteList() 0130 } 0131 } 0132 } 0133 }