~mpredotka/ubuntu-clock-app/fix-1272628

« back to all changes in this revision

Viewing changes to stopwatch/StopwatchFace.qml

  • Committer: Tarmac
  • Author(s): Nekhelesh Ramananthan
  • Date: 2014-01-10 14:22:15 UTC
  • mfrom: (281.1.22 dialer)
  • Revision ID: tarmac-20140110142215-2c7r1cn1q5g0ewmz
Transitions the clock app to use the SDK Dialer widget. Fixes: https://bugs.launchpad.net/bugs/1266945.

Approved by Ubuntu Phone Apps Jenkins Bot, Michael Zanetti.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical Ltd
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Alessandro Pozzi <signor.hyde@gmail.com>
 
17
 *              Nekhelesh Ramananthan <krnekhelesh@gmail.com>
 
18
 */
 
19
 
 
20
import QtQuick 2.0
 
21
import Ubuntu.Components 0.1
 
22
import "StopwatchSupport.js" as SScript
 
23
import "../common"
 
24
 
 
25
ClockBase {
 
26
    id: stopwatchFace
 
27
 
 
28
    // Properties to store/set the time variables
 
29
    property var startTime: 0
 
30
    property var stopTime: 0
 
31
    property int delay : 0
 
32
    property bool flag: true
 
33
    property int totalTime: 0
 
34
    property int milliseconds: 0
 
35
 
 
36
    // Sets the location and visible (bool) values of the blip (small circle visible when the lap button is pressed)
 
37
    property alias blipLocation: blipFist.location
 
38
    property alias blipVisible: blipFist.visible
 
39
 
 
40
    // Retrieves the status of the stopwatch timer
 
41
    property bool timerStatus: stopwatchUIUpdate.running
 
42
 
 
43
    function reset() {
 
44
        totalTime = milliseconds = seconds = minutes = hours = 0
 
45
        SScript.deltaTime[0] = SScript.deltaTime[1] = SScript.deltaTime[2] = SScript.deltaTime[3] = 0
 
46
        startTime = stopTime = delay = 0;
 
47
        flag = true;
 
48
    }
 
49
 
 
50
    function start() {
 
51
        stopwatchUIUpdate.start()
 
52
    }
 
53
 
 
54
    function stop() {
 
55
        stopwatchUIUpdate.stop()
 
56
    }
 
57
 
 
58
    // Timer which runs every 100 microseconds to update the time and also the trailing hand gradient.
 
59
    Timer {
 
60
        id: stopwatchUIUpdate
 
61
 
 
62
        interval: 100
 
63
        repeat: true
 
64
        onTriggered: {
 
65
            totalTime = SScript.delta();
 
66
            SScript.deltaTime = SScript.msToTime(totalTime)
 
67
            hours = SScript.deltaTime[0];
 
68
            minutes = SScript.deltaTime[1];
 
69
            seconds = SScript.deltaTime[2];
 
70
            milliseconds = SScript.deltaTime[3];
 
71
        }
 
72
    }
 
73
 
 
74
    // This component draws the small white circle that is visible everytime the lap button is pressed.
 
75
    Blip {
 
76
        id: blipFist
 
77
    }
 
78
 
 
79
    Repeater {
 
80
        id:stopwatchMarkers
 
81
 
 
82
        model: 24
 
83
 
 
84
        delegate: AnalogClockMarker {
 
85
            number: modelData
 
86
            total: 24;
 
87
            size: 0.2
 
88
            distance: 0.32
 
89
        }
 
90
    }
 
91
}