1// Copyright (c) 2019 Ultimaker B.V.
2// Uranium is released under the terms of the LGPLv3 or higher.
3
4import QtQuick 2.10
5import QtQuick.Controls 2.3 as Controls
6
7import UM 1.3 as UM
8
9//
10// Styled progress bar, with colours from the theme and rounded corners.
11//
12Controls.ProgressBar
13{
14    id: progressBar
15    width: parent.width
16    height: UM.Theme.getSize("progressbar").height
17
18    background: Rectangle
19    {
20        anchors.fill: parent
21        radius: UM.Theme.getSize("progressbar_radius").width
22        color: UM.Theme.getColor("progressbar_background")
23    }
24
25    contentItem: Item
26    {
27        anchors.fill: parent
28
29        // The progress block for showing progress value
30        Rectangle
31        {
32            id: progressBlockDeterminate
33            x: progressBar.indeterminate ? progressBar.visualPosition * parent.width : 0
34            width: progressBar.indeterminate ? parent.width * 0.1 : progressBar.visualPosition * parent.width
35            height: parent.height
36            radius: UM.Theme.getSize("progressbar_radius").width
37            color: UM.Theme.getColor("progressbar_control")
38        }
39        SequentialAnimation
40        {
41            PropertyAnimation
42            {
43                target: progressBar
44                property: "value"
45                from: 0
46                to: 0.9 // The block is not centered, so let it go to 90% (since it's 10% long)
47                duration: 3000
48            }
49            PropertyAnimation
50            {
51                target: progressBar
52                property: "value"
53                from: 0.9 // The block is not centered, so let it go to 90% (since it's 10% long)
54                to: 0
55                duration: 3000
56            }
57
58            loops: Animation.Infinite
59            running: progressBar.visible && progressBar.indeterminate
60        }
61    }
62}
63