整理对话框布局。

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") {
LOG(info) << "md5 check finished";
m_otaProgress = 99;
if (m_otaTimer != nullptr) {
m_otaTimer->stop();
}
emit otaProgressChanged(true, m_otaProgress, "设备正在升级中,请稍后......");
QTimer::singleShot(0, this, [this]() {
m_commandSocket->close(); // 等待设备重新上线后,发起广播。由搜索服务触发重连

View File

@ -99,14 +99,6 @@ std::shared_ptr<DeviceConnection> DeviceListModel::device(int index) {
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() {
if (m_timerId >= 0) {
LOG(error) << "app is searching device.";

View File

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

View File

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

View File

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