|
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 |
|
21 #include <aknViewAppUi.h> |
|
22 #include <gscamerapluginrsc.rsg> |
|
23 #include <AknQueryDialog.h> |
|
24 #include <StringLoader.h> |
|
25 #include "CamSettingsInternal.hrh" |
|
26 #include "GSCamdefaultnamesettingpage.h" |
|
27 #include "CamUtility.h" |
|
28 // CONSTANTS |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CGSCamDefaultNameSettingPage::CGSCamDefaultNameSettingPage |
|
34 // C++ constructor |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CGSCamDefaultNameSettingPage::CGSCamDefaultNameSettingPage( |
|
38 TDes& aNameBase, |
|
39 TCamCameraMode aMode, |
|
40 const TDesC* aSettingTitleText, |
|
41 TInt aSettingNumber, |
|
42 TInt aControlType, |
|
43 TInt aEditorResourceId, |
|
44 TInt aSettingPageResourceId, |
|
45 MAknQueryValue& aQueryValue, |
|
46 TBool aCamera ) |
|
47 : CAknPopupSettingPage( aSettingTitleText, aSettingNumber, |
|
48 aControlType, aEditorResourceId, |
|
49 aSettingPageResourceId, |
|
50 aQueryValue ), |
|
51 iNameBase( aNameBase ), |
|
52 iMode( aMode ), |
|
53 iCamera ( aCamera ) |
|
54 { |
|
55 } |
|
56 |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CGSCamDefaultNameSettingPage::~CGSCamDefaultNameSettingPage |
|
60 // Destructor. |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CGSCamDefaultNameSettingPage::~CGSCamDefaultNameSettingPage() |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CGSCamDefaultNameSettingPage::OkToExitL |
|
70 // Check if the name base value is ok, so the user can |
|
71 // exit the setting page. |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 TBool CGSCamDefaultNameSettingPage::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 CAknAppUiBase* appUi = |
|
84 static_cast<CAknAppUiBase*>( CCoeEnv::Static()->AppUi() ); |
|
85 |
|
86 // Show the editor dialog |
|
87 TBool editorRet = EFalse; |
|
88 // Trap this to make sure the orientation is reverted back to normal |
|
89 TRAPD( leaveErr, editorRet = ShowEditorDialogL() ) |
|
90 if ( !editorRet ) |
|
91 { |
|
92 // redraw listbox to update radio button when cancel is pressed |
|
93 ListBoxControl()->DrawNow(); |
|
94 } |
|
95 if ( !iCamera ) |
|
96 { |
|
97 appUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationLandscape ); |
|
98 } |
|
99 else |
|
100 { |
|
101 //appUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationPortrait ); |
|
102 } |
|
103 User::LeaveIfError( leaveErr ); |
|
104 return editorRet; |
|
105 } |
|
106 |
|
107 } |
|
108 return ETrue; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CGSCamDefaultNameSettingPage::ShowEditorDialogL |
|
113 // Display the text editor dialog |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 TBool CGSCamDefaultNameSettingPage::ShowEditorDialogL() |
|
117 { |
|
118 TBool done = EFalse; |
|
119 while ( !done ) |
|
120 { |
|
121 // Show data query |
|
122 HBufC* prompt = NULL; |
|
123 if ( ECamControllerVideo == iMode ) |
|
124 { |
|
125 prompt = StringLoader::LoadLC( R_CAM_QUERY_DEFAULT_VIDEO_NAME ); |
|
126 } |
|
127 else |
|
128 { |
|
129 prompt = StringLoader::LoadLC( R_CAM_QUERY_DEFAULT_IMAGE_NAME ); |
|
130 } |
|
131 |
|
132 CAknTextQueryDialog* nameQuery = |
|
133 CAknTextQueryDialog::NewL( iTempNameBase ); |
|
134 |
|
135 nameQuery->SetMaxLength( KMaxNameBaseLength ); |
|
136 nameQuery->PrepareLC( R_CAM_RENAME_QUERY ); |
|
137 nameQuery->SetPromptL( *prompt ); |
|
138 |
|
139 TBool res = ( nameQuery->RunLD() == EAknSoftkeyOk ); |
|
140 |
|
141 CleanupStack::PopAndDestroy(); // prompt |
|
142 |
|
143 if ( !res ) |
|
144 { |
|
145 // User cancelled the query, return to setting page |
|
146 return EFalse; |
|
147 } |
|
148 |
|
149 // Check base name validity |
|
150 res = CamUtility::CheckFileNameValidityL( iTempNameBase ); |
|
151 |
|
152 if ( res ) |
|
153 { |
|
154 // New name base was valid, exit setting page |
|
155 iNameBase = iTempNameBase; |
|
156 return res; |
|
157 } |
|
158 |
|
159 // Show data query again |
|
160 } |
|
161 // should never get here |
|
162 return EFalse; |
|
163 } |
|
164 // end of file |