From dca55eee4b8d1c624348b186b64ad2b466e0eeef Mon Sep 17 00:00:00 2001 From: Johan Ouwerkerk Date: Mon, 20 Apr 2020 20:19:12 +0200 Subject: [PATCH] Ask for confirmation before removing accounts This change provides a modal dialog to prompt for confirmation when the user clicks the delete button. --- src/CMakeLists.txt | 1 + src/contents/ui/AccountEntryView.qml | 50 +++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7cdc8d1..d17baba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,6 +32,7 @@ if(ANDROID) kirigami_package_breeze_icons(ICONS go-next edit-delete + edit-undo list-add answer-correct ) diff --git a/src/contents/ui/AccountEntryView.qml b/src/contents/ui/AccountEntryView.qml index ea0e842..0011c16 100644 --- a/src/contents/ui/AccountEntryView.qml +++ b/src/contents/ui/AccountEntryView.qml @@ -35,17 +35,61 @@ Kirigami.SwipeListItem { property Kirigami.Action deleteAccount : Kirigami.Action { iconName: "edit-delete" - text: "Delete account" + text: i18nc("Button for removal of a single account", "Delete account") onTriggered: { // TODO convert to C++ helper, have proper logging? if (alive && account) { - alive = false; - account.remove(); + root.sheet.open(); } // TODO warn if not } } + property Kirigami.OverlaySheet sheet: Kirigami.OverlaySheet { + sheetOpen: false + header: Kirigami.Heading { + text: i18nc("Confirm dialog title: %1 is the name of the account to remove", "Removing account: %1", account ? account.name : "") + } + ColumnLayout { + spacing: Kirigami.Units.largeSpacing * 5 + Controls.Label { + Layout.fillWidth: true + wrapMode: Text.WordWrap + text: i18n("

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:

") + } + } + footer: RowLayout { + Controls.Button { + action: Kirigami.Action { + iconName: "edit-undo" + text: i18nc("Button cancelling account removal", "Cancel") + onTriggered: { + sheet.close(); + } + } + } + Rectangle { + color: "transparent" + Layout.fillWidth: true + } + Controls.Button { + action: Kirigami.Action { + iconName: "edit-delete" + text: i18nc("Button confirming account removal", "Delete account") + onTriggered: { + // TODO convert to C++ helper, have proper logging? + if (alive && account) { + alive = false; + account.remove(); + } + // TODO warn if not + sheet.close(); + } + } + } + } + } + actions: account && account.isHotp ? [deleteAccount, advanceCounter] : [deleteAccount] contentItem: ColumnLayout {