import Felgo import QtQuick import QtQuick.Layouts import QtQuick.Controls import "../controls" import "../common" AppPage { id: notificationPage backgroundColor: Qt.rgba(0,0,0, 0.75) // page background is translucent, we can see other items beneath the page useSafeArea: false // do not consider safe area insets of screen Connections{ target: serial function onYmodemReady(mtype) { progressBar.value = 0.0 notificationtext.text = mtype notificationPage.visible = true } function onYmodemProgress(val,tval) { //console.log("更新进度条:",val,tval) var percent = Number(val) / Number(tval) * 100.0 percent = Math.min(percent,100) console.log("更新进度:",percent) progressBar.value = percent process_text.text = percent.toFixed(2) + "%" } function onYmodemFinished(r) { if(r===0){ progressBar.value = 100.0 notificationtext.text += "成功" }else{ notificationtext.text += "失败:" + r.toString(); } } } Connections{ target:curl function onSglProgress(val,timeLeft,speed) { console.log("更新curl进度条:",val,timeLeft) progressBar.value = val process_text.text = val.toFixed(2) + "%"; } function onDownloadStart(mtype) { notificationtext.text = mtype notificationPage.visible = true } function onDownloadFinished(result){ //notificationPage.visible = false if(result){ notificationtext.text += "成功" notificationtext.color = "green" }else{ notificationtext.text += "失败" notificationtext.color = "red" } } } // 图片上传进度已改为 TestPage 右上角 32 格进度网格展示, 不再弹出上传进度窗口 Connections{ target:curl_picture function onProgressChanged(uploadedPercent){ } function onDownloadStart(tips){ } function onFinished(success,error){ } } // login form background Rectangle { id: loginForm anchors.centerIn: parent color: "white" width: content.width + dp(48) height: content.height + dp(16) radius: dp(4) } // login form content GridLayout { id: content anchors.centerIn: loginForm columnSpacing: dp(20) rowSpacing: dp(10) columns: 2 width: Math.min(parent.width * 0.9, dp(400)) // 限制最大宽度 // headline AppText { id: notificationtext Layout.topMargin: dp(8) Layout.bottomMargin: dp(12) Layout.columnSpan: 2 Layout.alignment: Qt.AlignHCenter text: "通知" Layout.preferredWidth: parent.width * 0.8 // 设置最大宽度 Layout.maximumWidth: dp(300) // 限制最大宽度 wrapMode: Text.Wrap // 关键换行属性 horizontalAlignment: Text.AlignHCenter // 保持居中 height: implicitHeight // 自动高度 } AppText { id: process_text Layout.bottomMargin: dp(5) Layout.columnSpan: 2 Layout.alignment: Qt.AlignHCenter text: "" } // 进度条行(占满第一列) ProgressBar { id: progressBar Layout.fillWidth: true // 关键属性:填充可用宽度 Layout.columnSpan: 1 // 占第一列 from: 0.0000 to: 100.0000 value: 0.0 // 根据父布局动态计算宽度 //implicitWidth: content.width - closeButton.width - content.columnSpacing } // 按钮行(第二列) AppButton { id: closeButton Layout.columnSpan: 1 // 占第二列 Layout.alignment: Qt.AlignRight text: qsTr("关闭") flat: false // 固定按钮宽度 implicitWidth: dp(80) onClicked: { progressBar.value = 0.0; notificationPage.visible = false; } } } }