videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackcontrolbar.cpp
changeset 35 3738fe97f027
child 17 69946d1824c4
equal deleted inserted replaced
34:bbb98528c666 35:3738fe97f027
       
     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 QMPXVideoPlaybackControlBar
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version:  1 %
       
    19 
       
    20 
       
    21 
       
    22 #include <hbframeitem.h>
       
    23 #include <hbframedrawer.h>
       
    24 
       
    25 #include "mpxvideo_debug.h"
       
    26 #include "mpxvideoplaybackbuttonbar.h"
       
    27 #include "mpxvideoplaybackcontrolbar.h"
       
    28 #include "mpxvideoplaybackprogressbar.h"
       
    29 #include "mpxcommonvideoplaybackview.hrh"
       
    30 #include "mpxvideoplaybackdocumentloader.h"
       
    31 #include "mpxvideoplaybackcontrolscontroller.h"
       
    32 
       
    33 
       
    34 // -------------------------------------------------------------------------------------------------
       
    35 // QMPXVideoPlaybackControlBar::QMPXVideoPlaybackControlBar()
       
    36 // -------------------------------------------------------------------------------------------------
       
    37 //
       
    38 QMPXVideoPlaybackControlBar::QMPXVideoPlaybackControlBar( 
       
    39         QMPXVideoPlaybackControlsController* controller )
       
    40     : mController( controller )
       
    41     , mButtonBar( NULL )
       
    42     , mProgressBar( NULL )
       
    43     , mFrameItem( NULL )
       
    44 {
       
    45     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlBar::QMPXVideoPlaybackControlBar"));
       
    46 
       
    47     HbEffect::add( this, ":/hbvideoplaybackview/effects/controlbar_appear.fxml", "appear" );
       
    48     HbEffect::add( this, ":/hbvideoplaybackview/effects/controlbar_disappear.fxml", "disappear" );
       
    49 }
       
    50 
       
    51 // -------------------------------------------------------------------------------------------------
       
    52 // QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()
       
    53 // -------------------------------------------------------------------------------------------------
       
    54 //
       
    55 QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()
       
    56 {
       
    57     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::~QMPXVideoPlaybackControlBar()"));
       
    58 
       
    59     HbEffect::remove( this, ":/hbvideoplaybackview/effects/controlbar_appear.fxml", "appear" );
       
    60     HbEffect::remove( this, ":/hbvideoplaybackview/effects/controlbar_disappear.fxml", "disappear" );
       
    61 }
       
    62 
       
    63 // -------------------------------------------------------------------------------------------------
       
    64 // QMPXVideoPlaybackControlBar::initialize()
       
    65 // -------------------------------------------------------------------------------------------------
       
    66 //
       
    67 void QMPXVideoPlaybackControlBar::initialize()
       
    68 {
       
    69     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackControlBar::initialize()"));
       
    70 
       
    71     QMPXVideoPlaybackDocumentLoader *loader = mController->layoutLoader();
       
    72 
       
    73     //
       
    74     // Don't need to initialize buttons once it gets initialized
       
    75     //
       
    76     if ( mButtonBar == NULL && mProgressBar == NULL )
       
    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         //
       
    90         // progress bar
       
    91         //
       
    92         widget = loader->findWidget( QString( "progressBarLayout" ) );
       
    93         mProgressBar = qobject_cast<QMPXVideoPlaybackProgressBar*>( widget );
       
    94 
       
    95         if ( mProgressBar )
       
    96         {
       
    97             mProgressBar->initialize();
       
    98         }
       
    99 
       
   100         //
       
   101         // Set framedrawer for semi transparent background
       
   102         //
       
   103         mFrameItem = new HbFrameItem ( this );
       
   104         mFrameItem->setGeometry( boundingRect() );
       
   105         mFrameItem->frameDrawer().setFrameType( HbFrameDrawer::OnePiece );
       
   106         mFrameItem->frameDrawer().setFillWholeRect( true );
       
   107         mFrameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_status_trans_normal_c" );
       
   108         mFrameItem->setVisible( false );
       
   109     }
       
   110 }
       
   111 
       
   112 // -------------------------------------------------------------------------------------------------
       
   113 // QMPXVideoPlaybackControlBar::updateState()
       
   114 // -------------------------------------------------------------------------------------------------
       
   115 //
       
   116 void QMPXVideoPlaybackControlBar::updateState( TMPXPlaybackState state )
       
   117 {
       
   118     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::updateState() state = %d"), state );
       
   119 
       
   120     if ( mButtonBar )
       
   121     {
       
   122         mButtonBar->updateState( state );
       
   123     }
       
   124 
       
   125     if ( mProgressBar )
       
   126     {
       
   127         mProgressBar->updateState( state );
       
   128     }
       
   129 }
       
   130 
       
   131 // -------------------------------------------------------------------------------------------------
       
   132 // QMPXVideoPlaybackControlBar::aspectRatioChanged()
       
   133 // -------------------------------------------------------------------------------------------------
       
   134 //
       
   135 void QMPXVideoPlaybackControlBar::aspectRatioChanged( int aspectRatio )
       
   136 {
       
   137     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio );
       
   138 
       
   139     if ( mButtonBar )
       
   140     {
       
   141         mButtonBar->aspectRatioChanged( aspectRatio );
       
   142     }
       
   143 }
       
   144 
       
   145 // -------------------------------------------------------------------------------------------------
       
   146 // QMPXVideoPlaybackControlBar::updateWithFileDetails()
       
   147 // -------------------------------------------------------------------------------------------------
       
   148 //
       
   149 void QMPXVideoPlaybackControlBar::updateWithFileDetails(
       
   150         QMPXVideoPlaybackViewFileDetails* details )
       
   151 {
       
   152     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::updateWithFileDetails()"));
       
   153 
       
   154     if ( mButtonBar )
       
   155     {
       
   156         mButtonBar->updateWithFileDetails( details );
       
   157     }
       
   158 
       
   159     if ( mProgressBar )
       
   160     {
       
   161         mProgressBar->updateWithFileDetails( details );
       
   162     }
       
   163 
       
   164     mFrameItem->setVisible( ( mController->viewMode() == EFullScreenView )? ETrue:EFalse ); 
       
   165 }
       
   166 
       
   167 // -------------------------------------------------------------------------------------------------
       
   168 // QMPXVideoPlaybackControlBar::setVisibleToControlBar()
       
   169 // -------------------------------------------------------------------------------------------------
       
   170 //
       
   171 void QMPXVideoPlaybackControlBar::setVisibleToControlBar( bool visible )
       
   172 {
       
   173     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::setVisibleToControlBar() %d"), visible);
       
   174 
       
   175     if ( visible && isVisible() == false )
       
   176     {
       
   177         setVisible( true );
       
   178         HbEffect::start( this, "appear", this, "appeared" );
       
   179     }
       
   180     else if ( ! visible && isVisible() == true )
       
   181     {
       
   182         HbEffect::start( this, "disappear", this, "disappeared" );
       
   183     }
       
   184 }
       
   185 
       
   186 // -------------------------------------------------------------------------------------------------
       
   187 // QMPXVideoPlaybackControlBar::appeared()
       
   188 // -------------------------------------------------------------------------------------------------
       
   189 //
       
   190 void QMPXVideoPlaybackControlBar::appeared( const HbEffect::EffectStatus &status )
       
   191 {
       
   192     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::appeared()"));
       
   193 
       
   194     if ( status.reason == Hb::EffectFinished )
       
   195     {
       
   196         MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::appeared() successful"));
       
   197     }
       
   198     else
       
   199     {
       
   200         MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::appeared() NOT successful"));
       
   201     }
       
   202 }
       
   203 
       
   204 // -------------------------------------------------------------------------------------------------
       
   205 // QMPXVideoPlaybackControlBar::disappeared()
       
   206 // -------------------------------------------------------------------------------------------------
       
   207 //
       
   208 void QMPXVideoPlaybackControlBar::disappeared( const HbEffect::EffectStatus &status )
       
   209 {
       
   210     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::disappeared()"));
       
   211 
       
   212     setVisible( false );
       
   213 
       
   214     if ( status.reason == Hb::EffectFinished )
       
   215     {
       
   216         MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::disappeared() successful"));
       
   217     }
       
   218     else
       
   219     {
       
   220         MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::disappeared() NOT successful"));
       
   221     }
       
   222 }
       
   223 
       
   224 // -------------------------------------------------------------------------------------------------
       
   225 // QMPXVideoPlaybackControlBar::durationChanged()
       
   226 // -------------------------------------------------------------------------------------------------
       
   227 //
       
   228 void QMPXVideoPlaybackControlBar::durationChanged( int duration )
       
   229 {
       
   230     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::durationChanged()"));
       
   231 
       
   232     if ( mProgressBar )
       
   233     {
       
   234         mProgressBar->durationChanged( duration );
       
   235     }
       
   236 }
       
   237 
       
   238 // -------------------------------------------------------------------------------------------------
       
   239 // QMPXVideoPlaybackControlBar::positionChanged()
       
   240 // -------------------------------------------------------------------------------------------------
       
   241 //
       
   242 void QMPXVideoPlaybackControlBar::positionChanged( int position )
       
   243 {
       
   244     MPX_DEBUG(_L("QMPXVideoPlaybackControlBar::positionChanged()"));
       
   245 
       
   246     if ( mProgressBar )
       
   247     {
       
   248         mProgressBar->positionChanged( position );
       
   249     }
       
   250 }
       
   251 
       
   252 //End of file