aboutsummaryrefslogtreecommitdiffstats
path: root/demo/Main.qml
blob: 02bc31e1d4a2cd3ff9055fb1010fabfb382e6869 (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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Main.qml — Demo app for Bobink library.
// Connects to an OPC UA server, then pushes NodePage for node interaction.
pragma ComponentBehavior: Bound

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

ApplicationWindow {
    id: root

    height: 900
    title: "Bobink Demo"
    visible: true
    width: 800

    Connections {
        function onCertificateTrustRequested(certInfo) {
            certTrustDialog.certInfo = certInfo;
            certTrustDialog.open();
        }

        function onConnectedChanged() {
            debugConsole.appendLog("Connected: " + Bobink.connected);
            if (Bobink.connected) {
                connectionPage.autoConnectFailed = false;
                Bobink.stopDiscovery();
                stack.push("NodePage.qml", {
                               stackRef: stack,
                               pageNumber: 1
                           });
            } else {
                stack.pop(null);
            }
        }

        function onConnectionError(message) {
            debugConsole.appendLog("Connection error: " + message);
            connectionPage.autoConnectFailed = true;
            certTrustDialog.close();
            keyPasswordDialog.close();
        }

        function onDiscoveringChanged() {
            debugConsole.appendLog("Discovering: " + Bobink.discovering);
        }

        function onPrivateKeyPasswordRequired(keyFilePath,
                                              previousTryWasInvalid) {
            keyPasswordDialog.keyFilePath = keyFilePath;
            keyPasswordDialog.previousTryWasInvalid = previousTryWasInvalid;
            keyPasswordDialog.open();
        }

        function onServersChanged() {
            debugConsole.appendLog("Discovered server list updated");
        }

        function onStatusMessage(message) {
            debugConsole.appendLog(message);
        }

        target: Bobink
    }

    CertTrustDialog {
        id: certTrustDialog

    }

    KeyPasswordDialog {
        id: keyPasswordDialog

    }

    ColumnLayout {
        anchors.fill: parent
        spacing: 0

        StackView {
            id: stack

            Layout.fillHeight: true
            Layout.fillWidth: true

            initialItem: ConnectionPage {
                id: connectionPage

            }

            Connections {
                function onLogRequested(message) {
                    debugConsole.appendLog(message);
                }

                ignoreUnknownSignals: true
                target: stack.currentItem
            }
        }

        DebugConsole {
            id: debugConsole

            Layout.fillWidth: true
            Layout.preferredHeight: 120
        }
    }
}