2024-02-09 11:31:37 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.12
|
2024-02-21 17:01:28 +00:00
|
|
|
import QtQml.Models 2.14
|
2024-02-09 11:31:37 +00:00
|
|
|
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.controls 1.0
|
|
|
|
import shared.stores 1.0
|
|
|
|
import shared.views 1.0
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
2024-03-14 18:24:38 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2024-02-21 17:01:28 +00:00
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2024-02-09 11:31:37 +00:00
|
|
|
|
|
|
|
import AppLayouts.Profile.popups 1.0
|
|
|
|
|
|
|
|
SettingsContentBase {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var privacyStore
|
2024-02-21 17:01:28 +00:00
|
|
|
|
|
|
|
readonly property bool biometricsEnabled: localAccountSettings.storeToKeychainValue === Constants.keychain.storedValue.store
|
|
|
|
|
2024-03-15 12:13:35 +00:00
|
|
|
readonly property Item biometricsPopup: titleRowComponentLoader.item
|
2024-02-21 17:01:28 +00:00
|
|
|
readonly property Connections privacyStoreConnections: Connections {
|
|
|
|
target: Qt.platform.os === Constants.mac ? root.privacyStore.privacyModule : null
|
|
|
|
|
|
|
|
function onStoreToKeychainError(errorDescription: string) {
|
2024-03-15 12:13:35 +00:00
|
|
|
biometricsPopup.popupItem.close();
|
|
|
|
if (biometricsPopup.switchItem.requestForEnabling) {
|
|
|
|
Global.displayToastMessage(qsTr("Failed to enable biometric login and transaction authentication for this device"),
|
|
|
|
errorDescription, "warning", false, Constants.ephemeralNotificationType.danger, "")
|
|
|
|
} else {
|
|
|
|
Global.displayToastMessage(qsTr("Failed to disable biometric login and transaction authentication for this device"),
|
|
|
|
errorDescription, "warning", false, Constants.ephemeralNotificationType.danger, "")
|
|
|
|
}
|
2024-02-21 17:01:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onStoreToKeychainSuccess() {
|
2024-03-15 12:13:35 +00:00
|
|
|
biometricsPopup.popupItem.close();
|
|
|
|
if (biometricsPopup.switchItem.requestForEnabling) {
|
|
|
|
Global.displayToastMessage(qsTr("Biometric login and transaction authentication enabled for this device"),
|
|
|
|
"", "checkmark-circle", false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
} else {
|
|
|
|
Global.displayToastMessage(qsTr("Biometric login and transaction authentication disabled for this device"),
|
|
|
|
"", "checkmark-circle", false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
}
|
2024-02-21 17:01:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-09 11:31:37 +00:00
|
|
|
property var passwordStrengthScoreFunction: function () {}
|
|
|
|
|
2024-02-21 17:01:28 +00:00
|
|
|
titleRowComponentLoader.sourceComponent: Item {
|
|
|
|
implicitWidth: 226
|
|
|
|
implicitHeight: 38
|
|
|
|
visible: (Qt.platform.os === Constants.mac)
|
2024-03-14 19:04:15 +00:00
|
|
|
|
|
|
|
property StatusSwitch switchItem: biometricsSwitch
|
2024-03-15 12:13:35 +00:00
|
|
|
property StatusDialog popupItem: enableBiometricsPopup
|
|
|
|
|
2024-02-21 17:01:28 +00:00
|
|
|
StatusSwitch {
|
|
|
|
id: biometricsSwitch
|
2024-03-14 19:04:15 +00:00
|
|
|
|
2024-02-21 17:01:28 +00:00
|
|
|
LayoutMirroring.enabled: true
|
|
|
|
LayoutMirroring.childrenInherit: true
|
2024-03-14 19:04:15 +00:00
|
|
|
|
2024-02-21 17:01:28 +00:00
|
|
|
text: qsTr("Enable biometrics")
|
2024-03-14 18:24:38 +00:00
|
|
|
textColor: Theme.palette.baseColor1
|
2024-03-14 19:04:15 +00:00
|
|
|
|
2024-03-15 12:13:35 +00:00
|
|
|
property bool requestForEnabling: false
|
2024-03-14 19:04:15 +00:00
|
|
|
|
2024-02-21 17:01:28 +00:00
|
|
|
checked: root.biometricsEnabled
|
2024-03-15 12:13:35 +00:00
|
|
|
onReleased: {
|
2024-02-21 17:01:28 +00:00
|
|
|
enableBiometricsPopup.open();
|
|
|
|
}
|
|
|
|
StatusToolTip {
|
|
|
|
x: 15
|
|
|
|
visible: (!root.checked && biometricsSwitch.hovered)
|
|
|
|
text: qsTr("Biometric login and transaction authentication")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusDialog {
|
|
|
|
id: enableBiometricsPopup
|
|
|
|
width: 480
|
|
|
|
title: biometricsSwitch.checked ? qsTr("Enable biometrics") : qsTr("Disable biometrics")
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: Style.current.padding
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
text: biometricsSwitch.checked ? qsTr("Do you want to enable biometrics for login and transaction authentication?") :
|
|
|
|
qsTr("Are you sure you want to disable biometrics for login and transaction authentication?")
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: StatusDialogFooter {
|
|
|
|
rightButtons: ObjectModel {
|
|
|
|
StatusFlatButton {
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
onClicked: {
|
|
|
|
enableBiometricsPopup.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
text: biometricsSwitch.checked ? qsTr("Yes, enable biometrics") : qsTr("Yes, disable biometrics")
|
|
|
|
onClicked: {
|
|
|
|
if (biometricsSwitch.checked && !biometricsSwitch.biometricsEnabled) {
|
2024-03-15 12:13:35 +00:00
|
|
|
biometricsSwitch.requestForEnabling = true;
|
2024-02-21 17:01:28 +00:00
|
|
|
root.privacyStore.tryStoreToKeyChain();
|
|
|
|
} else if (!biometricsSwitch.checked) {
|
2024-03-15 12:13:35 +00:00
|
|
|
biometricsSwitch.requestForEnabling = false;
|
2024-02-21 17:01:28 +00:00
|
|
|
root.privacyStore.tryRemoveFromKeyChain();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
biometricsSwitch.checked = Qt.binding(() => { return root.biometricsEnabled });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-02-09 11:31:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
PasswordView {
|
|
|
|
id: choosePasswordForm
|
|
|
|
|
|
|
|
width: 507
|
|
|
|
height: 660
|
|
|
|
|
|
|
|
createNewPsw: false
|
2024-03-14 18:24:38 +00:00
|
|
|
title: qsTr("Change your password")
|
2024-02-09 11:31:37 +00:00
|
|
|
titleSize: 17
|
|
|
|
contentAlignment: Qt.AlignLeft
|
|
|
|
|
2024-03-14 18:24:38 +00:00
|
|
|
highSizeIntro: true
|
|
|
|
|
2024-02-09 11:31:37 +00:00
|
|
|
passwordStrengthScoreFunction: root.passwordStrengthScoreFunction
|
|
|
|
onReadyChanged: {
|
|
|
|
submitBtn.enabled = ready
|
|
|
|
}
|
|
|
|
|
|
|
|
onReturnPressed: {
|
|
|
|
if (ready) {
|
|
|
|
confirmPasswordChangePopup.open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-14 18:24:38 +00:00
|
|
|
StatusModalDivider {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.bottomMargin: 20
|
|
|
|
}
|
|
|
|
|
2024-02-09 11:31:37 +00:00
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
2024-05-02 10:43:37 +00:00
|
|
|
StatusFlatButton {
|
2024-02-09 11:31:37 +00:00
|
|
|
text: qsTr("Clear & cancel")
|
2024-05-02 10:43:37 +00:00
|
|
|
onClicked: choosePasswordForm.reset()
|
2024-02-09 11:31:37 +00:00
|
|
|
}
|
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
StatusButton {
|
|
|
|
id: submitBtn
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
objectName: "changePasswordModalSubmitButton"
|
|
|
|
text: qsTr("Change password")
|
|
|
|
enabled: choosePasswordForm.ready
|
|
|
|
onClicked: { confirmPasswordChangePopup.open(); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfirmChangePasswordModal {
|
|
|
|
id: confirmPasswordChangePopup
|
|
|
|
onChangePasswordRequested: {
|
|
|
|
root.privacyStore.changePassword(choosePasswordForm.currentPswText, choosePasswordForm.newPswText);
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.privacyStore.privacyModule
|
|
|
|
function onPasswordChanged(success: bool, errorMsg: string) {
|
|
|
|
if (success) {
|
|
|
|
confirmPasswordChangePopup.passwordSuccessfulyChanged()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
choosePasswordForm.reset()
|
|
|
|
choosePasswordForm.errorMsgText = errorMsg
|
|
|
|
confirmPasswordChangePopup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|