Warning, /pim/kidentitymanagement/src/quick/qml/IdentityEditorPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Claudio Cambra <claudio.cambra@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 import QtQuick 2.15 0005 import QtQuick.Layouts 1.15 0006 import QtQuick.Controls 2.15 as QQC2 0007 0008 import org.kde.kirigami 2.20 as Kirigami 0009 import org.kde.kidentitymanagement 1.0 0010 import org.kde.kirigamiaddons.formcard 1.0 as FormCard 0011 0012 FormCard.FormCardPage { 0013 id: root 0014 0015 property alias mode: backend.mode 0016 property alias identityUoid: backend.identityUoid 0017 0018 required property bool allowDelete 0019 required property string identityName 0020 required property var cryptographyEditorBackend 0021 onCryptographyEditorBackendChanged: cryptographyEditorBackend.identity = identity 0022 0023 readonly property IdentityEditorBackend backend: IdentityEditorBackend { 0024 id: backend 0025 mode: IdentityEditorBackend.CreateMode 0026 } 0027 readonly property var identity: backend.identity 0028 onIdentityChanged: cryptographyEditorBackend.identity = identity 0029 0030 readonly property QQC2.Action submitAction: QQC2.Action { 0031 id: submitAction 0032 enabled: !root.identity.isNull 0033 shortcut: "Return" 0034 onTriggered: { 0035 root.backend.saveIdentity(root.identity); 0036 root.closeDialog(); 0037 } 0038 } 0039 0040 title: if (mode === IdentityEditorBackend.CreateMode) { 0041 return i18n("Add Identity"); 0042 } else { 0043 return i18n("Edit Identity"); 0044 } 0045 0046 header: QQC2.Control { 0047 id: errorContainer 0048 0049 property bool displayError: false 0050 property string errorMessage: '' 0051 0052 padding: contentItem.visible ? Kirigami.Units.smallSpacing : 0 0053 leftPadding: padding 0054 rightPadding: padding 0055 topPadding: padding 0056 bottomPadding: padding 0057 contentItem: Kirigami.InlineMessage { 0058 type: Kirigami.MessageType.Error 0059 visible: errorContainer.displayError 0060 text: errorContainer.errorMessage 0061 showCloseButton: true 0062 } 0063 } 0064 0065 BasicIdentityEditorCard { 0066 identity: root.identity 0067 } 0068 0069 FormCard.FormHeader { 0070 visible: root.cryptographyEditorBackend.validBackend 0071 title: i18ndc("libkpimidentities6", "@title:group", "Cryptography") 0072 } 0073 0074 Loader { 0075 Layout.fillWidth: true 0076 active: root.cryptographyEditorBackend.validBackend 0077 sourceComponent: CryptographyEditorCard { 0078 identity: root.identity 0079 cryptographyEditorBackend: root.cryptographyEditorBackend 0080 } 0081 } 0082 0083 footer: ColumnLayout { 0084 spacing: 0 0085 0086 Kirigami.Separator { 0087 Layout.fillWidth: true 0088 } 0089 0090 QQC2.DialogButtonBox { 0091 Layout.fillWidth: true 0092 0093 standardButtons: QQC2.DialogButtonBox.Cancel 0094 0095 QQC2.Button { 0096 icon.name: "delete" 0097 text: i18n("Delete") 0098 visible: root.mode === IdentityEditorBackend.EditMode 0099 enabled: root.allowDelete 0100 QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.DestructiveRole 0101 } 0102 0103 QQC2.Button { 0104 icon.name: root.mode === IdentityEditorBackend.EditMode ? "document-save" : "list-add" 0105 text: root.mode === IdentityEditorBackend.EditMode ? i18n("Save") : i18n("Add") 0106 QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole 0107 } 0108 0109 onRejected: root.closeDialog() 0110 onAccepted: submitAction.trigger(); 0111 onDiscarded: { 0112 dialogLoader.active = true; 0113 dialogLoader.item.open(); 0114 } 0115 0116 Loader { 0117 id: dialogLoader 0118 sourceComponent: Kirigami.PromptDialog { 0119 id: dialog 0120 title: i18n("Delete %1", root.identityName) 0121 subtitle: i18n("Are you sure you want to delete this identity?") 0122 standardButtons: Kirigami.Dialog.NoButton 0123 0124 customFooterActions: [ 0125 Kirigami.Action { 0126 text: i18n("Delete") 0127 icon.name: "delete" 0128 onTriggered: { 0129 IdentityUtils.removeIdentity(root.identityName); 0130 dialog.close(); 0131 } 0132 }, 0133 Kirigami.Action { 0134 text: i18n("Cancel") 0135 icon.name: "dialog-cancel" 0136 onTriggered: dialog.close() 0137 } 0138 ] 0139 } 0140 } 0141 } 0142 } 0143 }