forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·62 lines (57 loc) · 1.29 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
// import "slint";
let slint = require("slint-ui");
// import * as demo from "../ui/todo.slint";
let demo = require("../ui/todo.slint");
let app = new demo.MainWindow();
let model = new slint.ArrayModel([
{
title: "Implement the .slint file",
checked: true
},
{
title: "Do the Rust part",
checked: false
},
{
title: "Make the C++ code",
checked: false
},
{
title: "Write some JavaScript code",
checked: true
},
{
title: "Test the application",
checked: false
},
{
title: "Ship to customer",
checked: false
},
{
title: "???",
checked: false
},
{
title: "Profit",
checked: false
},
]);
app.todo_model = model;
app.todo_added.setHandler(function (text) {
model.push({ title: text, checked: false })
})
app.remove_done.setHandler(function () {
let offset = 0;
const length = model.length;
for (let i = 0; i < length; ++i) {
if (model.rowData(i - offset).checked) {
model.remove(i - offset, 1);
offset++;
}
}
})
app.run();