121 TX_LOG_ARGS("connection error: " << err); |
126 TX_LOG_ARGS("connection error: " << err); |
122 XQServiceUtil::toBackground( false ); |
127 XQServiceUtil::toBackground( false ); |
123 } |
128 } |
124 |
129 |
125 if ( !mMusicServices ) { |
130 if ( !mMusicServices ) { |
|
131 HbApplication* app = qobject_cast<HbApplication*>(qApp); |
|
132 QVariantHash params = app->activateParams(); |
126 MpEngineFactory::createSharedEngine(); |
133 MpEngineFactory::createSharedEngine(); |
127 mPopupHandler = new MpGlobalPopupHandler( this ); |
134 mPopupHandler = new MpGlobalPopupHandler( this ); |
|
135 if( app->activateReason() == Hb::ActivationReasonActivity ) { |
|
136 // Restoring an activity, not a fresh startup or a service |
|
137 // Activities from Task switcher only have one parameter |
|
138 if( params.count() == 1 ) { |
|
139 loadActivity( app->activateData() ); |
|
140 } |
|
141 } |
128 if ( orientation() == Qt::Vertical ) { |
142 if ( orientation() == Qt::Vertical ) { |
129 // If first startup ignore shuffleAll and send to collection view to refresh library |
143 // If first startup ignore shuffleAll and send to collection view to refresh library |
130 if ( mode == MusicMainView || MpSettingsManager::firstStartup() ) { |
144 if ( mode == MusicMainView || MpSettingsManager::firstStartup() ) { |
131 loadView(CollectionView); |
145 loadView( CollectionView ); |
132 activateView(CollectionView); |
146 activateView( CollectionView ); |
133 loadView(MediaWallView); |
147 loadView( MediaWallView ); |
134 loadView( PlaybackView ); |
148 loadView( PlaybackView ); |
135 } else if (mode == MusicNowPlayingViewShuffleAll ) { |
149 } else if ( mode == MusicNowPlayingView ) { |
136 MpEngineFactory::sharedEngine()->shuffleAll(); |
150 if( params.contains( "shuffle" ) ) { |
|
151 if( !params.value( "shuffle" ).toString().compare( "yes" ) ) { |
|
152 MpEngineFactory::sharedEngine()->shuffleAll(); |
|
153 } |
|
154 } |
137 loadView( PlaybackView ); |
155 loadView( PlaybackView ); |
138 activateView(PlaybackView); |
156 activateView( PlaybackView ); |
139 loadView(CollectionView); |
157 loadView( CollectionView ); |
140 loadView(MediaWallView); |
158 loadView( MediaWallView ); |
141 } |
159 } |
142 } |
160 } |
143 else { |
161 else { |
144 // If first startup ignore shuffleAll and send to refresh library |
162 // If first startup ignore shuffleAll and send to refresh library |
145 if( mode == MusicNowPlayingViewShuffleAll && !MpSettingsManager::firstStartup() ) { |
163 if( mode == MusicNowPlayingView && !MpSettingsManager::firstStartup() ) { |
146 MpEngineFactory::sharedEngine()->shuffleAll(); |
164 if( params.contains( "shuffle" ) ) { |
|
165 if( !params.value( "shuffle" ).toString().compare( "yes" ) ) { |
|
166 MpEngineFactory::sharedEngine()->shuffleAll(); |
|
167 } |
|
168 } |
147 mVerticalViewType = PlaybackView; |
169 mVerticalViewType = PlaybackView; |
148 } |
170 } |
149 loadView(MediaWallView); |
171 loadView( MediaWallView ); |
150 activateView(MediaWallView); |
172 activateView( MediaWallView ); |
151 loadView(CollectionView); |
173 loadView( CollectionView ); |
152 loadView( PlaybackView ); |
174 loadView( PlaybackView ); |
153 } |
175 } |
154 connect(this, SIGNAL( orientationChanged( Qt::Orientation ) ), SLOT( switchView( Qt::Orientation ) ) ); |
176 connect(this, SIGNAL( orientationChanged( Qt::Orientation ) ), SLOT( switchView( Qt::Orientation ) ) ); |
155 connect( MpEngineFactory::sharedEngine(), SIGNAL( libraryUpdated() ), SLOT( handleLibraryUpdated() ) ); |
177 connect( MpEngineFactory::sharedEngine(), SIGNAL( libraryUpdated() ), SLOT( handleLibraryUpdated() ) ); |
156 MpEngineFactory::sharedEngine()->checkForSystemEvents(); |
178 MpEngineFactory::sharedEngine()->checkForSystemEvents(); |
157 //Register to application manager to wait for activities |
179 //Register to application manager to wait for activities and clear previous activities on the task switcher |
158 HbApplication* app = qobject_cast<HbApplication*>(qApp); |
180 mActivityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
159 app->activityManager()->waitActivity(); |
181 mActivityManager->waitActivity(); |
|
182 mActivityManager->removeActivity( MUSIC_MAIN_VIEW ); |
|
183 mActivityManager->removeActivity( MUSIC_NOW_PLAYING_VIEW ); |
160 connect( app, SIGNAL( activate() ), this , SLOT( handleActivity() ) ); |
184 connect( app, SIGNAL( activate() ), this , SLOT( handleActivity() ) ); |
|
185 connect( app, SIGNAL( aboutToQuit() ), this, SLOT( saveActivity() ) ); |
|
186 emit applicationReady(); |
161 |
187 |
162 } |
188 } |
163 else { |
189 else { |
164 setOrientation(Qt::Vertical, true);//This sould prevent media wall activation. |
190 setOrientation(Qt::Vertical, true);//This sould prevent media wall activation. |
165 } |
191 } |
358 } |
388 } |
359 default: |
389 default: |
360 Q_ASSERT_X(false, "MpMainWindow::initializeServiceView", "undefined service"); |
390 Q_ASSERT_X(false, "MpMainWindow::initializeServiceView", "undefined service"); |
361 break; |
391 break; |
362 } |
392 } |
|
393 emit applicationReady(); |
|
394 } |
|
395 |
|
396 /*! |
|
397 Slot to handle activity switching once the stand alone instance is running and registered |
|
398 in the activity manager to wait for activities. |
|
399 Only running activity supported at the moment is "MusicNowPlayingView" |
|
400 */ |
|
401 void MpMainWindow::handleActivity() |
|
402 { |
|
403 TX_ENTRY |
|
404 HbApplication* app = qobject_cast<HbApplication*>(qApp); |
|
405 QString activityId = app->activateId(); |
|
406 |
|
407 if( !activityId.compare( MUSIC_NOW_PLAYING_VIEW ) ) { |
|
408 if ( orientation() == Qt::Vertical ) { |
|
409 if( mVerticalViewType != PlaybackView ) { |
|
410 activateView( PlaybackView ); |
|
411 } |
|
412 } |
|
413 } |
|
414 |
|
415 mActivityManager->waitActivity(); |
|
416 TX_EXIT |
|
417 } |
|
418 |
|
419 /*! |
|
420 Slot to save activity upon exiting application |
|
421 */ |
|
422 void MpMainWindow::saveActivity() |
|
423 { |
|
424 TX_ENTRY |
|
425 QString activity = ( mVerticalViewType == CollectionView ) ? MUSIC_MAIN_VIEW : MUSIC_NOW_PLAYING_VIEW; |
|
426 //Get data from engine |
|
427 QByteArray serializedRestorePath; |
|
428 if ( mUserExit ) { |
|
429 //Internal exit will always return to the main view |
|
430 activity = MUSIC_MAIN_VIEW; |
|
431 } |
|
432 else { |
|
433 //Only saved data if exited via task switcher or GOOM |
|
434 MpEngineFactory::sharedEngine()->saveActivityData( serializedRestorePath ); |
|
435 } |
|
436 QVariantHash activityParameters; |
|
437 activityParameters.insert( "screenshot", QPixmap::grabWidget( this, this->rect() ) ); |
|
438 QVariantHash activityData; |
|
439 activityData.insert( "restorePath", serializedRestorePath ); |
|
440 |
|
441 |
|
442 bool ok = mActivityManager->addActivity( activity , activityData, activityParameters ); |
|
443 if ( !ok ){ |
|
444 TX_LOG_ARGS( "Error: Add Failed; should never get here." ); |
|
445 } |
|
446 TX_EXIT |
|
447 } |
|
448 |
|
449 /*! |
|
450 Slot to handle a failed path restoration. Switch to collection view if not already there. |
|
451 */ |
|
452 void MpMainWindow::handleRestorePathFailed() |
|
453 { |
|
454 TX_ENTRY |
|
455 if ( orientation() == Qt::Vertical ) { |
|
456 if( mVerticalViewType != CollectionView ) { |
|
457 activateView( CollectionView ); |
|
458 } |
|
459 } |
|
460 TX_EXIT |
363 } |
461 } |
364 |
462 |
365 /*! |
463 /*! |
366 loads a view if type \a type, return the view plugin, if view is already loaded it will not reload the view. |
464 loads a view if type \a type, return the view plugin, if view is already loaded it will not reload the view. |
367 */ |
465 */ |
412 Q_ASSERT( plugin ? *plugin : 0 ); |
510 Q_ASSERT( plugin ? *plugin : 0 ); |
413 return plugin ? *plugin : 0; |
511 return plugin ? *plugin : 0; |
414 } |
512 } |
415 |
513 |
416 /*! |
514 /*! |
417 Slot to handle activity switching once the stand alone instance is running and registered |
515 Load activity called via task switcher |
418 in the activity manager to wait for activities. |
516 Restore view and playback path if applicable |
419 Only running activity supported at the moment is "MusicNowPlayingView" |
517 */ |
420 */ |
518 void MpMainWindow::loadActivity( QVariant data ) |
421 void MpMainWindow::handleActivity() |
519 { |
422 { |
520 TX_ENTRY |
423 HbApplication* app = qobject_cast<HbApplication*>(qApp); |
521 QVariantHash activityData = data.toHash(); |
424 QString activityId = app->activateId(); |
522 QByteArray serializedRestorePath = activityData.value( "restorePath" ).toByteArray(); |
425 |
523 MpEngineFactory::sharedEngine()->loadActivityData( serializedRestorePath ); |
426 if( !activityId.compare( "MusicNowPlayingView&launchtype=standalone" ) ) { |
524 TX_EXIT |
427 if ( orientation() == Qt::Vertical ) { |
525 } |
428 if( mVerticalViewType != PlaybackView ) { |
526 |
429 activateView( PlaybackView ); |
|
430 } |
|
431 } |
|
432 } |
|
433 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
434 activityManager->waitActivity(); |
|
435 } |
|
436 |
|