From e5fcb4cf9b148105363f2415baba9999845d6a3b Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Mon, 11 Apr 2022 13:39:15 +0200 Subject: [PATCH] fix(@desktop/profile): settings to store pass in keychain remain the same Fixes #5464 --- .../Onboarding/shared/CreatePasswordModal.qml | 6 ++- .../popups/StoreToKeychainSelectionModal.qml | 53 +++++++++++++++++++ .../Profile/stores/PrivacyStore.qml | 4 ++ ui/app/mainui/AppMain.qml | 5 -- ui/imports/utils/Global.qml | 5 +- 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/ui/app/AppLayouts/Onboarding/shared/CreatePasswordModal.qml b/ui/app/AppLayouts/Onboarding/shared/CreatePasswordModal.qml index 302e7591bb..9a1c786698 100644 --- a/ui/app/AppLayouts/Onboarding/shared/CreatePasswordModal.qml +++ b/ui/app/AppLayouts/Onboarding/shared/CreatePasswordModal.qml @@ -22,6 +22,8 @@ ModalPopup { property string repeatPasswordValidationError: "" property bool storingPasswordModal: false + signal offerToStorePassword(string password, bool runStoreToKeychainPopup) + id: popup title: storingPasswordModal? qsTr("Store password") : @@ -171,7 +173,7 @@ ModalPopup { passwordValidationError = qsTr("Incorrect password") } else { - //Global.applicationWindow.prepareForStoring(repeatPasswordField.text, true) + popup.offerToStorePassword(repeatPasswordField.text, true) popup.close() } } @@ -179,7 +181,7 @@ ModalPopup { { loading = true OnboardingStore.onboardingModuleInst.storeSelectedAccountAndLogin(repeatPasswordField.text); - //Global.applicationWindow.prepareForStoring(repeatPasswordField.text, false) + popup.offerToStorePassword(repeatPasswordField.text, false) } } } diff --git a/ui/app/AppLayouts/Profile/popups/StoreToKeychainSelectionModal.qml b/ui/app/AppLayouts/Profile/popups/StoreToKeychainSelectionModal.qml index 84ddb7f27e..d75fb3d235 100644 --- a/ui/app/AppLayouts/Profile/popups/StoreToKeychainSelectionModal.qml +++ b/ui/app/AppLayouts/Profile/popups/StoreToKeychainSelectionModal.qml @@ -30,6 +30,14 @@ ModalPopup { neverBtn.checked = true } + function offerToStorePassword(password, runStoreToKeychainPopup) { + if(Qt.platform.os == "osx") + { + if(runStoreToKeychainPopup) + Global.openPopup(storeToKeychainConfirmationPopupComponent, { password: password }) + } + } + Column { anchors.top: parent.top anchors.bottom: parent.bottom @@ -103,6 +111,51 @@ ModalPopup { privacyStore: popup.privacyStore storingPasswordModal: true height: 350 + + onOfferToStorePassword: { + popup.offerToStorePassword(password, runStoreToKeychainPopup) + } + } + } + + Component { + id: storeToKeychainConfirmationPopupComponent + ConfirmationDialog { + id: storeToKeychainConfirmationPopup + property string password: "" + height: 200 + confirmationText: qsTr("Would you like to store password to the Keychain?") + showRejectButton: true + showCancelButton: true + confirmButtonLabel: qsTr("Store") + rejectButtonLabel: qsTr("Not now") + cancelButtonLabel: qsTr("Never") + + onClosed: { + destroy() + } + + function finish() + { + password = "" + storeToKeychainConfirmationPopup.close() + } + + onConfirmButtonClicked: { + localAccountSettings.storeToKeychainValue = Constants.storeToKeychainValueStore + root.privacyStore.storeToKeyChain(password) + finish() + } + + onRejectButtonClicked: { + localAccountSettings.storeToKeychainValue = Constants.storeToKeychainValueNotNow + finish() + } + + onCancelButtonClicked: { + localAccountSettings.storeToKeychainValue = Constants.storeToKeychainValueNever + finish() + } } } } diff --git a/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml b/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml index e3c17320a8..4a61b1fd92 100644 --- a/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml +++ b/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml @@ -28,4 +28,8 @@ QtObject { function validatePassword(password) { return root.privacyModule.validatePassword(password) } + + function storeToKeyChain(pass) { + mainModule.storePassword(pass); + } } diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index a7f4979c16..a76644cfb4 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -69,11 +69,6 @@ Item { onOpenChooseBrowserPopup: { Global.openPopup(chooseBrowserPopupComponent, {link: link}); } - onOpenPopupRequested: { - const popup = popupComponent.createObject(appMain, params); - popup.open(); - return popup; - } onOpenDownloadModalRequested: { const downloadPage = downloadPageComponent.createObject(appMain, { diff --git a/ui/imports/utils/Global.qml b/ui/imports/utils/Global.qml index f044968753..d629c5e4cf 100644 --- a/ui/imports/utils/Global.qml +++ b/ui/imports/utils/Global.qml @@ -23,7 +23,6 @@ QtObject { signal openImagePopup(var image, var contextMenu) signal openLinkInBrowser(string link) signal openChooseBrowserPopup(string link) - signal openPopupRequested(var popupComponent, var params) signal openDownloadModalRequested() signal settingsLoaded() signal openBackUpSeedPopup() @@ -36,7 +35,9 @@ QtObject { } function openPopup(popupComponent, params = {}) { - root.openPopupRequested(popupComponent, params); + const popup = popupComponent.createObject(root.appMain, params); + popup.open(); + return popup; } function openDownloadModal(){