1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4import { LineEdit, Button, Slider, StandardListView, GridBox, HorizontalBox } from "std-widgets.slint";
5
6export component MainWindow inherits Window {
7 in property <[StandardListViewItem]> names-list;
8 out property <int> current-item: list.current-item;
9 out property <string> name;
10 out property <string> surname;
11 out property <string> prefix;
12 callback prefixEdited();
13 callback createClicked();
14 callback updateClicked();
15 callback deleteClicked();
16
17 GridBox {
18 filter-label := Text {
19 text: "Filter prefix:";
20 vertical-alignment: center;
21 horizontal-alignment: right;
22 }
23
24 LineEdit {
25 text <=> root.prefix;
26 edited => { root.prefixEdited() }
27 accessible-label: filter-label.accessible-label;
28 }
29
30 list := StandardListView {
31 row: 1;
32 rowspan: 3;
33 colspan: 2;
34 model: root.names-list;
35 accessible-label: "Names";
36 }
37
38 name-label := Text {
39 col: 2;
40 row: 1;
41 text: "Name: ";
42 vertical-alignment: center;
43 horizontal-alignment: right;
44 }
45
46 LineEdit {
47 text <=> root.name;
48 accessible-label: name-label.accessible-label;
49 }
50
51 surname-label := Text {
52 col: 2;
53 row: 2;
54 text: "Surname: ";
55 vertical-alignment: center;
56 horizontal-alignment: right;
57 }
58
59 LineEdit {
60 text <=> root.surname;
61 accessible-label: surname-label.accessible-label;
62 }
63
64 HorizontalBox {
65 padding-left: 0;
66 padding-bottom: 0;
67 row: 4;
68 alignment: start;
69
70 Button {
71 clicked => { root.createClicked() }
72
73 text: "Create";
74 }
75 Button {
76 clicked => { root.updateClicked() }
77
78 text: "Update";
79 enabled: list.current-item != -1 && list.current-item < root.names-list.length;
80
81 }
82 Button {
83 clicked => { root.deleteClicked() }
84
85 text: "Delete";
86 enabled: list.current-item != -1 && list.current-item < root.names-list.length;
87 }
88 }
89 }
90}
91