videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackcontrolbar.cpp
changeset 20 b9e04db066d4
parent 17 69946d1824c4
child 41 229f037ce963
equal deleted inserted replaced
17:69946d1824c4 20:b9e04db066d4
    13 *
    13 *
    14 * Description:  Implementation of QMPXVideoPlaybackControlBar
    14 * Description:  Implementation of QMPXVideoPlaybackControlBar
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version:  5 %
    18 // Version : %version:  6 %
    19 
    19 
    20 
    20 
    21 
       
    22 #include <hbframeitem.h>
       
    23 #include <hbframedrawer.h>
       
    24 
    21 
    25 #include "mpxvideo_debug.h"
    22 #include "mpxvideo_debug.h"
    26 #include "mpxvideoplaybackbuttonbar.h"
    23 #include "mpxvideoplaybacktoolbar.h"
    27 #include "mpxvideoplaybackcontrolbar.h"
    24 #include "mpxvideoplaybackcontrolbar.h"
    28 #include "mpxvideoplaybackprogressbar.h"
    25 #include "mpxvideoplaybackprogressbar.h"
    29 #include "mpxcommonvideoplaybackview.hrh"
    26 #include "mpxcommonvideoplaybackview.hrh"
    30 #include "mpxvideoplaybackdocumentloader.h"
    27 #include "mpxvideoplaybackdocumentloader.h"
    31 #include "mpxvideoplaybackcontrolscontroller.h"
    28 #include "mpxvideoplaybackcontrolscontroller.h"
    36 // -------------------------------------------------------------------------------------------------
    33 // -------------------------------------------------------------------------------------------------
    37 //
    34 //
    38 QMPXVideoPlaybackControlBar::QMPXVideoPlaybackControlBar( 
    35 QMPXVideoPlaybackControlBar::QMPXVideoPlaybackControlBar( 
    39         QMPXVideoPlaybackControlsController* controller )
    36         QMPXVideoPlaybackControlsController* controller )
    40     : mController( controller )
    37     : mController( controller )
    41     , mButtonBar( NULL )
       
    42     , mProgressBar( NULL )
    38     , mProgressBar( NULL )
    43     , mFrameItem( NULL )
       
    44 {
    39 {
    45     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlBar::QMPXVideoPlaybackControlBar"));
    40     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlBar::QMPXVideoPlaybackControlBar"));
    46 
    41 
    47     HbEffect::add( this, ":/hbvideoplaybackview/effects/controlbar_appear.fxml", "appear" );
    42     //
    48     HbEffect::add( this, ":/hbvideoplaybackview/effects/controlbar_disappear.fxml", "disappear" );
    43     // button bar
       
    44     //
       
    45     mToolBar = new QMPXVideoPlaybackToolBar( mController );
    49 }
    46 }
    50 
    47 
    51 // -------------------------------------------------------------------------------------------------
    48 // -------------------------------------------------------------------------------------------------
    52 // QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()
    49 // QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()
    53 // -------------------------------------------------------------------------------------------------
    50 // -------------------------------------------------------------------------------------------------
    54 //
    51 //
    55 QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()
    52 QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()
    56 {
    53 {
    57     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()"));
    54     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()"));
    58 
    55 
    59     HbEffect::remove( this, ":/hbvideoplaybackview/effects/controlbar_appear.fxml", "appear" );
    56     if ( mToolBar )
    60     HbEffect::remove( this, ":/hbvideoplaybackview/effects/controlbar_disappear.fxml", "disappear" );
    57     {
       
    58         delete mToolBar;
       
    59         mToolBar = NULL;
       
    60     }
    61 }
    61 }
    62 
    62 
    63 // -------------------------------------------------------------------------------------------------
    63 // -------------------------------------------------------------------------------------------------
    64 // QMPXVideoPlaybackControlBar::initialize()
    64 // QMPXVideoPlaybackControlBar::initialize()
    65 // -------------------------------------------------------------------------------------------------
    65 // -------------------------------------------------------------------------------------------------
    71     QMPXVideoPlaybackDocumentLoader *loader = mController->layoutLoader();
    71     QMPXVideoPlaybackDocumentLoader *loader = mController->layoutLoader();
    72 
    72 
    73     //
    73     //
    74     // Don't need to initialize buttons once it gets initialized
    74     // Don't need to initialize buttons once it gets initialized
    75     //
    75     //
    76     if ( mButtonBar == NULL && mProgressBar == NULL )
    76     if ( mProgressBar == NULL )
    77     {
    77     {
    78         //
       
    79         // button bar
       
    80         //
       
    81         QGraphicsWidget *widget = loader->findWidget( QString( "buttonBarLayout" ) );
       
    82         mButtonBar = qobject_cast<QMPXVideoPlaybackButtonBar*>( widget );
       
    83 
       
    84         if ( mButtonBar )
       
    85         {
       
    86             mButtonBar->initialize();
       
    87         }
       
    88         
       
    89         //
    78         //
    90         // progress bar
    79         // progress bar
    91         //
    80         //
    92         widget = loader->findWidget( QString( "progressBarLayout" ) );
    81         QGraphicsWidget *widget = loader->findWidget( QString( "progressBarLayout" ) );
    93         mProgressBar = qobject_cast<QMPXVideoPlaybackProgressBar*>( widget );
    82         mProgressBar = qobject_cast<QMPXVideoPlaybackProgressBar*>( widget );
    94 
    83 
    95         if ( mProgressBar )
    84         if ( mProgressBar )
    96         {
    85         {
    97             mProgressBar->initialize();
    86             mProgressBar->initialize();
    98         }
    87         }
    99 
       
   100         //
       
   101         // Set framedrawer for semi transparent background
       
   102         //
       
   103         mFrameItem = new HbFrameItem ( this );
       
   104         mFrameItem->setGeometry( boundingRect() );
       
   105         mFrameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_multimedia_trans" );
       
   106         mFrameItem->frameDrawer().setFrameType( HbFrameDrawer::NinePieces );
       
   107         mFrameItem->frameDrawer().setFillWholeRect( true );
       
   108         mFrameItem->setVisible( false );
       
   109     }
    88     }
   110 }
    89 }
   111 
    90 
   112 // -------------------------------------------------------------------------------------------------
    91 // -------------------------------------------------------------------------------------------------
   113 // QMPXVideoPlaybackControlBar::updateState()
    92 // QMPXVideoPlaybackControlBar::updateState()
   115 //
    94 //
   116 void QMPXVideoPlaybackControlBar::updateState( TMPXPlaybackState state )
    95 void QMPXVideoPlaybackControlBar::updateState( TMPXPlaybackState state )
   117 {
    96 {
   118     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::updateState() state = %d"), state );
    97     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::updateState() state = %d"), state );
   119 
    98 
   120     if ( mButtonBar )
    99     if ( mToolBar )
   121     {
   100     {
   122         mButtonBar->updateState( state );
   101         mToolBar->updateState( state );
   123     }
   102     }
   124 
   103 
   125     if ( mProgressBar )
   104     if ( mProgressBar )
   126     {
   105     {
   127         mProgressBar->updateState( state );
   106         mProgressBar->updateState( state );
   134 //
   113 //
   135 void QMPXVideoPlaybackControlBar::aspectRatioChanged( int aspectRatio )
   114 void QMPXVideoPlaybackControlBar::aspectRatioChanged( int aspectRatio )
   136 {
   115 {
   137     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio );
   116     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio );
   138 
   117 
   139     if ( mButtonBar )
   118     if ( mToolBar )
   140     {
   119     {
   141         mButtonBar->aspectRatioChanged( aspectRatio );
   120         mToolBar->aspectRatioChanged( aspectRatio );
   142     }
   121     }
   143 }
   122 }
   144 
   123 
   145 // -------------------------------------------------------------------------------------------------
   124 // -------------------------------------------------------------------------------------------------
   146 // QMPXVideoPlaybackControlBar::updateWithFileDetails()
   125 // QMPXVideoPlaybackControlBar::updateWithFileDetails()
   149 void QMPXVideoPlaybackControlBar::updateWithFileDetails(
   128 void QMPXVideoPlaybackControlBar::updateWithFileDetails(
   150         QMPXVideoPlaybackViewFileDetails* details )
   129         QMPXVideoPlaybackViewFileDetails* details )
   151 {
   130 {
   152     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::updateWithFileDetails()"));
   131     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::updateWithFileDetails()"));
   153 
   132 
   154     if ( mButtonBar )
   133     if ( mToolBar )
   155     {
   134     {
   156         mButtonBar->updateWithFileDetails( details );
   135         mToolBar->updateWithFileDetails( details );
   157     }
   136     }
   158 
   137 
   159     if ( mProgressBar )
   138     if ( mProgressBar )
   160     {
   139     {
   161         mProgressBar->updateWithFileDetails( details );
   140         mProgressBar->updateWithFileDetails( details );
   162     }
   141     }
   163 
       
   164     mFrameItem->setVisible( ( mController->viewMode() == EFullScreenView )? ETrue:EFalse ); 
       
   165 }
   142 }
   166 
   143 
   167 // -------------------------------------------------------------------------------------------------
   144 // -------------------------------------------------------------------------------------------------
   168 // QMPXVideoPlaybackControlBar::setVisibleToControlBar()
   145 // QMPXVideoPlaybackControlBar::setVisibleToControlBar()
   169 // -------------------------------------------------------------------------------------------------
   146 // -------------------------------------------------------------------------------------------------
   171 void QMPXVideoPlaybackControlBar::setVisibleToControlBar( bool visible )
   148 void QMPXVideoPlaybackControlBar::setVisibleToControlBar( bool visible )
   172 {
   149 {
   173     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlBar::setVisibleToControlBar()"),
   150     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlBar::setVisibleToControlBar()"),
   174                    _L("visible = %d, current visibility = %d"), visible, isVisible() );
   151                    _L("visible = %d, current visibility = %d"), visible, isVisible() );
   175 
   152 
   176     //
   153     if ( visible != isVisible() )
   177     // Change the visibility if the following condition meet:
   154     {
   178     // - visible is true
   155         setVisible( visible );
   179     // - appear effect is not going on
   156         mToolBar->setVisible( visible );        
   180     // - disappear effect is going on (assume current visiblity is false)
       
   181     //
       
   182     if ( visible && 
       
   183          ! HbEffect::effectRunning( this, "appear" ) &&
       
   184          ( ! isVisible() || HbEffect::effectRunning( this, "disappear" ) ) )
       
   185     {
       
   186         //
       
   187         // If disappear effect is running on this, cancel
       
   188         //
       
   189         if ( HbEffect::effectRunning( this, "disappear" ) )
       
   190         {
       
   191             HbEffect::cancel( this );
       
   192         }
       
   193 
       
   194         if ( ! isEnabled() )
       
   195         {
       
   196             setEnabled( true );
       
   197         }
       
   198 
       
   199         setVisible( true );
       
   200 
       
   201         HbEffect::start( this, "appear", this, "appeared" );
       
   202     }
       
   203     else if ( ! visible && isVisible()&& ! HbEffect::effectRunning( this, "disappear" ) )
       
   204     {
       
   205         //
       
   206         // If appear effect is running on this, cancel
       
   207         //
       
   208         if( HbEffect::effectRunning( this, "appear" ) )
       
   209         {
       
   210             HbEffect::cancel( this );
       
   211         }
       
   212 
       
   213         if ( isEnabled() )
       
   214 		{
       
   215             setEnabled( false );
       
   216 		}
       
   217 
       
   218         HbEffect::start( this, "disappear", this, "disappeared" );
       
   219     }
   157     }
   220 }
   158 }
   221 
   159 
   222 // -------------------------------------------------------------------------------------------------
   160 // -------------------------------------------------------------------------------------------------
   223 // QMPXVideoPlaybackControlBar::appeared()
   161 // QMPXVideoPlaybackControlBar::appeared()
   268     if ( mProgressBar )
   206     if ( mProgressBar )
   269     {
   207     {
   270         mProgressBar->durationChanged( duration );
   208         mProgressBar->durationChanged( duration );
   271     }
   209     }
   272 
   210 
   273     if ( mButtonBar )
   211     if ( mToolBar )
   274     {
   212     {
   275         mButtonBar->durationChanged( duration );
   213         mToolBar->durationChanged( duration );
   276     }
   214     }
   277 }
   215 }
   278 
   216 
   279 // -------------------------------------------------------------------------------------------------
   217 // -------------------------------------------------------------------------------------------------
   280 // QMPXVideoPlaybackControlBar::positionChanged()
   218 // QMPXVideoPlaybackControlBar::positionChanged()
   287     if ( mProgressBar )
   225     if ( mProgressBar )
   288     {
   226     {
   289         mProgressBar->positionChanged( position );
   227         mProgressBar->positionChanged( position );
   290     }
   228     }
   291     
   229     
   292     if ( mButtonBar )
   230     if ( mToolBar )
   293     {
   231     {
   294         mButtonBar->positionChanged( position );
   232         mToolBar->positionChanged( position );
   295     }
   233     }
   296 }
   234 }
   297 
   235 
   298 //End of file
   236 //End of file