camerauis/cameraapp/generic/src/Camdefaultnamesettingpage.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:  Setting item page for default name (text/date).*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "Camdefaultnamesettingpage.h"
       
    21 #include "CamUtility.h"
       
    22 #include "CamAppUi.h"
       
    23 
       
    24 #include <cameraapp.rsg>
       
    25 #include <vgacamsettings.rsg>
       
    26 
       
    27 #include <AknQueryDialog.h>
       
    28 #include <StringLoader.h>
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CCamDefaultNameSettingPage::CCamDefaultNameSettingPage
       
    36 // C++ constructor
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CCamDefaultNameSettingPage::CCamDefaultNameSettingPage(
       
    40     TDes&           aNameBase,
       
    41     TCamCameraMode  aMode,
       
    42     const TDesC*    aSettingTitleText, 
       
    43     TInt            aSettingNumber, 
       
    44     TInt            aControlType,
       
    45     TInt            aEditorResourceId, 
       
    46     TInt            aSettingPageResourceId,
       
    47     MAknQueryValue& aQueryValue )
       
    48     : CAknPopupSettingPage( aSettingTitleText, aSettingNumber,
       
    49                             aControlType, aEditorResourceId,
       
    50                             aSettingPageResourceId,
       
    51                             aQueryValue ),
       
    52       iNameBase( aNameBase ),
       
    53       iMode( aMode )
       
    54     {
       
    55     }
       
    56     
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CCamDefaultNameSettingPage::~CCamDefaultNameSettingPage
       
    60 // Destructor.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CCamDefaultNameSettingPage::~CCamDefaultNameSettingPage()
       
    64     {
       
    65     }
       
    66 
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CCamDefaultNameSettingPage::OkToExitL
       
    70 // Check if the name base value is ok, so the user can
       
    71 // exit the setting page.
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 TBool CCamDefaultNameSettingPage::OkToExitL( TBool aAccept )
       
    75     {
       
    76     if ( aAccept )
       
    77         {
       
    78         iTempNameBase = iNameBase;
       
    79         
       
    80         if ( QueryValue()->CurrentValueIndex() == ECamNameBaseText )
       
    81             {
       
    82             // Ensure application is in editing orientation
       
    83             CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
       
    84             TInt editingOrientation = CAknAppUiBase::EAppUiOrientationUnspecified;
       
    85             TInt error = CamUtility::GetPsiInt( ECamPsiEditingOrientation, editingOrientation );
       
    86             if ( !error )
       
    87                 {
       
    88                 appUi->SwitchOrientationIfRequiredL( editingOrientation );
       
    89                 }  
       
    90             // Show the editor dialog                
       
    91             TBool editorRet = EFalse;  
       
    92             // Trap this to make sure the orientation is reverted back to normal   
       
    93             TRAPD( leaveErr, editorRet = ShowEditorDialogL() )
       
    94             appUi->SwitchOrientationIfRequiredL( CAknAppUiBase::EAppUiOrientationUnspecified );
       
    95             User::LeaveIfError( leaveErr ); 
       
    96             return editorRet;
       
    97             }
       
    98         }
       
    99     return ETrue;
       
   100     }
       
   101  
       
   102 // ---------------------------------------------------------------------------
       
   103 // CCamDefaultNameSettingPage::ShowEditorDialogL
       
   104 // Display the text editor dialog
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 TBool CCamDefaultNameSettingPage::ShowEditorDialogL()    
       
   108     {
       
   109     TBool done = EFalse;
       
   110     while ( !done )
       
   111         {
       
   112         // Show data query
       
   113         HBufC* prompt = NULL;
       
   114         if ( ECamControllerVideo == iMode )
       
   115             {
       
   116             prompt = StringLoader::LoadLC( R_CAM_QUERY_DEFAULT_VIDEO_NAME );
       
   117             }
       
   118         else
       
   119             {
       
   120             prompt = StringLoader::LoadLC( R_CAM_QUERY_DEFAULT_IMAGE_NAME );
       
   121             }
       
   122 
       
   123         CAknTextQueryDialog* nameQuery = 
       
   124                     CAknTextQueryDialog::NewL( iTempNameBase );
       
   125 
       
   126         nameQuery->SetMaxLength( KMaxNameBaseLength );
       
   127         nameQuery->PrepareLC( R_CAM_RENAME_QUERY );
       
   128         nameQuery->SetPromptL( *prompt );
       
   129 
       
   130         TBool res = ( nameQuery->RunLD() == EAknSoftkeyOk );
       
   131 
       
   132         CleanupStack::PopAndDestroy(); // prompt
       
   133 
       
   134         if ( !res )
       
   135             {
       
   136             // User cancelled the query, return to setting page
       
   137             return EFalse;
       
   138             }
       
   139 
       
   140         // Check base name validity
       
   141         res = CamUtility::CheckFileNameValidityL( iTempNameBase );
       
   142 
       
   143         if ( res )
       
   144             {
       
   145             // New name base was valid, exit setting page
       
   146             iNameBase = iTempNameBase;
       
   147             return res;
       
   148             }
       
   149 
       
   150         // Show data query again
       
   151         }
       
   152     // should never get here        
       
   153     return EFalse;
       
   154     }
       
   155 // end of file