Ubuntu Pastebin

Paste from Christopher Lee at Wed, 23 Sep 2015 02:10:33 +0000

Download as text
 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Components.Popups 0.1

Item {
    id: ssoOAuthDialog

    property alias dialogComponent: component

    function signOnAttempt(email, pass, otp) {
        dlgloading = true;
        py.call('...', [email, pass, otp], function(response) {
            if(response.code == 500) {
                //...
            }
            else if(response.code == 200) {
                PopupUtils.close(dialogComponent.dlg);
            } else {
                // ...
            }
        });
    }

    Component {
        id: component
        Dialog {
            id: dlg
            objectName: "dialog"
            modal: true // Screen behind the dialog will be greyed-out
            title: "Login credentials for login.ubuntu.com"

            Label {
                id: errorMessage
            }

            TextField {
                id: emailBox
                // ...
            }

            TextField {
                id: passwordBox
                // ...
            }

            TextField {
                id: otpBox
                // ...
            }

            Button {
                text: i18n.tr("Ok")
                objectName: "okButton"
                onClicked: {
                    signOnAttempt(emailBox.text, passwordBox.text, otpBox.text);
                }
            }

            Button {
                text: i18n.tr("Cancel")
                objectName: "cancelButton"
                onClicked: {
                    PopupUtils.close(dlg);
                    cancelClicked();
                }
            }

            Component.onCompleted: {
                emailBox.forceActiveFocus();
            }

            Component.onDestruction: {
                emailBox.text = "";
                passwordBox.text = "";
                otpBox.text = "";
            }

        }

    }
}
Download as text