videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackdetailsplaybackwindow.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 QMPXVideoPlaybackDetailsPlaybackWindow
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version:  18 %
       
    19 
       
    20 
       
    21 
       
    22 #include <QGraphicsSceneMouseEvent>
       
    23 
       
    24 #include <hbframeitem.h>
       
    25 #include <hbpushbutton.h>
       
    26 #include <hbframedrawer.h>
       
    27 
       
    28 #include "mpxvideo_debug.h"
       
    29 #include "mpxvideoplaybackdocumentloader.h"
       
    30 #include "mpxvideoplaybackcontrolscontroller.h"
       
    31 #include "mpxvideoplaybackdetailsplaybackwindow.h"
       
    32 
       
    33 // -------------------------------------------------------------------------------------------------
       
    34 // QMPXVideoPlaybackDetailsPlaybackWindow::QMPXVideoPlaybackDetailsPlaybackWindow
       
    35 // -------------------------------------------------------------------------------------------------
       
    36 //
       
    37 QMPXVideoPlaybackDetailsPlaybackWindow::QMPXVideoPlaybackDetailsPlaybackWindow(
       
    38         QMPXVideoPlaybackControlsController* controller )
       
    39     : mController( controller )
       
    40     , mInitialized( false )
       
    41 {
       
    42     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDetailsPlaybackWindow::QMPXVideoPlaybackDetailsPlaybackWindow()"));
       
    43 }
       
    44 
       
    45 // -------------------------------------------------------------------------------------------------
       
    46 // QMPXVideoPlaybackDetailsPlaybackWindow::~QMPXVideoPlaybackDetailsPlaybackWindow
       
    47 // -------------------------------------------------------------------------------------------------
       
    48 //
       
    49 QMPXVideoPlaybackDetailsPlaybackWindow::~QMPXVideoPlaybackDetailsPlaybackWindow()
       
    50 {
       
    51     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDetailsPlaybackWindow::~QMPXVideoPlaybackDetailsPlaybackWindow()"));
       
    52 }
       
    53 
       
    54 // -------------------------------------------------------------------------------------------------
       
    55 // QMPXVideoPlaybackDetailsPlaybackWindow::initialize
       
    56 // -------------------------------------------------------------------------------------------------
       
    57 //
       
    58 void QMPXVideoPlaybackDetailsPlaybackWindow::initialize()
       
    59 {
       
    60     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDetailsPlaybackWindow::initialize()"));
       
    61 
       
    62     QMPXVideoPlaybackDocumentLoader *loader = mController->layoutLoader();
       
    63 
       
    64     //
       
    65     // Don't need to initialize buttons once it gets initialized
       
    66     //
       
    67     if ( loader && ! mInitialized )
       
    68     {
       
    69         mInitialized = true;
       
    70 
       
    71         QMPXVideoPlaybackViewFileDetails *details = mController->fileDetails();
       
    72 
       
    73         //
       
    74         // Connect signal and slot for play button
       
    75         //
       
    76         QGraphicsWidget *widget = loader->findWidget( QString( "detailsViewPlayButton" ) );
       
    77         mPlayButton = qobject_cast<HbPushButton*>( widget );
       
    78         mPlayButton->setFlag( QGraphicsItem::ItemIsFocusable, false );
       
    79 
       
    80         connect( mPlayButton, SIGNAL( released() ), this, SLOT( playPause() ) );
       
    81 
       
    82         //
       
    83         // Set framedrawer for semi transparent background
       
    84         //
       
    85         HbFrameDrawer *drawer = mPlayButton->frameBackground();
       
    86 
       
    87         if( drawer == NULL )
       
    88         {
       
    89             drawer = new HbFrameDrawer();
       
    90         }
       
    91 
       
    92         drawer->setFillWholeRect( true );
       
    93         drawer->setFrameType( HbFrameDrawer::NinePieces );
       
    94         drawer->setFrameGraphicsName( "qtg_fr_multimedia_trans" );
       
    95         mPlayButton->setFrameBackground( drawer );
       
    96 
       
    97         //
       
    98         // create 'attach' button and connect corresponding signal/slot
       
    99         //
       
   100         QGraphicsWidget *detailsAttachWidget = loader->findWidget( QString( "detailsAttachButton" ) );
       
   101         HbPushButton *attachButton = qobject_cast<HbPushButton*>( detailsAttachWidget );
       
   102         connect( attachButton, SIGNAL( released() ), mController, SLOT( attachVideo() ) );
       
   103 
       
   104         //
       
   105         // create 'share' button and connect corresponding signal/slot
       
   106         //
       
   107         QGraphicsWidget *detailsShareWidget = loader->findWidget( QString( "detailsShareButton" ) );
       
   108         HbPushButton *shareButton = qobject_cast<HbPushButton*>( detailsShareWidget );
       
   109         connect( shareButton, SIGNAL( released() ), mController, SLOT( sendVideo() ) );
       
   110 
       
   111         //
       
   112         // by default in xml layout, attachButton is not visible while shareButton is visible.
       
   113         // if it's an 'attach' operation, reverse the visibility order
       
   114         //
       
   115         if ( mController->isAttachOperation() )
       
   116         {
       
   117             attachButton->setVisible( true );
       
   118             shareButton->setVisible( false );
       
   119         }
       
   120         else
       
   121         {
       
   122             //
       
   123             // dim "share" button for streaming
       
   124             //
       
   125             if ( details->mPlaybackMode == EMPXVideoStreaming ||
       
   126                  details->mPlaybackMode == EMPXVideoLiveStreaming )
       
   127             {
       
   128                 shareButton->setEnabled( false );
       
   129             }
       
   130         }
       
   131     }
       
   132 
       
   133     updateState( mController->state() );
       
   134 }
       
   135 
       
   136 // -------------------------------------------------------------------------------------------------
       
   137 // QMPXVideoPlaybackDetailsPlaybackWindow::updateState()
       
   138 // -------------------------------------------------------------------------------------------------
       
   139 //
       
   140 void QMPXVideoPlaybackDetailsPlaybackWindow::updateState( TMPXPlaybackState state )
       
   141 {
       
   142     MPX_DEBUG(_L("QMPXVideoPlaybackDetailsPlaybackWindow::updateState() state = %d"), state );
       
   143 
       
   144     switch ( state )
       
   145     {
       
   146         case EPbStatePaused:
       
   147         {
       
   148             mPlayButton->setVisible( true );
       
   149             break;
       
   150         }
       
   151         default:
       
   152         {
       
   153             mPlayButton->setVisible( false );
       
   154             break;
       
   155         }
       
   156     }
       
   157 }
       
   158 
       
   159 // -------------------------------------------------------------------------------------------------
       
   160 // QMPXVideoPlaybackDetailsPlaybackWindow::playPause()
       
   161 // -------------------------------------------------------------------------------------------------
       
   162 //
       
   163 void QMPXVideoPlaybackDetailsPlaybackWindow::playPause()
       
   164 {
       
   165     MPX_DEBUG(_L("QMPXVideoPlaybackDetailsPlaybackWindow::playPause"));
       
   166 
       
   167     mController->handleCommand( EMPXPbvCmdPlayPause );
       
   168 }
       
   169 
       
   170 //End of file