整理对话框布局。

This commit is contained in:
luocai 2024-08-30 14:47:03 +08:00
parent e3d599fdf7
commit aa3f4ebb29
5 changed files with 76 additions and 96 deletions

View File

@ -558,9 +558,6 @@ QString DeviceConnection::handleCommand(const std::string_view &replyText, const
} else if (value == "2") { } else if (value == "2") {
LOG(info) << "md5 check finished"; LOG(info) << "md5 check finished";
m_otaProgress = 99; m_otaProgress = 99;
if (m_otaTimer != nullptr) {
m_otaTimer->stop();
}
emit otaProgressChanged(true, m_otaProgress, "设备正在升级中,请稍后......"); emit otaProgressChanged(true, m_otaProgress, "设备正在升级中,请稍后......");
QTimer::singleShot(0, this, [this]() { QTimer::singleShot(0, this, [this]() {
m_commandSocket->close(); // 等待设备重新上线后,发起广播。由搜索服务触发重连 m_commandSocket->close(); // 等待设备重新上线后,发起广播。由搜索服务触发重连

View File

@ -99,14 +99,6 @@ std::shared_ptr<DeviceConnection> DeviceListModel::device(int index) {
return ret; return ret;
} }
bool DeviceListModel::deviceConnected(int index) {
bool ret = false;
if (index >= 0 && index < m_devices.size()) {
ret = m_devices.at(index)->isConnected();
}
return ret;
}
void DeviceListModel::startSearchDevice() { void DeviceListModel::startSearchDevice() {
if (m_timerId >= 0) { if (m_timerId >= 0) {
LOG(error) << "app is searching device."; LOG(error) << "app is searching device.";

View File

@ -31,7 +31,6 @@ public:
QHash<int, QByteArray> roleNames() const final; QHash<int, QByteArray> roleNames() const final;
Q_INVOKABLE QVariantMap get(int index) const; Q_INVOKABLE QVariantMap get(int index) const;
std::shared_ptr<DeviceConnection> device(int index); std::shared_ptr<DeviceConnection> device(int index);
Q_INVOKABLE bool deviceConnected(int index);
void startSearchDevice(); void startSearchDevice();
bool isSearching() const; bool isSearching() const;
float searchProgress() const; float searchProgress() const;

View File

@ -21,8 +21,8 @@ ApplicationWindow {
onClicked: { onClicked: {
deviceList.currentIndex = -1 deviceList.currentIndex = -1
App.startSearchDevice() App.startSearchDevice()
App.collector.stop() // App.collector.stop() //
App.collector.path="" App.collector.path = ""
} }
} }
Label { Label {
@ -80,7 +80,9 @@ ApplicationWindow {
deviceList.currentIndex = index deviceList.currentIndex = index
} }
onDoubleClicked: { onDoubleClicked: {
if (App.devices.deviceConnected(index)) { if (!softwareVersion.includes("R003")) {
showMessageDialog(2, "网络设置", "当前设备不支持有线网络设置!")
} else if (onlineStatus) {
networkPopup.open() networkPopup.open()
} else { } else {
showMessageDialog(2, "网络设置", "设备已离线!") showMessageDialog(2, "网络设置", "设备已离线!")
@ -90,8 +92,8 @@ ApplicationWindow {
} }
onCurrentIndexChanged: { onCurrentIndexChanged: {
App.connectToDevice(deviceList.currentIndex) App.connectToDevice(deviceList.currentIndex)
App.collector.stop() // App.collector.stop() //
App.collector.path="" App.collector.path = ""
} }
ProgressBar { ProgressBar {
anchors.left: parent.left anchors.left: parent.left
@ -179,16 +181,15 @@ ApplicationWindow {
let component = Qt.createComponent("MessageDialog.qml") let component = Qt.createComponent("MessageDialog.qml")
if (component.status === Component.Ready) { if (component.status === Component.Ready) {
let dialog = component.createObject(window, { let dialog = component.createObject(window, {
"type": type, "type": type,
"height": 200, "titleText": title,
"titleText": title, "text": message
"text": message })
})
dialog.open() dialog.open()
} }
} }
function showFileDialog(nameFilters,onSelected){ function showFileDialog(nameFilters, onSelected) {
let dialog = null let dialog = null
if (isQt5) { if (isQt5) {
dialog = Qt.createQmlObject("import QtQuick.Dialogs 1.3; FileDialog {}", window, "myDynamicSnippet") dialog = Qt.createQmlObject("import QtQuick.Dialogs 1.3; FileDialog {}", window, "myDynamicSnippet")
@ -200,8 +201,7 @@ ApplicationWindow {
dialog.visible = true dialog.visible = true
dialog.accepted.connect(function () { dialog.accepted.connect(function () {
let fileUrl = isQt5 ? dialog.fileUrl.toString() : dialog.selectedFile.toString() let fileUrl = isQt5 ? dialog.fileUrl.toString() : dialog.selectedFile.toString()
let localFilePath = fileUrl.startsWith( let localFilePath = fileUrl.startsWith("file:///") ? fileUrl.substring(8) : fileUrl
"file:///") ? fileUrl.substring(8) : fileUrl
onSelected(localFilePath) onSelected(localFilePath)
dialog.destroy() dialog.destroy()
}) })

View File

@ -1,9 +1,11 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
Dialog { Dialog {
id: control id: control
width: 320 width: 320
padding: 30
parent: Overlay.overlay parent: Overlay.overlay
anchors.centerIn: Overlay.overlay anchors.centerIn: Overlay.overlay
modal: true modal: true
@ -21,87 +23,77 @@ Dialog {
Warning, Warning,
Failed Failed
} }
IconButton { contentItem: ColumnLayout {
anchors.right: parent.right id: layout
anchors.rightMargin: 7 IconButton {
anchors.top: parent.top Layout.leftMargin: 30
anchors.topMargin: 10 Layout.rightMargin: 6
source: "../resources/popup_close.svg" Layout.alignment: Qt.AlignRight
onClicked: control.close() source: "../resources/popup_close.svg"
} onClicked: control.close()
Image { }
id: image RowLayout {
width: 18 Layout.leftMargin: 30
height: 18 Image {
anchors.left: parent.left id: image
anchors.leftMargin: 30 Layout.rightMargin: 6
anchors.top: parent.top width: 18
anchors.topMargin: 40 height: 18
source: "qrc:/qt/qml/AntiClipSettings/resources/successfull.svg" source: "qrc:/qt/qml/AntiClipSettings/resources/successfull.svg"
} }
Text {
Text { id: titleLabel
id: titleLabel font.family: control.font.family
anchors.left: parent.left font.pixelSize: 16
anchors.leftMargin: 60 color: "#0A1F44"
anchors.top: parent.top horizontalAlignment: Text.AlignHCenter
anchors.topMargin: 40 verticalAlignment: Text.AlignVCenter
font.family: control.font.family }
font.pixelSize: 16 }
color: "#0A1F44" Label {
horizontalAlignment: Text.AlignHCenter id: textLabel
verticalAlignment: Text.AlignVCenter Layout.leftMargin: 30 + image.width+image.Layout.rightMargin+layout.spacing
} Layout.maximumWidth: control.width-Layout.leftMargin-control.rightPadding-control.rightInset-50
font.family: control.font.family
Text { font.pixelSize: 14
id: textLabel color: "#53627C"
anchors.left: parent.left horizontalAlignment: Text.AlignLeft
anchors.leftMargin: 60
anchors.right: parent.right
anchors.rightMargin: 40
anchors.top: parent.top
anchors.topMargin: 76
font.family: control.font.family
font.pixelSize: 14
color: "#53627C"
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
}
Button {
id: cancelButton
width: 72
height: 40
anchors.right: parent.right
anchors.rightMargin: 15
anchors.bottom: parent.bottom
anchors.bottomMargin: 15
font.family: control.font.family
text: "关闭"
font.pixelSize: 14
contentItem: Text {
text: parent.text
font: parent.font
color: parent.down ? "#FFFFFF" : "#53627C"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
} }
background: Rectangle { Button {
border.color: "#E1E4E8" id: cancelButton
border.width: 1 Layout.alignment: Qt.AlignRight
color: parent.down ? "#F25959" : "#FFFFFF" Layout.rightMargin: 6
radius: 2 Layout.preferredWidth: 72
Layout.preferredHeight: 40
font.family: control.font.family
text: "关闭"
font.pixelSize: 14
contentItem: Text {
text: parent.text
font: parent.font
color: parent.down ? "#FFFFFF" : "#53627C"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
border.color: "#E1E4E8"
border.width: 1
color: parent.down ? "#F25959" : "#FFFFFF"
radius: 2
}
onClicked: control.reject()
} }
onClicked: control.reject()
} }
onTypeChanged: { onTypeChanged: {
if (type === MessageDialog.Type.Successful || type === MessageDialog.Type.Ok) { if (type === MessageDialog.Type.Successful || type === MessageDialog.Type.Ok) {
image.source = "qrc:/qt/qml/AntiClipSettings/resources/successfull.svg" image.source = "qrc:/qt/qml/AntiClipSettings/resources/successfull.svg"
} else if (type === MessageDialog.Type.Warning) { } else if (type === MessageDialog.Type.Warning) {
image.source = "qrc:/qt/qml/AntiClipSettings/resources/warning.svg" image.source = "qrc:/qt/qml/AntiClipSettings/resources/warning.svg"
} else if(type === MessageDialog.Type.Failed){ } else if (type === MessageDialog.Type.Failed) {
image.source = "qrc:/qt/qml/AntiClipSettings/resources/prompt_delete.svg" image.source = "qrc:/qt/qml/AntiClipSettings/resources/prompt_delete.svg"
} }
} }