57
71
if (participants.length == 1) {
58
72
return firstRecipient
60
var numOther = participants.length-1
61
return firstRecipient + " +" + i18n.tr("%1 other", "%1 others", numOther).arg(numOther)
74
return i18n.tr("Group")
64
77
return i18n.tr("New Message")
66
tools: messagesToolbar
67
onSelectionModeChanged: messagesToolbar.opened = false
81
return messagesToolbarSelectionMode
84
if (participants.length == 0) {
86
} else if (participants.length == 1) {
87
if (contactWatcher.isUnknown) {
88
return messagesToolbarUnknownContact
90
return messagesToolbarKnownContact
92
} else if (groupChat){
93
return messagesToolbarGroupChat
68
97
Component.onCompleted: {
69
98
threadId = getCurrentThreadId()
182
rightMargin: units.gu(1)
184
bottom: parent.bottom
187
visible: participants.length == 0 && isReady && messages.active
188
MultiRecipientInput {
190
objectName: "multiRecipient"
192
width: childrenRect.width
196
rightMargin: units.gu(1)
197
verticalCenter: parent.verticalCenter
202
visible: multiRecipient.visible
207
verticalCenter: parent.verticalCenter
215
Qt.inputMethod.hide()
216
mainStack.push(Qt.resolvedUrl("NewRecipientPage.qml"), {"multiRecipient": multiRecipient})
224
property bool searchEnabled: multiRecipient.searchString !== "" && multiRecipient.focus
225
visible: searchEnabled
226
detailToPick: ContactDetail.PhoneNumber
231
property string searchTerm: {
232
if(multiRecipient.searchString !== "" && multiRecipient.focus) {
233
return multiRecipient.searchString
240
when: contactSearch.count === 0
242
target: contactSearch
252
bottom: bottomPanel.top
256
UbuntuNumberAnimation { }
259
onSearchTermChanged: {
260
if ((searchTerm.length > 0) && (filter != contactSearchFilter)) {
261
changeFilter(contactSearchFilter)
262
} else if ((searchTerm.length == 0) && (filter != null)) {
265
contactSearchTimeout.restart()
272
// clear list if it is invisible to save some memory
274
if (visible && (filter != null)) {
276
} else if (!visible && filter != invalidFilter) {
277
changeFilter(invalidFilter)
279
contactSearch.update()
283
if (action === "message" || action === "") {
284
multiRecipient.addRecipient(detail.number)
285
multiRecipient.clearSearch()
286
multiRecipient.forceActiveFocus()
287
} else if (action === "call") {
288
Qt.inputMethod.hide()
289
Qt.openUrlExternally("tel:///" + encodeURIComponent(detail.number))
294
Qt.inputMethod.hide()
295
Qt.openUrlExternally("addressbook:///contact?id=" + encodeURIComponent(contact.contactId))
299
id: contactSearchFilter
302
detail: ContactDetail.DisplayLabel
303
field: DisplayLabel.Label
304
value: contactSearch.searchTerm
305
matchFlags: DetailFilter.MatchContains
308
detail: ContactDetail.PhoneNumber
309
field: PhoneNumber.Number
310
value: contactSearch.searchTerm
311
matchFlags: DetailFilter.MatchPhoneNumber
315
detail: ContactDetail.PhoneNumber
316
field: PhoneNumber.Number
317
value: contactSearch.searchTerm
318
matchFlags: DetailFilter.MatchContains
323
id: contactSearchTimeout
328
onTriggered: contactSearch.update()
195
333
id: contactWatcher
196
334
phoneNumber: participants.length > 0 ? participants[0] : ""
200
338
threadId = getCurrentThreadId()
204
id: addPhoneNumberToContactSheet
206
// FIXME: workaround to set the contact list
207
// background to black
210
anchors.margins: -units.gu(1)
214
title: i18n.tr("Add to contact")
217
contentsHeight: parent.height
218
contentsWidth: parent.width
222
Qt.openUrlExternally("addressbook:///addphone?id=" + encodeURIComponent(contact.contactId) +
223
"&phone=" + encodeURIComponent(contactWatcher.phoneNumber))
224
PopupUtils.close(sheet)
227
onDoneClicked: PopupUtils.close(sheet)
232
id: addContactToConversationSheet
234
// FIXME: workaround to set the contact list
235
// background to black
238
anchors.margins: -units.gu(1)
242
title: i18n.tr("Add Contact")
245
contentsHeight: parent.height
246
contentsWidth: parent.width
249
detailToPick: ContactDetail.PhoneNumber
251
// FIXME: search for favorite number
252
multiRecipient.addRecipient(contact.phoneNumber.number)
253
multiRecipient.forceActiveFocus()
254
PopupUtils.close(sheet)
257
multiRecipient.addRecipient(detail.number)
258
PopupUtils.close(sheet)
259
multiRecipient.forceActiveFocus()
262
onDoneClicked: PopupUtils.close(sheet)
269
objectName: "selectMessagesButton"
270
visible: messageList.count !== 0
272
iconSource: "image://theme/select"
273
text: i18n.tr("Select")
274
onTriggered: messageList.startSelection()
278
visible: contactWatcher.isUnknown && participants.length == 1
342
id: messagesToolbarSelectionMode
344
back: ToolbarButton {
345
id: selectionModeCancelButton
346
objectName: "selectionModeCancelButton"
348
objectName: "selectionModeCancelAction"
349
iconSource: "image://theme/close"
350
onTriggered: messageList.cancelSelection()
354
id: selectionModeSelectAllButton
355
objectName: "selectionModeSelectAllButton"
357
objectName: "selectionModeSelectAllAction"
358
iconSource: "image://theme/filter"
359
onTriggered: messageList.selectAll()
363
id: selectionModeDeleteButton
364
objectName: "selectionModeDeleteButton"
366
objectName: "selectionModeDeleteAction"
367
enabled: messageList.selectedItems.count > 0
368
iconSource: "image://theme/delete"
369
onTriggered: messageList.endSelection()
375
id: messagesToolbarGroupChat
379
objectName: "groupChatButton"
381
iconSource: "image://theme/navigation-menu"
383
PopupUtils.open(participantsPopover, messages.header)
390
id: messagesToolbarUnknownContact
393
objectName: "contactCallButton"
395
visible: participants.length == 1
396
iconSource: "image://theme/call-start"
397
text: i18n.tr("Call")
399
Qt.inputMethod.hide()
400
Qt.openUrlExternally("tel:///" + encodeURIComponent(contactWatcher.phoneNumber))
279
405
objectName: "addContactButton"
407
visible: contactWatcher.isUnknown && participants.length == 1
281
408
iconSource: "image://theme/new-contact"
282
409
text: i18n.tr("Add")
411
Qt.inputMethod.hide()
284
412
PopupUtils.open(newContactDialog)
285
messagesToolbar.opened = false
290
visible: !contactWatcher.isUnknown && participants.length == 1
419
id: messagesToolbarKnownContact
422
objectName: "contactCallButton"
424
visible: participants.length == 1
425
iconSource: "image://theme/call-start"
426
text: i18n.tr("Call")
428
Qt.inputMethod.hide()
429
Qt.openUrlExternally("tel:///" + encodeURIComponent(contactWatcher.phoneNumber))
291
434
objectName: "contactProfileButton"
436
visible: !contactWatcher.isUnknown && participants.length == 1
293
437
iconSource: "image://theme/contact"
294
438
text: i18n.tr("Contact")
296
440
Qt.openUrlExternally("addressbook:///contact?id=" + encodeURIComponent(contactWatcher.contactId))
297
messagesToolbar.opened = false
302
visible: participants.length == 1
303
objectName: "contactCallButton"
305
iconSource: "image://theme/call-start"
306
text: i18n.tr("Call")
308
Qt.openUrlExternally("tel:///" + encodeURIComponent(contactWatcher.phoneNumber))
309
messagesToolbar.opened = false
313
locked: selectionMode
316
446
HistoryEventModel {
461
552
ListItem.ThinDivider {
462
553
anchors.top: parent.top
558
anchors.left: parent.left
559
anchors.leftMargin: units.gu(2)
560
anchors.verticalCenter: sendButton.verticalCenter
466
anchors.bottomMargin: units.gu(2)
467
anchors.bottom: attachButton.top
468
anchors.left: parent.left
469
anchors.leftMargin: units.gu(2)
470
anchors.right: parent.right
471
anchors.rightMargin: units.gu(2)
569
anchors.bottomMargin: units.gu(1)
570
anchors.bottom: parent.bottom
571
anchors.left: attachButton.right
572
anchors.leftMargin: units.gu(1)
573
anchors.right: sendButton.left
574
anchors.rightMargin: units.gu(1)
474
578
placeholderText: i18n.tr("Write a message...")
476
580
font.family: "Ubuntu"
485
589
Component.onCompleted: {
486
if (messages.keyboardFocus && participants.length != 0) {
590
// if page is active, it means this is not a bottom edge page
591
if (messages.active && messages.keyboardFocus && participants.length != 0) {
487
592
textEntry.forceActiveFocus()
494
anchors.left: parent.left
495
anchors.leftMargin: units.gu(2)
599
anchors.bottomMargin: units.gu(1)
496
600
anchors.bottom: parent.bottom
504
601
anchors.right: parent.right
505
602
anchors.rightMargin: units.gu(2)
506
anchors.bottom: parent.bottom
509
606
enabled: (textEntry.text != "" || textEntry.inputMethodComposing) && telepathyHelper.connected && (participants.length > 0 || multiRecipient.recipientCount > 0 )
511
608
// make sure we flush everything we have prepared in the OSK preedit
513
610
if (textEntry.text == "") {
517
613
if (participants.length == 0 && multiRecipient.recipientCount > 0) {
518
614
participants = multiRecipient.recipients
521
616
if (messages.accountId == "") {
522
617
// FIXME: handle dual sim
523
618
messages.accountId = telepathyHelper.accountIds[0]
526
if (messages.threadId == "") {
620
if (messages.newMessage) {
527
621
// create the new thread and get the threadId
528
622
messages.threadId = eventModel.threadIdForParticipants(messages.accountId,
529
623
HistoryThreadModel.EventTypeText,