camerauis/cameraapp/generic/GsCamcorderPlugin/src/GSCamVideoSettingsList.cpp
changeset 19 d9aefe59d544
parent 3 8b2d6d0384b0
child 21 fa6d9f75d6a6
child 28 3075d9b614e6
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
     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:  Video settings list class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20  
       
    21 #include <CAknMemorySelectionSettingItem.h> // CAknMemorySelectionSettingItem
       
    22 #include <bldvariant.hrh>
       
    23 #include <featmgr.h>
       
    24 #include <gscamerapluginrsc.rsg>
       
    25 #include <StringLoader.h>
       
    26 #include <AknQueryDialog.h>
       
    27 #include <AknWaitDialog.h>
       
    28 #include <CAknMemorySelectionSettingItemMultiDrive.h>
       
    29 #include <driveinfo.h>          // DriveInfo
       
    30 
       
    31 #include "GSCamcorderPlugin.hrh"
       
    32 #include "Cam.hrh"
       
    33 #include "CamSettings.hrh"
       
    34 #include "CamSettingsInternal.hrh"
       
    35 #include "GSCamVideoSettingsList.h"
       
    36 #include "CamPanic.h"
       
    37 #include "CamAppUiBase.h"
       
    38 #include "GSCamcorderPlugin.h"
       
    39 #include "CamUtility.h"
       
    40 #include "MCamAppController.h"
       
    41 #include "CamStaticSettingsModel.h"
       
    42 #include "GSCamQualitySettingItem.h"
       
    43 #include "GSCamDefaultNameSettingItem.h"
       
    44 #include "GSCustomQualitySettingItem.h"
       
    45 #include "CameraUiConfigManager.h"
       
    46 
       
    47 #include "CamCollectionManagerAo.h"
       
    48 #include "CamWaitDialog.h"
       
    49 
       
    50 #include "camconfiguration.h"
       
    51 #include "CamLocationSettingItem.h"
       
    52 
       
    53 // FORWARD DECLARATIONS
       
    54 
       
    55 // ========================= MEMBER FUNCTIONS ================================
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CGSCamVideoSettingsList::CGSCamVideoSettingsList
       
    59 // C++ constructor
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CGSCamVideoSettingsList::CGSCamVideoSettingsList( CCamStaticSettingsModel& aModel )
       
    63 :iModel( aModel )
       
    64     {
       
    65     iSettings.Reset();
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CGSCamVideoSettingsList::ConstructL
       
    71 // Symbian OS 2nd phase constructor
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CGSCamVideoSettingsList::ConstructL( TBool aLaunchedFromGS,
       
    75                                           TBool aSecondaryCameraSettings )
       
    76     {
       
    77     CAknViewAppUi *AppUi = 
       
    78                   static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() );
       
    79 
       
    80     CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> 
       
    81         					     ( AppUi->View( KGSCamcorderGSPluginUid ) );
       
    82 
       
    83     if ( parent )
       
    84         {
       
    85         parent->LoadVideoStaticSettingsL( ETrue );
       
    86         parent->LoadPhotoStaticSettingsL( ETrue );
       
    87         }
       
    88 
       
    89     iModel.Configuration().GetPsiIntArrayL( ECamPsiSupportedVideoQualities, iSupportedVideoQualities );
       
    90                                                      
       
    91     iLaunchedFromGS = aLaunchedFromGS;
       
    92     iSecondaryCameraSettings = aSecondaryCameraSettings;
       
    93     iSettings.ResetAndDestroy();
       
    94 
       
    95     TInt resId;
       
    96     if ( iModel.UiConfigManagerPtr() &&
       
    97          iModel.UiConfigManagerPtr()->IsLocationSupported() )
       
    98         {
       
    99         resId =  R_CAM_VIDEO_SETTINGS_WITH_LOCATION_ITEM_LIST_CAMCORDER;
       
   100         }
       
   101     else
       
   102         {
       
   103         resId =  R_CAM_VIDEO_SETTINGS_ITEM_LIST_CAMCORDER;
       
   104         }
       
   105 
       
   106     if ( iSecondaryCameraSettings )
       
   107         {
       
   108         resId =  R_CAM_VIDEO_SETTINGS_ITEM_LIST_PORTRAIT;
       
   109         }
       
   110 
       
   111     ConstructFromResourceL( resId );
       
   112     }
       
   113 
       
   114 
       
   115 // Destructor
       
   116 //CGSCamVideoSettingsList::~CGSCamVideoSettingsList()
       
   117 //
       
   118 CGSCamVideoSettingsList::~CGSCamVideoSettingsList()
       
   119     {
       
   120     iSettings.ResetAndDestroy();
       
   121     iSettings.Close();
       
   122     iSupportedVideoQualities.Close();
       
   123     }
       
   124 
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CGSCamVideoSettingsList::CreateSettingItemL
       
   128 // From CAknSettingItemList Handles creating setting items
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 CAknSettingItem* CGSCamVideoSettingsList::CreateSettingItemL( TInt aIdentifier )
       
   132     {
       
   133     CAknViewAppUi *AppUi = static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() );
       
   134     CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> 
       
   135         					     ( AppUi->View( KGSCamcorderGSPluginUid ) );
       
   136     // Add storage place to storage list of settings values. 
       
   137     // ...create the storage place.
       
   138     TIntSetting* newSetting = new( ELeave ) TIntSetting;
       
   139     CleanupStack::PushL( newSetting );
       
   140     // ...set the identifier for this setting item.
       
   141     newSetting->iItemId = aIdentifier;
       
   142     if( aIdentifier != ECamSettingItemRestoreCameraSettings )
       
   143         {
       
   144         if ( parent )
       
   145             {
       
   146             newSetting->iValueId = parent->IntegerSettingValue( aIdentifier );
       
   147             }
       
   148         }
       
   149     else
       
   150         {
       
   151         newSetting->iValueId = 0;     
       
   152         }
       
   153     // ...add the new storage place item to the storage list.
       
   154     iSettings.AppendL( newSetting );
       
   155     CleanupStack::Pop( newSetting );
       
   156 
       
   157     // Create the list setting item
       
   158     CAknSettingItem* settingItem = NULL;
       
   159     TInt lastItem = iSettings.Count() - 1;
       
   160     // Setting items take reference to the value to be manipulated.
       
   161     TInt& valueId( iSettings[lastItem]->iValueId );
       
   162 
       
   163     switch ( aIdentifier )
       
   164         {
       
   165         case ECamSettingItemVideoAudioRec:
       
   166         case ECamSettingItemVideoShowCapturedVideo:
       
   167         case ECamSettingItemVideoOpZoomOff:
       
   168             {
       
   169             settingItem = 
       
   170                 new( ELeave ) CAknBinaryPopupSettingItem( aIdentifier, valueId );
       
   171             }
       
   172             break;
       
   173         case ECamSettingItemVideoDigitalZoom:
       
   174             {
       
   175             if ( iModel.UiConfigManagerPtr() &&
       
   176                  iModel.UiConfigManagerPtr()->IsExtendedDigitalZoomSupported() )
       
   177                 {
       
   178                 settingItem = new( ELeave ) CAknBinaryPopupSettingItem( aIdentifier, valueId );          
       
   179                 }
       
   180             break;
       
   181             }
       
   182         case ECamSettingItemVideoQuality:
       
   183             {
       
   184             if ( parent )
       
   185                 {
       
   186                 iQualityValue = parent->IntegerSettingValue( ECamSettingItemVideoQuality);
       
   187                 }
       
   188             if ( !iLaunchedFromGS )
       
   189       	        {
       
   190                 settingItem = new( ELeave )
       
   191                     CGSCamQualitySettingItem( ECamControllerVideo,
       
   192                                               aIdentifier,
       
   193                                               iQualityValue,
       
   194                                               iModel );
       
   195                 }
       
   196             else
       
   197                 {
       
   198                 settingItem = new( ELeave ) 
       
   199                     CGSCustomQualitySettingItem( aIdentifier,
       
   200                                                  iQualityValue,
       
   201                                                  iModel,
       
   202                                                  ECamControllerVideo );
       
   203                 }
       
   204             }
       
   205             break;
       
   206  
       
   207 	    case ECamSettingItemRecLocation:
       
   208       	  {
       
   209           if ( !iLaunchedFromGS )
       
   210             {
       
   211             settingItem = 
       
   212                 new( ELeave ) CCamLocationSettingItem( ECamControllerVideo,
       
   213                                                        aIdentifier, 
       
   214                                                        valueId );
       
   215             }
       
   216           else
       
   217             {
       
   218             settingItem = 
       
   219                 new( ELeave ) CAknEnumeratedTextPopupSettingItem( aIdentifier, 
       
   220                                                                   valueId );
       
   221             }
       
   222           }
       
   223       	  break;
       
   224 
       
   225         case ECamSettingItemVideoMediaStorage:
       
   226             {
       
   227             // Convert the setting to a memory enum
       
   228             iMemVal = static_cast<DriveInfo::TDefaultDrives>
       
   229                     ( CamUtility::MapToSettingsListMemory( 
       
   230                                   iSettings[lastItem]->iValueId ) );
       
   231 
       
   232             __ASSERT_DEBUG( iMemVal != KErrNotFound,
       
   233                             CamPanic( ECamPanicUnhandledCreateSettingItem ) );
       
   234 
       
   235 		    // Get the root path of the default mass storage memory.
       
   236 		    TInt driveInt;
       
   237 		    TInt err = DriveInfo::GetDefaultDrive( iMemVal, driveInt );
       
   238 		    iDrive = static_cast<TDriveNumber>(driveInt);
       
   239 
       
   240 		    settingItem = new ( ELeave ) 
       
   241 		                  CAknMemorySelectionSettingItemMultiDrive( aIdentifier, 
       
   242                                                                     iDrive );
       
   243             break;
       
   244             }
       
   245         case ECamSettingItemVideoNameBaseType:
       
   246             {
       
   247             if ( parent )
       
   248                 {
       
   249                 iDefaultNameBase = parent->TextSettingValue( 
       
   250                                             ECamSettingItemVideoNameBase );
       
   251                 }
       
   252             TBool flag = ( iLaunchedFromGS || iSecondaryCameraSettings );
       
   253             settingItem = new( ELeave ) 
       
   254                           CGSCamDefaultNameSettingItem( iDefaultNameBase, 
       
   255                                                         ECamControllerVideo, 
       
   256                                                         aIdentifier, 
       
   257                                                         valueId,
       
   258                                                         flag );
       
   259       }
       
   260       break;
       
   261 
       
   262 
       
   263     case ECamSettingItemVideoStab:
       
   264       {
       
   265       if ( iModel.UiConfigManagerPtr() &&
       
   266            iModel.UiConfigManagerPtr()->IsVideoStabilizationSupported() )
       
   267           {
       
   268           settingItem = 
       
   269             new( ELeave ) CAknBinaryPopupSettingItem( aIdentifier, valueId );          
       
   270           }
       
   271       }
       
   272       break;
       
   273     case ECamSettingItemRestoreCameraSettings:
       
   274       {
       
   275       settingItem = new ( ELeave ) CAknBigSettingItemBase( aIdentifier );
       
   276       }
       
   277       break;
       
   278     case ECamSettingItemContinuousAutofocus: 
       
   279         {
       
   280         if ( iModel.UiConfigManagerPtr() &&
       
   281                    iModel.UiConfigManagerPtr()->IsContinuosAutofocusSupported() )
       
   282                   {
       
   283                   settingItem = 
       
   284                     new( ELeave ) CAknBinaryPopupSettingItem( aIdentifier, valueId );          
       
   285                   }
       
   286         
       
   287         break;
       
   288         }
       
   289     default:
       
   290       __ASSERT_DEBUG( EFalse, CamPanic( ECamPanicUnhandledCreateSettingItem ) );
       
   291       break;
       
   292     }
       
   293 
       
   294   PRINT( _L("Camera <= CCamVideoSettingsList::CreateSettingItemL") );
       
   295   return settingItem;
       
   296   }
       
   297 
       
   298 
       
   299 // ---------------------------------------------------------------------------
       
   300 // CGSCamVideoSettingsList::EditItemL
       
   301 // Launch the setting page for the current item by calling
       
   302 // EditItemL on it.
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 void CGSCamVideoSettingsList::EditItemL( TInt aIndex, TBool aCalledFromMenu )
       
   306     {      
       
   307     PRINT( _L("Camera => CCamVideoSettingsList::EditItemL" ))
       
   308     CAknViewAppUi *AppUi = static_cast<CAknViewAppUi*>( 
       
   309                            CCoeEnv::Static()->AppUi() );
       
   310 
       
   311     CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> 
       
   312         					    ( AppUi->View( KGSCamcorderGSPluginUid ) );
       
   313 
       
   314     CAknSettingItemArray* itemArray = SettingItemArray();
       
   315     CAknSettingItem* editedItem = itemArray->At(aIndex);
       
   316     
       
   317     if ( editedItem->Identifier() == ECamSettingItemRestoreCameraSettings )
       
   318         {
       
   319         TInt response = 0;
       
   320         if ( parent )
       
   321         	{
       
   322         	response = parent->DisplayRestoreSettingsDlgL();
       
   323         	}
       
   324         // If launched from GS and response "Yes" reload settings page to update values 
       
   325         if ( iLaunchedFromGS && response )
       
   326         	{
       
   327         	AppUi->ActivateLocalViewL( KGSCamcorderGSPluginUid );
       
   328         	}
       
   329         return;
       
   330         }
       
   331 
       
   332     // Edit item via setting page or in-place.
       
   333     CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
       
   334     // Write the new value for the edited control to its stored data.
       
   335     editedItem->StoreL();
       
   336 
       
   337     // Update the settings model so that the navipane is updated.
       
   338     TInt settingValue;
       
   339     // ...If the changed setting is the media storage setting
       
   340     // ...then convert the memory value to settings model type value.
       
   341     if ( editedItem->Identifier() == ECamSettingItemVideoMediaStorage )
       
   342         {
       
   343         iMemVal = static_cast<DriveInfo::TDefaultDrives>(CamUtility::GetDriveTypeFromDriveNumber( iDrive ));
       
   344         settingValue = CamUtility::MapFromSettingsListMemory( iMemVal );
       
   345         //__ASSERT_DEBUG( settingValue != KErrNotFound, CamPanic( ECamPanicUnknownSettingItem ) );
       
   346         }
       
   347     else if ( editedItem->Identifier() == ECamSettingItemVideoQuality )
       
   348         {
       
   349         settingValue = iQualityValue;
       
   350         }
       
   351     // ...Otherwise, no conversion necessary.
       
   352     else
       
   353         {
       
   354         settingValue = ValueOfSetting( editedItem->Identifier() );
       
   355         }
       
   356     // ...Update the settings model with the new value.
       
   357     if ( parent )
       
   358         {
       
   359         parent->SetIntegerSettingValueL( editedItem->Identifier(),
       
   360                							 settingValue );
       
   361         }
       
   362 
       
   363     // If the setting is for the video base name then store the name.
       
   364     if ( editedItem->Identifier() == ECamSettingItemVideoNameBaseType  
       
   365          && parent )
       
   366         {
       
   367         parent->SetTextSettingValueL( ECamSettingItemVideoNameBase,
       
   368                                       iDefaultNameBase );
       
   369         }
       
   370 
       
   371     PRINT( _L("Camera <= CCamVideoSettingsList::EditItemL" ))
       
   372     }
       
   373 
       
   374 // ---------------------------------------------------------------------------
       
   375 // CGSCamVideoSettingsList::ValueOfSetting
       
   376 // Returns the current value of the a setting for this list.
       
   377 // Note, this is not the value currently stored in the settings model, as these
       
   378 // may differ.
       
   379 // ---------------------------------------------------------------------------
       
   380 //
       
   381 TInt CGSCamVideoSettingsList::ValueOfSetting( TInt aItemId ) const
       
   382     {
       
   383     TInt itemIndex = IndexOfSetting( aItemId );
       
   384     return iSettings[itemIndex]->iValueId;
       
   385     }
       
   386 
       
   387 // ---------------------------------------------------------------------------
       
   388 // CGSCamVideoSettingsList::IndexOfSetting
       
   389 // Returns the array index of a setting for this list.
       
   390 // ---------------------------------------------------------------------------
       
   391 //
       
   392 TInt CGSCamVideoSettingsList::IndexOfSetting( TInt aItemId ) const
       
   393     {
       
   394     TInt i;
       
   395   TInt itemTotal = iSettings.Count();
       
   396     for ( i = 0; i < itemTotal; ++i )
       
   397         {
       
   398         if ( iSettings[i]->iItemId == aItemId )
       
   399             {
       
   400             return i;
       
   401             }
       
   402         }
       
   403 
       
   404     // Should never get here.
       
   405     // Remove lint warning
       
   406     return KErrNotFound;
       
   407     }
       
   408 
       
   409    
       
   410 // ---------------------------------------------------------------------------
       
   411 // CGSCamVideoSettingsList::SizeChanged
       
   412 // Set the size and position of component controls.
       
   413 // ---------------------------------------------------------------------------
       
   414 //
       
   415 void CGSCamVideoSettingsList::SizeChanged()
       
   416     {
       
   417     CAknSettingItemList::SizeChanged();
       
   418     CEikListBox* lb = ListBox();
       
   419     if( lb )
       
   420         {
       
   421         lb->SetRect( Rect() );  // Set container's rect to listbox
       
   422         }
       
   423     }
       
   424 
       
   425 
       
   426 // End of File
       
   427