summaryrefslogtreecommitdiffstats
path: root/demo/Main.qml
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-19 18:00:52 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-19 18:00:52 +0100
commite73fe498e86dbb20d74f8d6ca13b541642676b82 (patch)
tree572593fd880d10ae23544986116847271ee49f99 /demo/Main.qml
parent50c62c35463b62a3a7acebf9ebe22d44f1c6dca2 (diff)
downloadBobinkQtOpcUa-e73fe498e86dbb20d74f8d6ca13b541642676b82.tar.gz
BobinkQtOpcUa-e73fe498e86dbb20d74f8d6ca13b541642676b82.zip
Rename QML singleton to Bobink and simplify singleton lifecycle
Replace QML_ELEMENT with QML_NAMED_ELEMENT(Bobink) so QML references use `Bobink` instead of `BobinkClient`. Remove instance()/create() factory in favor of inline s_instance set in the constructor. Import BobinkPlugin statically in demo, link demo to BobinkQtOpcUaplugin, and make library link dependencies PUBLIC. Add .qtcreator to gitignore.
Diffstat (limited to 'demo/Main.qml')
-rw-r--r--demo/Main.qml191
1 files changed, 127 insertions, 64 deletions
diff --git a/demo/Main.qml b/demo/Main.qml
index 7b76fee..ef09b7d 100644
--- a/demo/Main.qml
+++ b/demo/Main.qml
@@ -18,15 +18,15 @@ ApplicationWindow {
property bool showPkiSettings: false
Connections {
- target: BobinkClient
+ target: Bobink
function onServersChanged() {
debugConsole.appendLog("Discovered server list updated");
}
function onConnectedChanged() {
- debugConsole.appendLog("Connected: " + BobinkClient.connected);
- if (BobinkClient.connected) {
+ debugConsole.appendLog("Connected: " + Bobink.connected);
+ if (Bobink.connected) {
root.autoConnectFailed = false;
- BobinkClient.stopDiscovery();
+ Bobink.stopDiscovery();
stack.push("NodePage.qml", {
stackRef: stack,
pageNumber: 1,
@@ -44,7 +44,7 @@ ApplicationWindow {
debugConsole.appendLog(message);
}
function onDiscoveringChanged() {
- debugConsole.appendLog("Discovering: " + BobinkClient.discovering);
+ debugConsole.appendLog("Discovering: " + Bobink.discovering);
}
function onCertificateTrustRequested(certInfo) {
certTrustDialog.certInfo = certInfo;
@@ -59,9 +59,11 @@ ApplicationWindow {
title: "Certificate Trust"
modal: true
standardButtons: Dialog.Yes | Dialog.No
- Label { text: certTrustDialog.certInfo }
- onAccepted: BobinkClient.acceptCertificate()
- onRejected: BobinkClient.rejectCertificate()
+ Label {
+ text: certTrustDialog.certInfo
+ }
+ onAccepted: Bobink.acceptCertificate()
+ onRejected: Bobink.rejectCertificate()
}
ColumnLayout {
@@ -75,8 +77,8 @@ ApplicationWindow {
initialItem: Page {
Component.onCompleted: {
- BobinkClient.discoveryUrl = discoveryUrlField.text;
- BobinkClient.startDiscovery();
+ Bobink.discoveryUrl = discoveryUrlField.text;
+ Bobink.startDiscovery();
}
BobinkAuth {
@@ -84,8 +86,8 @@ ApplicationWindow {
mode: authModeCombo.currentValue
username: usernameField.text
password: passwordField.text
- certPath: BobinkClient.certFile
- keyPath: BobinkClient.keyFile
+ certPath: Bobink.certFile
+ keyPath: Bobink.keyFile
}
FileDialog {
@@ -126,22 +128,20 @@ ApplicationWindow {
text: "opc.tcp://localhost:4840"
}
Button {
- text: BobinkClient.discovering ? "Stop" : "Discover"
+ text: Bobink.discovering ? "Stop" : "Discover"
onClicked: {
- if (BobinkClient.discovering) {
- BobinkClient.stopDiscovery();
+ if (Bobink.discovering) {
+ Bobink.stopDiscovery();
} else {
- BobinkClient.discoveryUrl = discoveryUrlField.text;
- BobinkClient.startDiscovery();
+ Bobink.discoveryUrl = discoveryUrlField.text;
+ Bobink.startDiscovery();
}
}
}
}
Label {
- text: BobinkClient.discovering
- ? "Discovering... (" + BobinkClient.servers.length + " found)"
- : BobinkClient.servers.length + " server(s)"
+ text: Bobink.discovering ? "Discovering... (" + Bobink.servers.length + " found)" : Bobink.servers.length + " server(s)"
font.italic: true
}
@@ -149,7 +149,7 @@ ApplicationWindow {
Layout.fillWidth: true
Layout.preferredHeight: 100
clip: true
- model: BobinkClient.servers
+ model: Bobink.servers
delegate: ItemDelegate {
required property var modelData
width: ListView.view.width
@@ -163,15 +163,18 @@ ApplicationWindow {
}
RowLayout {
- Label { text: "PKI"; font.bold: true }
Label {
- text: BobinkClient.certFile
- ? " (" + BobinkClient.certFile.split("/").pop() + ")"
- : " (no certificate found)"
+ text: "PKI"
+ font.bold: true
+ }
+ Label {
+ text: Bobink.certFile ? " (" + Bobink.certFile.split("/").pop() + ")" : " (no certificate found)"
font.italic: true
- color: BobinkClient.certFile ? "green" : "gray"
+ color: Bobink.certFile ? "green" : "gray"
+ }
+ Item {
+ Layout.fillWidth: true
}
- Item { Layout.fillWidth: true }
Button {
text: root.showPkiSettings ? "Hide" : "Configure..."
flat: true
@@ -184,31 +187,46 @@ ApplicationWindow {
Layout.fillWidth: true
visible: root.showPkiSettings
- Label { text: "Certificate:" }
+ Label {
+ text: "Certificate:"
+ }
TextField {
id: certFileField
Layout.fillWidth: true
- text: BobinkClient.certFile
+ text: Bobink.certFile
placeholderText: "Client certificate (.der)"
}
- Button { text: "Browse..."; onClicked: certFileDialog.open() }
+ Button {
+ text: "Browse..."
+ onClicked: certFileDialog.open()
+ }
- Label { text: "Private key:" }
+ Label {
+ text: "Private key:"
+ }
TextField {
id: keyFileField
Layout.fillWidth: true
- text: BobinkClient.keyFile
+ text: Bobink.keyFile
placeholderText: "Private key (.pem, .crt)"
}
- Button { text: "Browse..."; onClicked: keyFileDialog.open() }
+ Button {
+ text: "Browse..."
+ onClicked: keyFileDialog.open()
+ }
- Label { text: "Trust folder:" }
+ Label {
+ text: "Trust folder:"
+ }
TextField {
id: trustFolderField
Layout.fillWidth: true
- text: BobinkClient.pkiDir
+ text: Bobink.pkiDir
+ }
+ Button {
+ text: "Browse..."
+ onClicked: trustFolderDialog.open()
}
- Button { text: "Browse..."; onClicked: trustFolderDialog.open() }
}
Button {
@@ -216,14 +234,17 @@ ApplicationWindow {
Layout.fillWidth: true
visible: root.showPkiSettings
onClicked: {
- BobinkClient.pkiDir = trustFolderField.text;
- BobinkClient.certFile = certFileField.text;
- BobinkClient.keyFile = keyFileField.text;
- BobinkClient.applyPki();
+ Bobink.pkiDir = trustFolderField.text;
+ Bobink.certFile = certFileField.text;
+ Bobink.keyFile = keyFileField.text;
+ Bobink.applyPki();
}
}
- Label { text: "Server URL"; font.bold: true }
+ Label {
+ text: "Server URL"
+ font.bold: true
+ }
TextField {
id: serverUrlField
@@ -231,7 +252,10 @@ ApplicationWindow {
placeholderText: "opc.tcp://..."
}
- Label { text: "Authentication"; font.bold: true }
+ Label {
+ text: "Authentication"
+ font.bold: true
+ }
ComboBox {
id: authModeCombo
@@ -239,9 +263,18 @@ ApplicationWindow {
textRole: "text"
valueRole: "mode"
model: [
- { text: "Anonymous", mode: BobinkAuth.Anonymous },
- { text: "Username / Password", mode: BobinkAuth.UserPass },
- { text: "Certificate", mode: BobinkAuth.Certificate }
+ {
+ text: "Anonymous",
+ mode: BobinkAuth.Anonymous
+ },
+ {
+ text: "Username / Password",
+ mode: BobinkAuth.UserPass
+ },
+ {
+ text: "Certificate",
+ mode: BobinkAuth.Certificate
+ }
]
}
@@ -250,9 +283,16 @@ ApplicationWindow {
visible: authModeCombo.currentValue === BobinkAuth.UserPass
Layout.fillWidth: true
- Label { text: "Username:" }
- TextField { id: usernameField; Layout.fillWidth: true }
- Label { text: "Password:" }
+ Label {
+ text: "Username:"
+ }
+ TextField {
+ id: usernameField
+ Layout.fillWidth: true
+ }
+ Label {
+ text: "Password:"
+ }
TextField {
id: passwordField
Layout.fillWidth: true
@@ -265,9 +305,9 @@ ApplicationWindow {
Layout.fillWidth: true
onClicked: {
root.autoConnectFailed = false;
- BobinkClient.auth = auth;
- BobinkClient.serverUrl = serverUrlField.text;
- BobinkClient.connectToServer();
+ Bobink.auth = auth;
+ Bobink.serverUrl = serverUrlField.text;
+ Bobink.connectToServer();
}
}
@@ -282,29 +322,51 @@ ApplicationWindow {
Layout.fillWidth: true
visible: root.autoConnectFailed
- Label { text: "Security policy:" }
+ Label {
+ text: "Security policy:"
+ }
ComboBox {
id: securityPolicyCombo
Layout.fillWidth: true
textRole: "text"
valueRole: "policy"
model: [
- { text: "Basic256Sha256", policy: BobinkClient.Basic256Sha256 },
- { text: "Aes128-Sha256-RsaOaep", policy: BobinkClient.Aes128_Sha256_RsaOaep },
- { text: "Aes256-Sha256-RsaPss", policy: BobinkClient.Aes256_Sha256_RsaPss }
+ {
+ text: "Basic256Sha256",
+ policy: Bobink.Basic256Sha256
+ },
+ {
+ text: "Aes128-Sha256-RsaOaep",
+ policy: Bobink.Aes128_Sha256_RsaOaep
+ },
+ {
+ text: "Aes256-Sha256-RsaPss",
+ policy: Bobink.Aes256_Sha256_RsaPss
+ }
]
}
- Label { text: "Security mode:" }
+ Label {
+ text: "Security mode:"
+ }
ComboBox {
id: securityModeCombo
Layout.fillWidth: true
textRole: "text"
valueRole: "mode"
model: [
- { text: "Sign & Encrypt", mode: BobinkClient.SignAndEncrypt },
- { text: "Sign", mode: BobinkClient.Sign },
- { text: "None", mode: BobinkClient.None }
+ {
+ text: "Sign & Encrypt",
+ mode: Bobink.SignAndEncrypt
+ },
+ {
+ text: "Sign",
+ mode: Bobink.Sign
+ },
+ {
+ text: "None",
+ mode: Bobink.None
+ }
]
}
}
@@ -314,14 +376,15 @@ ApplicationWindow {
Layout.fillWidth: true
visible: root.autoConnectFailed
onClicked: {
- BobinkClient.auth = auth;
- BobinkClient.serverUrl = serverUrlField.text;
- BobinkClient.connectDirect(securityPolicyCombo.currentValue,
- securityModeCombo.currentValue);
+ Bobink.auth = auth;
+ Bobink.serverUrl = serverUrlField.text;
+ Bobink.connectDirect(securityPolicyCombo.currentValue, securityModeCombo.currentValue);
}
}
- Item { Layout.fillHeight: true }
+ Item {
+ Layout.fillHeight: true
+ }
}
}
}