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