~unity-team/unity8/dash-only

« back to all changes in this revision

Viewing changes to qml/Greeter/Clock.qml

  • Committer: Kevin Gunn
  • Date: 2016-10-24 19:51:33 UTC
  • Revision ID: kevin.gunn@canonical.com-20161024195133-61lwdzzdwsnue1mn
shave some more

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 */
16
 
 
17
 
import QtQuick 2.4
18
 
import Ubuntu.Components 1.3
19
 
import "../Panel/Indicators"
20
 
import Unity.Indicators 0.1 as Indicators
21
 
 
22
 
Item {
23
 
    id: clock
24
 
 
25
 
    implicitWidth: childrenRect.width
26
 
    implicitHeight: childrenRect.height
27
 
 
28
 
    // Allows to set the current Date. Will be overwritten if visible
29
 
    property date currentDate
30
 
 
31
 
    Component.onCompleted: {
32
 
        if (visible) {
33
 
            currentDate = new Date()
34
 
        }
35
 
    }
36
 
 
37
 
    Connections {
38
 
        target: i18n
39
 
        onLanguageChanged: {
40
 
            if (visible) {
41
 
                timeLabel.text = Qt.formatTime(clock.currentDate); // kicks time
42
 
                clock.currentDate = new Date(); // kicks date
43
 
            }
44
 
        }
45
 
    }
46
 
 
47
 
    Indicators.SharedUnityMenuModel {
48
 
        id: timeModel
49
 
        objectName: "timeModel"
50
 
 
51
 
        busName: "com.canonical.indicator.datetime"
52
 
        actions: { "indicator": "/com/canonical/indicator/datetime" }
53
 
        menuObjectPath: clock.visible ? "/com/canonical/indicator/datetime/phone" : ""
54
 
    }
55
 
 
56
 
    Indicators.ModelActionRootState {
57
 
        menu: timeModel.model
58
 
        onUpdated: {
59
 
            if (timeLabel.text != rightLabel) {
60
 
                if (rightLabel != "") timeLabel.text = rightLabel;
61
 
                clock.currentDate = new Date();
62
 
            }
63
 
        }
64
 
    }
65
 
 
66
 
    Column {
67
 
        spacing: units.gu(0.5)
68
 
 
69
 
        Label {
70
 
            id: timeLabel
71
 
            objectName: "timeLabel"
72
 
 
73
 
            anchors.horizontalCenter: parent.horizontalCenter
74
 
            font.pixelSize: units.gu(7.5)
75
 
            color: "white"
76
 
            text: Qt.formatTime(clock.currentDate)
77
 
            font.weight: Font.Light
78
 
        }
79
 
 
80
 
        Label {
81
 
            id: dateLabel
82
 
            objectName: "dateLabel"
83
 
 
84
 
            anchors.horizontalCenter: parent.horizontalCenter
85
 
            fontSize: "medium"
86
 
            color: "white"
87
 
            text: Qt.formatDate(clock.currentDate, Qt.DefaultLocaleLongDate)
88
 
            font.weight: Font.Light
89
 
        }
90
 
    }
91
 
}