slint-test/testfrontend/src/homepage.slint

126 lines
3.7 KiB
Plaintext

import { DemoPalette, Page } from "./common.slint";
// import { WidePrinterQueueList } from "./printer_queue.slint";
import { Button, VerticalBox, CheckBox, ComboBox, ListView, HorizontalBox, LineEdit } from "std-widgets.slint";
export struct TodoItem {
title: string,
checked: bool,
}
export component HomePage inherits Page {
// has-back-button: true;
// header: @tr("Print");
// preferred-width: 400px;
// preferred-height: 600px;
// title: @tr("Serial");
callback todo-added(string);
in-out property<int> counter: 42;
callback request-increase-value();
callback apply_sorting_and_filtering();
in property <[TodoItem]> todo-model;
in property <bool> show-header: true;
in-out property <bool> is-sort-by-name: false;
in-out property <bool> hide-done-items: false;
VerticalBox {
HorizontalBox {
// ComboBox {
// value: @tr("119200");
// choices: [@tr("300"), @tr("1200"), @tr("2400"), @tr("4800"), @tr("19200"), @tr("38400"), @tr("57600")];
// }
ComboBox {
model: [@tr("Select Port"), @tr("300"), @tr("1200"), @tr("2400"), @tr("4800"), @tr("19200"), @tr("38400"), @tr("57600")];
// enabled: GallerySettings.widgets-enabled;
}
connectbtn := Button {
text: "Connect";
enabled: text-edit.text != "";
clicked => {
root.todo-added(text-edit.text);
text-edit.text = "";
}
}
disconectbtn := Button {
text: "Disconnect";
enabled: text-edit.text != "";
clicked => {
root.todo-added(text-edit.text);
text-edit.text = "";
}
}
}
if (root.show-header) : HorizontalBox {
alignment: start;
CheckBox {
text: "Sort by name";
checked <=> root.is-sort-by-name;
toggled => {
root.apply_sorting_and_filtering();
}
}
CheckBox {
text: "Hide done items";
checked <=> root.hide-done-items;
toggled => {
root.apply_sorting_and_filtering();
}
}
}
list-view := ListView {
for todo in root.todo-model: HorizontalLayout {
Text {
padding: 2px;
text: todo.title;
}
// CheckBox {
// text: todo.title;
// checked: todo.checked;
// toggled => {
// todo.checked = self.checked;
// }
// }
}
}
HorizontalBox {
padding: 0px;
text-edit := LineEdit {
placeholder-text: "Enter Command";
accepted(text) => {
root.todo-added(self.text);
self.text = "";
}
}
btn := Button {
text: "Send";
enabled: text-edit.text != "";
clicked => {
root.todo-added(text-edit.text);
text-edit.text = "";
}
}
}
// Text {
// text: "Counter: \{root.counter}";
// }
// Button {
// text: "Increase value";
// clicked => {
// root.request-increase-value();
// }
// }
}
}