gssettingsuis/Gs/GSAutoKeyguardPlugin/Src/GSAutoKeyguardPluginAutoKeyguardSettingPage.cpp
changeset 68 13e71d907dc3
equal deleted inserted replaced
40:6465d5bb863a 68:13e71d907dc3
       
     1 /*
       
     2 * Copyright (c) 2006 - 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: 
       
    15 *		Autokeyguard period settingpage
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 #include <eikmenub.h>
       
    21 #include <gsautokeyguardpluginrsc.rsg>
       
    22 #include <e32base.h>
       
    23 #include <AknQueryDialog.h>
       
    24 #include "GSAutoKeyguardPluginAutoKeyguardTimeQuery.h"
       
    25 #include "GSAutoKeyguardPluginAutoKeyguardSettingPage.h"
       
    26 
       
    27 const TInt64 minPeriodInMicroseconds(5000000);
       
    28 
       
    29 //
       
    30 // ----------------------------------------------------------
       
    31 // CAutoKeyguardSettingPage::CAutoKeyguardSettingPage()
       
    32 // C++ default constructor
       
    33 // ----------------------------------------------------------
       
    34 // 
       
    35 CAutoKeyguardSettingPage::CAutoKeyguardSettingPage(TInt aResourceId, 
       
    36                                                     TInt& aCurrentSelectionItem, 
       
    37                                                     CDesCArrayFlat* aItemArray, 
       
    38                                                     TTime* aAutoKeyguardValue,
       
    39                                                     TTime aMaxPeriod) : CAknRadioButtonSettingPage(aResourceId, aCurrentSelectionItem, aItemArray)					
       
    40 
       
    41 	{	//c++ constructor may not contain any code which might leave
       
    42 		iAutoKeyguardValue = aAutoKeyguardValue;
       
    43 		iMaxPeriod = aMaxPeriod;
       
    44 	}
       
    45 
       
    46 //
       
    47 // ----------------------------------------------------------
       
    48 // CAutoKeyguardSettingPage::ConstructL()
       
    49 // Symbian OS default constructor
       
    50 // ----------------------------------------------------------
       
    51 // 
       
    52 void CAutoKeyguardSettingPage::ConstructL()
       
    53 	{
       
    54 	CAknRadioButtonSettingPage::ConstructL();
       
    55 	const TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels();
       
    56 	}
       
    57 
       
    58 
       
    59 //
       
    60 // ----------------------------------------------------------
       
    61 // CAutoKeyguardSettingPage::ProcessCommandL()
       
    62 // 
       
    63 // ----------------------------------------------------------
       
    64 // 
       
    65 void CAutoKeyguardSettingPage::ProcessCommandL(TInt aCommandId)
       
    66 	{
       
    67 	// Respond to softkey events
       
    68 
       
    69 	switch (aCommandId)
       
    70 		{
       
    71 		case EAknSoftkeySelect:
       
    72 		case EAknSoftkeyOk:
       
    73 			ExecuteAutoKeyguardSettingsL();
       
    74 			break;
       
    75 
       
    76 		default:
       
    77 			CAknSettingPage::ProcessCommandL(aCommandId);
       
    78 			break;
       
    79 		}
       
    80 
       
    81 	}
       
    82 
       
    83 //---------------------------------------------------------------------------------------
       
    84 // CAutoKeyguardSettingPage::HandleListBoxEventL()
       
    85 // 
       
    86 //---------------------------------------------------------------------------------------
       
    87 //
       
    88 void CAutoKeyguardSettingPage::HandleListBoxEventL(CEikListBox* aListBox,
       
    89 		MEikListBoxObserver::TListBoxEvent aEventType)
       
    90 	{
       
    91 	// Respond to double click events
       
    92 	if ( aEventType == EEventEnterKeyPressed || aEventType == EEventItemSingleClicked )
       
    93 		{
       
    94 		ExecuteAutoKeyguardSettingsL();
       
    95 		}
       
    96 	}
       
    97 
       
    98 //---------------------------------------------------------------------------------------
       
    99 // CAutoKeyguardSettingPage::ExecuteAutoKeyguardSettingsL()
       
   100 // 
       
   101 //---------------------------------------------------------------------------------------
       
   102 //
       
   103 void CAutoKeyguardSettingPage::ExecuteAutoKeyguardSettingsL()
       
   104 	{
       
   105 	TInt cur = ListBoxControl()->CurrentItemIndex();
       
   106 	
       
   107 	// autoKeyguard off
       
   108 	if (cur == 0)
       
   109 		{
       
   110 		*iAutoKeyguardValue = 0;
       
   111 		AttemptExitL(ETrue);
       
   112 		}
       
   113 	// user defined
       
   114 	if (cur == 1)
       
   115 		{
       
   116 
       
   117 		CAutoKeyguardTimeQuery* dlg = new (ELeave) CAutoKeyguardTimeQuery(*iAutoKeyguardValue, CAknQueryDialog::ENoTone);
       
   118 
       
   119 		if(AknLayoutUtils::PenEnabled()) 
       
   120 			{
       
   121 			dlg->PrepareLC(R_AUTOKEYGUARD_TOUCH_TIME_SETTING_QUERY);
       
   122 			}
       
   123 		else
       
   124 			{
       
   125 			dlg->PrepareLC(R_AUTOKEYGUARD_TIME_SETTING_QUERY);
       
   126 			}
       
   127 
       
   128 		if(iMaxPeriod > 0)
       
   129 			{
       
   130 			TTime minimum(minPeriodInMicroseconds);
       
   131 			dlg->SetMinimumAndMaximum(minimum, iMaxPeriod);
       
   132 			}
       
   133 
       
   134 		if(dlg->RunLD())
       
   135 			{
       
   136 			AttemptExitL(ETrue);
       
   137 			}
       
   138 		else
       
   139 			AttemptExitL(EFalse);
       
   140 		}
       
   141 	}
       
   142 // End of file
       
   143