From 2c8542769e5cf351ef6d484b8785b573a51b2274 Mon Sep 17 00:00:00 2001 From: Amin Bandali <amin.bandali@savoirfairelinux.com> Date: Wed, 6 Apr 2022 14:40:28 -0400 Subject: [PATCH] deleteaccountdialog: disable delete button when it's clicked This is so that the user cannot accidentally click Delete again and delete another account. Also, show a BusyIndicator spinning wheel when Delete is clicked, so as to give the user visual feedback that something is happening. Also, set the account Id, best name, and whether it's a SIP account from outside when opening the dialog, so that they don't automatically change when the next account is selected if the user confirms the deletion of the current account. GitLab: #711 Change-Id: I4e93deb4f74257387884edc62d76a5b3cb58d845 --- src/commoncomponents/DeleteAccountDialog.qml | 36 ++++++++++++------- .../components/CurrentAccountSettings.qml | 3 ++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/commoncomponents/DeleteAccountDialog.qml b/src/commoncomponents/DeleteAccountDialog.qml index 30e847b22..abf15a83a 100644 --- a/src/commoncomponents/DeleteAccountDialog.qml +++ b/src/commoncomponents/DeleteAccountDialog.qml @@ -24,19 +24,12 @@ import net.jami.Models 1.1 import net.jami.Adapters 1.1 import net.jami.Constants 1.1 -import "../commoncomponents" - BaseModalDialog { id: root - property bool isSIP: { - switch (CurrentAccount.type) { - case Profile.Type.SIP: - return true; - default: - return false; - } - } + property bool isSIP: false + property string bestName: "" + property string accountId: "" signal accepted @@ -74,7 +67,7 @@ BaseModalDialog { JamiTheme.preferredMarginSize * 2 color: JamiTheme.textColor - text: CurrentAccount.bestName + text: bestName font.pointSize: JamiTheme.textFontSize font.kerning: true @@ -93,7 +86,7 @@ BaseModalDialog { JamiTheme.preferredMarginSize * 2 color: JamiTheme.textColor - text: CurrentAccount.uri + text: accountId font.pointSize: JamiTheme.textFontSize font.kerning: true @@ -144,10 +137,27 @@ BaseModalDialog { text: JamiStrings.optionDelete + Connections { + target: root + function onClosed() { btnDelete.enabled = true } + } + onClicked: { + btnDelete.enabled = false + busyInd.running = true AccountAdapter.deleteCurrentAccount() - accepted() close() + accepted() + } + } + + BusyIndicator { + id: busyInd + running: false + + Connections { + target: root + function onClosed() { busyInd.running = false } } } diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml index 6323ed378..28c455a85 100644 --- a/src/settingsview/components/CurrentAccountSettings.qml +++ b/src/settingsview/components/CurrentAccountSettings.qml @@ -58,6 +58,9 @@ Rectangle { } function delAccountSlot() { + deleteAccountDialog.isSIP = CurrentAccount.type === Profile.Type.SIP + deleteAccountDialog.bestName = CurrentAccount.bestName + deleteAccountDialog.accountId = CurrentAccount.uri deleteAccountDialog.open() } -- GitLab