~pkunal-parmar/ubuntu-calendar-app/MonthYearView-Redesign

« back to all changes in this revision

Viewing changes to NewEventTimePicker.qml

  • Committer: Kunal Parmar
  • Date: 2014-10-21 18:58:31 UTC
  • mto: This revision was merged to the branch mainline in revision 516.
  • Revision ID: pkunal.parmar@gmail.com-20141021185831-9pqmtt38wdbdhi6x
Moved TimeComponent to seperate comp

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.3
 
2
import Ubuntu.Components.ListItems 1.0 as ListItem
 
3
import Ubuntu.Components.Themes.Ambiance 1.0
 
4
import Ubuntu.Components.Pickers 1.0
 
5
 
 
6
Column {
 
7
    id: dateTimeInput
 
8
    property alias header: listHeader.text
 
9
 
 
10
    property date dateTime;
 
11
    property bool showTimePicker;
 
12
 
 
13
    function clearFocus() {
 
14
        dateInput.focus = false;
 
15
        timeInput.focus = false;
 
16
    }
 
17
 
 
18
    function openDatePicker (element, caller, callerProperty, mode) {
 
19
        element.highlighted = true;
 
20
        var picker = PickerPanel.openDatePicker(caller, callerProperty, mode);
 
21
        if (!picker) return;
 
22
        picker.closed.connect(function () {
 
23
            element.highlighted = false;
 
24
        });
 
25
    }
 
26
 
 
27
    onDateTimeChanged: {
 
28
        dateInput.text = dateTime.toLocaleDateString();
 
29
        timeInput.text = Qt.formatTime(dateTime);
 
30
    }
 
31
 
 
32
    ListItem.Header {
 
33
        id: listHeader
 
34
    }
 
35
 
 
36
    Item {
 
37
        anchors {
 
38
            left: parent.left
 
39
            right: parent.right
 
40
            margins: units.gu(2)
 
41
        }
 
42
 
 
43
        height: dateInput.height
 
44
 
 
45
        NewEventEntryField{
 
46
            id: dateInput
 
47
            objectName: "dateInput"
 
48
 
 
49
            text: ""
 
50
            anchors.left: parent.left
 
51
            width: !showTimePicker ? parent.width : 4 * parent.width / 5
 
52
 
 
53
            MouseArea{
 
54
                anchors.fill: parent
 
55
                onClicked: openDatePicker(dateInput, dateTimeInput, "dateTime", "Years|Months|Days")
 
56
            }
 
57
        }
 
58
 
 
59
        NewEventEntryField{
 
60
            id: timeInput
 
61
            objectName: "timeInput"
 
62
 
 
63
            text: ""
 
64
            anchors.right: parent.right
 
65
            width: parent.width / 5
 
66
            visible: showTimePicker
 
67
            horizontalAlignment: Text.AlignRight
 
68
 
 
69
            MouseArea{
 
70
                anchors.fill: parent
 
71
                onClicked: openDatePicker(timeInput, dateTimeInput, "dateTime", "Hours|Minutes")
 
72
            }
 
73
        }
 
74
    }
 
75
}