~nik90/ubuntu-clock-app/add-developer-guidelines

« back to all changes in this revision

Viewing changes to app/clock/Clock.qml

  • Committer: Nekhelesh Ramananthan
  • Date: 2014-06-06 18:45:49 UTC
  • Revision ID: krnekhelesh@gmail.com-20140606184549-l8qpmg55pwqqurjd
Initial commit of files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2014 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
 
 
17
import QtQuick 2.0
 
18
import Ubuntu.Components 1.1
 
19
import "../components"
 
20
 
 
21
ClockCircle {
 
22
    id: outerCircle
 
23
 
 
24
    property alias time: digitalTime.text
 
25
    
 
26
    isOuter: true
 
27
    
 
28
    width: units.gu(0)
 
29
    anchors.verticalCenter: parent.verticalCenter
 
30
    anchors.verticalCenterOffset: -parent.height/6
 
31
    anchors.horizontalCenter: parent.horizontalCenter
 
32
    
 
33
    Component.onCompleted: clockOpenAnimation.start()
 
34
    
 
35
    ParallelAnimation {
 
36
        id: clockOpenAnimation
 
37
        
 
38
        PropertyAnimation {
 
39
            id: outerCircleAnimation
 
40
            target: outerCircle
 
41
            property: "width"
 
42
            from: units.gu(0)
 
43
            to: units.gu(32)
 
44
            duration: 900
 
45
        }
 
46
        
 
47
        ScriptAction {
 
48
            script: animationTimer.start()
 
49
        }
 
50
    }
 
51
    
 
52
    ClockCircle {
 
53
        id: innerCircle
 
54
        
 
55
        width: units.gu(0)
 
56
        anchors.centerIn: parent
 
57
        
 
58
        Timer {
 
59
            id: animationTimer
 
60
            interval: 200
 
61
            repeat: false
 
62
            onTriggered: innerCircleAnimation.start()
 
63
        }
 
64
        
 
65
        ParallelAnimation {
 
66
            id: innerCircleAnimation
 
67
            
 
68
            PropertyAnimation {
 
69
                target: innerCircle
 
70
                property: "width"
 
71
                to: units.gu(23)
 
72
                duration: 900
 
73
            }
 
74
            
 
75
            PropertyAnimation {
 
76
                target: digitalTime
 
77
                property: "font.pixelSize"
 
78
                to: units.dp(41)
 
79
                duration: 900
 
80
            }
 
81
        }
 
82
        
 
83
        Label {
 
84
            id: digitalTime
 
85
            anchors.centerIn: parent
 
86
            color: UbuntuColors.midAubergine
 
87
            opacity: font.pixelSize === units.dp(41) ? 1 : 0
 
88
            text: Qt.formatTime(new Date(), "hh:mm")
 
89
        }
 
90
    }
 
91
}