photosgallery/slideshow/settingsdialog/src/shwslideshowsettingsdialog.cpp
changeset 0 4e91876724a2
child 2 7d9067c6fcb1
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007 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 Slideshow Settings Dialog
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 //  CLASS HEADER
       
    22 #include "shwslideshowsettingsdialog.h"
       
    23 
       
    24 //  EXTERNAL INCLUDES
       
    25 #include <hlplch.h>						// for HlpLauncher
       
    26 #include <eikdialg.h>					// for CEikDialog
       
    27 #include <aknappui.h>					// for CAknAppUi
       
    28 #include <akntitle.h>					// for CAknTitlePane
       
    29 #include <StringLoader.h>				// for StringLoader
       
    30 #include <bautils.h>					// for BaflUtils
       
    31 #include <data_caging_path_literals.hrh>// for KDC_APP_RESOURCE_DIR
       
    32 #include <coeutils.h>					// for ConeUitls
       
    33 #include <eikon.hrh>                    // for Navi-scroll key events
       
    34 #include <akntoolbar.h>
       
    35 
       
    36 //  INTERNAL INCLUDES
       
    37 #include <glxlog.h>
       
    38 #include <glxtracer.h>
       
    39 #include <glxpanic.h>                    // For Panics
       
    40 #include <shwsettingsdialog.rsg> 
       
    41 #include <glxresourceutilities.h>        // for CGlxResourceUtilities		  
       
    42 #include "shwslideshowsettings.hrh"
       
    43 #include "shwslideshowengine.h"			 // for CShwSlideshowEngine
       
    44 #include "shwslideshowsettings.hrh"		 // for Command Ids and Control Ids
       
    45 #include "shwsettingsmodel.h"			 // for CShwSettingsModel
       
    46 #include "shwslideshowsettingslist.h"	 // for CShwSlideshowSettingsList
       
    47 
       
    48 #define GetAppUi() (dynamic_cast<CAknAppUi*>(iEikonEnv->EikAppUi()))
       
    49 //CONSTANTS
       
    50 namespace
       
    51 	{
       
    52     // uid and id from doc/help_parameters_for_photos.xls
       
    53 	const TInt KShwHelpUID = 0x2000A778; 
       
    54 	_LIT( KSHW_HLP_SLIDESHOW_SETTINGS, "LGAL_HLP_SLIDESHOW_SETTINGS" );
       
    55 	}
       
    56 
       
    57 //-----------------------------------------------------------------------------
       
    58 // C++ default constructor.
       
    59 //-----------------------------------------------------------------------------
       
    60 inline CShwSlideshowSettingsDialog::CShwSlideshowSettingsDialog()
       
    61 	{
       
    62 	// No implementation required
       
    63 	}
       
    64 
       
    65 //-----------------------------------------------------------------------------
       
    66 // Two-phased constructor.
       
    67 //-----------------------------------------------------------------------------
       
    68 CShwSlideshowSettingsDialog* CShwSlideshowSettingsDialog::NewL()
       
    69 	{
       
    70 	TRACER("CShwSlideshowSettingsDialog::NewL");
       
    71 	GLX_LOG_INFO("CShwSlideshowSettingsDialog::NewL");	
       
    72 	CShwSlideshowSettingsDialog* self=new(ELeave)CShwSlideshowSettingsDialog();
       
    73     CleanupStack::PushL(self);
       
    74     self->ConstructL();
       
    75     CleanupStack::Pop(self);
       
    76     return self;
       
    77 	}
       
    78 
       
    79 
       
    80 
       
    81 //-----------------------------------------------------------------------------
       
    82 // Destructor
       
    83 //-----------------------------------------------------------------------------
       
    84 CShwSlideshowSettingsDialog::~CShwSlideshowSettingsDialog()
       
    85 	{
       
    86 	TRACER("CShwSlideshowSettingsDialog::~CShwSlideshowSettingsDialog");
       
    87 	GLX_LOG_INFO("CShwSlideshowSettingsDialog::~CShwSlideshowSettingsDialog");	
       
    88 	
       
    89 	// Draw the toolbar 
       
    90 	SetSlShwToolbarVisibility(ETrue);
       
    91 	
       
    92 	delete iShwSettings;
       
    93     // Delete resource file
       
    94 	if (iResourceOffset)
       
    95         {
       
    96         iEikonEnv->DeleteResourceFile( iResourceOffset );
       
    97         iResourceOffset = NULL;
       
    98         }
       
    99 	// If the status pane was enabled , set it to not visbible.
       
   100 	// used in FS view
       
   101 	if (iStatusPaneChanged)
       
   102 	    {
       
   103 	    iStatusPane->MakeVisible(EFalse);
       
   104 	    }
       
   105 	if (iPreviousTitle)
       
   106         {
       
   107         delete iPreviousTitle;
       
   108         }
       
   109     }
       
   110 
       
   111 //-----------------------------------------------------------------------------
       
   112 // Symbian 2nd phase constructor can leave.
       
   113 //-----------------------------------------------------------------------------
       
   114 void CShwSlideshowSettingsDialog::ConstructL()
       
   115 	{
       
   116 	TRACER("CShwSlideshowSettingsDialog::ConstructL");
       
   117 	GLX_LOG_INFO("CShwSlideshowSettingsDialog::ConstructL");	
       
   118 	
       
   119 	// hide toolbar.	
       
   120 	SetSlShwToolbarVisibility(EFalse);
       
   121 	iStatusPaneChanged = EFalse;
       
   122 	iStatusPane = GetAppUi()->StatusPane();
       
   123     iTitlePane = ( CAknTitlePane* )iStatusPane->ControlL(
       
   124             TUid::Uid( EEikStatusPaneUidTitle ));
       
   125 	// If Status pane not visible, then make it visible.
       
   126 	// Set the status pane flag as True, to be used in destructor, if 
       
   127 	// status pane is made visible.
       
   128 	// This is used in Fullscreen.
       
   129 	if(!iStatusPane->IsVisible())  
       
   130         {
       
   131         iStatusPane->MakeVisible(ETrue);
       
   132         iStatusPaneChanged = ETrue;
       
   133         }   
       
   134 	// Load the dialog resource file
       
   135 	_LIT(KShwSettingDlgResource,"shwsettingsdialog.rsc");	
       
   136     TFileName resourceFile(KDC_APP_RESOURCE_DIR);
       
   137     resourceFile.Append(KShwSettingDlgResource); 
       
   138     CGlxResourceUtilities::GetResourceFilenameL( resourceFile );  
       
   139     iResourceOffset = iCoeEnv->AddResourceFileL( resourceFile );
       
   140 
       
   141 	iShwSettings = CShwSettingsModel::NewL();
       
   142 
       
   143     // CAknDialog takes the menu resource as constructor parameter
       
   144 	CAknDialog::ConstructL( R_SHW_SETTINGSLIST_MENU_BAR );
       
   145     
       
   146     // set the title to the dialog, Note that avkon dialogs do not support
       
   147     // setting the title in the status pane so we need to do it the hard way
       
   148     // get status pane
       
   149 	SetTitleL();
       
   150 	}
       
   151 	
       
   152 // ---------------------------------------------------------------------------
       
   153 // SetSlShwToolbarVisibility()
       
   154 // ---------------------------------------------------------------------------
       
   155 void CShwSlideshowSettingsDialog::SetSlShwToolbarVisibility(TBool aVisible)
       
   156     {
       
   157     TRACER("CShwSlideshowSettingsDialog::SetSlShwToolbarVisibility");
       
   158     CAknAppUi* appUi = GetAppUi();
       
   159     __ASSERT_DEBUG(appUi, Panic(EGlxPanicNullPointer));
       
   160     CAknToolbar* popupToolbar = appUi->PopupToolbar();
       
   161     if(popupToolbar)
       
   162         {
       
   163         popupToolbar->SetToolbarVisibility( !aVisible ); 
       
   164         popupToolbar->MakeVisible( !aVisible );
       
   165 	     if(!aVisible)
       
   166 			{
       
   167 	        popupToolbar->DrawNow();	
       
   168 			}
       
   169         }  	
       
   170 	
       
   171 	CAknToolbar* toolbar = appUi->CurrentFixedToolbar();
       
   172     if(toolbar)
       
   173         {
       
   174         toolbar->SetToolbarVisibility(aVisible);
       
   175         toolbar->MakeVisible( aVisible );
       
   176         } 
       
   177 	
       
   178 	CAknToolbar* currentPopupToolbar = appUi->CurrentPopupToolbar();
       
   179     if(currentPopupToolbar)
       
   180         {
       
   181         currentPopupToolbar->SetToolbarVisibility(aVisible);
       
   182         currentPopupToolbar->MakeVisible( aVisible ); 
       
   183         }
       
   184     }
       
   185 	
       
   186 // ---------------------------------------------------------------------------
       
   187 // SetTitleL()
       
   188 // ---------------------------------------------------------------------------
       
   189 void CShwSlideshowSettingsDialog::SetTitleL()
       
   190     {
       
   191     TRACER("CShwSlideshowSettingsDialog::SetTitleL");
       
   192     GLX_LOG_INFO("CShwSlideshowSettingsDialog::SetTitleL");
       
   193     // Stores the previous Title
       
   194     iPreviousTitle = iTitlePane->Text()->AllocL();
       
   195     HBufC* aTitleText = StringLoader::LoadLC( 
       
   196                     R_SHW_SETTINGSLIST_TITLE_PANE_TXT, iEikonEnv );
       
   197                 
       
   198     iTitlePane->SetTextL( *aTitleText );
       
   199     CleanupStack::PopAndDestroy( aTitleText );
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // SetPreviousTitleL - Restores back the previous title, used in Slideshow Settings only
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CShwSlideshowSettingsDialog::SetPreviousTitleL()
       
   207     {
       
   208     TRACER("CShwSlideshowSettingsDialog::SetPreviousTitleL");
       
   209     GLX_LOG_INFO("CShwSlideshowSettingsDialog::SetPreviousTitleL");
       
   210     // Restore the Title back of the Calling View
       
   211     iTitlePane->SetTextL( *iPreviousTitle );
       
   212     }
       
   213 
       
   214 //-----------------------------------------------------------------------------
       
   215 // CShwSlideshowSettingsDialog::ProcessCommandL
       
   216 //-----------------------------------------------------------------------------
       
   217 void CShwSlideshowSettingsDialog::ProcessCommandL(TInt aCommandId)
       
   218 	{
       
   219 	TRACER("CShwSlideshowSettingsDialog::ProcessCommandL");
       
   220 	GLX_LOG_INFO("CShwSlideshowSettingsDialog::ProcessCommandL");			
       
   221 	switch (aCommandId)
       
   222 		{
       
   223 		case EShwCmdSettingsChange: 
       
   224 			{
       
   225 			CAknDialog::ProcessCommandL(aCommandId);
       
   226 		    iItemList->UpdateListBoxL(iItemList->ListBox()->CurrentItemIndex());
       
   227 			break;			
       
   228 			}
       
   229 		case EShwCmdHelp:
       
   230 			{
       
   231 			TCoeHelpContext helpContext;
       
   232 			helpContext.iMajor = TUid::Uid( KShwHelpUID );
       
   233 			helpContext.iContext.Copy( KSHW_HLP_SLIDESHOW_SETTINGS );
       
   234 			
       
   235 			const TInt KListSz = 1;
       
   236 			CArrayFix<TCoeHelpContext>* contextList =
       
   237 						new (ELeave) CArrayFixFlat<TCoeHelpContext>( KListSz );
       
   238 			CleanupStack::PushL(contextList);
       
   239 			contextList->AppendL(helpContext);
       
   240 			
       
   241 			HlpLauncher::LaunchHelpApplicationL(
       
   242                 iEikonEnv->WsSession(), contextList );
       
   243 			CleanupStack::Pop( contextList );
       
   244 			break;
       
   245 			}
       
   246 		case EShwCmdExit:
       
   247 			{
       
   248 			TryExitL(EShwCmdExit);
       
   249 			break;
       
   250 			}			
       
   251 		default:
       
   252 			{
       
   253 			CAknDialog::ProcessCommandL(aCommandId);
       
   254 			break;
       
   255 			}
       
   256 		};				
       
   257 	}
       
   258 	
       
   259 	
       
   260 //-----------------------------------------------------------------------------
       
   261 // CShwSlideshowSettingsDialog::CreateCustomControlL
       
   262 //-----------------------------------------------------------------------------
       
   263 SEikControlInfo CShwSlideshowSettingsDialog::CreateCustomControlL(TInt 
       
   264 																aControlType)
       
   265 	{
       
   266 	TRACER("CShwSlideshowSettingsDialog::CreateCustomControlL");
       
   267 	GLX_LOG_INFO("CShwSlideshowSettingsDialog::CreateCustomControlL");
       
   268     // create control info, no flags or trailer text set
       
   269 	SEikControlInfo controlInfo;
       
   270 	controlInfo.iControl 		= NULL;
       
   271 	controlInfo.iTrailerTextId 	= 0;
       
   272 	controlInfo.iFlags 			= 0;
       
   273 	
       
   274   	if (aControlType == EShwCtSettingListBox)
       
   275 		{
       
   276 		iItemList = CShwSlideShowSettingsList::NewL(*iShwSettings);
       
   277 		controlInfo.iControl = iItemList; // giving ownership
       
   278 		}
       
   279 	return controlInfo; // returns ownership of ItemList
       
   280 	}
       
   281 
       
   282 //-----------------------------------------------------------------------------
       
   283 // CShwSlideshowSettingsDialog::OkToExitL
       
   284 //-----------------------------------------------------------------------------
       
   285 TBool CShwSlideshowSettingsDialog::OkToExitL(TInt aKeycode)
       
   286 	{
       
   287 	TRACER("CShwSlideshowSettingsDialog::OkToExitL");
       
   288 	GLX_LOG_INFO("CShwSlideshowSettingsDialog::OkToExitL");					
       
   289     TBool retVal = EFalse;
       
   290     switch (aKeycode)
       
   291         {
       
   292         case EAknSoftkeyChange:
       
   293             {
       
   294             iItemList->UpdateListBoxL(iItemList->ListBox()->CurrentItemIndex(), ETrue);
       
   295             break;
       
   296             }
       
   297         case EAknSoftkeyOptions: // display menu only
       
   298             {
       
   299             DisplayMenuL();
       
   300             break;
       
   301             }
       
   302         case EAknSoftkeyBack: // exit dialog
       
   303         case EEikCmdExit:
       
   304         case EAknCmdExit:
       
   305         case EShwCmdExit:        
       
   306             {
       
   307             SetPreviousTitleL();
       
   308             retVal = ETrue;
       
   309             break;
       
   310             }
       
   311         }
       
   312     return retVal;
       
   313 	}
       
   314 
       
   315 //-----------------------------------------------------------------------------
       
   316 // CShwSlideshowSettingsDialog::SizeChanged
       
   317 //-----------------------------------------------------------------------------
       
   318 void CShwSlideshowSettingsDialog::SizeChanged()
       
   319 	{
       
   320 	TRACER("CShwSlideshowSettingsDialog::SizeChanged");
       
   321 	GLX_LOG_INFO("CShwSlideshowSettingsDialog::SizeChanged");						
       
   322 	if(iItemList) 
       
   323 		{
       
   324 		iItemList->ListBox()->SetRect(Rect());
       
   325 		}
       
   326 	CAknDialog::SizeChanged();
       
   327 	}
       
   328 
       
   329 //-----------------------------------------------------------------------------
       
   330 // CShwSlideshowSettingsDialog::OfferKeyEventL
       
   331 //-----------------------------------------------------------------------------
       
   332 TKeyResponse CShwSlideshowSettingsDialog::OfferKeyEventL(
       
   333     const TKeyEvent& aKeyEvent, TEventCode aType)
       
   334     {
       
   335     TRACER("CShwSlideshowSettingsDialog::OfferKeyEventL");
       
   336     GLX_LOG_INFO("CShwSlideshowSettingsDialog::OfferKeyEventL");   
       
   337     // Fix for EEBD-79UL8Q - "No Naviscroll support in Slideshow settings
       
   338     // options menu"
       
   339     TKeyEvent localKeyEvent = aKeyEvent;
       
   340     if ( aType == EEventKey )
       
   341         {
       
   342         switch ( aKeyEvent.iCode )
       
   343             {
       
   344             // Handle the previous and next navi-scroll events and modify the 
       
   345             // key code to the corresponding values used by the dialog
       
   346             case EKeyPrevious:
       
   347                 localKeyEvent.iCode = EKeyUpArrow;
       
   348                 break;
       
   349             case EKeyNext:
       
   350                 localKeyEvent.iCode = EKeyDownArrow;
       
   351                 break;
       
   352             default:
       
   353                 // nothing to change
       
   354                 break;
       
   355             }
       
   356         }
       
   357     
       
   358     // pass the key event up to the parent to handle
       
   359     return CAknDialog::OfferKeyEventL( localKeyEvent, aType );
       
   360     }
       
   361 //-----------------------------------------------------------------------------
       
   362 // CShwSlideshowSettingsDialog::FocusChanged
       
   363 //-----------------------------------------------------------------------------
       
   364 void CShwSlideshowSettingsDialog::FocusChanged(TDrawNow  aDrawNow)
       
   365 	{
       
   366     TRACER("CShwSlideshowSettingsDialog::FocusChanged");
       
   367     GLX_LOG_INFO("CShwSlideshowSettingsDialog::FocusChanged");   
       
   368 	// hide toolbar.
       
   369     if(aDrawNow == EDrawNow )
       
   370     	{
       
   371     	SetSlShwToolbarVisibility(EFalse);
       
   372     	}
       
   373 	}
       
   374 
       
   375 //  End of File