实现通过cdc进行升级。
This commit is contained in:
@ -160,6 +160,10 @@ ColumnLayout {
|
||||
text: "ID查询"
|
||||
onClicked: App.module.requestUniqueId()
|
||||
}
|
||||
Button {
|
||||
text: "OTA升级"
|
||||
onClicked: loader.active = true
|
||||
}
|
||||
Row {
|
||||
Text {
|
||||
text: qsTr("日志")
|
||||
@ -171,4 +175,18 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
source: "OtaPage.qml"
|
||||
active: false
|
||||
onLoaded: {
|
||||
if (loader.item && loader.item.open) {
|
||||
loader.item.open();
|
||||
loader.item.onClose = ()=>{
|
||||
loader.active= false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
115
Analyser/qml/OtaPage.qml
Normal file
115
Analyser/qml/OtaPage.qml
Normal file
@ -0,0 +1,115 @@
|
||||
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 {
|
||||
id:progressBar
|
||||
Layout.fillWidth: true
|
||||
from: 0
|
||||
to:100
|
||||
value: 0.0
|
||||
}
|
||||
Text {
|
||||
id:progressText
|
||||
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"
|
||||
App.startOta(otaFile.text)
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
function onOtaProgressChanged(progress){
|
||||
progressBar.value = progress;
|
||||
progressText.text = `${progress}%`
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ import Analyser
|
||||
|
||||
Window {
|
||||
width: 1120
|
||||
height: 640
|
||||
height: 680
|
||||
visible: true
|
||||
title: qsTr(Qt.application.name + " " + Qt.application.version)
|
||||
|
||||
|
Reference in New Issue
Block a user