videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybacktoolbar.cpp
changeset 20 b9e04db066d4
child 24 7d93ee07fb27
equal deleted inserted replaced
17:69946d1824c4 20:b9e04db066d4
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Implementation of QMPXVideoPlaybackToolBar
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version:  3 %
       
    19 
       
    20 
       
    21 
       
    22 #include <QTimer>
       
    23 #include <QGraphicsLayout>
       
    24 
       
    25 #include <hbeffect.h>
       
    26 #include <hbaction.h>
       
    27 #include <hbtoolbar.h>
       
    28 #include <hbinstance.h>
       
    29 #include <hbtoolbutton.h>
       
    30 #include <w32std.h>
       
    31 
       
    32 #include "mpxvideo_debug.h"
       
    33 #include "hbvideobaseplaybackview.h"
       
    34 #include "mpxvideoplaybacktoolbar.h"
       
    35 #include "mpxcommonvideoplaybackview.hrh"
       
    36 #include "mpxvideoplaybackdocumentloader.h"
       
    37 #include "mpxvideoplaybackviewfiledetails.h"
       
    38 #include "mpxvideoplaybackcontrolscontroller.h"
       
    39 
       
    40 const int KSeekStartTimeOut = 700;
       
    41 const int KRetrieveButtonTimeOut = 1000;
       
    42 
       
    43 // -------------------------------------------------------------------------------------------------
       
    44 // QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar()
       
    45 // -------------------------------------------------------------------------------------------------
       
    46 //
       
    47 QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar( 
       
    48         QMPXVideoPlaybackControlsController* controller )
       
    49     : mController( controller )
       
    50     , mSeekStartTimer( NULL )
       
    51     , mRetrieveButtonTimer( NULL )
       
    52     , mSeekingState( EMPXNotSeeking )
       
    53     , mInitialized( false )
       
    54     , mNeverVisibled( true )
       
    55     , mPosition( 0 )
       
    56     , mDuration( 0 )
       
    57     , mAspectRatio( EMPXPbvCmdNaturalAspectRatio )
       
    58 {
       
    59     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar"));
       
    60 
       
    61     mToolBar = mController->view()->toolBar();
       
    62     mToolBar->setOrientation( Qt::Horizontal );
       
    63     HbEffect::disable( mToolBar );
       
    64     
       
    65     mController->view()->hideItems( Hb::ToolBarItem );
       
    66 
       
    67     initialize();
       
    68 }
       
    69 
       
    70 // -------------------------------------------------------------------------------------------------
       
    71 // QMPXVideoPlaybackToolBar::~QMPXVideoPlaybackToolBar()
       
    72 // -------------------------------------------------------------------------------------------------
       
    73 //
       
    74 QMPXVideoPlaybackToolBar::~QMPXVideoPlaybackToolBar()
       
    75 {
       
    76     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::~QMPXVideoPlaybackToolBar()"));
       
    77 
       
    78     HbEffect::enable( mToolBar );
       
    79     mToolBar->clearActions();
       
    80 
       
    81     for ( int i = 0 ; i < mButtonIcons.count() ; i++ )
       
    82     {
       
    83         if ( mButtonIcons[i] )
       
    84         {
       
    85             delete mButtonIcons[i];
       
    86         }
       
    87     }
       
    88     mButtonIcons.clear();
       
    89 
       
    90     if ( mSeekStartTimer )
       
    91     {
       
    92         if ( mSeekStartTimer->isActive() )
       
    93         {
       
    94             mSeekStartTimer->stop();
       
    95         }
       
    96 
       
    97         delete mSeekStartTimer;
       
    98         mSeekStartTimer = NULL;
       
    99     }
       
   100 
       
   101     if ( mRetrieveButtonTimer )
       
   102     {
       
   103         if ( mRetrieveButtonTimer->isActive() )
       
   104         {
       
   105             mRetrieveButtonTimer->stop();
       
   106         }
       
   107 
       
   108         delete mRetrieveButtonTimer;
       
   109         mRetrieveButtonTimer = NULL;
       
   110     }
       
   111 }
       
   112 
       
   113 // -------------------------------------------------------------------------------------------------
       
   114 // QMPXVideoPlaybackToolBar::initialize()
       
   115 // -------------------------------------------------------------------------------------------------
       
   116 //
       
   117 void QMPXVideoPlaybackToolBar::initialize()
       
   118 {
       
   119     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::initialize()"));
       
   120 
       
   121     //
       
   122     // Don't need to initialize buttons once it gets initialized
       
   123     //
       
   124     if ( ! mInitialized )
       
   125     {
       
   126         mInitialized = true;
       
   127 
       
   128         QActionGroup *actionsGroup = new QActionGroup( mToolBar );
       
   129 
       
   130         for ( int i = 0 ; i < EMPXButtonCount ; i++ )
       
   131         {
       
   132             mButtonActions.append( new HbAction( actionsGroup ) );
       
   133         }
       
   134 
       
   135         for ( int i = 0 ; i < EMPXIconCount ; i++ )
       
   136         {
       
   137             mButtonIcons.append( new HbIcon() );
       
   138         }
       
   139 
       
   140         //
       
   141         // RW button
       
   142         //
       
   143         mButtonIcons[EMPXRWIcon]->setIconName( "qtg_mono_previous" );
       
   144         mButtonActions[EMPX2ndButton]->setIcon( *mButtonIcons[EMPXRWIcon] );
       
   145 
       
   146         //
       
   147         // Play/Pause button
       
   148         //
       
   149         mButtonIcons[EMPXPlayIcon]->setIconName( "qtg_mono_play" );
       
   150         mButtonIcons[EMPXPauseIcon]->setIconName( "qtg_mono_pause" );
       
   151         mButtonActions[EMPX3rdButton]->setIcon( *mButtonIcons[EMPXPlayIcon] );
       
   152 
       
   153         //
       
   154         // FF button
       
   155         //
       
   156         mButtonIcons[EMPXFFIcon]->setIconName( "qtg_mono_next" );
       
   157         mButtonActions[EMPX4thButton]->setIcon( *mButtonIcons[EMPXFFIcon] );
       
   158 
       
   159         //
       
   160         // Details button
       
   161         //
       
   162         mButtonIcons[EMPXDetailsIcon]->setIconName( "qtg_mono_info" );
       
   163         mButtonActions[EMPX5thButton]->setIcon( *mButtonIcons[EMPXDetailsIcon] );
       
   164 
       
   165         //
       
   166         // Aspect ratio buttons
       
   167         //
       
   168         mButtonIcons[EMPXNaturalIcon]->setIconName( "qtg_mono_aspect_ratio_natural" );
       
   169         mButtonIcons[EMPXStretchIcon]->setIconName( "qtg_mono_aspect_ratio_stretched" );
       
   170         mButtonIcons[EMPXZoomIcon]->setIconName( "qtg_mono_aspect_ratio_zoom" );
       
   171         mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXNaturalIcon] );
       
   172 
       
   173         //
       
   174         // Attach/Share button 
       
   175         //
       
   176         mButtonIcons[EMPXAttachIcon]->setIconName( "qtg_mono_attach" );
       
   177         mButtonIcons[EMPXShareIcon]->setIconName( "qtg_mono_share" );
       
   178 
       
   179         for ( int i = 0 ; i < EMPXButtonCount ; i++ )
       
   180         {
       
   181             mButtonActions[i]->setCheckable( false );
       
   182             mToolBar->addAction( mButtonActions[i] );
       
   183         }
       
   184 
       
   185         mDuration = (qreal)mController->fileDetails()->mDuration / (qreal)KPbMilliMultiplier;
       
   186 
       
   187         //
       
   188         // Create a timer for seeking. 
       
   189         // We will issue SetPosition every KSeekingTimeOut msec to show the current frame to user
       
   190         //
       
   191         mSeekStartTimer = new QTimer();
       
   192         mSeekStartTimer->setSingleShot( true );
       
   193         mSeekStartTimer->setInterval( KSeekStartTimeOut );
       
   194         
       
   195         //
       
   196         // get window size
       
   197         //
       
   198         RWindow *window = mController->view()->getWindow();            
       
   199         TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) );
       
   200         
       
   201         //
       
   202         // get window aspect ratio
       
   203         //   if device is in portrait mode, width > height
       
   204         //   if device is in landscape mode, width < height
       
   205         //
       
   206         TReal32 width = (TReal32) displayRect.Width();
       
   207         TReal32 height = (TReal32) displayRect.Height();            
       
   208         mDisplayAspectRatio = (width > height)? (width / height) : (height / width);
       
   209         
       
   210     }
       
   211 }
       
   212 
       
   213 // -------------------------------------------------------------------------------------------------
       
   214 // QMPXVideoPlaybackToolBar::playPause()
       
   215 // -------------------------------------------------------------------------------------------------
       
   216 //
       
   217 void QMPXVideoPlaybackToolBar::playPause()
       
   218 {
       
   219     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::playPause()"));
       
   220 
       
   221     mController->resetDisappearingTimers( EMPXTimerReset );
       
   222     mController->handleCommand( EMPXPbvCmdPlayPause );
       
   223 }
       
   224 
       
   225 // -------------------------------------------------------------------------------------------------
       
   226 // QMPXVideoPlaybackToolBar::ffPressing()
       
   227 // -------------------------------------------------------------------------------------------------
       
   228 //
       
   229 void QMPXVideoPlaybackToolBar::ffPressing()
       
   230 {
       
   231     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::ffPressing()"),
       
   232                    _L("mSeekingState = %d"), mSeekingState );
       
   233 
       
   234     if ( mSeekingState == EMPXNotSeeking )
       
   235     {
       
   236         mSeekingState = EMPXFastForwarding;
       
   237 
       
   238         mController->handleCommand( EMPXPbvCmdSeekForward );        
       
   239     }
       
   240 }
       
   241 
       
   242 // -------------------------------------------------------------------------------------------------
       
   243 // QMPXVideoPlaybackToolBar::rwPressing()
       
   244 // -------------------------------------------------------------------------------------------------
       
   245 //
       
   246 void QMPXVideoPlaybackToolBar::rwPressing()
       
   247 {
       
   248     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::rwPressing()"),
       
   249                    _L("mSeekingState = %d"), mSeekingState );
       
   250 
       
   251     if ( mSeekingState == EMPXNotSeeking )
       
   252     {
       
   253         mSeekingState = EMPXRewinding;
       
   254 
       
   255         mController->handleCommand( EMPXPbvCmdSeekBackward );
       
   256     }
       
   257 }
       
   258 
       
   259 // -------------------------------------------------------------------------------------------------
       
   260 // QMPXVideoPlaybackToolBar::ffReleased()
       
   261 // -------------------------------------------------------------------------------------------------
       
   262 //
       
   263 void QMPXVideoPlaybackToolBar::ffReleased()
       
   264 {
       
   265     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::ffReleased()"),
       
   266                    _L("mSeekingState = %d"), mSeekingState );
       
   267 
       
   268     disconnect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( ffPressing() ) );
       
   269 
       
   270     if ( mSeekStartTimer->isActive() )
       
   271     {
       
   272         mSeekStartTimer->stop();
       
   273     }
       
   274 
       
   275     if ( mSeekingState == EMPXFastForwarding )
       
   276     {
       
   277         mController->handleCommand( EMPXPbvCmdEndSeek );        
       
   278     }
       
   279     else
       
   280     {
       
   281         int temp = mPosition + KMPXFastForward;
       
   282         MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::ffReleased() temp position = %d"), temp);
       
   283 
       
   284         //
       
   285         // If it has the playing time which is less than KMPXFastForward, ignore
       
   286         //
       
   287         if ( temp < mDuration )
       
   288         {
       
   289             mController->handleCommand( EMPXPbvCmdSetPosition, temp );
       
   290         }
       
   291     }
       
   292 
       
   293     mSeekingState = EMPXNotSeeking;
       
   294     mController->resetDisappearingTimers( EMPXTimerReset );
       
   295 }
       
   296 
       
   297 // -------------------------------------------------------------------------------------------------
       
   298 // QMPXVideoPlaybackToolBar::rwReleased()
       
   299 // -------------------------------------------------------------------------------------------------
       
   300 //
       
   301 void QMPXVideoPlaybackToolBar::rwReleased()
       
   302 {
       
   303     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::rwReleased()"),
       
   304                    _L("mSeekingState = %d"), mSeekingState );
       
   305 
       
   306     disconnect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( rwPressing() ) );
       
   307 
       
   308     if ( mSeekStartTimer->isActive() )
       
   309     {
       
   310         mSeekStartTimer->stop();
       
   311     }
       
   312 
       
   313     if ( mSeekingState == EMPXRewinding )
       
   314     {
       
   315         mController->handleCommand( EMPXPbvCmdEndSeek );        
       
   316     }
       
   317     else
       
   318     {
       
   319         int temp = mPosition + KMPXRewind;
       
   320         MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::rwReleased() temp position = %d"), temp);
       
   321 
       
   322         //
       
   323         // If it played less than KMPXRewind, jump to 0
       
   324         //
       
   325         if ( temp < 0 )
       
   326         {
       
   327             temp = 0;
       
   328         }
       
   329 
       
   330         mController->handleCommand( EMPXPbvCmdSetPosition, temp );
       
   331     }
       
   332 
       
   333     mSeekingState = EMPXNotSeeking;
       
   334     mController->resetDisappearingTimers( EMPXTimerReset );
       
   335 }
       
   336 
       
   337 // -------------------------------------------------------------------------------------------------
       
   338 // QMPXVideoPlaybackToolBar::changeAspectRatio()
       
   339 // -------------------------------------------------------------------------------------------------
       
   340 //
       
   341 void QMPXVideoPlaybackToolBar::changeAspectRatio()
       
   342 {
       
   343     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::changeAspectRatio()"));
       
   344 
       
   345     mController->resetDisappearingTimers( EMPXTimerReset );
       
   346     
       
   347     TMPXVideoPlaybackViewCommandIds cmd = EMPXPbvCmdStretchAspectRatio;
       
   348 
       
   349     switch( mAspectRatio )
       
   350     {
       
   351         case EMMFZoom:
       
   352         {
       
   353             cmd = EMPXPbvCmdNaturalAspectRatio;
       
   354             break;
       
   355         }
       
   356         case EMMFStretch:
       
   357         {
       
   358             cmd = EMPXPbvCmdZoomAspectRatio;
       
   359             break;
       
   360         }
       
   361     }
       
   362 
       
   363     mController->handleCommand( cmd );
       
   364 }
       
   365 
       
   366 // -------------------------------------------------------------------------------------------------
       
   367 // QMPXVideoPlaybackToolBar::updateState()
       
   368 // -------------------------------------------------------------------------------------------------
       
   369 //
       
   370 void QMPXVideoPlaybackToolBar::updateState( TMPXPlaybackState state )
       
   371 {
       
   372     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::updateState() state = %d"), state );
       
   373 
       
   374     switch ( state )
       
   375     {
       
   376         case EPbStatePlaying:
       
   377         {
       
   378             mToolBar->setEnabled( true );
       
   379 
       
   380             mButtonActions[EMPX3rdButton]->setIcon( *mButtonIcons[EMPXPauseIcon] );
       
   381 
       
   382             break;
       
   383         }
       
   384         case EPbStatePaused:
       
   385         {
       
   386             mToolBar->setEnabled( true );
       
   387 
       
   388             mButtonActions[EMPX3rdButton]->setIcon( *mButtonIcons[EMPXPlayIcon] );
       
   389 
       
   390             break;
       
   391         }
       
   392         default:
       
   393         {
       
   394             mToolBar->setEnabled( false );
       
   395 
       
   396             break;
       
   397         }
       
   398     }
       
   399 }
       
   400 
       
   401 // -------------------------------------------------------------------------------------------------
       
   402 // QMPXVideoPlaybackToolBar::aspectRatioChanged()
       
   403 // -------------------------------------------------------------------------------------------------
       
   404 //
       
   405 void QMPXVideoPlaybackToolBar::aspectRatioChanged( int aspectRatio )
       
   406 {
       
   407     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio );
       
   408 
       
   409     mAspectRatio = aspectRatio;
       
   410 
       
   411     if ( ! mController->isAttachOperation() )
       
   412     {
       
   413         switch( mAspectRatio )
       
   414         {
       
   415             case EMMFNatural:
       
   416             {
       
   417                 mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXStretchIcon] );
       
   418                 break;
       
   419             }
       
   420             case EMMFStretch:
       
   421             {
       
   422                 mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXZoomIcon] );
       
   423                 break;
       
   424             }
       
   425             default:
       
   426             {
       
   427                 mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXNaturalIcon] );
       
   428                 break;
       
   429             }
       
   430         }    
       
   431     }
       
   432 }
       
   433 
       
   434 // -------------------------------------------------------------------------------------------------
       
   435 // QMPXVideoPlaybackToolBar::handleButtonPressed()
       
   436 // -------------------------------------------------------------------------------------------------
       
   437 //
       
   438 void QMPXVideoPlaybackToolBar::handleButtonPressed()
       
   439 {
       
   440     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::handleButtonPressed()"));
       
   441 
       
   442     mController->resetDisappearingTimers( EMPXTimerCancel );
       
   443 }
       
   444 
       
   445 // -------------------------------------------------------------------------------------------------
       
   446 // QMPXVideoPlaybackToolBar::handleRWButtonPressed()
       
   447 // -------------------------------------------------------------------------------------------------
       
   448 //
       
   449 void QMPXVideoPlaybackToolBar::handleRWButtonPressed()
       
   450 {
       
   451     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::handleRWButtonPressed()"));
       
   452 
       
   453     mController->resetDisappearingTimers( EMPXTimerCancel );
       
   454 
       
   455     connect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( rwPressing() ) );
       
   456 
       
   457     if ( mSeekStartTimer->isActive() )
       
   458     {
       
   459         mSeekStartTimer->stop();
       
   460     }
       
   461 
       
   462     mSeekStartTimer->start();
       
   463 }
       
   464 
       
   465 // -------------------------------------------------------------------------------------------------
       
   466 // QMPXVideoPlaybackToolBar::handleFFButtonPressed()
       
   467 // -------------------------------------------------------------------------------------------------
       
   468 //
       
   469 void QMPXVideoPlaybackToolBar::handleFFButtonPressed()
       
   470 {
       
   471     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::handleButtonPressed()"));
       
   472 
       
   473     mController->resetDisappearingTimers( EMPXTimerCancel );
       
   474 
       
   475     connect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( ffPressing() ) );
       
   476 
       
   477     if ( mSeekStartTimer->isActive() )
       
   478     {
       
   479         mSeekStartTimer->stop();
       
   480     }
       
   481 
       
   482     mSeekStartTimer->start();
       
   483 }
       
   484 
       
   485 // -------------------------------------------------------------------------------------------------
       
   486 // QMPXVideoPlaybackToolBar::updateWithFileDetails()
       
   487 // -------------------------------------------------------------------------------------------------
       
   488 //
       
   489 void QMPXVideoPlaybackToolBar::updateWithFileDetails(
       
   490         QMPXVideoPlaybackViewFileDetails* details )
       
   491 {
       
   492     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::updateWithFileDetails()"));
       
   493 
       
   494     if ( mController->isAttachOperation() )
       
   495     {
       
   496         //
       
   497         // Show attach button
       
   498         //
       
   499         mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXAttachIcon] );
       
   500 
       
   501         if ( mButtons.count() )
       
   502         {
       
   503             disconnect( mButtons[EMPX1stButton], SIGNAL( released() ) );
       
   504             connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   505                      mController, SLOT( attachVideo() ) );
       
   506         }
       
   507     }
       
   508     else
       
   509     {
       
   510         if ( mController->viewMode() == EFullScreenView )
       
   511         {
       
   512             //
       
   513             // Show aspect ratio button
       
   514             //
       
   515             aspectRatioChanged( mAspectRatio );
       
   516 
       
   517             if ( ! details->mVideoEnabled ||
       
   518                    details->mVideoHeight <= 0 ||
       
   519                    details->mVideoWidth <= 0 ||
       
   520                    details->mTvOutConnected )
       
   521             {
       
   522                 //
       
   523                 // dim 'aspect ratio' buttons
       
   524                 //
       
   525                 mButtonActions[EMPX1stButton]->setEnabled( false );
       
   526             }
       
   527             else
       
   528             {
       
   529                 //
       
   530                 // check if video clip has same aspect ratio as display window 
       
   531                 //
       
   532                 TReal32 videoAspectRatio = (TReal32) details->mVideoWidth / (TReal32) details->mVideoHeight; 
       
   533                 bool enabled = ( mDisplayAspectRatio == videoAspectRatio )? false : true;
       
   534                 
       
   535                 //
       
   536                 // enable or dim 'aspect ratio' buttons accordingly
       
   537                 //
       
   538                 mButtonActions[EMPX1stButton]->setEnabled( enabled );
       
   539 
       
   540                 if ( mButtons.count() )
       
   541                 {
       
   542                     disconnect( mButtons[EMPX1stButton], SIGNAL( released() ) );
       
   543                     connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   544                              this, SLOT( changeAspectRatio() ) );
       
   545                 }
       
   546             }
       
   547         }                
       
   548         else if ( mController->viewMode() == EAudioOnlyView )
       
   549         {
       
   550             //
       
   551             // Show share button
       
   552             //
       
   553             mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXShareIcon] );
       
   554 
       
   555             if ( mController->fileDetails()->mPlaybackMode == EMPXVideoStreaming ||
       
   556                  mController->fileDetails()->mPlaybackMode == EMPXVideoLiveStreaming )
       
   557             {
       
   558                 //
       
   559                 // dim 'share' button for streaming
       
   560                 //
       
   561                 mButtonActions[EMPX1stButton]->setEnabled( false );
       
   562             }
       
   563             else
       
   564             {
       
   565                 //
       
   566                 // enable 'share' button
       
   567                 //
       
   568                 mButtonActions[EMPX1stButton]->setEnabled( true );
       
   569 
       
   570                 if ( mButtons.count() )
       
   571                 {
       
   572                     disconnect( mButtons[EMPX1stButton], SIGNAL( released() ) );
       
   573                     connect( mButtons[EMPX1stButton], SIGNAL( released() ), 
       
   574                              mController, SLOT( sendVideo() ) );
       
   575                 }
       
   576             }
       
   577         }
       
   578     }
       
   579 
       
   580     //
       
   581     // for audio-only clips and tv-out, default view is audionOnlyView
       
   582     // therefore, dim details button
       
   583     //
       
   584     if ( ! details->mVideoEnabled || details->mTvOutConnected )
       
   585     {
       
   586         mButtonActions[EMPX5thButton]->setEnabled( false );
       
   587     }
       
   588     else
       
   589     {
       
   590         mButtonActions[EMPX5thButton]->setEnabled( true );
       
   591     }
       
   592 
       
   593     if ( ! details->mSeekable )
       
   594     {
       
   595         mButtonActions[EMPX2ndButton]->setEnabled( false );
       
   596         mButtonActions[EMPX4thButton]->setEnabled( false );
       
   597     }
       
   598     else
       
   599     {
       
   600         mButtonActions[EMPX2ndButton]->setEnabled( true );
       
   601         mButtonActions[EMPX4thButton]->setEnabled( true );
       
   602     }
       
   603 
       
   604     if ( ! details->mPausableStream )
       
   605     {
       
   606         mButtonActions[EMPX3rdButton]->setEnabled( false );
       
   607     }
       
   608     else
       
   609     {
       
   610         mButtonActions[EMPX3rdButton]->setEnabled( true );
       
   611     }        
       
   612 }
       
   613 
       
   614 // -------------------------------------------------------------------------------------------------
       
   615 // QMPXVideoPlaybackToolBar::openDetailsView()
       
   616 // -------------------------------------------------------------------------------------------------
       
   617 //
       
   618 void QMPXVideoPlaybackToolBar::openDetailsView()
       
   619 {
       
   620     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::openDetailsView()"));
       
   621 
       
   622     TPlaybackViewMode viewMode = mController->viewMode();
       
   623 
       
   624     if ( viewMode == EFullScreenView )
       
   625     {
       
   626         mController->changeViewMode( EDetailsView );
       
   627     }
       
   628 }
       
   629 
       
   630 // -------------------------------------------------------------------------------------------------
       
   631 // QMPXVideoPlaybackToolBar::positionChanged
       
   632 // -------------------------------------------------------------------------------------------------
       
   633 //
       
   634 void QMPXVideoPlaybackToolBar::positionChanged( int position )
       
   635 {
       
   636     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::positionChanged position = %d"), position );
       
   637 
       
   638     mPosition = position;
       
   639     retrieveButtons();
       
   640 }
       
   641 
       
   642 // -------------------------------------------------------------------------------------------------
       
   643 // QMPXVideoPlaybackToolBar::durationChanged
       
   644 // -------------------------------------------------------------------------------------------------
       
   645 //
       
   646 void QMPXVideoPlaybackToolBar::durationChanged( int duration )
       
   647 {
       
   648     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::durationChanged duration = %d"), duration );
       
   649 
       
   650     mDuration = duration;
       
   651 }
       
   652 
       
   653 // -------------------------------------------------------------------------------------------------
       
   654 // QMPXVideoPlaybackToolBar::setVisible
       
   655 // -------------------------------------------------------------------------------------------------
       
   656 //
       
   657 void QMPXVideoPlaybackToolBar::setVisible( bool visible )
       
   658 {
       
   659     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::setVisible visible = %d"), visible );
       
   660 
       
   661     if ( visible )
       
   662     {
       
   663         mController->view()->showItems( Hb::ToolBarItem );
       
   664 
       
   665         if ( mNeverVisibled )
       
   666         {
       
   667             mNeverVisibled = false;
       
   668 
       
   669 
       
   670             //
       
   671             // toolbar creates button once it gets visible, so we don't know exact timing when toolbar 
       
   672             // creates button, so start timer to get layout information once the toolbar gets visible.
       
   673             // This is needed since we don't use toolbar in proper way.
       
   674             //
       
   675             mRetrieveButtonTimer = new QTimer();
       
   676             mRetrieveButtonTimer->setSingleShot( false );
       
   677             mRetrieveButtonTimer->setInterval( KRetrieveButtonTimeOut );
       
   678             connect( mRetrieveButtonTimer, SIGNAL( timeout() ), this, SLOT( retrieveButtons() ) );
       
   679 
       
   680             mRetrieveButtonTimer->start();
       
   681         }
       
   682     }
       
   683     else
       
   684     {
       
   685         mController->view()->hideItems( Hb::ToolBarItem );
       
   686     }
       
   687 }
       
   688 
       
   689 // -------------------------------------------------------------------------------------------------
       
   690 // QMPXVideoPlaybackToolBar::retrieveButtons()
       
   691 // -------------------------------------------------------------------------------------------------
       
   692 //
       
   693 void QMPXVideoPlaybackToolBar::retrieveButtons()
       
   694 {
       
   695     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::retrieveButtons()"));
       
   696 
       
   697     if ( mButtons.count() == 0 )
       
   698     {
       
   699         QGraphicsLayout *layout = mToolBar->layout();
       
   700 
       
   701         if ( layout )
       
   702         {
       
   703 		    disconnect( mRetrieveButtonTimer, SIGNAL( timeout() ), this, SLOT( retrieveButtons() ) );
       
   704             if ( mRetrieveButtonTimer->isActive() )
       
   705             {
       
   706                 mRetrieveButtonTimer->stop();
       
   707             }
       
   708 
       
   709             for ( int i = 0 ; i < layout->count() ; i++ )
       
   710             {
       
   711                 mButtons.append( dynamic_cast<HbToolButton*>( layout->itemAt( i ) ) );
       
   712             }
       
   713 
       
   714             //
       
   715             // Connect signal and slots
       
   716             //
       
   717             connect( mButtons[EMPX1stButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
       
   718 
       
   719             connect( mButtons[EMPX2ndButton], SIGNAL( pressed() ), this, SLOT( handleRWButtonPressed() ) );
       
   720             connect( mButtons[EMPX2ndButton], SIGNAL( released() ), this, SLOT( rwReleased() ) );
       
   721 
       
   722             connect( mButtons[EMPX3rdButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
       
   723             connect( mButtons[EMPX3rdButton], SIGNAL( released() ), this, SLOT( playPause() ) );
       
   724 
       
   725             connect( mButtons[EMPX4thButton], SIGNAL( pressed() ), this, SLOT( handleFFButtonPressed() ) );
       
   726             connect( mButtons[EMPX4thButton], SIGNAL( released() ), this, SLOT( ffReleased() ) );
       
   727 
       
   728             connect( mButtons[EMPX5thButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
       
   729             connect( mButtons[EMPX5thButton], SIGNAL( released() ), this, SLOT( openDetailsView() ) );
       
   730 
       
   731             if ( mController->isAttachOperation() )
       
   732             {
       
   733                 connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   734                          mController, SLOT( attachVideo() ) );
       
   735             }
       
   736             else
       
   737             {
       
   738                 if ( mController->viewMode() == EFullScreenView )
       
   739                 {
       
   740                     connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   741                              this, SLOT( changeAspectRatio() ) );
       
   742                 }                
       
   743                 else if ( mController->viewMode() == EAudioOnlyView )
       
   744                 {
       
   745                     connect( mButtons[EMPX1stButton], SIGNAL( released() ), 
       
   746                              mController, SLOT( sendVideo() ) );
       
   747                 }
       
   748             }
       
   749         }
       
   750     }
       
   751 }
       
   752 
       
   753 //End of file