photosgallery/slideshow/view/src/shwslideshowkeyhandler.cpp
changeset 0 4e91876724a2
child 14 ce1c7ad1f18b
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:    The view key handling control for the slideshow
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 //  CLASS HEADER
       
    22 #include "shwslideshowkeyhandler.h"
       
    23 
       
    24 //  EXTERNAL INCLUDES
       
    25 
       
    26 //  INTERNAL INCLUDES
       
    27 #include <glxlog.h>
       
    28 #include <glxtracer.h>
       
    29 #include <glxuiutility.h>
       
    30 #include "shwslideshowengine.h"
       
    31 #include "shwslideshowpausehandler.h"
       
    32 #include "shwslideshowview.h"
       
    33 // -----------------------------------------------------------------------------
       
    34 // C++ Constructor. 
       
    35 // -----------------------------------------------------------------------------
       
    36 inline CShwSlideShowKeyHandler::CShwSlideShowKeyHandler(
       
    37         CShwSlideshowEngine& aEngine, 
       
    38         CShwSlideShowPauseHandler& aPauseHandler,
       
    39         TInt& aState ) 
       
    40     : iEngine( aEngine ),iPauseHandler( aPauseHandler ), iState( aState )
       
    41     {
       
    42     TRACER("CShwSlideShowKeyHandler::CShwSlideShowKeyHandler");
       
    43     GLX_LOG_INFO("CShwSlideShowKeyHandler::CShwSlideShowKeyHandler");
       
    44     // No implementation required
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // ConstructL
       
    49 // -----------------------------------------------------------------------------
       
    50 void CShwSlideShowKeyHandler::ConstructL()
       
    51     {
       
    52     TRACER("CShwSlideShowKeyHandler::ConstructL");
       
    53     GLX_LOG_INFO("CShwSlideShowKeyHandler::ConstructL");
       
    54     iUiUtility = CGlxUiUtility::UtilityL();
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // NewL. Static construction
       
    59 // -----------------------------------------------------------------------------
       
    60 CShwSlideShowKeyHandler* CShwSlideShowKeyHandler::NewL(
       
    61         CShwSlideshowEngine& aEngine,
       
    62         CShwSlideShowPauseHandler& aPauseHandler,
       
    63         TInt& aState )
       
    64     {
       
    65     TRACER("CShwSlideShowKeyHandler::NewL");
       
    66     GLX_LOG_INFO("CShwSlideShowKeyHandler::NewL");
       
    67     CShwSlideShowKeyHandler* self = 
       
    68         new( ELeave ) CShwSlideShowKeyHandler( aEngine, aPauseHandler,
       
    69                 aState );
       
    70     CleanupStack::PushL(self);
       
    71     self->ConstructL();
       
    72     CleanupStack::Pop(self);
       
    73     return self;
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // Destructor.
       
    78 // -----------------------------------------------------------------------------
       
    79 CShwSlideShowKeyHandler::~CShwSlideShowKeyHandler()
       
    80     {
       
    81     TRACER("CShwSlideShowKeyHandler::~CShwSlideShowKeyHandler");
       
    82     GLX_LOG_INFO("CShwSlideShowKeyHandler::~CShwSlideShowKeyHandler");
       
    83     if ( iUiUtility )
       
    84         {
       
    85         iUiUtility->Close();
       
    86         }
       
    87     // No implementation required
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // OfferKeyEventL.
       
    92 // -----------------------------------------------------------------------------
       
    93 TKeyResponse CShwSlideShowKeyHandler::OfferKeyEventL(
       
    94         const TKeyEvent& aKeyEvent, TEventCode aType )
       
    95     {
       
    96     TRACER("CShwSlideShowKeyHandler::OfferKeyEventL");
       
    97     GLX_LOG_INFO( "CShwSlideShowKeyHandler::OfferKeyEventL" );
       
    98     TKeyResponse retVal = EKeyWasNotConsumed;
       
    99     
       
   100     if( aType == EEventKeyDown )
       
   101         {
       
   102         switch( aKeyEvent.iScanCode )
       
   103             {
       
   104             case EStdKeyIncVolume : // volume up
       
   105                 {
       
   106                 iEngine.VolumeUpL();
       
   107                 retVal = EKeyWasConsumed;
       
   108                 break;
       
   109                 }
       
   110             case EStdKeyDecVolume : // volume down
       
   111                 {
       
   112                 iEngine.VolumeDownL();
       
   113                 retVal = EKeyWasConsumed;
       
   114                 break;
       
   115                 }
       
   116             case EStdKeyLeftArrow :	// this gets rotated in landscape
       
   117                 {
       
   118                 // show previous image
       
   119                 iEngine.PreviousItemL();
       
   120                 retVal = EKeyWasConsumed;
       
   121                 break;
       
   122                 }
       
   123             case EStdKeyRightArrow : // this gets rotated in landscape
       
   124                 {
       
   125                 iEngine.NextItemL();
       
   126                 retVal = EKeyWasConsumed;
       
   127                 break;
       
   128                 }
       
   129             case EStdKeyDevice0 : // left soft key
       
   130                 {
       
   131                 iEngine.LSKPressedL();
       
   132                 // key was consumed
       
   133                 retVal = EKeyWasConsumed;
       
   134                 break;                
       
   135                 }
       
   136             case EStdKeyDevice3 : // navi select
       
   137                 {
       
   138                 iPauseHandler.ToggleUiControlsVisibiltyL();
       
   139                 // key was consumed
       
   140                 retVal = EKeyWasConsumed;
       
   141                 break;
       
   142                 }
       
   143             case EStdKeyDevice1 : // right soft key
       
   144                 {
       
   145                 // Exiting so revert to showing the system skin
       
   146                 // Note: this has to be done here, not in the view deactivation
       
   147                 // as when we come to deactivate, the screen furniture will
       
   148                 // match the view id to the active view (e.g. the tile view)
       
   149                 //@todo-check
       
   150                 //iScreenFurniture.DisableSystemSkinL( iViewId.iUid,
       
   151                 //    CGlxScreenFurniture::EGlxSfItemLeftSoftkey, EFalse );
       
   152                 //iScreenFurniture.DisableSystemSkinL( iViewId.iUid,
       
   153                 //    CGlxScreenFurniture::EGlxSfItemRightSoftkey, EFalse );
       
   154                 // Note that in practice it doesn't matter whether we return
       
   155                 // EKeyWasConsumed or EKeyWasNotConsumed as the result is
       
   156                 // the same (we still get back to the last view). This is due to
       
   157                 // HUI's key handling. So, for safety's sake, if in future there 
       
   158                 // are changes to HUI to cease processing the key events when 
       
   159                 // EKeyWasConsumed is returned, then we return EKeyWasNotConsumed to
       
   160                 // ensure that the command is forwarded to the back command handler.
       
   161                 break;                
       
   162                 }
       
   163             default:	
       
   164                 {
       
   165                 retVal = EKeyWasNotConsumed;
       
   166                 break;
       
   167                 }
       
   168             }// end switch
       
   169         }// end if
       
   170     // if its a system generated exit event
       
   171     // set the state 
       
   172     else if (aType == EEventKey && aKeyEvent.iScanCode == EStdKeyNo)
       
   173     	{
       
   174   
       
   175  //       iState = CShwSlideshowView::EShwExiting;
       
   176     	iUiUtility->SetExitingState(ETrue);
       
   177     	} // end if else
       
   178 
       
   179     return retVal; 
       
   180     }