User: Support change password

pull/30/head
reionwong 4 years ago
parent 1bf4149054
commit ca657cd018

@ -43,8 +43,8 @@ ItemPage {
onUserAdded: {
if (account.userName === userNameField.text) {
account.passwordMode = UserAccount.RegularPasswordMode;
account.setPassword(Password.cryptPassword(passwordField.text));
account.passwordMode = UserAccount.RegularPasswordMode
account.setPassword(Password.cryptPassword(passwordField.text))
}
}
}
@ -195,6 +195,7 @@ ItemPage {
id: _addUserButton
text: qsTr("Add user")
Layout.fillWidth: true
visible: !newUserItem.visible
onClicked: {
newUserItem.visible = true
userNameField.forceActiveFocus()

@ -193,11 +193,87 @@ RoundedItem {
}
}
// Change password
HorizontalDivider {
visible: changePasswdLabel.visible
}
Label {
id: changePasswdLabel
visible: false
text: qsTr("Change password")
}
GridLayout {
id: changePasswdLayout
visible: false
columns: 2
columnSpacing: FishUI.Units.largeSpacing * 2
rowSpacing: FishUI.Units.smallSpacing * 2
Label {
text: qsTr("Password")
Layout.alignment: Qt.AlignRight
}
TextField {
id: passwordField
placeholderText: qsTr("Password")
echoMode: TextField.Password
Layout.fillWidth: true
selectByMouse: true
}
Label {
text: qsTr("Verify password")
Layout.alignment: Qt.AlignRight
}
TextField {
id: verifyPasswordField
placeholderText: qsTr("Verify password")
echoMode: TextField.Password
Layout.fillWidth: true
selectByMouse: true
}
}
RowLayout {
id: changePasswdFooterLayout
spacing: FishUI.Units.largeSpacing
visible: false
Button {
text: qsTr("Cancel")
onClicked: hideChangePasswordItem()
Layout.fillWidth: true
}
Button {
text: qsTr("Change password")
enabled: passwordField.text != "" &&
passwordField.text == verifyPasswordField.text
Layout.fillWidth: true
flat: true
onClicked: {
currentUser.setPassword(Password.cryptPassword(passwordField.text));
hideChangePasswordItem()
}
}
}
HorizontalDivider {
visible: changePasswdLabel.visible
}
// Change password end.
StandardButton {
text: qsTr("Change password")
// onClicked: accountsManager.deleteUser(userId, true)
onClicked: showChangePasswordItem()
backgroundColor: FishUI.Theme.darkMode ? "#363636" : FishUI.Theme.backgroundColor
Layout.fillWidth: true
visible: !changePasswdLabel.visible
}
StandardButton {
@ -209,4 +285,21 @@ RoundedItem {
}
}
}
function showChangePasswordItem() {
changePasswdLabel.visible = true
changePasswdLayout.visible = true
changePasswdFooterLayout.visible = true
passwordField.forceActiveFocus()
}
function hideChangePasswordItem() {
passwordField.clear()
verifyPasswordField.clear()
changePasswdLabel.visible = false
changePasswdLayout.visible = false
changePasswdFooterLayout.visible = false
}
}

@ -761,12 +761,31 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="197"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="204"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="253"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="272"/>
<source>Change password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="204"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="215"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="221"/>
<source>Password</source>
<translation type="unfinished">Password</translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="228"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="234"/>
<source>Verify password</source>
<translation type="unfinished">Verify password</translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="247"/>
<source>Cancel</source>
<translation type="unfinished">Cancel</translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="280"/>
<source>Delete this user</source>
<translation type="unfinished"></translation>
</message>

@ -761,12 +761,31 @@
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="197"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="204"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="253"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="272"/>
<source>Change password</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="204"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="215"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="221"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="228"/>
<location filename="../src/qml/User/UserDelegateItem.qml" line="234"/>
<source>Verify password</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="247"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/User/UserDelegateItem.qml" line="280"/>
<source>Delete this user</source>
<translation></translation>
</message>

Loading…
Cancel
Save