author | hgs |
Fri, 06 Aug 2010 13:16:44 +0300 | |
changeset 53 | 22cc52eade9b |
parent 46 | bc5a64e5bc3c |
child 51 | f39ed5e045e0 |
child 60 | 1eef62f5c541 |
permissions | -rw-r--r-- |
37 | 1 |
/*! |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Phone UI's Qt view. |
|
15 |
* |
|
16 |
*/ |
|
17 |
#include <hbinstance.h> |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
18 |
#include <QSignalMapper> |
37 | 19 |
#include <hbaction.h> |
20 |
#include <hbtoolbar.h> |
|
21 |
#include <hbvolumesliderpopup.h> |
|
22 |
#include <hbnamespace.h> |
|
23 |
#include <bubblemanager2.h> |
|
24 |
#include <hblineedit.h> |
|
25 |
#include <hbmenu.h> |
|
26 |
||
27 |
#include <xqserviceutil.h> |
|
28 |
#include <xqkeycapture.h> |
|
29 |
#include <dialpad.h> |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
30 |
#include <dialpadkeyhandler.h> |
37 | 31 |
|
32 |
#include "phoneuiqtview.h" |
|
33 |
#include "phoneaction.h" |
|
34 |
#include "qtphonelog.h" |
|
35 |
||
36 |
PhoneUIQtView::PhoneUIQtView (HbMainWindow &window, QGraphicsItem *parent) : |
|
37 |
HbView (parent), |
|
38 |
m_window(window), |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
39 |
m_bubbleManager(0), |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
40 |
m_signalMapper(0), |
37 | 41 |
m_volumeSlider (0), |
42 |
m_expandSignalMapper(0), |
|
43 |
m_participantListSignalMapper(0), |
|
44 |
m_volumeCommandId(0), |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
45 |
m_backAction(0), |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
46 |
m_dialpad(0), |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
47 |
m_menuSignalMapper(0), |
37 | 48 |
m_keyCapture(0), |
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
49 |
m_networkInfo(0), |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
50 |
m_dialpadKeyHandler(0), |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
51 |
m_restrictedMode(false) |
37 | 52 |
{ |
53 |
// Set network name |
|
54 |
m_networkInfo = new QSystemNetworkInfo(this); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
55 |
QString networkName = m_networkInfo->networkName(QSystemNetworkInfo::WcdmaMode); |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
56 |
if(networkName.isEmpty()) { |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
57 |
networkName = m_networkInfo->networkName(QSystemNetworkInfo::GsmMode); |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
58 |
} |
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
59 |
connect(m_networkInfo, SIGNAL (networkNameChanged(QSystemNetworkInfo::NetworkMode,QString)), |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
60 |
this, SLOT(networkNameChanged(QSystemNetworkInfo::NetworkMode, QString))); |
37 | 61 |
setTitle(networkName); |
62 |
||
63 |
// Capturing long press of end key |
|
64 |
m_keyCapture = new XqKeyCapture(); |
|
65 |
||
66 |
// Dialpad |
|
67 |
m_dialpad = new Dialpad(m_window); |
|
68 |
m_dialpad->setCallButtonEnabled(false); |
|
69 |
m_dialpad->setTapOutsideDismiss(true); |
|
70 |
connect(m_dialpad,SIGNAL(aboutToClose()),this, |
|
71 |
SLOT(dialpadClosed())); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
72 |
|
37 | 73 |
// Call handling widget |
74 |
m_bubbleManager = new BubbleManager (this); |
|
75 |
setWidget(m_bubbleManager); |
|
76 |
||
77 |
// Set event filter |
|
78 |
m_window.installEventFilter(this); |
|
79 |
||
80 |
m_signalMapper = new QSignalMapper (this); |
|
81 |
connect(m_signalMapper, SIGNAL (mapped (int)), this, SIGNAL (command (int))); |
|
82 |
connect(&m_window,SIGNAL(orientationChanged(Qt::Orientation)), |
|
83 |
this,SLOT(handleOrientationChange(Qt::Orientation))); |
|
84 |
||
85 |
m_menuSignalMapper = new QSignalMapper(this); |
|
86 |
connect(m_menuSignalMapper, SIGNAL(mapped(int)), this, SIGNAL(command(int))); |
|
87 |
||
88 |
m_bubbleManager->handleOrientationChange(m_window.orientation()); |
|
89 |
||
90 |
// change exit softkey to back button |
|
91 |
m_backAction = new HbAction(Hb::BackNaviAction, this); |
|
92 |
connect(m_backAction, SIGNAL(triggered()), this, SLOT(backButtonClicked())); |
|
93 |
setNavigationAction(m_backAction); |
|
94 |
||
95 |
createToolBarActions(); |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
96 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
97 |
// Set restricted mode off, normal state |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
98 |
setRestrictedMode(false); |
37 | 99 |
} |
100 |
||
101 |
PhoneUIQtView::~PhoneUIQtView () |
|
102 |
{ |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
103 |
qDeleteAll(m_toolbarActions); |
37 | 104 |
m_window.removeEventFilter(this); |
105 |
delete m_volumeSlider; |
|
106 |
delete m_dialpad; |
|
107 |
} |
|
108 |
||
109 |
BubbleManagerIF& PhoneUIQtView::bubbleManager() |
|
110 |
{ |
|
111 |
return *m_bubbleManager; |
|
112 |
} |
|
113 |
||
114 |
void PhoneUIQtView::addBubbleCommand ( |
|
115 |
int bubbleId, |
|
116 |
const PhoneAction& action ) |
|
117 |
{ |
|
118 |
HbAction* bubbleAction = new HbAction (); |
|
119 |
bubbleAction->setText (action.text()); |
|
120 |
bubbleAction->setIcon (action.icon()); |
|
121 |
setActionRole(action,*bubbleAction); |
|
122 |
m_bubbleManager->addAction (bubbleId, bubbleAction); |
|
123 |
||
124 |
QList<int> bubbles = m_bubbleMap.keys(); |
|
125 |
bool found(false); |
|
126 |
||
127 |
for ( int i=0; i<bubbles.size(); ++i ) { |
|
128 |
if (bubbleId==bubbles[i]){ |
|
129 |
connect(bubbleAction, SIGNAL (triggered ()), m_bubbleMap.value(bubbleId), SLOT (map ())); |
|
130 |
m_bubbleMap.value(bubbleId)->setMapping(bubbleAction, action.command()); |
|
131 |
m_bubbleActionMap.value(bubbleId)->append(bubbleAction); |
|
132 |
found = true; |
|
133 |
} |
|
134 |
} |
|
135 |
||
136 |
if (!found) { |
|
137 |
QSignalMapper *mapper = new QSignalMapper(); |
|
138 |
connect(mapper, SIGNAL (mapped (int)), this, SIGNAL (command (int))); |
|
139 |
connect(bubbleAction, SIGNAL (triggered ()), mapper, SLOT (map ())); |
|
140 |
mapper->setMapping (bubbleAction, action.command()); |
|
141 |
QList<HbAction *> *actionList = new QList<HbAction *>(); |
|
142 |
actionList->append( bubbleAction ); |
|
143 |
m_bubbleActionMap.insert(bubbleId,actionList); |
|
144 |
m_bubbleMap.insert(bubbleId,mapper); |
|
145 |
} |
|
146 |
} |
|
147 |
||
148 |
void PhoneUIQtView::addParticipantListAction( |
|
149 |
int commandId, |
|
150 |
const QString& text, |
|
151 |
const HbIcon& icon) |
|
152 |
{ |
|
153 |
HbAction* action = new HbAction (); |
|
154 |
action->setText (text); |
|
155 |
action->setIcon (icon); |
|
156 |
m_bubbleManager->addParticipantListAction(action); |
|
157 |
||
158 |
if (!m_participantListSignalMapper) { |
|
159 |
m_participantListSignalMapper = new QSignalMapper(); |
|
160 |
connect(m_participantListSignalMapper, SIGNAL (mapped (int)), this, SIGNAL (command (int))); |
|
161 |
} |
|
162 |
||
163 |
connect(action, SIGNAL (triggered ()), m_participantListSignalMapper, SLOT (map ())); |
|
164 |
m_participantListSignalMapper->setMapping (action, commandId); |
|
165 |
m_participantListActions.append( action ); |
|
166 |
} |
|
167 |
||
168 |
void PhoneUIQtView::clearParticipantListActions() |
|
169 |
{ |
|
170 |
||
171 |
if (m_participantListSignalMapper) { |
|
172 |
m_bubbleManager->clearParticipantListActions(); |
|
173 |
||
174 |
foreach (HbAction *action, m_participantListActions ) { |
|
175 |
m_participantListSignalMapper->removeMappings(action); |
|
176 |
} |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
177 |
qDeleteAll(m_participantListActions); |
37 | 178 |
m_participantListActions.clear(); |
179 |
delete m_participantListSignalMapper; |
|
180 |
m_participantListSignalMapper = 0; |
|
181 |
} |
|
182 |
||
183 |
} |
|
184 |
||
185 |
void PhoneUIQtView::clearBubbleCommands (int bubbleId) |
|
186 |
{ |
|
187 |
m_bubbleManager->clearActions (bubbleId); |
|
188 |
QSignalMapper *mapper = m_bubbleMap.value(bubbleId); |
|
189 |
||
190 |
if (mapper) { |
|
191 |
QList<HbAction *> *actions = m_bubbleActionMap.value(bubbleId); |
|
192 |
||
193 |
foreach (HbAction *action, *actions ) { |
|
194 |
mapper->removeMappings(action); |
|
195 |
delete action; |
|
196 |
} |
|
197 |
||
198 |
actions->clear(); |
|
199 |
m_bubbleMap.remove(bubbleId); |
|
200 |
m_bubbleActionMap.remove(bubbleId); |
|
201 |
delete mapper; |
|
202 |
delete actions; |
|
203 |
} |
|
204 |
||
205 |
} |
|
206 |
||
207 |
void PhoneUIQtView::setToolbarActions(const QList<PhoneAction*>& actions) |
|
208 |
{ |
|
209 |
// clear current toolbar actions |
|
210 |
for (int i=0;i<toolBar()->actions().count();++i) { |
|
211 |
m_signalMapper->removeMappings( |
|
212 |
static_cast<HbAction*>(toolBar()->actions().at(i))); |
|
213 |
} |
|
214 |
||
215 |
QList<QAction*> toolBarActions = toolBar()->actions(); |
|
216 |
||
217 |
if (toolBarActions.size()<actions.size()) { |
|
218 |
for (int i=toolBarActions.size(); i<actions.size(); ++i) { |
|
219 |
toolBar()->addAction(m_toolbarActions.at(i)); |
|
220 |
} |
|
221 |
} else if (toolBarActions.size()>actions.size()) { |
|
222 |
for (int i=toolBarActions.size(); 0<i; --i) { |
|
223 |
if (i>actions.size()) { |
|
224 |
HbAction* action = static_cast<HbAction*>(toolBarActions.at(i-1)); |
|
225 |
toolBar()->removeAction(action); |
|
226 |
} |
|
227 |
} |
|
228 |
} |
|
229 |
||
230 |
for (int i=0; i<toolBar()->actions().size(); ++i) { |
|
231 |
||
232 |
if (i<actions.count()) { |
|
233 |
HbAction* action = static_cast<HbAction*>(toolBar()->actions().at(i)); |
|
234 |
action->setText(actions.at(i)->text()); |
|
235 |
action->setIcon(actions.at(i)->icon()); |
|
236 |
action->setDisabled(actions.at(i)->isDisabled()); |
|
237 |
||
238 |
m_signalMapper->setMapping(action, actions.at(i)->command()); |
|
239 |
} |
|
240 |
} |
|
241 |
||
242 |
if ( m_window.orientation() == Qt::Horizontal ) { |
|
243 |
toolBar()->setOrientation(Qt::Horizontal); |
|
244 |
} |
|
245 |
// update toolbar |
|
246 |
toolBar()->update(); |
|
247 |
} |
|
248 |
||
249 |
void PhoneUIQtView::hideToolbar () |
|
250 |
{ |
|
251 |
toolBar()->hide (); |
|
252 |
} |
|
253 |
||
254 |
void PhoneUIQtView::showToolbar () |
|
255 |
{ |
|
256 |
setFocus(); |
|
257 |
toolBar()->show(); |
|
258 |
} |
|
259 |
||
260 |
int PhoneUIQtView::volumeSliderValue () |
|
261 |
{ |
|
262 |
if (m_volumeSlider) { |
|
263 |
return m_volumeSlider->value (); |
|
264 |
} else { |
|
265 |
return -1; |
|
266 |
} |
|
267 |
} |
|
268 |
||
269 |
void PhoneUIQtView::removeVolumeSlider () |
|
270 |
{ |
|
271 |
if (m_volumeSlider) { |
|
272 |
if (m_volumeSlider->isVisible()) { |
|
273 |
m_volumeSlider->hide(); |
|
274 |
} |
|
275 |
m_volumeSlider->deleteLater(); |
|
276 |
m_volumeSlider = 0; |
|
277 |
} |
|
278 |
} |
|
279 |
||
280 |
void PhoneUIQtView::volumeSliderClosed () |
|
281 |
{ |
|
282 |
removeVolumeSlider(); |
|
283 |
} |
|
284 |
||
285 |
void PhoneUIQtView::setVolumeSliderValue ( |
|
286 |
int value, int commandId, int maxVolumeValue, int minVolumeValue) |
|
287 |
{ |
|
288 |
m_volumeCommandId = commandId; |
|
289 |
||
290 |
if (!m_volumeSlider) { |
|
291 |
m_volumeSlider = new HbVolumeSliderPopup (); |
|
292 |
m_volumeSlider->setDismissPolicy(HbDialog::TapOutside); |
|
293 |
m_volumeSlider->setTimeout (10000); // TODO: 10 seconds for now, replace with correct value when spec is ready and says what it is |
|
294 |
connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeSliderChanged(int))); |
|
295 |
connect(m_volumeSlider, SIGNAL(aboutToClose()), this, SLOT(volumeSliderClosed())); |
|
296 |
} |
|
297 |
||
298 |
||
299 |
if (m_volumeSlider->minimum() != minVolumeValue || |
|
300 |
m_volumeSlider->maximum() != maxVolumeValue ) { |
|
301 |
m_volumeSlider->setRange (minVolumeValue, maxVolumeValue); |
|
302 |
} |
|
303 |
||
304 |
if (value != m_volumeSlider->value()) |
|
305 |
m_volumeSlider->setValue (value); |
|
306 |
||
307 |
if (false == m_volumeSlider->isVisible()) { |
|
308 |
m_volumeSlider->show(); |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
void PhoneUIQtView::volumeSliderChanged(int value) |
|
313 |
{ |
|
314 |
Q_UNUSED (value); |
|
315 |
emit command (m_volumeCommandId); |
|
316 |
} |
|
317 |
||
318 |
void PhoneUIQtView::setExpandAction(int bubbleId, int commandId) |
|
319 |
{ |
|
320 |
removeExpandAction(bubbleId); |
|
321 |
||
322 |
HbAction* action = new HbAction(); |
|
323 |
m_bubbleManager->setExpandAction(bubbleId, action); |
|
324 |
||
325 |
if (!m_expandSignalMapper) { |
|
326 |
m_expandSignalMapper = new QSignalMapper(this); |
|
327 |
connect(m_expandSignalMapper, SIGNAL (mapped (int)), |
|
328 |
this, SIGNAL (command (int))); |
|
329 |
} |
|
330 |
||
331 |
connect(action, SIGNAL (triggered ()), m_expandSignalMapper, SLOT (map ())); |
|
332 |
m_expandSignalMapper->setMapping(action, commandId); |
|
333 |
||
334 |
m_expandActionMap.insert(bubbleId,action); |
|
335 |
} |
|
336 |
||
337 |
void PhoneUIQtView::removeExpandAction(int bubbleId) |
|
338 |
{ |
|
339 |
if (m_expandActionMap.contains(bubbleId)) { |
|
340 |
m_bubbleManager->setExpandAction(bubbleId, 0); |
|
341 |
HbAction* action = m_expandActionMap.value(bubbleId); |
|
342 |
m_expandSignalMapper->removeMappings(action); |
|
343 |
m_expandActionMap.remove(bubbleId); |
|
344 |
delete action; |
|
345 |
} |
|
346 |
} |
|
347 |
||
348 |
void PhoneUIQtView::showDialpad() |
|
349 |
{ |
|
350 |
if (false == m_dialpad->isVisible()) { |
|
351 |
setDialpadPosition(); |
|
352 |
m_dialpad->openDialpad(); |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
void PhoneUIQtView::hideDialpad() |
|
357 |
{ |
|
358 |
if (true == m_dialpad->isVisible()) |
|
359 |
m_dialpad->closeDialpad(); |
|
360 |
} |
|
361 |
||
362 |
bool PhoneUIQtView::isDialpadVisible() |
|
363 |
{ |
|
364 |
return m_dialpad->isVisible(); |
|
365 |
} |
|
366 |
||
367 |
QString PhoneUIQtView::dialpadText() |
|
368 |
{ |
|
369 |
return m_dialpad->editor().text(); |
|
370 |
} |
|
371 |
||
372 |
void PhoneUIQtView::clearAndHideDialpad() |
|
373 |
{ |
|
374 |
m_dialpad->editor().setText(QString("")); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
375 |
m_dialpad->closeDialpad(); |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
376 |
} |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
377 |
|
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
378 |
void PhoneUIQtView::clearDialpad() |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
379 |
{ |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
380 |
m_dialpad->editor().setText(QString("")); |
37 | 381 |
} |
382 |
||
383 |
void PhoneUIQtView::bringToForeground() |
|
384 |
{ |
|
385 |
m_window.show(); |
|
386 |
} |
|
387 |
||
388 |
void PhoneUIQtView::setMenuActions(const QList<PhoneAction*>& actions) |
|
389 |
{ |
|
390 |
||
391 |
for (int i=menu()->actions().count(); 0<i; --i) { |
|
392 |
HbAction* action = static_cast<HbAction*>(menu()->actions().at(i-1)); |
|
393 |
m_menuSignalMapper->removeMappings(action); |
|
394 |
menu()->removeAction(action); |
|
395 |
delete action; |
|
396 |
} |
|
397 |
||
398 |
for (int i=0; i<actions.count(); ++i) { |
|
399 |
HbAction* action = new HbAction(); |
|
400 |
action->setText(actions.at(i)->text()); |
|
401 |
menu()->addAction(action); |
|
402 |
connect(action, SIGNAL(triggered()), m_menuSignalMapper, SLOT(map())); |
|
403 |
m_menuSignalMapper->setMapping(action, actions.at(i)->command()); |
|
404 |
} |
|
405 |
||
406 |
} |
|
407 |
||
408 |
HbMenu &PhoneUIQtView::menuReference() |
|
409 |
{ |
|
410 |
return *menu(); |
|
411 |
} |
|
412 |
||
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
413 |
void PhoneUIQtView::captureKey(Qt::Key key, bool capture) |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
414 |
{ |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
415 |
if (capture) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
416 |
if (!m_keyCaptures.contains(key)) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
417 |
m_keyCapture->captureLongKey(key); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
418 |
m_keyCapture->captureKey(key); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
419 |
m_keyCaptures.append(key); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
420 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
421 |
} else { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
422 |
if (m_keyCaptures.contains(key)) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
423 |
m_keyCapture->cancelCaptureKey(key); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
424 |
m_keyCapture->cancelCaptureLongKey(key); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
425 |
m_keyCaptures.removeOne(key); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
426 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
427 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
428 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
429 |
|
37 | 430 |
void PhoneUIQtView::handleOrientationChange(Qt::Orientation orientation) |
431 |
{ |
|
432 |
if (orientation==Qt::Horizontal) { |
|
433 |
toolBar()->setOrientation(Qt::Horizontal); |
|
434 |
} |
|
435 |
||
436 |
m_bubbleManager->handleOrientationChange(orientation); |
|
437 |
||
438 |
setDialpadPosition(); |
|
439 |
} |
|
440 |
||
441 |
void PhoneUIQtView::backButtonClicked() |
|
442 |
{ |
|
443 |
XQServiceUtil::toBackground(true); |
|
444 |
} |
|
445 |
||
446 |
void PhoneUIQtView::onEditorContentChanged() |
|
447 |
{ |
|
448 |
m_dialpad->setCallButtonEnabled( |
|
449 |
m_dialpad->editor().text().length()); |
|
450 |
} |
|
451 |
||
452 |
void PhoneUIQtView::dialpadClosed() |
|
453 |
{ |
|
454 |
emit dialpadIsAboutToClose(); |
|
455 |
} |
|
456 |
||
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
457 |
bool PhoneUIQtView::eventFilter(QObject *watched, QEvent * event) |
37 | 458 |
{ |
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
459 |
Q_UNUSED(watched); |
37 | 460 |
PHONE_DEBUG2("PhoneUIQtView::eventFilter event type:", event->type()); |
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
461 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
462 |
// Allow send key only when there is callbutton enabled or no text in input field |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
463 |
bool sendKeyAllowed = m_dialpad->isCallButtonEnabled() || |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
464 |
(m_dialpad->editor().text().length() == 0); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
465 |
|
37 | 466 |
if(event->type() == QEvent::KeyPress) { |
467 |
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); |
|
468 |
PHONE_DEBUG2("PhoneUIQtView::eventFilter pressed key:", keyEvent->key()); |
|
469 |
PHONE_DEBUG2("PhoneUIQtView::eventFilter isAutoRepeat:", keyEvent->isAutoRepeat()); |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
470 |
if ( (keyEvent->key() != Qt::Key_Yes && keyEvent->key() != Qt::Key_Enter) || |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
471 |
sendKeyAllowed) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
472 |
emit keyPressed(keyEvent); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
473 |
keyEvent->accept(); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
474 |
} |
37 | 475 |
|
476 |
return false; |
|
477 |
} else if(event->type() == QEvent::KeyRelease) { |
|
478 |
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); |
|
479 |
PHONE_DEBUG2("PhoneUIQtView::eventFilter released key:", keyEvent->key()); |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
480 |
if ( (keyEvent->key() != Qt::Key_Yes && keyEvent->key() != Qt::Key_Enter) || |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
481 |
sendKeyAllowed) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
482 |
emit keyReleased(keyEvent); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
483 |
keyEvent->accept(); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
484 |
} |
37 | 485 |
return false; |
486 |
} else if (event->type() == QEvent::WindowActivate){ |
|
487 |
PHONE_DEBUG("PhoneUIQtView::eventFilter WindowActivate"); |
|
488 |
emit windowActivated(); |
|
489 |
return false; |
|
490 |
} else if (event->type() == QEvent::WindowDeactivate){ |
|
491 |
PHONE_DEBUG("PhoneUIQtView::eventFilter WindowDeactivate"); |
|
492 |
emit windowDeactivated(); |
|
493 |
return false; |
|
494 |
}else{ |
|
495 |
return false; |
|
496 |
} |
|
497 |
} |
|
498 |
||
499 |
void PhoneUIQtView::setDialpadPosition() |
|
500 |
{ |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
501 |
QRectF screenRect(m_window.layoutRect()); |
37 | 502 |
|
503 |
if (m_window.orientation() == Qt::Horizontal) { |
|
504 |
// dialpad takes half of the screen |
|
505 |
m_dialpad->setPos(QPointF(screenRect.width()/2, |
|
506 |
this->scenePos().y())); |
|
507 |
m_dialpad->setPreferredSize(screenRect.width()/2, |
|
508 |
(screenRect.height()-scenePos().y())); |
|
509 |
} else { |
|
510 |
// dialpad takes 65% of the screen height |
|
511 |
qreal screenHeight = screenRect.height(); |
|
512 |
m_dialpad->setPos(QPointF(0, |
|
513 |
screenHeight/2.25)); |
|
514 |
m_dialpad->setPreferredSize(screenRect.width(), |
|
515 |
screenHeight-screenHeight/2.25); |
|
516 |
} |
|
517 |
} |
|
518 |
||
519 |
void PhoneUIQtView::setActionRole(const PhoneAction& pa, HbAction& action) |
|
520 |
{ |
|
521 |
if (pa.actionRole()==PhoneAction::Accept) { |
|
522 |
action.setSoftKeyRole(QAction::PositiveSoftKey); |
|
523 |
} else if (pa.actionRole()==PhoneAction::Decline) { |
|
524 |
action.setSoftKeyRole(QAction::NegativeSoftKey); |
|
525 |
} |
|
526 |
} |
|
527 |
||
528 |
void PhoneUIQtView::createToolBarActions() |
|
529 |
{ |
|
530 |
for (int i=0;i<4;++i) { |
|
531 |
HbAction* action = new HbAction(); |
|
532 |
connect(action, SIGNAL(triggered()), m_signalMapper, SLOT(map())); |
|
533 |
m_toolbarActions.append(action); |
|
534 |
} |
|
535 |
} |
|
536 |
||
537 |
void PhoneUIQtView::shutdownPhoneApp() |
|
538 |
{ |
|
539 |
PHONE_DEBUG("PhoneUIQtView::shutdownPhoneApp"); |
|
540 |
QCoreApplication::quit(); |
|
541 |
} |
|
542 |
||
543 |
void PhoneUIQtView::setBackButtonVisible(bool visible) |
|
544 |
{ |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
545 |
if (!m_restrictedMode) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
546 |
m_backAction->setEnabled(visible); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
547 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
548 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
549 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
550 |
void PhoneUIQtView::setRestrictedMode(bool restrictedMode) |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
551 |
{ |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
552 |
m_restrictedMode = restrictedMode; |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
553 |
m_backAction->setEnabled(!restrictedMode); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
554 |
m_dialpad->setCallButtonEnabled(false); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
555 |
m_dialpad->editor().setText(""); // Clead dialpad |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
556 |
if (m_restrictedMode) { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
557 |
delete m_dialpadKeyHandler; |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
558 |
m_dialpadKeyHandler = 0; |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
559 |
m_dialpadKeyHandler = new DialpadKeyHandler( |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
560 |
m_dialpad, DialpadKeyHandler::EmergencyCall, this); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
561 |
disconnect(&m_dialpad->editor(),SIGNAL(contentsChanged()), |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
562 |
this, SLOT(onEditorContentChanged())); // Let emergency handler do updating |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
563 |
} else { |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
564 |
delete m_dialpadKeyHandler; |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
565 |
m_dialpadKeyHandler = 0; |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
566 |
// enable key sequence handling during a call |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
567 |
m_dialpadKeyHandler = new DialpadKeyHandler( |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
568 |
m_dialpad, DialpadKeyHandler::KeySequence, this); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
569 |
connect(&m_dialpad->editor(),SIGNAL(contentsChanged()), |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
570 |
SLOT(onEditorContentChanged())); // Update our self |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
571 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
572 |
|
37 | 573 |
} |
574 |
||
575 |
void PhoneUIQtView::networkNameChanged(QSystemNetworkInfo::NetworkMode mode, const QString &netName) |
|
576 |
{ |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
577 |
if((mode == QSystemNetworkInfo::GsmMode) || |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
578 |
(mode == QSystemNetworkInfo::WcdmaMode)) { |
37 | 579 |
setTitle(netName); |
580 |
} |
|
581 |
} |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
582 |