videoplayback/videoplaybackview/controlsrc/videoplaybacktoolbar.cpp
changeset 66 adb51f74b890
parent 63 4707a0db12f6
equal deleted inserted replaced
63:4707a0db12f6 66:adb51f74b890
    13 *
    13 *
    14 * Description:  Implementation of VideoPlaybackToolBar
    14 * Description:  Implementation of VideoPlaybackToolBar
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version:  13 %
    18 // Version : %version:  14 %
    19 
    19 
    20 
    20 
    21 
    21 
    22 #include <QTimer>
    22 #include <QTimer>
    23 #include <QGraphicsLayout>
    23 #include <QGraphicsLayout>
   191         //
   191         //
   192         // get window size
   192         // get window size
   193         //
   193         //
   194         RWindow *window = mController->view()->getWindow();
   194         RWindow *window = mController->view()->getWindow();
   195         TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) );
   195         TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) );
   196 
       
   197         //
       
   198         // get window aspect ratio
       
   199         //   if device is in portrait mode, width > height
       
   200         //   if device is in landscape mode, width < height
       
   201         //
       
   202         TReal32 width = (TReal32) displayRect.Width();
       
   203         TReal32 height = (TReal32) displayRect.Height();
       
   204         mDisplayAspectRatio = (width > height)? (width / height) : (height / width);
       
   205     }
   196     }
   206 }
   197 }
   207 
   198 
   208 // -------------------------------------------------------------------------------------------------
   199 // -------------------------------------------------------------------------------------------------
   209 // VideoPlaybackToolBar::playPause()
   200 // VideoPlaybackToolBar::playPause()
   421 {
   412 {
   422     MPX_DEBUG(_L("VideoPlaybackToolBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio );
   413     MPX_DEBUG(_L("VideoPlaybackToolBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio );
   423 
   414 
   424     mAspectRatio = aspectRatio;
   415     mAspectRatio = aspectRatio;
   425 
   416 
   426     //
   417     setAspectRatioButton();
   427     // If we are in attach service or audio only view, then don't update the icon.
       
   428 	// Aspect ratio icon slots are shared with attach and share icon.
       
   429 	// Just update the mAspectRatio
       
   430 	// and once we go back to full screen, we will show the correct aspect ratio icon
       
   431 	//
       
   432     if ( ! mController->isAttachOperation() && mController->viewMode() == EFullScreenView )
       
   433     {
       
   434         switch( mAspectRatio )
       
   435         {
       
   436             case EMMFNatural:
       
   437             {
       
   438                 mButtonActions[E1stButton]->setIcon( *mButtonIcons[EStretchIcon] );
       
   439                 break;
       
   440             }
       
   441             case EMMFStretch:
       
   442             {
       
   443                 mButtonActions[E1stButton]->setIcon( *mButtonIcons[EZoomIcon] );
       
   444                 break;
       
   445             }
       
   446             default:
       
   447             {
       
   448                 mButtonActions[E1stButton]->setIcon( *mButtonIcons[ENaturalIcon] );
       
   449                 break;
       
   450             }
       
   451         }
       
   452     }
       
   453 }
   418 }
   454 
   419 
   455 // -------------------------------------------------------------------------------------------------
   420 // -------------------------------------------------------------------------------------------------
   456 // VideoPlaybackToolBar::handleButtonPressed()
   421 // VideoPlaybackToolBar::handleButtonPressed()
   457 // -------------------------------------------------------------------------------------------------
   422 // -------------------------------------------------------------------------------------------------
   528     }
   493     }
   529     else
   494     else
   530     {
   495     {
   531         if ( mController->viewMode() == EFullScreenView )
   496         if ( mController->viewMode() == EFullScreenView )
   532         {
   497         {
   533             //
   498             setAspectRatioButton();
   534             // Show aspect ratio button
   499 
   535             //
   500             if ( mButtons.count() )
   536             aspectRatioChanged( mAspectRatio );
   501             {
   537 
   502                 disconnect( mButtons[E1stButton], SIGNAL( released() ), 0, 0 );
   538             if ( ! details->mVideoEnabled ||
   503                 connect( mButtons[E1stButton], SIGNAL( released() ),
   539                    details->mVideoHeight <= 0 ||
   504                          this, SLOT( changeAspectRatio() ) );
   540                    details->mVideoWidth <= 0 ||
       
   541                    details->mTvOutConnected )
       
   542             {
       
   543                 //
       
   544                 // dim 'aspect ratio' buttons
       
   545                 //
       
   546                 mButtonActions[E1stButton]->setEnabled( false );
       
   547             }
       
   548             else
       
   549             {
       
   550                 //
       
   551                 // check if video clip has same aspect ratio as display window
       
   552                 //
       
   553                 TReal32 videoAspectRatio = (TReal32) details->mVideoWidth / (TReal32) details->mVideoHeight;
       
   554                 bool enabled = ( mDisplayAspectRatio == videoAspectRatio )? false : true;
       
   555 
       
   556                 //
       
   557                 // enable or dim 'aspect ratio' buttons accordingly
       
   558                 //
       
   559                 mButtonActions[E1stButton]->setEnabled( enabled );
       
   560 
       
   561                 if ( mButtons.count() )
       
   562                 {
       
   563                     disconnect( mButtons[E1stButton], SIGNAL( released() ), 0, 0 );
       
   564                     connect( mButtons[E1stButton], SIGNAL( released() ),
       
   565                              this, SLOT( changeAspectRatio() ) );
       
   566                 }
       
   567             }
   505             }
   568         }
   506         }
   569         else if ( mController->viewMode() == EAudioOnlyView )
   507         else if ( mController->viewMode() == EAudioOnlyView )
   570         {
   508         {
   571             //
   509             //
   790             break;
   728             break;
   791         }
   729         }
   792     }
   730     }
   793 }
   731 }
   794 
   732 
       
   733 // -------------------------------------------------------------------------------------------------
       
   734 // VideoPlaybackToolBar::setAspectRatioButton
       
   735 // -------------------------------------------------------------------------------------------------
       
   736 //
       
   737 void VideoPlaybackToolBar::setAspectRatioButton()
       
   738 {
       
   739     MPX_DEBUG(_L("VideoPlaybackToolBar::setAspectRatioButton"));
       
   740 
       
   741     //
       
   742     // If we are in attach service or audio only view, then don't update the icon.
       
   743     // Aspect ratio icon slots are shared with attach and share icon.
       
   744     // Just update the mAspectRatio
       
   745     // and once we go back to full screen, we will show the correct aspect ratio icon
       
   746     //
       
   747     if ( ! mController->isAttachOperation() && mController->viewMode() == EFullScreenView )
       
   748     {
       
   749         switch( mAspectRatio )
       
   750         {
       
   751             case EMMFNatural:
       
   752             {
       
   753                 mButtonActions[E1stButton]->setIcon( *mButtonIcons[EStretchIcon] );
       
   754                 break;
       
   755             }
       
   756             case EMMFStretch:
       
   757             {
       
   758                 mButtonActions[E1stButton]->setIcon( *mButtonIcons[EZoomIcon] );
       
   759                 break;
       
   760             }
       
   761             default:
       
   762             {
       
   763                 mButtonActions[E1stButton]->setIcon( *mButtonIcons[ENaturalIcon] );
       
   764                 break;
       
   765             }
       
   766         }
       
   767 
       
   768         if ( mController->fileDetails()->mAspectRatioChangeable )
       
   769         {
       
   770             if ( ! mButtonActions[E1stButton]->isEnabled() )
       
   771             {
       
   772                 mButtonActions[E1stButton]->setEnabled( true );
       
   773             }
       
   774         }
       
   775         else
       
   776         {
       
   777             if ( mButtonActions[E1stButton]->isEnabled() )
       
   778             {
       
   779                 mButtonActions[E1stButton]->setEnabled( false );
       
   780             }
       
   781         }
       
   782     }
       
   783 }
       
   784 
   795 //End of file
   785 //End of file