Libplasma

ProgressBar.qml
1/*
2 SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import QtQuick.Templates as T
9import org.kde.ksvg as KSvg
10//NOTE: importing PlasmaCore is necessary in order to make KSvg load the current Plasma Theme
11import org.kde.plasma.core as PlasmaCore
12import org.kde.kirigami as Kirigami
13
14T.ProgressBar {
15 id: control
16
17 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
18 implicitContentWidth + leftPadding + rightPadding)
19 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
20 implicitContentHeight + topPadding + bottomPadding)
21
22 hoverEnabled: false
23
24 KSvg.Svg {
25 id: barSvg
26 imagePath: "widgets/bar_meter_horizontal"
27 // FIXME
28 colorSet: control.Kirigami.Theme.colorSet
29 }
30
31 contentItem: Item {
32 implicitWidth: Kirigami.Units.gridUnit * 8
33 implicitHeight: children[0].height
34
36 readonly property real indeterminateWidth: Math.round(control.availableWidth / 4)
37 property real indeterminateProgress: 0
38
39 imagePath: "widgets/bar_meter_horizontal"
40 prefix: "bar-active"
41
42 LayoutMirroring.enabled: control.mirrored
43 anchors.left: parent.left
44 anchors.leftMargin: control.indeterminate ? indeterminateProgress * (control.availableWidth - indeterminateWidth) : 0
45 anchors.verticalCenter: parent.verticalCenter
46
47 // unlike Slider, this width is allowed to be less than its minimum (margins) size, in which case it would not render at all.
48 width: control.indeterminate ? indeterminateWidth : Math.round(control.position * control.availableWidth)
49 height: barSvg.hasElement("hint-bar-size")
50 ? barSvg.elementSize("hint-bar-size").height
51 : fixedMargins.top + fixedMargins.bottom
52
53 visible: width >= fixedMargins.left + fixedMargins.right
54
55 SequentialAnimation on indeterminateProgress {
56 loops: Animation.Infinite
57 running: control.indeterminate && control.contentItem.visible
58
59 NumberAnimation {
60 duration: Kirigami.Units.humanMoment / 2
61 easing.type: Easing.InOutSine
62 to: 1
63 }
64 NumberAnimation {
65 duration: Kirigami.Units.humanMoment / 2
66 easing.type: Easing.InOutSine
67 to: 0
68 }
69 }
70 }
71 }
72
73 background: Item {
74 implicitWidth: Kirigami.Units.gridUnit * 8
75 implicitHeight: children[0].height
76
78 imagePath: "widgets/bar_meter_horizontal"
79 prefix: "bar-inactive"
80
81 anchors.centerIn: parent
82 width: Math.max(parent.width, fixedMargins.left + fixedMargins.right)
83 height: barSvg.hasElement("hint-bar-size")
84 ? barSvg.elementSize("hint-bar-size").height
85 : fixedMargins.top + fixedMargins.bottom
86 }
87 }
88}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:34:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.