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 type for "Add to album"* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <cameraapp.mbg> |
|
22 #include <gscamerapluginrsc.rsg> |
|
23 |
|
24 #include "CamAlbumSettingItem.h" |
|
25 #include "CamSettings.hrh" |
|
26 #include "CamUtility.h" |
|
27 #include "CameraappPrivateCRKeys.h" |
|
28 #include "CamStaticSettingsModel.h" |
|
29 #include "camerauiconfigmanager.h" |
|
30 #include "CamAppUiBase.h" |
|
31 #include "GSCamcorderPlugin.h" |
|
32 |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CCamAlbumSettingItem::CCamAlbumSettingItem |
|
38 // Two phase construction |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CCamAlbumSettingItem::CCamAlbumSettingItem( TInt aSettingItemId, |
|
42 TInt& aValue) |
|
43 : CAknEnumeratedTextPopupSettingItem( aSettingItemId, aValue ) |
|
44 { |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // Destructor |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CCamAlbumSettingItem::~CCamAlbumSettingItem() |
|
52 { |
|
53 PRINT( _L("Camera => ~CCamAlbumSettingItem") ); |
|
54 PRINT( _L("Camera <= ~CCamAlbumSettingItem") ); |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CCamAlbumSettingItem::HandleSettingPageEventL |
|
59 // Handle events in the setting page |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CCamAlbumSettingItem::HandleSettingPageEventL( CAknSettingPage* /*aSettingPage*/, |
|
63 TAknSettingPageEvent aEventType ) |
|
64 { |
|
65 // Get the value of the currently selected item on the setting page |
|
66 MAknQueryValue* settingPageValues = QueryValue(); |
|
67 TInt selectedIndex = settingPageValues->CurrentValueIndex(); |
|
68 CArrayPtr<CAknEnumeratedText>* items = EnumeratedTextArray(); |
|
69 TInt selectedValue = items->At( selectedIndex )->EnumerationValue(); |
|
70 |
|
71 // If the user has Okayed the "Yes" option. |
|
72 if ( aEventType == EEventSettingOked && selectedValue == ECamSettYes ) |
|
73 { |
|
74 // Launch the album selection list popup |
|
75 DisplayAlbumSelectionListL(); |
|
76 } |
|
77 UpdateListBoxTextL(); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CCamAlbumSettingItem::CompleteConstructionL |
|
82 // Gets the correct text for a currently selected album |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CCamAlbumSettingItem::CompleteConstructionL() |
|
86 { |
|
87 PRINT( _L("Camera => CCamAlbumSettingItem::CompleteConstructionL") ); |
|
88 CAknEnumeratedTextPopupSettingItem::CompleteConstructionL(); |
|
89 if ( ExternalValue() == ECamSettYes ) |
|
90 { |
|
91 // We update the list box only if the setting item is true |
|
92 // In this case, we stop displaying "Yes" and replace it with |
|
93 // current album name. |
|
94 UpdateListTextL(); |
|
95 } |
|
96 PRINT( _L("Camera <= CCamAlbumSettingItem::CompleteConstructionL") ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CCamAlbumSettingItem::UpdateListTextL |
|
101 // Update the text in the setting list to show the current capture album name |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 void CCamAlbumSettingItem::UpdateListTextL() |
|
105 { |
|
106 PRINT( _L("Camera => CCamAlbumSettingItem::UpdateListTextL") ); |
|
107 |
|
108 CAknViewAppUi *AppUi = static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() ); |
|
109 CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> |
|
110 ( AppUi->View( KGSCamcorderGSPluginUid ) ); |
|
111 // If "Add to album" is on |
|
112 if ( ExternalValue() == ECamSettYes ) |
|
113 { |
|
114 // A default capture album exists |
|
115 // Replace the "Yes" text with the current capture album name |
|
116 CArrayPtr<CAknEnumeratedText>* itemArray = EnumeratedTextArray(); |
|
117 TInt numberOfItems = itemArray->Count(); // item count |
|
118 TInt index = 0; |
|
119 TBool found = EFalse; |
|
120 while ( !found && index < numberOfItems ) |
|
121 { |
|
122 TInt value = itemArray->At( index )->EnumerationValue(); |
|
123 // This is the "Yes" option |
|
124 if ( value == ECamSettYes ) |
|
125 { |
|
126 // Replace the text with the album name |
|
127 // We get the album name from CenRep key |
|
128 HBufC* albumName = parent->TextSettingValue( |
|
129 ECamSettingItemDefaultAlbumName ).AllocLC(); |
|
130 |
|
131 CAknEnumeratedText* newItem = new( ELeave ) |
|
132 CAknEnumeratedText( value, albumName ); |
|
133 CleanupStack::Pop( albumName ); |
|
134 CleanupStack::PushL( newItem ); |
|
135 CAknEnumeratedText* oldItem = itemArray->At( index ); |
|
136 itemArray->Delete( index ); |
|
137 delete oldItem; |
|
138 oldItem = NULL; |
|
139 itemArray->InsertL( index, newItem ); |
|
140 CleanupStack::Pop( newItem ); |
|
141 found = ETrue; |
|
142 } |
|
143 index++; |
|
144 } |
|
145 } // End of ExternalValue |
|
146 UpdateListBoxTextL(); |
|
147 PRINT( _L("Camera <= CCamAlbumSettingItem::UpdateListTextL C") ); |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CCamAlbumSettingItem::DisplayAlbumSelectionListL |
|
152 // Launch the album selection list popup |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CCamAlbumSettingItem::DisplayAlbumSelectionListL() |
|
156 { |
|
157 |
|
158 CAknViewAppUi *AppUi = static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() ); |
|
159 CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> |
|
160 ( AppUi->View( KGSCamcorderGSPluginUid ) ); |
|
161 // Launch the Pop-up menu using the Gallery API |
|
162 // allowMultipleSelection = ETrue --> Multiple Selection |
|
163 // allowMultipleSelection = EFalse --> Single Selection |
|
164 TBool allowMultipleSelection = EFalse; |
|
165 RArray<TUint32> selectedAlbumIds; |
|
166 CleanupClosePushL( selectedAlbumIds ); |
|
167 // Launching the Pop-up menu with the list of albums |
|
168 TRAPD ( err, TGlxCollectionSelectionPopup::ShowPopupL( |
|
169 selectedAlbumIds, |
|
170 KGlxCollectionTypeIdAlbum, |
|
171 allowMultipleSelection, |
|
172 ETrue |
|
173 ) ); |
|
174 |
|
175 TInt defaultAlbumId = 0; // default album id in CenRep |
|
176 |
|
177 TInt prevDefaultId = parent->IntegerSettingValue( |
|
178 ECamSettingItemDefaultAlbumId ); |
|
179 if ( selectedAlbumIds.Count() > 0 && err == KErrNone ) |
|
180 { |
|
181 // this is the new album which is set as default |
|
182 defaultAlbumId = static_cast<TInt>( selectedAlbumIds[0] ); |
|
183 } |
|
184 else if ( prevDefaultId != 0 ) |
|
185 { |
|
186 // UseCase: If the user selects cancel when the pop-up active |
|
187 // we then go back to the prev album selected |
|
188 defaultAlbumId = prevDefaultId; |
|
189 } |
|
190 else |
|
191 { |
|
192 } |
|
193 CleanupStack::PopAndDestroy( &selectedAlbumIds ); |
|
194 |
|
195 parent->SetIntegerSettingValueL( ECamSettingItemDefaultAlbumId, |
|
196 defaultAlbumId ); |
|
197 |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CCamAlbumSettingItem::HandleAlbumError |
|
202 // Deal with loss of capture album or album information |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CCamAlbumSettingItem::HandleAlbumError() |
|
206 { |
|
207 // Set "Add to album" off |
|
208 SetInternalValue( ECamSettNo ); |
|
209 SetExternalValue( ECamSettNo ); |
|
210 } |
|
211 |
|
212 // End of File |
|