videoplayback/videoplaybackview/controlsrc/videoplaybackdetailsplaybackwindow.cpp
changeset 44 518105d52e45
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 VideoPlaybackDetailsPlaybackWindow
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version:  20 %
       
    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 "videoplaybackdocumentloader.h"
       
    30 #include "videoplaybackcontrolscontroller.h"
       
    31 #include "videoplaybackdetailsplaybackwindow.h"
       
    32 
       
    33 // -------------------------------------------------------------------------------------------------
       
    34 // VideoPlaybackDetailsPlaybackWindow::VideoPlaybackDetailsPlaybackWindow
       
    35 // -------------------------------------------------------------------------------------------------
       
    36 //
       
    37 VideoPlaybackDetailsPlaybackWindow::VideoPlaybackDetailsPlaybackWindow(
       
    38         VideoPlaybackControlsController* controller )
       
    39     : mController( controller )
       
    40     , mInitialized( false )
       
    41 {
       
    42     MPX_ENTER_EXIT(_L("VideoPlaybackDetailsPlaybackWindow::VideoPlaybackDetailsPlaybackWindow()"));
       
    43 }
       
    44 
       
    45 // -------------------------------------------------------------------------------------------------
       
    46 // VideoPlaybackDetailsPlaybackWindow::~VideoPlaybackDetailsPlaybackWindow
       
    47 // -------------------------------------------------------------------------------------------------
       
    48 //
       
    49 VideoPlaybackDetailsPlaybackWindow::~VideoPlaybackDetailsPlaybackWindow()
       
    50 {
       
    51     MPX_ENTER_EXIT(_L("VideoPlaybackDetailsPlaybackWindow::~VideoPlaybackDetailsPlaybackWindow()"));
       
    52 }
       
    53 
       
    54 // -------------------------------------------------------------------------------------------------
       
    55 // VideoPlaybackDetailsPlaybackWindow::initialize
       
    56 // -------------------------------------------------------------------------------------------------
       
    57 //
       
    58 void VideoPlaybackDetailsPlaybackWindow::initialize()
       
    59 {
       
    60     MPX_ENTER_EXIT(_L("VideoPlaybackDetailsPlaybackWindow::initialize()"));
       
    61 
       
    62     VideoPlaybackDocumentLoader *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         VideoPlaybackViewFileDetails *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( play() ) );
       
    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 // VideoPlaybackDetailsPlaybackWindow::updateState()
       
   138 // -------------------------------------------------------------------------------------------------
       
   139 //
       
   140 void VideoPlaybackDetailsPlaybackWindow::updateState( TMPXPlaybackState state )
       
   141 {
       
   142     MPX_DEBUG(_L("VideoPlaybackDetailsPlaybackWindow::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 // VideoPlaybackDetailsPlaybackWindow::play()
       
   161 // -------------------------------------------------------------------------------------------------
       
   162 //
       
   163 void VideoPlaybackDetailsPlaybackWindow::play()
       
   164 {
       
   165     MPX_DEBUG(_L("VideoPlaybackDetailsPlaybackWindow::play()"));
       
   166 
       
   167     //
       
   168     // Only 'Play' button is created in this Details Playback Window,
       
   169     // hence when user touches on the 'Play' button, 'Play' command will be issued here.
       
   170     // On the other hand, when user touches anywhere in the Details Playback Window, 
       
   171     // the 'PlayPause' command will be handled via handleTappedOnScreen() method in the controller
       
   172     // 
       
   173     mController->handleCommand( EMPXPbvCmdPlay );
       
   174 }
       
   175 
       
   176 //End of file