voicerecorder/AppSrc/CVRSettingsDialog.cpp
branchRCL_3
changeset 21 c6bafb5162d8
parent 0 845549f293a7
equal deleted inserted replaced
20:072a5fa0c63b 21:c6bafb5162d8
       
     1 /*
       
     2 * Copyright (c) 2002 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 *     This class defines a settings dialog for the Voice Recorder application.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <bldvariant.hrh>
       
    21 
       
    22 #include <AknLists.h>
       
    23 #include <aknform.h>
       
    24 #include <featmgr.h>
       
    25 #include "CVRSettingsDialog.h"
       
    26 #include "VoiceRecorder.hrh"
       
    27 #include <VoiceRecorder.rsg>
       
    28 #include "VRConsts.h"
       
    29 #include "VRUtils.h"
       
    30 
       
    31 CVRSettingsDialog::~CVRSettingsDialog()
       
    32     {
       
    33 	iSettingItemArray.ResetAndDestroy();
       
    34     }
       
    35 
       
    36 CVRSettingsDialog* CVRSettingsDialog::NewL()
       
    37     {
       
    38     CVRSettingsDialog* self = new( ELeave ) CVRSettingsDialog;
       
    39 	CleanupStack::PushL( self );
       
    40 	self->ConstructL( R_VR_SETTINGS_MENUBAR );
       
    41 	CleanupStack::Pop();
       
    42     return self;
       
    43     }
       
    44 
       
    45 TBool CVRSettingsDialog::OkToExitL( TInt aButtonId )
       
    46 	{
       
    47 	if ( aButtonId == EAknSoftkeyOptions )
       
    48         {
       
    49         DisplayMenuL();
       
    50         return EFalse;
       
    51         }
       
    52 
       
    53 	TInt settingItemCount( iSettingItemArray.Count() );
       
    54 
       
    55 	for ( TInt i( 0 ); i < settingItemCount; i++ )
       
    56 		{
       
    57 		iSettingItemArray.At( i )->StoreL();
       
    58 		}
       
    59 
       
    60     if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
       
    61         {
       
    62         // Save the quality setting	
       
    63 	    VRUtils::SetQualityL( iQuality );
       
    64         }
       
    65 
       
    66 	return ETrue;
       
    67 	}
       
    68 
       
    69 void CVRSettingsDialog::PreLayoutDynInitL()
       
    70 	{
       
    71     if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
       
    72         {
       
    73 	    iQuality = VRUtils::QualityL();
       
    74         }
       
    75 
       
    76 	CAknSettingStyleListBox* listBox = static_cast< CAknSettingStyleListBox* >
       
    77 										( Control( EVRSettingsListboxId ) );
       
    78 	User::LeaveIfNull( listBox );
       
    79 
       
    80 	CAknSettingItem* settingItem;
       
    81 	HBufC* itemTitle = NULL;
       
    82 	TInt id( 0 );
       
    83 
       
    84     if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) )
       
    85         {
       
    86     	// Add quality setting
       
    87     	settingItem = new( ELeave ) CAknBinaryPopupSettingItem( 0, ( TInt& ) iQuality );
       
    88     	CleanupStack::PushL( settingItem );
       
    89 
       
    90     	itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_QUALITY );
       
    91     	settingItem->ConstructL( EFalse, id, *itemTitle, NULL,
       
    92     	                     R_VR_SETTINGS_DEFAULT_SPEAKER_PAGE, EAknCtPopupField, NULL,
       
    93     						 R_VR_SETTINGS_QUALITY_TEXTS );
       
    94     	CleanupStack::PopAndDestroy();		// itemTitle
       
    95 
       
    96     	// Add quality item to the settings array
       
    97     	iSettingItemArray.AppendL( settingItem );
       
    98     	CleanupStack::Pop();	// settingItem
       
    99     	id++;
       
   100         }
       
   101         
       
   102 	CTextListBoxModel* model = listBox->Model();
       
   103 	model->SetItemTextArray( &iSettingItemArray );
       
   104 	// Ownership retained by us
       
   105 	model->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   106 
       
   107 	iSettingItemArray.RecalculateVisibleIndicesL();
       
   108 	listBox->CreateScrollBarFrameL( ETrue );
       
   109 	listBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   110 						CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   111 	listBox->HandleItemAdditionL();
       
   112 	listBox->SetListBoxObserver( this );
       
   113 	listBox->UpdateScrollBarsL();
       
   114 
       
   115 	}
       
   116 
       
   117 void CVRSettingsDialog::HandleListBoxEventL( CEikListBox* aListBox,
       
   118 											 TListBoxEvent aEventType )
       
   119 	{
       
   120 	TInt index( aListBox->CurrentItemIndex() );
       
   121 		if ( index >=0 )	// index is -1 if there are no items in the list
       
   122 			{
       
   123 			iSettingItemArray.At( index )->EditItemL(
       
   124 				aEventType == EEventEditingStarted );
       
   125 			aListBox->DrawItem( index );
       
   126 			}
       
   127 	}
       
   128 
       
   129 void CVRSettingsDialog::ProcessCommandL( TInt aCommandId )
       
   130 	{
       
   131 	HideMenu();
       
   132 	switch ( aCommandId )
       
   133 		{
       
   134 		case ECmdChange:
       
   135 			{
       
   136 			CEikListBox* listBox = static_cast< CEikListBox* >( Control( EVRSettingsListboxId ) );
       
   137 			HandleListBoxEventL( listBox, EEventEditingStarted );
       
   138 			break;
       
   139 			}
       
   140 		case EEikCmdExit:
       
   141 			{
       
   142 			TryExitL( EAknSoftkeyBack );
       
   143 			CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId );
       
   144 			break;
       
   145 			}
       
   146 		default:
       
   147 			{
       
   148 			CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId );
       
   149 			break;
       
   150 			}
       
   151 		}
       
   152 	}
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // CVRSettingsDialog::DynInitMenuPaneL
       
   156 // 
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 void CVRSettingsDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   160 	{
       
   161 
       
   162 	switch ( aResourceId )
       
   163 		{
       
   164 		case R_VR_SETTINGS_MENUPANE:
       
   165 			{
       
   166 			// Check if HELP is enabled in FeatureManager, if not, disable the Help menu item
       
   167 			if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
       
   168 				{
       
   169 				aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
       
   170 				}
       
   171             break; 
       
   172 			}
       
   173 		default:
       
   174 			{
       
   175 			break;
       
   176 			}
       
   177 		}
       
   178 	}
       
   179