|
1 /* |
|
2 * Copyright (c) 2007-2010 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 iNameSelected = QueryValue()->CurrentValueIndex(); |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CGSCamDefaultNameSettingPage::~CGSCamDefaultNameSettingPage |
|
61 // Destructor. |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CGSCamDefaultNameSettingPage::~CGSCamDefaultNameSettingPage() |
|
65 { |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CGSCamDefaultNameSettingPage::OkToExitL |
|
71 // Check if the name base value is ok, so the user can |
|
72 // exit the setting page. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 TBool CGSCamDefaultNameSettingPage::OkToExitL( TBool aAccept ) |
|
76 { |
|
77 if ( aAccept ) |
|
78 { |
|
79 iTempNameBase = iNameBase; |
|
80 |
|
81 if ( QueryValue()->CurrentValueIndex() == ECamNameBaseText ) |
|
82 { |
|
83 // Ensure application is in editing orientation |
|
84 CAknAppUiBase* appUi = |
|
85 static_cast<CAknAppUiBase*>( CCoeEnv::Static()->AppUi() ); |
|
86 |
|
87 // Show the editor dialog |
|
88 TBool editorRet = EFalse; |
|
89 // Trap this to make sure the orientation is reverted back to normal |
|
90 if ( Cba() && !iCamera ) |
|
91 { |
|
92 Cba()->MakeVisible( EFalse ); |
|
93 } |
|
94 TRAPD( leaveErr, editorRet = ShowEditorDialogL() ) |
|
95 if ( Cba() && !iCamera ) |
|
96 { |
|
97 Cba()->MakeVisible( ETrue ); |
|
98 } |
|
99 if ( !editorRet ) |
|
100 { |
|
101 // redraw listbox to update radio button when cancel is pressed |
|
102 ListBoxControl()->DrawNow(); |
|
103 } |
|
104 if ( !iCamera ) |
|
105 { |
|
106 appUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationLandscape ); |
|
107 } |
|
108 else |
|
109 { |
|
110 //appUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationPortrait ); |
|
111 } |
|
112 User::LeaveIfError( leaveErr ); |
|
113 return editorRet; |
|
114 } |
|
115 |
|
116 } |
|
117 else |
|
118 { |
|
119 // Cancelled |
|
120 QueryValue()->SetCurrentValueIndex( iNameSelected ); |
|
121 } |
|
122 return ETrue; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CGSCamDefaultNameSettingPage::ShowEditorDialogL |
|
127 // Display the text editor dialog |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 TBool CGSCamDefaultNameSettingPage::ShowEditorDialogL() |
|
131 { |
|
132 TBool done = EFalse; |
|
133 while ( !done ) |
|
134 { |
|
135 // Show data query |
|
136 HBufC* prompt = NULL; |
|
137 if ( ECamControllerVideo == iMode ) |
|
138 { |
|
139 prompt = StringLoader::LoadLC( R_CAM_QUERY_DEFAULT_VIDEO_NAME ); |
|
140 } |
|
141 else |
|
142 { |
|
143 prompt = StringLoader::LoadLC( R_CAM_QUERY_DEFAULT_IMAGE_NAME ); |
|
144 } |
|
145 |
|
146 CAknTextQueryDialog* nameQuery = |
|
147 CAknTextQueryDialog::NewL( iTempNameBase ); |
|
148 |
|
149 nameQuery->SetMaxLength( KMaxNameBaseLength ); |
|
150 nameQuery->PrepareLC( R_CAM_RENAME_QUERY ); |
|
151 nameQuery->SetPromptL( *prompt ); |
|
152 |
|
153 TBool res = ( nameQuery->RunLD() == EAknSoftkeyOk ); |
|
154 |
|
155 CleanupStack::PopAndDestroy(); // prompt |
|
156 |
|
157 if ( !res ) |
|
158 { |
|
159 // User cancelled the query, return to setting page |
|
160 return EFalse; |
|
161 } |
|
162 |
|
163 // Check base name validity |
|
164 res = CamUtility::CheckFileNameValidityL( iTempNameBase ); |
|
165 |
|
166 if ( res ) |
|
167 { |
|
168 // New name base was valid, exit setting page |
|
169 iNameBase = iTempNameBase; |
|
170 return res; |
|
171 } |
|
172 |
|
173 // Show data query again |
|
174 } |
|
175 // should never get here |
|
176 return EFalse; |
|
177 } |
|
178 // end of file |