screengrabber/src/SGSettingListContainer.cpp
branchRCL_3
changeset 21 b3cee849fa46
parent 20 48060abbbeaf
child 22 fad26422216a
equal deleted inserted replaced
20:48060abbbeaf 21:b3cee849fa46
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "SGSettingListContainer.h"
       
    22 #include <screengrabber.rsg>
       
    23 #include "SG.hrh"
       
    24 #include "SGDocument.h"
       
    25 
       
    26 
       
    27 #ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
       
    28   #include <CAknMemorySelectionSettingItemMultiDrive.h>
       
    29 #else
       
    30   #include <CAknMemorySelectionSettingItem.h>
       
    31 #endif
       
    32 
       
    33 #include <eikappui.h>
       
    34 #include <akntitle.h>
       
    35 #include <eikspane.h> 
       
    36 
       
    37 #include <AknDef.h>
       
    38 
       
    39 
       
    40 // ================= MEMBER FUNCTIONS =======================
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // CScreenGrabberSettingListContainer::ConstructL(const TRect& aRect)
       
    44 // EPOC two phased constructor
       
    45 // ---------------------------------------------------------
       
    46 //
       
    47 void CScreenGrabberSettingListContainer::ConstructL(const TRect& aRect)
       
    48     {
       
    49     CreateWindowL();
       
    50     
       
    51     // set title of the app
       
    52     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
    53     CAknTitlePane* title = static_cast<CAknTitlePane*>( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
    54     title->SetTextL( _L("Settings") );
       
    55 
       
    56     // get an instance of the engine
       
    57     iModel = static_cast<CScreenGrabberDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
       
    58 
       
    59     // get the settings from the engine
       
    60     iGrabSettings = iModel->GrabSettings();
       
    61 
       
    62     // construct the settings list from resources
       
    63     ConstructFromResourceL(R_SCREENGRABBER_SETTINGLIST);
       
    64     
       
    65     // set visibilities
       
    66     SetVisibilitiesOfSettingItems();
       
    67 
       
    68     // set correct drawing area for the listbox
       
    69     SetRect(aRect);
       
    70     HandleResourceChange(KEikDynamicLayoutVariantSwitch);
       
    71 
       
    72     ActivateL();
       
    73     }
       
    74 
       
    75 
       
    76 // Destructor
       
    77 CScreenGrabberSettingListContainer::~CScreenGrabberSettingListContainer()
       
    78     {
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CScreenGrabberSettingListView::CreateSettingItemL( TInt aIdentifier )
       
    84 // ---------------------------------------------------------
       
    85 //
       
    86 CAknSettingItem* CScreenGrabberSettingListContainer::CreateSettingItemL( TInt aIdentifier )
       
    87     {
       
    88     CAknSettingItem* settingItem = NULL;
       
    89 
       
    90     switch (aIdentifier)
       
    91         {
       
    92         case ESettingListCaptureModeSelection:
       
    93             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iCaptureMode);
       
    94             break;
       
    95       
       
    96             
       
    97         case ESettingListSingleCaptureHotkeySelection:
       
    98             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iSingleCaptureHotkey);
       
    99             break;
       
   100         
       
   101         case ESettingListSingleCaptureImageFormatSelection:
       
   102             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iSingleCaptureImageFormat);
       
   103             break;
       
   104         
       
   105         case ESettingListSingleCaptureMemorySelection:
       
   106 #ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
       
   107             settingItem = new(ELeave) CAknMemorySelectionSettingItemMultiDrive(aIdentifier, iGrabSettings.iSingleCaptureMemoryInUseMultiDrive);
       
   108 #else
       
   109             settingItem = new(ELeave) CAknMemorySelectionSettingItem(aIdentifier, iGrabSettings.iSingleCaptureMemoryInUse);
       
   110 #endif
       
   111             break;
       
   112 
       
   113         case ESettingListSingleCaptureFileNameSelection:
       
   114             settingItem = new(ELeave) CAknTextSettingItem(aIdentifier, iGrabSettings.iSingleCaptureFileName);
       
   115             break;
       
   116 
       
   117 
       
   118         case ESettingListSequantialCaptureHotkeySelection:
       
   119             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureHotkey);
       
   120             break;
       
   121         
       
   122         case ESettingListSequantialCaptureImageFormatSelection:
       
   123             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureImageFormat);
       
   124             break;
       
   125 
       
   126         case ESettingListSequantialCaptureDelaySelection:
       
   127             settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureDelay);
       
   128             break;
       
   129                     
       
   130         case ESettingListSequantialCaptureMemorySelection:
       
   131 #ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
       
   132             settingItem = new(ELeave) CAknMemorySelectionSettingItemMultiDrive(aIdentifier, iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive);
       
   133 #else
       
   134             settingItem = new(ELeave) CAknMemorySelectionSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureMemoryInUse);
       
   135 #endif
       
   136             break;
       
   137 
       
   138         case ESettingListSequantialCaptureFileNameSelection:
       
   139             settingItem = new(ELeave) CAknTextSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureFileName);
       
   140             break;
       
   141 
       
   142 
       
   143         case ESettingListVideoCaptureHotkeySelection:
       
   144             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iVideoCaptureHotkey);
       
   145             break;
       
   146         
       
   147         case ESettingListVideoCaptureVideoFormatSelection:
       
   148             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iVideoCaptureVideoFormat);
       
   149             break;
       
   150         
       
   151         case ESettingListVideoCaptureMemorySelection:
       
   152 #ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
       
   153             settingItem = new(ELeave) CAknMemorySelectionSettingItemMultiDrive(aIdentifier, iGrabSettings.iVideoCaptureMemoryInUseMultiDrive);
       
   154 #else
       
   155             settingItem = new(ELeave) CAknMemorySelectionSettingItem(aIdentifier, iGrabSettings.iVideoCaptureMemoryInUse);
       
   156 #endif
       
   157             break;
       
   158 
       
   159         case ESettingListVideoCaptureFileNameSelection:
       
   160             settingItem = new(ELeave) CAknTextSettingItem(aIdentifier, iGrabSettings.iVideoCaptureFileName);
       
   161             break;
       
   162 
       
   163         }
       
   164 
       
   165     return settingItem;
       
   166     }
       
   167 
       
   168 
       
   169 // ---------------------------------------------------------
       
   170 // CScreenGrabberSettingListView::UpdateSettings()
       
   171 // ---------------------------------------------------------
       
   172 //
       
   173 void CScreenGrabberSettingListContainer::UpdateSettingsL()
       
   174     {
       
   175     // get the modified settings to our own variables
       
   176     StoreSettingsL();  // from CAknSettingItemList
       
   177 
       
   178     // store new settings in engine and save the settings in disk
       
   179     TRAP_IGNORE(iModel->SaveSettingsL(iGrabSettings));
       
   180     
       
   181     // Change the keys used for capturing
       
   182     iModel->ActivateCaptureKeysL(ETrue);
       
   183     }
       
   184 
       
   185 
       
   186 // ---------------------------------------------------------
       
   187 // CScreenGrabberSettingListView::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
       
   188 // ---------------------------------------------------------
       
   189 //
       
   190 void CScreenGrabberSettingListContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
   191     {
       
   192     switch (aEventType) 
       
   193         {
       
   194         case EEventEnterKeyPressed:
       
   195         case EEventItemDoubleClicked:
       
   196             ShowSettingPageL(EFalse);
       
   197             break;
       
   198         default:
       
   199             break;
       
   200         }
       
   201     }
       
   202 
       
   203 // ---------------------------------------------------------
       
   204 // CScreenGrabberSettingListView::ShowSettingPageL(TInt aCalledFromMenu)
       
   205 // ---------------------------------------------------------
       
   206 //
       
   207 void CScreenGrabberSettingListContainer::ShowSettingPageL(TInt aCalledFromMenu) 
       
   208     {
       
   209     // open the setting page
       
   210     TInt listIndex = ListBox()->CurrentItemIndex();
       
   211     TInt realIndex = SettingItemArray()->ItemIndexFromVisibleIndex(listIndex);
       
   212     EditItemL(realIndex, aCalledFromMenu);
       
   213 
       
   214     // update and save the settings
       
   215     UpdateSettingsL();
       
   216     
       
   217     // set visibilities
       
   218     SetVisibilitiesOfSettingItems();
       
   219 
       
   220     // refresh the screen 
       
   221     DrawNow();
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------
       
   225 // CScreenGrabberSettingListContainer::SetVisibilitiesOfSettingItems()
       
   226 // ---------------------------------------------------------
       
   227 //
       
   228 void CScreenGrabberSettingListContainer::SetVisibilitiesOfSettingItems() 
       
   229     {
       
   230 
       
   231     switch (iGrabSettings.iCaptureMode)
       
   232         {
       
   233         case ECaptureModeSingleCapture:
       
   234             {
       
   235             ((*SettingItemArray())[ESettingListSingleCaptureHotkeySelection])->SetHidden(EFalse);
       
   236             ((*SettingItemArray())[ESettingListSingleCaptureImageFormatSelection])->SetHidden(EFalse);
       
   237             ((*SettingItemArray())[ESettingListSingleCaptureMemorySelection])->SetHidden(EFalse);
       
   238             ((*SettingItemArray())[ESettingListSingleCaptureFileNameSelection])->SetHidden(EFalse);
       
   239             ((*SettingItemArray())[ESettingListSequantialCaptureHotkeySelection])->SetHidden(ETrue);
       
   240             ((*SettingItemArray())[ESettingListSequantialCaptureImageFormatSelection])->SetHidden(ETrue);
       
   241             ((*SettingItemArray())[ESettingListSequantialCaptureDelaySelection])->SetHidden(ETrue);
       
   242             ((*SettingItemArray())[ESettingListSequantialCaptureMemorySelection])->SetHidden(ETrue);
       
   243             ((*SettingItemArray())[ESettingListSequantialCaptureFileNameSelection])->SetHidden(ETrue);
       
   244             ((*SettingItemArray())[ESettingListVideoCaptureHotkeySelection])->SetHidden(ETrue);
       
   245             ((*SettingItemArray())[ESettingListVideoCaptureVideoFormatSelection])->SetHidden(ETrue);
       
   246             ((*SettingItemArray())[ESettingListVideoCaptureMemorySelection])->SetHidden(ETrue);
       
   247             ((*SettingItemArray())[ESettingListVideoCaptureFileNameSelection])->SetHidden(ETrue);
       
   248             }
       
   249             break;
       
   250         
       
   251         case ECaptureModeSequantialCapture:
       
   252             {
       
   253             ((*SettingItemArray())[ESettingListSingleCaptureHotkeySelection])->SetHidden(ETrue);
       
   254             ((*SettingItemArray())[ESettingListSingleCaptureImageFormatSelection])->SetHidden(ETrue);
       
   255             ((*SettingItemArray())[ESettingListSingleCaptureMemorySelection])->SetHidden(ETrue);
       
   256             ((*SettingItemArray())[ESettingListSingleCaptureFileNameSelection])->SetHidden(ETrue);
       
   257             ((*SettingItemArray())[ESettingListSequantialCaptureHotkeySelection])->SetHidden(EFalse);
       
   258             ((*SettingItemArray())[ESettingListSequantialCaptureImageFormatSelection])->SetHidden(EFalse);
       
   259             ((*SettingItemArray())[ESettingListSequantialCaptureDelaySelection])->SetHidden(EFalse);
       
   260             ((*SettingItemArray())[ESettingListSequantialCaptureMemorySelection])->SetHidden(EFalse);
       
   261             ((*SettingItemArray())[ESettingListSequantialCaptureFileNameSelection])->SetHidden(EFalse);
       
   262             ((*SettingItemArray())[ESettingListVideoCaptureHotkeySelection])->SetHidden(ETrue);
       
   263             ((*SettingItemArray())[ESettingListVideoCaptureVideoFormatSelection])->SetHidden(ETrue);
       
   264             ((*SettingItemArray())[ESettingListVideoCaptureMemorySelection])->SetHidden(ETrue);
       
   265             ((*SettingItemArray())[ESettingListVideoCaptureFileNameSelection])->SetHidden(ETrue);
       
   266             }
       
   267             break;            
       
   268 
       
   269         case ECaptureModeVideoCapture:
       
   270             {
       
   271             ((*SettingItemArray())[ESettingListSingleCaptureHotkeySelection])->SetHidden(ETrue);
       
   272             ((*SettingItemArray())[ESettingListSingleCaptureImageFormatSelection])->SetHidden(ETrue);
       
   273             ((*SettingItemArray())[ESettingListSingleCaptureMemorySelection])->SetHidden(ETrue);
       
   274             ((*SettingItemArray())[ESettingListSingleCaptureFileNameSelection])->SetHidden(ETrue);
       
   275             ((*SettingItemArray())[ESettingListSequantialCaptureHotkeySelection])->SetHidden(ETrue);
       
   276             ((*SettingItemArray())[ESettingListSequantialCaptureImageFormatSelection])->SetHidden(ETrue);
       
   277             ((*SettingItemArray())[ESettingListSequantialCaptureDelaySelection])->SetHidden(ETrue);
       
   278             ((*SettingItemArray())[ESettingListSequantialCaptureMemorySelection])->SetHidden(ETrue);
       
   279             ((*SettingItemArray())[ESettingListSequantialCaptureFileNameSelection])->SetHidden(ETrue);
       
   280             ((*SettingItemArray())[ESettingListVideoCaptureHotkeySelection])->SetHidden(EFalse);
       
   281             ((*SettingItemArray())[ESettingListVideoCaptureVideoFormatSelection])->SetHidden(EFalse);
       
   282             ((*SettingItemArray())[ESettingListVideoCaptureMemorySelection])->SetHidden(EFalse);
       
   283             ((*SettingItemArray())[ESettingListVideoCaptureFileNameSelection])->SetHidden(EFalse);
       
   284             }
       
   285             break;             
       
   286 
       
   287         default:
       
   288             User::Panic(_L("Inv.capt.mode"), 50);
       
   289             break;
       
   290         }
       
   291         
       
   292     HandleChangeInItemArrayOrVisibilityL(); 
       
   293     }
       
   294 
       
   295 // ---------------------------------------------------------
       
   296 // CScreenGrabberSettingListView::HandleResourceChange(TInt aType)
       
   297 // ---------------------------------------------------------
       
   298 //
       
   299 void CScreenGrabberSettingListContainer::HandleResourceChange(TInt aType)
       
   300     {
       
   301     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   302         {
       
   303         TRect mainPaneRect;
       
   304         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   305         SetRect(mainPaneRect);
       
   306 
       
   307         TSize outputRectSize;
       
   308         AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize);
       
   309         TRect outputRect(outputRectSize);
       
   310         ListBox()->SetRect(outputRect);
       
   311         }
       
   312     else
       
   313         {
       
   314         CCoeControl::HandleResourceChange(aType);
       
   315         }
       
   316     }
       
   317 
       
   318 // End of File