-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditionCell.qml
More file actions
97 lines (88 loc) · 3.04 KB
/
Copy pathConditionCell.qml
File metadata and controls
97 lines (88 loc) · 3.04 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import QtQuick
import QtQuick.Controls
Row {
id: container
required property int row
required property int column
required property bool current
required property bool editing
required property bool selected
required property var model
ComboBox {
id: typeComboBox
y: 5
height: 35
property string none: "🤖"
property string time: "⏱️"
property string temp: "🌡️"
model: [none, time, temp]
width: 65
font.pointSize: 9
currentIndex: {
switch (container.model.condition.type) {
case "none": return 0
case "time": return 1
case "temp": return 2
default: return 0 // Default to "none"
}
}
onCurrentTextChanged: {
Qt.callLater(makeChanges)
}
function makeChanges() {
let newCond = container.model.condition
newCond.type = typeComboBox.currentText === none ? "none" : typeComboBox.currentText === time ? "time" : "temp"
// Auto-set values to 0 when disabled
if (typeComboBox.currentText === none) {
newCond.temp = 0
newCond.time = 0
} else if (typeComboBox.currentText === time) {
newCond.temp = 0 // Disable temp when only time is selected
}
// For "temp" option, both fields remain enabled
container.model.condition = newCond
}
}
TextField {
id: tempTextField
y: 5
height: 35
width: 50
font.pointSize: 8
validator: DoubleValidator { bottom: 0; top: 1000; decimals: 3 }
selectByMouse: true
horizontalAlignment: TextInput.AlignHCenter
placeholderText: "°C"
text: container.model.condition.temp
enabled: typeComboBox.currentText === typeComboBox.temp
opacity: enabled ? 1.0 : 0.5 // Visual feedback for disabled state
onEditingFinished: {
if (enabled) {
let newCond = container.model.condition
newCond.temp = parseFloat(tempTextField.text) || 0
container.model.condition = newCond
}
}
}
TextField {
id: timeTextField
y: 5
height: 35
width: 50
font.pointSize: 8
validator: IntValidator { bottom: 0; top: 1000 }
selectByMouse: true
horizontalAlignment: TextInput.AlignHCenter
placeholderText: "мин"
text: container.model.condition.time
enabled: typeComboBox.currentText === typeComboBox.time || typeComboBox.currentText === typeComboBox.temp
opacity: enabled ? 1.0 : 0.5 // Visual feedback for disabled state
onEditingFinished: {
if (enabled) {
let newCond = container.model.condition
newCond.time = parseInt(timeTextField.text) || 0
container.model.condition = newCond
}
}
}
}