forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·61 lines (55 loc) · 1.17 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
#!/usr/bin/env node
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT
import * as slint from "slint-ui";
let demo = slint.loadFile("../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 = function (text) {
model.push({ title: text, checked: false })
};
app.remove_done = 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();