From a93ed35eee44227b7a005ad39bc95a280d80cf8b Mon Sep 17 00:00:00 2001 From: Jakub Date: Fri, 26 Aug 2022 15:01:18 +0200 Subject: [PATCH] GODT-1794: Add confirmation dialog and change wording --- internal/frontend/qml/Bridge_test.qml | 10 ++--- internal/frontend/qml/GeneralSettings.qml | 8 ++-- internal/frontend/qml/NotificationPopups.qml | 5 +++ .../qml/Notifications/Notifications.qml | 43 +++++++++++++++++++ internal/frontend/qt/qml_backend.go | 12 +++--- 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/internal/frontend/qml/Bridge_test.qml b/internal/frontend/qml/Bridge_test.qml index 72f3c959..35442b4c 100644 --- a/internal/frontend/qml/Bridge_test.qml +++ b/internal/frontend/qml/Bridge_test.qml @@ -674,7 +674,7 @@ Window { } RowLayout { Label {colorScheme: root.colorScheme; text: "All Mail disabled:"} - Toggle {colorScheme: root.colorScheme; checked: root.isAllMailDisabled; onClicked: root.isAllMailDisabled = !root.isAllMailDisabled} + Toggle {colorScheme: root.colorScheme; checked: root.isAllMailVisible; onClicked: root.isAllMailVisible = !root.isAllMailVisible} } RowLayout { Label {colorScheme: root.colorScheme; text: "Ports:"} @@ -815,10 +815,10 @@ Window { root.isDoHEnabled = makeItActive } - property bool isAllMailDisabled : false - function changeIsAllMailDisabled(isDisabled){ - console.debug("-> All Mail Disabled", isDisabled, root.isAllMailDisabled) - root.isAllMailDisabled = isDisabled + property bool isAllMailVisible : true + function changeIsAllMailVisible(isVisible){ + console.debug("-> All Mail Visible", isVisible, root.isAllMailVisible) + root.isAllMailVisible = isVisible } diff --git a/internal/frontend/qml/GeneralSettings.qml b/internal/frontend/qml/GeneralSettings.qml index fb370abd..b0ea78d7 100644 --- a/internal/frontend/qml/GeneralSettings.qml +++ b/internal/frontend/qml/GeneralSettings.qml @@ -160,11 +160,11 @@ SettingsView { id: allMail visible: root._isAdvancedShown colorScheme: root.colorScheme - text: qsTr("Disable All Mail") - description: qsTr("Choose not to list the All Mail folder in your local client.") + text: qsTr("Show All Mail") + description: qsTr("Choose to list the All Mail folder in your local client.") type: SettingsItem.Toggle - checked: root.backend.isAllMailDisabled - onClicked: root.backend.changeIsAllMailDisabled(!allMail.checked ) + checked: root.backend.isAllMailVisible + onClicked: root.notifications.askChangeAllMailVisibility(root.backend.isAllMailVisible) Layout.fillWidth: true } diff --git a/internal/frontend/qml/NotificationPopups.qml b/internal/frontend/qml/NotificationPopups.qml index 4c89a979..211ce858 100644 --- a/internal/frontend/qml/NotificationPopups.qml +++ b/internal/frontend/qml/NotificationPopups.qml @@ -110,6 +110,11 @@ Item { notification: root.notifications.resetBridge } + NotificationDialog { + colorScheme: root.colorScheme + notification: root.notifications.changeAllMailVisibility + } + NotificationDialog { colorScheme: root.colorScheme notification: root.notifications.deleteAccount diff --git a/internal/frontend/qml/Notifications/Notifications.qml b/internal/frontend/qml/Notifications/Notifications.qml index 980f9f1f..32370fad 100644 --- a/internal/frontend/qml/Notifications/Notifications.qml +++ b/internal/frontend/qml/Notifications/Notifications.qml @@ -34,6 +34,7 @@ QtObject { signal askDisableLocalCache() signal askEnableLocalCache(var path) signal askResetBridge() + signal askChangeAllMailVisibility(var isVisibleNow) signal askDeleteAccount(var user) enum Group { @@ -72,6 +73,7 @@ QtObject { root.disableLocalCache, root.enableLocalCache, root.resetBridge, + root.changeAllMailVisibility, root.deleteAccount, root.noKeychain, root.rebuildKeychain, @@ -840,6 +842,47 @@ QtObject { ] } + property Notification changeAllMailVisibility: Notification { + title: root.changeAllMailVisibility.isVisibleNow ? + qsTr("Hide All Mail folder?") : + qsTr("Show All Mail folder?") + brief: title + icon: "./icons/ic-info-circle-filled.svg" + description: qsTr("Switching between showing and hiding the All Mail folder will require you to restart your client.") + type: Notification.NotificationType.Info + group: Notifications.Group.Configuration | Notifications.Group.Dialogs + + property var isVisibleNow + + Connections { + target: root + onAskChangeAllMailVisibility: { + root.changeAllMailVisibility.isVisibleNow = isVisibleNow + root.changeAllMailVisibility.active = true + } + } + + action: [ + Action { + id: allMail_change + text: root.changeAllMailVisibility.isVisibleNow ? + qsTr("Hide All Mail folder") : + qsTr("Show All Mail folder") + onTriggered: { + root.backend.changeIsAllMailVisible(!root.changeAllMailVisibility.isVisibleNow) + root.changeAllMailVisibility.active = false + } + }, + Action { + id: allMail_cancel + text: qsTr("Cancel") + onTriggered: { + root.changeAllMailVisibility.active = false + } + } + ] + } + property Notification deleteAccount: Notification { title: qsTr("Remove this account?") brief: title diff --git a/internal/frontend/qt/qml_backend.go b/internal/frontend/qt/qml_backend.go index d0db4fe2..04d38be7 100644 --- a/internal/frontend/qt/qml_backend.go +++ b/internal/frontend/qt/qml_backend.go @@ -156,8 +156,8 @@ type QMLBackend struct { _ func(userID string) `signal:userChanged` - _ bool `property:"isAllMailDisabled"` - _ func(isDisabled bool) `slot:"changeIsAllMailDisabled"` + _ bool `property:"isAllMailVisible"` + _ func(isDisabled bool) `slot:"changeIsAllMailVisible"` } func (q *QMLBackend) setup(f *FrontendQt) { @@ -308,10 +308,10 @@ func (q *QMLBackend) setup(f *FrontendQt) { }() }) - q.SetIsAllMailDisabled(!f.bridge.IsAllMailVisible()) - q.ConnectChangeIsAllMailDisabled(func(isDisabled bool) { - f.bridge.SetIsAllMailVisible(!isDisabled) - f.qml.SetIsAllMailDisabled(isDisabled) + q.SetIsAllMailVisible(f.bridge.IsAllMailVisible()) + q.ConnectChangeIsAllMailVisible(func(isVisible bool) { + f.bridge.SetIsAllMailVisible(isVisible) + f.qml.SetIsAllMailVisible(isVisible) }) }