aboutsummaryrefslogtreecommitdiffstats
path: root/demo/KeyPasswordDialog.qml
blob: 4bf094cbaf984b64a953d7e0c4969488323033e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// KeyPasswordDialog.qml — Modal dialog for encrypted private-key passphrase.

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Bobink

Dialog {
    id: keyPasswordDialog

    property string keyFilePath
    property bool previousTryWasInvalid: false

    anchors.centerIn: parent
    implicitWidth: 400
    modal: true
    standardButtons: Dialog.Ok | Dialog.Cancel
    title: "Private Key Password"

    onAccepted: Bobink.provideKeyPassword(passwordField.text)
    onOpened: {
        passwordField.text = "";
        passwordField.forceActiveFocus();
    }
    onRejected: Bobink.cancelKeyPassword()

    ColumnLayout {
        width: parent.width

        Label {
            Layout.fillWidth: true
            text: "Enter the password for:\n" + keyPasswordDialog.keyFilePath
            wrapMode: Text.Wrap
        }

        Label {
            Layout.fillWidth: true
            color: "red"
            text: "Invalid password, please try again."
            visible: keyPasswordDialog.previousTryWasInvalid
        }

        TextField {
            id: passwordField

            Layout.fillWidth: true
            echoMode: TextInput.Password
            placeholderText: "Password"

            onAccepted: keyPasswordDialog.accept()
        }
    }
}