Merge lp:~bfiller/messaging-app/rtm-14.09-sim-presence into lp:messaging-app/rtm-14.09

Proposed by Bill Filler
Status: Merged
Approved by: Bill Filler
Approved revision: 193
Merged at revision: 193
Proposed branch: lp:~bfiller/messaging-app/rtm-14.09-sim-presence
Merge into: lp:messaging-app/rtm-14.09
Diff against target: 279 lines (+156/-32)
4 files modified
src/qml/Dialogs/NoDefaultSIMCardDialog.qml (+1/-1)
src/qml/Messages.qml (+19/-26)
src/qml/PictureImport.qml (+114/-0)
src/qml/messaging-app.qml (+22/-5)
To merge this branch: bzr merge lp:~bfiller/messaging-app/rtm-14.09-sim-presence
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+231913@code.launchpad.net

Commit message

sim presence and call grouping merge from trunk

Description of the change

sim presence and call grouping merge from trunk

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/Dialogs/NoDefaultSIMCardDialog.qml'
2--- src/qml/Dialogs/NoDefaultSIMCardDialog.qml 2014-08-11 22:22:59 +0000
3+++ src/qml/Dialogs/NoDefaultSIMCardDialog.qml 2014-08-22 15:28:37 +0000
4@@ -35,7 +35,7 @@
5 anchors.horizontalCenter: parent.horizontalCenter
6 height: paintedHeight + units.gu(3)
7 Repeater {
8- model: telepathyHelper.accounts
9+ model: telepathyHelper.activeAccounts
10 delegate: Label {
11 text: modelData.displayName
12 color: UbuntuColors.orange
13
14=== modified file 'src/qml/Messages.qml'
15--- src/qml/Messages.qml 2014-08-12 15:14:25 +0000
16+++ src/qml/Messages.qml 2014-08-22 15:28:37 +0000
17@@ -36,7 +36,7 @@
18
19 // this property can be overriden by the user using the account switcher,
20 // in the suru divider
21- property QtObject account: mainView.defaultAccount
22+ property QtObject account: mainView.account
23
24 property variant participants: []
25 property bool groupChat: participants.length > 1
26@@ -80,25 +80,24 @@
27 // default account changes in system settings
28 Connections {
29 target: mainView
30- onDefaultAccountChanged: account = mainView.defaultAccount
31+ onAccountChanged: messages.account = mainView.account
32 }
33
34 ListModel {
35 id: attachments
36 }
37
38- Connections {
39- target: activeTransfer !== null ? activeTransfer : null
40- onStateChanged: {
41- var done = ((activeTransfer.state === ContentTransfer.Charged) ||
42- (activeTransfer.state === ContentTransfer.Aborted));
43+ PictureImport {
44+ id: pictureImporter
45
46- if (activeTransfer.state === ContentTransfer.Charged) {
47- if (activeTransfer.items.length > 0) {
48- addAttachmentsToModel(activeTransfer)
49- textEntry.forceActiveFocus()
50- }
51- }
52+ onPictureReceived: {
53+ var attachment = {}
54+ var filePath = String(pictureUrl).replace('file://', '')
55+ attachment["contentType"] = application.fileMimeType(filePath)
56+ attachment["name"] = filePath.split('/').reverse()[0]
57+ attachment["filePath"] = filePath
58+ attachments.append(attachment)
59+ textEntry.forceActiveFocus()
60 }
61 }
62
63@@ -175,13 +174,6 @@
64 return eventModel.markEventAsRead(accountId, threadId, eventId, type);
65 }
66
67- ContentPeer {
68- id: defaultSource
69- contentType: ContentType.Pictures
70- handler: ContentHandler.Source
71- selectionType: ContentTransfer.Single
72- }
73-
74 Component {
75 id: attachmentPopover
76
77@@ -262,8 +254,8 @@
78 }
79
80 var accountNames = []
81- for(var i=0; i < telepathyHelper.accounts.length; i++) {
82- accountNames.push(telepathyHelper.accounts[i].displayName)
83+ for(var i=0; i < telepathyHelper.activeAccounts.length; i++) {
84+ accountNames.push(telepathyHelper.activeAccounts[i].displayName)
85 }
86 return accountNames
87 }
88@@ -271,8 +263,8 @@
89 if (!messages.account) {
90 return -1
91 }
92- for (var i in telepathyHelper.accounts) {
93- if (telepathyHelper.accounts[i].accountId === messages.account.accountId) {
94+ for (var i in telepathyHelper.activeAccounts) {
95+ if (telepathyHelper.activeAccounts[i].accountId === messages.account.accountId) {
96 return i
97 }
98 }
99@@ -280,7 +272,7 @@
100 }
101 Connections {
102 target: messages.head.sections
103- onSelectedIndexChanged: messages.account = telepathyHelper.accounts[head.sections.selectedIndex]
104+ onSelectedIndexChanged: messages.account = telepathyHelper.activeAccounts[head.sections.selectedIndex]
105 }
106
107 Component {
108@@ -738,7 +730,8 @@
109 MouseArea {
110 anchors.fill: parent
111 onClicked: {
112- activeTransfer = defaultSource.request();
113+ Qt.inputMethod.hide()
114+ pictureImporter.requestNewPicture()
115 }
116 }
117 }
118
119=== added file 'src/qml/PictureImport.qml'
120--- src/qml/PictureImport.qml 1970-01-01 00:00:00 +0000
121+++ src/qml/PictureImport.qml 2014-08-22 15:28:37 +0000
122@@ -0,0 +1,114 @@
123+/*
124+ * Copyright (C) 2012-2014 Canonical, Ltd.
125+ *
126+ * This program is free software; you can redistribute it and/or modify
127+ * it under the terms of the GNU General Public License as published by
128+ * the Free Software Foundation; version 3.
129+ *
130+ * This program is distributed in the hope that it will be useful,
131+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
132+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133+ * GNU General Public License for more details.
134+ *
135+ * You should have received a copy of the GNU General Public License
136+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
137+ */
138+
139+import QtQuick 2.2
140+import Ubuntu.Components 1.1
141+import Ubuntu.Components.Popups 1.0 as Popups
142+import Ubuntu.Content 0.1 as ContentHub
143+
144+Item {
145+ id: root
146+
147+ property var importDialog: null
148+
149+ signal pictureReceived(string pictureUrl)
150+
151+ function requestNewPicture()
152+ {
153+ if (!root.importDialog) {
154+ root.importDialog = PopupUtils.open(contentHubDialog, root)
155+ } else {
156+ console.warn("Import dialog already running")
157+ }
158+ }
159+
160+ Component {
161+ id: contentHubDialog
162+
163+ Popups.PopupBase {
164+ id: dialogue
165+
166+ property alias activeTransfer: signalConnections.target
167+
168+
169+ focus: true
170+
171+ Rectangle {
172+ anchors.fill: parent
173+
174+ ContentHub.ContentPeerPicker {
175+ id: peerPicker
176+
177+ anchors.fill: parent
178+ visible: dialogue.done
179+ contentType: ContentHub.ContentType.Pictures
180+ handler: ContentHub.ContentHandler.Source
181+
182+ onPeerSelected: {
183+ peer.selectionType = ContentHub.ContentTransfer.Single
184+ dialogue.activeTransfer = peer.request()
185+ }
186+
187+ onCancelPressed: {
188+ PopupUtils.close(root.importDialog)
189+ }
190+ }
191+ }
192+
193+ Connections {
194+ id: signalConnections
195+
196+ target: dialogue.activeTransfer
197+ onStateChanged: {
198+ var done = ((dialogue.activeTransfer.state === ContentHub.ContentTransfer.Charged) ||
199+ (dialogue.activeTransfer.state === ContentHub.ContentTransfer.Aborted))
200+
201+ if (dialogue.activeTransfer.state === ContentHub.ContentTransfer.Charged) {
202+ dialogue.hide()
203+ if (dialogue.activeTransfer.items.length > 0) {
204+ root.pictureReceived(dialogue.activeTransfer.items[0].url)
205+ }
206+ }
207+
208+ if (done) {
209+ acceptTimer.restart()
210+ }
211+ }
212+ }
213+
214+ // WORKAROUND: Work around for application becoming insensitive to touch events
215+ // if the dialog is dismissed while the application is inactive.
216+ // Just listening for changes to Qt.application.active doesn't appear
217+ // to be enough to resolve this, so it seems that something else needs
218+ // to be happening first. As such there's a potential for a race
219+ // condition here, although as yet no problem has been encountered.
220+ Timer {
221+ id: acceptTimer
222+
223+ interval: 100
224+ repeat: true
225+ running: false
226+ onTriggered: {
227+ if(Qt.application.active) {
228+ PopupUtils.close(root.importDialog)
229+ }
230+ }
231+ }
232+
233+ Component.onDestruction: root.importDialog = null
234+ }
235+ }
236+}
237
238=== modified file 'src/qml/messaging-app.qml'
239--- src/qml/messaging-app.qml 2014-08-12 15:14:25 +0000
240+++ src/qml/messaging-app.qml 2014-08-22 15:28:37 +0000
241@@ -28,16 +28,33 @@
242 id: mainView
243
244 property string newPhoneNumber
245- property bool multipleAccounts: telepathyHelper.accounts.length > 1
246- property QtObject defaultAccount: {
247+ property bool multipleAccounts: telepathyHelper.activeAccounts.length > 1
248+ property QtObject account: defaultAccount()
249+
250+ function defaultAccount() {
251 // we only use the default account property if we have more
252 // than one account, otherwise we use always the first one
253 if (multipleAccounts) {
254 return telepathyHelper.defaultMessagingAccount
255 } else {
256- return telepathyHelper.accounts[0]
257- }
258- }
259+ return telepathyHelper.activeAccounts[0]
260+ }
261+ }
262+
263+ Connections {
264+ target: telepathyHelper
265+ // restore default bindings if any system settings changed
266+ onActiveAccountsChanged: {
267+ for (var i in telepathyHelper.activeAccounts) {
268+ if (telepathyHelper.activeAccounts[i] == account) {
269+ return;
270+ }
271+ }
272+ account = Qt.binding(defaultAccount)
273+ }
274+ onDefaultMessagingAccountChanged: account = Qt.binding(defaultAccount)
275+ }
276+
277
278 automaticOrientation: true
279 width: units.gu(40)

Subscribers

People subscribed via source and target branches