Warning, /sdk/cutehmi/extensions/CuteHMI/LockScreen.2/ChangePasswordWizard.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.7
0002 import QtQuick.Controls 2.3
0003 import QtQuick.Layouts 1.3
0004 
0005 import CuteHMI.LockScreen 2.0
0006 
0007 Item {
0008         id: root
0009 
0010         readonly property string initialState: secret.byteLength !== 0 ? "OLD_PASSWORD" : "NEW_PASSWORD"
0011 
0012         property var secret: new ArrayBuffer
0013 
0014         property LockItem lockItem
0015 
0016         property int spacing: 10
0017 
0018         property int padding: 10
0019 
0020         signal accepted()
0021 
0022         signal rejected()
0023 
0024         state: initialState
0025 
0026         states: [
0027                 State {
0028                         name: "OLD_PASSWORD"
0029 
0030                         PropertyChanges {
0031                                 target: label
0032                                 text: qsTr('Please enter old password.')
0033                         }
0034                 },
0035 
0036                 State {
0037                         name: "NEW_PASSWORD"
0038 
0039                         PropertyChanges {
0040                                 target: label
0041                                 text: qsTr('Please enter new password.')
0042                         }
0043 
0044                         PropertyChanges {
0045                                 restoreEntryValues: false
0046                                 target: lockItem
0047                                 secret: new ArrayBuffer
0048                         }
0049                 },
0050 
0051                 State {
0052                         name: "RETYPE_PASSWORD"
0053 
0054                         PropertyChanges {
0055                                 target: label
0056                                 text: qsTr('Please re-enter the passowrd.')
0057                         }
0058 
0059                         PropertyChanges {
0060                                 target: acceptButton
0061                                 text: qsTr('Apply')
0062                         }
0063                 }
0064         ]
0065 
0066         onSecretChanged: lockItem.secret = secret
0067 
0068         ColumnLayout {
0069                 anchors.fill: parent
0070                 anchors.margins: root.padding
0071 
0072                 spacing: root.spacing
0073 
0074                 RowLayout {
0075                         id: controlsLayout
0076 
0077                         spacing: root.spacing
0078 
0079                         Button {
0080                                 id: cancelButton
0081 
0082                                 Layout.alignment: Qt.AlignLeft
0083 
0084                                 text: qsTr("Cancel")
0085 
0086                                 onClicked: {
0087                                         lockItem.passwordInput.reset()
0088                                         root.state = root.initialState
0089                                         rejected()
0090                                 }
0091                         }
0092 
0093                         Frame {
0094                                 Layout.alignment: Qt.AlignHCenter
0095                                 Layout.fillWidth: true
0096 
0097                                 Label {
0098                                         id: label
0099 
0100                                         anchors.centerIn: parent
0101                                 }
0102                         }
0103 
0104                         Button {
0105                                 id: acceptButton
0106 
0107                                 Layout.alignment: Qt.AlignRight
0108 
0109                                 text: qsTr("Next")
0110 
0111                                 onClicked: lockItem.passwordInput.accept()
0112                         }
0113                 }
0114 
0115                 Rectangle {
0116                         id: lockItemPlaceholder
0117 
0118                         Layout.fillWidth: true
0119                         Layout.fillHeight: true
0120 
0121                         color: palette.shadow
0122                 }
0123         }
0124 
0125         Binding {
0126                 target: root.lockItem
0127                 property: "parent"
0128                 value: lockItemPlaceholder
0129         }
0130 
0131         Connections {
0132                 target: lockItem.passwordInput
0133 
0134                 property string newPassword
0135 
0136                 function onAccepted() {
0137                         if (root.state === "OLD_PASSWORD") {
0138                                 if (root.lockItem.gatekeeper.authenticate())
0139                                         root.state = "NEW_PASSWORD"
0140                         } else if (root.state === "NEW_PASSWORD") {
0141                                 newPassword = root.lockItem.passwordInput.text
0142                                 if (newPassword !== "")
0143                                         root.lockItem.secret = root.lockItem.gatekeeper.makeSecret(newPassword)
0144                                 root.lockItem.passwordInput.reset()
0145                                 root.state = "RETYPE_PASSWORD"
0146                         } else if (root.state === "RETYPE_PASSWORD") {
0147                                 if (newPassword === root.lockItem.passwordInput.text)
0148                                         passwordChangedDialog.open()
0149                                 else
0150                                         passwordMismatchDialog.open()
0151                                 root.lockItem.passwordInput.reset()
0152                         }
0153                 }
0154         }
0155 
0156         Dialog {
0157                 id: passwordChangedDialog
0158 
0159                 anchors.centerIn: parent
0160 
0161                 modal: true
0162                 closePolicy: Popup.NoAutoClose
0163                 title: qsTr("Password Change")
0164                 standardButtons: Dialog.Ok
0165 
0166                 onAccepted: {
0167                         root.accepted()
0168                         root.state = root.initialState
0169                 }
0170 
0171                 Label {
0172                         anchors.centerIn: parent
0173 
0174                         text: qsTr("Password has been successfully changed!")
0175                 }
0176         }
0177 
0178         Dialog {
0179                 id: passwordMismatchDialog
0180 
0181                 anchors.centerIn: parent
0182 
0183                 modal: true
0184                 closePolicy: Popup.NoAutoClose
0185                 title: qsTr("Password Change")
0186                 standardButtons: Dialog.Ok
0187 
0188                 onAccepted: root.state = "NEW_PASSWORD"
0189 
0190                 Label {
0191                         anchors.centerIn: parent
0192 
0193                         text: qsTr('Passwords do not match. Please enter new password again.')
0194                 }
0195         }
0196 }
0197 
0198 //(c)WZMP: Copyright © 2018, Wojciech Zygmuntowicz, Michal Policht. All rights reserved.
0199 //(c)WZMP: This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0200 
0201 //(c)C: Copyright © 2021, Michał Policht <michal@policht.pl>. All rights reserved.
0202 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
0203 //(c)C: This file is a part of CuteHMI.
0204 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
0205 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
0206 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI.  If not, see <https://www.gnu.org/licenses/>.
0207 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
0208 //(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
0209 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
0210 //(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.