8ab644c1a47837c9f6cfb86948ed2c0781333b00
[harmattan/cameraplus] / qml / RecordingDurationLabel.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 @IMPORT_QT_QUICK@
24 import com.nokia.meego 1.1
25
26 Rectangle {
27     property int duration
28
29     anchors.bottom: parent.bottom
30     anchors.right: parent.right
31     anchors.rightMargin: 20
32     anchors.bottomMargin: 20
33
34     color: "black"
35     opacity: 0.5
36     width: 100
37     height: 30
38
39     Image {
40         id: recordingIcon
41         source: "image://theme/icon-m-camera-ongoing-recording"
42         width: 20
43         height: 20
44         anchors.verticalCenter: parent.verticalCenter
45         anchors.left: parent.left
46         anchors.leftMargin: 5
47         sourceSize.width: 20
48         sourceSize.height: 20
49     }
50
51     Label {
52         function formatDuration(dur) {
53             var secs = parseInt(recordingDuration.duration)
54             var minutes = Math.floor(secs / 60)
55             var seconds = secs - (minutes * 60)
56
57             var date = new Date()
58             date.setSeconds(seconds)
59             date.setMinutes(minutes)
60             return Qt.formatTime(date, "mm:ss")
61         }
62
63         text: formatDuration(parent.duration)
64         anchors.left: recordingIcon.right
65         anchors.leftMargin: 5
66     }
67 }