videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybacktoolbar.cpp
changeset 44 518105d52e45
parent 42 17f382c040b1
child 49 824471cb468a
equal deleted inserted replaced
42:17f382c040b1 44:518105d52e45
     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:  7 %
       
    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 "hbvideobaseplaybackview.h"
       
    33 #include "mpxvideoplaybacktoolbar.h"
       
    34 #include "mpxcommonvideoplaybackview.hrh"
       
    35 #include "mpxvideoplaybackdocumentloader.h"
       
    36 #include "mpxvideoplaybackviewfiledetails.h"
       
    37 #include "mpxvideoplaybackcontrolscontroller.h"
       
    38 
       
    39 const int KSeekStartTimeOut = 700;
       
    40 const int KRetrieveButtonTimeOut = 1000;
       
    41 
       
    42 // -------------------------------------------------------------------------------------------------
       
    43 // QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar()
       
    44 // -------------------------------------------------------------------------------------------------
       
    45 //
       
    46 QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar(
       
    47         QMPXVideoPlaybackControlsController* controller )
       
    48     : mController( controller )
       
    49     , mSeekStartTimer( NULL )
       
    50     , mRetrieveButtonTimer( NULL )
       
    51     , mSeekingState( EMPXNotSeeking )
       
    52     , mInitialized( false )
       
    53     , mPosition( 0 )
       
    54     , mDuration( 0 )
       
    55     , mAspectRatio( EMPXPbvCmdNaturalAspectRatio )
       
    56 {
       
    57     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::QMPXVideoPlaybackToolBar"));
       
    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 // QMPXVideoPlaybackToolBar::~QMPXVideoPlaybackToolBar()
       
    69 // -------------------------------------------------------------------------------------------------
       
    70 //
       
    71 QMPXVideoPlaybackToolBar::~QMPXVideoPlaybackToolBar()
       
    72 {
       
    73     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::~QMPXVideoPlaybackToolBar()"));
       
    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 // QMPXVideoPlaybackToolBar::initialize()
       
   111 // -------------------------------------------------------------------------------------------------
       
   112 //
       
   113 void QMPXVideoPlaybackToolBar::initialize()
       
   114 {
       
   115     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::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 < EMPXButtonCount ; i++ )
       
   127         {
       
   128             mButtonActions.append( new HbAction( actionsGroup ) );
       
   129         }
       
   130 
       
   131         for ( int i = 0 ; i < EMPXIconCount ; i++ )
       
   132         {
       
   133             mButtonIcons.append( new HbIcon() );
       
   134         }
       
   135 
       
   136         //
       
   137         // RW button
       
   138         //
       
   139         mButtonIcons[EMPXRWIcon]->setIconName( "qtg_mono_previous" );
       
   140         mButtonActions[EMPX2ndButton]->setIcon( *mButtonIcons[EMPXRWIcon] );
       
   141 
       
   142         //
       
   143         // Play/Pause button
       
   144         //
       
   145         mButtonIcons[EMPXPlayIcon]->setIconName( "qtg_mono_play" );
       
   146         mButtonIcons[EMPXPauseIcon]->setIconName( "qtg_mono_pause" );
       
   147         mButtonActions[EMPX3rdButton]->setIcon( *mButtonIcons[EMPXPlayIcon] );
       
   148 
       
   149         //
       
   150         // FF button
       
   151         //
       
   152         mButtonIcons[EMPXFFIcon]->setIconName( "qtg_mono_next" );
       
   153         mButtonActions[EMPX4thButton]->setIcon( *mButtonIcons[EMPXFFIcon] );
       
   154 
       
   155         //
       
   156         // Details button
       
   157         //
       
   158         mButtonIcons[EMPXDetailsIcon]->setIconName( "qtg_mono_info" );
       
   159         mButtonActions[EMPX5thButton]->setIcon( *mButtonIcons[EMPXDetailsIcon] );
       
   160 
       
   161         //
       
   162         // Aspect ratio buttons
       
   163         //
       
   164         mButtonIcons[EMPXNaturalIcon]->setIconName( "qtg_mono_aspect_ratio_natural" );
       
   165         mButtonIcons[EMPXStretchIcon]->setIconName( "qtg_mono_aspect_ratio_stretched" );
       
   166         mButtonIcons[EMPXZoomIcon]->setIconName( "qtg_mono_aspect_ratio_zoom" );
       
   167         mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXNaturalIcon] );
       
   168 
       
   169         //
       
   170         // Attach/Share button
       
   171         //
       
   172         mButtonIcons[EMPXAttachIcon]->setIconName( "qtg_mono_attach" );
       
   173         mButtonIcons[EMPXShareIcon]->setIconName( "qtg_mono_share" );
       
   174 
       
   175         for ( int i = 0 ; i < EMPXButtonCount ; 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 // QMPXVideoPlaybackToolBar::playPause()
       
   210 // -------------------------------------------------------------------------------------------------
       
   211 //
       
   212 void QMPXVideoPlaybackToolBar::playPause()
       
   213 {
       
   214     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::playPause()"));
       
   215 
       
   216     mController->resetDisappearingTimers( EMPXTimerReset );
       
   217     mController->handleCommand( EMPXPbvCmdPlayPause );
       
   218 }
       
   219 
       
   220 // -------------------------------------------------------------------------------------------------
       
   221 // QMPXVideoPlaybackToolBar::ffPressing()
       
   222 // -------------------------------------------------------------------------------------------------
       
   223 //
       
   224 void QMPXVideoPlaybackToolBar::ffPressing()
       
   225 {
       
   226     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::ffPressing()"),
       
   227                    _L("mSeekingState = %d"), mSeekingState );
       
   228 
       
   229     if ( mSeekingState == EMPXNotSeeking )
       
   230     {
       
   231         mSeekingState = EMPXFastForwarding;
       
   232 
       
   233         mController->handleCommand( EMPXPbvCmdSeekForward );
       
   234     }
       
   235 }
       
   236 
       
   237 // -------------------------------------------------------------------------------------------------
       
   238 // QMPXVideoPlaybackToolBar::rwPressing()
       
   239 // -------------------------------------------------------------------------------------------------
       
   240 //
       
   241 void QMPXVideoPlaybackToolBar::rwPressing()
       
   242 {
       
   243     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::rwPressing()"),
       
   244                    _L("mSeekingState = %d"), mSeekingState );
       
   245 
       
   246     if ( mSeekingState == EMPXNotSeeking )
       
   247     {
       
   248         mSeekingState = EMPXRewinding;
       
   249 
       
   250         mController->handleCommand( EMPXPbvCmdSeekBackward );
       
   251     }
       
   252 }
       
   253 
       
   254 // -------------------------------------------------------------------------------------------------
       
   255 // QMPXVideoPlaybackToolBar::ffReleased()
       
   256 // -------------------------------------------------------------------------------------------------
       
   257 //
       
   258 void QMPXVideoPlaybackToolBar::ffReleased()
       
   259 {
       
   260     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::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 == EMPXFastForwarding )
       
   271     {
       
   272         mController->handleCommand( EMPXPbvCmdEndSeek );
       
   273     }
       
   274     else
       
   275     {
       
   276         int temp = mPosition + KMPXFastForward;
       
   277         MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::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 = EMPXNotSeeking;
       
   289     mController->resetDisappearingTimers( EMPXTimerReset );
       
   290 }
       
   291 
       
   292 // -------------------------------------------------------------------------------------------------
       
   293 // QMPXVideoPlaybackToolBar::rwReleased()
       
   294 // -------------------------------------------------------------------------------------------------
       
   295 //
       
   296 void QMPXVideoPlaybackToolBar::rwReleased()
       
   297 {
       
   298     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::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 == EMPXRewinding )
       
   309     {
       
   310         mController->handleCommand( EMPXPbvCmdEndSeek );
       
   311     }
       
   312     else
       
   313     {
       
   314         int temp = mPosition + KMPXRewind;
       
   315         MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::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 = EMPXNotSeeking;
       
   329     mController->resetDisappearingTimers( EMPXTimerReset );
       
   330 }
       
   331 
       
   332 // -------------------------------------------------------------------------------------------------
       
   333 // QMPXVideoPlaybackToolBar::changeAspectRatio()
       
   334 // -------------------------------------------------------------------------------------------------
       
   335 //
       
   336 void QMPXVideoPlaybackToolBar::changeAspectRatio()
       
   337 {
       
   338     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::changeAspectRatio()"));
       
   339 
       
   340     mController->resetDisappearingTimers( EMPXTimerReset );
       
   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 // QMPXVideoPlaybackToolBar::updateState()
       
   363 // -------------------------------------------------------------------------------------------------
       
   364 //
       
   365 void QMPXVideoPlaybackToolBar::updateState( TMPXPlaybackState state )
       
   366 {
       
   367     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::updateState() state = %d"), state );
       
   368 
       
   369     switch ( state )
       
   370     {
       
   371         case EPbStatePlaying:
       
   372         {
       
   373             mToolBar->setEnabled( true );
       
   374 
       
   375             mButtonActions[EMPX3rdButton]->setIcon( *mButtonIcons[EMPXPauseIcon] );
       
   376 
       
   377             break;
       
   378         }
       
   379         case EPbStatePaused:
       
   380         {
       
   381             mToolBar->setEnabled( true );
       
   382 
       
   383             mButtonActions[EMPX3rdButton]->setIcon( *mButtonIcons[EMPXPlayIcon] );
       
   384 
       
   385             break;
       
   386         }
       
   387         default:
       
   388         {
       
   389             mToolBar->setEnabled( false );
       
   390 
       
   391             break;
       
   392         }
       
   393     }
       
   394 }
       
   395 
       
   396 // -------------------------------------------------------------------------------------------------
       
   397 // QMPXVideoPlaybackToolBar::aspectRatioChanged()
       
   398 // -------------------------------------------------------------------------------------------------
       
   399 //
       
   400 void QMPXVideoPlaybackToolBar::aspectRatioChanged( int aspectRatio )
       
   401 {
       
   402     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio );
       
   403 
       
   404     mAspectRatio = aspectRatio;
       
   405 
       
   406     //
       
   407     // If we are in attach service or audio only view, then don't update the icon.
       
   408 	// Aspect ratio icon slots are shared with attach and share icon.
       
   409 	// Just update the mAspectRatio
       
   410 	// and once we go back to full screen, we will show the correct aspect ratio icon
       
   411 	//
       
   412     if ( ! mController->isAttachOperation() && mController->viewMode() == EFullScreenView )
       
   413     {
       
   414         switch( mAspectRatio )
       
   415         {
       
   416             case EMMFNatural:
       
   417             {
       
   418                 mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXStretchIcon] );
       
   419                 break;
       
   420             }
       
   421             case EMMFStretch:
       
   422             {
       
   423                 mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXZoomIcon] );
       
   424                 break;
       
   425             }
       
   426             default:
       
   427             {
       
   428                 mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXNaturalIcon] );
       
   429                 break;
       
   430             }
       
   431         }
       
   432     }
       
   433 }
       
   434 
       
   435 // -------------------------------------------------------------------------------------------------
       
   436 // QMPXVideoPlaybackToolBar::handleButtonPressed()
       
   437 // -------------------------------------------------------------------------------------------------
       
   438 //
       
   439 void QMPXVideoPlaybackToolBar::handleButtonPressed()
       
   440 {
       
   441     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::handleButtonPressed()"));
       
   442 
       
   443     mController->resetDisappearingTimers( EMPXTimerCancel );
       
   444 }
       
   445 
       
   446 // -------------------------------------------------------------------------------------------------
       
   447 // QMPXVideoPlaybackToolBar::handleRWButtonPressed()
       
   448 // -------------------------------------------------------------------------------------------------
       
   449 //
       
   450 void QMPXVideoPlaybackToolBar::handleRWButtonPressed()
       
   451 {
       
   452     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::handleRWButtonPressed()"));
       
   453 
       
   454     mController->resetDisappearingTimers( EMPXTimerCancel );
       
   455 
       
   456     connect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( rwPressing() ) );
       
   457 
       
   458     if ( mSeekStartTimer->isActive() )
       
   459     {
       
   460         mSeekStartTimer->stop();
       
   461     }
       
   462 
       
   463     mSeekStartTimer->start();
       
   464 }
       
   465 
       
   466 // -------------------------------------------------------------------------------------------------
       
   467 // QMPXVideoPlaybackToolBar::handleFFButtonPressed()
       
   468 // -------------------------------------------------------------------------------------------------
       
   469 //
       
   470 void QMPXVideoPlaybackToolBar::handleFFButtonPressed()
       
   471 {
       
   472     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::handleButtonPressed()"));
       
   473 
       
   474     mController->resetDisappearingTimers( EMPXTimerCancel );
       
   475 
       
   476     connect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( ffPressing() ) );
       
   477 
       
   478     if ( mSeekStartTimer->isActive() )
       
   479     {
       
   480         mSeekStartTimer->stop();
       
   481     }
       
   482 
       
   483     mSeekStartTimer->start();
       
   484 }
       
   485 
       
   486 // -------------------------------------------------------------------------------------------------
       
   487 // QMPXVideoPlaybackToolBar::updateWithFileDetails()
       
   488 // -------------------------------------------------------------------------------------------------
       
   489 //
       
   490 void QMPXVideoPlaybackToolBar::updateWithFileDetails(
       
   491         QMPXVideoPlaybackViewFileDetails* details )
       
   492 {
       
   493     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::updateWithFileDetails()"));
       
   494 
       
   495     if ( mController->isAttachOperation() )
       
   496     {
       
   497         //
       
   498         // Show attach button
       
   499         //
       
   500         mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXAttachIcon] );
       
   501 
       
   502         if ( mButtons.count() )
       
   503         {
       
   504             disconnect( mButtons[EMPX1stButton], SIGNAL( released() ), 0, 0 );
       
   505             connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   506                      mController, SLOT( attachVideo() ) );
       
   507         }
       
   508     }
       
   509     else
       
   510     {
       
   511         if ( mController->viewMode() == EFullScreenView )
       
   512         {
       
   513             //
       
   514             // Show aspect ratio button
       
   515             //
       
   516             aspectRatioChanged( mAspectRatio );
       
   517 
       
   518             if ( ! details->mVideoEnabled ||
       
   519                    details->mVideoHeight <= 0 ||
       
   520                    details->mVideoWidth <= 0 ||
       
   521                    details->mTvOutConnected )
       
   522             {
       
   523                 //
       
   524                 // dim 'aspect ratio' buttons
       
   525                 //
       
   526                 mButtonActions[EMPX1stButton]->setEnabled( false );
       
   527             }
       
   528             else
       
   529             {
       
   530                 //
       
   531                 // check if video clip has same aspect ratio as display window
       
   532                 //
       
   533                 TReal32 videoAspectRatio = (TReal32) details->mVideoWidth / (TReal32) details->mVideoHeight;
       
   534                 bool enabled = ( mDisplayAspectRatio == videoAspectRatio )? false : true;
       
   535 
       
   536                 //
       
   537                 // enable or dim 'aspect ratio' buttons accordingly
       
   538                 //
       
   539                 mButtonActions[EMPX1stButton]->setEnabled( enabled );
       
   540 
       
   541                 if ( mButtons.count() )
       
   542                 {
       
   543                     disconnect( mButtons[EMPX1stButton], SIGNAL( released() ), 0, 0 );
       
   544                     connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   545                              this, SLOT( changeAspectRatio() ) );
       
   546                 }
       
   547             }
       
   548         }
       
   549         else if ( mController->viewMode() == EAudioOnlyView )
       
   550         {
       
   551             //
       
   552             // Show share button
       
   553             //
       
   554             mButtonActions[EMPX1stButton]->setIcon( *mButtonIcons[EMPXShareIcon] );
       
   555 
       
   556             if ( mController->fileDetails()->mPlaybackMode == EMPXVideoStreaming ||
       
   557                  mController->fileDetails()->mPlaybackMode == EMPXVideoLiveStreaming )
       
   558             {
       
   559                 //
       
   560                 // dim 'share' button for streaming
       
   561                 //
       
   562                 mButtonActions[EMPX1stButton]->setEnabled( false );
       
   563             }
       
   564             else
       
   565             {
       
   566                 //
       
   567                 // enable 'share' button
       
   568                 //
       
   569                 mButtonActions[EMPX1stButton]->setEnabled( true );
       
   570 
       
   571                 if ( mButtons.count() )
       
   572                 {
       
   573                     disconnect( mButtons[EMPX1stButton], SIGNAL( released() ), 0, 0 );
       
   574                     connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   575                              mController, SLOT( sendVideo() ) );
       
   576                 }
       
   577             }
       
   578         }
       
   579     }
       
   580 
       
   581     //
       
   582     // for audio-only clips and tv-out, default view is audionOnlyView
       
   583     // therefore, dim details button
       
   584     //
       
   585     if ( ! details->mVideoEnabled || details->mTvOutConnected )
       
   586     {
       
   587         mButtonActions[EMPX5thButton]->setEnabled( false );
       
   588     }
       
   589     else
       
   590     {
       
   591         mButtonActions[EMPX5thButton]->setEnabled( true );
       
   592     }
       
   593 
       
   594     if ( details->mSeekable && details->mPausableStream )
       
   595     {
       
   596         mButtonActions[EMPX2ndButton]->setEnabled( true );
       
   597         mButtonActions[EMPX4thButton]->setEnabled( true );
       
   598     }
       
   599     else
       
   600     {
       
   601         mButtonActions[EMPX2ndButton]->setEnabled( false );
       
   602         mButtonActions[EMPX4thButton]->setEnabled( false );
       
   603     }
       
   604 
       
   605     if ( details->mPausableStream )
       
   606     {
       
   607         mButtonActions[EMPX3rdButton]->setEnabled( true );
       
   608     }
       
   609     else
       
   610     {
       
   611         mButtonActions[EMPX3rdButton]->setEnabled( false );
       
   612     }
       
   613 
       
   614     //
       
   615     // toolbar creates button once it gets visible, so we don't know exact timing when toolbar
       
   616     // creates button, so start timer to get layout information once the toolbar gets visible.
       
   617     // This is needed since we don't use toolbar in proper way.
       
   618     //
       
   619     if ( ! mRetrieveButtonTimer && ! mButtons.count() )
       
   620     {
       
   621         mRetrieveButtonTimer = new QTimer();
       
   622         mRetrieveButtonTimer->setSingleShot( false );
       
   623         mRetrieveButtonTimer->setInterval( KRetrieveButtonTimeOut );
       
   624         connect( mRetrieveButtonTimer, SIGNAL( timeout() ), this, SLOT( retrieveButtons() ) );
       
   625 
       
   626         mRetrieveButtonTimer->start();
       
   627     }
       
   628 
       
   629     durationChanged( (qreal)mController->fileDetails()->mDuration / (qreal)KPbMilliMultiplier );
       
   630 }
       
   631 
       
   632 // -------------------------------------------------------------------------------------------------
       
   633 // QMPXVideoPlaybackToolBar::openDetailsView()
       
   634 // -------------------------------------------------------------------------------------------------
       
   635 //
       
   636 void QMPXVideoPlaybackToolBar::openDetailsView()
       
   637 {
       
   638     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackToolBar::openDetailsView()"));
       
   639 
       
   640     TPlaybackViewMode viewMode = mController->viewMode();
       
   641 
       
   642     if ( viewMode == EFullScreenView )
       
   643     {
       
   644         mController->changeViewMode( EDetailsView );
       
   645     }
       
   646 }
       
   647 
       
   648 // -------------------------------------------------------------------------------------------------
       
   649 // QMPXVideoPlaybackToolBar::positionChanged
       
   650 // -------------------------------------------------------------------------------------------------
       
   651 //
       
   652 void QMPXVideoPlaybackToolBar::positionChanged( int position )
       
   653 {
       
   654     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::positionChanged position = %d"), position );
       
   655 
       
   656     mPosition = position;
       
   657 }
       
   658 
       
   659 // -------------------------------------------------------------------------------------------------
       
   660 // QMPXVideoPlaybackToolBar::durationChanged
       
   661 // -------------------------------------------------------------------------------------------------
       
   662 //
       
   663 void QMPXVideoPlaybackToolBar::durationChanged( int duration )
       
   664 {
       
   665     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::durationChanged duration = %d"), duration );
       
   666 
       
   667     mDuration = duration;
       
   668 }
       
   669 
       
   670 // -------------------------------------------------------------------------------------------------
       
   671 // QMPXVideoPlaybackToolBar::setVisible
       
   672 // -------------------------------------------------------------------------------------------------
       
   673 //
       
   674 void QMPXVideoPlaybackToolBar::setVisible( bool visible )
       
   675 {
       
   676     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::setVisible visible = %d"), visible );
       
   677 
       
   678     if ( visible )
       
   679     {
       
   680         mController->view()->showItems( Hb::ToolBarItem );
       
   681     }
       
   682     else
       
   683     {
       
   684         mController->view()->hideItems( Hb::ToolBarItem );
       
   685     }
       
   686 }
       
   687 
       
   688 // -------------------------------------------------------------------------------------------------
       
   689 // QMPXVideoPlaybackToolBar::retrieveButtons()
       
   690 // -------------------------------------------------------------------------------------------------
       
   691 //
       
   692 void QMPXVideoPlaybackToolBar::retrieveButtons()
       
   693 {
       
   694     MPX_DEBUG(_L("QMPXVideoPlaybackToolBar::retrieveButtons()"));
       
   695 
       
   696     if ( mButtons.count() == 0 )
       
   697     {
       
   698         QGraphicsLayout *layout = mToolBar->layout();
       
   699 
       
   700         if ( layout )
       
   701         {
       
   702             if ( mRetrieveButtonTimer )
       
   703             {
       
   704                 disconnect( mRetrieveButtonTimer, SIGNAL( timeout() ), this, SLOT( retrieveButtons() ) );
       
   705                 if ( mRetrieveButtonTimer->isActive() )
       
   706                 {
       
   707                     mRetrieveButtonTimer->stop();
       
   708                 }
       
   709             }
       
   710 
       
   711             for ( int i = 0 ; i < layout->count() ; i++ )
       
   712             {
       
   713                 mButtons.append( dynamic_cast<HbToolButton*>( layout->itemAt( i ) ) );
       
   714             }
       
   715 
       
   716             //
       
   717             // Connect signal and slots
       
   718             //
       
   719             connect( mButtons[EMPX1stButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
       
   720 
       
   721             connect( mButtons[EMPX2ndButton], SIGNAL( pressed() ), this, SLOT( handleRWButtonPressed() ) );
       
   722             connect( mButtons[EMPX2ndButton], SIGNAL( released() ), this, SLOT( rwReleased() ) );
       
   723 
       
   724             connect( mButtons[EMPX3rdButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
       
   725             connect( mButtons[EMPX3rdButton], SIGNAL( released() ), this, SLOT( playPause() ) );
       
   726 
       
   727             connect( mButtons[EMPX4thButton], SIGNAL( pressed() ), this, SLOT( handleFFButtonPressed() ) );
       
   728             connect( mButtons[EMPX4thButton], SIGNAL( released() ), this, SLOT( ffReleased() ) );
       
   729 
       
   730             connect( mButtons[EMPX5thButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
       
   731             connect( mButtons[EMPX5thButton], SIGNAL( released() ), this, SLOT( openDetailsView() ) );
       
   732 
       
   733             if ( mController->isAttachOperation() )
       
   734             {
       
   735                 connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   736                          mController, SLOT( attachVideo() ) );
       
   737             }
       
   738             else
       
   739             {
       
   740                 if ( mController->viewMode() == EFullScreenView )
       
   741                 {
       
   742                     connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   743                              this, SLOT( changeAspectRatio() ) );
       
   744                 }
       
   745                 else if ( mController->viewMode() == EAudioOnlyView )
       
   746                 {
       
   747                     connect( mButtons[EMPX1stButton], SIGNAL( released() ),
       
   748                              mController, SLOT( sendVideo() ) );
       
   749                 }
       
   750             }
       
   751         }
       
   752     }
       
   753 }
       
   754 
       
   755 //End of file