SmartLockerTools/Analyser/qml/OtaPage.qml

114 lines
3.0 KiB
QML
Raw Permalink Normal View History

2024-08-05 17:42:27 +08:00
import QtCore
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import Analyser
Popup {
id: root
parent: Overlay.overlay
anchors.centerIn: Overlay.overlay
width: 500
height: 200
modal: true
focus: true
closePolicy: Popup.CloseOnEscape
property var onClose
ColumnLayout {
anchors.fill: parent
anchors.margins: 10
spacing: 10
RowLayout {
Layout.alignment: Qt.AlignRight
Button {
text: "关闭"
onClicked: root.close()
}
}
RowLayout {
spacing: 10
TextField {
id: otaFile
Layout.fillWidth: true
placeholderText: "请选择升级文件或将文件拖入工具中"
}
Button {
text: "选择"
onClicked: fileDialog.open()
}
}
RowLayout {
spacing: 10
ProgressBar {
2024-08-08 17:05:32 +08:00
id: progressBar
2024-08-05 17:42:27 +08:00
Layout.fillWidth: true
from: 0
2024-08-08 17:05:32 +08:00
to: 100
2024-08-05 17:42:27 +08:00
value: 0.0
}
Text {
2024-08-08 17:05:32 +08:00
id: progressText
2024-08-05 17:42:27 +08:00
text: "0%"
verticalAlignment: Text.AlignVCenter
}
}
RowLayout {
Text {
id: otaMessage
text: "请选择升级文件,点击开始按钮升级模组"
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
}
Button {
text: "开始"
Layout.alignment: Qt.AlignRight
onClicked: {
otaMessage.color = "black"
2024-08-08 17:05:32 +08:00
enabled = !App.startOta(otaFile.text)
2024-08-05 17:42:27 +08:00
}
}
}
}
onClosed: {
if (onClose)
onClose()
}
FileDialog {
id: fileDialog
nameFilters: ["OTA文件 (*.Pkg)"]
currentFolder: StandardPaths.standardLocations(
StandardPaths.DesktopLocation)[0]
onAccepted: {
var fileUrl = fileDialog.selectedFile.toString()
var localFilePath = fileUrl.startsWith(
"file:///") ? fileUrl.substring(8) : fileUrl
otaFile.text = localFilePath
}
}
Connections {
target: App
function onUpdateFinished() {
otaMessage.text = "OTA升级完成"
otaMessage.color = "green"
}
function onOtaMessage(message) {
otaMessage.text = message
}
2024-08-08 17:05:32 +08:00
function onOtaProgressChanged(progress) {
progressBar.value = progress
2024-08-05 17:42:27 +08:00
progressText.text = `${progress}%`
}
}
}