Merge lp:~mihirsoni/telegram-app/sectionHeader into lp:telegram-app/app-dev
- sectionHeader
- Merge into telegram-app-dev
Proposed by
Mihir Soni
Status: | Merged |
---|---|
Approved by: | Michał Karnicki |
Approved revision: | 124 |
Merged at revision: | 121 |
Proposed branch: | lp:~mihirsoni/telegram-app/sectionHeader |
Merge into: | lp:telegram-app/app-dev |
Diff against target: |
401 lines (+186/-154) 4 files modified
components/TelegramDelegate.qml (+166/-153) components/TelegramSection.qml (+1/-1) js/time.js (+16/-0) ui/DialogPage.qml (+3/-0) |
To merge this branch: | bzr merge lp:~mihirsoni/telegram-app/sectionHeader |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michał Karnicki (community) | Approve | ||
Review via email: mp+237852@code.launchpad.net |
Commit message
Description of the change
Added section work around.
This is how it looks like :-
http://
You'll need this MR , https:/
To post a comment you must log in.
- 122. By Mihir Soni
-
Merged with trunl
- 123. By Mihir Soni
-
Shows Month Date in section text
- 124. By Mihir Soni
-
Removed space
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'components/TelegramDelegate.qml' |
2 | --- components/TelegramDelegate.qml 2014-10-08 21:22:10 +0000 |
3 | +++ components/TelegramDelegate.qml 2014-10-09 21:21:05 +0000 |
4 | @@ -9,6 +9,8 @@ |
5 | property bool outgoing: false |
6 | property string message: "" |
7 | property int mediaType: 0 |
8 | + property string sectionText: section.text |
9 | + property bool sectionVisible: false |
10 | property string senderColor: "" |
11 | property string senderName: "" |
12 | property string senderImage: "" |
13 | @@ -28,166 +30,177 @@ |
14 | signal clicked() |
15 | signal profileImageClicked() |
16 | |
17 | - ListItem.Empty { |
18 | - id: internalDelegate |
19 | - anchors { |
20 | - top: parent ? parent.top : undefined |
21 | - left: parent ? parent.left : undefined |
22 | - right: parent ? parent.right : undefined |
23 | - } |
24 | - height: bubble.height |
25 | - showDivider: false |
26 | - highlightWhenPressed: false |
27 | - |
28 | - onClicked: messageDelegate.clicked() |
29 | - |
30 | - Image { |
31 | - id: image |
32 | - anchors { |
33 | - left: parent.left |
34 | - leftMargin: source == "" ? 0 : units.gu(1) |
35 | - bottom: parent.bottom |
36 | - } |
37 | - |
38 | - width: source == "" || source === undefined ? 0 : units.gu(5); |
39 | - height: width |
40 | - asynchronous: true |
41 | - fillMode: Image.PreserveAspectCrop |
42 | - source: senderImage |
43 | - |
44 | - MouseArea { |
45 | - anchors.fill: parent |
46 | - onClicked: messageDelegate.profileImageClicked() |
47 | - } |
48 | - } |
49 | - |
50 | - TelegramBubble { |
51 | - id: bubble |
52 | - outgoing: messageDelegate.outgoing |
53 | - anchors { |
54 | - top: parent.top |
55 | - left: outgoing ? undefined: image.right |
56 | - leftMargin: units.gu(1) |
57 | - right: outgoing ? parent.right : undefined |
58 | - rightMargin: units.gu(1) |
59 | - } |
60 | - height: messageContents.height + units.gu(2) |
61 | - width: Math.max(messageLabel.width, senderLabel.width, messageStatusRow.width, messagePhoto.width) + units.gu(3) |
62 | - |
63 | - Item { |
64 | - id: messageContents |
65 | + Column { |
66 | + id: column |
67 | + anchors.fill: parent |
68 | + spacing: units.gu(1) |
69 | + |
70 | + TelegramSection { |
71 | + id: section |
72 | + text: sectionText |
73 | + visible: sectionVisible |
74 | + } |
75 | + |
76 | + ListItem.Empty { |
77 | + id: internalDelegate |
78 | + anchors { |
79 | + left: parent ? parent.left : undefined |
80 | + right: parent ? parent.right : undefined |
81 | + } |
82 | + height: sectionVisible ? bubble.height + section.height : bubble.height |
83 | + showDivider: false |
84 | + highlightWhenPressed: false |
85 | + |
86 | + onClicked: messageDelegate.clicked() |
87 | + |
88 | + Image { |
89 | + id: image |
90 | + anchors { |
91 | + left: parent.left |
92 | + leftMargin: source == "" ? 0 : units.gu(1) |
93 | + bottom: sectionVisible ? bubble.bottom : parent.bottom |
94 | + } |
95 | + |
96 | + width: source == "" || source === undefined ? 0 : units.gu(5); |
97 | + height: width |
98 | + asynchronous: true |
99 | + fillMode: Image.PreserveAspectCrop |
100 | + source: senderImage |
101 | + |
102 | + MouseArea { |
103 | + anchors.fill: parent |
104 | + onClicked: messageDelegate.profileImageClicked() |
105 | + } |
106 | + } |
107 | + |
108 | + TelegramBubble { |
109 | + id: bubble |
110 | + outgoing: messageDelegate.outgoing |
111 | anchors { |
112 | top: parent.top |
113 | - topMargin: units.gu(1) |
114 | - left: parent.left |
115 | - leftMargin: outgoing ? units.gu(1) : units.gu(2) |
116 | - right: parent.right |
117 | - rightMargin: units.gu(1.5) |
118 | - } |
119 | - height: childrenRect.height |
120 | - |
121 | - Text { |
122 | - id: senderLabel |
123 | - anchors.top: parent.top |
124 | - height: text === "" ? 0 : implicitHeight |
125 | - font.pixelSize: FontUtils.sizeToPixels("small") |
126 | - font.weight: Font.Normal |
127 | - color: senderColor |
128 | - text: senderName |
129 | - } |
130 | - |
131 | - Text { |
132 | - id: messageLabel |
133 | - anchors{ |
134 | - top: senderLabel.bottom |
135 | - } |
136 | - height: paintedHeight |
137 | - width: Math.min(implicitWidth, 0.7 * internalDelegate.width) |
138 | - wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
139 | - font.pixelSize: mediaType != TLMessageMedia.TypeMessageMediaEmpty ? |
140 | - FontUtils.sizeToPixels("small") : FontUtils.sizeToPixels("medium") |
141 | - font.weight: mediaType != TLMessageMedia.TypeMessageMediaEmpty ? |
142 | - Font.DemiBold : Font.Normal |
143 | - color: textColor |
144 | - text: parseText(message) |
145 | - onLinkActivated: Qt.openUrlExternally(link) |
146 | - |
147 | - // Taken from messaging-app |
148 | - function parseText(text) { |
149 | - var phoneExp = /(\+?([0-9]+[ ]?)?\(?([0-9]+)\)?[-. ]?([0-9]+)[-. ]?([0-9]+)[-. ]?([0-9]+))/img; |
150 | - // remove html tags |
151 | - text = text.replace(/</g,'<').replace(/>/g,'<tt>></tt>'); |
152 | - // replace line breaks |
153 | - text = text.replace(/(\n)+/g, '<br />'); |
154 | - // check for links |
155 | - var htmlText = BaLinkify.linkify(text); |
156 | - if (htmlText !== text) { |
157 | - return htmlText |
158 | - } |
159 | - // linkify phone numbers if no web links were found |
160 | - return text.replace(phoneExp, '<a href="tel:///$1">$1</a>'); |
161 | - } |
162 | - } |
163 | - |
164 | - Image { |
165 | - id: messagePhoto |
166 | - |
167 | - anchors{ |
168 | - horizontalCenter: parent.horizontalCenter |
169 | - top: senderLabel.bottom |
170 | - } |
171 | - asynchronous: true |
172 | - visible: source !== "" |
173 | - fillMode: Image.PreserveAspectFit |
174 | - sourceSize.width: 0.6 * internalDelegate.width |
175 | - sourceSize.height: 0.6 * internalDelegate.width |
176 | - source: { |
177 | - console.log("messagePhoto source: " + thumbnail); |
178 | - return Qt.resolvedUrl(thumbnail); |
179 | - } |
180 | - |
181 | - onStatusChanged: { |
182 | - if (status === Image.Error) { |
183 | - source = "image://theme/image-missing" |
184 | - width = 128 |
185 | - height = 128 |
186 | - } |
187 | - } |
188 | - |
189 | - MouseArea { |
190 | - anchors.fill: parent |
191 | - onClicked: { |
192 | - var properties = { "previewSource": parent.source }; |
193 | - pageStack.push(previewPage, properties); |
194 | - } |
195 | - } |
196 | - } |
197 | - |
198 | - Row { |
199 | - id: messageStatusRow |
200 | - |
201 | - spacing: units.gu(0.5) |
202 | - |
203 | + left: outgoing ? undefined: image.right |
204 | + leftMargin: units.gu(1) |
205 | + right: outgoing ? parent.right : undefined |
206 | + rightMargin: units.gu(1) |
207 | + } |
208 | + height: messageContents.height + units.gu(2) |
209 | + width: Math.max(messageLabel.width, senderLabel.width, messageStatusRow.width, messagePhoto.width) + units.gu(3) |
210 | + |
211 | + Item { |
212 | + id: messageContents |
213 | anchors { |
214 | - top: messagePhoto.source != "" ? messagePhoto.bottom : messageLabel.bottom |
215 | + top: parent.top |
216 | + topMargin: units.gu(1) |
217 | + left: parent.left |
218 | + leftMargin: outgoing ? units.gu(1) : units.gu(2) |
219 | right: parent.right |
220 | - } |
221 | - |
222 | - Text { |
223 | - id: timeLabel |
224 | - font.weight: Font.DemiBold |
225 | - font.pixelSize: FontUtils.sizeToPixels("x-small") |
226 | - color: outgoing ? Color.dark_green : Color.grey |
227 | - text: time |
228 | + rightMargin: units.gu(1.5) |
229 | + } |
230 | + height: childrenRect.height |
231 | + |
232 | + Text { |
233 | + id: senderLabel |
234 | + anchors.top: parent.top |
235 | + height: text === "" ? 0 : implicitHeight |
236 | + font.pixelSize: FontUtils.sizeToPixels("small") |
237 | + font.weight: Font.Normal |
238 | + color: senderColor |
239 | + text: senderName |
240 | + } |
241 | + |
242 | + Text { |
243 | + id: messageLabel |
244 | + anchors{ |
245 | + top: senderLabel.bottom |
246 | + } |
247 | + height: paintedHeight |
248 | + width: Math.min(implicitWidth, 0.7 * internalDelegate.width) |
249 | + wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
250 | + font.pixelSize: mediaType != TLMessageMedia.TypeMessageMediaEmpty ? |
251 | + FontUtils.sizeToPixels("small") : FontUtils.sizeToPixels("medium") |
252 | + font.weight: mediaType != TLMessageMedia.TypeMessageMediaEmpty ? |
253 | + Font.DemiBold : Font.Normal |
254 | + color: textColor |
255 | + text: parseText(message) |
256 | + onLinkActivated: Qt.openUrlExternally(link) |
257 | + |
258 | + // Taken from messaging-app |
259 | + function parseText(text) { |
260 | + var phoneExp = /(\+?([0-9]+[ ]?)?\(?([0-9]+)\)?[-. ]?([0-9]+)[-. ]?([0-9]+)[-. ]?([0-9]+))/img; |
261 | + // remove html tags |
262 | + text = text.replace(/</g,'<').replace(/>/g,'<tt>></tt>'); |
263 | + // replace line breaks |
264 | + text = text.replace(/(\n)+/g, '<br />'); |
265 | + // check for links |
266 | + var htmlText = BaLinkify.linkify(text); |
267 | + if (htmlText !== text) { |
268 | + return htmlText |
269 | + } |
270 | + // linkify phone numbers if no web links were found |
271 | + return text.replace(phoneExp, '<a href="tel:///$1">$1</a>'); |
272 | + } |
273 | } |
274 | |
275 | Image { |
276 | - id: messageSentStatus |
277 | - visible: !sent |
278 | - height: units.gu(1.4) |
279 | - width: height |
280 | - anchors.verticalCenter: timeLabel.verticalCenter |
281 | - source: sent ? "" : Qt.resolvedUrl("../images/dialog_clock_w.png") |
282 | + id: messagePhoto |
283 | + |
284 | + anchors{ |
285 | + horizontalCenter: parent.horizontalCenter |
286 | + top: senderLabel.bottom |
287 | + } |
288 | + asynchronous: true |
289 | + visible: source !== "" |
290 | + fillMode: Image.PreserveAspectFit |
291 | + sourceSize.width: 0.6 * internalDelegate.width |
292 | + sourceSize.height: 0.6 * internalDelegate.width |
293 | + source: { |
294 | + console.log("messagePhoto source: " + thumbnail); |
295 | + return Qt.resolvedUrl(thumbnail); |
296 | + } |
297 | + |
298 | + onStatusChanged: { |
299 | + if (status === Image.Error) { |
300 | + source = "image://theme/image-missing" |
301 | + width = 128 |
302 | + height = 128 |
303 | + } |
304 | + } |
305 | + |
306 | + MouseArea { |
307 | + anchors.fill: parent |
308 | + onClicked: { |
309 | + var properties = { "previewSource": parent.source }; |
310 | + pageStack.push(previewPage, properties); |
311 | + } |
312 | + } |
313 | + } |
314 | + |
315 | + Row { |
316 | + id: messageStatusRow |
317 | + |
318 | + spacing: units.gu(0.5) |
319 | + |
320 | + anchors { |
321 | + top: messagePhoto.source != "" ? messagePhoto.bottom : messageLabel.bottom |
322 | + right: parent.right |
323 | + } |
324 | + |
325 | + Text { |
326 | + id: timeLabel |
327 | + font.weight: Font.DemiBold |
328 | + font.pixelSize: FontUtils.sizeToPixels("x-small") |
329 | + color: outgoing ? Color.dark_green : Color.grey |
330 | + text: time |
331 | + } |
332 | + |
333 | + Image { |
334 | + id: messageSentStatus |
335 | + visible: !sent |
336 | + height: units.gu(1.4) |
337 | + width: height |
338 | + anchors.verticalCenter: timeLabel.verticalCenter |
339 | + source: sent ? "" : Qt.resolvedUrl("../images/dialog_clock_w.png") |
340 | + } |
341 | } |
342 | } |
343 | } |
344 | |
345 | === modified file 'components/TelegramSection.qml' |
346 | --- components/TelegramSection.qml 2014-08-08 17:23:03 +0000 |
347 | +++ components/TelegramSection.qml 2014-10-09 21:21:05 +0000 |
348 | @@ -3,7 +3,7 @@ |
349 | import "TelegramColors.js" as Color |
350 | |
351 | Item { |
352 | - anchors.margins: units.gu(1) |
353 | + property alias text: sectionLabel.text |
354 | |
355 | width: parent.width |
356 | height: childrenRect.height + units.gu(1) |
357 | |
358 | === modified file 'js/time.js' |
359 | --- js/time.js 2014-08-19 00:25:56 +0000 |
360 | +++ js/time.js 2014-10-09 21:21:05 +0000 |
361 | @@ -22,6 +22,12 @@ |
362 | return Qt.formatDate(date, "MMM d"); |
363 | } |
364 | |
365 | +function formatSection(time) { |
366 | + var date = new Date(time); |
367 | + |
368 | + return Qt.formatDate(date, "MMMM d"); |
369 | +} |
370 | + |
371 | function formatLastSeen(time) { |
372 | var date = new Date(time); |
373 | var today = new Date(); |
374 | @@ -42,3 +48,13 @@ |
375 | |
376 | return Qt.formatTime(date, "hh:mm"); |
377 | } |
378 | + |
379 | +function areSameDay(date1, date2) { |
380 | + var firstDate = new Date(date1) |
381 | + var secondDate = new Date(date2) |
382 | + if (!firstDate || !secondDate) |
383 | + return false |
384 | + return firstDate.getFullYear() == secondDate.getFullYear() |
385 | + && firstDate.getMonth() == secondDate.getMonth() |
386 | + && firstDate.getDate() == secondDate.getDate() |
387 | +} |
388 | |
389 | === modified file 'ui/DialogPage.qml' |
390 | --- ui/DialogPage.qml 2014-10-09 11:33:15 +0000 |
391 | +++ ui/DialogPage.qml 2014-10-09 21:21:05 +0000 |
392 | @@ -198,6 +198,9 @@ |
393 | outgoing: model.out |
394 | message: getMessageText(model.mediaType) |
395 | mediaType: model.mediaType |
396 | + //FIXME: When section headers upstream bug is resolved revet this with section headers. |
397 | + sectionVisible: (index === list.count) || !Time.areSameDay((messagesProxy.get(index+1).date * 1000),model.date*1000) |
398 | + sectionText: Time.formatSection(model.date * 1000) |
399 | senderColor: Avatar.getColor(model.fromId) |
400 | senderName: (!isChat || outgoing) ? "" : getSenderName() |
401 | senderImage: { |
Very well. It's hard to review the bits that supposedly did not change, as most that changed in their regard is indentation, so it's hard to follow, but the related changed bits look solid and well integrated. Good stuff. Feel free to merge to lp:libqtelegram/app-dev
https:/ /code.launchpad .net/~mihirsoni /libqtelegram/ addedGetFunctio n/+merge/ 237492
to lp:libqtelegram/dev
As always, make sure you first merge back any changes that have been made since. Thanks.