15 * |
15 * |
16 */ |
16 */ |
17 #include <hbaction.h> |
17 #include <hbaction.h> |
18 #include <QApplication> |
18 #include <QApplication> |
19 #include <QTimer> |
19 #include <QTimer> |
|
20 #include <HbApplication> |
|
21 #include <HbActivityManager> |
|
22 #include <xqserviceutil.h> |
|
23 |
20 |
24 |
21 #include "irviewmanager.h" |
25 #include "irviewmanager.h" |
22 #include "irapplication.h" |
26 #include "irapplication.h" |
23 #include "irmainview.h" |
27 #include "irmainview.h" |
24 #include "ircategoryview.h" |
28 #include "ircategoryview.h" |
44 const int KCrossLineMaxAngle = 75; // degree |
48 const int KCrossLineMaxAngle = 75; // degree |
45 |
49 |
46 static bool crossLineReady(const QLineF &aLine); |
50 static bool crossLineReady(const QLineF &aLine); |
47 static bool crossLineIntersected(const QLineF &aLineA, const QLineF &aLineB); |
51 static bool crossLineIntersected(const QLineF &aLineA, const QLineF &aLineB); |
48 |
52 |
|
53 static const QString KActivityMainView("InternetRadioMainView"); |
|
54 static const QString KActivityPlayingView("InternetRadioNowPlayingView"); |
|
55 |
49 enum CrossLineAngleType |
56 enum CrossLineAngleType |
50 { |
57 { |
51 EPositiveAngle = 0, // Line within 1,3 quadrant |
58 EPositiveAngle = 0, // Line within 1,3 quadrant |
52 ENegativeAngle // Line within 2,4 quadrant |
59 ENegativeAngle // Line within 2,4 quadrant |
53 }; |
60 }; |
347 |
354 |
348 IRBaseView *curView = getView(aViewId, true); |
355 IRBaseView *curView = getView(aViewId, true); |
349 Q_ASSERT(curView); |
356 Q_ASSERT(curView); |
350 iViewStack.push(curView); |
357 iViewStack.push(curView); |
351 } |
358 } |
352 |
359 |
|
360 void IRViewManager::saveScreenShot() |
|
361 { |
|
362 //if capture screen shot immediately for first view, can't get correct result |
|
363 //use timer as a temp solution, will raise error to Orbit |
|
364 QTimer::singleShot(200, this, SLOT(handleSaveScreenShot())); |
|
365 } |
|
366 |
|
367 void IRViewManager::saveActivity() |
|
368 { |
|
369 HbActivityManager *activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
370 |
|
371 //for embedded applications, don't publish activity. If backup activity is available, need to restore |
|
372 if (XQServiceUtil::isEmbedded()) |
|
373 { |
|
374 if (!iActivityBackup.activityId.isEmpty()) |
|
375 { |
|
376 QVariantHash metadata; |
|
377 metadata.insert("screenshot", iActivityBackup.screenShot); |
|
378 |
|
379 QByteArray serializedActivity; |
|
380 QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); |
|
381 stream<<iActivityBackup.viewId; |
|
382 activityManager->addActivity(iActivityBackup.activityId, serializedActivity, metadata); |
|
383 } |
|
384 return; |
|
385 } |
|
386 |
|
387 removeActivity(); |
|
388 |
|
389 |
|
390 QVariantHash metadata; |
|
391 |
|
392 QByteArray serializedActivity; |
|
393 QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); |
|
394 |
|
395 TIRViewId viewId = getExitingView(); |
|
396 switch (viewId) |
|
397 { |
|
398 case EIRView_MainView: |
|
399 case EIRView_FavoritesView: |
|
400 case EIRView_CategoryView: |
|
401 stream<<viewId; |
|
402 metadata.insert("screenshot", iScreenShots[viewId]); |
|
403 activityManager->addActivity(KActivityMainView, serializedActivity, metadata); |
|
404 break; |
|
405 |
|
406 case EIRView_PlayingView: |
|
407 stream<<viewId; |
|
408 metadata.insert("screenshot", iScreenShots[viewId]); |
|
409 activityManager->addActivity(KActivityPlayingView, serializedActivity, metadata); |
|
410 break; |
|
411 |
|
412 default: |
|
413 break; |
|
414 } |
|
415 } |
|
416 |
|
417 void IRViewManager::removeActivity() |
|
418 { |
|
419 if (XQServiceUtil::isEmbedded()) |
|
420 { |
|
421 backupActivity(); |
|
422 } |
|
423 |
|
424 HbActivityManager *activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
425 activityManager->removeActivity(KActivityMainView); |
|
426 activityManager->removeActivity(KActivityPlayingView); |
|
427 } |
|
428 |
|
429 void IRViewManager::backupActivity() |
|
430 { |
|
431 HbApplication *hbApp = qobject_cast<HbApplication*>(qApp); |
|
432 HbActivityManager *activityManager = hbApp->activityManager(); |
|
433 QList<QVariantHash> params = activityManager->activities(); |
|
434 TInt count = params.count(); |
|
435 if (count > 0) |
|
436 { |
|
437 QVariantHash activity = params[0]; |
|
438 QString path = activity.value(activity.keys().at(2)).toString(); |
|
439 iActivityBackup.screenShot = QPixmap(path); |
|
440 iActivityBackup.activityId = activity.value(activity.keys().at(1)).toString(); |
|
441 |
|
442 QByteArray serializedModel = activityManager->activityData(iActivityBackup.activityId).toByteArray(); |
|
443 QDataStream stream(&serializedModel, QIODevice::ReadOnly); |
|
444 int id = 0; |
|
445 stream>>id; |
|
446 iActivityBackup.viewId = TIRViewId(id); |
|
447 } |
|
448 } |
353 |
449 |
354 // slot functions |
450 // slot functions |
355 |
451 |
356 /* |
452 /* |
357 * Description : slot function for softkey action. |
453 * Description : slot function for softkey action. |
589 |
694 |
590 void IRViewManager::exitTimeout() |
695 void IRViewManager::exitTimeout() |
591 { |
696 { |
592 crossLineReset(); |
697 crossLineReset(); |
593 viewport()->repaint(); |
698 viewport()->repaint(); |
|
699 #ifdef SUBTITLE_STR_BY_LOCID |
594 HbMessageBox::information(hbTrId("txt_common_info_exiting"), (QObject*)NULL, NULL); |
700 HbMessageBox::information(hbTrId("txt_common_info_exiting"), (QObject*)NULL, NULL); |
|
701 #else |
|
702 HbMessageBox::information(hbTrId("Exiting..."), (QObject*)NULL, NULL); |
|
703 #endif |
595 qApp->quit(); |
704 qApp->quit(); |
596 iExiting = true; |
705 iExiting = true; |
597 } |
706 } |
598 |
707 |
599 bool IRViewManager::isExiting() const |
708 bool IRViewManager::isExiting() const |