add check password
This commit is contained in:
@@ -14,7 +14,16 @@ Dialog {
|
||||
|
||||
property string action: "update"
|
||||
property string packageName: ""
|
||||
signal passwordEntered(string password)
|
||||
property bool checking: false
|
||||
property string errorText: ""
|
||||
signal passwordSubmitted(string password)
|
||||
|
||||
function submit() {
|
||||
if (root.checking || passwordField.text.length === 0) return;
|
||||
root.checking = true;
|
||||
root.errorText = "";
|
||||
root.passwordSubmitted(passwordField.text);
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: Theme.color1
|
||||
@@ -61,7 +70,16 @@ Dialog {
|
||||
border.color: passwordField.activeFocus ? Theme.color6 : Theme.color4
|
||||
}
|
||||
|
||||
onAccepted: if (okButton.enabled) root.accept()
|
||||
onAccepted: root.submit()
|
||||
}
|
||||
|
||||
Label {
|
||||
text: root.errorText
|
||||
visible: text.length > 0
|
||||
color: "#e78284"
|
||||
font.pixelSize: 12
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,13 +123,13 @@ Dialog {
|
||||
Button {
|
||||
id: okButton
|
||||
text: root.action === "install" ? "✓ Установить" : root.action === "remove" ? "✓ Удалить" : "✓ Обновить"
|
||||
enabled: passwordField.text.length > 0
|
||||
enabled: passwordField.text.length > 0 && !root.checking
|
||||
leftPadding: 14
|
||||
rightPadding: 14
|
||||
topPadding: 8
|
||||
bottomPadding: 8
|
||||
|
||||
onClicked: root.accept()
|
||||
onClicked: root.submit()
|
||||
|
||||
background: Rectangle {
|
||||
radius: 4
|
||||
@@ -130,7 +148,14 @@ Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
onOpened: passwordField.forceActiveFocus()
|
||||
onAccepted: root.passwordEntered(passwordField.text)
|
||||
onClosed: passwordField.text = ""
|
||||
onOpened: {
|
||||
root.checking = false
|
||||
root.errorText = ""
|
||||
passwordField.forceActiveFocus()
|
||||
}
|
||||
onClosed: {
|
||||
passwordField.text = ""
|
||||
root.checking = false
|
||||
root.errorText = ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user