1/* 2 SPDX-FileCopyrightText: 2014 Kai Uwe Broulik <kde@privat.broulik.de> 3 SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org> 4 5 SPDX-License-Identifier: LGPL-2.0-or-later 6*/ 7 8import QtQuick 2.2 9import QtQuick.Templates @QQC2_VERSION@ as T 10import org.kde.plasma.core 2.0 as PlasmaCore 11 12T.BusyIndicator { 13 id: control 14 15 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, 16 implicitContentWidth + leftPadding + rightPadding) 17 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, 18 implicitContentHeight + topPadding + bottomPadding) 19 20 /* PC2 BusyIndicator didn't have padding or margins and 21 * BusyIndicator doesn't need padding since it has no background. 22 * A Control containing a BusyIndicator can have padding instead 23 * (e.g., a ToolBar, a Page or maybe a widget in a Plasma panel). 24 */ 25 padding: 0 26 27 contentItem: Item { 28 id: baseItem 29 /* implicitWidth and implicitHeight won't work unless they come 30 * from a child of the contentItem. No idea why. 31 */ 32 implicitWidth: PlasmaCore.Units.gridUnit * 2 33 implicitHeight: implicitWidth 34 35 visible: opacity > 0 36 opacity: control.running ? 1.0 : 0.0 37 Behavior on opacity { 38 OpacityAnimator { 39 duration: PlasmaCore.Units.shortDuration 40 easing.type: Easing.OutQuad 41 } 42 } 43 44 PlasmaCore.SvgItem { 45 id: busyIndicatorSvgItem 46 47 /* Do not use `anchors.fill: parent` in here or else 48 * the aspect ratio won't always be 1:1. 49 */ 50 width: Math.min(parent.width, parent.height) 51 height: width 52 53 svg: PlasmaCore.Svg { 54 imagePath: "widgets/busywidget" 55 colorGroup: PlasmaCore.ColorScope.colorGroup 56 } 57 elementId: "busywidget" 58 59 RotationAnimator on rotation { 60 id: rotationAnimator 61 from: 0 62 to: 360 63 // Not using a standard duration value because we don't want the 64 // animation to spin faster or slower based on the user's animation 65 // scaling preferences; it doesn't make sense in this context 66 duration: 2000 67 loops: Animation.Infinite 68 // Don't want it to animate at all if the user has disabled animations 69 running: visible && (control.running || baseItem.opacity > 0) && PlasmaCore.Units.longDuration > 1; 70 } 71 } 72 } 73} 74