117 qApp->installTranslator( mCommonTranslator ); |
121 qApp->installTranslator( mCommonTranslator ); |
118 } |
122 } |
119 |
123 |
120 mWindow = mainWindow(); |
124 mWindow = mainWindow(); |
121 |
125 |
122 mNavigationBack = new HbAction( Hb::BackNaviAction, this ); |
126 mSoftKeyBack = new HbAction( Hb::BackNaviAction, this ); |
123 connect( mNavigationBack, SIGNAL( triggered() ), this, SLOT( back() ) ); |
127 connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) ); |
124 |
128 |
125 mMpEngine = MpEngine::instance(); |
129 mMpEngine = MpEngineFactory::sharedEngine(); |
126 mPlaybackData = mMpEngine->playbackData(); |
130 mPlaybackData = mMpEngine->playbackData(); |
127 connect( mPlaybackData, SIGNAL( playbackStateChanged() ), |
131 connect( mPlaybackData, SIGNAL( playbackStateChanged() ), |
128 this, SLOT( playbackStateChanged() ) ); |
132 this, SLOT( playbackStateChanged() ) ); |
129 |
133 |
130 mPlaybackWidget = new MpPlaybackWidget( mPlaybackData ); |
134 mPlaybackWidget = new MpPlaybackWidget( mPlaybackData ); |
131 connect( mPlaybackWidget, SIGNAL( setPlaybackPosition( int ) ), mMpEngine, SLOT( setPosition( int ) ) ); |
135 connect( mPlaybackWidget, SIGNAL( setPlaybackPosition( int ) ), mMpEngine, SLOT( setPosition( int ) ) ); |
132 |
136 //repeat should not be displayed on fetcher or embedded. |
|
137 mRepeat = mViewMode == MpCommon::DefaultView ? MpSettingsManager::repeat() : false; |
|
138 mPlaybackWidget->repeatChanged( mRepeat ); |
133 setWidget( mPlaybackWidget ); |
139 setWidget( mPlaybackWidget ); |
134 setupMenu(); |
140 setupMenu(); |
135 setupToolbar(); |
141 setupToolbar(); |
136 |
142 |
137 mEqualizerWidget->prepareDialog(); |
143 //Connect FF and RW buttons when view (toolbar) is ready |
138 |
144 connect ( mWindow, SIGNAL( viewReady() ), this, SLOT( connectButtons() ) ); |
139 // Observe changes in settings. |
145 |
140 connect( MpSettingsManager::instance(), SIGNAL( shuffleChanged( bool ) ), |
146 if ( mViewMode == MpCommon::DefaultView ) { |
141 this, SLOT( shuffleChanged( bool ) ) ); |
147 mEqualizerWidget = new MpEqualizerWidget(); |
142 connect( MpSettingsManager::instance(), SIGNAL( repeatChanged( bool ) ), |
148 mEqualizerWidget->prepareDialog(); |
143 this, SLOT( repeatChanged( bool ) ) ); |
149 // Observe changes in settings. |
|
150 connect( MpSettingsManager::instance(), SIGNAL( shuffleChanged( bool ) ), |
|
151 this, SLOT( shuffleChanged( bool ) ) ); |
|
152 connect( MpSettingsManager::instance(), SIGNAL( repeatChanged( bool ) ), |
|
153 this, SLOT( repeatChanged( bool ) ) ); |
|
154 } |
144 |
155 |
145 TX_EXIT |
156 TX_EXIT |
146 } |
157 } |
147 |
158 |
148 /*! |
159 /*! |
347 } |
341 } |
348 else { |
342 else { |
349 mShuffleAction->setEnabled( false ); |
343 mShuffleAction->setEnabled( false ); |
350 } |
344 } |
351 |
345 |
352 toolBar->addAction( mShuffleAction ); |
346 myToolBar->addAction( mShuffleAction ); |
353 |
347 |
354 HbAction *action = new HbAction( actionsGroup ); |
348 HbAction *action = new HbAction( actionsGroup ); |
355 action->setIcon( HbIcon( "qtg_mono_previous" ) ); |
349 action->setIcon( HbIcon( "qtg_mono_seek_previous" ) ); |
356 action->setCheckable( false ); |
350 action->setCheckable( false ); |
357 connect( action, SIGNAL( triggered( bool ) ), |
351 action->setObjectName("previous"); |
358 mMpEngine, SLOT( skipBackward() ) ); |
352 myToolBar->addAction( action ); |
359 toolBar->addAction( action ); |
353 |
360 |
|
361 mPlayPauseAction = new HbAction( actionsGroup ); |
354 mPlayPauseAction = new HbAction( actionsGroup ); |
362 mPlayIcon = new HbIcon( "qtg_mono_play" ); |
355 mPlayIcon = new HbIcon( "qtg_mono_play" ); |
363 mPauseIcon = new HbIcon( "qtg_mono_pause" ); |
356 mPauseIcon = new HbIcon( "qtg_mono_pause" ); |
364 mPlayPauseAction->setIcon( *mPlayIcon ); |
357 updatePlayPauseIcon(); |
365 mPlayPauseAction->setCheckable( false ); |
358 mPlayPauseAction->setCheckable( false ); |
366 connect( mPlayPauseAction, SIGNAL( triggered( bool ) ), |
359 connect( mPlayPauseAction, SIGNAL( triggered( bool ) ), |
367 mMpEngine, SLOT( playPause() ) ); |
360 mMpEngine, SLOT( playPause() ) ); |
368 toolBar->addAction( mPlayPauseAction ); |
361 myToolBar->addAction( mPlayPauseAction ); |
369 |
362 |
370 action = new HbAction( actionsGroup ); |
363 action = new HbAction( actionsGroup ); |
371 action->setIcon( HbIcon( "qtg_mono_next" ) ); |
364 action->setIcon( HbIcon( "qtg_mono_seek_next" ) ); |
372 action->setCheckable( false ); |
365 action->setCheckable( false ); |
373 connect( action, SIGNAL( triggered( bool ) ), |
366 action->setObjectName("next"); |
374 mMpEngine, SLOT( skipForward() ) ); |
367 myToolBar->addAction( action ); |
375 toolBar->addAction( action ); |
|
376 |
368 |
377 HbIcon icon( "qtg_mono_info" ); |
369 HbIcon icon( "qtg_mono_info" ); |
378 action = new HbAction( actionsGroup ); |
370 action = new HbAction( actionsGroup ); |
379 action->setIcon( icon ); |
371 action->setIcon( icon ); |
380 action->setCheckable( false ); |
372 action->setCheckable( false ); |
381 //TODO: Remove once song details takes hostUid from engine |
373 |
382 if ( mViewMode == MpCommon::DefaultView ) { |
374 connect( action, SIGNAL( triggered( bool ) ), |
383 connect( action, SIGNAL( triggered( bool ) ), |
375 this, SLOT( flip() ) ); |
384 this, SLOT( flip() ) ); |
376 |
385 } |
377 myToolBar->addAction( action ); |
386 else { |
|
387 action->setEnabled( false ); |
|
388 } |
|
389 toolBar->addAction( action ); |
|
390 } |
378 } |
391 else { |
379 else { |
392 // Fetch mode |
380 // Fetch mode |
393 HbAction *action = new HbAction( actionsGroup ); |
381 HbAction *action = new HbAction( actionsGroup ); |
394 action->setIcon( HbIcon( "qtg_mono_tick" ) ); |
382 action->setIcon( HbIcon( "qtg_mono_tick" ) ); |
395 action->setCheckable( false ); |
383 action->setCheckable( false ); |
396 connect( action, SIGNAL( triggered( bool ) ), |
384 connect( action, SIGNAL( triggered( bool ) ), |
397 this, SLOT( handleSongSelected() ) ); |
385 this, SLOT( handleSongSelected() ) ); |
398 toolBar->addAction( action ); |
386 myToolBar->addAction( action ); |
399 |
387 |
400 mPlayPauseAction = new HbAction( actionsGroup ); |
388 mPlayPauseAction = new HbAction( actionsGroup ); |
401 mPlayIcon = new HbIcon( "qtg_mono_play" ); |
389 mPlayIcon = new HbIcon( "qtg_mono_play" ); |
402 mPauseIcon = new HbIcon( "qtg_mono_pause" ); |
390 mPauseIcon = new HbIcon( "qtg_mono_pause" ); |
403 mPlayPauseAction->setIcon( *mPlayIcon ); |
391 updatePlayPauseIcon(); |
404 mPlayPauseAction->setCheckable( false ); |
392 mPlayPauseAction->setCheckable( false ); |
405 connect( mPlayPauseAction, SIGNAL( triggered( bool ) ), |
393 connect( mPlayPauseAction, SIGNAL( triggered( bool ) ), |
406 mMpEngine, SLOT( playPause() ) ); |
394 mMpEngine, SLOT( playPause() ) ); |
407 toolBar->addAction( mPlayPauseAction ); |
395 myToolBar->addAction( mPlayPauseAction ); |
408 } |
396 } |
409 |
397 |
410 |
398 |
411 TX_EXIT |
399 TX_EXIT |
412 } |
400 } |
413 |
401 |
|
402 /*! |
|
403 Updates the play pause icon on the toolbar base on playback state. |
|
404 */ |
|
405 void MpPlaybackView::updatePlayPauseIcon() |
|
406 { |
|
407 TX_ENTRY |
|
408 switch ( mPlaybackData->playbackState() ) { |
|
409 case MpPlaybackData::Playing: |
|
410 case MpPlaybackData::NotPlaying: |
|
411 TX_LOG_ARGS( "MpPlaybackData::Playing" ) |
|
412 mPlayPauseAction->setIcon( *mPauseIcon ); |
|
413 break; |
|
414 case MpPlaybackData::Paused: |
|
415 case MpPlaybackData::Stopped: |
|
416 TX_LOG_ARGS( "MpPlaybackData::Paused" ) |
|
417 mPlayPauseAction->setIcon( *mPlayIcon ); |
|
418 break; |
|
419 |
|
420 default: |
|
421 break; |
|
422 } |
|
423 TX_EXIT |
|
424 } |
|
425 |
|
426 /*! |
|
427 start rewind long press detection |
|
428 */ |
|
429 void MpPlaybackView::startRewindTimer() |
|
430 { |
|
431 if(mTimer){ |
|
432 delete mTimer; |
|
433 mTimer = 0; |
|
434 } |
|
435 mTimer = new QTimer(this); |
|
436 mTimer->setSingleShot(true); |
|
437 connect(mTimer, SIGNAL(timeout()), this, SLOT(startSeekRewind())); |
|
438 mTimer->start(600); |
|
439 } |
|
440 |
|
441 /*! |
|
442 start fast forward long press detection |
|
443 */ |
|
444 void MpPlaybackView::startForwardTimer() |
|
445 { |
|
446 if(mTimer){ |
|
447 delete mTimer; |
|
448 mTimer = 0; |
|
449 } |
|
450 mTimer = new QTimer(this); |
|
451 mTimer->setSingleShot(true); |
|
452 connect(mTimer, SIGNAL(timeout()), this, SLOT(startSeekForward())); |
|
453 mTimer->start(600); |
|
454 } |
|
455 |
|
456 /*! |
|
457 start backward seeking |
|
458 */ |
|
459 void MpPlaybackView::startSeekRewind() |
|
460 { |
|
461 mMpEngine->startSeekBackward(); |
|
462 mSeeking = true; |
|
463 } |
|
464 |
|
465 /*! |
|
466 start forward seeking |
|
467 */ |
|
468 void MpPlaybackView::startSeekForward() |
|
469 { |
|
470 mMpEngine->startSeekForward(); |
|
471 mSeeking = true; |
|
472 } |
|
473 |
|
474 /*! |
|
475 end backward seeking or skip backward |
|
476 */ |
|
477 void MpPlaybackView::endRewind() |
|
478 { |
|
479 if(mTimer){ |
|
480 mTimer->stop(); |
|
481 delete mTimer; |
|
482 mTimer = 0; |
|
483 } |
|
484 if( mSeeking ) { |
|
485 mMpEngine->stopSeeking(); |
|
486 } |
|
487 else { |
|
488 mMpEngine->skipBackward(); |
|
489 } |
|
490 mSeeking = false; |
|
491 } |
|
492 |
|
493 /*! |
|
494 end forward seeking or skip forward |
|
495 */ |
|
496 void MpPlaybackView::endForward() |
|
497 { |
|
498 if(mTimer){ |
|
499 mTimer->stop(); |
|
500 delete mTimer; |
|
501 mTimer = 0; |
|
502 } |
|
503 if( mSeeking ) { |
|
504 mMpEngine->stopSeeking(); |
|
505 } |
|
506 else { |
|
507 mMpEngine->skipForward(); |
|
508 } |
|
509 mSeeking = false; |
|
510 } |
|
511 |
|
512 /*! |
|
513 Slot to connect seek forward and backward toolbar buttons |
|
514 */ |
|
515 void MpPlaybackView::connectButtons() |
|
516 { |
|
517 |
|
518 HbToolBar *myToolBar = toolBar(); |
|
519 QGraphicsLayout *layout = myToolBar->layout(); |
|
520 if( layout ) { |
|
521 int count = layout->count(); |
|
522 for ( int i = 0; i < count; i++ ) { |
|
523 HbToolButton *button = dynamic_cast<HbToolButton *>( layout->itemAt(i) ); |
|
524 QString name = button->action()->objectName(); |
|
525 |
|
526 if ( name == "previous" ) { |
|
527 connect( button, SIGNAL( pressed() ), |
|
528 this, SLOT( startRewindTimer() ) ); |
|
529 connect( button, SIGNAL( released() ), |
|
530 this, SLOT( endRewind() ) ); |
|
531 } |
|
532 if ( name == "next" ) { |
|
533 connect( button, SIGNAL( pressed() ), |
|
534 this, SLOT( startForwardTimer() ) ); |
|
535 connect( button, SIGNAL( released() ), |
|
536 this, SLOT( endForward() ) ); |
|
537 disconnect ( mWindow, SIGNAL( viewReady() ), this, SLOT( connectButtons() ) ); |
|
538 } |
|
539 } |
|
540 } |
|
541 } |
414 /*! |
542 /*! |
415 Slot to be called to activate equalizer dialog. |
543 Slot to be called to activate equalizer dialog. |
416 */ |
544 */ |
417 void MpPlaybackView::showEqualizerDialog() |
545 void MpPlaybackView::showEqualizerDialog() |
418 { |
546 { |