slint-test/testfrontend/src/welcome.slint

78 lines
2.5 KiB
Plaintext

import { DemoPalette, Page } from "./common.slint";
import { HomePage } from "./homepage.slint";
import { Button, VerticalBox, CheckBox, ComboBox, ListView, HorizontalBox, LineEdit } from "std-widgets.slint";
component ActionButton inherits Rectangle {
in property <image> icon <=> img.source;
in property <string> text <=> label.text;
callback clicked;
VerticalLayout {
spacing: 4px;
Rectangle {
border-radius: 25px;
border-width: 5px;
// border-color: DemoPalette.control-outline-color;
background: DemoPalette.printer-action-background-color;
img := Image {
x: (parent.width / 2) - (self.width / 2);
y: (parent.height / 2) - (self.height / 2);
colorize: DemoPalette.text-foreground-color;
}
}
label := Text {
font-size: DemoPalette.base-font-size * 1.375;
font-weight: 800;
horizontal-alignment: center;
color: DemoPalette.text-foreground-color;
}
}
TouchArea { clicked => { root.clicked() } }
}
export component DevicesPage inherits Page {
in-out property <length> header-row-height: 40px;
in-out property <length> button-spacing: 105px;
in-out property <length> button-width: 127px;
in-out property <length> button-height: root.button-width + 37px;
pure callback validate-date(string) -> bool;
// header: @tr("Slint Printer Demo");
private property <bool> message-visible;
in-out property <int> current-subpage: 0;
VerticalBox {
width: root.button-width;
height: root.button-height;
combo := ComboBox {
// row: 0;
model: ["/dev/device", "bluetooth"];
current-value: "bluetooth";
current-index: 0;
}
Button {
// row: 3;
text: "Connect";
clicked() => { root.message-visible = true; }
// enabled: combo.current-index != 1 ? root.validate-date(t1.text) : root.compare-date(t1.text, t2.text);
}
for action[idx] in [
{ name: @tr("Scan"), icon: @image-url("images/scan.svg") },
// { name: @tr("USB"), icon: @image-url("images/usb.svg") },
]: ActionButton {
width: root.button-width;
height: root.button-height;
icon: action.icon;
text: action.name;
clicked => { root.current-subpage = idx + 1; }
}
}
}