on d90fbf7 help sign in
unity8/Panel/Indicators/DatetimeIndicatorPage.qml
97 lines 2.6 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: timeLabel
51 anchors {
52 horizontalCenter: parent.horizontalCenter
53 verticalCenter: parent.verticalCenter
54 }
56 text: ""
57 color: Theme.palette.selected.backgroundText
58 font.weight: Font.Light
59 font.pixelSize: units.gu(6)
60 }
62 Label {
63 id: dateLabel
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: Theme.palette.selected.backgroundText
73 fontSize: "small"
74 }
75 }
77 Timer {
78 interval: 1000 * 10 // 10 seconds
79 running: true
80 repeat: true
81 triggeredOnStart: true
82 onTriggered: updateTime();
83 }
85 function updateTime() {
86 var dt = new Date();
87 var time = Qt.formatTime(dt);
88 var space = time.indexOf(" ");
89 timeLabel.text = time.substr(0, space > 0 ? space : 5);
90 dateLabel.text = Qt.formatDateTime(dt, "dddd,\ndd MMMM");
91 }
93 // Make it compatible with the PluginItem interface
94 function start() {}
95 function stop() {}
96 function reset() {}