blob: 33999fa872be05730371fac16f78e808727acd13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
import QtQuick.Controls.impl
import QtQuick.Controls.FluentWinUI3.impl as Impl
import QtQuick.Templates as T
import QtQuick.Effects
T.ProgressBar {
id: control
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
topPadding: __config.topPadding || 0
bottomPadding: __config.bottomPadding || 0
leftPadding: __config.leftPadding || 0
rightPadding: __config.rightPadding || 0
topInset: -__config.topInset || 0
bottomInset: -__config.bottomInset || 0
leftInset: -__config.leftInset || 0
rightInset: -__config.rightInset || 0
readonly property string __currentState: [
!control.enabled && "disabled",
control.indeterminate && "indeterminate"
].filter(Boolean).join("_") || "normal"
readonly property var __config: Config.controls.progressbar[__currentState] || {}
contentItem: Item {
implicitWidth: control.indeterminate ? parent.availableWidth : progress.implicitWidth
implicitHeight: control.indeterminate ? control.__config.track.height : progress.implicitHeight
scale: control.mirrored ? -1 : 1
clip: control.indeterminate
readonly property Rectangle progress: Rectangle {
x: control.background.groove?.x - 1
y: control.background.groove?.y - 1
parent: control.contentItem
visible: !control.indeterminate && control.value
implicitWidth: control.__config.track.width
implicitHeight: control.__config.track.height
width: control.position * parent.width
height: control.__config.track.height
radius: control.__config.track.height * 0.5
color: control.palette.accent
}
readonly property Rectangle animatedProgress: Rectangle {
parent: control.contentItem
implicitWidth: parent.width
implicitHeight: control.__config.track.height
radius: control.__config.track.height * 0.5
clip: true
visible: false
color: "transparent"
Rectangle {
width: 0.5 * parent.width
height: control.__config.track.height
radius: control.__config.track.height * 0.5
color: control.palette.accent
SequentialAnimation on x {
loops: Animation.Infinite
running: control.indeterminate && control.visible
NumberAnimation {
from: -control.contentItem.animatedProgress.width
to: control.contentItem.width
easing.type: Easing.InOutCubic
duration: control.width * 8
}
NumberAnimation {
from: -control.contentItem.animatedProgress.width * 0.5
to: control.contentItem.width
easing.type: Easing.InOutCubic
duration: control.width * 5
}
}
}
}
readonly property Rectangle mask: Rectangle {
parent: control.contentItem
width: control.availableWidth
height: control.contentItem.animatedProgress.height
radius: control.contentItem.animatedProgress.radius
visible: false
color: control.palette.accent
layer.enabled: true
antialiasing: false
}
MultiEffect {
visible: control.indeterminate
source: control.contentItem.animatedProgress
width: control.contentItem.animatedProgress.width
height: control.contentItem.animatedProgress.height
maskEnabled: true
maskSource: control.contentItem.mask
}
}
background: Item {
implicitWidth: groove.width
property Item groove: Impl.StyleImage {
imageConfig: control.__config.groove
visible: !control.indeterminate
parent: control.background
height: implicitHeight
width: parent.width
x: (parent.width - width) / 2
y: (parent.height - height) / 2
}
}
}
|