Warning, /plasma/qqc2-breeze-style/style/qtquickcontrols/BusyIndicator.qml is written in an unsupported language. File is not indexed.
0001 /* SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com>
0002 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0003 */
0004
0005 import QtQuick
0006 import QtQuick.Templates as T
0007 import org.kde.kirigami as Kirigami
0008 import org.kde.quickcharts as Charts
0009
0010 import org.kde.breeze.impl as Impl
0011
0012 T.BusyIndicator {
0013 id: control
0014
0015 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
0016 implicitContentWidth + leftPadding + rightPadding)
0017 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
0018 implicitContentHeight + topPadding + bottomPadding)
0019
0020 hoverEnabled: false
0021
0022 padding: Kirigami.Units.mediumSpacing
0023
0024 ListModel {
0025 id: pieModel
0026 dynamicRoles: true
0027
0028 property color oddColor: Kirigami.Theme.focusColor
0029 property color evenColor: "transparent"
0030
0031 // The ends periodically appear to connect,
0032 // forming a six sided asterisk-like shape with no center area
0033
0034 Component.onCompleted: {
0035 append({ value: 1, color: oddColor })
0036 append({ value: 2, color: evenColor })
0037 append({ value: 2, color: oddColor })
0038 append({ value: 2, color: evenColor })
0039 append({ value: 2, color: oddColor })
0040 append({ value: 2, color: evenColor })
0041 append({ value: 2, color: oddColor })
0042 append({ value: 2, color: evenColor })
0043 append({ value: 2, color: oddColor })
0044 append({ value: 2, color: evenColor })
0045 append({ value: 2, color: oddColor })
0046 append({ value: 2, color: evenColor })
0047 append({ value: 1, color: oddColor })
0048 }
0049 }
0050
0051 contentItem: Loader {
0052 sourceComponent: GraphicsInfo.api == GraphicsInfo.Software ?
0053 lowPowerSpinnerComponent : fancySpinnerComponent
0054 }
0055
0056 Component {
0057 id: lowPowerSpinnerComponent
0058 Kirigami.Icon {
0059 id: lowPowerSpinner
0060 implicitWidth: Kirigami.Units.iconSizes.sizeForLabels
0061 implicitHeight: Kirigami.Units.iconSizes.sizeForLabels
0062 source: "view-refresh"
0063
0064 opacity: control.visible && control.enabled && control.running ? 1 : 0
0065 Behavior on opacity {
0066 OpacityAnimator { duration: Kirigami.Units.shortDuration }
0067 }
0068
0069 smooth: true
0070 RotationAnimator {
0071 target: lowPowerSpinner
0072 running: control.visible && control.enabled && control.running
0073 from: 0
0074 to: 360
0075 loops: Animation.Infinite
0076 duration: 1500
0077 }
0078 }
0079 }
0080
0081 Component {
0082 id: fancySpinnerComponent
0083 Charts.PieChart {
0084 id: fancySpinner
0085 implicitWidth: Kirigami.Units.gridUnit
0086 implicitHeight: Kirigami.Units.gridUnit
0087
0088 opacity: control.visible && control.enabled && control.running ? 1 : 0
0089 Behavior on opacity {
0090 OpacityAnimator { duration: Kirigami.Units.shortDuration }
0091 }
0092
0093 valueSources: Charts.ModelSource { roleName: "value"; model: pieModel }
0094 colorSource: Charts.ModelSource { roleName: "color"; model: pieModel }
0095
0096 fromAngle: 0
0097 toAngle: 360
0098 thickness: Math.max(Impl.Units.smallRadius * 2, Math.floor(Math.min(width, height)/6))
0099 filled: false
0100 //smoothEnds: true // Turns the segments into aesthetically pleasing round dots, but breaks the connected appearance when the ends meet :(
0101
0102 ParallelAnimation {
0103 running: control.visible && control.enabled && control.running
0104 SequentialAnimation {
0105 loops: Animation.Infinite
0106 NumberAnimation {
0107 target: fancySpinner
0108 property: "toAngle"
0109 from: 0
0110 to: 360
0111 duration: 1000
0112 }
0113 PauseAnimation {
0114 duration: 1000
0115 }
0116 NumberAnimation {
0117 target: fancySpinner
0118 property: "fromAngle"
0119 from: 0
0120 to: 360
0121 duration: 1000
0122 }
0123 PropertyAction {
0124 target: fancySpinner
0125 properties: "fromAngle,toAngle"
0126 value: 0
0127 }
0128 }
0129 SequentialAnimation {
0130 loops: Animation.Infinite
0131 RotationAnimator {
0132 target: fancySpinner
0133 from: 0
0134 to: 30
0135 duration: 1000
0136 }
0137 // This is meant to appear to rotate at the same rate as the other 2 animations.
0138 // In order to achieve this, the actual rotation rate has to be much higher than the other 2 animimations.
0139 // This is because the pie angles aren't being animated while this animation is running.
0140 RotationAnimator {
0141 target: fancySpinner
0142 from: 30
0143 to: 330
0144 duration: 1000
0145 }
0146 RotationAnimator {
0147 target: fancySpinner
0148 from: 330
0149 to: 360
0150 duration: 1000
0151 }
0152 }
0153 }
0154 }
0155 }
0156 }