Files
2026-05-23 17:09:27 +02:00

224 lines
6.8 KiB
Plaintext

import { Button, LineEdit, CheckBox, Spinner, GridBox, VerticalBox, HorizontalBox, ListView, ScrollView, StandardTableView } from "std-widgets.slint";
export struct ResultEntry {
is-header: bool,
is-new: bool,
label: string,
}
export component MainWindow inherits Window {
title: "Sane Vector Log Decoder";
preferred-width: 640px;
preferred-height: 320px;
in-out property <string> dbc-path;
in-out property <string> asc-label;
in-out property <bool> has-asc;
in-out property <string> output-dir;
in-out property <bool> laps;
in-out property <bool> busy;
in-out property <string> status;
in-out property <bool> has-results;
callback browse-dbc();
callback browse-asc();
callback browse-output();
callback decode();
callback open-results();
VerticalBox {
padding: 12px;
spacing: 8px;
GridBox {
spacing: 8px;
Row {
Text { text: "DBC file:"; vertical-alignment: center; }
LineEdit { read-only: true; text: root.dbc-path; }
Button { text: "Browse..."; clicked => { root.browse-dbc(); } }
}
Row {
Text { text: "ASC file(s):"; vertical-alignment: center; }
LineEdit { read-only: true; text: root.asc-label; }
Button { text: "Browse..."; clicked => { root.browse-asc(); } }
}
Row {
Text { text: "Output dir:"; vertical-alignment: center; }
LineEdit { read-only: true; text: root.output-dir; }
Button { text: "Browse..."; clicked => { root.browse-output(); } }
}
}
CheckBox {
text: "Generate lap beacons";
checked <=> root.laps;
}
Rectangle { vertical-stretch: 1; }
HorizontalBox {
padding: 0px;
spacing: 8px;
if root.busy: Spinner {
width: 20px;
height: 20px;
indeterminate: true;
}
Text {
text: root.status;
horizontal-stretch: 1;
vertical-alignment: center;
overflow: elide;
}
if root.has-results: Button {
text: "Show results";
clicked => { root.open-results(); }
}
Button {
text: "Decode!";
enabled: !root.busy
&& root.dbc-path != ""
&& root.has-asc
&& root.output-dir != "";
clicked => { root.decode(); }
}
}
}
}
export component ResultsWindow inherits Window {
title: "Decode results";
preferred-width: 900px;
preferred-height: 520px;
in property <[ResultEntry]> entries;
in-out property <int> selected-index: -1;
in property <string> sel-label;
in property <string> sel-date;
in property <int> sel-unknown-count;
in property <int> sel-error-count;
in property <string> sel-unknown-ids;
in property <[[StandardListViewItem]]> sel-error-rows;
in property <string> sel-runtime-stats;
callback select(int);
HorizontalBox {
padding: 8px;
spacing: 8px;
Rectangle {
width: 280px;
border-width: 1px;
border-color: #cccccc;
ListView {
for entry[i] in root.entries: Rectangle {
height: 26px;
background: i == root.selected-index ? #3a78d8 : transparent;
TouchArea {
clicked => { root.select(i); }
HorizontalLayout {
padding-left: entry.is-header ? 6px : 24px;
padding-right: 6px;
spacing: 6px;
Text {
text: entry.label;
font-weight: entry.is-header ? 700 : 400;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
if entry.is-header && entry.is-new: Rectangle {
background: #2ecc71;
border-radius: 3px;
width: 38px;
height: 16px;
y: (parent.height - self.height) / 2;
Text {
text: "NEW";
color: white;
font-size: 10px;
horizontal-alignment: center;
vertical-alignment: center;
}
}
}
}
}
}
}
VerticalBox {
padding: 0px;
spacing: 6px;
horizontal-stretch: 1;
Text {
text: root.selected-index >= 0 ? root.sel-label : "Select an ASC file on the left.";
font-size: 14px;
font-weight: 700;
}
if root.selected-index >= 0: Text {
text: "Date: " + root.sel-date;
}
if root.selected-index >= 0: Text {
text: "Unknown IDs: " + root.sel-unknown-count
+ " Error frames: " + root.sel-error-count;
}
if root.selected-index >= 0: Text {
text: "Unknown CAN IDs";
font-weight: 700;
}
if root.selected-index >= 0: Rectangle {
border-width: 1px;
border-color: #cccccc;
height: 90px;
ScrollView {
Text {
text: root.sel-unknown-ids;
wrap: word-wrap;
}
}
}
if root.selected-index >= 0: Text {
text: "Error frames";
font-weight: 700;
}
if root.selected-index >= 0: StandardTableView {
vertical-stretch: 1;
columns: [
{ title: "Timestamp" },
{ title: "Channel" },
{ title: "Data (binary)" },
];
rows: root.sel-error-rows;
}
if root.selected-index >= 0: Text {
text: "Runtime stats";
font-weight: 700;
}
if root.selected-index >= 0: Text {
text: root.sel-runtime-stats;
}
}
}
}