on 7cd287d help sign in
unity8/Greeter/Clock.qml
85 lines 2.5 kB history raw
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 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 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 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Unity.Indicators 0.1 as Indicators
21Item {
22 id: clock
24 implicitWidth: childrenRect.width
25 implicitHeight: childrenRect.height
27 // Allows to set the current Date. Will be overwritten if active
28 property date currentDate
30 // If active, time will be updated through the indicators service
31 property bool active: clock.enabled && clock.visible
33 Component.onCompleted: {
34 if (active) {
35 currentDate = new Date()
36 }
37 }
39 Indicators.CachedUnityMenuModel {
40 id: timeModel
41 objectName: "timeModel"
43 busName: "com.canonical.indicator.datetime"
44 actionsObjectPath: "/com/canonical/indicator/datetime"
45 menuObjectPath: clock.active ? "/com/canonical/indicator/datetime/phone" : ""
47 Indicators.RootActionState {
48 menu: timeModel.model
49 onUpdated: {
50 if (timeLabel.text != rightLabel) {
51 timeLabel.text = rightLabel;
52 clock.currentDate = new Date();
53 }
54 }
55 }
56 }
58 Column {
59 spacing: units.gu(0.5)
61 Label {
62 id: timeLabel
63 objectName: "timeLabel"
65 anchors.horizontalCenter: parent.horizontalCenter
66 font.pixelSize: units.gu(7.5)
67 color: "white"
68 opacity: 0.5
69 text: Qt.formatTime(clock.currentDate)
70 font.weight: Font.Light
71 }
73 Label {
74 id: dateLabel
75 objectName: "dateLabel"
77 anchors.horizontalCenter: parent.horizontalCenter
78 fontSize: "medium"
79 color: "white"
80 opacity: 0.5
81 text: Qt.formatDate(clock.currentDate, Qt.DefaultLocaleLongDate)
82 font.weight: Font.Light
83 }
84 }