This commit is contained in:
zhuzichu
2023-09-05 16:48:04 +08:00
parent 54be482833
commit d93d6b7c26
15 changed files with 422 additions and 107 deletions

View File

@ -138,7 +138,8 @@ FluExpander{
"FluTimeline",
"FluChart",
"FluRangeSlider",
"FluStaggeredView"
"FluStaggeredView",
"FluProgressButton"
];
code = code.replace(/\n/g, "<br>");
code = code.replace(/ /g, "&nbsp;");

View File

@ -161,6 +161,58 @@ FluScrollablePage{
}'
}
Timer{
id:timer_progress
interval: 200
onTriggered: {
btn_progress.progress = (btn_progress.progress + 0.1).toFixed(1)
if(btn_progress.progress==1){
timer_progress.stop()
}else{
timer_progress.start()
}
}
}
FluArea{
Layout.fillWidth: true
height: 68
Layout.topMargin: 20
paddings: 10
FluProgressButton{
id:btn_progress
disabled:progress_button_switch.checked
text:"Progress Button"
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
onClicked: {
btn_progress.progress = 0
timer_progress.restart()
}
}
FluToggleSwitch{
id:progress_button_switch
anchors{
right: parent.right
verticalCenter: parent.verticalCenter
}
text:"Disabled"
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluProgressButton{
text:"Progress Button"
onClicked: {
}
}'
}
FluArea{
Layout.fillWidth: true

View File

@ -115,7 +115,7 @@ FluContentPage{
http.postString("https://httpbingo.org/post",callable,param)
}
}
FluButton{
FluProgressButton{
id:btn_download
implicitWidth: parent.width
implicitHeight: 36
@ -124,7 +124,7 @@ FluContentPage{
folder_dialog.open()
}
}
FluButton{
FluProgressButton{
id:btn_upload
implicitWidth: parent.width
implicitHeight: 36
@ -198,12 +198,10 @@ FluContentPage{
}
onFinish: {
btn_upload.disabled = false
btn_upload.text = "上传文件"
layout_upload_file_size.visible = false
text_upload_file_size.text = ""
}
onError:
(status,errorString,result)=>{
btn_upload.progress = 0
text_info.text = result
console.debug(result)
}
@ -213,11 +211,7 @@ FluContentPage{
}
onUploadProgress:
(sent,total)=>{
var locale = Qt.locale()
var precent = (sent/total * 100).toFixed(0) + "%"
btn_upload.text = "上传中..."+precent
text_upload_file_size.text = "%1/%2".arg(locale.formattedDataSize(sent)).arg(locale.formattedDataSize(total))
layout_upload_file_size.visible = true
btn_upload.progress = sent/total
}
}
@ -242,12 +236,10 @@ FluContentPage{
}
onFinish: {
btn_download.disabled = false
btn_download.text = "下载文件"
layout_download_file_size.visible = false
text_download_file_size.text = ""
}
onError:
(status,errorString,result)=>{
btn_download.progress = 0
showError(errorString)
console.debug(status+";"+errorString+";"+result)
}
@ -257,11 +249,7 @@ FluContentPage{
}
onDownloadProgress:
(recv,total)=>{
var locale = Qt.locale()
var precent = (recv/total * 100).toFixed(0) + "%"
btn_download.text = "下载中..."+precent
text_download_file_size.text = "%1/%2".arg(locale.formattedDataSize(recv)).arg(locale.formattedDataSize(total))
layout_download_file_size.visible = true
btn_download.progress = recv/total
}
}
@ -300,32 +288,4 @@ FluContentPage{
}
}
FluRectangle{
id:layout_download_file_size
radius: [4,4,4,4]
height: 36
width: 160
visible: false
x:layout_flick.width
y: 173 - layout_flick.contentY
FluText{
id:text_download_file_size
anchors.centerIn: parent
}
}
FluRectangle{
id:layout_upload_file_size
radius: [4,4,4,4]
height: 36
width: 160
visible: false
x:layout_flick.width
y: 210 - layout_flick.contentY
FluText{
id:text_upload_file_size
anchors.centerIn: parent
}
}
}

View File

@ -138,7 +138,8 @@ FluExpander{
"FluTimeline",
"FluChart",
"FluRangeSlider",
"FluStaggeredView"
"FluStaggeredView",
"FluProgressButton"
];
code = code.replace(/\n/g, "<br>");
code = code.replace(/ /g, "&nbsp;");

View File

@ -161,6 +161,58 @@ FluScrollablePage{
}'
}
Timer{
id:timer_progress
interval: 200
onTriggered: {
btn_progress.progress = (btn_progress.progress + 0.1).toFixed(1)
if(btn_progress.progress==1){
timer_progress.stop()
}else{
timer_progress.start()
}
}
}
FluArea{
Layout.fillWidth: true
height: 68
Layout.topMargin: 20
paddings: 10
FluProgressButton{
id:btn_progress
disabled:progress_button_switch.checked
text:"Progress Button"
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
onClicked: {
btn_progress.progress = 0
timer_progress.restart()
}
}
FluToggleSwitch{
id:progress_button_switch
anchors{
right: parent.right
verticalCenter: parent.verticalCenter
}
text:"Disabled"
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluProgressButton{
text:"Progress Button"
onClicked: {
}
}'
}
FluArea{
Layout.fillWidth: true

View File

@ -8,6 +8,7 @@ import FluentUI 1.0
import "qrc:///example/qml/component"
import "../component"
FluContentPage{
title:"Http"
@ -116,7 +117,7 @@ FluContentPage{
http.postString("https://httpbingo.org/post",callable,param)
}
}
FluButton{
FluProgressButton{
id:btn_download
implicitWidth: parent.width
implicitHeight: 36
@ -125,7 +126,7 @@ FluContentPage{
folder_dialog.open()
}
}
FluButton{
FluProgressButton{
id:btn_upload
implicitWidth: parent.width
implicitHeight: 36
@ -199,12 +200,10 @@ FluContentPage{
}
onFinish: {
btn_upload.disabled = false
btn_upload.text = "上传文件"
layout_upload_file_size.visible = false
text_upload_file_size.text = ""
}
onError:
(status,errorString,result)=>{
btn_upload.progress = 0
text_info.text = result
console.debug(result)
}
@ -214,11 +213,7 @@ FluContentPage{
}
onUploadProgress:
(sent,total)=>{
var locale = Qt.locale()
var precent = (sent/total * 100).toFixed(0) + "%"
btn_upload.text = "上传中..."+precent
text_upload_file_size.text = "%1/%2".arg(locale.formattedDataSize(sent)).arg(locale.formattedDataSize(total))
layout_upload_file_size.visible = true
btn_upload.progress = sent/total
}
}
@ -243,12 +238,10 @@ FluContentPage{
}
onFinish: {
btn_download.disabled = false
btn_download.text = "下载文件"
layout_download_file_size.visible = false
text_download_file_size.text = ""
}
onError:
(status,errorString,result)=>{
btn_download.progress = 0
showError(errorString)
console.debug(status+";"+errorString+";"+result)
}
@ -258,11 +251,7 @@ FluContentPage{
}
onDownloadProgress:
(recv,total)=>{
var locale = Qt.locale()
var precent = (recv/total * 100).toFixed(0) + "%"
btn_download.text = "下载中..."+precent
text_download_file_size.text = "%1/%2".arg(locale.formattedDataSize(recv)).arg(locale.formattedDataSize(total))
layout_download_file_size.visible = true
btn_download.progress = recv/total
}
}
@ -301,32 +290,4 @@ FluContentPage{
}
}
FluRectangle{
id:layout_download_file_size
radius: [4,4,4,4]
height: 36
width: 160
visible: false
x:layout_flick.width
y: 173 - layout_flick.contentY
FluText{
id:text_download_file_size
anchors.centerIn: parent
}
}
FluRectangle{
id:layout_upload_file_size
radius: [4,4,4,4]
height: 36
width: 160
visible: false
x:layout_flick.width
y: 210 - layout_flick.contentY
FluText{
id:text_upload_file_size
anchors.centerIn: parent
}
}
}