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