diff --git a/DeviceConnection.cpp b/DeviceConnection.cpp index ff0b450..f998f16 100644 --- a/DeviceConnection.cpp +++ b/DeviceConnection.cpp @@ -517,7 +517,11 @@ void DeviceConnection::requestReset() { void DeviceConnection::transferBinContent() { constexpr int SliceSize = 1024; constexpr int WaitMd5CheckTime = 3000; // ms - if (m_sendedSize >= m_uploadBuffer.size()) return; + if (m_sendedSize >= m_uploadBuffer.size()) { + LOG(warning) << "file size is wrong, sended size: " << m_sendedSize + << "ota file size: " << m_uploadBuffer.size(); + return; + } char buffer[1 + sizeof(int32_t) + 1024]; int sendSize = SliceSize; diff --git a/qml/Main.qml b/qml/Main.qml index 196abe3..d26ba07 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -156,9 +156,9 @@ ApplicationWindow { } if (App.collector.path.length <= 0) { showFolderDialog(folder => { - App.collector.path = folder - App.collector.start(App.devices.get(deviceList.currentIndex).ip) - }) + App.collector.path = folder + App.collector.start(App.devices.get(deviceList.currentIndex).ip) + }) } else { App.collector.start(App.devices.get( deviceList.currentIndex).ip) @@ -190,8 +190,8 @@ ApplicationWindow { showMessageDialog(2, "恢复出厂设置", "请先选择设备") return } else { - showMessageDialog(2, "恢复出厂设置", "设备将会重启,重启后配置恢复默认",()=>{ - App.resetDevice(); + showMessageDialog(2, "恢复出厂设置", "设备将会重启,重启后配置恢复默认", () => { + App.resetDevice() }) } } @@ -203,19 +203,19 @@ ApplicationWindow { id: messageBar root: window.contentItem } - function showSuccess(text,duration){ - return messageBar.showSuccess(text,duration) + function showSuccess(text, duration) { + return messageBar.showSuccess(text, duration) } function showMessageDialog(type, title, message, callback) { let component = Qt.createComponent("MessageDialog.qml") if (component.status === Component.Ready) { let dialog = component.createObject(window, { - "type": type, - "titleText": title, - "text": message, - "callback": callback - }) + "type": type, + "titleText": title, + "text": message, + "callback": callback + }) dialog.open() } } @@ -228,11 +228,14 @@ ApplicationWindow { dialog = Qt.createQmlObject("import QtQuick.Dialogs; FileDialog {}", window, "myDynamicSnippet") } if (dialog) { - dialog.nameFilters = nameFilters; + dialog.nameFilters = nameFilters dialog.visible = true dialog.accepted.connect(function () { let fileUrl = isQt5 ? dialog.fileUrl.toString() : dialog.selectedFile.toString() - let localFilePath = fileUrl.startsWith("file:///") ? fileUrl.substring(8) : fileUrl + let localFilePath = fileUrl + if (fileUrl.startsWith("file:///")) { + localFilePath = fileUrl.substring(Qt.platform.os === "windows" ? 8 : 7) + } onSelected(localFilePath) dialog.destroy() }) diff --git a/qml/OtaPopup.qml b/qml/OtaPopup.qml index 2e1e106..148fde8 100644 --- a/qml/OtaPopup.qml +++ b/qml/OtaPopup.qml @@ -41,6 +41,7 @@ Popup { Layout.fillWidth: true readOnly: true placeholderText: "请选择升级bin文件" + selectByMouse: true } Button { enabled: otaFinished