videoplayback/videoplaybackview/controlsrc/videoplaybackdetailsplaybackwindow.cpp
author hgs
Fri, 23 Jul 2010 11:10:06 +0300
changeset 49 824471cb468a
parent 44 518105d52e45
permissions -rw-r--r--
201029
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  Implementation of VideoPlaybackDetailsPlaybackWindow
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
// Version : %version:  20 %
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
#include <QGraphicsSceneMouseEvent>
hgs
parents:
diff changeset
    23
hgs
parents:
diff changeset
    24
#include <hbframeitem.h>
hgs
parents:
diff changeset
    25
#include <hbpushbutton.h>
hgs
parents:
diff changeset
    26
#include <hbframedrawer.h>
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
#include "mpxvideo_debug.h"
hgs
parents:
diff changeset
    29
#include "videoplaybackdocumentloader.h"
hgs
parents:
diff changeset
    30
#include "videoplaybackcontrolscontroller.h"
hgs
parents:
diff changeset
    31
#include "videoplaybackdetailsplaybackwindow.h"
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    34
// VideoPlaybackDetailsPlaybackWindow::VideoPlaybackDetailsPlaybackWindow
hgs
parents:
diff changeset
    35
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    36
//
hgs
parents:
diff changeset
    37
VideoPlaybackDetailsPlaybackWindow::VideoPlaybackDetailsPlaybackWindow(
hgs
parents:
diff changeset
    38
        VideoPlaybackControlsController* controller )
hgs
parents:
diff changeset
    39
    : mController( controller )
hgs
parents:
diff changeset
    40
    , mInitialized( false )
hgs
parents:
diff changeset
    41
{
hgs
parents:
diff changeset
    42
    MPX_ENTER_EXIT(_L("VideoPlaybackDetailsPlaybackWindow::VideoPlaybackDetailsPlaybackWindow()"));
hgs
parents:
diff changeset
    43
}
hgs
parents:
diff changeset
    44
hgs
parents:
diff changeset
    45
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    46
// VideoPlaybackDetailsPlaybackWindow::~VideoPlaybackDetailsPlaybackWindow
hgs
parents:
diff changeset
    47
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    48
//
hgs
parents:
diff changeset
    49
VideoPlaybackDetailsPlaybackWindow::~VideoPlaybackDetailsPlaybackWindow()
hgs
parents:
diff changeset
    50
{
hgs
parents:
diff changeset
    51
    MPX_ENTER_EXIT(_L("VideoPlaybackDetailsPlaybackWindow::~VideoPlaybackDetailsPlaybackWindow()"));
hgs
parents:
diff changeset
    52
}
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    55
// VideoPlaybackDetailsPlaybackWindow::initialize
hgs
parents:
diff changeset
    56
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    57
//
hgs
parents:
diff changeset
    58
void VideoPlaybackDetailsPlaybackWindow::initialize()
hgs
parents:
diff changeset
    59
{
hgs
parents:
diff changeset
    60
    MPX_ENTER_EXIT(_L("VideoPlaybackDetailsPlaybackWindow::initialize()"));
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
    VideoPlaybackDocumentLoader *loader = mController->layoutLoader();
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
    //
hgs
parents:
diff changeset
    65
    // Don't need to initialize buttons once it gets initialized
hgs
parents:
diff changeset
    66
    //
hgs
parents:
diff changeset
    67
    if ( loader && ! mInitialized )
hgs
parents:
diff changeset
    68
    {
hgs
parents:
diff changeset
    69
        mInitialized = true;
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
        VideoPlaybackViewFileDetails *details = mController->fileDetails();
hgs
parents:
diff changeset
    72
hgs
parents:
diff changeset
    73
        //
hgs
parents:
diff changeset
    74
        // Connect signal and slot for play button
hgs
parents:
diff changeset
    75
        //
hgs
parents:
diff changeset
    76
        QGraphicsWidget *widget = loader->findWidget( QString( "detailsViewPlayButton" ) );
hgs
parents:
diff changeset
    77
        mPlayButton = qobject_cast<HbPushButton*>( widget );
hgs
parents:
diff changeset
    78
        mPlayButton->setFlag( QGraphicsItem::ItemIsFocusable, false );
hgs
parents:
diff changeset
    79
hgs
parents:
diff changeset
    80
        connect( mPlayButton, SIGNAL( released() ), this, SLOT( play() ) );
hgs
parents:
diff changeset
    81
hgs
parents:
diff changeset
    82
        //
hgs
parents:
diff changeset
    83
        // Set framedrawer for semi transparent background
hgs
parents:
diff changeset
    84
        //
hgs
parents:
diff changeset
    85
        HbFrameDrawer *drawer = mPlayButton->frameBackground();
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
        if( drawer == NULL )
hgs
parents:
diff changeset
    88
        {
hgs
parents:
diff changeset
    89
            drawer = new HbFrameDrawer();
hgs
parents:
diff changeset
    90
        }
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
        drawer->setFillWholeRect( true );
hgs
parents:
diff changeset
    93
        drawer->setFrameType( HbFrameDrawer::NinePieces );
hgs
parents:
diff changeset
    94
        drawer->setFrameGraphicsName( "qtg_fr_multimedia_trans" );
hgs
parents:
diff changeset
    95
        mPlayButton->setFrameBackground( drawer );
hgs
parents:
diff changeset
    96
hgs
parents:
diff changeset
    97
        //
hgs
parents:
diff changeset
    98
        // create 'attach' button and connect corresponding signal/slot
hgs
parents:
diff changeset
    99
        //
hgs
parents:
diff changeset
   100
        QGraphicsWidget *detailsAttachWidget = loader->findWidget( QString( "detailsAttachButton" ) );
hgs
parents:
diff changeset
   101
        HbPushButton *attachButton = qobject_cast<HbPushButton*>( detailsAttachWidget );
hgs
parents:
diff changeset
   102
        connect( attachButton, SIGNAL( released() ), mController, SLOT( attachVideo() ) );
hgs
parents:
diff changeset
   103
hgs
parents:
diff changeset
   104
        //
hgs
parents:
diff changeset
   105
        // create 'share' button and connect corresponding signal/slot
hgs
parents:
diff changeset
   106
        //
hgs
parents:
diff changeset
   107
        QGraphicsWidget *detailsShareWidget = loader->findWidget( QString( "detailsShareButton" ) );
hgs
parents:
diff changeset
   108
        HbPushButton *shareButton = qobject_cast<HbPushButton*>( detailsShareWidget );
hgs
parents:
diff changeset
   109
        connect( shareButton, SIGNAL( released() ), mController, SLOT( sendVideo() ) );
hgs
parents:
diff changeset
   110
hgs
parents:
diff changeset
   111
        //
hgs
parents:
diff changeset
   112
        // by default in xml layout, attachButton is not visible while shareButton is visible.
hgs
parents:
diff changeset
   113
        // if it's an 'attach' operation, reverse the visibility order
hgs
parents:
diff changeset
   114
        //
hgs
parents:
diff changeset
   115
        if ( mController->isAttachOperation() )
hgs
parents:
diff changeset
   116
        {
hgs
parents:
diff changeset
   117
            attachButton->setVisible( true );
hgs
parents:
diff changeset
   118
            shareButton->setVisible( false );
hgs
parents:
diff changeset
   119
        }
hgs
parents:
diff changeset
   120
        else
hgs
parents:
diff changeset
   121
        {
hgs
parents:
diff changeset
   122
            //
hgs
parents:
diff changeset
   123
            // dim "share" button for streaming
hgs
parents:
diff changeset
   124
            //
hgs
parents:
diff changeset
   125
            if ( details->mPlaybackMode == EMPXVideoStreaming ||
hgs
parents:
diff changeset
   126
                 details->mPlaybackMode == EMPXVideoLiveStreaming )
hgs
parents:
diff changeset
   127
            {
hgs
parents:
diff changeset
   128
                shareButton->setEnabled( false );
hgs
parents:
diff changeset
   129
            }
hgs
parents:
diff changeset
   130
        }
hgs
parents:
diff changeset
   131
    }
hgs
parents:
diff changeset
   132
hgs
parents:
diff changeset
   133
    updateState( mController->state() );
hgs
parents:
diff changeset
   134
}
hgs
parents:
diff changeset
   135
hgs
parents:
diff changeset
   136
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   137
// VideoPlaybackDetailsPlaybackWindow::updateState()
hgs
parents:
diff changeset
   138
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   139
//
hgs
parents:
diff changeset
   140
void VideoPlaybackDetailsPlaybackWindow::updateState( TMPXPlaybackState state )
hgs
parents:
diff changeset
   141
{
hgs
parents:
diff changeset
   142
    MPX_DEBUG(_L("VideoPlaybackDetailsPlaybackWindow::updateState() state = %d"), state );
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
    switch ( state )
hgs
parents:
diff changeset
   145
    {
hgs
parents:
diff changeset
   146
        case EPbStatePaused:
hgs
parents:
diff changeset
   147
        {
hgs
parents:
diff changeset
   148
            mPlayButton->setVisible( true );
hgs
parents:
diff changeset
   149
            break;
hgs
parents:
diff changeset
   150
        }
hgs
parents:
diff changeset
   151
        default:
hgs
parents:
diff changeset
   152
        {
hgs
parents:
diff changeset
   153
            mPlayButton->setVisible( false );
hgs
parents:
diff changeset
   154
            break;
hgs
parents:
diff changeset
   155
        }
hgs
parents:
diff changeset
   156
    }
hgs
parents:
diff changeset
   157
}
hgs
parents:
diff changeset
   158
hgs
parents:
diff changeset
   159
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   160
// VideoPlaybackDetailsPlaybackWindow::play()
hgs
parents:
diff changeset
   161
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   162
//
hgs
parents:
diff changeset
   163
void VideoPlaybackDetailsPlaybackWindow::play()
hgs
parents:
diff changeset
   164
{
hgs
parents:
diff changeset
   165
    MPX_DEBUG(_L("VideoPlaybackDetailsPlaybackWindow::play()"));
hgs
parents:
diff changeset
   166
hgs
parents:
diff changeset
   167
    //
hgs
parents:
diff changeset
   168
    // Only 'Play' button is created in this Details Playback Window,
hgs
parents:
diff changeset
   169
    // hence when user touches on the 'Play' button, 'Play' command will be issued here.
hgs
parents:
diff changeset
   170
    // On the other hand, when user touches anywhere in the Details Playback Window, 
hgs
parents:
diff changeset
   171
    // the 'PlayPause' command will be handled via handleTappedOnScreen() method in the controller
hgs
parents:
diff changeset
   172
    // 
hgs
parents:
diff changeset
   173
    mController->handleCommand( EMPXPbvCmdPlay );
hgs
parents:
diff changeset
   174
}
hgs
parents:
diff changeset
   175
hgs
parents:
diff changeset
   176
//End of file