|
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: Manages differnt messaging views. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "msgserviceviewmanager.h" |
|
19 |
|
20 #include <QPixmap> |
|
21 #include <HbMainWindow> |
|
22 #include <HbAction> |
|
23 #include <HbApplication> |
|
24 #include <hbmessagebox.h> |
|
25 |
|
26 #include <xqserviceutil.h> |
|
27 #include <xqappmgr.h> |
|
28 |
|
29 #include "msgunieditorview.h" |
|
30 #include "unifiedviewer.h" |
|
31 #include "msgstorehandler.h" |
|
32 |
|
33 #include "msgsettingsview.h" |
|
34 #include "convergedmessageid.h" |
|
35 #include "ringbc.h" |
|
36 #include "unidatamodelloader.h" |
|
37 #include "unidatamodelplugininterface.h" |
|
38 |
|
39 // CONSTANTS |
|
40 static const char SEND_EFFECT[] = "sendeffect"; |
|
41 static const char SEND_EFFECT_FILE[] = ":/effects/sendeffect.fxml"; |
|
42 |
|
43 // LOCALIZATION |
|
44 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
|
45 #define LOC_DLG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone") |
|
46 |
|
47 //---------------------------------------------------------------------------- |
|
48 // MsgViewInterface::MsgViewInterface |
|
49 // @see header |
|
50 //---------------------------------------------------------------------------- |
|
51 MsgServiceViewManager::MsgServiceViewManager(MsgStoreHandler* storeHandler, |
|
52 HbMainWindow* mainWindow, QObject* parent) : |
|
53 QObject(parent), mMainWindow(mainWindow), mUniEditor(NULL), |
|
54 mUniViewer(NULL), mSettingsView(NULL), mBackAction(NULL), |
|
55 mStoreHandler(storeHandler),mMessageId(-1) |
|
56 { |
|
57 //creating back action. |
|
58 mBackAction = new HbAction(Hb::BackNaviAction, this); |
|
59 connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction())); |
|
60 |
|
61 // create a temp view : which is required for lazy loading of other views |
|
62 HbView* tempView = new HbView(); |
|
63 mMainWindow->addView(tempView); |
|
64 mMainWindow->setCurrentView(tempView); |
|
65 } |
|
66 |
|
67 //---------------------------------------------------------------------------- |
|
68 // MsgServiceViewManager::~MsgServiceViewManager |
|
69 // @see header |
|
70 //---------------------------------------------------------------------------- |
|
71 MsgServiceViewManager::~MsgServiceViewManager() |
|
72 { |
|
73 |
|
74 } |
|
75 |
|
76 //---------------------------------------------------------------------------- |
|
77 // MsgServiceViewManager::onBackAction |
|
78 // @see header |
|
79 //---------------------------------------------------------------------------- |
|
80 void MsgServiceViewManager::onBackAction() |
|
81 { |
|
82 switch(mCurrentView) |
|
83 { |
|
84 case MsgBaseView::UNIEDITOR: |
|
85 { |
|
86 mUniEditor->saveContentToDrafts(); |
|
87 HbApplication::quit(); |
|
88 break; |
|
89 } |
|
90 case MsgBaseView::MSGSETTINGS: |
|
91 { |
|
92 //delete the settings instance |
|
93 if (mSettingsView) |
|
94 { |
|
95 mMainWindow->removeView(mSettingsView); |
|
96 delete mSettingsView; |
|
97 mSettingsView = NULL; |
|
98 } |
|
99 if(mUniEditor) |
|
100 { |
|
101 mMainWindow->setCurrentView(mUniEditor); |
|
102 mCurrentView = MsgBaseView::UNIEDITOR; |
|
103 } |
|
104 else |
|
105 { |
|
106 ConvergedMessage message; |
|
107 QVariantList param; |
|
108 QByteArray dataArray; |
|
109 QDataStream messageStream(&dataArray, |
|
110 QIODevice::WriteOnly | QIODevice::Append); |
|
111 message.serialize(messageStream); |
|
112 param << dataArray; |
|
113 |
|
114 // switch to editor |
|
115 switchToUniEditor(param); |
|
116 } |
|
117 break; |
|
118 } |
|
119 case MsgBaseView::UNIVIEWER: |
|
120 default: |
|
121 { |
|
122 HbApplication::quit(); |
|
123 break; |
|
124 } |
|
125 |
|
126 } |
|
127 } |
|
128 |
|
129 //---------------------------------------------------------------------------- |
|
130 // MsgServiceViewManager::switchView |
|
131 // @see header |
|
132 //---------------------------------------------------------------------------- |
|
133 void MsgServiceViewManager::switchView(const QVariantList& data) |
|
134 { |
|
135 int viewId = data.at(0).toInt(); |
|
136 switch (viewId) |
|
137 { |
|
138 case MsgBaseView::UNIEDITOR: |
|
139 { |
|
140 // except first 2 parameters pass other parameters |
|
141 QVariantList editorData; |
|
142 for(int a = 2; a < data.length(); ++a) |
|
143 { |
|
144 editorData << data.at(a); |
|
145 } |
|
146 switchToUniEditor(editorData); |
|
147 break; |
|
148 } |
|
149 |
|
150 case MsgBaseView::MSGSETTINGS: |
|
151 { |
|
152 switchToMsgSettings(data); |
|
153 break; |
|
154 } |
|
155 default: |
|
156 { |
|
157 // if send from editor is successful, then run effects |
|
158 int previousView = data.at(1).toInt(); |
|
159 if(previousView == MsgBaseView::UNIEDITOR) |
|
160 { |
|
161 startAnimation(SEND_EFFECT); |
|
162 } |
|
163 else |
|
164 { |
|
165 HbApplication::quit(); |
|
166 } |
|
167 } |
|
168 } |
|
169 } |
|
170 |
|
171 //---------------------------------------------------------------------------- |
|
172 // MsgServiceViewManager::send |
|
173 // @see header |
|
174 //---------------------------------------------------------------------------- |
|
175 void MsgServiceViewManager::send(const QString phoneNumber, |
|
176 const qint32 contactId, |
|
177 const QString displayName) |
|
178 { |
|
179 Q_UNUSED(contactId); |
|
180 ConvergedMessage message; |
|
181 ConvergedMessageAddress address; |
|
182 address.setAddress(phoneNumber); |
|
183 address.setAlias(displayName); |
|
184 message.addToRecipient(address); |
|
185 |
|
186 QVariantList param; |
|
187 QByteArray dataArray; |
|
188 QDataStream messageStream(&dataArray, |
|
189 QIODevice::WriteOnly | QIODevice::Append); |
|
190 message.serialize(messageStream); |
|
191 param << dataArray; |
|
192 |
|
193 // switch to editor |
|
194 switchToUniEditor(param); |
|
195 |
|
196 XQServiceUtil::toBackground(false); |
|
197 } |
|
198 |
|
199 //---------------------------------------------------------------------------- |
|
200 // MsgServiceViewManager::send |
|
201 // @see header |
|
202 //---------------------------------------------------------------------------- |
|
203 void MsgServiceViewManager::send(const QString phoneNumber, |
|
204 const QString alias, |
|
205 const QString bodyText) |
|
206 { |
|
207 ConvergedMessage message; |
|
208 ConvergedMessageAddress address; |
|
209 address.setAddress(phoneNumber); |
|
210 address.setAlias(alias); |
|
211 message.addToRecipient(address); |
|
212 message.setBodyText(bodyText); |
|
213 |
|
214 QVariantList param; |
|
215 QByteArray dataArray; |
|
216 QDataStream messageStream(&dataArray, |
|
217 QIODevice::WriteOnly | QIODevice::Append); |
|
218 message.serialize(messageStream); |
|
219 param << dataArray; |
|
220 |
|
221 // switch to editor |
|
222 switchToUniEditor(param); |
|
223 |
|
224 XQServiceUtil::toBackground(false); |
|
225 } |
|
226 |
|
227 //---------------------------------------------------------------------------- |
|
228 // MsgServiceViewManager::send |
|
229 // @see header |
|
230 //---------------------------------------------------------------------------- |
|
231 void MsgServiceViewManager::send(const QVariantMap addressList, |
|
232 const QString bodyText) |
|
233 { |
|
234 QStringList phoneNumList = addressList.keys(); |
|
235 |
|
236 ConvergedMessageAddressList addrList; |
|
237 |
|
238 int count = phoneNumList.count(); |
|
239 for( int i = 0; i < count; ++ i ) |
|
240 { |
|
241 QString phNum = phoneNumList[i]; |
|
242 ConvergedMessageAddress* address = new ConvergedMessageAddress(phNum, |
|
243 addressList.value(phNum).toString()); |
|
244 addrList.append(address); |
|
245 } |
|
246 |
|
247 ConvergedMessage message; |
|
248 message.addToRecipients(addrList); |
|
249 message.setBodyText(bodyText); |
|
250 |
|
251 QVariantList param; |
|
252 QByteArray dataArray; |
|
253 QDataStream messageStream(&dataArray, |
|
254 QIODevice::WriteOnly | QIODevice::Append); |
|
255 message.serialize(messageStream); |
|
256 param << dataArray; |
|
257 |
|
258 // switch to editor |
|
259 switchToUniEditor(param); |
|
260 |
|
261 XQServiceUtil::toBackground(false); |
|
262 } |
|
263 |
|
264 //---------------------------------------------------------------------------- |
|
265 // MsgServiceViewManager::send |
|
266 // @see header |
|
267 //---------------------------------------------------------------------------- |
|
268 void MsgServiceViewManager::send(QVariant data) |
|
269 { |
|
270 ConvergedMessage message; |
|
271 ConvergedMessageAttachmentList attachmentList; |
|
272 // handle multiple files from sendUI |
|
273 // e.g. contacts can send multiple vcards |
|
274 QStringList receivedFiles = data.toStringList(); |
|
275 int recFileCount = receivedFiles.count(); |
|
276 for (int i = 0; i < recFileCount; i++) { |
|
277 ConvergedMessageAttachment *attachment = |
|
278 new ConvergedMessageAttachment(receivedFiles.at(i)); |
|
279 attachmentList.append(attachment); |
|
280 } |
|
281 message.addAttachments(attachmentList); |
|
282 |
|
283 QVariantList param; |
|
284 QByteArray dataArray; |
|
285 QDataStream messageStream(&dataArray, |
|
286 QIODevice::WriteOnly | QIODevice::Append); |
|
287 message.serialize(messageStream); |
|
288 param << dataArray; |
|
289 |
|
290 // switch to editor |
|
291 switchToUniEditor(param); |
|
292 |
|
293 XQServiceUtil::toBackground(false); |
|
294 } |
|
295 |
|
296 //---------------------------------------------------------------------------- |
|
297 // MsgServiceViewManager::switchToUniEditor |
|
298 // @see header |
|
299 //---------------------------------------------------------------------------- |
|
300 void MsgServiceViewManager::switchToUniEditor(const QVariantList& editorData) |
|
301 { |
|
302 // construct |
|
303 if (!mUniEditor) { |
|
304 mUniEditor = new MsgUnifiedEditorView(); |
|
305 mMainWindow->addView(mUniEditor); |
|
306 mUniEditor->setNavigationAction(mBackAction); |
|
307 connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this, |
|
308 SLOT(switchView(const QVariantList&))); |
|
309 // construct completion : viewReady() signal was not called when |
|
310 // editor is constructed first time. |
|
311 // mUniEditor->doDelayedConstruction(); |
|
312 } |
|
313 |
|
314 // populate |
|
315 mUniEditor->populateContent(editorData); |
|
316 |
|
317 // set current view as editor |
|
318 mMainWindow->setCurrentView(mUniEditor); |
|
319 mCurrentView = MsgBaseView::UNIEDITOR; |
|
320 } |
|
321 |
|
322 //---------------------------------------------------------------------------- |
|
323 // MsgServiceViewManager::switchToMsgSettings |
|
324 // @see header |
|
325 //---------------------------------------------------------------------------- |
|
326 void MsgServiceViewManager::switchToMsgSettings(const QVariantList& data) |
|
327 { |
|
328 MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView; |
|
329 |
|
330 if (mCurrentView == MsgBaseView::UNIEDITOR) |
|
331 { |
|
332 view = (MsgSettingsView::SettingsView)data.at(2).toInt(); |
|
333 } |
|
334 |
|
335 mCurrentView = MsgBaseView::MSGSETTINGS; |
|
336 |
|
337 if (!mSettingsView) { |
|
338 mSettingsView = new MsgSettingsView(view); |
|
339 mSettingsView->setNavigationAction(mBackAction); |
|
340 mMainWindow->addView(mSettingsView); |
|
341 } |
|
342 mMainWindow->setCurrentView(mSettingsView); |
|
343 } |
|
344 |
|
345 //---------------------------------------------------------------------------- |
|
346 // MsgServiceViewManager::view |
|
347 // @see header |
|
348 //---------------------------------------------------------------------------- |
|
349 void MsgServiceViewManager::view(int msgId) |
|
350 { |
|
351 int msgType; |
|
352 int msgSubType; |
|
353 |
|
354 mMessageId = msgId; |
|
355 // Mark as read and get message type |
|
356 mStoreHandler->markAsReadAndGetType(msgId,msgType,msgSubType); |
|
357 |
|
358 switch (msgType) { |
|
359 case ConvergedMessage::Sms: |
|
360 case ConvergedMessage::Mms: |
|
361 case ConvergedMessage::MmsNotification: |
|
362 { |
|
363 handleSmsMmsMsg(msgId,msgType); |
|
364 break; |
|
365 } |
|
366 case ConvergedMessage::BioMsg: |
|
367 { |
|
368 if (msgSubType == ConvergedMessage::RingingTone) { |
|
369 handleRingtoneMsg(msgId); |
|
370 } |
|
371 else if (msgSubType == ConvergedMessage::Provisioning) { |
|
372 handleProvisoningMsg(msgId); |
|
373 } |
|
374 break; |
|
375 } |
|
376 case ConvergedMessage::BT: |
|
377 { |
|
378 handleBTMessage(msgId); |
|
379 break; |
|
380 } |
|
381 default: |
|
382 { |
|
383 // for un supported message show delete option |
|
384 HbMessageBox::question(LOC_DELETE_MESSAGE, |
|
385 this,SLOT(onDialogDeleteMsg(HbAction*)), |
|
386 HbMessageBox::Delete | HbMessageBox::Cancel); |
|
387 break; |
|
388 } |
|
389 } |
|
390 } |
|
391 |
|
392 // ---------------------------------------------------------------------------- |
|
393 // MsgServiceViewManager::handleSmsMmsMsg |
|
394 // @see header |
|
395 // ---------------------------------------------------------------------------- |
|
396 void MsgServiceViewManager::handleSmsMmsMsg(int msgId,int msgType) |
|
397 { |
|
398 if(mStoreHandler->isDraftMessage(msgId)) |
|
399 { |
|
400 ConvergedMessageId convergedMsgId = ConvergedMessageId(msgId); |
|
401 ConvergedMessage message; |
|
402 message.setMessageType((ConvergedMessage::MessageType) msgType); |
|
403 message.setMessageId(convergedMsgId); |
|
404 |
|
405 // Launch uni-editor view |
|
406 QByteArray dataArray; |
|
407 QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
408 message.serialize(messageStream); |
|
409 |
|
410 QVariantList params; |
|
411 params << MsgBaseView::UNIEDITOR; // target view |
|
412 params << MsgBaseView::SERVICE; // source view |
|
413 |
|
414 params << dataArray; |
|
415 |
|
416 // except first 2 parameters pass other parameters |
|
417 QVariantList editorData; |
|
418 for(int a = 2; a < params.length(); ++a) |
|
419 { |
|
420 editorData << params.at(a); |
|
421 } |
|
422 // construct |
|
423 if (!mUniEditor) { |
|
424 mUniEditor = new MsgUnifiedEditorView(); |
|
425 mMainWindow->addView(mUniEditor); |
|
426 mUniEditor->setNavigationAction(mBackAction); |
|
427 connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this, |
|
428 SLOT(switchView(const QVariantList&))); |
|
429 } |
|
430 |
|
431 // check if additional data for unieditor's consumption is available |
|
432 mUniEditor->openDraftsMessage(editorData); |
|
433 |
|
434 mMainWindow->setCurrentView(mUniEditor); |
|
435 mCurrentView = MsgBaseView::UNIEDITOR; |
|
436 } |
|
437 else |
|
438 { |
|
439 if (!mUniViewer) { |
|
440 mUniViewer = new UnifiedViewer(msgId); |
|
441 mUniViewer->setNavigationAction(mBackAction); |
|
442 mMainWindow->addView(mUniViewer); |
|
443 connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this, |
|
444 SLOT(switchView(const QVariantList&))); |
|
445 } |
|
446 mUniViewer->populateContent(msgId, true, 1); |
|
447 |
|
448 mMainWindow->setCurrentView(mUniViewer); |
|
449 |
|
450 // set current view as viewer |
|
451 mCurrentView = MsgBaseView::UNIVIEWER; |
|
452 } |
|
453 } |
|
454 |
|
455 // ---------------------------------------------------------------------------- |
|
456 // MsgServiceViewManager::handleRingtoneMsg |
|
457 // @see header |
|
458 // ---------------------------------------------------------------------------- |
|
459 void MsgServiceViewManager::handleRingtoneMsg(int msgId) |
|
460 { |
|
461 mMessageId = msgId; |
|
462 HbMessageBox::question(LOC_DLG_SAVE_RINGTONE, this, |
|
463 SLOT(onDialogSaveTone(HbAction*)), |
|
464 HbMessageBox::Save | HbMessageBox::Cancel); |
|
465 } |
|
466 |
|
467 // ---------------------------------------------------------------------------- |
|
468 // MsgServiceViewManager::handleProvisoningMsg |
|
469 // @see header |
|
470 // ---------------------------------------------------------------------------- |
|
471 void MsgServiceViewManager::handleProvisoningMsg(int msgId) |
|
472 { |
|
473 QString messageId; |
|
474 messageId.setNum(msgId); |
|
475 |
|
476 XQApplicationManager* aiwMgr = new XQApplicationManager(); |
|
477 |
|
478 XQAiwRequest* request = aiwMgr->create("com.nokia.services.MDM", |
|
479 "Provisioning", |
|
480 "ProcessMessage(QString)", true); // embedded |
|
481 |
|
482 if (request) { |
|
483 QList<QVariant> args; |
|
484 args << QVariant(messageId); |
|
485 request->setArguments(args); |
|
486 |
|
487 // Send the request |
|
488 bool res = request->send(); |
|
489 |
|
490 // Cleanup |
|
491 delete request; |
|
492 } |
|
493 |
|
494 delete aiwMgr; |
|
495 |
|
496 // close the application once its handled |
|
497 HbApplication::quit(); |
|
498 } |
|
499 |
|
500 //----------------------------------------------------------------------------- |
|
501 //MsgServiceViewManager::handleBTMessage() |
|
502 //@see header |
|
503 //----------------------------------------------------------------------------- |
|
504 void MsgServiceViewManager::handleBTMessage(int msgId) |
|
505 { |
|
506 XQApplicationManager* aiwMgr = new XQApplicationManager(); |
|
507 XQAiwRequest* request = |
|
508 aiwMgr->create("com.nokia.services.btmsgdispservices", "displaymsg", |
|
509 "displaymsg(int)", true); // embedded |
|
510 |
|
511 if (request) { |
|
512 QList<QVariant> args; |
|
513 args << QVariant(msgId); |
|
514 request->setArguments(args); |
|
515 |
|
516 // Send the request |
|
517 bool res = request->send(); |
|
518 |
|
519 // Cleanup |
|
520 delete request; |
|
521 } |
|
522 |
|
523 delete aiwMgr; |
|
524 |
|
525 // close the application once its handled |
|
526 HbApplication::quit(); |
|
527 } |
|
528 |
|
529 //----------------------------------------------------------------------------- |
|
530 //MsgServiceViewManager::onDialogDeleteMsg() |
|
531 //@see header |
|
532 //----------------------------------------------------------------------------- |
|
533 void MsgServiceViewManager::onDialogDeleteMsg(HbAction* action) |
|
534 { |
|
535 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
536 if (action == dlg->actions().at(0)) { |
|
537 mStoreHandler->deleteMessage(mMessageId); |
|
538 } |
|
539 HbApplication::quit(); // exit after handling |
|
540 } |
|
541 |
|
542 //----------------------------------------------------------------------------- |
|
543 //MsgServiceViewManager::onDialogSaveTone() |
|
544 //@see header |
|
545 //----------------------------------------------------------------------------- |
|
546 |
|
547 void MsgServiceViewManager::onDialogSaveTone(HbAction* action) |
|
548 { |
|
549 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
550 if (action == dlg->actions().at(0)) { |
|
551 |
|
552 UniDataModelLoader* pluginLoader = new UniDataModelLoader(); |
|
553 UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin( |
|
554 ConvergedMessage::BioMsg); |
|
555 pluginInterface->setMessageId(mMessageId); |
|
556 UniMessageInfoList attachments = pluginInterface->attachmentList(); |
|
557 |
|
558 QString attachmentPath = attachments.at(0)->path(); |
|
559 |
|
560 RingBc* ringBc = new RingBc(); |
|
561 ringBc->saveTone(attachmentPath); |
|
562 |
|
563 // clear attachement list : its allocated at data model |
|
564 while (!attachments.isEmpty()) { |
|
565 delete attachments.takeFirst(); |
|
566 } |
|
567 |
|
568 delete ringBc; |
|
569 delete pluginLoader; |
|
570 } |
|
571 |
|
572 // close the application once its handled |
|
573 HbApplication::quit(); |
|
574 } |
|
575 |
|
576 //----------------------------------------------------------------------------- |
|
577 //MsgServiceViewManager::startAnimation |
|
578 //@see header |
|
579 //----------------------------------------------------------------------------- |
|
580 void MsgServiceViewManager::startAnimation(QString effectEvent) |
|
581 { |
|
582 // take screen shot |
|
583 QGraphicsPixmapItem *animationScreenShot = screenShot(); |
|
584 if (animationScreenShot) |
|
585 { |
|
586 // but don't show it yet. |
|
587 animationScreenShot->hide(); |
|
588 animationScreenShot->setPos(0,0); |
|
589 animationScreenShot->setZValue(0); |
|
590 |
|
591 // hide items, so that background app's items are visible immediately |
|
592 mMainWindow->currentView()->hideItems(Hb::AllItems); |
|
593 |
|
594 // reset background & set the base transparent |
|
595 mMainWindow->setBackgroundImageName( |
|
596 mMainWindow->orientation(), QString("dummy_blank")); |
|
597 QPalette p = mMainWindow->viewport()->palette(); |
|
598 p.setColor(QPalette::Base, Qt::transparent); |
|
599 mMainWindow->viewport()->setPalette(p); |
|
600 |
|
601 // add animating item directly to the scene |
|
602 mMainWindow->scene()->addItem(animationScreenShot); |
|
603 |
|
604 // hide other views |
|
605 QList<HbView*> vws = mMainWindow->views(); |
|
606 while (!vws.isEmpty()) |
|
607 { |
|
608 HbView* view = vws.takeLast(); |
|
609 view->hide(); |
|
610 } |
|
611 |
|
612 // now show the animating item, and start animation on it |
|
613 animationScreenShot->show(); |
|
614 QString effectFile = getAnimationFile(effectEvent); |
|
615 HbEffect::add(animationScreenShot, effectFile, effectEvent); |
|
616 HbEffect::start(animationScreenShot, effectEvent, this, |
|
617 "onAnimationComplete"); |
|
618 } |
|
619 } |
|
620 |
|
621 //----------------------------------------------------------------------------- |
|
622 //MsgServiceViewManager::resetAnimation |
|
623 //@see header |
|
624 //----------------------------------------------------------------------------- |
|
625 void MsgServiceViewManager::resetAnimation( |
|
626 QString effectEvent, |
|
627 QGraphicsItem* item) |
|
628 { |
|
629 if (item) |
|
630 { |
|
631 QString effectFile = getAnimationFile(effectEvent); |
|
632 HbEffect::remove(item, effectFile, effectEvent); |
|
633 mMainWindow->scene()->removeItem(item); |
|
634 delete item; |
|
635 item = NULL; |
|
636 } |
|
637 } |
|
638 |
|
639 //----------------------------------------------------------------------------- |
|
640 //MsgServiceViewManager::onAnimationComplete |
|
641 //@see header |
|
642 //----------------------------------------------------------------------------- |
|
643 void MsgServiceViewManager::onAnimationComplete( |
|
644 const HbEffect::EffectStatus &status) |
|
645 { |
|
646 QGraphicsItem* item = status.item; |
|
647 QString effectEvent = status.effectEvent; |
|
648 resetAnimation(effectEvent, item); |
|
649 HbApplication::quit(); |
|
650 } |
|
651 |
|
652 //----------------------------------------------------------------------------- |
|
653 //MsgServiceViewManager::screenShot |
|
654 //@see header |
|
655 //----------------------------------------------------------------------------- |
|
656 QGraphicsPixmapItem* MsgServiceViewManager::screenShot() |
|
657 { |
|
658 // set fullscreen and hide unwanted items |
|
659 mMainWindow->currentView()->hideItems(Hb::ToolBarItem | Hb::DockWidgetItem | Hb::StatusBarItem); |
|
660 mMainWindow->currentView()->setContentFullScreen(true); |
|
661 |
|
662 // grab whole view into pixmap image |
|
663 QPixmap screenCapture = QPixmap::grabWindow(mMainWindow->internalWinId()); |
|
664 |
|
665 // create an QGraphicsItem to do animation |
|
666 QGraphicsPixmapItem *ret(NULL); |
|
667 |
|
668 // for landscape, the screenshot must be rotated |
|
669 if(mMainWindow->orientation() == Qt::Horizontal) |
|
670 { |
|
671 QMatrix mat; |
|
672 mat.rotate(-90); // rotate 90 degrees counter-clockwise |
|
673 ret = new QGraphicsPixmapItem(screenCapture.transformed(mat)); |
|
674 } |
|
675 else |
|
676 { |
|
677 ret = new QGraphicsPixmapItem(screenCapture); |
|
678 } |
|
679 return ret; |
|
680 } |
|
681 |
|
682 //----------------------------------------------------------------------------- |
|
683 //MsgServiceViewManager::getAnimationFile |
|
684 //@see header |
|
685 //----------------------------------------------------------------------------- |
|
686 QString MsgServiceViewManager::getAnimationFile(QString effectEvent) |
|
687 { |
|
688 QString animFile; |
|
689 if(effectEvent == SEND_EFFECT) |
|
690 { |
|
691 animFile.append(SEND_EFFECT_FILE); |
|
692 } |
|
693 |
|
694 return animFile; |
|
695 } |