| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- 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: ymodem
- onDownloadStart: {
- progressBar.value = 0.0
- notificationtext.text = mtype
- notificationPage.visible = true
- }
- onProgress: {
- console.log("更新进度条:",val,tval)
- progressBar.value = val/tval*100.0
- process_text.text = progressBar.value.toFixed(2) + "%";
- }
- onModem_result: {
- if(r===0){
- progressBar.value = 100.0
- notificationtext.text += "成功"
- }else{
- notificationtext.text += "失败:" + r.toString();
- }
- }
- }
- Connections{
- target: curl
- onSglProgress:{
- //console.log("更新进度条:",val,timeLeft)
- progressBar.value = val
- process_text.text = val.toFixed(2) + "%";
- }
- onDownloadStart:{
- notificationtext.text = mtype
- notificationPage.visible = true
- }
- onDownloadFinished :{
- //notificationPage.visible = false
- if(result){
- notificationtext.text += "成功"
- notificationtext.color = "green"
- }else{
- notificationtext.text += "失败"
- notificationtext.color = "red"
- }
- }
- }
- Connections{
- target:curl_picture
- onProgressChanged:{
- console.log("更新进度条:",uploadedPercent)
- progressBar.value = uploadedPercent
- process_text.text = uploadedPercent.toFixed(2) + "%";
- }
- onDownloadStart:function(tips){
- notificationPage.visible = true
- notificationtext.text = tips
- }
- onFinished :function(success,error){
- //notificationPage.visible = false
- if(success){
- notificationtext.color = "green"
- }else{
- notificationtext.text += error
- notificationtext.color = "red"
- }
- }
- }
- // 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;
- }
- }
- }
- }
|