forked from patrickelectric/AtCore-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
201 lines (181 loc) · 6 KB
/
main.qml
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import QtQuick 2.1
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.1 as Kirigami
import QtQuick.Extras 1.4
import QtQuick.Dialogs 1.0
import org.kde.atcore 1.0
Kirigami.ApplicationItem {
id: root
AtCore {
id: atcore
onPortsChanged: devText.model = ports
Component.onCompleted: atcore.setSerialTimerInterval(1000)
}
globalDrawer: Kirigami.GlobalDrawer {
id: left
title: "AtCore Gui"
titleIcon: "applications-graphics"
handleVisible: true
ColumnLayout {
id: mainLayout
RowLayout {
id: connectionMenu
ComboBox {
id: devText
editable: true
model: atcore.serialPorts
Layout.preferredWidth: 150
Layout.fillWidth: true
}
ComboBox{
id: devSpeed
editable: true
model: atcore.portSpeeds
currentIndex: 7
Layout.preferredWidth: 150
Layout.maximumWidth: 225
}
Button {
text: "Connect"
onClicked: {
atcore.initSerial(devText.text, devSpeed.currentText.valueOf())
rowPie.visible = !rowPie.visible
}
}
}
RowLayout {
id: printMenu
Button {
text: "Load file..."
Layout.fillWidth: true
onClicked: {
fileDialog.visible = true
}
}
FileDialog {
id: fileDialog
title: "Please choose a file"
folder: shortcuts.home
onAccepted: {
// https://stackoverflow.com/questions/24927850/get-the-path-from-a-qml-url
var path = fileDialog.fileUrl.toString();
// remove prefixed "file:///"
path = path.replace(/^(file:\/{3})/,"");
// unescape html codes like '%23' for '#'
var cleanPath = decodeURIComponent(path);
}
}
Button {
text: "Print"
onClicked: atcore.print(cleanPath)
}
}
ColumnLayout {
id: controlMenu
width: parent.width
RowLayout {
Button {
text: "Stop"
onClicked: atcore.stop()
}
Button {
text: "Emergency"
onClicked: atcore.emergencyStop()
}
Button {
Layout.fillWidth: true
text: "Motors Off"
}
}
RowLayout {
id: rowPie
height: width
Pie {
id: pie
width: rowPie.width
visible: true
}
}
RowLayout {
Button {
text: "Relative Mode"
onClicked: {
text = text == "Relative Mode" ? "Absolute" : "Relative"
text = text + " Mode"
}
}
SpinBox {
Layout.fillWidth: true
editable: true
value: 50
textFromValue: function(value) {return value + " mm"}
}
Button {
Layout.fillWidth: true
text: "Set"
onClicked: atcore.setExtruderTemp(hendTemp.currentText.valueOf(), 0)
}
}
RowLayout {
Label {
text: "Heat:"
color: "gray"
}
Button {
Layout.fillWidth: true
text: "Off"
}
ComboBox {
id: hendTemp
editable: true
validator: IntValidator {
bottom: 0
top: 300
}
model: [185, 235]
}
Button {
Layout.fillWidth: true
text: "Set"
}
}
RowLayout {
Label {
text: "Bed :"
color: "gray"
}
Button {
Layout.fillWidth: true
text: "Off"
}
ComboBox {
id: bedTemp
editable: true
validator: IntValidator {
bottom: 0
top: 300
}
model: [50, 80]
}
Button {
Layout.fillWidth: true
text: "Set"
onClicked: atcore.setBedTemp(bedTemp.currentText.valueOf())
}
}
}
Item {
Layout.fillHeight: true
}
}
}
contextDrawer: Kirigami.ContextDrawer {
id: contextDrawer
}
pageStack.initialPage: mainPageComponent
Component {
id: mainPageComponent
Principal{}
}
}