2
* Copyright (C) 2013 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
20
import Ubuntu.Components 0.1
23
// Component which draws the analog timer face.
27
property var startTime: 0;
28
property var remTime: 0;
30
// Properties to store/set the time variables
31
property int seconds: 0;
32
property int minutes: 0;
33
property int totalTime: 0;
34
property int pauseTime: 0;
36
// Property to activate/deactivate the timer
37
property bool timerOn: false;
38
property bool inProgressFlag
40
// Timer function called by the main clock loop
41
function onTimerUpdate () {
43
inProgressFlag = true;
44
remTime = totalTime - Math.floor((new Date() - startTime)/ 1000) - pauseTime;
55
// Function to convert time (in seconds) to hh:mm:ss format
56
function ssToTime(time) {
58
time = Math.floor(time / 60)
60
secondHand.rotationValue = seconds * 6;
61
minuteHand.rotationValue = minutes * 6;
64
// Function to disable timer and reset time
71
inProgressFlag = true;
72
minuteHand.rotationValue = secondHand.rotationValue = 0;
73
inProgressFlag = false;
81
startTime = remTime = pauseTime = 0;
82
minutes = seconds = totalTime = 0;
83
minuteHand.timerValue = secondHand.timerValue = 0;
88
delegate: AnalogClockMarker {
95
// Minute hand with touch/mouse drag support
98
objectName: "minuteHand"
100
onTimerValueChanged: minutes = timerValue;
102
handHeight: units.gu(14.5); handWidth: units.gu(0.5);
103
animateFlag: inProgressFlag;
104
enabled: !inProgressFlag;
105
grabMargin: units.gu(0)
106
grabHeight: units.gu(7)
109
// Second hand with touch/mouse drag support
113
onTimerValueChanged: seconds = timerValue;
115
handHeight: units.gu(17); handWidth: units.gu(0.5);
117
animateFlag: inProgressFlag;
118
enabled: !inProgressFlag;
119
grabMargin: -units.gu(2)