on 42b1bfc help sign in
unity8/Panel/Indicators/DatetimeIndicatorPage.qml
98 lines 2.5 kB history raw
1/*
2 * Copyright 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 Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Ubo Riboni <ugo.riboni@canonical.com>
19 */
21import QtQuick 2.0
22import Ubuntu.Components 0.1
24Flickable {
25 id: page
27 contentHeight: image.height
29 Image {
30 id: image
31 anchors {
32 left: parent.left
33 right: parent.right
34 }
35 source: "../graphics/time_and_date@18.png"
36 fillMode: Image.PreserveAspectFit
37 }
39 Item {
40 anchors {
41 top: parent.top
42 topMargin: units.gu(5)
43 left: parent.left
44 right: parent.right
45 }
47 height: units.gu(30)
49 Label {
50 id: __time
51 anchors {
52 horizontalCenter: parent.horizontalCenter
53 verticalCenter: parent.verticalCenter
54 }
56 text: ""
57 color: "#f3f3e7"
58 font.weight: Font.Light
59 font.pixelSize: units.gu(6)
60 }
62 Label {
63 id: __date
65 anchors {
66 left: parent.left
67 leftMargin: units.gu(2)
68 bottom: parent.bottom
69 bottomMargin: units.gu(1.5)
70 }
71 text: ""
72 color: "#f3f3e7"
73 fontSize: "small"
74 }
75 }
77 Timer {
78 interval: 1000 * 60 // one minute
79 running: true
80 repeat: true
81 onTriggered: updateTime();
83 Component.onCompleted: updateTime();
84 }
86 function updateTime() {
87 var dt = new Date()
88 var time = Qt.formatTime(dt)
89 var space = time.indexOf(" ")
90 __time.text = time.substr(0, space > 0 ? space : 5)
91 __date.text = Qt.formatDateTime(dt, "dddd,\ndd MMMM")
92 }
94 // Make it compatible with the PluginItem interface
95 function start() {}
96 function stop() {}
97 function reset() {}