This commit is contained in:
zhuzichu 2023-07-25 17:57:37 +08:00
parent 7122407b0b
commit b22e79148b
5 changed files with 111 additions and 113 deletions

View File

@ -63,12 +63,15 @@ FluScrollablePage{
onFinish: { onFinish: {
btn_download.disabled = false btn_download.disabled = false
btn_download.text = "下载文件" btn_download.text = "下载文件"
text_file_size.text = ""
} }
onDownloadProgress: onDownloadProgress:
(recv,total)=>{ (recv,total)=>{
var locale = Qt.locale()
var precent = (recv/total * 100).toFixed(0) + "%" var precent = (recv/total * 100).toFixed(0) + "%"
console.debug(precent) console.debug(precent)
btn_download.text = "下载中..."+precent btn_download.text = "下载中..."+precent
text_file_size.text = "%1/%2".arg(locale.formattedDataSize(recv)).arg(locale.formattedDataSize(total))
} }
onError: onError:
(status,errorString)=>{ (status,errorString)=>{
@ -101,6 +104,7 @@ FluScrollablePage{
http_post.post({k:"jitpack"}) http_post.post({k:"jitpack"})
} }
} }
RowLayout{
FluButton{ FluButton{
id:btn_download id:btn_download
text:disabled ? "下载中..." : "下载文件" text:disabled ? "下载中..." : "下载文件"
@ -108,6 +112,12 @@ FluScrollablePage{
file_dialog.open() file_dialog.open()
} }
} }
FluText{
id:text_file_size
Layout.alignment: Qt.AlignVCenter
}
}
} }
} }
@ -125,6 +135,7 @@ FluScrollablePage{
id:window_result id:window_result
width: 600 width: 600
height: 400 height: 400
color: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
Item{ Item{
anchors.fill: parent anchors.fill: parent
Flickable{ Flickable{

View File

@ -12,7 +12,7 @@ FluScrollablePage{
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 110 height: 130
paddings: 10 paddings: 10
ColumnLayout{ ColumnLayout{
@ -45,7 +45,7 @@ FluProgressRing{
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 20 Layout.topMargin: 20
height: 230 height: 286
paddings: 10 paddings: 10
ColumnLayout{ ColumnLayout{
@ -59,21 +59,24 @@ FluProgressRing{
} }
FluProgressBar{ FluProgressBar{
indeterminate: false indeterminate: false
progress: slider.value/100 value:slider.value/100
} Layout.topMargin: 10
FluProgressRing{
indeterminate: false
progress: slider.value/100
} }
FluProgressBar{ FluProgressBar{
indeterminate: false indeterminate: false
value:slider.value/100
progressVisible: true progressVisible: true
progress: slider.value/100 Layout.topMargin: 10
} }
FluProgressRing{ FluProgressRing{
indeterminate: false indeterminate: false
value: slider.value/100
Layout.topMargin: 10
}
FluProgressRing{
progressVisible: true progressVisible: true
progress: slider.value/100 indeterminate: false
value: slider.value/100
} }
FluSlider{ FluSlider{
id:slider id:slider

View File

@ -164,7 +164,7 @@ CustomWindow {
height: parent.height height: parent.height
z:999 z:999
//StackpopFluPagelaunchMode //StackpopFluPagelaunchMode
// pageMode: FluNavigationViewType.Stack pageMode: FluNavigationViewType.Stack
//NoStack //NoStack
// pageMode: FluNavigationViewType.NoStack // pageMode: FluNavigationViewType.NoStack
items: ItemsOriginal items: ItemsOriginal

View File

@ -2,56 +2,48 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import FluentUI import FluentUI
Item{ ProgressBar{
property real strokeWidth: 6
property real progress: 0.5
property bool indeterminate: true
property bool progressVisible: false property bool progressVisible: false
id: control property color color: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
width: 150 property color backgroundColor : FluTheme.dark ? Qt.rgba(99/255,99/255,99/255,1) : Qt.rgba(214/255,214/255,214/255,1)
height: 5 id:control
indeterminate : true
FluRectangle { QtObject{
shadow: false id:d
radius: [3,3,3,3] property real _radius: strokeWidth/2
anchors.fill: parent
color: FluTheme.dark ? Qt.rgba(99/255,99/255,99/255,1) : Qt.rgba(214/255,214/255,214/255,1)
Component.onCompleted: {
if(indeterminate){
bar.x = -control.width*0.5
behavior.enabled = true
bar.x = control.width
}else{
bar.x = 0
} }
background: Rectangle {
implicitWidth: 150
implicitHeight: control.strokeWidth
color: control.backgroundColor
radius: d._radius
} }
Rectangle{ contentItem: FluItem {
id:bar clip: true
radius: 3 radius: [d._radius,d._radius,d._radius,d._radius]
width: control.width*progress Rectangle {
height: control.height id:rect_progress
color:FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark width: {
Behavior on x{ if(control.indeterminate){
id:behavior return 0.5 * parent.width
enabled: false }
NumberAnimation{ return control.visualPosition * parent.width
duration: 1000 }
onRunningChanged: { height: parent.height
if(!running){ radius: d._radius
behavior.enabled = false color: control.color
bar.x = -control.width*0.5 PropertyAnimation on x {
behavior.enabled = true running: control.indeterminate && control.visible
bar.x = control.width from: -rect_progress.width
to:control.width+rect_progress.width
loops: Animation.Infinite
duration: 888
} }
} }
} }
}
}
}
FluText{ FluText{
text:(control.progress * 100).toFixed(0) + "%" text:(control.visualPosition * 100).toFixed(0) + "%"
font.pixelSize: 10
visible: { visible: {
if(control.indeterminate){ if(control.indeterminate){
return false return false

View File

@ -1,32 +1,31 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Shapes
import FluentUI import FluentUI
Rectangle { ProgressBar{
property real linWidth : 5 property real strokeWidth: 6
property real progress: 0.25
property bool indeterminate: true
property color primaryColor : FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property bool progressVisible: false property bool progressVisible: false
id: control property color color: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
width: 44 property color backgroundColor : FluTheme.dark ? Qt.rgba(99/255,99/255,99/255,1) : Qt.rgba(214/255,214/255,214/255,1)
height: 44 id:control
radius: width/2 indeterminate : true
border.width: linWidth clip: true
color: "#00000000" background: Rectangle {
border.color: FluTheme.dark ? Qt.rgba(99/255,99/255,99/255,1) : Qt.rgba(214/255,214/255,214/255,1) implicitWidth: 56
onProgressChanged: { implicitHeight: 56
canvas.requestPaint() radius: control.width/2
} color:"transparent"
Component.onCompleted: { border.color: control.backgroundColor
if(indeterminate){ border.width: control.strokeWidth
behavior.enabled = true
control.rotation = 360
}
} }
QtObject{ QtObject{
id:d id:d
property real _radius: control.radius-control.linWidth/2 property real _radius: control.width/2-control.strokeWidth/2
property real _progress: control.indeterminate ? 0.3 : control.visualPosition
on_ProgressChanged: {
canvas.requestPaint()
}
} }
Connections{ Connections{
target: FluTheme target: FluTheme
@ -34,20 +33,13 @@ Rectangle {
canvas.requestPaint() canvas.requestPaint()
} }
} }
Behavior on rotation{ contentItem: Item {
id:behavior RotationAnimation on rotation {
enabled: false running: control.indeterminate && control.visible
NumberAnimation{ from: 0
duration: 999 to:360
onRunningChanged: { loops: Animation.Infinite
if(!running){ duration: 888
behavior.enabled = false
control.rotation = 0
behavior.enabled = true
control.rotation = 360
}
}
}
} }
Canvas { Canvas {
id:canvas id:canvas
@ -58,19 +50,18 @@ Rectangle {
var ctx = canvas.getContext("2d") var ctx = canvas.getContext("2d")
ctx.clearRect(0, 0, canvas.width, canvas.height) ctx.clearRect(0, 0, canvas.width, canvas.height)
ctx.save() ctx.save()
ctx.lineWidth = linWidth ctx.lineWidth = control.strokeWidth
ctx.strokeStyle = primaryColor ctx.strokeStyle = control.color
ctx.fillStyle = primaryColor
ctx.beginPath() ctx.beginPath()
ctx.arc(width/2, height/2, d._radius ,-0.5 * Math.PI,-0.5 * Math.PI + progress * 2 * Math.PI) ctx.arc(width/2, height/2, d._radius ,-0.5 * Math.PI,-0.5 * Math.PI + d._progress * 2 * Math.PI)
ctx.stroke() ctx.stroke()
ctx.closePath() ctx.closePath()
ctx.restore() ctx.restore()
} }
} }
}
FluText{ FluText{
text:(control.progress * 100).toFixed(0) + "%" text:(control.visualPosition * 100).toFixed(0) + "%"
font.pixelSize: 10
visible: { visible: {
if(control.indeterminate){ if(control.indeterminate){
return false return false
@ -80,3 +71,4 @@ Rectangle {
anchors.centerIn: parent anchors.centerIn: parent
} }
} }