videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackdetailsplaybackwindow.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 QMPXVideoPlaybackProgressBar
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version:  11 %
       
    19 
       
    20 
       
    21 
       
    22 #include <QFileInfo>
       
    23 #include <QGraphicsSceneMouseEvent>
       
    24 
       
    25 
       
    26 #include <hblabel.h>
       
    27 #include <hbframeitem.h>
       
    28 #include <hbpushbutton.h>
       
    29 #include <hbframedrawer.h>
       
    30 
       
    31 #include "mpxvideo_debug.h"
       
    32 #include "mpxvideoplaybackdocumentloader.h"
       
    33 #include "mpxvideoplaybackcontrolscontroller.h"
       
    34 #include "mpxvideoplaybackdetailsplaybackwindow.h"
       
    35 
       
    36 // -------------------------------------------------------------------------------------------------
       
    37 // QMPXVideoPlaybackDetailsPlaybackWindow::QMPXVideoPlaybackDetailsPlaybackWindow
       
    38 // -------------------------------------------------------------------------------------------------
       
    39 //
       
    40 QMPXVideoPlaybackDetailsPlaybackWindow::QMPXVideoPlaybackDetailsPlaybackWindow( 
       
    41         QMPXVideoPlaybackControlsController* controller )
       
    42     : mController( controller )
       
    43     , mInitialized( false )
       
    44 {
       
    45     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDetailsPlaybackWindow::QMPXVideoPlaybackDetailsPlaybackWindow()"));
       
    46 }
       
    47 
       
    48 // -------------------------------------------------------------------------------------------------
       
    49 // QMPXVideoPlaybackDetailsPlaybackWindow::~QMPXVideoPlaybackDetailsPlaybackWindow
       
    50 // -------------------------------------------------------------------------------------------------
       
    51 //
       
    52 QMPXVideoPlaybackDetailsPlaybackWindow::~QMPXVideoPlaybackDetailsPlaybackWindow()
       
    53 {
       
    54     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDetailsPlaybackWindow::~QMPXVideoPlaybackDetailsPlaybackWindow()"));
       
    55 }
       
    56 
       
    57 // -------------------------------------------------------------------------------------------------
       
    58 // QMPXVideoPlaybackDetailsPlaybackWindow::initialize
       
    59 // -------------------------------------------------------------------------------------------------
       
    60 //
       
    61 void QMPXVideoPlaybackDetailsPlaybackWindow::initialize()
       
    62 {
       
    63     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDetailsPlaybackWindow::initialize()"));
       
    64 
       
    65     QMPXVideoPlaybackDocumentLoader *loader = mController->layoutLoader();
       
    66 
       
    67     //
       
    68     // Don't need to initialize buttons once it gets initialized
       
    69     //
       
    70     if ( loader && ! mInitialized )
       
    71     {
       
    72         mInitialized = true;
       
    73 
       
    74         QMPXVideoPlaybackViewFileDetails *details = mController->fileDetails();
       
    75 
       
    76         //
       
    77         // Connect signal and slot for play button
       
    78         //
       
    79         QGraphicsWidget *widget = loader->findWidget( QString( "detailsViewPlayButton" ) );
       
    80         mPlayButton = qobject_cast<HbPushButton*>( widget );
       
    81         mPlayButton->setFlag( QGraphicsItem::ItemIsFocusable, false );
       
    82 
       
    83         connect( mPlayButton, SIGNAL( released() ), this, SLOT( playPause() ) );
       
    84         
       
    85         QGraphicsItem *widget1 = mPlayButton->primitive( HbStyle::P_PushButton_background );
       
    86         widget1->setVisible( false );
       
    87 
       
    88         //
       
    89         // Set framedrawer for semi transparent background
       
    90         //
       
    91         HbFrameItem *frameItem = new HbFrameItem ( mPlayButton );
       
    92         frameItem->setGeometry( mPlayButton->boundingRect() );
       
    93         frameItem->frameDrawer().setFrameType( HbFrameDrawer::OnePiece );
       
    94         frameItem->frameDrawer().setFillWholeRect( true );
       
    95         frameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_status_trans_normal_c" );
       
    96     }
       
    97 
       
    98     updateState( mController->state() );
       
    99 }
       
   100 
       
   101 // -------------------------------------------------------------------------------------------------
       
   102 // QMPXVideoPlaybackDetailsPlaybackWindow::updateState()
       
   103 // -------------------------------------------------------------------------------------------------
       
   104 //
       
   105 void QMPXVideoPlaybackDetailsPlaybackWindow::updateState( TMPXPlaybackState state )
       
   106 {
       
   107     MPX_DEBUG(_L("QMPXVideoPlaybackDetailsPlaybackWindow::updateState() state = %d"), state );
       
   108 
       
   109     switch ( state )
       
   110     {
       
   111         case EPbStatePaused:
       
   112         {
       
   113             mPlayButton->setVisible( true );
       
   114             break;
       
   115         }
       
   116         default:
       
   117         {
       
   118             mPlayButton->setVisible( false );
       
   119             break;
       
   120         }
       
   121     }
       
   122 }
       
   123 
       
   124 // -------------------------------------------------------------------------------------------------
       
   125 // QMPXVideoPlaybackDetailsPlaybackWindow::playPause()
       
   126 // -------------------------------------------------------------------------------------------------
       
   127 //
       
   128 void QMPXVideoPlaybackDetailsPlaybackWindow::playPause()
       
   129 {
       
   130     MPX_DEBUG(_L("QMPXVideoPlaybackDetailsPlaybackWindow::playPause"));
       
   131 
       
   132     mController->handleCommand( EMPXPbvCmdPlayPause );
       
   133 }
       
   134 
       
   135 // -------------------------------------------------------------------------------------------------
       
   136 // QMPXVideoPlaybackDetailsPlaybackWindow::mousePressEvent
       
   137 // -------------------------------------------------------------------------------------------------
       
   138 //
       
   139 void QMPXVideoPlaybackDetailsPlaybackWindow::mousePressEvent( QGraphicsSceneMouseEvent *event )
       
   140 {
       
   141     MPX_DEBUG(_L("QMPXVideoPlaybackDetailsPlaybackWindow::mousePressEvent"));
       
   142 
       
   143     event->accept();
       
   144 }
       
   145 
       
   146 // -------------------------------------------------------------------------------------------------
       
   147 // QMPXVideoPlaybackDetailsPlaybackWindow::mouseReleaseEvent
       
   148 // -------------------------------------------------------------------------------------------------
       
   149 //
       
   150 void QMPXVideoPlaybackDetailsPlaybackWindow::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
       
   151 {
       
   152     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDetailsPlaybackWindow::mouseReleaseEvent"));
       
   153 
       
   154     Q_UNUSED( event );
       
   155 
       
   156     playPause();
       
   157 }
       
   158 
       
   159 //End of file