~ubuntu-branches/ubuntu/utopic/sflphone/utopic-proposed

« back to all changes in this revision

Viewing changes to kde/plasma/plasmoid-qml/package/contents/ui/CallTab.qml

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2013-06-30 11:40:56 UTC
  • mfrom: (4.1.18 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130630114056-0np50jkyqo6vnmii
Tags: 1.2.3-2
* changeset_r92d62cfc54732bbbcfff2b1d36c096b120b981a5.diff 
  - fixes automatic endian detection 
* Update Vcs: fixes vcs-field-not-canonical

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *   Copyright (C) 2012 by Savoir-Faire Linux                                 *
 
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>   *
 
4
 *                                                                            *
 
5
 *   This library is free software; you can redistribute it and/or            *
 
6
 *   modify it under the terms of the GNU Lesser General Public               *
 
7
 *   License as published by the Free Software Foundation; either             *
 
8
 *   version 2.1 of the License, or (at your option) any later version.       *
 
9
 *                                                                            *
 
10
 *   This library is distributed in the hope that it will be useful,          *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        *
 
13
 *   Lesser General Public License for more details.                          *
 
14
 *                                                                            *
 
15
 *   You should have received a copy of the Lesser GNU General Public License *
 
16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.    *
 
17
 *****************************************************************************/
 
18
import QtQuick 1.1
 
19
import org.kde.plasma.components 0.1 as Plasma
 
20
import org.kde.plasma.core       0.1 as PlasmaCore
 
21
 
 
22
Plasma.Page {
 
23
   anchors.top: tabs.bottom
 
24
   width:parent.width
 
25
   height:parent.height - tabs.height
 
26
   id:callTab
 
27
 
 
28
   property string currentCall: ""
 
29
   property string currentCallId: ""
 
30
   property bool   requestNumberOverlay: false
 
31
 
 
32
   Component {
 
33
      id: callDelegate
 
34
      Rectangle {
 
35
         id:bookmarkItemRect
 
36
         width:parent.parent.width
 
37
         height: 50
 
38
         color: "#1a000000"
 
39
         radius: 5
 
40
         Row {
 
41
            spacing: 2
 
42
            anchors.margins: 4
 
43
            anchors.leftMargin: 50
 
44
            Rectangle {
 
45
               width: 10
 
46
               height: 48
 
47
               color: "#AAAAAA"
 
48
               border.color: "black"
 
49
               border.width: 1
 
50
               radius: 10
 
51
               anchors.leftMargin: 10
 
52
               Column {
 
53
                  anchors.centerIn: parent
 
54
                  Repeater {
 
55
                     model:3
 
56
                     Rectangle {
 
57
                        width:3
 
58
                        height:3
 
59
                        radius:2
 
60
                        color:"black"
 
61
                     }
 
62
                  }
 
63
               }
 
64
            }
 
65
            Image {
 
66
               property string callState: ""
 
67
               width:48
 
68
               fillMode: Image.PreserveAspectFit
 
69
               height:48
 
70
               sourceSize.width: parent.width
 
71
               sourceSize.height: parent.width
 
72
               Image {
 
73
               property string callState: stateName
 
74
               source: "plasmapackage:/images/contact.svg";
 
75
               width:48
 
76
               fillMode: Image.PreserveAspectFit
 
77
               height:48
 
78
               sourceSize.width: parent.width
 
79
               sourceSize.height: parent.width
 
80
               onCallStateChanged: {
 
81
                  if (callState == "Ringing (out)") {
 
82
                     source="plasmapackage:/images/state/ring.svg";
 
83
                  }
 
84
                  else if (callState == "Talking") {
 
85
                     source="plasmapackage:/images/state/current.svg";
 
86
                  }
 
87
                  else if (callState == "Hold") {
 
88
                     source="plasmapackage:/images/state/hold.svg";
 
89
                  }
 
90
                  else if (callState == "Busy") {
 
91
                     source="plasmapackage:/images/state/busy.svg";
 
92
                  }
 
93
                  else if (callState == "Failed") {
 
94
                     source="plasmapackage:/images/state/fail.svg";
 
95
                  }
 
96
                  else if (callState == "Ringing (in)") {
 
97
                     source="plasmapackage:/images/state/incoming.svg";
 
98
                  }
 
99
                  else if (callState == "Dialing") {
 
100
                     source="plasmapackage:/images/state/dial.svg";
 
101
                  }
 
102
                  else if (callState == "Transfer") {
 
103
                     source="plasmapackage:/images/state/transfert.svg";
 
104
                  }
 
105
                  else {
 
106
                     console.log("Unknow state")
 
107
                  }
 
108
               }
 
109
               Component.onCompleted: {
 
110
                  if (callState == "Ringing (out)") {
 
111
                     source="plasmapackage:/images/state/ring.svg";
 
112
                  }
 
113
                  else if (callState == "Talking") {
 
114
                     source="plasmapackage:/images/state/current.svg";
 
115
                  }
 
116
                  else if (callState == "Hold") {
 
117
                     source="plasmapackage:/images/state/hold.svg";
 
118
                  }
 
119
                  else if (callState == "Busy") {
 
120
                     source="plasmapackage:/images/state/busy.svg";
 
121
                  }
 
122
                  else if (callState == "Failed") {
 
123
                     source="plasmapackage:/images/state/fail.svg";
 
124
                  }
 
125
                  else if (callState == "Ringing (in)") {
 
126
                     source="plasmapackage:/images/state/incoming.svg";
 
127
                  }
 
128
                  else if (callState == "Dialing") {
 
129
                     source="plasmapackage:/images/state/dial.svg";
 
130
                  }
 
131
                  else if (callState == "Transfer") {
 
132
                     source="plasmapackage:/images/state/transfert.svg";
 
133
                  }
 
134
                  else {
 
135
                     console.log("Unknow state "+callState+" end"+stateName)
 
136
                  }
 
137
               }
 
138
            }
 
139
            }
 
140
 
 
141
            Column {
 
142
               Text { text: '<b>Name:</b> '   + peerName;color:  theme.textColor }
 
143
               Text { text: '<b>Number:</b> ' + peerNumber;color:   theme.textColor }
 
144
               //Text { text: '<b>E-Mail:</b>'  + preferredEmail;color: theme.textColor }
 
145
            }
 
146
         }
 
147
 
 
148
         MouseArea {
 
149
            anchors.fill: parent
 
150
            onClicked: {
 
151
               currentCallId = id;
 
152
               currentCall   = peerNumber;
 
153
            }
 
154
         }
 
155
         states: [
 
156
            State {
 
157
               name: "selected"
 
158
               when: (id==currentCallId)
 
159
               PropertyChanges {target: bookmarkItemRect; color: theme.highlightColor}
 
160
            }
 
161
         ]
 
162
      }
 
163
   }
 
164
 
 
165
   PlasmaCore.DataSource {
 
166
      id: callSource
 
167
      engine: "sflphone"
 
168
      interval: 250
 
169
      connectedSources: ["calls"]
 
170
      onDataChanged: {
 
171
         console.log("CALL LIST CHANGED")
 
172
         plasmoid.busy = false
 
173
      }
 
174
   }
 
175
 
 
176
   /*PlasmaCore.SortFilterModel {
 
177
      id: filter
 
178
      filterRole: "listPriority"
 
179
      sortRole: "listPriority"
 
180
      sortOrder: "DescendingOrder"
 
181
      sourceModel:PlasmaCore.SortFilterModel {
 
182
         filterRole: "peerName"
 
183
         sortRole: "peerName"
 
184
         sortOrder: "AscendingOrder"
 
185
         sourceModel:
 
186
      }
 
187
   }*/
 
188
 
 
189
 
 
190
   ListView {
 
191
      id: callList
 
192
      model: PlasmaCore.DataModel {
 
193
            dataSource: callSource
 
194
            keyRoleFilter: "[\\d]*"
 
195
         }
 
196
      width:parent.width
 
197
      height:parent.height-280
 
198
      delegate: callDelegate
 
199
      //anchors.fill:parent
 
200
      focus: true
 
201
      section {
 
202
            property: "section"
 
203
            delegate: ListSectiondelegate {}
 
204
      }
 
205
      onCountChanged: {
 
206
         if (count == 0) {
 
207
            currentCall = ""
 
208
            currentCallId = ""
 
209
         }
 
210
      }
 
211
   }
 
212
 
 
213
   Plasma.TextArea {
 
214
      id:display
 
215
      width:parent.width
 
216
      height:40
 
217
      focus:true
 
218
      readOnly:true
 
219
      anchors {
 
220
            top: callList.bottom;
 
221
            left: parent.left;
 
222
            right: parent.right;
 
223
      }
 
224
 
 
225
      function addText(text) {
 
226
         display.text = display.text+text
 
227
      }
 
228
 
 
229
      Keys.onPressed: {
 
230
         console.log("Key pressed")
 
231
         display.addText(event.key)
 
232
      }
 
233
      Keys.onReturnPressed: {
 
234
         console.log("Call")
 
235
 
 
236
      }
 
237
   }
 
238
   
 
239
   Image {
 
240
      source: "plasmapackage:/images/phone.svg";
 
241
      width:parent.width
 
242
      fillMode: Image.PreserveAspectFit
 
243
      height:parent.height-250
 
244
   }
 
245
 
 
246
   DialPad {
 
247
      anchors {
 
248
            top: display.bottom;
 
249
            left: parent.left;
 
250
            right: parent.right;
 
251
      }
 
252
      id: dialPad
 
253
      width:parent.width
 
254
      height:200
 
255
   }
 
256
 
 
257
   Rectangle {
 
258
      width:parent.width
 
259
      height:50
 
260
      anchors {
 
261
         top: dialPad.bottom;
 
262
         left: parent.left;
 
263
         right: parent.right;
 
264
      }
 
265
      Row {
 
266
         width:parent.width
 
267
         height:parent.height
 
268
         Plasma.Button {
 
269
            id:addContactButton
 
270
            width:parent.width/5
 
271
            height:parent.height
 
272
            iconSource: "list-add-user"
 
273
            onClicked: {
 
274
               call("112")
 
275
            }
 
276
         }
 
277
         Plasma.Button {
 
278
            id:newCallButton
 
279
            width:parent.width/6
 
280
            height:parent.height
 
281
            iconSource: "plasmapackage:/images/state/new_call.svg"
 
282
            visible:false
 
283
            onClicked: {
 
284
               currentCall   = ""
 
285
               currentCallId = ""
 
286
            }
 
287
         }
 
288
         Plasma.Button {
 
289
            id: buttonCall
 
290
            width:parent.width/5 * 3
 
291
            height:parent.height
 
292
            iconSource: "call-start"
 
293
            onClicked: {
 
294
               currentCall = display.text
 
295
               display.text = ""
 
296
               call(currentCall)
 
297
            }
 
298
         }
 
299
         Plasma.Button {
 
300
            id:buttonTransfer
 
301
            width:parent.width/5
 
302
            height:parent.height
 
303
            visible:false
 
304
            iconSource: "plasmapackage:/images/state/transfert.svg"
 
305
            onClicked: {
 
306
               if (currentCall != "") {
 
307
                  requestNumberOverlay = true
 
308
               }
 
309
            }
 
310
         }
 
311
         Plasma.Button {
 
312
            id:buttonHangUp
 
313
            width:parent.width/5
 
314
            height:parent.height
 
315
            visible:false
 
316
            iconSource: "plasmapackage:/images/state/hang_up.svg"
 
317
            onClicked: {
 
318
               console.log("Attempt to hangup "+currentCallId)
 
319
               if (currentCallId != "") {
 
320
                  hangUp(currentCallId)
 
321
               }
 
322
            }
 
323
         }
 
324
         Plasma.Button {
 
325
            id:buttonHold
 
326
            width:parent.width/5
 
327
            height:parent.height
 
328
            visible:false
 
329
            iconSource: "plasmapackage:/images/state/hold.svg"
 
330
            onClicked: {
 
331
               if (currentCall != "") {
 
332
                  hold(currentCallId)
 
333
               }
 
334
            }
 
335
         }
 
336
         Plasma.Button {
 
337
            id:buttonRecord
 
338
            width:parent.width/5
 
339
            height:parent.height
 
340
            visible:false
 
341
            iconSource: "plasmapackage:/images/state/record.svg"
 
342
            onClicked: {
 
343
               if (currentCall != "") {
 
344
                  record(currentCallId)
 
345
               }
 
346
            }
 
347
         }
 
348
         Plasma.Button {
 
349
            id:buttonClear
 
350
            width:parent.width/5
 
351
            height:parent.height
 
352
            iconSource: "edit-clear-locationbar-rtl"
 
353
            onClicked: {
 
354
               currentCall = ""
 
355
               display.text = ""
 
356
            }
 
357
         }
 
358
      }
 
359
   }
 
360
 
 
361
   states: [
 
362
      State {
 
363
         name: "dialing"
 
364
         when: (currentCall == "")
 
365
         PropertyChanges {
 
366
            target: buttonCall
 
367
         }
 
368
      },
 
369
      State {
 
370
         name: "active"
 
371
         when: (currentCall != "")
 
372
         PropertyChanges {
 
373
            target: buttonHangUp
 
374
            visible:true
 
375
            width:parent.width/3
 
376
         }
 
377
         PropertyChanges {
 
378
            target: addContactButton
 
379
            visible:false
 
380
         }
 
381
         PropertyChanges {
 
382
            target: newCallButton
 
383
            visible:true
 
384
         }
 
385
         PropertyChanges {
 
386
            target: buttonRecord
 
387
            visible:true
 
388
            width:parent.width/6
 
389
         }
 
390
         PropertyChanges {
 
391
            target: buttonTransfer
 
392
            visible:true
 
393
            width:parent.width/6
 
394
         }
 
395
         PropertyChanges {
 
396
            target: buttonHold
 
397
            visible:true
 
398
            width:parent.width/6
 
399
         }
 
400
         PropertyChanges {
 
401
            target: buttonCall
 
402
            //width:parent.width/5
 
403
            visible:false
 
404
         }
 
405
         PropertyChanges {
 
406
            target: buttonClear
 
407
            //width:parent.width/5
 
408
            visible:false
 
409
         }
 
410
      },
 
411
      State {
 
412
         name: "requestTransferOverlay"
 
413
         when: (requestNumberOverlay == true)
 
414
      }
 
415
   ]
 
416
}