-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStateDelegate.qml
More file actions
65 lines (62 loc) · 2.03 KB
/
Copy pathStateDelegate.qml
File metadata and controls
65 lines (62 loc) · 2.03 KB
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
63
64
65
import QtQuick
import QtQuick.Controls
import com.grams.prototable
TextField {
id: stateDelegate
topInset: 5
font.pointSize: 9
required property int row
required property int column
required property bool current
required property bool editing
required property bool selected
required property var model
function toHHMMSS(secs) { // seems working
let newDate = new Date(secs * 1000).toISOString().slice(11, 19);
// debug if need, Date use 1970 thing
return newDate
}
function fromHHMMSS(str){
// let date = new Date(str);
let a = str.split(':'); // split it at the colons
// minutes are worth 60 seconds. Hours are worth 60 minutes.
let seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
return seconds; //
}
readOnly: true
color: "black"
text: {
switch (model.state) {
case RegimeState.Running:
return toHHMMSS(model.time_passed_in_seconds);
case RegimeState.Paused:
return toHHMMSS((model.max_time*60 - model.time_passed_in_seconds));
case RegimeState.Skipped:
case RegimeState.Done:
return toHHMMSS(model.max_time*60);
case RegimeState.Error:
return "Ошибка";
case RegimeState.Stopped:
default:
return "Ожидание";
}
}
background: Rectangle {
color: {
switch (model.state) {
case RegimeState.Running:
return "#C8E6C9"; // Pastel Green
case RegimeState.Paused:
return "#BBDEFB"; // Pastel Blue
case RegimeState.Stopped:
case RegimeState.Error:
return "#FFCDD2"; // Pastel Red
case RegimeState.Skipped:
case RegimeState.Done:
return '#fffecd';
default:
return "white";
}
}
}
}