| 1 |
/* |
| 2 |
* Copyright (C) 2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This file is part of Lomiri Weather App |
| 5 |
* |
| 6 |
* Lomiri Weather App is free software: you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License version 3 as |
| 8 |
* published by the Free Software Foundation. |
| 9 |
* |
| 10 |
* Lomiri Weather App is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
import QtQuick 2.12 |
| 20 |
import Lomiri.Components 1.3 |
| 21 |
|
| 22 |
Rectangle { |
| 23 |
id: indicator |
| 24 |
objectName: "processingIndicator" |
| 25 |
height: units.dp(3) |
| 26 |
color: theme.palette.normal.background |
| 27 |
opacity: 0 |
| 28 |
visible: opacity > 0 |
| 29 |
|
| 30 |
property bool processing: false |
| 31 |
|
| 32 |
Behavior on opacity { |
| 33 |
LomiriNumberAnimation { duration: LomiriAnimation.FastDuration } |
| 34 |
} |
| 35 |
|
| 36 |
onProcessingChanged: { |
| 37 |
if (processing) delay.start(); |
| 38 |
else if (!persist.running) indicator.opacity = 0; |
| 39 |
} |
| 40 |
|
| 41 |
Timer { |
| 42 |
id: delay |
| 43 |
interval: 200 |
| 44 |
onTriggered: if (indicator.processing) { |
| 45 |
persist.restart(); |
| 46 |
indicator.opacity = 1; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
Timer { |
| 51 |
id: persist |
| 52 |
interval: 2 * LomiriAnimation.SleepyDuration - LomiriAnimation.FastDuration |
| 53 |
onTriggered: if (!indicator.processing) indicator.opacity = 0 |
| 54 |
} |
| 55 |
|
| 56 |
Rectangle { |
| 57 |
id: orange |
| 58 |
anchors { top: parent.top; bottom: parent.bottom } |
| 59 |
width: parent.width / 4 |
| 60 |
color: LomiriColors.orange |
| 61 |
|
| 62 |
SequentialAnimation { |
| 63 |
running: indicator.visible |
| 64 |
loops: Animation.Infinite |
| 65 |
XAnimator { |
| 66 |
from: -orange.width / 2 |
| 67 |
to: indicator.width - orange.width / 2 |
| 68 |
duration: LomiriAnimation.SleepyDuration |
| 69 |
easing.type: Easing.InOutSine |
| 70 |
target: orange |
| 71 |
} |
| 72 |
XAnimator { |
| 73 |
from: indicator.width - orange.width / 2 |
| 74 |
to: -orange.width / 2 |
| 75 |
duration: LomiriAnimation.SleepyDuration |
| 76 |
easing.type: Easing.InOutSine |
| 77 |
target: orange |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
} |