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

« back to all changes in this revision

Viewing changes to stopwatch/AnalogStopwatch.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
 
// This component draws the stopwatch analog UI and defines different UI modes like normal and easteregg.
26
 
AnalogFaceBase {
27
 
    id: analogStopwatch
28
 
 
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
 
 
35
 
    property int hours: 0;
36
 
    property int minutes: 0;
37
 
    property int seconds: 0;
38
 
    property int milliseconds: 0;
39
 
    property int decimalgradient: 0;  
40
 
 
41
 
    // Sets the location and visible (bool) values of the blip (small circle visible when the lap button is pressed)
42
 
    property alias blipLocation: blipFist.location;
43
 
    property alias blipVisible: blipFist.visible;
44
 
 
45
 
    // Retrieves the status of the stopwatch timer
46
 
    property bool timerStatus: stopwatchUIUpdate.running    
47
 
 
48
 
    function reset() {
49
 
        decimalgradient = totalTime = milliseconds = seconds = minutes = hours = 0
50
 
        SScript.deltaTime[0] = SScript.deltaTime[1] = SScript.deltaTime[2] = SScript.deltaTime[3] = 0
51
 
        startTime = stopTime = delay = 0;
52
 
        flag = true;
53
 
    }
54
 
 
55
 
    function start() {
56
 
        stopwatchUIUpdate.start()
57
 
    }
58
 
 
59
 
    function stop() {
60
 
        stopwatchUIUpdate.stop()
61
 
    }        
62
 
 
63
 
    // Timer which runs every 100 microseconds to update the time and also the trailing hand gradient.
64
 
    Timer {
65
 
        id: stopwatchUIUpdate
66
 
 
67
 
        interval: 100
68
 
        repeat: true
69
 
        onTriggered: {            
70
 
            totalTime = SScript.delta();
71
 
            SScript.deltaTime = SScript.msToTime(totalTime)
72
 
            hours = SScript.deltaTime[0];
73
 
            minutes = SScript.deltaTime[1];
74
 
            seconds = SScript.deltaTime[2];
75
 
            milliseconds = SScript.deltaTime[3];
76
 
            decimalgradient = minutes * 10;
77
 
        }
78
 
    }
79
 
 
80
 
    // This component draws the small orange circle that is visible everytime the lap button is pressed.
81
 
    Blip {
82
 
        id: blipFist
83
 
    }
84
 
    
85
 
    // This component draws the trailing shadow of the second hand.
86
 
    HandGradient {
87
 
        id: gradientSecond
88
 
        rotationAngle: minutes * 6
89
 
        decimalGradient: decimalgradient
90
 
    }
91
 
 
92
 
    Repeater {
93
 
        id:stopwatchMarkers
94
 
        
95
 
        model: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
96
 
        
97
 
        delegate: AnalogClockMarker {
98
 
            number: modelData            
99
 
            total: 24;
100
 
            size: 0.2
101
 
            distance: 0.32            
102
 
        }
103
 
    }
104
 
 
105
 
    AnalogClockHand {
106
 
        id: hourHand
107
 
 
108
 
        z: parent.z
109
 
        handHeight: units.gu(12.5); handWidth: units.gu(1);
110
 
        rotation: hours * 15;
111
 
    }
112
 
 
113
 
    AnalogClockHand {
114
 
        id: minuteHand
115
 
 
116
 
        z: parent.z
117
 
        handHeight: units.gu(14.5); handWidth: units.gu(0.5);
118
 
        rotation: minutes * 6;
119
 
    }
120
 
 
121
 
    AnalogClockHand {
122
 
        id: secondHand
123
 
 
124
 
        z: parent.z - 1;
125
 
        handHeight: units.gu(17); handWidth:  units.gu(0.5)
126
 
        rotation: seconds * 6;
127
 
    }
128
 
}