videoplayback/videoplaybackview/controlsrc/videoplaybackstatuspanecontrol.cpp
changeset 52 e3cecb93e76a
child 65 a9d57bd8d7b7
equal deleted inserted replaced
47:45e72b57a2fd 52:e3cecb93e76a
       
     1 /*
       
     2 * Copyright (c) 2009 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 VideoPlaybackStatusPaneControl
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 22 %
       
    19 
       
    20 
       
    21 
       
    22 #include <QFileInfo>
       
    23 
       
    24 #include <hbmenu.h>
       
    25 #include <hblabel.h>
       
    26 #include <hbaction.h>
       
    27 #include <hbgroupbox.h>
       
    28 #include <hbinstance.h>
       
    29 #include <hbframeitem.h>
       
    30 #include <hbframedrawer.h>
       
    31 
       
    32 #include <w32std.h>
       
    33 
       
    34 #include "mpxvideo_debug.h"
       
    35 #include "videobaseplaybackview.h"
       
    36 #include "videoplaybackdocumentloader.h"
       
    37 #include "videoplaybackstatuspanecontrol.h"
       
    38 #include "videoplaybackcontrolscontroller.h"
       
    39 
       
    40 
       
    41 // -------------------------------------------------------------------------------------------------
       
    42 // VideoPlaybackStatusPaneControl::VideoPlaybackStatusPaneControl()
       
    43 // -------------------------------------------------------------------------------------------------
       
    44 //
       
    45 VideoPlaybackStatusPaneControl::VideoPlaybackStatusPaneControl(
       
    46         VideoPlaybackControlsController* controller,
       
    47         TVideoPlaybackControls index,
       
    48         HbWidget* widget,
       
    49         TUint controlproperties )
       
    50     : VideoPlaybackFullScreenControl( controller, index, widget, controlproperties )
       
    51     , mActionBack( NULL )
       
    52     , mTitleLabel( NULL )
       
    53     , mTitleGroupBox( NULL )
       
    54     , mTitleLayout( NULL )
       
    55 {
       
    56     MPX_ENTER_EXIT(_L("VideoPlaybackStatusPaneControl::VideoPlaybackStatusPaneControl()"));
       
    57 
       
    58     Q_UNUSED( widget );
       
    59 
       
    60     mActionBack = new HbAction( Hb::BackNaviAction );
       
    61 
       
    62     //
       
    63     // Press "back" key means going back to previous view if it's avaiable
       
    64     //
       
    65     connect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
    66     mController->view()->setNavigationAction( mActionBack );
       
    67 
       
    68     connect( mController->view()->menu(), SIGNAL( aboutToShow() ), this, SLOT( handleAboutToShow() ) );
       
    69     connect( mController->view()->menu(), SIGNAL( aboutToHide() ), this, SLOT( handleAboutToHide() ) );
       
    70 }
       
    71 
       
    72 // -------------------------------------------------------------------------------------------------
       
    73 // VideoPlaybackStatusPaneControl::~VideoPlaybackStatusPaneControl()
       
    74 // -------------------------------------------------------------------------------------------------
       
    75 //
       
    76 VideoPlaybackStatusPaneControl::~VideoPlaybackStatusPaneControl()
       
    77 {
       
    78     MPX_ENTER_EXIT(_L("VideoPlaybackStatusPaneControl::~VideoPlaybackStatusPaneControl"));
       
    79 
       
    80     disconnect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
    81     disconnect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
    82     mController->view()->setNavigationAction( 0 );
       
    83 
       
    84     disconnect( mController->view()->menu(), SIGNAL( aboutToShow() ), this, SLOT( handleAboutToShow() ) );
       
    85     disconnect( mController->view()->menu(), SIGNAL( aboutToHide() ), this, SLOT( handleAboutToHide() ) );
       
    86 
       
    87     mController->view()->menu()->close();
       
    88 
       
    89     if ( mActionBack )
       
    90     {
       
    91         delete mActionBack;
       
    92         mActionBack = NULL;
       
    93     }
       
    94 }
       
    95 
       
    96 // -------------------------------------------------------------------------------------------------
       
    97 // VideoPlaybackStatusPaneControl::setVisible()
       
    98 // -------------------------------------------------------------------------------------------------
       
    99 //
       
   100 void VideoPlaybackStatusPaneControl::setVisible( bool visible )
       
   101 {
       
   102     MPX_DEBUG(_L("VideoPlaybackStatusPaneControl::setVisible visible = %d"), visible);
       
   103 
       
   104     mVisible = visible;
       
   105 
       
   106     if ( mVisible )
       
   107     {
       
   108         mController->view()->setTitleBarVisible( true );
       
   109         mController->view()->setStatusBarVisible( true );
       
   110 
       
   111         if ( mController->viewMode() == EFullScreenView ||
       
   112              mController->viewMode() == EDetailsView )
       
   113         {
       
   114             if ( mTitleLayout )
       
   115             {
       
   116                 mTitleLayout->setVisible( true );
       
   117             }
       
   118         }
       
   119     }
       
   120     else
       
   121     {
       
   122         mController->view()->menu()->close();
       
   123         mController->view()->setTitleBarVisible( false );
       
   124         mController->view()->setStatusBarVisible( false );
       
   125 
       
   126         if ( mTitleLayout )
       
   127         {
       
   128             mTitleLayout->setVisible( false );
       
   129         }
       
   130     }
       
   131 }
       
   132 
       
   133 // -------------------------------------------------------------------------------------------------
       
   134 // VideoPlaybackStatusPaneControl::isVisible()
       
   135 // -------------------------------------------------------------------------------------------------
       
   136 //
       
   137 bool VideoPlaybackStatusPaneControl::isVisible()
       
   138 {
       
   139     return mVisible;
       
   140 }
       
   141 
       
   142 // -------------------------------------------------------------------------------------------------
       
   143 // VideoPlaybackStatusPaneControl::setVisibility()
       
   144 // -------------------------------------------------------------------------------------------------
       
   145 //
       
   146 void VideoPlaybackStatusPaneControl::setVisibility( TMPXPlaybackState state )
       
   147 {
       
   148     MPX_DEBUG(_L("VideoPlaybackStatusPaneControl::setVisibility()"));
       
   149 
       
   150     switch( state )
       
   151     {
       
   152         case EPbStatePlaying:
       
   153         case EPbStatePaused:
       
   154         {
       
   155             setMenu( mController->fileDetails() );
       
   156             break;
       
   157         }
       
   158         case EPbStatePluginSeeking:
       
   159         case EPbStateBuffering:
       
   160         case EPbStateNotInitialised:
       
   161         case EPbStateInitialising:
       
   162         {
       
   163             mController->view()->menu()->clearActions();
       
   164             break;
       
   165         }
       
   166     }
       
   167 
       
   168     VideoPlaybackFullScreenControl::setVisibility( state );
       
   169 }
       
   170 
       
   171 // -------------------------------------------------------------------------------------------------
       
   172 // VideoPlaybackStatusPaneControl::updateControlsWithFileDetails()
       
   173 // -------------------------------------------------------------------------------------------------
       
   174 //
       
   175 void VideoPlaybackStatusPaneControl::updateControlsWithFileDetails(
       
   176         VideoPlaybackViewFileDetails* details )
       
   177 {
       
   178     MPX_DEBUG(_L("VideoPlaybackStatusPaneControl::updateControlsWithFileDetails()"));
       
   179 
       
   180     if ( mController->isFileDetailsAdded() && ! mTitleLabel )
       
   181     {
       
   182         //
       
   183         // If title is not available, show clip name
       
   184         //
       
   185         QString title = mController->fileDetails()->mTitle;
       
   186 
       
   187         if ( title.count() == 0 )
       
   188         {
       
   189             QFileInfo fileInfo( mController->fileDetails()->mClipName );
       
   190             title = fileInfo.completeBaseName();
       
   191         }
       
   192 
       
   193         QGraphicsWidget *qWidget = mController->layoutLoader()->findWidget( QString( "title" ) );
       
   194         mTitleLabel = qobject_cast<HbLabel*>( qWidget );
       
   195         mTitleLabel->setPlainText( title );
       
   196 
       
   197         qWidget = mController->layoutLoader()->findWidget( QString( "titleGroupBox" ) );
       
   198         mTitleGroupBox = qobject_cast<HbGroupBox*>( qWidget );
       
   199         mTitleGroupBox->setHeading( title );
       
   200 
       
   201         mTitleLayout = mController->layoutLoader()->findWidget( QString( "titleLayout" ) );
       
   202 
       
   203         //
       
   204         // Set framedrawer for semi transparent background
       
   205         //
       
   206         HbFrameItem *frameItem = new HbFrameItem();
       
   207         frameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_multimedia_trans" );
       
   208         frameItem->frameDrawer().setFrameType( HbFrameDrawer::NinePieces );
       
   209         frameItem->frameDrawer().setFillWholeRect( true );
       
   210         mTitleLabel->setBackgroundItem( frameItem );
       
   211     }
       
   212 
       
   213     switch( mController->viewMode() )
       
   214     {
       
   215         case EFullScreenView:
       
   216         {
       
   217             //
       
   218             // Set TitleBar transparent and go back to preview view with back key
       
   219             //
       
   220             disconnect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   221             connect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   222 
       
   223             mController->view()->setViewFlags( mController->view()->viewFlags() |
       
   224                                                HbView::ViewTitleBarTransparent |
       
   225                                                HbView::ViewStatusBarTransparent );
       
   226 
       
   227             if ( mTitleLayout )
       
   228             {
       
   229                 mTitleLabel->setVisible( true );
       
   230                 mTitleGroupBox->setVisible( false );
       
   231             }
       
   232 
       
   233             break;
       
   234         }
       
   235         case EDetailsView:
       
   236         {
       
   237             //
       
   238             // Set TitleBar opaque and go back to full screen view with back key
       
   239             //
       
   240             disconnect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   241             connect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   242 
       
   243             mController->view()->setViewFlags( HbView::ViewFlagNone );
       
   244 
       
   245             if ( mTitleLayout )
       
   246             {
       
   247                 mTitleLabel->setVisible( false );
       
   248                 mTitleGroupBox->setVisible( true );
       
   249             }
       
   250 
       
   251             break;
       
   252         }
       
   253         case EAudioOnlyView:
       
   254         {
       
   255             //
       
   256             // Set TitleBar opaque and go back to preview view with back key
       
   257             //
       
   258             disconnect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   259             connect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   260 
       
   261             mController->view()->setViewFlags( HbView::ViewFlagNone );
       
   262             break;
       
   263         }
       
   264     }
       
   265 
       
   266     setMenu( details );
       
   267 }
       
   268 
       
   269 // -------------------------------------------------------------------------------------------------
       
   270 // VideoPlaybackStatusPaneControl::setMenu()
       
   271 // -------------------------------------------------------------------------------------------------
       
   272 //
       
   273 void VideoPlaybackStatusPaneControl::setMenu( VideoPlaybackViewFileDetails* details )
       
   274 {
       
   275     MPX_DEBUG(_L("VideoPlaybackStatusPaneControl::setMenu()"));
       
   276 
       
   277     //
       
   278     // No available menu for now
       
   279     //
       
   280     Q_UNUSED( details );
       
   281 }
       
   282 
       
   283 // -------------------------------------------------------------------------------------------------
       
   284 // VideoPlaybackStatusPaneControl::handleAboutToShow()
       
   285 // -------------------------------------------------------------------------------------------------
       
   286 //
       
   287 void VideoPlaybackStatusPaneControl::handleAboutToShow()
       
   288 {
       
   289     MPX_DEBUG(_L("VideoPlaybackStatusPaneControl::handleAboutToShow()"));
       
   290 
       
   291     mController->resetDisappearingTimers( ETimerCancel );
       
   292 }
       
   293 
       
   294 // -------------------------------------------------------------------------------------------------
       
   295 // VideoPlaybackStatusPaneControl::handleAboutToHide()
       
   296 // -------------------------------------------------------------------------------------------------
       
   297 //
       
   298 void VideoPlaybackStatusPaneControl::handleAboutToHide()
       
   299 {
       
   300     MPX_DEBUG(_L("VideoPlaybackStatusPaneControl::handleAboutToHide()"));
       
   301 
       
   302     mController->resetDisappearingTimers( ETimerReset );
       
   303 }
       
   304 
       
   305 // -------------------------------------------------------------------------------------------------
       
   306 // VideoPlaybackStatusPaneControl::controlListUpdated()
       
   307 // -------------------------------------------------------------------------------------------------
       
   308 //
       
   309 void VideoPlaybackStatusPaneControl::controlListUpdated(
       
   310         VideoPlaybackViewFileDetails* details )
       
   311 {
       
   312     setMenu( details );
       
   313 }
       
   314 
       
   315 // -------------------------------------------------------------------------------------------------
       
   316 // VideoPlaybackStatusPaneControl::openFullScreenView()
       
   317 // -------------------------------------------------------------------------------------------------
       
   318 //
       
   319 void VideoPlaybackStatusPaneControl::openFullScreenView()
       
   320 {
       
   321     MPX_DEBUG(_L("VideoPlaybackStatusPaneControl::openFullScreenView()"));
       
   322 
       
   323     mController->changeViewMode( EFullScreenView );
       
   324 }
       
   325 
       
   326 // End of file