Merge lp:~pkunal-parmar/ubuntu-calendar-app/TimeInputComponent into lp:ubuntu-calendar-app

Proposed by Kunal Parmar
Status: Merged
Approved by: Mihir Soni
Approved revision: 516
Merged at revision: 516
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/TimeInputComponent
Merge into: lp:ubuntu-calendar-app
Diff against target: 243 lines (+102/-101)
2 files modified
NewEvent.qml (+27/-101)
NewEventTimePicker.qml (+75/-0)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/TimeInputComponent
Reviewer Review Type Date Requested Status
Mihir Soni Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+239120@code.launchpad.net

Commit message

Moved Time input to separate component

Description of the change

Moved Time input to separate component

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Mihir Soni (mihirsoni) wrote :

Looks Good to me !
Thanks kunal.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NewEvent.qml'
2--- NewEvent.qml 2014-10-20 15:24:00 +0000
3+++ NewEvent.qml 2014-10-21 19:00:00 +0000
4@@ -43,14 +43,12 @@
5 property bool isEdit: false
6
7 onStartDateChanged: {
8- startDateInput.text = startDate.toLocaleDateString();
9- startTimeInput.text = Qt.formatTime(startDate);
10+ startDateTimeInput.dateTime = startDate;
11 adjustEndDateToStartDate()
12 }
13
14 onEndDateChanged: {
15- endDateInput.text = endDate.toLocaleDateString();
16- endTimeInput.text = Qt.formatTime(endDate);
17+ endDateTimeInput.dateTime = endDate;
18 }
19
20 head.actions: Action {
21@@ -229,15 +227,6 @@
22 return daysOfWeek;
23 }
24
25- function openDatePicker (element, caller, callerProperty, mode) {
26- element.highlighted = true;
27- var picker = PickerPanel.openDatePicker(caller, callerProperty, mode);
28- if (!picker) return;
29- picker.closed.connect(function () {
30- element.highlighted = false;
31- });
32- }
33-
34 // Calucate default hour and minute for start and end time on event
35 function roundDate(date) {
36 var tempDate = new Date(date)
37@@ -336,90 +325,29 @@
38
39 width: parent.width
40
41- ListItem.Header {
42- text: i18n.tr("From")
43- }
44-
45- Item {
46- anchors {
47- left: parent.left
48- right: parent.right
49- margins: units.gu(2)
50- }
51-
52- height: startDateInput.height
53-
54- NewEventEntryField{
55- id: startDateInput
56- objectName: "startDateInput"
57-
58- text: ""
59- anchors.left: parent.left
60- width: allDayEventCheckbox.checked ? parent.width : 4 * parent.width / 5
61-
62- MouseArea{
63- anchors.fill: parent
64- onClicked: openDatePicker(startDateInput, root, "startDate", "Years|Months|Days")
65- }
66- }
67-
68- NewEventEntryField{
69- id: startTimeInput
70- objectName: "startTimeInput"
71-
72- text: ""
73- anchors.right: parent.right
74- width: parent.width / 5
75- visible: !allDayEventCheckbox.checked
76- horizontalAlignment: Text.AlignRight
77-
78- MouseArea{
79- anchors.fill: parent
80- onClicked: openDatePicker(startTimeInput, root, "startDate", "Hours|Minutes")
81- }
82- }
83- }
84-
85- ListItem.Header {
86- text: i18n.tr("To")
87- }
88-
89- Item {
90- anchors {
91- left: parent.left
92- right: parent.right
93- margins: units.gu(2)
94- }
95-
96- height: endDateInput.height
97-
98- NewEventEntryField{
99- id: endDateInput
100- objectName: "endDateInput"
101-
102- text: ""
103- anchors.left: parent.left
104- width: allDayEventCheckbox.checked ? parent.width : 4 * parent.width / 5
105-
106- MouseArea{
107- anchors.fill: parent
108- onClicked: openDatePicker(endDateInput, root, "endDate", "Years|Months|Days")
109- }
110- }
111-
112- NewEventEntryField{
113- id: endTimeInput
114- objectName: "endTimeInput"
115- text: ""
116- width: parent.width / 5
117- visible: !allDayEventCheckbox.checked
118- anchors.right: parent.right
119- horizontalAlignment: Text.AlignRight
120-
121- MouseArea{
122- anchors.fill: parent
123- onClicked: openDatePicker(endTimeInput, root, "endDate", "Hours|Minutes")
124- }
125+ NewEventTimePicker{
126+ id: startDateTimeInput
127+ header: i18n.tr("From")
128+ showTimePicker: !allDayEventCheckbox.checked
129+ anchors {
130+ left: parent.left
131+ right: parent.right
132+ }
133+ onDateTimeChanged: {
134+ startDate = dateTime;
135+ }
136+ }
137+
138+ NewEventTimePicker{
139+ id: endDateTimeInput
140+ header: i18n.tr("To")
141+ showTimePicker: !allDayEventCheckbox.checked
142+ anchors {
143+ left: parent.left
144+ right: parent.right
145+ }
146+ onDateTimeChanged: {
147+ endDate = dateTime;
148 }
149 }
150
151@@ -676,10 +604,8 @@
152 Qt.inputMethod.hide()
153 titleEdit.focus = false
154 locationEdit.focus = false
155- startDateInput.focus = false
156- startTimeInput.focus = false
157- endDateInput.focus = false
158- endTimeInput.focus = false
159+ startDateTimeInput.clearFocus();
160+ endDateTimeInput.clearFocus();
161 messageEdit.focus = false
162 }
163
164
165=== added file 'NewEventTimePicker.qml'
166--- NewEventTimePicker.qml 1970-01-01 00:00:00 +0000
167+++ NewEventTimePicker.qml 2014-10-21 19:00:00 +0000
168@@ -0,0 +1,75 @@
169+import QtQuick 2.3
170+import Ubuntu.Components.ListItems 1.0 as ListItem
171+import Ubuntu.Components.Themes.Ambiance 1.0
172+import Ubuntu.Components.Pickers 1.0
173+
174+Column {
175+ id: dateTimeInput
176+ property alias header: listHeader.text
177+
178+ property date dateTime;
179+ property bool showTimePicker;
180+
181+ function clearFocus() {
182+ dateInput.focus = false;
183+ timeInput.focus = false;
184+ }
185+
186+ function openDatePicker (element, caller, callerProperty, mode) {
187+ element.highlighted = true;
188+ var picker = PickerPanel.openDatePicker(caller, callerProperty, mode);
189+ if (!picker) return;
190+ picker.closed.connect(function () {
191+ element.highlighted = false;
192+ });
193+ }
194+
195+ onDateTimeChanged: {
196+ dateInput.text = dateTime.toLocaleDateString();
197+ timeInput.text = Qt.formatTime(dateTime);
198+ }
199+
200+ ListItem.Header {
201+ id: listHeader
202+ }
203+
204+ Item {
205+ anchors {
206+ left: parent.left
207+ right: parent.right
208+ margins: units.gu(2)
209+ }
210+
211+ height: dateInput.height
212+
213+ NewEventEntryField{
214+ id: dateInput
215+ objectName: "dateInput"
216+
217+ text: ""
218+ anchors.left: parent.left
219+ width: !showTimePicker ? parent.width : 4 * parent.width / 5
220+
221+ MouseArea{
222+ anchors.fill: parent
223+ onClicked: openDatePicker(dateInput, dateTimeInput, "dateTime", "Years|Months|Days")
224+ }
225+ }
226+
227+ NewEventEntryField{
228+ id: timeInput
229+ objectName: "timeInput"
230+
231+ text: ""
232+ anchors.right: parent.right
233+ width: parent.width / 5
234+ visible: showTimePicker
235+ horizontalAlignment: Text.AlignRight
236+
237+ MouseArea{
238+ anchors.fill: parent
239+ onClicked: openDatePicker(timeInput, dateTimeInput, "dateTime", "Hours|Minutes")
240+ }
241+ }
242+ }
243+}

Subscribers

People subscribed via source and target branches

to status/vote changes: