videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackstatuspanecontrol.cpp
changeset 44 518105d52e45
parent 42 17f382c040b1
child 49 824471cb468a
equal deleted inserted replaced
42:17f382c040b1 44:518105d52e45
     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 QMPXVideoPlaybackStatusPaneControl
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 19 %
       
    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 "hbvideobaseplaybackview.h"
       
    36 #include "mpxvideoplaybackdocumentloader.h"
       
    37 #include "mpxvideoplaybackstatuspanecontrol.h"
       
    38 #include "mpxvideoplaybackcontrolscontroller.h"
       
    39 
       
    40 
       
    41 // -------------------------------------------------------------------------------------------------
       
    42 // QMPXVideoPlaybackStatusPaneControl::QMPXVideoPlaybackStatusPaneControl()
       
    43 // -------------------------------------------------------------------------------------------------
       
    44 //
       
    45 QMPXVideoPlaybackStatusPaneControl::QMPXVideoPlaybackStatusPaneControl(
       
    46         QMPXVideoPlaybackControlsController* controller,
       
    47         TMPXVideoPlaybackControls index,
       
    48         HbWidget* widget,
       
    49         TUint controlproperties )
       
    50     : QMPXVideoPlaybackFullScreenControl( controller, index, widget, controlproperties )
       
    51     , mActionBack( NULL )
       
    52     , mTitleLabel( NULL )
       
    53     , mTitleGroupBox( NULL )
       
    54     , mTitleLayout( NULL )
       
    55 {
       
    56     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackStatusPaneControl::QMPXVideoPlaybackStatusPaneControl()"));
       
    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 // QMPXVideoPlaybackStatusPaneControl::~QMPXVideoPlaybackStatusPaneControl()
       
    74 // -------------------------------------------------------------------------------------------------
       
    75 //
       
    76 QMPXVideoPlaybackStatusPaneControl::~QMPXVideoPlaybackStatusPaneControl()
       
    77 {
       
    78     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackStatusPaneControl::~QMPXVideoPlaybackStatusPaneControl"));
       
    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 // QMPXVideoPlaybackStatusPaneControl::setVisible()
       
    98 // -------------------------------------------------------------------------------------------------
       
    99 //
       
   100 void QMPXVideoPlaybackStatusPaneControl::setVisible( bool visible )
       
   101 {
       
   102     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::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             mTitleLayout->setVisible( true );
       
   115         }
       
   116     }
       
   117     else
       
   118     {
       
   119         mController->view()->menu()->close();
       
   120         mController->view()->setTitleBarVisible( false );
       
   121         mController->view()->setStatusBarVisible( false );
       
   122 
       
   123         mTitleLayout->setVisible( false );
       
   124     }
       
   125 }
       
   126 
       
   127 // -------------------------------------------------------------------------------------------------
       
   128 // QMPXVideoPlaybackStatusPaneControl::isVisible()
       
   129 // -------------------------------------------------------------------------------------------------
       
   130 //
       
   131 bool QMPXVideoPlaybackStatusPaneControl::isVisible()
       
   132 {
       
   133     return mVisible;
       
   134 }
       
   135 
       
   136 // -------------------------------------------------------------------------------------------------
       
   137 // QMPXVideoPlaybackStatusPaneControl::setVisibility()
       
   138 // -------------------------------------------------------------------------------------------------
       
   139 //
       
   140 void QMPXVideoPlaybackStatusPaneControl::setVisibility( TMPXPlaybackState state )
       
   141 {
       
   142     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::setVisibility()"));
       
   143 
       
   144     switch( state )
       
   145     {
       
   146         case EPbStatePlaying:
       
   147         case EPbStatePaused:
       
   148         {
       
   149             setMenu( mController->fileDetails() );
       
   150             break;
       
   151         }
       
   152         case EPbStatePluginSeeking:
       
   153         case EPbStateBuffering:
       
   154         case EPbStateNotInitialised:
       
   155         case EPbStateInitialising:
       
   156         {
       
   157             mController->view()->menu()->clearActions();
       
   158             break;
       
   159         }
       
   160     }
       
   161 
       
   162     QMPXVideoPlaybackFullScreenControl::setVisibility( state );
       
   163 }
       
   164 
       
   165 // -------------------------------------------------------------------------------------------------
       
   166 // QMPXVideoPlaybackStatusPaneControl::updateControlsWithFileDetails()
       
   167 // -------------------------------------------------------------------------------------------------
       
   168 //
       
   169 void QMPXVideoPlaybackStatusPaneControl::updateControlsWithFileDetails(
       
   170         QMPXVideoPlaybackViewFileDetails* details )
       
   171 {
       
   172     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::updateControlsWithFileDetails()"));
       
   173 
       
   174     if ( ! mTitleLabel )
       
   175     {
       
   176         //
       
   177         // If title is not available, show clip name
       
   178         //
       
   179         QString title = mController->fileDetails()->mTitle;
       
   180 
       
   181         if ( title.count() == 0 )
       
   182         {
       
   183             QFileInfo fileInfo( mController->fileDetails()->mClipName );
       
   184             title = fileInfo.completeBaseName();
       
   185         }
       
   186 
       
   187         QGraphicsWidget *qWidget = mController->layoutLoader()->findWidget( QString( "title" ) );
       
   188         mTitleLabel = qobject_cast<HbLabel*>( qWidget );
       
   189         mTitleLabel->setPlainText( title );
       
   190 
       
   191         qWidget = mController->layoutLoader()->findWidget( QString( "titleGroupBox" ) );
       
   192         mTitleGroupBox = qobject_cast<HbGroupBox*>( qWidget );
       
   193         mTitleGroupBox->setHeading( title );
       
   194 
       
   195         mTitleLayout = mController->layoutLoader()->findWidget( QString( "titleLayout" ) );
       
   196 
       
   197         //
       
   198         // Set framedrawer for semi transparent background
       
   199         //
       
   200         HbFrameItem *frameItem = new HbFrameItem();
       
   201         frameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_multimedia_trans" );
       
   202         frameItem->frameDrawer().setFrameType( HbFrameDrawer::NinePieces );
       
   203         frameItem->frameDrawer().setFillWholeRect( true );
       
   204         mTitleLabel->setBackgroundItem( frameItem );
       
   205     }
       
   206 
       
   207     switch( mController->viewMode() )
       
   208     {
       
   209         case EFullScreenView:
       
   210         {
       
   211             //
       
   212             // Set TitleBar transparent and go back to preview view with back key
       
   213             //
       
   214             disconnect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   215             connect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   216 
       
   217             mController->view()->setViewFlags( mController->view()->viewFlags() |
       
   218                                                HbView::ViewTitleBarTransparent |
       
   219                                                HbView::ViewStatusBarTransparent );
       
   220 
       
   221             mTitleLabel->setVisible( true );
       
   222             mTitleGroupBox->setVisible( false );
       
   223 
       
   224             break;
       
   225         }
       
   226         case EDetailsView:
       
   227         {
       
   228             //
       
   229             // Set TitleBar opaque and go back to full screen view with back key
       
   230             //
       
   231             disconnect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   232             connect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   233 
       
   234             mController->view()->setViewFlags( HbView::ViewFlagNone );
       
   235 
       
   236             mTitleGroupBox->setVisible( true );
       
   237             mTitleLabel->setVisible( false );
       
   238 
       
   239             break;
       
   240         }
       
   241         case EAudioOnlyView:
       
   242         {
       
   243             //
       
   244             // Set TitleBar opaque and go back to preview view with back key
       
   245             //
       
   246             disconnect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   247             connect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   248 
       
   249             mController->view()->setViewFlags( HbView::ViewFlagNone );
       
   250             break;
       
   251         }
       
   252     }
       
   253 
       
   254     setMenu( details );
       
   255 }
       
   256 
       
   257 // -------------------------------------------------------------------------------------------------
       
   258 // QMPXVideoPlaybackStatusPaneControl::setMenu()
       
   259 // -------------------------------------------------------------------------------------------------
       
   260 //
       
   261 void QMPXVideoPlaybackStatusPaneControl::setMenu( QMPXVideoPlaybackViewFileDetails* details )
       
   262 {
       
   263     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::setMenu()"));
       
   264 
       
   265     //
       
   266     // No available menu for now
       
   267     //
       
   268     Q_UNUSED( details );
       
   269 }
       
   270 
       
   271 // -------------------------------------------------------------------------------------------------
       
   272 // QMPXVideoPlaybackStatusPaneControl::handleAboutToShow()
       
   273 // -------------------------------------------------------------------------------------------------
       
   274 //
       
   275 void QMPXVideoPlaybackStatusPaneControl::handleAboutToShow()
       
   276 {
       
   277     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::handleAboutToShow()"));
       
   278 
       
   279     mController->resetDisappearingTimers( EMPXTimerCancel );
       
   280 }
       
   281 
       
   282 // -------------------------------------------------------------------------------------------------
       
   283 // QMPXVideoPlaybackStatusPaneControl::handleAboutToHide()
       
   284 // -------------------------------------------------------------------------------------------------
       
   285 //
       
   286 void QMPXVideoPlaybackStatusPaneControl::handleAboutToHide()
       
   287 {
       
   288     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::handleAboutToHide()"));
       
   289 
       
   290     mController->resetDisappearingTimers( EMPXTimerReset );
       
   291 }
       
   292 
       
   293 // -------------------------------------------------------------------------------------------------
       
   294 // QMPXVideoPlaybackStatusPaneControl::controlListUpdated()
       
   295 // -------------------------------------------------------------------------------------------------
       
   296 //
       
   297 void QMPXVideoPlaybackStatusPaneControl::controlListUpdated(
       
   298         QMPXVideoPlaybackViewFileDetails* details )
       
   299 {
       
   300     setMenu( details );
       
   301 }
       
   302 
       
   303 // -------------------------------------------------------------------------------------------------
       
   304 // QMPXVideoPlaybackStatusPaneControl::openFullScreenView()
       
   305 // -------------------------------------------------------------------------------------------------
       
   306 //
       
   307 void QMPXVideoPlaybackStatusPaneControl::openFullScreenView()
       
   308 {
       
   309     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::openFullScreenView()"));
       
   310 
       
   311     mController->changeViewMode( EFullScreenView );
       
   312 }
       
   313 
       
   314 // End of file