photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlerslideshow.cpp
branchRCL_3
changeset 11 71da52165949
parent 2 7d9067c6fcb1
child 12 ce1c7ad1f18b
equal deleted inserted replaced
9:6b87b143d312 11:71da52165949
    33 #include <glxresourceutilities.h>                // for CGlxResourceUtilities
    33 #include <glxresourceutilities.h>                // for CGlxResourceUtilities
    34 #include <glxattributecontext.h>                 // for CGlxAttributeContext
    34 #include <glxattributecontext.h>                 // for CGlxAttributeContext
    35 #include <glxmedia.h>                            // for TGlxMedia
    35 #include <glxmedia.h>                            // for TGlxMedia
    36 #include <StringLoader.h>                        // for stringloader
    36 #include <StringLoader.h>                        // for stringloader
    37 #include <glxlog.h>
    37 #include <glxlog.h>
       
    38 #include <glxtracer.h>
    38 
    39 
    39 #include "shwslideshowviewplugin.hrh"		 // for the slideshow view's UID
    40 #include "shwslideshowviewplugin.hrh"		 // for the slideshow view's UID
    40 #include "shwslideshowsettingsplugin_UID.hrh"// for slideshow setting dlg UID
    41 #include "shwslideshowsettingsplugin_UID.hrh"// for slideshow setting dlg UID
    41 #include "glxuiutility.h"
    42 #include "glxuiutility.h"
    42 #include "glxscreenfurniture.h"
    43 #include "glxscreenfurniture.h"
    55 // ---------------------------------------------------------------------------
    56 // ---------------------------------------------------------------------------
    56 //
    57 //
    57 EXPORT_C CGlxCommandHandlerSlideshow* CGlxCommandHandlerSlideshow::NewL(
    58 EXPORT_C CGlxCommandHandlerSlideshow* CGlxCommandHandlerSlideshow::NewL(
    58     MGlxMediaListProvider* aMediaListProvider, TBool aStepBack, TBool aHasToolbarItem )
    59     MGlxMediaListProvider* aMediaListProvider, TBool aStepBack, TBool aHasToolbarItem )
    59     {
    60     {
    60     GLX_LOG_INFO( "CGlxCommandHandlerSlideshow::NewL" );
    61     TRACER( "CGlxCommandHandlerSlideshow::NewL" );
    61     CGlxCommandHandlerSlideshow* self = new ( ELeave )
    62     CGlxCommandHandlerSlideshow* self = new ( ELeave )
    62     	CGlxCommandHandlerSlideshow(aMediaListProvider, aStepBack, aHasToolbarItem);
    63     	CGlxCommandHandlerSlideshow(aMediaListProvider, aStepBack, aHasToolbarItem);
    63     CleanupStack::PushL( self );
    64     CleanupStack::PushL( self );
    64     self->ConstructL();
    65     self->ConstructL();
    65     CleanupStack::Pop( self );
    66     CleanupStack::Pop( self );
    82 // Symbian 2nd phase constructor can leave.
    83 // Symbian 2nd phase constructor can leave.
    83 // ---------------------------------------------------------------------------
    84 // ---------------------------------------------------------------------------
    84 //
    85 //
    85 void CGlxCommandHandlerSlideshow::ConstructL()
    86 void CGlxCommandHandlerSlideshow::ConstructL()
    86     {
    87     {
    87     GLX_LOG_INFO( "CGlxCommandHandlerSlideshow::ConstructL" );
    88     TRACER( "CGlxCommandHandlerSlideshow::ConstructL" );
    88     
    89     
    89     // Get a handle 
    90     // Get a handle 
    90     iUiUtility = CGlxUiUtility::UtilityL();
    91     iUiUtility = CGlxUiUtility::UtilityL();
    91 
    92 
    92     // Load resource file
    93     // Load resource file
   150 // Destructor
   151 // Destructor
   151 // ---------------------------------------------------------------------------
   152 // ---------------------------------------------------------------------------
   152 //
   153 //
   153 EXPORT_C CGlxCommandHandlerSlideshow::~CGlxCommandHandlerSlideshow()
   154 EXPORT_C CGlxCommandHandlerSlideshow::~CGlxCommandHandlerSlideshow()
   154     {
   155     {
   155     GLX_LOG_INFO( "CGlxCommandHandlerSlideshow::~CGlxCommandHandlerSlideshow" );
   156     TRACER( "CGlxCommandHandlerSlideshow::~CGlxCommandHandlerSlideshow" );
   156     if ( iResourceOffset )
   157     if ( iResourceOffset )
   157         {
   158         {
   158         CCoeEnv::Static()->DeleteResourceFile(iResourceOffset);
   159         CCoeEnv::Static()->DeleteResourceFile(iResourceOffset);
   159         }
   160         }
   160 
   161 
   171 // DoActivateL
   172 // DoActivateL
   172 // ---------------------------------------------------------------------------
   173 // ---------------------------------------------------------------------------
   173 //
   174 //
   174 void CGlxCommandHandlerSlideshow::DoActivateL(TInt aViewId)
   175 void CGlxCommandHandlerSlideshow::DoActivateL(TInt aViewId)
   175     {
   176     {
   176     GLX_LOG_INFO( "CGlxCommandHandlerSlideshow::DoActivateL" );    
   177     TRACER( "CGlxCommandHandlerSlideshow::DoActivateL" );    
   177     iViewId = aViewId;
   178     iViewId = aViewId;
   178 
   179 
   179     // for media list item "focus changed" notification
   180     // for media list item "focus changed" notification
   180     MGlxMediaList& mediaList( MediaList() );
   181     MGlxMediaList& mediaList( MediaList() );
   181     mediaList.AddMediaListObserverL( this );
   182     mediaList.AddMediaListObserverL( this );
   185 // ----------------------------------------------------------------------------
   186 // ----------------------------------------------------------------------------
   186 // Deactivate
   187 // Deactivate
   187 // ----------------------------------------------------------------------------
   188 // ----------------------------------------------------------------------------
   188 void CGlxCommandHandlerSlideshow::Deactivate()
   189 void CGlxCommandHandlerSlideshow::Deactivate()
   189     {
   190     {
   190     GLX_LOG_INFO( "CGlxCommandHandlerSlideshow::Deactivate" );       
   191     TRACER( "CGlxCommandHandlerSlideshow::Deactivate" );       
   191 
   192 
   192     MGlxMediaList& mediaList( MediaList() );
   193     MGlxMediaList& mediaList( MediaList() );
   193     mediaList.RemoveMediaListObserver( this );
   194     mediaList.RemoveMediaListObserver( this );
   194     }
   195     }
   195 
   196 
   198 // ----------------------------------------------------------------------------
   199 // ----------------------------------------------------------------------------
   199 //
   200 //
   200 TBool CGlxCommandHandlerSlideshow::IsSlideshowNotPlayableOnFocusedContainer
   201 TBool CGlxCommandHandlerSlideshow::IsSlideshowNotPlayableOnFocusedContainer
   201             (TInt aCommandId, MGlxMediaList& aList)
   202             (TInt aCommandId, MGlxMediaList& aList)
   202     {
   203     {
       
   204     TRACER("CGlxCommandHandlerSlideshow::IsSlideshowNotPlayableOnFocusedContainer");
   203     TBool slideshowDisabled = EFalse;
   205     TBool slideshowDisabled = EFalse;
   204 
   206 
   205     // get the media item
   207     // get the media item
   206     const TGlxMedia& item = aList.Item( aList.FocusIndex() );
   208     const TGlxMedia& item = aList.Item( aList.FocusIndex() );
   207     const TCommandInfo& info = CommandInfo(aCommandId);    
   209     const TCommandInfo& info = CommandInfo(aCommandId);    
   227 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   228 //
   230 //
   229 TBool CGlxCommandHandlerSlideshow::DoExecuteL(TInt aCommandId,
   231 TBool CGlxCommandHandlerSlideshow::DoExecuteL(TInt aCommandId,
   230 	MGlxMediaList& aList )
   232 	MGlxMediaList& aList )
   231 	{
   233 	{
   232     GLX_LOG_INFO( "CGlxCommandHandlerSlideshow::DoExecuteL" );
   234     TRACER( "CGlxCommandHandlerSlideshow::DoExecuteL" );
   233 	TBool handledCommand = ETrue;
   235 	TBool handledCommand = ETrue;
   234 	
   236 	
   235 	switch (aCommandId)
   237 	switch (aCommandId)
   236 		{
   238 		{
   237         case EGlxCmdSlideshowPlay:
   239         case EGlxCmdSlideshowPlay:
   238 	        {        
   240 	        {        
   239 	        // This check has to be done again here since Slideshow can be 
   241 	        // This check has to be done again here since Slideshow can be 
   240 	        // activated from toolbar even when there are non-slideshow playable 
   242 	        // activated from toolbar even when there are non-slideshow playable 
   241 	        // items in a container and when that container is focused.	
   243 	        // items in a container and when that container is focused.	
   242 	        if( IsSlideshowNotPlayableOnFocusedContainer( aCommandId, aList ) )
   244 	        if( aList.Count() <= 0 || IsSlideshowNotPlayableOnFocusedContainer( aCommandId, aList ) )
   243 	            {
   245 	            {
   244 	            HBufC* popupText = NULL;
   246 	            HBufC* popupText = NULL;
   245 	            	            
   247 	            	            
   246 	            //Load the "No Images to Play Slideshow" string from the resource file
   248 	            //Load the "No Images to Play Slideshow" string from the resource file
   247 	            popupText = StringLoader::LoadLC( R_GLX_NO_IMAGES_TO_PLAY_SLIDESHOW );
   249 	            popupText = StringLoader::LoadLC( R_GLX_NO_IMAGES_TO_PLAY_SLIDESHOW );
   319 // -----------------------------------------------------------------------------
   321 // -----------------------------------------------------------------------------
   320 //
   322 //
   321 TBool CGlxCommandHandlerSlideshow::DoIsDisabled(
   323 TBool CGlxCommandHandlerSlideshow::DoIsDisabled(
   322     TInt /*aCommandId*/, MGlxMediaList& /*aList*/) const
   324     TInt /*aCommandId*/, MGlxMediaList& /*aList*/) const
   323     {
   325     {
       
   326     TRACER("CGlxCommandHandlerSlideshow::DoIsDisabled");
   324     // Disable if UPnP is active
   327     // Disable if UPnP is active
   325     return ( GlxUpnpRenderer::Status() == NGlxUpnpRenderer::EActive );
   328     return ( GlxUpnpRenderer::Status() == NGlxUpnpRenderer::EActive );
   326     }
   329     }
   327 
   330 
   328 // -----------------------------------------------------------------------------
   331 // -----------------------------------------------------------------------------
   329 // BypassFiltersForExecute
   332 // BypassFiltersForExecute
   330 // -----------------------------------------------------------------------------
   333 // -----------------------------------------------------------------------------
   331 //
   334 //
   332 TBool CGlxCommandHandlerSlideshow::BypassFiltersForExecute() const
   335 TBool CGlxCommandHandlerSlideshow::BypassFiltersForExecute() const
   333     {
   336     {
       
   337     TRACER("CGlxCommandHandlerSlideshow::BypassFiltersForExecute");
   334     // Always bypass filters to minimise the time spent by the base class
   338     // Always bypass filters to minimise the time spent by the base class
   335     // when it initialises the slideshow menu item.
   339     // when it initialises the slideshow menu item.
   336     return ETrue;
   340     return ETrue;
   337     }
   341     }
   338 
   342 
   341 // ----------------------------------------------------------------------------
   345 // ----------------------------------------------------------------------------
   342 void CGlxCommandHandlerSlideshow::HandleFocusChangedL(
   346 void CGlxCommandHandlerSlideshow::HandleFocusChangedL(
   343                 NGlxListDefs::TFocusChangeType /*aType*/,
   347                 NGlxListDefs::TFocusChangeType /*aType*/,
   344                 TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/ )
   348                 TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/ )
   345     {
   349     {
   346     GLX_FUNC("CGlxCommandHandlerSlideshow::HandleFocusChangedL");
   350     TRACER("CGlxCommandHandlerSlideshow::HandleFocusChangedL");
   347 
   351 
   348     }
   352     }
   349 
   353 
   350 // ---------------------------------------------------------------------------
   354 // ---------------------------------------------------------------------------
   351 // HandleItemAddedL
   355 // HandleItemAddedL
   389 //
   393 //
   390 void CGlxCommandHandlerSlideshow::HandleAttributesAvailableL(
   394 void CGlxCommandHandlerSlideshow::HandleAttributesAvailableL(
   391             TInt aItemIndex, const RArray<TMPXAttribute>& aAttributes,
   395             TInt aItemIndex, const RArray<TMPXAttribute>& aAttributes,
   392             MGlxMediaList* /*aList*/ )
   396             MGlxMediaList* /*aList*/ )
   393     {
   397     {
       
   398     TRACER("CGlxCommandHandlerSlideshow::HandleAttributesAvailableL");
   394     if ( iShowInToolbar && MediaList().FocusIndex() == aItemIndex )
   399     if ( iShowInToolbar && MediaList().FocusIndex() == aItemIndex )
   395         {
   400         {
   396         TIdentityRelation<TMPXAttribute> match( TMPXAttribute::MatchContentId );
   401         TIdentityRelation<TMPXAttribute> match( TMPXAttribute::MatchContentId );
   397 
   402 
   398         if ( aAttributes.Find( KMPXMediaGeneralCategory, match ) >= 0
   403         if ( aAttributes.Find( KMPXMediaGeneralCategory, match ) >= 0
   427 // -----------------------------------------------------------------------------
   432 // -----------------------------------------------------------------------------
   428 //
   433 //
   429 void CGlxCommandHandlerSlideshow::ActivateViewL( NShwSlideshow::TPlayDirection
   434 void CGlxCommandHandlerSlideshow::ActivateViewL( NShwSlideshow::TPlayDirection
   430 	aPlaybackDirection )
   435 	aPlaybackDirection )
   431 	{
   436 	{
   432     GLX_LOG_INFO( "CGlxCommandHandlerSlideshow::ActivateViewL" );
   437     TRACER( "CGlxCommandHandlerSlideshow::ActivateViewL" );
   433     
   438     
   434     // Determine the path from the media list
   439     // Determine the path from the media list
   435     CMPXCollectionPath* path = MediaList().PathLC();
   440     CMPXCollectionPath* path = MediaList().PathLC();
   436 	// Ensure the path's at the correct level for the view
   441 	// Ensure the path's at the correct level for the view
   437 	if ( iStepBack && path->Levels() > 0 )
   442 	if ( iStepBack && path->Levels() > 0 )
   480 // UpdateToolbarL
   485 // UpdateToolbarL
   481 // ---------------------------------------------------------------------------
   486 // ---------------------------------------------------------------------------
   482 //
   487 //
   483 void CGlxCommandHandlerSlideshow::UpdateToolbar()
   488 void CGlxCommandHandlerSlideshow::UpdateToolbar()
   484     {
   489     {
       
   490     TRACER("CGlxCommandHandlerSlideshow::UpdateToolbar");
   485     TBool visible = EFalse;
   491     TBool visible = EFalse;
   486 
   492 
   487     if ( GlxUpnpRenderer::Status() != NGlxUpnpRenderer::EActive )
   493     if ( GlxUpnpRenderer::Status() != NGlxUpnpRenderer::EActive )
   488         {
   494         {
   489         TInt focus = MediaList().FocusIndex();
   495         TInt focus = MediaList().FocusIndex();
   514 // PopulateToolbar
   520 // PopulateToolbar
   515 // ---------------------------------------------------------------------------
   521 // ---------------------------------------------------------------------------
   516 //
   522 //
   517 void CGlxCommandHandlerSlideshow::PopulateToolbarL()
   523 void CGlxCommandHandlerSlideshow::PopulateToolbarL()
   518 	{
   524 	{
   519 	
   525     TRACER("CGlxCommandHandlerSlideshow::PopulateToolbarL");
   520 	iUiUtility->ScreenFurniture()->SetTooltipL( EGlxCmdSlideshowPlay, CAknButton::EPositionLeft );
   526 	iUiUtility->ScreenFurniture()->SetTooltipL( EGlxCmdSlideshowPlay, CAknButton::EPositionLeft );
   521 	}
   527 	}
   522 
   528 
   523 // End of File
   529 // End of File