Warning, /utilities/keysmith/src/contents/ui/AccountEntryViewBase.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-License-Identifier: GPL-3.0-or-later 0003 * SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com> 0004 */ 0005 0006 import QtQuick 0007 import QtQuick.Layouts 0008 import QtQuick.Controls as Controls 0009 import org.kde.kirigami as Kirigami 0010 import org.kde.kirigamiaddons.formcard as FormCard 0011 0012 import Keysmith.Application 1.0 0013 import Keysmith.Models 1.0 as Models 0014 0015 Kirigami.SwipeListItem { 0016 /* 0017 * WARNING: AccountEntryViewBase is a derivative of SwipeListItem and SwipeListem instances *must* be 0018 * called `listItem`. This took *way* too long to figure out. If you change it, things will break for example the 0019 * flood fill effect when pressing a list entry on Android. 0020 */ 0021 id: listItem 0022 0023 signal actionTriggered 0024 property Models.Account account: null 0025 property bool alive: account !== null 0026 property bool tokenAvailable: alive && account.token && account.token.length > 0 0027 property bool highlightActive: listItem.pressed || listItem.checked 0028 property color labelColor: highlightActive ? listItem.activeTextColor : listItem.textColor 0029 0030 visible: alive 0031 enabled: alive 0032 0033 readonly property Component details: FormCard.FormCardPage { 0034 title: i18nc("Details dialog title: %1 is the name of the account", "Details of account: %1", account.name) 0035 0036 topPadding: Kirigami.Units.gridUnit 0037 bottomPadding: Kirigami.Units.gridUnit 0038 0039 FormCard.FormCard { 0040 FormCard.FormTextDelegate { 0041 text: i18n("Name:") 0042 description: account.name 0043 } 0044 0045 FormCard.FormDelegateSeparator {} 0046 0047 FormCard.FormTextDelegate { 0048 text: i18n("Issuer:") 0049 description: account.issuer 0050 } 0051 0052 FormCard.FormDelegateSeparator {} 0053 0054 FormCard.FormTextDelegate { 0055 text: i18n("Mode:") 0056 description: account.isHotp ? i18nc("Mode of 2fa", "HOTP") : i18nc("Mode of 2fa", "TOTP") 0057 } 0058 0059 FormCard.FormDelegateSeparator {} 0060 0061 FormCard.FormTextDelegate { 0062 text: i18n("Epoch:") 0063 description: account.epoch 0064 } 0065 0066 FormCard.FormDelegateSeparator {} 0067 0068 FormCard.FormTextDelegate { 0069 text: i18n("Time Step:") 0070 description: account.timeStep 0071 } 0072 0073 FormCard.FormDelegateSeparator {} 0074 0075 FormCard.FormTextDelegate { 0076 text: i18n("Offset:") 0077 description: account.offset 0078 } 0079 0080 FormCard.FormDelegateSeparator {} 0081 0082 FormCard.FormTextDelegate { 0083 text: i18n("Token Length:") 0084 description: account.tokenLength 0085 } 0086 0087 FormCard.FormDelegateSeparator {} 0088 0089 FormCard.FormTextDelegate { 0090 text: i18n("Hash:") 0091 description: account.hash 0092 } 0093 } 0094 } 0095 0096 readonly property Kirigami.OverlaySheet sheet: Kirigami.OverlaySheet { 0097 visible: false 0098 header: Kirigami.Heading { 0099 text: i18nc("Confirm dialog title: %1 is the name of the account to remove", "Removing account: %1", account.name) 0100 } 0101 ColumnLayout { 0102 spacing: Kirigami.Units.largeSpacing * 5 0103 Controls.Label { 0104 Layout.fillWidth: true 0105 wrapMode: Text.WordWrap 0106 text: i18n("<p><ul><li>Account name: %1</li><li>Account issuer: %2</li></ul></p><p>Removing this account from Keysmith will not disable two-factor authentication (2FA). Make sure you can still access your account without using Keysmith before proceeding:</p><ul><li>Make sure you have another 2FA app set up for your account, or:</li><li>Make sure you have recovery codes for your account, or:</li><li>Disable two-factor authentication on your account</li></ul>", account.name, account.issuer) 0107 } 0108 } 0109 footer: RowLayout { 0110 Controls.Button { 0111 icon.name: "edit-undo" 0112 text: i18nc("Button cancelling account removal", "Cancel") 0113 onClicked: sheet.close(); 0114 } 0115 Rectangle { 0116 color: "transparent" 0117 Layout.fillWidth: true 0118 } 0119 Controls.Button { 0120 icon.name: "edit-delete" 0121 text: i18nc("Button confirming account removal", "Delete Account") 0122 enabled: alive 0123 onClicked: { 0124 alive = false; 0125 account.remove(); 0126 sheet.close(); 0127 } 0128 } 0129 } 0130 } 0131 0132 onClicked: { 0133 // TODO convert to C++ helper, have proper logging? 0134 actionTriggered(); 0135 if (tokenAvailable) { 0136 Keysmith.copyToClipboard(account.token); 0137 applicationWindow().showPassiveNotification(i18nc("Notification shown in a passive notification", "Token copied to clipboard!")) 0138 } 0139 // TODO warn if not 0140 } 0141 }