-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMainLayout.qml
78 lines (77 loc) · 2.25 KB
/
MainLayout.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
import QtQuick 2.8
import QtQuick.Dialogs 1.2
import io.qt.serialportdealer 1.0
MainLayoutForm {
property string firmwareDirectory
width: parent.width
height: parent.height
Timer{
interval: 500
running: true
repeat: true
onTriggered: {
serialPortCombo.model = portDealer.portList
}
}
MessageDialog{
id:msgBox
visible: false
function showCriticalMessage(title,text)
{
msgBox.setTitle(title)
msgBox.setText(text)
msgBox.icon = StandardIcon.Critical
msgBox.standardButtons = MessageDialog.Ok
msgBox.visible = true
}
function showOKMessage(title,text)
{
msgBox.setTitle(title)
msgBox.setText(text)
msgBox.icon = StandardIcon.Information
msgBox.standardButtons = MessageDialog.Ok
msgBox.visible = true
}
}
firmwareChooseButton.onClicked: {
fileDialog.open()
}
downloadButton.onClicked: {
if(serialPortCombo.count === 0)
{
msgBox.showCriticalMessage("错误","请插入串口调试器!")
}
else
{
portDealer.useCRC8 = crc8CheckCheckBox.checked
portDealer.firmwareDir = firmwareDirectory
portDealer.portName = serialPortCombo.currentText;
portDealer.sliceSize = parseInt(packetLengthCombo.currentText)
if(portDealer.firmwareDownload() !== true)
{
msgBox.showCriticalMessage("下载失败","请确认没有其他程序占用该端口,同时确认!")
}
else
{
msgBox.showOKMessage("下载成功","下载完成!")
}
}
}
FileDialog {
id: fileDialog
title: "选择准备烧录的固件"
folder: shortcuts.desktop
nameFilters: ["Bin Files (*.bin)"]
selectExisting: true
selectFolder: false
selectMultiple: false
onAccepted: {
firmwareDirectory = fileUrl.toString().slice(8)
fileInfo.text = firmwareDirectory
downloadButton.enabled = true
}
}
SerialPortDealer{
id:portDealer
}
}