aboutsummaryrefslogtreecommitdiffstats
path: root/demo/Main.qml
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-03-16 16:19:49 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-03-16 16:19:49 +0100
commitfa095de6cc8ec5a5b5c14091f2b3179ad7071876 (patch)
treeaa094011263a83a4c91eb8722c2095344656c838 /demo/Main.qml
parent7830f0ae98d742467b948ed93c85e122be38fb83 (diff)
downloadQtXpl2-fa095de6cc8ec5a5b5c14091f2b3179ad7071876.tar.gz
QtXpl2-fa095de6cc8ec5a5b5c14091f2b3179ad7071876.zip
EV_ events with Q_GADGET status types, mock periodic emission, tabbed demo UI
Diffstat (limited to 'demo/Main.qml')
-rw-r--r--demo/Main.qml270
1 files changed, 60 insertions, 210 deletions
diff --git a/demo/Main.qml b/demo/Main.qml
index 394d1ba..9b9223f 100644
--- a/demo/Main.qml
+++ b/demo/Main.qml
@@ -39,6 +39,14 @@ ApplicationWindow {
debugConsole.appendLog("ERROR: " + error);
}
+ function onJcStatusReceived(status) {
+ statusPage.lastJcStatus = status;
+ }
+
+ function onPhStatusReceived(status) {
+ statusPage.lastPhStatus = status;
+ }
+
function onPhVersionReceived(controllerId: int, printheadId: int,
mcuFirmwareVersion: string,
mcuHardwareVersion: string,
@@ -61,6 +69,10 @@ ApplicationWindow {
}
}
+ function onShuttingDown() {
+ debugConsole.appendLog("SERVER SHUTTING DOWN");
+ }
+
function onStatusMessage(message: string) {
debugConsole.appendLog(message);
}
@@ -72,249 +84,87 @@ ApplicationWindow {
anchors.fill: parent
spacing: 0
- ColumnLayout {
- Layout.fillHeight: true
+ // --- Connection (always visible) ---
+ GroupBox {
+ Layout.bottomMargin: 0
Layout.fillWidth: true
Layout.margins: 16
- spacing: 12
-
- // --- Connection ---
- GroupBox {
- Layout.fillWidth: true
- title: "Connection"
-
- RowLayout {
- anchors.fill: parent
-
- Label {
- text: "Host:"
- }
-
- TextField {
- id: hostField
-
- Layout.fillWidth: true
- text: Xpl2Client.host
-
- onEditingFinished: Xpl2Client.host = text
- }
+ title: "Connection"
- Button {
- text: Xpl2Client.connected ? "Disconnect" : "Connect"
+ RowLayout {
+ anchors.fill: parent
- onClicked: {
- if (Xpl2Client.connected)
- Xpl2Client.disconnectFromServer();
- else
- Xpl2Client.connectToServer();
- }
- }
+ Label {
+ text: "Host:"
}
- }
- // --- JC Version ---
- GroupBox {
- Layout.fillWidth: true
- enabled: Xpl2Client.connected
- title: "Jetting Controller"
+ TextField {
+ id: hostField
- RowLayout {
- anchors.fill: parent
+ Layout.fillWidth: true
+ text: Xpl2Client.host
- Button {
- text: "Get JC Version"
-
- onClicked: Xpl2Client.getJcVersion()
- }
-
- Label {
- text: Xpl2Client.controllerId > 0
- ? "Controller: %1 | FW: %2 | HW: %3 | PHs: %4".arg(
- Xpl2Client.controllerId).arg(
- Xpl2Client.firmwareVersion).arg(
- Xpl2Client.hardwareVersion).arg(
- Xpl2Client.printheadCount) :
- "No version data"
- }
+ onEditingFinished: Xpl2Client.host = text
}
- }
-
- // --- Control ---
- GroupBox {
- Layout.fillWidth: true
- enabled: Xpl2Client.connected
- title: "Control"
-
- GridLayout {
- anchors.fill: parent
- columns: 4
- Button {
- text: "Jetting All On"
+ Button {
+ text: Xpl2Client.connected ? "Disconnect" : "Connect"
- onClicked: Xpl2Client.jettingAllOn()
- }
-
- Button {
- text: "Jetting Off"
-
- onClicked: Xpl2Client.jettingOff()
- }
-
- Button {
- text: "JC LED On"
-
- onClicked: Xpl2Client.jcIdLedOn()
- }
-
- Button {
- text: "JC LED Off"
-
- onClicked: Xpl2Client.jcIdLedOff()
- }
-
- Button {
- text: "JC Calibration"
-
- onClicked: Xpl2Client.jcCalibration()
- }
-
- Button {
- text: "Reset Fault Codes"
-
- onClicked: Xpl2Client.jcResetFaultCodes()
+ onClicked: {
+ if (Xpl2Client.connected)
+ Xpl2Client.disconnectFromServer();
+ else
+ Xpl2Client.connectToServer();
}
}
}
+ }
- // --- Configuration ---
- GroupBox {
- Layout.fillWidth: true
- enabled: Xpl2Client.connected
- title: "Configuration"
-
- GridLayout {
- anchors.fill: parent
- columns: 4
-
- Button {
- text: "Save All Settings"
-
- onClicked: Xpl2Client.jcSaveAllPrintheadSettings()
- }
-
- Button {
- text: "Reboot All PHs"
-
- onClicked: Xpl2Client.jcRebootAllPrintheads()
- }
-
- Button {
- text: "Restart JC"
-
- onClicked: Xpl2Client.jcRestart()
- }
+ // --- Tab bar ---
+ TabBar {
+ id: tabBar
- Button {
- text: "Shutdown JC"
+ Layout.fillWidth: true
+ Layout.leftMargin: 16
+ Layout.rightMargin: 16
- onClicked: Xpl2Client.jcShutdown()
- }
- }
+ TabButton {
+ text: "Commands"
}
- // --- Printheads ---
- GroupBox {
- Layout.fillHeight: true
- Layout.fillWidth: true
- enabled: Xpl2Client.connected
- title: "Printheads (%1)".arg(root.demoPhCount)
-
- ColumnLayout {
- anchors.fill: parent
-
- Button {
- text: "Get All PH Versions"
-
- onClicked: {
- for (let i = 0; i < phModel.count; ++i)
- Xpl2Client.getPhVersion(phModel.get(i).phId);
- }
- }
-
- ScrollView {
- Layout.fillHeight: true
- Layout.fillWidth: true
-
- ListView {
- model: phModel
- spacing: 4
-
- delegate: RowLayout {
- id: phDelegate
+ TabButton {
+ text: "Status"
+ }
+ }
- required property int phId
- required property string versionInfo
+ // --- Swipe view ---
+ SwipeView {
+ id: swipeView
- width: ListView.view.width
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.margins: 16
+ currentIndex: tabBar.currentIndex
- Label {
- Layout.preferredWidth: 50
- font.bold: true
- text: "PH %1".arg(phDelegate.phId)
- }
+ onCurrentIndexChanged: tabBar.currentIndex = currentIndex
- Button {
- text: "Version"
+ CommandsPage {
+ demoPhCount: root.demoPhCount
+ phModel: phModel
+ }
- onClicked: Xpl2Client.getPhVersion(
- phDelegate.phId)
- }
+ StatusPage {
+ id: statusPage
- Label {
- Layout.fillWidth: true
- elide: Text.ElideRight
- text: phDelegate.versionInfo || "—"
- }
- }
- }
- }
- }
}
}
// --- Debug Console ---
- Rectangle {
+ DebugConsole {
id: debugConsole
- function appendLog(msg: string): void {
- let ts = new Date().toLocaleTimeString(Qt.locale(),
- "HH:mm:ss.zzz");
- debugLog.text += "[" + ts + "] " + msg + "\n";
- debugLog.cursorPosition = debugLog.text.length;
- }
-
Layout.fillWidth: true
Layout.preferredHeight: 160
- border.color: "#444"
- color: "#1e1e1e"
- radius: 4
-
- ScrollView {
- anchors.fill: parent
- anchors.margins: 4
-
- TextArea {
- id: debugLog
-
- background: null
- color: "#cccccc"
- font.family: "monospace"
- font.pointSize: 9
- readOnly: true
- wrapMode: TextEdit.Wrap
- }
- }
}
}
}