videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackstatuspanecontrol.cpp
changeset 15 cf5481c2bc0b
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     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: ou1cpsw#13 %
       
    19 
       
    20 
       
    21 #include <hbmenu.h>
       
    22 #include <hblabel.h>
       
    23 #include <hbaction.h>
       
    24 #include <hbinstance.h>
       
    25 #include <hbframeitem.h>
       
    26 #include <hbframedrawer.h>
       
    27 
       
    28 #include <w32std.h>
       
    29 
       
    30 #include "mpxvideo_debug.h"
       
    31 #include "hbvideobaseplaybackview.h"
       
    32 #include "mpxvideoplaybackdocumentloader.h"
       
    33 #include "mpxvideoplaybackstatuspanecontrol.h"
       
    34 #include "mpxvideoplaybackcontrolscontroller.h"
       
    35 
       
    36 
       
    37 // -------------------------------------------------------------------------------------------------
       
    38 // QMPXVideoPlaybackStatusPaneControl::QMPXVideoPlaybackStatusPaneControl()
       
    39 // -------------------------------------------------------------------------------------------------
       
    40 //
       
    41 QMPXVideoPlaybackStatusPaneControl::QMPXVideoPlaybackStatusPaneControl( 
       
    42         QMPXVideoPlaybackControlsController* controller, 
       
    43         TMPXVideoPlaybackControls index, 
       
    44         HbWidget* widget, 
       
    45         TUint controlproperties )
       
    46     : QMPXVideoPlaybackFullScreenControl( controller, index, widget, controlproperties )
       
    47     , mActionBack( NULL )
       
    48     , mFrameItem( NULL )
       
    49 {
       
    50     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackStatusPaneControl::QMPXVideoPlaybackStatusPaneControl()"));
       
    51 
       
    52     mActionBack = new HbAction( Hb::BackNaviAction );
       
    53 
       
    54     //
       
    55     // Press "back" key means going back to previous view if it's avaiable
       
    56     //
       
    57     connect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
    58     
       
    59     HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
       
    60     HbView *currentView = mainWnd->currentView();
       
    61     currentView->setNavigationAction(mActionBack);
       
    62 
       
    63     connect( mController->view()->menu(), SIGNAL( aboutToShow() ), this, SLOT( handleAboutToShow() ) );
       
    64     connect( mController->view()->menu(), SIGNAL( aboutToHide() ), this, SLOT( handleAboutToHide() ) );
       
    65 
       
    66     QGraphicsWidget *widget1 = mController->layoutLoader()->findWidget( QString( "title" ) );
       
    67     mTitleLabel = qobject_cast<HbLabel*>( widget1 );
       
    68 }
       
    69 
       
    70 // -------------------------------------------------------------------------------------------------
       
    71 // QMPXVideoPlaybackStatusPaneControl::~QMPXVideoPlaybackStatusPaneControl()
       
    72 // -------------------------------------------------------------------------------------------------
       
    73 //
       
    74 QMPXVideoPlaybackStatusPaneControl::~QMPXVideoPlaybackStatusPaneControl()
       
    75 {
       
    76     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::QMPXVideoPlaybackStatusPaneControl"));
       
    77 
       
    78     disconnect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
    79     disconnect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
    80 
       
    81     HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
       
    82     HbView *currentView = mainWnd->currentView();
       
    83     currentView->setNavigationAction(0);
       
    84 
       
    85     disconnect( mController->view()->menu(), SIGNAL( aboutToShow() ), this, SLOT( handleAboutToShow() ) );
       
    86     disconnect( mController->view()->menu(), SIGNAL( aboutToHide() ), this, SLOT( handleAboutToHide() ) );
       
    87 
       
    88     mController->view()->menu()->close();
       
    89 
       
    90     if ( mActionBack )
       
    91     {
       
    92         delete mActionBack;
       
    93         mActionBack = NULL;
       
    94     }
       
    95 }
       
    96 
       
    97 // -------------------------------------------------------------------------------------------------
       
    98 // QMPXVideoPlaybackStatusPaneControl::setVisible()
       
    99 // -------------------------------------------------------------------------------------------------
       
   100 //
       
   101 void QMPXVideoPlaybackStatusPaneControl::setVisible( bool visible )
       
   102 {
       
   103     mVisible = visible;
       
   104 
       
   105     if ( mVisible )
       
   106     {
       
   107         mController->view()->showItems(
       
   108                 Hb::IndicatorItems | Hb::TitlePaneItem | Hb::SecondarySoftKeyItem | Hb::TitleBarItem );
       
   109 
       
   110         if ( mController->viewMode() == EFullScreenView ||
       
   111              mController->viewMode() == EDetailsView )
       
   112         {
       
   113             mTitleLabel->setVisible( true );            
       
   114         }
       
   115     }
       
   116     else
       
   117     {
       
   118         mController->view()->menu()->close();
       
   119         mController->view()->hideItems( Hb::AllItems );
       
   120 
       
   121         mTitleLabel->setVisible( false );
       
   122     }
       
   123 }
       
   124 
       
   125 // -------------------------------------------------------------------------------------------------
       
   126 // QMPXVideoPlaybackStatusPaneControl::isVisible()
       
   127 // -------------------------------------------------------------------------------------------------
       
   128 //
       
   129 bool QMPXVideoPlaybackStatusPaneControl::isVisible()
       
   130 {
       
   131     return mVisible;
       
   132 }
       
   133 
       
   134 // -------------------------------------------------------------------------------------------------
       
   135 // QMPXVideoPlaybackStatusPaneControl::setVisibility()
       
   136 // -------------------------------------------------------------------------------------------------
       
   137 //
       
   138 void QMPXVideoPlaybackStatusPaneControl::setVisibility( TMPXPlaybackState state )
       
   139 {
       
   140     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::setVisibility()"));
       
   141 
       
   142     switch( state )
       
   143     {
       
   144         case EPbStatePlaying:
       
   145         case EPbStatePaused:
       
   146         {
       
   147             setMenu( mController->fileDetails() );
       
   148             break;
       
   149         }
       
   150         case EPbStatePluginSeeking:
       
   151         case EPbStateBuffering:
       
   152         case EPbStateNotInitialised:
       
   153         case EPbStateInitialising:
       
   154         {
       
   155             mController->view()->menu()->clearActions();
       
   156             break;
       
   157         }
       
   158     }
       
   159 
       
   160     QMPXVideoPlaybackFullScreenControl::setVisibility( state );
       
   161 }
       
   162 
       
   163 // -------------------------------------------------------------------------------------------------
       
   164 // QMPXVideoPlaybackStatusPaneControl::updateControlsWithFileDetails()
       
   165 // -------------------------------------------------------------------------------------------------
       
   166 //
       
   167 void QMPXVideoPlaybackStatusPaneControl::updateControlsWithFileDetails(
       
   168         QMPXVideoPlaybackViewFileDetails* details )
       
   169 {
       
   170     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::updateControlsWithFileDetails()"));
       
   171 
       
   172     switch( mController->viewMode() )
       
   173     {
       
   174         case EFullScreenView:
       
   175         {
       
   176             //
       
   177             // Set TitleBar transparent and go back to preview view with back key
       
   178             // 
       
   179             disconnect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   180             connect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   181 
       
   182             mController->view()->setTitleBarFlags( HbView::TitleBarTransparent );
       
   183             break;
       
   184         }
       
   185         case EDetailsView:
       
   186         {
       
   187             //
       
   188             // Set TitleBar opaque and go back to full screen view with back key
       
   189             // 
       
   190             disconnect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   191             connect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   192 
       
   193             mController->view()->setTitleBarFlags( HbView::TitleBarFlagNone );
       
   194 
       
   195             break;
       
   196         }
       
   197         case EAudioOnlyView:
       
   198         {
       
   199             //
       
   200             // Set TitleBar opaque and go back to preview view with back key
       
   201             // 
       
   202             disconnect( mActionBack, SIGNAL( triggered() ), this, SLOT( openFullScreenView() ) );
       
   203             connect( mActionBack, SIGNAL( triggered() ), mController->view(), SLOT( closePlaybackView() ) );
       
   204 
       
   205             mController->view()->setTitleBarFlags( HbView::TitleBarFlagNone );
       
   206             break;
       
   207         }
       
   208     }
       
   209 
       
   210     setMenu( details );
       
   211 
       
   212     //
       
   213     // Set framedrawer for semi transparent background
       
   214     //
       
   215     if ( ! mFrameItem )
       
   216     {
       
   217         mFrameItem = new HbFrameItem ( mTitleLabel );
       
   218         mFrameItem->frameDrawer().setFrameType( HbFrameDrawer::OnePiece );
       
   219         mFrameItem->frameDrawer().setFillWholeRect( true );
       
   220         mFrameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_status_trans_normal_c" );    
       
   221     }
       
   222 
       
   223     mFrameItem->setGeometry( mTitleLabel->boundingRect() );
       
   224     mFrameItem->setVisible( ( mController->viewMode() == EFullScreenView )? ETrue:EFalse ); 
       
   225 }
       
   226 
       
   227 // -------------------------------------------------------------------------------------------------
       
   228 // QMPXVideoPlaybackStatusPaneControl::setMenu()
       
   229 // -------------------------------------------------------------------------------------------------
       
   230 //
       
   231 void QMPXVideoPlaybackStatusPaneControl::setMenu( QMPXVideoPlaybackViewFileDetails* details )
       
   232 {
       
   233     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::setMenu()"));
       
   234 
       
   235     //
       
   236     // No available menu for now
       
   237     //
       
   238     Q_UNUSED( details );
       
   239 }
       
   240 
       
   241 // -------------------------------------------------------------------------------------------------
       
   242 // QMPXVideoPlaybackStatusPaneControl::handleAboutToShow()
       
   243 // -------------------------------------------------------------------------------------------------
       
   244 //
       
   245 void QMPXVideoPlaybackStatusPaneControl::handleAboutToShow()
       
   246 {
       
   247     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::handleAboutToShow()"));
       
   248 
       
   249     mController->resetDisappearingTimers( EMPXTimerCancel );
       
   250 }
       
   251 
       
   252 // -------------------------------------------------------------------------------------------------
       
   253 // QMPXVideoPlaybackStatusPaneControl::handleAboutToHide()
       
   254 // -------------------------------------------------------------------------------------------------
       
   255 //
       
   256 void QMPXVideoPlaybackStatusPaneControl::handleAboutToHide()
       
   257 {
       
   258     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::handleAboutToHide()"));
       
   259 
       
   260     mController->resetDisappearingTimers( EMPXTimerReset );
       
   261 }
       
   262 
       
   263 // -------------------------------------------------------------------------------------------------
       
   264 // QMPXVideoPlaybackStatusPaneControl::controlListUpdated()
       
   265 // -------------------------------------------------------------------------------------------------
       
   266 //
       
   267 void QMPXVideoPlaybackStatusPaneControl::controlListUpdated(
       
   268         QMPXVideoPlaybackViewFileDetails* details )
       
   269 {
       
   270     setMenu( details );
       
   271 }
       
   272 
       
   273 // -------------------------------------------------------------------------------------------------
       
   274 // QMPXVideoPlaybackStatusPaneControl::openFullScreenView()
       
   275 // -------------------------------------------------------------------------------------------------
       
   276 //
       
   277 void QMPXVideoPlaybackStatusPaneControl::openFullScreenView()
       
   278 {
       
   279     MPX_DEBUG(_L("QMPXVideoPlaybackStatusPaneControl::openFullScreenView()"));
       
   280 
       
   281     mController->changeViewMode( EFullScreenView );
       
   282 }
       
   283 
       
   284 // End of file