FluentUI/src/controls/FluProgressBar.qml

50 lines
1.2 KiB
QML
Raw Normal View History

2023-03-30 21:52:55 +08:00
import QtQuick
import QtQuick.Controls
2023-02-26 23:47:07 +08:00
2023-02-28 23:57:55 +08:00
FluRectangle {
2023-02-26 23:47:07 +08:00
2023-03-27 18:24:35 +08:00
property real progress: 0.5
property bool indeterminate: true
id: control
2023-03-09 16:44:24 +08:00
width: 150
height: 5
2023-03-25 13:35:21 +08:00
radius: [3,3,3,3]
2023-02-28 23:57:55 +08:00
clip: true
2023-03-28 21:37:10 +08:00
color: FluTheme.dark ? Qt.rgba(41/255,41/255,41/255,1) : Qt.rgba(214/255,214/255,214/255,1)
2023-02-28 23:57:55 +08:00
Component.onCompleted: {
if(indeterminate){
2023-03-01 11:58:30 +08:00
bar.x = -control.width*0.5
behavior.enabled = true
bar.x = control.width
2023-02-28 23:57:55 +08:00
}else{
2023-03-01 11:58:30 +08:00
bar.x = 0
2023-02-28 23:57:55 +08:00
}
2023-03-01 11:58:30 +08:00
}
2023-02-28 23:57:55 +08:00
Rectangle{
2023-03-01 11:58:30 +08:00
id:bar
2023-03-25 13:35:21 +08:00
radius: 3
2023-02-28 23:57:55 +08:00
width: control.width*progress
height: control.height
2023-03-28 21:37:10 +08:00
color:FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
2023-02-28 23:57:55 +08:00
Behavior on x{
2023-03-01 11:58:30 +08:00
id:behavior
enabled: false
2023-02-28 23:57:55 +08:00
NumberAnimation{
2023-03-01 11:58:30 +08:00
duration: 1000
2023-02-28 23:57:55 +08:00
onRunningChanged: {
if(!running){
2023-03-01 11:58:30 +08:00
behavior.enabled = false
bar.x = -control.width*0.5
behavior.enabled = true
bar.x = control.width
2023-02-28 23:57:55 +08:00
}
}
}
}
}
2023-02-26 23:47:07 +08:00
}