Warning, /system/mycroft-gui/import/qml/BusyIndicator.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright 2021 by Aditya Mehra <aix.m@outlook.com> 0003 * 0004 * Licensed under the Apache License, Version 2.0 (the "License"); 0005 * you may not use this file except in compliance with the License. 0006 * You may obtain a copy of the License at 0007 * 0008 * http://www.apache.org/licenses/LICENSE-2.0 0009 * 0010 * Unless required by applicable law or agreed to in writing, software 0011 * distributed under the License is distributed on an "AS IS" BASIS, 0012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0013 * See the License for the specific language governing permissions and 0014 * limitations under the License. 0015 * 0016 */ 0017 0018 import QtQuick 2.15 0019 import QtQuick.Controls 2.15 as Controls 0020 0021 Controls.BusyIndicator { 0022 id: control 0023 width: 200 0024 height: 200 0025 padding: 0 0026 0027 //Allow animations to be run at a slower speed if required 0028 property real speed: 1 0029 0030 onRunningChanged: { 0031 if(!running) { 0032 changeStage() 0033 } 0034 } 0035 0036 function changeStage() { 0037 canvas.startDeg = 0 0038 canvas.endDeg = 2 0039 } 0040 0041 contentItem: Canvas { 0042 id: canvas 0043 anchors.fill: parent 0044 antialiasing: true 0045 visible: control.visible 0046 0047 renderTarget: Canvas.FramebufferObject 0048 property int startDeg: 0 0049 property int endDeg: 2 0050 property color primaryColor: '#22A7F0' 0051 0052 Behavior on primaryColor { 0053 ColorAnimation { duration: 200 } 0054 } 0055 0056 onStartDegChanged: requestPaint() 0057 onEndDegChanged: requestPaint() 0058 onPrimaryColorChanged: requestPaint() 0059 0060 onPaint: { 0061 function deg2Rad(deg) { 0062 return (deg / 180) * Math.PI; 0063 } 0064 0065 var ctx = canvas.getContext('2d'); 0066 ctx.strokeStyle = primaryColor; 0067 ctx.lineWidth = 20; 0068 ctx.lineCap="round"; 0069 ctx.clearRect(0, 0, canvas.width, canvas.height); 0070 ctx.beginPath(); 0071 ctx.arc(canvas.width / 2, canvas.height / 2, (canvas.height > canvas.width ? canvas.width : canvas.height) / 2 - 20, deg2Rad(startDeg - 90), deg2Rad(endDeg - 90), false); 0072 ctx.stroke(); 0073 } 0074 } 0075 0076 SequentialAnimation { 0077 id: seqAnimator 0078 running: control.running 0079 loops: Animation.Infinite 0080 0081 ParallelAnimation { 0082 0083 NumberAnimation { 0084 target: canvas 0085 property: "endDeg" 0086 to: 360 0087 duration: 600 * control.speed 0088 easing.type: Easing.InOutQuad 0089 } 0090 0091 NumberAnimation { 0092 target: canvas 0093 property: "startDeg" 0094 to: 360 0095 duration: 900 * control.speed 0096 easing.type: Easing.InOutQuad 0097 } 0098 } 0099 0100 ScriptAction { 0101 script: changeStage() 0102 } 0103 0104 ParallelAnimation { 0105 0106 NumberAnimation { 0107 target: canvas 0108 property: "endDeg" 0109 to: 360 0110 duration: 900 * control.speed 0111 easing.type: Easing.InOutQuad 0112 } 0113 0114 NumberAnimation { 0115 loops: 1 0116 target: canvas 0117 property: "rotation" 0118 duration: 1200 * control.speed 0119 from: 0 0120 to: 720 0121 } 0122 0123 NumberAnimation { 0124 target: canvas 0125 property: "startDeg" 0126 to: 360 0127 duration: 1200 * control.speed 0128 easing.type: Easing.InOutQuad 0129 } 0130 } 0131 0132 ScriptAction { 0133 script: changeStage() 0134 } 0135 } 0136 }