-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomePage.qml
76 lines (72 loc) · 2.54 KB
/
HomePage.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
import QtQuick 2.7
HomePageForm {
id: homePage
Component.onCompleted: {
for (var i=0; i < ledButtons.length; i++){
ledButtons[i].onChosen.connect(ledChosen)
}
connectionStatus = "Disconnected"
}
Connections {
target: configurationWindow
onSerialConfigurationChanged: {
connectionStatus = "CHANGED!"
}
}
// Tratando sinais de conexão da porta serial
Connections {
target: backend
onSerialOpened: {
console.debug("Serial opened signal!")
connectionStatus = "Connected"
}
}
// Tratando sinais de desconexão da porta serial
Connections {
target: backend
onSerialClosed: {
console.debug("Serial closed signal!")
connectionStatus = "Disconnected"
}
}
Connections {
target: backend
onLedColorChanged: {
console.debug("RECVD LED " + number+ " CFG: " + color);
//ledButtons[number].color = Qt.lighter(color, 1.5)
var red_before = color.r;
color.r = Math.min(Math.pow(0.7 * color.r, 1/6), 1);
color.b = Math.min(Math.pow(color.b, 1/6), 1);
color.g = Math.min(Math.pow(1.4*color.g, 1/6), 1);
console.log("RED BEFORE: " + red_before + " RED AFTER: " + color.r)
//console.debug("CHANGED LED " + number+ " CFG: " + color);
ledButtons[number].color = color
}
}
serialConfigButton.button.onClicked: {configurationWindow.open()}
fileConfigButton.button.onClicked: {fileDialog.open()}
// Eventos de mudança do label de status da conexão
onConnectionStatusChanged: {
console.log("ConnectionStatusChanged! " + connectionStatus);
infoPaneStatusLabel.text = connectionStatus;
if (connectionStatus == "Disconnected") infoPaneStatusLabel.color = "red";
if (connectionStatus == "Connected") infoPaneStatusLabel.color = "green";
}
// Função para tratamento do LED escolhido
function ledChosen(chosen_led){
homePage.chosenLed = chosen_led
//swipeView.currentIndex = 1
swipeView.setCurrentIndex(1)
}
fileDialog.onAccepted: {
var path = fileDialog.fileUrl.toString();
// remove prefixed "file:///"
path = path.replace(/^(file:\/{2})/,"");
// unescape html codes like '%23' for '#'
var cleanPath = decodeURIComponent(path);
backend.loadFile(cleanPath)
}
fileDialog.onRejected: {
console.log("Canceled")
}
}