FluentUI/src/controls/FluProgressBar.qml

49 lines
1.2 KiB
QML
Raw Normal View History

2023-02-28 23:57:55 +08:00
import QtQuick 2.12
import QtQuick.Controls 2.12
2023-02-26 23:47:07 +08:00
2023-02-28 23:57:55 +08:00
FluRectangle {
id: control
2023-02-26 23:47:07 +08:00
2023-02-28 23:57:55 +08:00
width: 180
height: 6
radius: [3,3,3,3]
clip: true
2023-03-06 14:22:13 +08:00
color: FluTheme.isDark ? Qt.rgba(41/255,41/255,41/255,1) : Qt.rgba(214/255,214/255,214/255,1)
2023-03-01 11:58:30 +08:00
property real progress: 0.5
2023-02-28 23:57:55 +08:00
property bool indeterminate: true
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-02-28 23:57:55 +08:00
radius: 3
width: control.width*progress
height: control.height
2023-03-06 14:22:13 +08:00
color:FluTheme.isDark ? 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
}