1 /* |
1 /* |
2 * Copyright (c) 2010 Ixonos Plc. |
2 * Copyright (c) 2010 Ixonos Plc. |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the "Eclipse Public License v1.0" |
5 * under the terms of the "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - Initial contribution |
10 * Nokia Corporation - Initial contribution |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * Ixonos Plc |
13 * Ixonos Plc |
14 * |
14 * |
15 * Description: |
15 * Description: |
16 * Image Editor AppUI class. |
16 * Image Editor AppUI class. |
17 * |
17 * |
18 */ |
18 */ |
19 |
|
20 |
|
21 // INCLUDE FILES |
19 // INCLUDE FILES |
22 #include <fbs.h> |
20 #include <fbs.h> |
23 #include <f32file.h> |
21 #include <f32file.h> |
24 #include <badesca.h> |
22 #include <badesca.h> |
25 #include <bautils.h> |
23 #include <bautils.h> |
26 #include <e32math.h> |
24 #include <e32math.h> |
27 |
|
28 #include <aknnotifystd.h> |
25 #include <aknnotifystd.h> |
29 #include <aknwaitdialog.h> |
26 #include <aknwaitdialog.h> |
30 #include <AknGlobalNote.h> |
27 #include <AknGlobalNote.h> |
31 #include <eikprogi.h> |
28 #include <eikprogi.h> |
32 #include <sendui.h> |
29 #include <sendui.h> |
33 #include <hlplch.h> |
30 #include <hlplch.h> |
34 #include <aknnotewrappers.h> |
31 #include <aknnotewrappers.h> |
35 #include <CMessageData.h> |
32 #include <CMessageData.h> |
36 #include <e32property.h> |
33 #include <e32property.h> |
37 |
|
38 #include <AknDlgShut.h> |
34 #include <AknDlgShut.h> |
39 #include <CAknFileNamePromptDialog.h> |
35 #include <CAknFileNamePromptDialog.h> |
40 #include <CAknMemorySelectionDialog.h> |
36 #include <CAknMemorySelectionDialog.h> |
41 #include <PathInfo.h> |
37 #include <PathInfo.h> |
42 #include <csxhelp/sie.hlp.hrh> |
38 #include <csxhelp/sie.hlp.hrh> |
43 |
|
44 #ifdef VERBOSE |
39 #ifdef VERBOSE |
45 #include <eikenv.h> |
40 #include <eikenv.h> |
46 #endif |
41 #endif |
47 |
|
48 #include <AknCommonDialogsDynMem.h> |
42 #include <AknCommonDialogsDynMem.h> |
49 #include <CAknMemorySelectionDialogMultiDrive.h> |
43 #include <CAknMemorySelectionDialogMultiDrive.h> |
50 |
|
51 #include <ImageEditor.rsg> |
44 #include <ImageEditor.rsg> |
52 #include "ImageEditorUI.hrh" |
45 #include "ImageEditorUI.hrh" |
53 #include "ImageEditorPanics.h" |
46 #include "ImageEditorPanics.h" |
54 |
|
55 #include "imageeditoruids.hrh" |
47 #include "imageeditoruids.hrh" |
56 #include "commondefs.h" |
48 #include "commondefs.h" |
57 //#include "platform_security_literals.hrh" |
|
58 |
|
59 #include "ImageEditorApp.h" |
49 #include "ImageEditorApp.h" |
60 #include "ImageEditorAppUi.h" |
50 #include "ImageEditorAppUi.h" |
61 #include "ImageEditorUIView.h" |
51 #include "ImageEditorUIView.h" |
62 #include "ImageEditorUI.hrh" |
52 #include "ImageEditorUI.hrh" |
63 #include "ImageEditorError.h" |
53 #include "ImageEditorError.h" |
64 #include "PluginInfo.h" |
54 #include "PluginInfo.h" |
65 |
|
66 #include "ImageEditorPluginLocator.h" |
55 #include "ImageEditorPluginLocator.h" |
67 #include "ImageEditorPluginManager.h" |
56 #include "ImageEditorPluginManager.h" |
68 #include "ImageEditorImageController.h" |
57 #include "ImageEditorImageController.h" |
69 |
58 #include "ImageEditorUIContainer.h" |
70 #include "ImageEditorUtils.h" |
59 #include "ImageEditorUtils.h" |
71 #include "ResolutionUtil.h" |
60 #include "ResolutionUtil.h" |
72 #include "Callback.h" |
61 #include "Callback.h" |
73 |
62 |
74 |
|
75 // CONSTANTS |
63 // CONSTANTS |
76 |
|
77 // Panic category |
64 // Panic category |
78 _LIT(KComponentName, "ImageEditorAppUi"); |
65 _LIT(KComponentName, "ImageEditorAppUi"); |
79 |
66 _LIT(KDrawPlugin,"draw.pgn"); |
80 const TInt KObConstructCallBackID = 1; |
67 _LIT(KNull,""); |
81 const TInt KObInitPluginID = 1000; |
68 |
82 const TInt KObReturnFromPluginID = 1001; |
69 const TInt KObConstructCallBackID = 1; |
83 const TInt KObCancelCallbackID = 1002; |
70 const TInt KObInitPluginID = 1000; |
84 const TInt KObUndoDCallbackID = 1003; |
71 const TInt KObReturnFromPluginID = 1001; |
85 const TInt KObSendCallbackID = 1004; |
72 const TInt KObCancelCallbackID = 1002; |
86 const TInt KObPrintCallbackID = 1005; |
73 const TInt KObUndoDCallbackID = 1003; |
87 const TInt KObSaveCallbackID = 1006; |
74 const TInt KObSendCallbackID = 1004; |
|
75 const TInt KObPrintCallbackID = 1005; |
|
76 const TInt KObSaveCallbackID = 1006; |
88 |
77 |
89 //============================================================================= |
78 //============================================================================= |
90 CImageEditorAppUi::CImageEditorAppUi() : |
79 CImageEditorAppUi::CImageEditorAppUi() : |
91 // Initialize application flags and variables |
80 // Initialize application flags and variables |
92 iDocumentName(), |
81 iDocumentName(), iSourceFileName(), iImageSaved(EFalse), |
93 iSourceFileName(), |
82 iForeground(ETrue), iExitFromApp(EFalse), iSaveOnExit(ETrue), |
94 iImageSaved (EFalse), |
83 iSysExit(EFalse), iBusy(ETrue), iOrientationChanged(EFalse), |
95 iForeground (ETrue), |
84 iSaving(EFalse), iSending(EFalse), iPrinting(EFalse), iCancelling( |
96 iExitFromApp (EFalse), |
85 EFalse), iFullScreen(EFalse), iPluginsScanned(EFalse), |
97 iSaveOnExit (ETrue), |
86 iImageLoaded(EFalse), iEditorReady(EFalse), iCancelTextInputActive( |
98 iSysExit (EFalse), |
87 EFalse), iProcessPriorityAltered(EFalse) |
99 iBusy (ETrue), |
88 { |
100 iOrientationChanged (EFalse), |
89 |
101 iSaving (EFalse), |
90 } |
102 iSending (EFalse), |
|
103 iPrinting (EFalse), |
|
104 iCancelling (EFalse), |
|
105 iFullScreen (EFalse), |
|
106 iPluginsScanned (EFalse), |
|
107 iImageLoaded (EFalse), |
|
108 iEditorReady (EFalse), |
|
109 iCancelTextInputActive (EFalse), |
|
110 iProcessPriorityAltered (EFalse) |
|
111 { |
|
112 |
|
113 } |
|
114 |
91 |
115 //============================================================================= |
92 //============================================================================= |
116 void CImageEditorAppUi::ConstructL() |
93 void CImageEditorAppUi::ConstructL() |
117 { |
94 { |
118 LOG(KImageEditorLogFile, "CImageEditorAppUi::ConstructL"); |
95 LOG(KImageEditorLogFile, "CImageEditorAppUi::ConstructL"); |
119 |
96 |
120 // Initialize UI with standard values, read application resource file, |
97 // Initialize UI with standard values, read application resource file, |
121 // read default document |
98 // read default document |
122 |
99 |
123 #ifdef LANDSCAPE_ONLY |
100 #ifdef LANDSCAPE_ONLY |
124 BaseConstructL( EAppOrientationLandscape | EAknEnableSkin | EAknEnableMSK ); |
101 BaseConstructL( EAppOrientationLandscape | EAknEnableSkin | EAknEnableMSK ); |
125 #else |
102 #else |
126 #ifdef LANDSCAPE_SUPPORT |
103 #ifdef LANDSCAPE_SUPPORT |
127 BaseConstructL( EAppOrientationAutomatic|EAknEnableSkin | EAknEnableMSK ); |
104 BaseConstructL(EAppOrientationAutomatic | EAknEnableSkin | EAknEnableMSK); |
128 #else |
105 #else |
129 BaseConstructL( EAknEnableSkin | EAknEnableMSK ); |
106 BaseConstructL( EAknEnableSkin | EAknEnableMSK ); |
130 #endif |
107 #endif |
131 #endif // LANDSCAPE_SUPPORT |
108 #endif // LANDSCAPE_SUPPORT |
132 |
109 // Set busy |
133 // Set busy |
110 SetBusy(); |
134 SetBusy(); |
111 |
135 |
112 // Create main view |
136 // Create main view |
113 CImageEditorUIView * view = new (ELeave) CImageEditorUIView; |
137 CImageEditorUIView * view = new (ELeave) CImageEditorUIView; |
114 CleanupStack::PushL(view); |
138 CleanupStack::PushL (view); |
115 view->ConstructL(); |
139 view->ConstructL(); |
116 view->ConstructMenuAndCbaEarlyL(); |
140 view->ConstructMenuAndCbaEarlyL(); |
|
141 iEditorView = view; |
117 iEditorView = view; |
142 AddViewL (view); // transfers ownership |
118 AddViewL(view); // transfers ownership |
143 CleanupStack::Pop(); // view |
119 CleanupStack::Pop(); // view |
144 LOG (KImageEditorLogFile, "CImageEditorAppUi: Main view created"); |
120 LOG (KImageEditorLogFile, "CImageEditorAppUi: Main view created"); |
145 |
121 |
146 // Activate view |
122 // Activate view |
147 ActivateLocalViewL ( iEditorView->Id() ); |
123 ActivateLocalViewL(iEditorView->Id()); |
148 LOG(KImageEditorLogFile, "CImageEditorAppUi: View activated"); |
124 LOG(KImageEditorLogFile, "CImageEditorAppUi: View activated"); |
149 |
125 |
150 // Set default navi pane text |
126 // Set default navi pane text |
151 ClearTitlePaneTextL(); |
127 ClearTitlePaneTextL(); |
152 ClearNaviPaneTextL(); |
128 ClearNaviPaneTextL(); |
153 |
129 |
154 // Create CObCallback instance |
130 // Create CObCallback instance |
155 iConstructionState = EConstructionStateAlloc; |
131 iConstructionState = EConstructionStateAlloc; |
156 iCallback = CObCallback::NewL ( (MObCallbackMethod *)this ); |
132 iCallback = CObCallback::NewL((MObCallbackMethod *) this); |
157 iCallback->DoCallback (KObConstructCallBackID); |
133 iCallback->DoCallback(KObConstructCallBackID); |
158 |
134 |
159 // Volume key observer instance |
135 // Volume key observer instance |
160 iVolumeKeyObserver = CImageEditorRemConObserver::NewL( *this ); |
136 iVolumeKeyObserver = CImageEditorRemConObserver::NewL(*this); |
161 |
137 |
|
138 iStandby = EFalse; |
162 #ifdef S60_31_VOLUME_KEYS |
139 #ifdef S60_31_VOLUME_KEYS |
163 iMGXRemConTarget = CMGXRemConTarget::NewL( this ); |
140 iMGXRemConTarget = CMGXRemConTarget::NewL( this ); |
164 #endif |
141 #endif |
165 } |
142 } |
166 |
143 |
167 //============================================================================= |
144 //============================================================================= |
168 CImageEditorAppUi::~CImageEditorAppUi() |
145 CImageEditorAppUi::~CImageEditorAppUi() |
169 { |
146 { |
170 LOG(KImageEditorLogFile, "CImageEditorAppUi::~CImageEditorAppUi() starting..."); |
147 LOG(KImageEditorLogFile, "CImageEditorAppUi::~CImageEditorAppUi() starting..."); |
171 |
148 |
172 //KillWaitNote(); |
149 //KillWaitNote(); |
173 if (iWaitNote != NULL) |
150 if (iWaitNote != NULL) |
174 { |
151 { |
175 delete iWaitNote; |
152 delete iWaitNote; |
176 iWaitNote = NULL; |
153 iWaitNote = NULL; |
177 } |
154 } |
178 |
155 |
179 delete iLocator; |
156 delete iLocator; |
180 delete iImageController; |
157 delete iImageController; |
181 delete iEditorManager; |
158 delete iEditorManager; |
182 delete iSendAppUi; |
159 delete iSendAppUi; |
183 delete iCallback; |
160 delete iCallback; |
184 iSourceImageMgAlbumIdList.Close(); |
161 iSourceImageMgAlbumIdList.Close(); |
185 |
162 |
186 iEditorView = NULL; |
163 iEditorView = NULL; |
187 |
164 |
188 iFile.Close(); |
165 iFile.Close(); |
189 |
166 |
190 #ifdef S60_31_VOLUME_KEYS |
167 #ifdef S60_31_VOLUME_KEYS |
191 delete iMGXRemConTarget; |
168 delete iMGXRemConTarget; |
192 #endif |
169 #endif |
193 |
170 |
194 // deleted by CCoeEnv |
171 // deleted by CCoeEnv |
195 iResolutionUtil = NULL; |
172 iResolutionUtil = NULL; |
196 delete iVolumeKeyObserver; |
173 delete iVolumeKeyObserver; |
197 |
174 |
198 LOG(KImageEditorLogFile, "CImageEditorAppUi: AppUi deleted"); |
175 LOG(KImageEditorLogFile, "CImageEditorAppUi: AppUi deleted"); |
199 } |
176 } |
200 |
177 |
201 //============================================================================= |
178 //============================================================================= |
202 void CImageEditorAppUi::OperationReadyL ( |
179 void CImageEditorAppUi::OperationReadyL(TOperationCode aOpId, TInt aError) |
203 TOperationCode aOpId, |
180 { |
204 TInt aError |
181 LOGFMT2(KImageEditorLogFile, "CImageEditorAppUi:OperationReadyL (aOpId:%d, aError:%d)", (TInt)aOpId, aError); |
205 ) |
182 |
206 { |
183 // Kill wait note |
207 LOGFMT2(KImageEditorLogFile, "CImageEditorAppUi:OperationReadyL (aOpId:%d, aError:%d)", (TInt)aOpId, aError); |
184 KillWaitNote(); |
208 |
185 |
209 // Kill wait note |
186 // Handle error |
210 KillWaitNote(); |
187 if (aError != KErrNone) |
211 |
188 { |
212 // Handle error |
189 switch (aOpId) |
213 if ( aError != KErrNone ) |
190 { |
214 { |
|
215 switch ( aOpId ) |
|
216 { |
|
217 case EOperationCodeLoad: |
191 case EOperationCodeLoad: |
218 case EOperationCodeBlockLoad: |
192 case EOperationCodeBlockLoad: |
219 case EOperationCodeSearch: |
193 case EOperationCodeSearch: |
220 { |
194 { |
221 |
195 |
222 if (KErrCancel == aError) |
196 if (KErrCancel == aError) |
223 { |
197 { |
224 // Loading image was cancelled. |
198 // Loading image was cancelled. |
225 User::Leave (KSIEEErrorOkToExit); |
199 User::Leave(KSIEEErrorOkToExit); |
226 } |
200 } |
227 else |
201 else |
228 { |
202 { |
229 User::Leave (KSIEEOpenFile); |
203 User::Leave(KSIEEOpenFile); |
230 } |
204 } |
231 break; |
205 break; |
232 } |
206 } |
233 case EOperationCodeSave: |
207 case EOperationCodeSave: |
234 case EOperationCodeBlockSave: |
208 case EOperationCodeBlockSave: |
235 { |
209 { |
236 LOG(KImageEditorLogFile, "CImageEditorAppUi: Save cancelled"); |
210 LOG(KImageEditorLogFile, "CImageEditorAppUi: Save cancelled"); |
237 #ifdef VERBOSE |
211 #ifdef VERBOSE |
238 LOGFMT3(KImageEditorLogFile, "\tiSourceFileName: %S, iDocumentName: %S, iTempSaveFileName: %S", &iSourceFileName, &iDocumentName, &iTempSaveFileName); |
212 LOGFMT3(KImageEditorLogFile, "\tiSourceFileName: %S, iDocumentName: %S, iTempSaveFileName: %S", &iSourceFileName, &iDocumentName, &iTempSaveFileName); |
239 #endif |
213 #endif |
240 |
214 |
241 iSaving = EFalse; |
215 iSaving = EFalse; |
242 |
216 |
243 // delete the temporary files |
217 // delete the temporary files |
244 DeleteTempFiles(); |
218 DeleteTempFiles(); |
245 |
219 |
246 // Reset bitmap sink and screen size |
220 // Reset bitmap sink and screen size |
247 UpdateScreenRectL(); |
221 UpdateScreenRectL(); |
248 iOrientationChanged = EFalse; |
222 iOrientationChanged = EFalse; |
249 |
223 |
250 |
224 if (!iExitFromApp) |
251 if (!iExitFromApp) |
225 { |
252 { |
226 |
253 |
227 if (iSending) |
254 if (iSending) |
228 { |
255 { |
229 // Restore document name |
256 // Restore document name |
230 iEditorManager->SetImageName(iDocumentName); |
257 iEditorManager->SetImageName (iDocumentName); |
231 iSending = EFalse; |
258 iSending = EFalse; |
232 } |
259 } |
233 if (KErrCancel == aError) |
260 if (KErrCancel == aError) |
234 { |
261 { |
235 // KErrCancel means user cancel, not an error. |
262 // KErrCancel means user cancel, not an error. |
236 ResetBusy(); |
263 ResetBusy(); |
237 } |
264 } |
238 else |
265 else |
239 { |
266 { |
240 // Leave in case of error. |
267 // Leave in case of error. |
241 User::Leave(KSIEESaveFile); |
268 User::Leave (KSIEESaveFile); |
242 } |
269 } |
243 } |
270 } |
244 else |
271 else |
245 { |
272 { |
246 TInt exit = 0; |
273 TInt exit = 0; |
247 if (iSaveOnExit) |
274 if (iSaveOnExit) |
248 { |
275 { |
249 exit |
276 exit = ((CImageEditorUIView *)iEditorView)->LaunchExitWithoutSavingQueryL(); |
250 = ((CImageEditorUIView *) iEditorView)->LaunchExitWithoutSavingQueryL(); |
277 } |
251 } |
278 |
252 |
279 if (exit == EImageEditorSoftkeyCmdYes || !iSaveOnExit) |
253 if (exit == EImageEditorSoftkeyCmdYes || !iSaveOnExit) |
280 { |
254 { |
281 // If the image has not been saved before, the reserved target |
255 // If the image has not been saved before, the reserved target |
282 // file has zero size and can be deleted. |
256 // file has zero size and can be deleted. |
283 TEntry entry; |
257 TEntry entry; |
284 TInt err = iEikonEnv->FsSession().Entry( iDocumentName, entry ); |
258 TInt err = iEikonEnv->FsSession().Entry(iDocumentName, |
285 if ( err == KErrNone && entry.iSize == 0 ) |
259 entry); |
286 { |
260 if (err == KErrNone && entry.iSize == 0) |
287 BaflUtils::DeleteFile (iEikonEnv->FsSession(), iDocumentName); |
261 { |
288 } |
262 BaflUtils::DeleteFile(iEikonEnv->FsSession(), |
289 |
263 iDocumentName); |
290 // Exit the application |
264 } |
291 User::Leave (KSIEEErrorOkToExit); |
265 |
292 } |
266 // Exit the application |
293 else |
267 User::Leave(KSIEEErrorOkToExit); |
294 { |
268 } |
295 iExitFromApp = EFalse; |
269 else |
296 ResetBusy(); |
270 { |
297 } |
271 iExitFromApp = EFalse; |
298 } |
272 ResetBusy(); |
299 SetOrientationL(EAppUiOrientationUnspecified); |
273 } |
300 break; |
274 } |
301 } |
275 SetOrientationL(EAppUiOrientationUnspecified); |
302 default: |
276 break; |
303 { |
277 } |
304 User::Leave (aError); |
278 default: |
305 break; |
279 { |
306 } |
280 User::Leave(aError); |
307 } |
281 break; |
308 } |
282 } |
|
283 } |
|
284 } |
309 else |
285 else |
310 { |
286 { |
311 switch ( aOpId ) |
287 switch (aOpId) |
312 { |
288 { |
313 |
289 |
314 case EOperationCodeLoad: |
290 case EOperationCodeLoad: |
315 case EOperationCodeBlockLoad: |
291 case EOperationCodeBlockLoad: |
316 { |
292 { |
317 LOG(KImageEditorLogFile, "CImageEditorAppUi: Image loaded"); |
293 LOG(KImageEditorLogFile, "CImageEditorAppUi: Image loaded"); |
318 |
294 |
319 // Find out whether the source file belongs to any albums |
295 // Find out whether the source file belongs to any albums |
320 ImageEditorUtils::FindAlbumsForImageFileL ( |
296 ImageEditorUtils::FindAlbumsForImageFileL( |
321 iSourceImageMgAlbumIdList, |
297 iSourceImageMgAlbumIdList, iSourceFileName); |
322 iSourceFileName ); |
298 |
323 |
299 // Generate the name for the saved file |
324 // Generate the name for the saved file |
300 TInt err = ImageEditorUtils::GenerateNewDocumentNameL( |
325 TInt err = ImageEditorUtils::GenerateNewDocumentNameL ( |
301 iEikonEnv->FsSession(), iSourceFileName, iDocumentName, |
326 iEikonEnv->FsSession(), |
302 &iSourceImageMgAlbumIdList); |
327 iSourceFileName, |
|
328 iDocumentName, |
|
329 &iSourceImageMgAlbumIdList ); |
|
330 |
303 |
331 // Delete old temp files, which could exist if the exit was not clean |
304 // Delete old temp files, which could exist if the exit was not clean |
332 DeleteTempFiles(); |
305 DeleteTempFiles(); |
333 |
306 |
334 // If there is not enough disk space to save the edited image, show |
307 // If there is not enough disk space to save the edited image, show |
335 // error note but continue anyway (user can free up memory before saving) |
308 // error note but continue anyway (user can free up memory before saving) |
336 if (KSIEENotEnoughDiskSpace == err) |
309 if (KSIEENotEnoughDiskSpace == err) |
337 { |
310 { |
338 ShowErrorNoteL (err); |
311 ShowErrorNoteL(err); |
339 } |
312 } |
340 else if (KErrNone != err) |
313 else if (KErrNone != err) |
341 { |
314 { |
342 // Fatal error |
315 // Fatal error |
343 User::Leave (err); |
316 User::Leave(err); |
344 } |
317 } |
345 iEditorManager->SetImageName (iDocumentName); |
318 iEditorManager->SetImageName(iDocumentName); |
346 iImageLoaded = ETrue; |
319 iImageLoaded = ETrue; |
347 InitializeUiItemsL(); |
320 InitializeUiItemsL(); |
348 |
321 |
349 if (!iOrientationChanged) |
322 if (!iOrientationChanged) |
350 { |
323 { |
351 // Immediately display the loaded image |
324 // Immediately display the loaded image |
352 ((CImageEditorUIView *)iEditorView)-> |
325 ((CImageEditorUIView *) iEditorView)-> SetImageL( |
353 SetImageL ( iEditorManager->GetPreviewImage() ); |
326 iEditorManager->GetPreviewImage()); |
354 } |
327 } |
355 |
328 |
356 ApplicationReadyL(); |
329 ApplicationReadyL(); |
357 |
330 |
358 // Do not have to keep file open anymore. |
331 // Do not have to keep file open anymore. |
359 // Fixes problem with Online Printing |
332 // Fixes problem with Online Printing |
360 iFile.Close(); |
333 iFile.Close(); |
361 |
334 |
362 break; |
335 break; |
363 } |
336 } |
364 |
337 |
365 case EOperationCodeSave: |
338 case EOperationCodeSave: |
366 case EOperationCodeBlockSave: |
339 case EOperationCodeBlockSave: |
367 { |
340 { |
368 LOG(KImageEditorLogFile, "CImageEditorAppUi: Image saved"); |
341 LOG(KImageEditorLogFile, "CImageEditorAppUi: Image saved"); |
369 #ifdef VERBOSE |
342 #ifdef VERBOSE |
370 LOGFMT3(KImageEditorLogFile, "\tiSourceFileName: %S, iDocumentName: %S, iTempSaveFileName: %S", &iSourceFileName, &iDocumentName, &iTempSaveFileName); |
343 LOGFMT3(KImageEditorLogFile, "\tiSourceFileName: %S, iDocumentName: %S, iTempSaveFileName: %S", &iSourceFileName, &iDocumentName, &iTempSaveFileName); |
371 #endif |
344 #endif |
372 ResetBusy(); |
345 ResetBusy(); |
373 iSaving = EFalse; |
346 iSaving = EFalse; |
374 |
347 |
375 RFs & fs = iEikonEnv->FsSession(); |
348 RFs & fs = iEikonEnv->FsSession(); |
376 if ( BaflUtils::FileExists (fs, iTempSaveFileName )) |
349 if (BaflUtils::FileExists(fs, iTempSaveFileName)) |
377 { |
350 { |
378 // Image has been successfully saved |
351 // Image has been successfully saved |
379 iImageSaved = ETrue; |
352 iImageSaved = ETrue; |
380 |
353 |
381 CFileMan* fileMan = CFileMan::NewL( fs ); |
354 CFileMan* fileMan = CFileMan::NewL(fs); |
382 CleanupStack::PushL( fileMan ); |
355 CleanupStack::PushL(fileMan); |
383 |
356 |
384 // the temporary image file and the target file are located in the same drive |
357 // the temporary image file and the target file are located in the same drive |
385 if ( iTempSaveFileName.Left(1) == iDocumentName.Left(1) ) |
358 if (iTempSaveFileName.Left(1) == iDocumentName.Left(1)) |
386 { |
359 { |
387 User::LeaveIfError( fileMan->Rename( iTempSaveFileName, iDocumentName )); |
360 User::LeaveIfError(fileMan->Rename(iTempSaveFileName, |
388 } |
361 iDocumentName)); |
389 // the temporary image file and the target file are not in the same drive |
362 } |
390 else |
363 // the temporary image file and the target file are not in the same drive |
391 { |
364 else |
392 User::LeaveIfError( fileMan->Move( iTempSaveFileName, iDocumentName )); |
365 { |
393 } |
366 User::LeaveIfError(fileMan->Move(iTempSaveFileName, |
394 CleanupStack::PopAndDestroy(); //fileMan |
367 iDocumentName)); |
395 |
368 } |
396 // Source file changes (at least if saved with a new name) |
369 CleanupStack::PopAndDestroy(); //fileMan |
397 iSourceFileName = iDocumentName; |
370 |
398 |
371 // Source file changes (at least if saved with a new name) |
399 // Update title |
372 iSourceFileName = iDocumentName; |
400 SetFileNameTitlePaneL(iDocumentName); |
373 |
401 iEditorManager->SetImageName(iDocumentName); |
374 // Update title |
402 |
375 SetFileNameTitlePaneL(iDocumentName); |
403 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi: Temp file renamed to %S", &iDocumentName); |
376 iEditorManager->SetImageName(iDocumentName); |
404 |
377 |
405 // Purge undo stack if on the way to exit. |
378 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi: Temp file renamed to %S", &iDocumentName); |
406 // Don't purge if printing or sending the image. |
379 |
407 if( iExitFromApp ) |
380 // Purge undo stack if on the way to exit. |
408 { |
381 // Don't purge if printing or sending the image. |
409 iEditorManager->PurgeUndoRedoHistory(); |
382 if (iExitFromApp) |
410 } |
383 { |
411 |
384 iEditorManager->PurgeUndoRedoHistory(); |
412 FinalizeSaveL(); |
385 } |
413 } |
386 |
414 |
387 FinalizeSaveL(); |
415 if (iExitFromApp) |
388 } |
416 { |
389 |
417 DeleteTempFiles(); |
390 if (iExitFromApp) |
418 User::Leave (KSIEEErrorOkToExit); |
391 { |
419 } |
392 DeleteTempFiles(); |
420 else |
393 User::Leave(KSIEEErrorOkToExit); |
421 { |
394 } |
422 if (iSending) |
395 else |
423 { |
396 { |
424 // Restore document name |
397 if (iSending) |
425 SetBusy(); |
398 { |
426 iEditorManager->SetImageName (iDocumentName); |
399 // Restore document name |
427 iCallback->DoCallback (KObSendCallbackID); |
400 SetBusy(); |
428 } |
401 iEditorManager->SetImageName(iDocumentName); |
429 |
402 iCallback->DoCallback(KObSendCallbackID); |
430 if (iPrinting) |
403 } |
431 { |
404 |
432 // Restore document name |
405 if (iPrinting) |
433 SetBusy(); |
406 { |
434 iEditorManager->SetImageName (iDocumentName); |
407 // Restore document name |
435 iCallback->DoCallback (KObPrintCallbackID); |
408 SetBusy(); |
436 } |
409 iEditorManager->SetImageName(iDocumentName); |
437 |
410 iCallback->DoCallback(KObPrintCallbackID); |
438 // Reset bitmap sink and screen size |
411 } |
439 UpdateScreenRectL(); |
412 |
440 |
413 // Reset bitmap sink and screen size |
441 // Set saved image name for printing |
414 UpdateScreenRectL(); |
442 ((CImageEditorUIView *)iEditorView)->SetImageFileName(iDocumentName); |
415 |
443 |
416 // Set saved image name for printing |
444 } |
417 ((CImageEditorUIView *) iEditorView)->SetImageFileName( |
445 |
418 iDocumentName); |
446 // Update menu |
419 |
447 SetUndoFlag (); |
420 } |
448 SetOrientationL(EAppUiOrientationUnspecified); |
421 |
449 LOG(KImageEditorLogFile, "CImageEditorAppUi: Saving procedure completed"); |
422 // Update menu |
450 break; |
423 SetUndoFlag(); |
451 } |
424 SetOrientationL(EAppUiOrientationUnspecified); |
452 |
425 LOG(KImageEditorLogFile, "CImageEditorAppUi: Saving procedure completed"); |
453 default: |
426 break; |
454 { |
427 } |
455 break; |
428 |
456 } |
429 default: |
457 } |
430 { |
458 } |
431 break; |
459 } |
432 } |
460 |
433 } |
461 //============================================================================= |
434 } |
462 void CImageEditorAppUi::RenderL () |
435 } |
463 { |
436 |
464 LOG(KImageEditorLogFile, "CImageEditorAppUi: Rendering..."); |
437 //============================================================================= |
|
438 void CImageEditorAppUi::RenderL() |
|
439 { |
|
440 LOG(KImageEditorLogFile, "CImageEditorAppUi: Rendering..."); |
465 SetBusy(); |
441 SetBusy(); |
466 iEditorManager->ProcessImageL(); |
442 iEditorManager->ProcessImageL(); |
467 ((CImageEditorUIView *)iEditorView)->GetContainer()->DrawNow(); |
443 ((CImageEditorUIView *) iEditorView)->GetContainer()->DrawNow(); |
468 ResetBusy(); |
444 ResetBusy(); |
469 } |
445 } |
470 |
446 |
471 //============================================================================= |
447 //============================================================================= |
472 TKeyResponse CImageEditorAppUi::HandleKeyEventL ( |
448 TKeyResponse CImageEditorAppUi::HandleKeyEventL(const TKeyEvent & aKeyEvent, |
473 const TKeyEvent & aKeyEvent, |
449 TEventCode aType) |
474 TEventCode aType |
450 { |
475 ) |
451 LOGFMT2(KImageEditorLogFile, "CImageEditorAppUi:HandleKeyEventL (aKeyEvent: %d, aType:\t %d)", aKeyEvent,aType); |
476 { |
452 |
477 LOGFMT2(KImageEditorLogFile, "CImageEditorAppUi:HandleKeyEventL (aKeyEvent: %d, aType:\t %d)", aKeyEvent,aType); |
453 TKeyResponse response = EKeyWasNotConsumed; |
478 |
454 |
479 TKeyResponse response = EKeyWasNotConsumed; |
455 // if we are busy doing something |
480 |
|
481 // if we are busy doing something |
|
482 // then we consume the key |
456 // then we consume the key |
483 if ( iBusy || (iConstructionState != EConstructionStateReady) ) |
457 if (iBusy || (iConstructionState != EConstructionStateReady)) |
484 { |
458 { |
485 response = EKeyWasConsumed; |
459 response = EKeyWasConsumed; |
486 } |
460 } |
487 |
461 |
488 // we are only interested in real key events |
462 // we are only interested in real key events |
489 // rather than ups or downs |
463 // rather than ups or downs |
490 else if (aType != EEventKey) |
464 else if (aType != EEventKey) |
491 { |
465 { |
492 // These are handled separately here because pressing shift key doesn't |
466 // These are handled separately here because pressing shift key doesn't |
493 // give EEventKey event at all |
467 // give EEventKey event at all |
494 if ( aType == EEventKeyDown ) |
468 if (aType == EEventKeyDown) |
495 { |
469 { |
496 switch (aKeyEvent.iScanCode) |
470 switch (aKeyEvent.iScanCode) |
497 { |
471 { |
498 case EStdKeyLeftShift: |
472 case EStdKeyLeftShift: |
499 { |
473 { |
500 iEditorView->HandleCommandL (EImageEditorPreGlobalZoomChange); |
474 iEditorView->HandleCommandL(EImageEditorPreGlobalZoomChange); |
501 ZoomL( EZoomIn ); |
475 ZoomL(EZoomIn); |
502 iEditorView->HandleCommandL (EImageEditorGlobalZoomChanged); |
476 iEditorView->HandleCommandL(EImageEditorGlobalZoomChanged); |
503 response = EKeyWasConsumed; |
477 response = EKeyWasConsumed; |
504 break; |
478 break; |
505 } |
479 } |
506 case EStdKeyRightShift: |
480 case EStdKeyRightShift: |
507 { |
481 { |
508 iEditorView->HandleCommandL (EImageEditorPreGlobalZoomChange); |
482 iEditorView->HandleCommandL(EImageEditorPreGlobalZoomChange); |
509 ZoomL( EZoomOut ); |
483 ZoomL(EZoomOut); |
510 iEditorView->HandleCommandL (EImageEditorGlobalZoomChanged); |
484 iEditorView->HandleCommandL(EImageEditorGlobalZoomChanged); |
511 response = EKeyWasConsumed; |
485 response = EKeyWasConsumed; |
512 break; |
486 break; |
513 } |
487 } |
514 } |
488 } |
515 } |
489 } |
516 |
490 |
517 response = EKeyWasNotConsumed; |
491 response = EKeyWasNotConsumed; |
518 } |
492 } |
519 |
493 |
520 // scan codes for numbers are their ASCII codes |
494 // scan codes for numbers are their ASCII codes |
521 else |
495 else |
522 { |
496 { |
523 TBool rotated = LandscapeScreenOrientation(); |
497 TBool rotated = LandscapeScreenOrientation(); |
524 |
498 |
525 switch (aKeyEvent.iScanCode) |
499 switch (aKeyEvent.iScanCode) |
526 { |
500 { |
527 |
501 |
528 case 0x30: // 0 |
502 case 0x30: // 0 |
529 { |
503 { |
530 #ifdef FULLSCREEN_AVAILABLE |
504 #ifdef FULLSCREEN_AVAILABLE |
531 if (iFullScreen) |
505 if (iFullScreen) |
532 { |
506 { |
533 ResetFullScreenL(); |
507 ResetFullScreenL(); |
534 } |
508 } |
535 else |
509 else |
536 { |
510 { |
537 SetFullScreenL(); |
511 SetFullScreenL(); |
538 } |
512 } |
539 response = EKeyWasConsumed; |
513 response = EKeyWasConsumed; |
540 #endif // FULLSCREEN_AVAILABLE |
514 #endif // FULLSCREEN_AVAILABLE |
541 break; |
515 break; |
542 } |
516 } |
543 #ifndef LANDSCAPE_ROTATE_HOTKEYS |
517 #ifndef LANDSCAPE_ROTATE_HOTKEYS |
544 case 0x31: // 1 |
518 case 0x31: // 1 |
545 #else |
519 #else |
546 case 0x33: // 3 |
520 case 0x33: // 3 |
547 #endif |
521 #endif |
548 { |
522 { |
549 RotateL (ERotationCounterClockwise); |
523 RotateL(ERotationCounterClockwise); |
550 response = EKeyWasConsumed; |
524 response = EKeyWasConsumed; |
551 break; |
525 break; |
552 } |
526 } |
553 |
527 |
554 case 0x32: // 2 |
528 case 0x32: // 2 |
555 { |
529 { |
556 if (!rotated) |
530 if (!rotated) |
557 { |
531 { |
558 PanL (EDirectionUp); |
532 PanL(EDirectionUp); |
559 response = EKeyWasConsumed; |
533 response = EKeyWasConsumed; |
560 } |
534 } |
561 else |
535 else |
562 { |
536 { |
563 PanL (EDirectionLeft); |
537 PanL(EDirectionLeft); |
564 response = EKeyWasConsumed; |
538 response = EKeyWasConsumed; |
565 } |
539 } |
566 break; |
540 break; |
567 } |
541 } |
568 |
542 |
569 #ifndef LANDSCAPE_ROTATE_HOTKEYS |
543 #ifndef LANDSCAPE_ROTATE_HOTKEYS |
570 case 0x33: // 3 |
544 case 0x33: // 3 |
571 #else |
545 #else |
572 case 0x39: // 9 |
546 case 0x39: // 9 |
573 #endif |
547 #endif |
574 { |
548 { |
575 RotateL (ERotationClockwise); |
549 RotateL(ERotationClockwise); |
576 response = EKeyWasConsumed; |
550 response = EKeyWasConsumed; |
577 break; |
551 break; |
578 } |
552 } |
579 |
553 |
580 case 0x34: // 4 |
554 case 0x34: // 4 |
581 { |
555 { |
582 if (!rotated) |
556 if (!rotated) |
583 { |
557 { |
584 PanL (EDirectionLeft); |
558 PanL(EDirectionLeft); |
585 response = EKeyWasConsumed; |
559 response = EKeyWasConsumed; |
586 } |
560 } |
587 else |
561 else |
588 { |
562 { |
589 PanL (EDirectionDown); |
563 PanL(EDirectionDown); |
590 response = EKeyWasConsumed; |
564 response = EKeyWasConsumed; |
591 } |
565 } |
592 break; |
566 break; |
593 } |
567 } |
594 case 0x35: // 5 |
568 case 0x35: // 5 |
595 { |
569 { |
596 // No function |
570 // No function |
597 break; |
571 break; |
598 } |
572 } |
599 |
573 |
600 case 0x36: // 6 |
574 case 0x36: // 6 |
601 { |
575 { |
602 if (!rotated) |
576 if (!rotated) |
603 { |
577 { |
604 PanL (EDirectionRight); |
578 PanL(EDirectionRight); |
605 response = EKeyWasConsumed; |
579 response = EKeyWasConsumed; |
606 } |
580 } |
607 else |
581 else |
608 { |
582 { |
609 PanL (EDirectionUp); |
583 PanL(EDirectionUp); |
610 response = EKeyWasConsumed; |
584 response = EKeyWasConsumed; |
611 } |
585 } |
612 break; |
586 break; |
613 } |
587 } |
614 |
588 |
615 case 0x38: // 8 |
589 case 0x38: // 8 |
616 { |
590 { |
617 if (!rotated) |
591 if (!rotated) |
618 { |
592 { |
619 PanL (EDirectionDown); |
593 PanL(EDirectionDown); |
620 response = EKeyWasConsumed; |
594 response = EKeyWasConsumed; |
621 } |
595 } |
622 else |
596 else |
623 { |
597 { |
624 PanL (EDirectionRight); |
598 PanL(EDirectionRight); |
625 response = EKeyWasConsumed; |
599 response = EKeyWasConsumed; |
626 } |
600 } |
627 break; |
601 break; |
628 } |
602 } |
629 |
603 |
630 // following cases handle four directions and select key |
604 // following cases handle four directions and select key |
631 case EStdKeyRightArrow: |
605 case EStdKeyRightArrow: |
632 { |
606 { |
633 PanL (EDirectionRight); |
607 PanL(EDirectionRight); |
634 response = EKeyWasConsumed; |
|
635 break; |
|
636 } |
|
637 case EStdKeyLeftArrow: |
|
638 { |
|
639 PanL (EDirectionLeft); |
|
640 response = EKeyWasConsumed; |
|
641 break; |
|
642 } |
|
643 case EStdKeyUpArrow: |
|
644 { |
|
645 PanL (EDirectionUp); |
|
646 response = EKeyWasConsumed; |
|
647 break; |
|
648 } |
|
649 case EStdKeyDownArrow: |
|
650 { |
|
651 PanL (EDirectionDown); |
|
652 response = EKeyWasConsumed; |
|
653 break; |
|
654 } |
|
655 case EStdKeyEnter: |
|
656 { |
|
657 TBool zoomedIn = ( ( CImageEditorUIView *)iEditorView )->InZoomingState(); |
|
658 if ( zoomedIn ) |
|
659 { |
|
660 iEditorView->HandleCommandL (EImageEditorPreGlobalZoomChange); |
|
661 ZoomL( EZoomIn ); |
|
662 iEditorView->HandleCommandL (EImageEditorGlobalZoomChanged); |
|
663 } |
|
664 else |
|
665 { |
|
666 // display the plugin selection grid if not in zoomed state |
|
667 HandleCommandL( EImageEditorMenuCmdApplyEffect ); |
|
668 } |
|
669 response = EKeyWasConsumed; |
|
670 break; |
|
671 } |
|
672 case 0x2a: // * |
|
673 case EStdKeyNkpAsterisk: // * |
|
674 case EStdKeyIncVolume: |
|
675 { |
|
676 if ( iEditorManager->IsPluginLoaded() ) |
|
677 { |
|
678 if ( iEditorManager->GetZoomMode()== EZoomIn3 ) |
|
679 { |
|
680 response = EKeyWasConsumed; |
|
681 break; |
|
682 } |
|
683 } |
|
684 iEditorView->HandleCommandL (EImageEditorPreGlobalZoomChange); |
|
685 ZoomL (EZoomIn); |
|
686 iEditorView->HandleCommandL (EImageEditorGlobalZoomChanged); |
|
687 response = EKeyWasConsumed; |
|
688 break; |
|
689 } |
|
690 case 0x23: // # |
|
691 case EStdKeyHash: // # |
|
692 case EStdKeyDecVolume: |
|
693 { |
|
694 if ( iEditorManager->IsPluginLoaded() ) |
|
695 { |
|
696 if ( iEditorManager->GetZoomMode()== EZoomNormal ) |
|
697 { |
|
698 response = EKeyWasConsumed; |
|
699 break; |
|
700 } |
|
701 } |
|
702 iEditorView->HandleCommandL (EImageEditorPreGlobalZoomChange); |
|
703 ZoomL (EZoomOut); |
|
704 iEditorView->HandleCommandL (EImageEditorGlobalZoomChanged); |
|
705 response = EKeyWasConsumed; |
608 response = EKeyWasConsumed; |
706 break; |
609 break; |
707 } |
610 } |
708 case EStdKeyYes: // green answer call key |
611 case EStdKeyLeftArrow: |
709 { |
612 { |
710 if (!iEditorManager->IsPluginLoaded()) |
613 PanL(EDirectionLeft); |
711 { |
614 response = EKeyWasConsumed; |
712 // when touch is enabled, dialer application is launched |
615 break; |
713 // by the framework and application should not consume |
616 } |
714 // this key. Otherwise image is saved and send menu opened. |
617 case EStdKeyUpArrow: |
715 if ( !AknLayoutUtils::PenEnabled() ) |
618 { |
716 { |
619 PanL(EDirectionUp); |
717 if ( !iSending ) |
620 response = EKeyWasConsumed; |
718 { |
621 break; |
719 SaveChangesAndSendL(); |
622 } |
720 } |
623 case EStdKeyDownArrow: |
721 response = EKeyWasConsumed; |
624 { |
722 } |
625 PanL(EDirectionDown); |
723 else |
626 response = EKeyWasConsumed; |
724 { |
627 break; |
725 response = EKeyWasNotConsumed; |
628 } |
726 } |
629 case EStdKeyEnter: |
727 } |
630 { |
728 break; |
631 TBool zoomedIn = |
729 } |
632 ((CImageEditorUIView *) iEditorView)->InZoomingState(); |
730 case EStdKeyDevice3: // Select key (OK key) |
633 if (zoomedIn) |
731 { |
634 { |
732 // display the plugin selection grid |
635 iEditorView->HandleCommandL(EImageEditorPreGlobalZoomChange); |
733 HandleCommandL(EImageEditorMenuCmdApplyEffect); |
636 ZoomL(EZoomIn); |
734 response = EKeyWasConsumed; |
637 iEditorView->HandleCommandL(EImageEditorGlobalZoomChanged); |
735 break; |
638 } |
736 } |
639 else |
737 case EStdKeyNo: // end key |
640 { |
738 { |
641 // display the plugin selection grid if not in zoomed state |
739 iBusy = ETrue; |
642 HandleCommandL(EImageEditorMenuCmdApplyEffect); |
740 response = EKeyWasNotConsumed; |
643 } |
741 break; |
644 response = EKeyWasConsumed; |
742 } |
645 break; |
743 |
646 } |
744 default: |
647 case 0x2a: // * |
745 { |
648 case EStdKeyNkpAsterisk: // * |
746 response = EKeyWasNotConsumed; |
649 case EStdKeyIncVolume: |
747 break; |
650 { |
748 } |
651 if (iEditorManager->IsPluginLoaded()) |
749 } |
652 { |
750 } |
653 if (iEditorManager->GetZoomMode() == EZoomIn3) |
|
654 { |
|
655 response = EKeyWasConsumed; |
|
656 break; |
|
657 } |
|
658 } |
|
659 iEditorView->HandleCommandL(EImageEditorPreGlobalZoomChange); |
|
660 ZoomL(EZoomIn); |
|
661 iEditorView->HandleCommandL(EImageEditorGlobalZoomChanged); |
|
662 response = EKeyWasConsumed; |
|
663 break; |
|
664 } |
|
665 case 0x23: // # |
|
666 case EStdKeyHash: // # |
|
667 case EStdKeyDecVolume: |
|
668 { |
|
669 if (iEditorManager->IsPluginLoaded()) |
|
670 { |
|
671 if (iEditorManager->GetZoomMode() == EZoomNormal) |
|
672 { |
|
673 response = EKeyWasConsumed; |
|
674 break; |
|
675 } |
|
676 } |
|
677 iEditorView->HandleCommandL(EImageEditorPreGlobalZoomChange); |
|
678 ZoomL(EZoomOut); |
|
679 iEditorView->HandleCommandL(EImageEditorGlobalZoomChanged); |
|
680 response = EKeyWasConsumed; |
|
681 break; |
|
682 } |
|
683 case EStdKeyYes: // green answer call key |
|
684 { |
|
685 if (!iEditorManager->IsPluginLoaded()) |
|
686 { |
|
687 // when touch is enabled, dialer application is launched |
|
688 // by the framework and application should not consume |
|
689 // this key. Otherwise image is saved and send menu opened. |
|
690 if (!AknLayoutUtils::PenEnabled()) |
|
691 { |
|
692 if (!iSending) |
|
693 { |
|
694 SaveChangesAndSendL(); |
|
695 } |
|
696 response = EKeyWasConsumed; |
|
697 } |
|
698 else |
|
699 { |
|
700 response = EKeyWasNotConsumed; |
|
701 } |
|
702 } |
|
703 break; |
|
704 } |
|
705 case EStdKeyDevice3: // Select key (OK key) |
|
706 { |
|
707 // display the plugin selection grid |
|
708 HandleCommandL(EImageEditorMenuCmdApplyEffect); |
|
709 response = EKeyWasConsumed; |
|
710 break; |
|
711 } |
|
712 case EStdKeyNo: // end key |
|
713 { |
|
714 iBusy = ETrue; |
|
715 response = EKeyWasNotConsumed; |
|
716 break; |
|
717 } |
|
718 |
|
719 default: |
|
720 { |
|
721 response = EKeyWasNotConsumed; |
|
722 break; |
|
723 } |
|
724 } |
|
725 } |
751 return response; |
726 return response; |
752 } |
727 } |
753 |
728 |
754 //============================================================================= |
729 //============================================================================= |
755 void CImageEditorAppUi::HandleCommandL (TInt aCommand) |
730 void CImageEditorAppUi::HandleCommandL(TInt aCommand) |
756 { |
731 { |
757 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi:HandleCommandL (%d)", aCommand); |
732 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi:HandleCommandL (%d)", aCommand); |
758 |
733 |
759 switch ( aCommand ) |
734 switch (aCommand) |
760 { |
735 { |
761 |
736 |
762 /** |
737 /** |
763 * |
738 * |
764 * MENU COMMANDS |
739 * MENU COMMANDS |
765 * |
740 * |
766 */ |
741 */ |
767 |
742 |
768 // Launch plug-in selection grid |
743 // Launch plug-in selection grid |
769 case EImageEditorMenuCmdApplyEffect: |
744 case EImageEditorMenuCmdApplyEffect: |
770 { |
745 { |
771 SetBusy(); |
746 SetBusy(); |
772 iCallback->DoCallback (KObInitPluginID); |
747 iCallback->DoCallback(KObInitPluginID); |
773 break; |
748 break; |
774 } |
749 } |
775 |
750 |
776 // Undo effect |
751 // Undo effect |
777 case EImageEditorMenuCmdUndo: |
752 case EImageEditorMenuCmdUndo: |
778 { |
753 { |
779 SetBusy(); |
754 SetBusy(); |
780 iCallback->DoCallback (KObUndoDCallbackID); |
755 iCallback->DoCallback(KObUndoDCallbackID); |
781 break; |
756 break; |
782 } |
757 } |
783 |
758 |
784 // Switch to full screen |
759 // Switch to full screen |
785 case EImageEditorMenuCmdFullScreen: |
760 case EImageEditorMenuCmdFullScreen: |
786 { |
761 { |
787 #ifdef FULLSCREEN_AVAILABLE |
762 #ifdef FULLSCREEN_AVAILABLE |
788 SetFullScreenL(); |
763 SetFullScreenL(); |
789 #endif // FULLSCREEN_AVAILABLE |
764 #endif // FULLSCREEN_AVAILABLE |
790 break; |
765 break; |
791 } |
766 } |
792 |
767 |
793 // Switch to normal screen |
768 // Switch to normal screen |
794 case EImageEditorMenuCmdNormalScreen: |
769 case EImageEditorMenuCmdNormalScreen: |
795 { |
770 { |
796 #ifdef FULLSCREEN_AVAILABLE |
771 #ifdef FULLSCREEN_AVAILABLE |
797 ResetFullScreenL(); |
772 ResetFullScreenL(); |
798 #endif // FULLSCREEN_AVAILABLE |
773 #endif // FULLSCREEN_AVAILABLE |
799 break; |
774 break; |
800 } |
775 } |
801 |
776 |
802 // Increase Zoom |
777 // Increase Zoom |
803 case EImageEditorMenuCmdZoomIn: |
778 case EImageEditorMenuCmdZoomIn: |
804 { |
779 { |
805 ZoomL (EZoomIn); |
780 ZoomL(EZoomIn); |
806 break; |
781 break; |
807 } |
782 } |
808 |
783 |
809 // Decrease Zoom |
784 // Decrease Zoom |
810 case EImageEditorMenuCmdZoomOut: |
785 case EImageEditorMenuCmdZoomOut: |
811 { |
786 { |
812 ZoomL (EZoomOut); |
787 ZoomL(EZoomOut); |
813 break; |
788 break; |
814 } |
789 } |
815 |
790 |
816 // Set zoom to minimum (=normal image) |
791 // Set zoom to minimum (=normal image) |
817 case EImageEditorMenuCmdFitToScreen: |
792 case EImageEditorMenuCmdFitToScreen: |
818 { |
793 { |
819 ZoomL( EZoomMin ); |
794 ZoomL(EZoomMin); |
820 break; |
795 break; |
821 } |
796 } |
822 |
797 |
823 // Launch CSHelp |
798 // Launch CSHelp |
824 case EAknCmdHelp: |
799 case EAknCmdHelp: |
825 case EImageEditorMenuCmdHelp: |
800 case EImageEditorMenuCmdHelp: |
826 { |
801 { |
827 CArrayFix<TCoeHelpContext>* context = CCoeAppUi::AppHelpContextL(); |
802 CArrayFix<TCoeHelpContext>* context = CCoeAppUi::AppHelpContextL(); |
828 if (context) |
803 if (context) |
829 { |
804 { |
830 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), context); |
805 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), |
831 } |
806 context); |
832 break; |
807 } |
833 } |
808 break; |
834 case EImageEditorMenuCmdSave: |
809 } |
835 { |
810 case EImageEditorMenuCmdSave: |
836 if ( ! ((CImageEditorUIView*) iEditorView)->IsMemoryInCriticalLevel() ) |
811 { |
837 { |
812 if (!((CImageEditorUIView*) iEditorView)->IsMemoryInCriticalLevel()) |
838 QueryAndSaveL(); |
813 { |
839 } |
814 QueryAndSaveL(); |
840 break; |
815 } |
841 } |
816 break; |
842 |
817 } |
843 // Close editor |
818 |
844 case EImageEditorMenuCmdExit: |
819 // Close editor |
845 { |
820 case EImageEditorMenuCmdExit: |
846 TBool exitNow = ETrue; |
821 { |
847 if ( iEditorManager->IsImageChanged() ) |
822 TBool exitNow = ETrue; |
848 { |
823 if (iEditorManager->IsImageChanged()) |
849 if ( ! ((CImageEditorUIView*) iEditorView)->IsMemoryInCriticalLevel() ) |
824 { |
850 { |
825 if (!((CImageEditorUIView*) iEditorView)->IsMemoryInCriticalLevel()) |
851 // launch "Save changes?" query |
826 { |
852 TInt result = ((CImageEditorUIView *)iEditorView)->LaunchSaveChangesQueryL(); |
827 // launch "Save changes?" query |
853 if( result == EImageEditorSoftkeyCmdYes ) |
828 TInt |
854 { |
829 result = |
855 if (QueryAndSaveL()) |
830 ((CImageEditorUIView *) iEditorView)->LaunchSaveChangesQueryL(); |
856 { |
831 if (result == EImageEditorSoftkeyCmdYes) |
857 SetBusy(); |
832 { |
858 iExitFromApp = ETrue; |
833 if (QueryAndSaveL()) |
859 exitNow = EFalse; |
834 { |
860 LOG(KImageEditorLogFile, "CImageEditorAppUi:HandleCommandL: Hide application from Fast-swap window."); |
835 SetBusy(); |
861 CAknAppUi::HideApplicationFromFSW(ETrue); |
836 iExitFromApp = ETrue; |
862 } |
837 exitNow = EFalse; |
863 else |
838 LOG(KImageEditorLogFile, "CImageEditorAppUi:HandleCommandL: Hide application from Fast-swap window."); |
864 { |
839 CAknAppUi::HideApplicationFromFSW(ETrue); |
865 iExitFromApp = EFalse; |
840 } |
866 exitNow = EFalse; |
841 else |
867 } |
842 { |
868 |
843 iExitFromApp = EFalse; |
869 } |
844 exitNow = EFalse; |
870 else if( result == EImageEditorSoftkeyCmdNo ) |
845 } |
871 { |
846 |
872 // do nothing, exitNow == ETrue |
847 } |
873 } |
848 else if (result == EImageEditorSoftkeyCmdNo) |
874 else |
849 { |
875 { |
850 // do nothing, exitNow == ETrue |
876 // Automatic cancel may have occurred, don't exit |
851 } |
877 iExitFromApp = EFalse; |
852 else |
878 exitNow = EFalse; |
853 { |
879 } |
854 // Automatic cancel may have occurred, don't exit |
880 } |
855 iExitFromApp = EFalse; |
881 } |
856 exitNow = EFalse; |
882 |
857 } |
883 if (exitNow) |
858 } |
884 { |
859 } |
885 DeleteTempFiles(); |
860 |
886 RunAppShutter(); |
861 if (exitNow) |
887 |
862 { |
888 |
863 DeleteTempFiles(); |
889 //Exit(); |
864 RunAppShutter(); |
890 } |
865 |
891 break; |
866 //Exit(); |
892 } |
867 } |
893 |
868 break; |
894 /** |
869 } |
895 * |
870 |
896 * SOFTKEY COMMANDS |
871 /** |
897 * |
872 * |
898 */ |
873 * SOFTKEY COMMANDS |
899 |
874 * |
900 // Back softkey pressed => Close editor |
875 */ |
|
876 |
|
877 // Back softkey pressed => Close editor |
901 case EImageEditorSoftkeyCmdBack: |
878 case EImageEditorSoftkeyCmdBack: |
902 { |
879 { |
903 TBool exitNow = ETrue; |
880 TBool exitNow = ETrue; |
904 if (iSaving || iCancelling) |
881 if (iSaving || iCancelling) |
905 { |
882 { |
906 // ignore |
883 // ignore |
907 } |
884 } |
908 if ( ! ((CImageEditorUIView*) iEditorView)->IsMemoryInCriticalLevel() ) |
885 if (!((CImageEditorUIView*) iEditorView)->IsMemoryInCriticalLevel()) |
909 { |
886 { |
910 if ( iEditorManager->IsImageChanged() ) |
887 if (iEditorManager->IsImageChanged()) |
911 { |
888 { |
912 // launch "Save changes?" query |
889 // launch "Save changes?" query |
913 TInt result = ((CImageEditorUIView *)iEditorView)->LaunchSaveChangesQueryL(); |
890 TInt |
914 if( result == EImageEditorSoftkeyCmdYes ) |
891 result = |
915 { |
892 ((CImageEditorUIView *) iEditorView)->LaunchSaveChangesQueryL(); |
916 if (QueryAndSaveL()) |
893 if (result == EImageEditorSoftkeyCmdYes) |
917 { |
894 { |
918 SetBusy(); |
895 if (QueryAndSaveL()) |
919 iExitFromApp = ETrue; |
896 { |
920 exitNow = EFalse; |
897 SetBusy(); |
921 LOG(KImageEditorLogFile, "CImageEditorAppUi:HandleCommandL: Hide application from Fast-swap window."); |
898 iExitFromApp = ETrue; |
922 CAknAppUi::HideApplicationFromFSW(ETrue); |
899 exitNow = EFalse; |
923 } |
900 LOG(KImageEditorLogFile, "CImageEditorAppUi:HandleCommandL: Hide application from Fast-swap window."); |
924 else |
901 CAknAppUi::HideApplicationFromFSW(ETrue); |
925 { |
902 } |
926 iExitFromApp = EFalse; |
903 else |
927 exitNow = EFalse; |
904 { |
928 } |
905 iExitFromApp = EFalse; |
929 |
906 exitNow = EFalse; |
930 } |
907 } |
931 else if( result == EImageEditorSoftkeyCmdNo ) |
908 |
932 { |
909 } |
933 // do nothing, exitNow == ETrue |
910 else if (result == EImageEditorSoftkeyCmdNo) |
934 } |
911 { |
935 else |
912 // do nothing, exitNow == ETrue |
936 { |
913 } |
937 // Automatic cancel may have occurred, don't exit |
914 else |
938 iExitFromApp = EFalse; |
915 { |
939 exitNow = EFalse; |
916 // Automatic cancel may have occurred, don't exit |
940 } |
917 iExitFromApp = EFalse; |
941 } |
918 exitNow = EFalse; |
942 } |
919 } |
943 |
920 } |
944 if (exitNow) |
921 } |
945 { |
922 |
946 DeleteTempFiles(); |
923 if (exitNow) |
947 RunAppShutter(); |
924 { |
948 //ProcessCommandL(EAknCmdExit); |
925 DeleteTempFiles(); |
949 } |
926 RunAppShutter(); |
950 break; |
927 //ProcessCommandL(EAknCmdExit); |
951 } |
928 } |
952 |
929 break; |
953 /** |
930 } |
954 * |
931 |
955 * SYSTEM COMMANDS |
932 /** |
956 * |
933 * |
957 */ |
934 * SYSTEM COMMANDS |
958 |
935 * |
959 case EEikCmdExit: |
936 */ |
960 { |
937 |
961 LOG(KImageEditorLogFile, "CImageEditorAppUi: EEikCmdExit caught"); |
938 case EEikCmdExit: |
|
939 { |
|
940 LOG(KImageEditorLogFile, "CImageEditorAppUi: EEikCmdExit caught"); |
962 DeleteTempFiles(); |
941 DeleteTempFiles(); |
963 Exit(); |
942 Exit(); |
964 break; |
943 break; |
965 } |
944 } |
966 |
945 |
967 /** |
946 /** |
968 * |
947 * |
969 * MISC COMMANDS |
948 * MISC COMMANDS |
970 * |
949 * |
971 */ |
950 */ |
972 |
951 |
973 // Render image |
952 // Render image |
974 case EImageEditorCmdRender: |
953 case EImageEditorCmdRender: |
975 { |
954 { |
976 RenderL(); |
955 RenderL(); |
977 break; |
956 break; |
978 } |
957 } |
979 |
958 case EImageEditorResetFullScreen: |
980 case EImageEditorCmdViewReady: |
959 { |
981 { |
960 ResetFullScreenL(); |
982 |
961 } |
983 LOG(KImageEditorLogFile, "CImageEditorAppUi: View ready"); |
962 case EImageEditorCmdViewReady: |
|
963 { |
|
964 |
|
965 LOG(KImageEditorLogFile, "CImageEditorAppUi: View ready"); |
984 iEditorReady = ETrue; |
966 iEditorReady = ETrue; |
985 |
967 |
986 // Initialize UI items |
968 // Initialize UI items |
987 InitializeUiItemsL(); |
969 InitializeUiItemsL(); |
988 ApplicationReadyL(); |
970 ApplicationReadyL(); |
989 break; |
971 break; |
990 } |
972 } |
991 |
973 |
992 case EImageEditorApplyPlugin: |
974 case EImageEditorApplyPlugin: |
993 { |
975 { |
994 // Return from plug-in |
976 // Return from plug-in |
995 SetBusy(); |
977 SetBusy(); |
996 iCallback->DoCallback (KObReturnFromPluginID); |
978 iCallback->DoCallback(KObReturnFromPluginID); |
997 break; |
979 break; |
998 } |
980 } |
999 |
981 |
1000 case EImageEditorCancelPlugin: |
982 case EImageEditorCancelPlugin: |
1001 { |
983 { |
1002 SetBusy(); |
984 SetBusy(); |
1003 iCancelling = ETrue; |
985 iCancelling = ETrue; |
1004 iCallback->DoCallback (KObCancelCallbackID); |
986 // ResetFullScreenL(); |
1005 break; |
987 iPluginName.Copy(KNull); |
1006 } |
988 iCallback->DoCallback(KObCancelCallbackID); |
1007 |
989 break; |
1008 case EImageEditorAddFilterToEngine: |
990 } |
1009 { |
991 |
1010 // Add the current plugin parameters to engine |
992 case EImageEditorAddFilterToEngine: |
1011 // and continue with the same plugin |
993 { |
|
994 // Add the current plugin parameters to engine |
|
995 // and continue with the same plugin |
1012 iEditorManager->AddFilterToEngineL(); |
996 iEditorManager->AddFilterToEngineL(); |
1013 break; |
997 break; |
1014 } |
998 } |
1015 |
999 |
1016 case EImageEditorStoreParameters: |
1000 case EImageEditorStoreParameters: |
1017 { |
1001 { |
1018 break; |
1002 break; |
1019 } |
1003 } |
1020 |
1004 |
1021 case EImageEditorUndoFilter: |
1005 case EImageEditorUndoFilter: |
1022 { |
1006 { |
1023 // Undo one filter (can be called if one plugin |
1007 // Undo one filter (can be called if one plugin |
1024 // has put more than one filter to the engine) |
1008 // has put more than one filter to the engine) |
1025 SetBusy(); |
1009 SetBusy(); |
1026 iEditorManager->UndoL(); |
1010 iEditorManager->UndoL(); |
1027 SetUndoFlag(); |
1011 SetUndoFlag(); |
1028 ((CImageEditorUIView *)iEditorView)->GetContainer()->DrawNow(); |
1012 ((CImageEditorUIView *) iEditorView)->GetContainer()->DrawNow(); |
1029 ResetBusy(); |
1013 ResetBusy(); |
1030 break; |
1014 break; |
1031 } |
1015 } |
1032 |
1016 |
1033 case EImageEditorSaveAndPrint: |
1017 case EImageEditorSaveAndPrint: |
1034 { |
1018 { |
1035 if ( iEditorManager->IsImageChanged() ) |
1019 if (iEditorManager->IsImageChanged()) |
1036 { |
1020 { |
1037 iPrinting = ETrue; |
1021 iPrinting = ETrue; |
1038 SaveImageL(); |
1022 SaveImageL(); |
1039 } |
1023 } |
1040 else |
1024 else |
1041 { |
1025 { |
1042 SetBusy(); |
1026 SetBusy(); |
1043 iCallback->DoCallback (KObPrintCallbackID); |
1027 iCallback->DoCallback(KObPrintCallbackID); |
1044 } |
1028 } |
1045 break; |
1029 break; |
1046 } |
1030 } |
1047 case EImageEditorResetZoom: |
1031 case EImageEditorResetZoom: |
1048 { |
1032 { |
1049 // If this is called rendering must be done separately |
1033 // If this is called rendering must be done separately |
1050 iEditorManager->ZoomL( EZoomMin ); |
1034 iEditorManager->ZoomL(EZoomMin); |
1051 ((CImageEditorUIView *)iEditorView)->SetZoomModeL( iEditorManager->GetZoomMode() ); |
1035 ((CImageEditorUIView *) iEditorView)->SetZoomModeL( |
1052 break; |
1036 iEditorManager->GetZoomMode()); |
1053 } |
1037 break; |
1054 case EImageEditorCmdTouchPan: |
1038 } |
1055 { |
1039 case EImageEditorCmdTouchPan: |
1056 TouchPanL(); |
1040 { |
1057 break; |
1041 TouchPanL(); |
1058 } |
1042 break; |
1059 case EImageEditorOpenContextMenu: |
1043 } |
1060 { |
1044 case EImageEditorOpenContextMenu: |
1061 CAknViewAppUi::ProcessCommandL(EAknSoftkeyContextOptions); |
1045 { |
1062 break; |
1046 CAknViewAppUi::ProcessCommandL(EAknSoftkeyContextOptions); |
1063 } |
1047 break; |
1064 default: |
1048 } |
1065 { |
1049 default: |
1066 // CSendUi commands |
1050 { |
1067 if (aCommand >= EImageEditorMenuCmdSend && |
1051 // CSendUi commands |
1068 aCommand < EImageEditorMenuCmdSendLast) |
1052 if (aCommand >= EImageEditorMenuCmdSend && aCommand |
1069 { |
1053 < EImageEditorMenuCmdSendLast) |
1070 SetBusy(); |
1054 { |
1071 SaveChangesAndSendL(); |
1055 SetBusy(); |
1072 break; |
1056 SaveChangesAndSendL(); |
1073 } |
1057 break; |
1074 |
1058 } |
1075 /** |
1059 |
1076 * |
1060 /** |
1077 * BEVERLY HILLS |
1061 * |
1078 * |
1062 * BEVERLY HILLS |
1079 */ |
1063 * |
1080 else |
1064 */ |
1081 { |
1065 else |
1082 // Do not handle unknown commands |
1066 { |
1083 ResetBusy(); |
1067 // Do not handle unknown commands |
1084 break; |
1068 ResetBusy(); |
1085 } |
1069 break; |
1086 } |
1070 } |
1087 } |
1071 } |
1088 } |
1072 } |
1089 |
1073 } |
1090 //============================================================================= |
1074 |
1091 void CImageEditorAppUi::HandleWsEventL ( |
1075 //============================================================================= |
1092 const TWsEvent & aEvent, |
1076 void CImageEditorAppUi::HandleWsEventL(const TWsEvent & aEvent, |
1093 CCoeControl * aDestination |
1077 CCoeControl * aDestination) |
1094 ) |
1078 { |
1095 { |
|
1096 #ifdef VERBOSE |
1079 #ifdef VERBOSE |
1097 LOGFMT3 (KImageEditorLogFile, "CImageEditorAppUi::HandleWsEventL: aEvent.Type() == %d, aEvent.Key().iCode == %d, aEvent.Key().iScanCode == %d", aEvent.Type(), (TInt)aEvent.Key()->iCode, (TInt)aEvent.Key()->iScanCode); |
1080 LOGFMT3 (KImageEditorLogFile, "CImageEditorAppUi::HandleWsEventL: aEvent.Type() == %d, aEvent.Key().iCode == %d, aEvent.Key().iScanCode == %d", aEvent.Type(), (TInt)aEvent.Key()->iCode, (TInt)aEvent.Key()->iScanCode); |
1098 #endif |
1081 #endif |
1099 |
1082 |
1100 switch ( aEvent.Type() ) |
1083 switch (aEvent.Type()) |
1101 { |
1084 { |
1102 |
1085 |
1103 case EEventFocusLost: |
1086 case EEventFocusLost: |
1104 { |
1087 { |
1105 iForeground = EFalse; |
1088 iForeground = EFalse; |
1106 break; |
1089 break; |
1107 } |
1090 } |
1108 |
1091 |
1109 case EEventFocusGained: |
1092 case EEventFocusGained: |
1110 { |
1093 { |
1111 |
1094 |
1112 // Update the screen rect when we gain focus. |
1095 // Update the screen rect when we gain focus. |
1113 // This isn't really needed every time, it should only do this if something has changed |
1096 // This isn't really needed every time, it should only do this if something has changed |
1114 if (iImageController) |
1097 if (iImageController) |
1115 { |
1098 { |
1116 UpdateScreenRectL(); |
1099 UpdateScreenRectL(); |
1117 } |
1100 } |
1118 |
1101 |
1119 if (iFullScreen) |
1102 if (iFullScreen) |
1120 { |
1103 { |
1121 StatusPane()->MakeVisible ( EFalse ); |
1104 StatusPane()->MakeVisible(EFalse); |
1122 } |
1105 } |
1123 iForeground = ETrue; |
1106 iForeground = ETrue; |
1124 break; |
1107 break; |
1125 } |
1108 } |
1126 |
1109 |
1127 default: |
1110 default: |
1128 { |
1111 { |
1129 break; |
1112 break; |
1130 } |
1113 } |
1131 |
1114 |
1132 } |
1115 } |
1133 |
1116 |
1134 if ( ( aEvent.Type() == KAknUidValueEndKeyCloseEvent) && iEditorManager->IsImageChanged() ) |
1117 if ((aEvent.Type() == KAknUidValueEndKeyCloseEvent) |
|
1118 && iEditorManager->IsImageChanged()) |
1135 { |
1119 { |
1136 if (iCancelling) |
1120 if (iCancelling) |
1137 { |
1121 { |
1138 return; |
1122 return; |
1139 } |
1123 } |
1140 iExitFromApp = ETrue; |
1124 iExitFromApp = ETrue; |
1141 if (iSaving) |
1125 if (iSaving) |
1142 { |
1126 { |
1143 iImageController->CancelOperation(ETrue); |
1127 iImageController->CancelOperation(ETrue); |
1144 iSaveOnExit = EFalse; |
1128 iSaveOnExit = EFalse; |
1145 |
1129 |
1146 return; |
1130 return; |
1147 } |
1131 } |
1148 |
1132 |
1149 TInt err = ImageEditorUtils::GenerateNewDocumentNameL ( |
1133 TInt err = ImageEditorUtils::GenerateNewDocumentNameL( |
1150 iEikonEnv->FsSession(), |
1134 iEikonEnv->FsSession(), iSourceFileName, iDocumentName, |
1151 iSourceFileName, |
1135 &iSourceImageMgAlbumIdList); |
1152 iDocumentName, |
1136 SaveImageOverWriteL(EFalse); |
1153 &iSourceImageMgAlbumIdList |
|
1154 ); |
|
1155 SaveImageOverWriteL( EFalse ); |
|
1156 } |
1137 } |
1157 else |
1138 else |
1158 { |
1139 { |
1159 TInt err( 0 ); |
1140 TInt err(0); |
1160 TRAP( err, CAknViewAppUi::HandleWsEventL( aEvent, aDestination ) ); |
1141 TRAP( err, CAknViewAppUi::HandleWsEventL( aEvent, aDestination ) ); |
1161 } |
1142 } |
1162 } |
1143 } |
1163 |
|
1164 |
1144 |
1165 //============================================================================= |
1145 //============================================================================= |
1166 void CImageEditorAppUi::HandleScreenDeviceChangedL() |
1146 void CImageEditorAppUi::HandleScreenDeviceChangedL() |
1167 { |
1147 { |
1168 |
1148 |
1169 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleScreenDeviceChangedL()"); |
1149 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleScreenDeviceChangedL()"); |
1170 |
1150 // Work-a-round to avoid softkeys to drawn incorrectly |
1171 // Work-a-round to avoid softkeys to drawn incorrectly |
1151 // when a dialog is open when changing to view mode |
1172 // when a dialog is open when changing to view mode |
1152 if (iConstructionState == EConstructionStateReady && iSaving == EFalse |
1173 if (iConstructionState == EConstructionStateReady && |
1153 && iSending == EFalse) |
1174 iSaving == EFalse && |
1154 { |
1175 iSending == EFalse ) |
1155 StopDisplayingMenuBar(); |
1176 { |
1156 } |
1177 StopDisplayingMenuBar(); |
1157 |
1178 } |
1158 CAknViewAppUi::HandleScreenDeviceChangedL(); |
1179 |
1159 |
1180 CAknViewAppUi::HandleScreenDeviceChangedL(); |
1160 //called while screen mode change |
1181 |
1161 if (!iStandby) |
1182 TBool visibleFlag = EFalse; |
1162 { |
1183 if (((CImageEditorUIView *)iEditorView)->GetContainer()) |
1163 if (iPluginName == KDrawPlugin) |
1184 { |
1164 { |
1185 visibleFlag = ((CImageEditorUIView *)iEditorView)->GetContainer()->IsVisible(); |
1165 InitialHorizontalDrawPlugin(); |
1186 } |
1166 } |
1187 |
1167 } |
1188 // If orientation changes during loading - screen bitmap need to be recreated |
1168 iStandby = EFalse; |
1189 // In the start-up there can be event from system without screen device change |
1169 |
1190 if (!iImageLoaded && iConstructionState != EConstructionStateAlloc ) |
1170 TBool visibleFlag = EFalse; |
1191 { |
1171 if (((CImageEditorUIView *) iEditorView)->GetContainer()) |
1192 iOrientationChanged = ETrue; |
1172 { |
1193 // Set landscape parameter |
1173 visibleFlag |
1194 if (LandscapeScreenOrientation()) |
1174 = ((CImageEditorUIView *) iEditorView)->GetContainer()->IsVisible(); |
1195 { |
1175 } |
1196 iResolutionUtil->SetLandscape(ETrue); |
1176 |
1197 } |
1177 // If orientation changes during loading - screen bitmap need to be recreated |
1198 else |
1178 // In the start-up there can be event from system without screen device change |
1199 { |
1179 if (!iImageLoaded && iConstructionState != EConstructionStateAlloc) |
1200 iResolutionUtil->SetLandscape(EFalse); |
1180 { |
1201 } |
1181 iOrientationChanged = ETrue; |
1202 |
1182 // Set landscape parameter |
1203 iResolutionUtil->UpdateScreenMode(); |
1183 if (LandscapeScreenOrientation()) |
1204 TRect rect; |
1184 { |
1205 iResolutionUtil->GetClientRect(rect); |
1185 iResolutionUtil->SetLandscape(ETrue); |
1206 CCoeControl * control = ((CImageEditorUIView *)iEditorView)->GetContainer(); |
1186 } |
|
1187 else |
|
1188 { |
|
1189 iResolutionUtil->SetLandscape(EFalse); |
|
1190 } |
|
1191 |
|
1192 iResolutionUtil->UpdateScreenMode(); |
|
1193 TRect rect; |
|
1194 iResolutionUtil->GetClientRect(rect); |
|
1195 CCoeControl * control = |
|
1196 ((CImageEditorUIView *) iEditorView)->GetContainer(); |
1207 control->SetRect(rect); |
1197 control->SetRect(rect); |
1208 } |
1198 } |
1209 |
1199 |
1210 // Update screen rects if we are currently in the foreground. |
1200 // Update screen rects if we are currently in the foreground. |
1211 else if ((iForeground && iImageController) || visibleFlag) |
1201 else if ((iForeground && iImageController) || visibleFlag) |
1212 { |
1202 { |
1213 UpdateScreenRectL(); |
1203 UpdateScreenRectL(); |
1214 } |
1204 } |
1215 |
1205 |
1216 } |
1206 } |
1217 |
1207 |
1218 //============================================================================= |
1208 //============================================================================= |
1219 TBool CImageEditorAppUi::LandscapeScreenOrientation() |
1209 TBool CImageEditorAppUi::LandscapeScreenOrientation() |
1220 { |
1210 { |
1221 |
1211 |
1222 LOG(KImageEditorLogFile, "CImageEditorAppUi::LandscapeScreenOrientation()"); |
1212 LOG(KImageEditorLogFile, "CImageEditorAppUi::LandscapeScreenOrientation()"); |
1223 |
1213 |
1224 TBool orientation = EFalse; |
1214 TBool orientation = EFalse; |
1225 |
1215 |
1226 #ifdef LANDSCAPE_SUPPORT |
1216 #ifdef LANDSCAPE_SUPPORT |
1227 |
1217 |
1228 TRect rect; |
1218 TRect rect; |
1229 |
1219 |
1230 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, rect); |
1220 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, rect); |
1231 |
1221 |
1232 if ( rect.iBr.iX > rect.iBr.iY ) |
1222 if (rect.iBr.iX > rect.iBr.iY) |
1233 { |
1223 { |
1234 orientation = ETrue; |
1224 orientation = ETrue; |
1235 } |
1225 } |
1236 else |
1226 else |
1237 { |
1227 { |
1238 orientation = EFalse; |
1228 orientation = EFalse; |
1239 } |
1229 } |
1240 |
1230 |
1241 #endif |
1231 #endif |
1242 |
1232 |
1243 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi: Orientation (%d)", (TInt)orientation); |
1233 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi: Orientation (%d)", (TInt)orientation); |
1244 |
1234 |
1245 return orientation; |
1235 return orientation; |
1246 } |
1236 } |
1247 |
1237 |
1248 //============================================================================= |
1238 //============================================================================= |
1249 void CImageEditorAppUi::HandleForegroundEventL (TBool aForeground) |
1239 void CImageEditorAppUi::HandleForegroundEventL(TBool aForeground) |
1250 { |
1240 { |
1251 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleForegroundEventL()"); |
1241 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleForegroundEventL()"); |
1252 |
1242 |
1253 if (aForeground) |
1243 if (aForeground) |
1254 { |
1244 { |
1255 if ( !BaflUtils::FileExists( iEikonEnv->Static()->FsSession() , iSourceFileName ) ) |
1245 if (!BaflUtils::FileExists(iEikonEnv->Static()->FsSession(), |
|
1246 iSourceFileName)) |
1256 { |
1247 { |
1257 DeleteTempFiles(); |
1248 DeleteTempFiles(); |
1258 RunAppShutter(); |
1249 RunAppShutter(); |
1259 } |
1250 } |
1260 |
1251 |
1261 if ( iProcessPriorityAltered ) |
1252 if (iProcessPriorityAltered) |
1262 { |
1253 { |
1263 // Return to normal priority. |
1254 // Return to normal priority. |
1264 RProcess myProcess; |
1255 RProcess myProcess; |
1265 TProcessPriority priority = myProcess.Priority(); |
1256 TProcessPriority priority = myProcess.Priority(); |
1266 if ( priority < iOriginalProcessPriority ) |
1257 if (priority < iOriginalProcessPriority) |
1267 { |
1258 { |
1268 myProcess.SetPriority( iOriginalProcessPriority ); |
1259 myProcess.SetPriority(iOriginalProcessPriority); |
1269 } |
1260 } |
1270 iProcessPriorityAltered = EFalse; |
1261 iProcessPriorityAltered = EFalse; |
1271 } |
1262 iStandby = ETrue; |
1272 |
1263 } |
1273 // Check that application is in sync with the system |
1264 |
1274 if (!iImageLoaded && iConstructionState != EConstructionStateAlloc ) |
1265 // Check that application is in sync with the system |
1275 { |
1266 if (!iImageLoaded && iConstructionState != EConstructionStateAlloc) |
1276 iOrientationChanged = ETrue; |
1267 { |
1277 } |
1268 iOrientationChanged = ETrue; |
1278 else if (iResolutionUtil && LandscapeScreenOrientation() != iResolutionUtil->GetLandscape()) |
1269 } |
1279 { |
1270 else if (iResolutionUtil && LandscapeScreenOrientation() |
1280 UpdateScreenRectL(); |
1271 != iResolutionUtil->GetLandscape()) |
1281 } |
1272 { |
1282 |
1273 UpdateScreenRectL(); |
1283 iEditorView->HandleCommandL (EImageEditorFocusGained); |
1274 } |
1284 } |
1275 |
|
1276 iEditorView->HandleCommandL(EImageEditorFocusGained); |
|
1277 } |
1285 else |
1278 else |
1286 { |
1279 { |
1287 iEditorView->HandleCommandL (EImageEditorFocusLost); |
1280 iEditorView->HandleCommandL(EImageEditorFocusLost); |
1288 // Set the priority to low. This is needed to handle the situations |
1281 // Set the priority to low. This is needed to handle the situations |
1289 // where the engine is performing heavy processing while the application |
1282 // where the engine is performing heavy processing while the application |
1290 // is in background. |
1283 // is in background. |
1291 RProcess myProcess; |
1284 RProcess myProcess; |
1292 iOriginalProcessPriority = myProcess.Priority(); |
1285 iOriginalProcessPriority = myProcess.Priority(); |
1293 myProcess.SetPriority( EPriorityLow ); |
1286 myProcess.SetPriority(EPriorityLow); |
1294 iProcessPriorityAltered = ETrue; |
1287 iProcessPriorityAltered = ETrue; |
1295 |
1288 iStandby = ETrue; |
1296 |
1289 |
1297 } |
1290 } |
1298 CAknViewAppUi::HandleForegroundEventL (aForeground); |
1291 CAknViewAppUi::HandleForegroundEventL(aForeground); |
1299 } |
1292 } |
1300 |
1293 |
1301 |
1294 //============================================================================= |
1302 //============================================================================= |
1295 TBool CImageEditorAppUi::ProcessCommandParametersL(TApaCommand aCommand, |
1303 TBool CImageEditorAppUi::ProcessCommandParametersL ( |
1296 TFileName & aDocumentName, const TDesC8 & aTail) |
1304 TApaCommand aCommand, |
1297 { |
1305 TFileName & aDocumentName, |
1298 LOG(KImageEditorLogFile, "CImageEditorAppUi::ProcessCommandParametersL"); |
1306 const TDesC8 & aTail |
1299 |
1307 ) |
|
1308 { |
|
1309 LOG(KImageEditorLogFile, "CImageEditorAppUi::ProcessCommandParametersL"); |
|
1310 |
|
1311 /* ------------- : test only ---------- |
|
1312 if ( this->ContainerAppUi() == NULL ) // launched as standalone |
|
1313 { |
|
1314 aDocumentName = _L("C:\\Data\\Images\\test.jpg"); |
|
1315 }; |
|
1316 // ---------------- test only ------------- */ |
|
1317 |
|
1318 // Store command parameter document name |
1300 // Store command parameter document name |
1319 iDocumentName.Copy (aDocumentName); |
1301 iDocumentName.Copy(aDocumentName); |
1320 |
1302 |
1321 // Save original document name |
1303 // Save original document name |
1322 iSourceFileName.Copy(aDocumentName); |
1304 iSourceFileName.Copy(aDocumentName); |
1323 |
1305 |
1324 // Set document name for printing |
1306 // Set document name for printing |
1325 ((CImageEditorUIView *)iEditorView)->SetImageFileName(iDocumentName); |
1307 ((CImageEditorUIView *) iEditorView)->SetImageFileName(iDocumentName); |
1326 |
1308 |
1327 // Return default action |
1309 // Return default action |
1328 return CAknViewAppUi::ProcessCommandParametersL (aCommand, aDocumentName, aTail); |
1310 return CAknViewAppUi::ProcessCommandParametersL(aCommand, aDocumentName, |
|
1311 aTail); |
1329 } |
1312 } |
1330 |
1313 |
1331 //============================================================================= |
1314 //============================================================================= |
1332 void CImageEditorAppUi::OpenFileL(RFile &aFile) |
1315 void CImageEditorAppUi::OpenFileL(RFile &aFile) |
1333 { |
1316 { |
1334 LOG(KImageEditorLogFile, "CImageEditorAppUi::OpenFileL"); |
1317 LOG(KImageEditorLogFile, "CImageEditorAppUi::OpenFileL"); |
1335 |
1318 |
1336 // This function should be called only when editor is started |
1319 // This function should be called only when editor is started |
1337 // as an embedded application. |
1320 // as an embedded application. |
1338 |
1321 |
1339 // Store command parameter document name |
1322 // Store command parameter document name |
1340 aFile.FullName(iDocumentName); |
1323 aFile.FullName(iDocumentName); |
1341 |
1324 |
1342 // Open file for editor |
1325 // Open file for editor |
1343 // File must be opened until editor is closed, otherwise |
1326 // File must be opened until editor is closed, otherwise |
1344 // shared session is lost -> Error code -14. |
1327 // shared session is lost -> Error code -14. |
1345 RFs& fs = iEikonEnv->FsSession(); |
1328 RFs& fs = iEikonEnv->FsSession(); |
1346 fs.ShareProtected(); |
1329 fs.ShareProtected(); |
1347 TInt err = iFile.Open(fs, iDocumentName, EFileRead | EFileShareReadersOnly); |
1330 TInt err = iFile.Open(fs, iDocumentName, EFileRead | EFileShareReadersOnly); |
1348 if (KErrNone != err) |
1331 if (KErrNone != err) |
1349 { |
1332 { |
1350 User::LeaveIfError(iFile.Open(fs, iDocumentName, EFileRead | EFileShareAny)); |
1333 User::LeaveIfError(iFile.Open(fs, iDocumentName, EFileRead |
1351 } |
1334 | EFileShareAny)); |
1352 |
1335 } |
1353 // Save original document name |
1336 |
1354 aFile.FullName(iSourceFileName); |
1337 // Save original document name |
1355 |
1338 aFile.FullName(iSourceFileName); |
1356 // Set document name for printing |
1339 |
1357 ((CImageEditorUIView *)iEditorView)->SetImageFileName(iDocumentName); |
1340 // Set document name for printing |
|
1341 ((CImageEditorUIView *) iEditorView)->SetImageFileName(iDocumentName); |
1358 |
1342 |
1359 // If OpenFileL was not called when the startup sequence reached |
1343 // If OpenFileL was not called when the startup sequence reached |
1360 // the point where it needs the document name, the construction was |
1344 // the point where it needs the document name, the construction was |
1361 // suspended to wait for this. |
1345 // suspended to wait for this. |
1362 if (EConstructionStateWaitForStartupParameters == iConstructionState) |
1346 if (EConstructionStateWaitForStartupParameters == iConstructionState) |
1363 { |
1347 { |
1364 // Resume construction |
1348 // Resume construction |
1365 iConstructionState = EConstructionStateLoadImage; |
1349 iConstructionState = EConstructionStateLoadImage; |
1366 iCallback->DoCallback (KObConstructCallBackID); |
1350 iCallback->DoCallback(KObConstructCallBackID); |
1367 } |
1351 } |
1368 } |
1352 } |
1369 |
1353 |
1370 //============================================================================= |
1354 //============================================================================= |
1371 CArrayFix<TCoeHelpContext>* CImageEditorAppUi::HelpContextL() const |
1355 CArrayFix<TCoeHelpContext>* CImageEditorAppUi::HelpContextL() const |
1372 { |
1356 { |
1373 CArrayFixFlat<TCoeHelpContext>* array = |
1357 CArrayFixFlat<TCoeHelpContext>* array = new (ELeave) CArrayFixFlat< |
1374 new(ELeave)CArrayFixFlat<TCoeHelpContext>(1); |
1358 TCoeHelpContext> (1); |
1375 CleanupStack::PushL(array); |
1359 CleanupStack::PushL(array); |
1376 |
1360 |
1377 TBool zoomedIn = ( ( CImageEditorUIView *)iEditorView )->InZoomingState(); |
1361 TBool zoomedIn = ((CImageEditorUIView *) iEditorView)->InZoomingState(); |
1378 if ( zoomedIn ) |
1362 if (zoomedIn) |
1379 { |
1363 { |
1380 array->AppendL(TCoeHelpContext(TUid::Uid(UID_IMAGE_EDITOR), KSIE_HLP_ZOOMING)); |
1364 array->AppendL(TCoeHelpContext(TUid::Uid(UID_IMAGE_EDITOR), |
1381 } |
1365 KSIE_HLP_ZOOMING)); |
1382 else |
1366 } |
1383 { |
1367 else |
1384 array->AppendL(TCoeHelpContext(TUid::Uid(UID_IMAGE_EDITOR), KSIE_HLP_MAIN)); |
1368 { |
1385 } |
1369 array->AppendL(TCoeHelpContext(TUid::Uid(UID_IMAGE_EDITOR), |
1386 |
1370 KSIE_HLP_MAIN)); |
1387 CleanupStack::Pop(array); |
1371 } |
1388 return array; |
1372 |
1389 } |
1373 CleanupStack::Pop(array); |
1390 |
1374 return array; |
1391 //============================================================================= |
1375 } |
1392 void CImageEditorAppUi::InitializePluginL () |
1376 |
1393 { |
1377 //============================================================================= |
1394 LOG(KImageEditorLogFile, "CImageEditorAppUi: Initialising plugin"); |
1378 void CImageEditorAppUi::InitializePluginL() |
1395 |
1379 { |
1396 // Get pointer to the view |
1380 LOG(KImageEditorLogFile, "CImageEditorAppUi: Initialising plugin"); |
1397 CImageEditorUIView * view = (CImageEditorUIView *)iEditorView; |
1381 |
1398 |
1382 // Get pointer to the view |
|
1383 CImageEditorUIView * view = (CImageEditorUIView *) iEditorView; |
|
1384 |
1399 // Close the previous plug-in |
1385 // Close the previous plug-in |
1400 iEditorManager->ClosePlugin(); |
1386 iEditorManager->ClosePlugin(); |
|
1387 |
|
1388 // Open a new plug-in |
|
1389 CPluginInfo * pgn_info = view->GetSelectedPluginInfoL(); |
|
1390 |
|
1391 if (pgn_info) |
|
1392 { |
|
1393 iEditorManager->OpenPluginL(pgn_info->PluginDll()->Des()); |
|
1394 iPluginName.Copy(pgn_info->PluginDll()->Des()); |
1401 |
1395 |
1402 // Open a new plug-in |
1396 //judge if it is draw plug-in |
1403 CPluginInfo * pgn_info = view->GetSelectedPluginInfoL(); |
1397 if (iPluginName != KNull && iPluginName == KDrawPlugin) |
1404 |
1398 { |
1405 if (pgn_info) |
1399 ((CImageEditorUIContainer *) ((CImageEditorUIView *) iEditorView)->GetContainer())->IsDrawPlugin(ETrue); |
1406 { |
1400 SetFullScreenL(); |
1407 iEditorManager->OpenPluginL ( pgn_info->PluginDll()->Des() ); |
1401 } |
1408 |
1402 else |
1409 LOG(KImageEditorLogFile, "CImageEditorAppUi: Plugin opened"); |
1403 { |
1410 |
1404 ((CImageEditorUIContainer *) ((CImageEditorUIView *) iEditorView)->GetContainer())->IsDrawPlugin(EFalse); |
1411 // current rect |
1405 } |
1412 TRect rect; |
1406 |
1413 iResolutionUtil->GetClientRect(rect); |
1407 LOG(KImageEditorLogFile, "CImageEditorAppUi: Plugin opened"); |
1414 |
1408 |
1415 // Create a plug-in control |
1409 // current rect |
1416 // Ownership is moved to the plug-in |
1410 TRect rect; |
1417 CCoeControl * control = NULL; |
1411 iResolutionUtil->GetClientRect(rect); |
1418 TInt err = iEditorManager->CreatePluginControlL ( |
1412 |
1419 rect, |
1413 // Create a plug-in control |
1420 view->GetContainer(), |
1414 // Ownership is moved to the plug-in |
1421 control |
1415 CCoeControl * control = NULL; |
1422 ); |
1416 TInt err = iEditorManager->CreatePluginControlL(rect,view->GetContainer(), control); |
1423 |
1417 |
1424 LOG(KImageEditorLogFile, "CImageEditorAppUi: Plugin control created"); |
1418 LOG(KImageEditorLogFile, "CImageEditorAppUi: Plugin control created"); |
1425 |
1419 |
1426 // The plug-in activation was cancelled |
1420 // The plug-in activation was cancelled |
1427 if (err != KErrNone) |
1421 if (err != KErrNone) |
1428 { |
1422 { |
1429 // Cancel plug-in |
1423 // Cancel plug-in |
1430 iCancelling = ETrue; |
1424 iCancelling = ETrue; |
1431 iCallback->DoCallback (KObCancelCallbackID); |
1425 iCallback->DoCallback(KObCancelCallbackID); |
1432 } |
1426 } |
1433 |
1427 // Activate plug-in |
1434 // Activate plug-in |
1428 else |
1435 else |
1429 { |
1436 { |
1430 // Register control to UI |
1437 |
1431 view->ActivatePluginL(control); |
1438 // Register control to UI |
1432 |
1439 view->ActivatePluginL (control); |
1433 LOG(KImageEditorLogFile, "CImageEditorAppUi: Plugin activated"); |
1440 |
1434 |
1441 LOG(KImageEditorLogFile, "CImageEditorAppUi: Plugin activated"); |
1435 // If the filter did not have a control, close plug-in |
1442 |
1436 if (!control) |
1443 |
1437 { |
1444 // If the filter did not have a control, close plug-in |
1438 iEditorManager->ClosePlugin(); |
1445 if ( !control ) |
1439 } |
1446 { |
1440 |
1447 iEditorManager->ClosePlugin(); |
1441 // Set the last opened image to editor view |
1448 |
1442 ((CImageEditorUIView *) iEditorView)->SetImageL(iEditorManager->GetPreviewImage()); |
1449 } |
1443 |
1450 |
1444 ResetBusy(); |
1451 // Set the last opened image to editor view |
1445 } |
1452 ((CImageEditorUIView *)iEditorView)->SetImageL ( |
1446 } |
1453 iEditorManager->GetPreviewImage() |
1447 |
1454 ); |
|
1455 |
|
1456 ResetBusy(); |
|
1457 } |
|
1458 } |
|
1459 else |
1448 else |
1460 { |
1449 { |
1461 ResetBusy(); |
1450 ResetBusy(); |
1462 } |
1451 } |
1463 } |
1452 } |
1464 |
1453 |
1465 //============================================================================= |
1454 //============================================================================= |
1466 void CImageEditorAppUi::CreatePluginLocatorL () |
1455 void CImageEditorAppUi::CreatePluginLocatorL() |
1467 { |
1456 { |
1468 iLocator = CPluginLocator::NewL(); |
1457 iLocator = CPluginLocator::NewL(); |
1469 } |
1458 } |
1470 |
1459 |
1471 //============================================================================= |
1460 //============================================================================= |
1472 void CImageEditorAppUi::CreateEditorManagerL () |
1461 void CImageEditorAppUi::CreateEditorManagerL() |
1473 { |
1462 { |
1474 iEditorManager = CImageEditorPluginManager::NewL(); |
1463 iEditorManager = CImageEditorPluginManager::NewL(); |
1475 } |
1464 } |
1476 |
1465 |
1477 //============================================================================= |
1466 //============================================================================= |
1478 void CImageEditorAppUi::CreateImageControllerL () |
1467 void CImageEditorAppUi::CreateImageControllerL() |
1479 { |
1468 { |
1480 iImageController = CImageController::NewL (this, iEditorManager); |
1469 iImageController = CImageController::NewL(this, iEditorManager); |
1481 } |
1470 } |
1482 |
1471 |
1483 //============================================================================= |
1472 //============================================================================= |
1484 void CImageEditorAppUi::LoadPluginsL () |
1473 void CImageEditorAppUi::LoadPluginsL() |
1485 { |
1474 { |
1486 // Scan plug-ins |
1475 // Scan plug-ins |
1487 iLocator->ScanPluginsL (); |
1476 iLocator->ScanPluginsL(); |
1488 } |
1477 } |
1489 |
1478 |
1490 //============================================================================= |
1479 //============================================================================= |
1491 void CImageEditorAppUi::InitializeUiItemsL () |
1480 void CImageEditorAppUi::InitializeUiItemsL() |
1492 { |
1481 { |
1493 |
1482 |
1494 LOG (KImageEditorLogFile, "CImageEditorAppUi: InitializeUiItemsL"); |
1483 LOG (KImageEditorLogFile, "CImageEditorAppUi: InitializeUiItemsL"); |
1495 |
1484 |
1496 // Set UI items |
1485 // Set UI items |
1497 if (iEditorReady && iPluginsScanned && iImageLoaded) |
1486 if (iEditorReady && iPluginsScanned && iImageLoaded) |
1498 { |
1487 { |
1499 for (TInt i = 0, c = iLocator->CountPlugins(); i < c; ++i) |
1488 for (TInt i = 0, c = iLocator->CountPlugins(); i < c; ++i) |
1500 { |
1489 { |
1501 ((CImageEditorUIView *)iEditorView)->AddPluginUiItemL (iLocator->GetPluginInfo(i)); |
1490 ((CImageEditorUIView *) iEditorView)->AddPluginUiItemL(iLocator->GetPluginInfo(i)); |
1502 } |
1491 } |
1503 |
1492 |
1504 // Set the last opened image to editor view |
1493 SetFileNameTitlePaneL(iSourceFileName); |
1505 ((CImageEditorUIView *)iEditorView)->SetImageL ( |
1494 |
1506 iEditorManager->GetPreviewImage() |
1495 ((CImageEditorUIView *) iEditorView)->SetZoomModeL(iEditorManager->GetZoomMode()); |
1507 ); |
|
1508 |
|
1509 SetFileNameTitlePaneL(iSourceFileName); |
|
1510 |
|
1511 ((CImageEditorUIView *)iEditorView)->SetZoomModeL( iEditorManager->GetZoomMode() ); |
|
1512 |
1496 |
1513 LOG (KImageEditorLogFile, "CImageEditorAppUi: Plugins initialized"); |
1497 LOG (KImageEditorLogFile, "CImageEditorAppUi: Plugins initialized"); |
1514 |
1498 } |
1515 } |
1499 } |
1516 } |
|
1517 |
1500 |
1518 //============================================================================= |
1501 //============================================================================= |
1519 void CImageEditorAppUi::ApplicationReadyL() |
1502 void CImageEditorAppUi::ApplicationReadyL() |
1520 { |
1503 { |
1521 LOG (KImageEditorLogFile, "CImageEditorAppUi: ApplicationReadyLL"); |
1504 LOG (KImageEditorLogFile, "CImageEditorAppUi: ApplicationReadyLL"); |
1522 |
1505 |
1523 // Set UI items |
1506 // Set UI items |
1524 if (iEditorReady && iPluginsScanned && iImageLoaded) |
1507 if (iEditorReady && iPluginsScanned && iImageLoaded) |
1525 { |
1508 { |
1526 if ( iOrientationChanged ) |
1509 if (iOrientationChanged) |
1527 { |
1510 { |
1528 LOG(KImageEditorLogFile, |
1511 LOG(KImageEditorLogFile, "CImageEditorAppUi: Orientation changed, updating screen rect"); |
1529 "CImageEditorAppUi: Orientation changed, updating screen rect"); |
1512 // Check that application is in sync with the system |
1530 // Check that application is in sync with the system |
1513 // This should fix the problem with screen update after image is loading when |
1531 // This should fix the problem with screen update after image is loading when |
1514 // screen is folded during loading |
1532 // screen is folded during loading |
1515 UpdateScreenRectL(); |
1533 UpdateScreenRectL(); |
1516 iOrientationChanged = EFalse; |
1534 iOrientationChanged = EFalse; |
1517 } |
1535 } |
1518 else if ((LandscapeScreenOrientation() |
1536 else if ( ( LandscapeScreenOrientation() && |
1519 && (StatusPane()->CurrentLayoutResId() |
1537 ( StatusPane()->CurrentLayoutResId() != |
1520 != R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT))) |
1538 R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT ) ) ) |
1521 { |
1539 { |
1522 LOG(KImageEditorLogFile,"CImageEditorAppUi: Status pane needs to be changed->updating screen rect"); |
1540 LOG(KImageEditorLogFile, |
1523 // Updating screen rect updates also status pane to correct "flat version" |
1541 "CImageEditorAppUi: Status pane needs to be changed->updating screen rect"); |
1524 UpdateScreenRectL(); |
1542 // Updating screen rect updates also status pane to correct "flat version" |
1525 } |
1543 UpdateScreenRectL(); |
1526 |
1544 } |
|
1545 |
|
1546 TRect screenRect; |
1527 TRect screenRect; |
1547 CResolutionUtil::Self()->GetClientRect(screenRect); |
1528 CResolutionUtil::Self()->GetClientRect(screenRect); |
1548 iOldScreenRect = screenRect; |
1529 iOldScreenRect = screenRect; |
1549 |
1530 |
1550 ResetBusy(); |
1531 ResetBusy(); |
1551 |
1532 |
1552 // Open Plugin selection grid right away when application start is finished |
1533 // Open Plugin selection grid right away when application start is finished |
1553 //HandleCommandL(EImageEditorMenuCmdApplyEffect); |
1534 //HandleCommandL(EImageEditorMenuCmdApplyEffect); |
1554 |
1535 |
1555 } |
1536 } |
1556 } |
1537 } |
1557 |
1538 |
1558 |
1539 //============================================================================= |
1559 //============================================================================= |
1540 void CImageEditorAppUi::LoadImageL() |
1560 void CImageEditorAppUi::LoadImageL () |
1541 { |
1561 { |
1542 |
1562 LOGFMT (KImageEditorLogFile, "CImageEditorAppUi: Loading image (%S)", &iSourceFileName); |
1543 LOGFMT (KImageEditorLogFile, "CImageEditorAppUi: Loading image (%S)", &iSourceFileName); |
1563 |
1544 |
1564 // Load the image to be edited |
1545 // Load the image to be edited |
1565 iImageController->LoadImageL (iSourceFileName); |
1546 iImageController->LoadImageL(iSourceFileName); |
1566 } |
1547 } |
1567 |
1548 |
1568 //============================================================================= |
1549 //============================================================================= |
1569 void CImageEditorAppUi::SaveImageL () |
1550 void CImageEditorAppUi::SaveImageL() |
1570 { |
1551 { |
1571 LOG(KImageEditorLogFile, "CImageEditorAppUi: Saving image"); |
1552 |
1572 |
1553 LOG(KImageEditorLogFile, "CImageEditorAppUi: Saving image"); |
1573 // Check if source image still exists |
1554 |
1574 if (!BaflUtils::FileExists(iEikonEnv->FsSession(), iSourceFileName)) |
1555 // Check if source image still exists |
1575 { |
1556 if (!BaflUtils::FileExists(iEikonEnv->FsSession(), iSourceFileName)) |
1576 if (iExitFromApp) |
1557 { |
1577 { |
1558 if (iExitFromApp) |
1578 TInt exit = |
1559 { |
1579 ((CImageEditorUIView *)iEditorView)->LaunchExitWithoutSavingQueryL(); |
1560 TInt exit = ((CImageEditorUIView *) iEditorView)->LaunchExitWithoutSavingQueryL(); |
1580 if (exit) |
1561 if (exit) |
1581 { |
1562 { |
1582 // Exit |
1563 // Exit |
1583 User::Leave (KSIEEErrorOkToExit); |
1564 User::Leave(KSIEEErrorOkToExit); |
1584 } |
1565 } |
1585 else |
1566 else |
1586 { |
1567 { |
1587 iExitFromApp = EFalse; |
1568 iExitFromApp = EFalse; |
1588 User::Leave(KSIEEInternal); |
1569 User::Leave(KSIEEInternal); |
1589 } |
1570 } |
1590 } |
1571 } |
1591 else |
1572 else |
1592 { |
1573 { |
1593 User::Leave(KSIEEInternal); |
1574 User::Leave(KSIEEInternal); |
1594 } |
1575 } |
1595 } |
1576 } |
1596 |
1577 |
1597 // Check document name if not saved yet or memory card removed |
1578 // Check document name if not saved yet or memory card removed |
1598 if ( !iImageSaved || |
1579 if (!iImageSaved || !BaflUtils::PathExists(iEikonEnv->FsSession(), |
1599 !BaflUtils::PathExists(iEikonEnv->FsSession(), iTempSaveFileName.Left(3))) |
1580 iTempSaveFileName.Left(3))) |
1600 { |
1581 { |
1601 // If not saved yet, check that document name is valid |
1582 // If not saved yet, check that document name is valid |
1602 SetImageNameL(); |
1583 SetImageNameL(); |
1603 } |
1584 } |
1604 |
1585 |
1605 // Set temp save image name to engine |
1586 // Set temp save image name to engine |
1606 iEditorManager->SetImageName (iTempSaveFileName); |
1587 iEditorManager->SetImageName(iTempSaveFileName); |
1607 |
1588 |
1608 SetLayoutAwareApp(EFalse); |
1589 SetLayoutAwareApp(EFalse); |
1609 // Launch save wait note |
1590 // Launch save wait note |
1610 LaunchSaveWaitNoteL (); |
1591 LaunchSaveWaitNoteL(); |
1611 |
1592 |
1612 iCallback->DoCallback (KObSaveCallbackID); |
1593 iCallback->DoCallback(KObSaveCallbackID); |
1613 |
1594 |
1614 } |
1595 } |
1615 |
1596 |
1616 //============================================================================= |
1597 //============================================================================= |
1617 void CImageEditorAppUi::SetImageNameL() |
1598 void CImageEditorAppUi::SetImageNameL() |
1618 { |
1599 { |
1619 |
1600 |
1620 // Create new document name |
1601 // Create new document name |
1621 // (note that this also selects the drive where the image is saved) |
1602 // (note that this also selects the drive where the image is saved) |
1622 TInt err = ImageEditorUtils::GenerateNewDocumentNameL ( |
1603 TInt err = ImageEditorUtils::GenerateNewDocumentNameL( |
1623 iEikonEnv->FsSession(), |
1604 iEikonEnv->FsSession(), iSourceFileName, iDocumentName, |
1624 iSourceFileName, |
1605 &iSourceImageMgAlbumIdList); |
1625 iDocumentName, |
1606 User::LeaveIfError(err); // cannot save the image |
1626 &iSourceImageMgAlbumIdList |
1607 iEditorManager->SetImageName(iDocumentName); |
1627 ); |
1608 |
1628 User::LeaveIfError (err); // cannot save the image |
1609 // Change title pane text |
1629 iEditorManager->SetImageName (iDocumentName); |
1610 SetFileNameTitlePaneL(iSourceFileName); |
1630 |
|
1631 // Change title pane text |
|
1632 SetFileNameTitlePaneL(iSourceFileName); |
|
1633 |
1611 |
1634 // Check that everything is in order with the file |
1612 // Check that everything is in order with the file |
1635 CheckFileL (iDocumentName); |
1613 CheckFileL(iDocumentName); |
1636 |
1614 |
1637 // Generate temporary save file name |
1615 // Generate temporary save file name |
1638 TParse tempFileParser; |
1616 TParse tempFileParser; |
1639 tempFileParser.Set (KTempSaveFile, &KTempPath, &iDocumentName); |
1617 tempFileParser.Set(KTempSaveFile, &KTempPath, &iDocumentName); |
1640 iTempSaveFileName.Copy (tempFileParser.FullName()); |
1618 iTempSaveFileName.Copy(tempFileParser.FullName()); |
1641 BaflUtils::EnsurePathExistsL (iEikonEnv->FsSession(), iTempSaveFileName); |
1619 BaflUtils::EnsurePathExistsL(iEikonEnv->FsSession(), iTempSaveFileName); |
1642 |
1620 |
1643 } |
1621 } |
1644 |
|
1645 |
1622 |
1646 //============================================================================= |
1623 //============================================================================= |
1647 void CImageEditorAppUi::SaveChangesAndSendL() |
1624 void CImageEditorAppUi::SaveChangesAndSendL() |
1648 { |
1625 { |
1649 |
1626 |
1650 LOG(KImageEditorLogFile, "CImageEditorAppUi::SaveChangesAndSendL()"); |
1627 LOG(KImageEditorLogFile, "CImageEditorAppUi::SaveChangesAndSendL()"); |
1651 |
1628 |
1652 iSending = ETrue; |
1629 iSending = ETrue; |
1653 |
1630 |
1654 // Delete old temp files if exists |
1631 // Delete old temp files if exists |
1655 DeleteTempFiles(); |
1632 DeleteTempFiles(); |
1656 |
1633 |
1657 if (iEditorManager->IsImageChanged()) |
1634 if (iEditorManager->IsImageChanged()) |
1658 { |
1635 { |
1659 // Save image |
1636 // Save image |
1660 SaveImageL(); |
1637 SaveImageL(); |
1661 |
1638 } |
1662 } |
1639 // Otherwise send last saved image |
1663 // Otherwise send last saved image |
1640 else |
1664 else |
1641 { |
1665 { |
1642 SendImageL(); |
1666 SendImageL (); |
1643 } |
1667 } |
1644 |
1668 |
1645 } |
1669 } |
1646 |
1670 |
1647 //============================================================================= |
1671 //============================================================================= |
1648 void CImageEditorAppUi::SendImageL() |
1672 void CImageEditorAppUi::SendImageL () |
1649 { |
1673 { |
1650 LOG(KImageEditorLogFile, "CImageEditorAppUi::SendImageL()"); |
1674 LOG(KImageEditorLogFile, "CImageEditorAppUi::SendImageL()"); |
1651 |
1675 |
1652 ResetBusy(); |
1676 ResetBusy(); |
1653 |
1677 |
1654 RFs& fs = iEikonEnv->FsSession(); |
1678 RFs& fs = iEikonEnv->FsSession(); |
1655 TFileName fileToSend; |
1679 TFileName fileToSend; |
1656 |
1680 |
1657 // Check if image has been modified and saved |
1681 // Check if image has been modified and saved |
1658 if (BaflUtils::FileExists(fs, iDocumentName)) |
1682 if (BaflUtils::FileExists(fs, iDocumentName)) |
1659 { |
1683 { |
1660 fileToSend.Append(iDocumentName); |
1684 fileToSend.Append(iDocumentName); |
1661 } |
1685 } |
1662 // Use source file if no changes done |
1686 // Use source file if no changes done |
1663 else |
1687 else |
1664 { |
1688 { |
1665 fileToSend.Append(iSourceFileName); |
1689 fileToSend.Append(iSourceFileName); |
1666 } |
1690 } |
1667 |
1691 |
1668 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi: Sending image: %S", &fileToSend); |
1692 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi: Sending image: %S", &fileToSend); |
1669 |
1693 |
1670 iEikonEnv->SetBusy(ETrue); |
1694 iEikonEnv->SetBusy(ETrue); |
1671 |
1695 |
|
1696 // Launch send query dialog |
1672 // Launch send query dialog |
1697 TSendingCapabilities cap( 0, 0, TSendingCapabilities::ESupportsAttachments ); |
1673 TSendingCapabilities cap(0, 0, TSendingCapabilities::ESupportsAttachments); |
1698 ((CImageEditorUIView *)iEditorView)->LaunchSendQueryL(cap, fileToSend); |
1674 ((CImageEditorUIView *) iEditorView)->LaunchSendQueryL(cap, fileToSend); |
1699 |
1675 |
1700 iSending = EFalse; |
1676 iSending = EFalse; |
1701 iEikonEnv->SetBusy(EFalse); |
1677 iEikonEnv->SetBusy(EFalse); |
1702 } |
1678 } |
1703 |
1679 |
1704 //============================================================================= |
1680 //============================================================================= |
1705 void CImageEditorAppUi::CheckFileL (const TDesC & aFileName) const |
1681 void CImageEditorAppUi::CheckFileL(const TDesC & aFileName) const |
1706 { |
1682 { |
1707 RFs & fs = iEikonEnv->FsSession(); |
1683 RFs & fs = iEikonEnv->FsSession(); |
1708 |
1684 |
1709 // Is file name valid |
1685 // Is file name valid |
1710 if ( !fs.IsValidName (aFileName) ) |
1686 if (!fs.IsValidName(aFileName)) |
1711 { |
1687 { |
1712 User::Leave ( KSIEESaveFile ); |
1688 User::Leave(KSIEESaveFile); |
1713 } |
1689 } |
1714 |
1690 } |
1715 } |
1691 |
1716 |
1692 //============================================================================= |
1717 //============================================================================= |
1693 TBool CImageEditorAppUi::CallbackMethodL(TInt aParam) |
1718 TBool CImageEditorAppUi::CallbackMethodL (TInt aParam) |
1694 { |
1719 { |
|
1720 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi::CallbackMethodL (%d)", aParam); |
1695 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi::CallbackMethodL (%d)", aParam); |
1721 |
1696 |
1722 TBool ret = EFalse; |
1697 TBool ret = EFalse; |
1723 |
1698 |
1724 switch (aParam) |
1699 switch (aParam) |
1725 { |
1700 { |
1726 |
|
1727 case KObConstructCallBackID: |
1701 case KObConstructCallBackID: |
1728 { |
1702 { |
1729 |
1703 switch (iConstructionState) |
1730 switch (iConstructionState) |
1704 { |
1731 { |
1705 case EConstructionStateAlloc: |
1732 |
1706 { |
1733 case EConstructionStateAlloc: |
1707 // Launch wait note |
1734 { |
1708 LaunchLoadWaitNoteL(); |
1735 // Launch wait note |
1709 |
1736 LaunchLoadWaitNoteL(); |
1710 // Initialize resolution utility. CResolutionUtil::InitializeL() |
1737 |
1711 // Returns the singleton instance of the class, creating it if |
1738 // Initialize resolution utility. CResolutionUtil::InitializeL() |
1712 // it does not yet exist. |
1739 // Returns the singleton instance of the class, creating it if |
1713 iResolutionUtil = CResolutionUtil::InitializeL(); |
1740 // it does not yet exist. |
|
1741 iResolutionUtil = CResolutionUtil::InitializeL(); |
|
1742 iResolutionUtil->SetFullScreen(EFalse); |
1714 iResolutionUtil->SetFullScreen(EFalse); |
1743 |
1715 |
1744 #ifdef LANDSCAPE_SUPPORT |
1716 #ifdef LANDSCAPE_SUPPORT |
1745 // Set landscape parameter |
1717 // Set landscape parameter |
1746 if (LandscapeScreenOrientation()) |
1718 if (LandscapeScreenOrientation()) |
1747 { |
1719 { |
1748 iResolutionUtil->SetLandscape(ETrue); |
1720 iResolutionUtil->SetLandscape(ETrue); |
1749 } |
1721 } |
1750 else |
1722 else |
1751 { |
1723 { |
1752 iResolutionUtil->SetLandscape(EFalse); |
1724 iResolutionUtil->SetLandscape(EFalse); |
1753 } |
1725 } |
1754 #else |
1726 #else |
1755 #ifdef LANDSCAPE_ONLY |
1727 #ifdef LANDSCAPE_ONLY |
1756 iResolutionUtil->SetLandscape(ETrue); |
1728 iResolutionUtil->SetLandscape(ETrue); |
1757 #else |
1729 #else |
1758 iResolutionUtil->SetLandscape(EFalse); |
1730 iResolutionUtil->SetLandscape(EFalse); |
1759 #endif |
1731 #endif |
1760 #endif // LANDSCAPE_SUPPORT |
1732 #endif // LANDSCAPE_SUPPORT |
1761 |
1733 iResolutionUtil->UpdateScreenMode(); |
1762 iResolutionUtil->UpdateScreenMode(); |
1734 LOG(KImageEditorLogFile, "CImageEditorAppUi: Resolution set"); |
1763 LOG(KImageEditorLogFile, "CImageEditorAppUi: Resolution set"); |
1735 |
1764 |
1736 // Create the Send UI instance |
1765 // Create the Send UI instance |
1737 iSendAppUi = CSendUi::NewL(); |
1766 iSendAppUi = CSendUi::NewL(); |
1738 ((CImageEditorUIView *) iEditorView)->SetSendAppUi(iSendAppUi); |
1767 ((CImageEditorUIView *)iEditorView)->SetSendAppUi(iSendAppUi); |
1739 |
1768 |
1740 // Create plug-in locator |
1769 // Create plug-in locator |
1741 CreatePluginLocatorL(); |
1770 CreatePluginLocatorL(); |
|
1771 LOG(KImageEditorLogFile, "Locator created"); |
1742 LOG(KImageEditorLogFile, "Locator created"); |
1772 // Create plug-in manager |
1743 |
1773 CreateEditorManagerL(); |
1744 // Create plug-in manager |
|
1745 CreateEditorManagerL(); |
1774 LOG(KImageEditorLogFile, "Manager created"); |
1746 LOG(KImageEditorLogFile, "Manager created"); |
1775 // Create image controller |
1747 |
1776 CreateImageControllerL(); |
1748 // Create image controller |
|
1749 CreateImageControllerL(); |
1777 LOG(KImageEditorLogFile, "Image Controller created"); |
1750 LOG(KImageEditorLogFile, "Image Controller created"); |
1778 iConstructionState = EConstructionStateLoadImage; |
1751 iConstructionState = EConstructionStateLoadImage; |
1779 ret = ETrue; |
1752 ret = ETrue; |
1780 break; |
1753 break; |
1781 } |
1754 } |
1782 |
1755 |
1783 case EConstructionStateLoadImage: |
1756 case EConstructionStateLoadImage: |
1784 { |
1757 { |
1785 LOG(KImageEditorLogFile, "Loading image"); |
1758 LOG(KImageEditorLogFile, "Loading image"); |
1786 |
1759 |
1787 // iSourceFileName is available (in embedded mode) only after |
1760 // iSourceFileName is available (in embedded mode) only after |
1788 // CImageEditorDocument::OpenFileL has been called by the system. |
1761 // CImageEditorDocument::OpenFileL has been called by the system. |
1789 // If that has not been done |
1762 // If that has not been done |
1790 if (!iSourceFileName.Length()) |
1763 if (!iSourceFileName.Length()) |
1791 { |
1764 { |
1792 iConstructionState = EConstructionStateWaitForStartupParameters; |
1765 iConstructionState = EConstructionStateWaitForStartupParameters; |
1793 ret = EFalse; |
1766 ret = EFalse; |
1794 } |
1767 } |
1795 else |
1768 else |
1796 { |
1769 { |
1797 // Kill wait note before loading image. |
1770 // Kill wait note before loading image. |
1798 // Some corrupted images loading stacks if wait note is displayd |
1771 // Some corrupted images loading stacks if wait note is displayd |
1799 //KillWaitNote(); |
1772 //KillWaitNote(); |
1800 |
1773 |
1801 // Relaunch wait note |
1774 // Relaunch wait note |
1802 //LaunchLoadWaitNoteL(); |
1775 //LaunchLoadWaitNoteL(); |
1803 |
1776 |
1804 // Load image |
1777 // Load image |
1805 LoadImageL(); |
1778 LoadImageL(); |
1806 |
1779 |
1807 SetFileNameTitlePaneL(iSourceFileName); |
1780 SetFileNameTitlePaneL(iSourceFileName); |
1808 iConstructionState = EConstructionStateScanPlugins; |
1781 iConstructionState = EConstructionStateScanPlugins; |
1809 ret = ETrue; |
1782 ret = ETrue; |
1810 } |
1783 } |
1811 break; |
1784 break; |
1812 } |
1785 } |
1813 |
1786 |
1814 case EConstructionStateScanPlugins: |
1787 case EConstructionStateScanPlugins: |
1815 { |
1788 { |
1816 LOG(KImageEditorLogFile, "Scanning plugins"); |
1789 LOG(KImageEditorLogFile, "Scanning plugins"); |
1817 LoadPluginsL(); |
1790 LoadPluginsL(); |
1818 iConstructionState = EConstructionStateInitUi; |
1791 iConstructionState = EConstructionStateInitUi; |
1819 ret = ETrue; |
1792 ret = ETrue; |
1820 break; |
1793 break; |
1821 } |
1794 } |
1822 |
1795 |
1823 case EConstructionStateInitUi: |
1796 case EConstructionStateInitUi: |
1824 { |
1797 { |
1825 LOG(KImageEditorLogFile, "Init UI"); |
1798 LOG(KImageEditorLogFile, "Init UI"); |
1826 // Initialize UI items |
1799 // Initialize UI items |
1827 iPluginsScanned = ETrue; |
1800 iPluginsScanned = ETrue; |
1828 InitializeUiItemsL(); |
1801 InitializeUiItemsL(); |
1829 iConstructionState = EConstructionStateReady; |
1802 iConstructionState = EConstructionStateReady; |
1830 ret = ETrue; |
1803 ret = ETrue; |
1831 break; |
1804 break; |
1832 } |
1805 } |
1833 |
1806 |
1834 default: |
1807 default: |
1835 { |
1808 { |
1836 LOG(KImageEditorLogFile, "Ready"); |
1809 LOG(KImageEditorLogFile, "Ready"); |
1837 KillWaitNote(); |
1810 KillWaitNote(); |
1838 ApplicationReadyL(); |
1811 ApplicationReadyL(); |
1839 break; |
1812 break; |
1840 } |
1813 } |
1841 } |
1814 } |
1842 break; |
1815 break; |
1843 } |
1816 } |
1844 |
1817 |
1845 case KObReturnFromPluginID: |
1818 case KObReturnFromPluginID: |
1846 { |
1819 { |
1847 SetUndoFlag(); |
1820 SetUndoFlag(); |
1848 iEditorManager->ShowPluginPopup(); |
1821 iEditorManager->ShowPluginPopup(); |
1849 iEditorManager->ClosePlugin(); |
1822 iEditorManager->ClosePlugin(); |
1850 |
1823 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
1851 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
1824 ((CImageEditorUIView *) iEditorView)->ActivateMainViewL(); |
1852 ((CImageEditorUIView *)iEditorView)->ActivateMainViewL(); |
1825 |
1853 |
1826 //Only for draw plug-in |
1854 ((CImageEditorUIView *)iEditorView)->SetImageL ( |
1827 if (iPluginName != KNull && iPluginName == KDrawPlugin) |
1855 iEditorManager->GetPreviewImage()); |
1828 { |
1856 |
1829 iPluginName.Copy(KNull); |
|
1830 ResetFullScreenL(); |
|
1831 } |
|
1832 |
1857 ResetBusy(); |
1833 ResetBusy(); |
1858 break; |
1834 break; |
1859 } |
1835 } |
1860 |
1836 |
1861 case KObInitPluginID: |
1837 case KObInitPluginID: |
1862 { |
1838 { |
1863 InitializePluginL (); |
1839 InitializePluginL(); |
1864 SetUndoFlag(); |
1840 SetUndoFlag(); |
1865 break; |
1841 break; |
1866 } |
1842 } |
1867 |
1843 |
1868 case KObCancelCallbackID: |
1844 case KObCancelCallbackID: |
1869 { |
1845 { |
|
1846 TRect rect; |
|
1847 CResolutionUtil::Self()->GetClientRect(rect); |
|
1848 CCoeControl* control = ((CImageEditorUIView *) iEditorView)->GetContainer(); |
|
1849 control->SetRect(rect); |
|
1850 |
1870 iEditorManager->ClosePlugin(); |
1851 iEditorManager->ClosePlugin(); |
1871 iEditorManager->UndoL(); |
1852 iEditorManager->UndoL(); |
1872 |
1853 |
1873 |
1854 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
1874 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
1855 ((CImageEditorUIView *) iEditorView)->ActivateMainViewL(); |
1875 ((CImageEditorUIView *)iEditorView)->ActivateMainViewL(); |
1856 |
1876 |
1857 ((CImageEditorUIView *) iEditorView)->SetImageL(iEditorManager->GetPreviewImage()); |
1877 ((CImageEditorUIView *)iEditorView)->SetImageL ( |
1858 |
1878 iEditorManager->GetPreviewImage()); |
1859 SetUndoFlag(); |
1879 |
|
1880 SetUndoFlag(); |
|
1881 ResetBusy(); |
1860 ResetBusy(); |
1882 iCancelling = EFalse; |
1861 iCancelling = EFalse; |
1883 break; |
1862 break; |
1884 } |
1863 } |
1885 |
1864 |
1886 case KObUndoDCallbackID: |
1865 case KObUndoDCallbackID: |
1887 { |
1866 { |
1888 iEditorManager->UndoL(); |
1867 iEditorManager->UndoL(); |
1889 SetUndoFlag(); |
1868 SetUndoFlag(); |
1890 ((CImageEditorUIView *)iEditorView)->GetContainer()->DrawNow(); |
1869 ((CImageEditorUIView *) iEditorView)->GetContainer()->DrawNow(); |
1891 ResetBusy(); |
1870 ResetBusy(); |
1892 break; |
1871 break; |
1893 } |
1872 } |
1894 |
1873 |
1895 case KObSendCallbackID: |
1874 case KObSendCallbackID: |
1896 { |
1875 { |
1897 SendImageL (); |
1876 SendImageL(); |
1898 ResetBusy(); |
1877 ResetBusy(); |
1899 break; |
1878 break; |
1900 } |
1879 } |
1901 |
1880 |
1902 case KObPrintCallbackID: |
1881 case KObPrintCallbackID: |
1903 { |
1882 { |
1904 // Reset first otherwise canceling print application |
1883 // Reset first otherwise canceling print application |
1905 // leaves busy state active |
1884 // leaves busy state active |
1906 iPrinting = EFalse; |
1885 iPrinting = EFalse; |
1907 ResetBusy(); |
1886 ResetBusy(); |
1908 ((CImageEditorUIView *)iEditorView)-> |
1887 ((CImageEditorUIView *) iEditorView)-> HandleCommandL(EImageEditorDoPrint); |
1909 HandleCommandL(EImageEditorDoPrint); |
1888 break; |
1910 break; |
1889 } |
1911 } |
1890 |
1912 |
1891 case KObSaveCallbackID: |
1913 case KObSaveCallbackID: |
1892 { |
1914 { |
|
1915 // Start saving |
1893 // Start saving |
1916 iImageController->SaveImageL (iTempSaveFileName); |
1894 iImageController->SaveImageL(iTempSaveFileName); |
1917 |
1895 iSaving = ETrue; |
1918 iSaving = ETrue; |
1896 break; |
1919 break; |
1897 } |
1920 } |
1898 |
1921 |
1899 default: |
1922 default: |
1900 { |
1923 { |
1901 break; |
1924 break; |
1902 } |
1925 } |
1903 } |
1926 } |
1904 |
1927 |
1905 return ret; |
1928 return ret; |
1906 } |
1929 } |
1907 |
1930 |
1908 //============================================================================= |
1931 //============================================================================= |
1909 void CImageEditorAppUi::SetBusy() |
1932 void CImageEditorAppUi::SetBusy () |
1910 { |
1933 { |
1911 LOG(KImageEditorLogFile, "CImageEditorAppUi: SetBusy()"); |
1934 LOG(KImageEditorLogFile, "CImageEditorAppUi: SetBusy()"); |
1912 if (iEditorView) |
1935 if (iEditorView) |
1913 { |
1936 { |
1914 ((CImageEditorUIView *) iEditorView)->SetBusy(); |
1937 ((CImageEditorUIView *)iEditorView)->SetBusy(); |
1915 } |
1938 } |
1916 iBusy = ETrue; |
1939 iBusy = ETrue; |
1917 } |
1940 } |
1918 |
1941 |
1919 //============================================================================= |
1942 //============================================================================= |
1920 void CImageEditorAppUi::ResetBusy() |
1943 void CImageEditorAppUi::ResetBusy () |
1921 { |
1944 { |
1922 |
1945 LOG(KImageEditorLogFile, "CImageEditorAppUi: ResetBusy()"); |
1923 LOG(KImageEditorLogFile, "CImageEditorAppUi: ResetBusy()"); |
1946 // Keep busy until application is fully constructed |
1924 // Keep busy until application is fully constructed |
1947 if (iConstructionState == EConstructionStateReady) |
1925 if (iConstructionState == EConstructionStateReady) |
1948 { |
1926 { |
1949 if (iEditorView) |
1927 if (iEditorView) |
1950 { |
1928 { |
1951 ((CImageEditorUIView *)iEditorView)->ResetBusy(); |
1929 ((CImageEditorUIView *) iEditorView)->ResetBusy(); |
1952 } |
1930 } |
1953 iBusy = EFalse; |
1931 iBusy = EFalse; |
1954 } |
1932 } |
1955 } |
1933 } |
1956 |
1934 |
1957 //============================================================================= |
1935 //============================================================================= |
1958 void CImageEditorAppUi::SetFullScreenL () |
1936 void CImageEditorAppUi::SetFullScreenL() |
1959 { |
1937 { |
1960 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
1938 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
1961 |
1939 |
1962 LOG(KImageEditorLogFile, "CImageEditorAppUi: Setting full screen"); |
1940 LOG(KImageEditorLogFile, "CImageEditorAppUi: Setting full screen"); |
1963 |
1941 |
1964 iFullScreen = ETrue; |
1942 iFullScreen = ETrue; |
1965 |
1943 |
1966 // Set to full screen mode |
1944 // Set to full screen mode |
1967 ((CImageEditorUIView *)iEditorView)->SetFullScreen(); |
1945 ((CImageEditorUIView *) iEditorView)->SetFullScreen(); |
1968 |
1946 |
1969 // In the startup image controller might not be created yet |
1947 // In the startup image controller might not be created yet |
1970 if (iImageController) |
1948 if (iImageController) |
1971 { |
1949 { |
1972 // Update new screen resolution |
1950 // Update new screen resolution |
1973 UpdateScreenRectL(); |
1951 UpdateScreenRectL(); |
1974 } |
1952 } |
1975 |
1953 |
1976 |
1954 } |
1977 } |
1955 |
1978 |
1956 //============================================================================= |
1979 //============================================================================= |
1957 void CImageEditorAppUi::ResetFullScreenL() |
1980 void CImageEditorAppUi::ResetFullScreenL () |
1958 { |
1981 { |
1959 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
1982 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
1960 |
1983 |
1961 LOG(KImageEditorLogFile, "CImageEditorAppUi: Resetting full screen"); |
1984 LOG(KImageEditorLogFile, "CImageEditorAppUi: Resetting full screen"); |
1962 |
1985 |
1963 iFullScreen = EFalse; |
1986 iFullScreen = EFalse; |
1964 |
1987 |
1965 // Set to full screen mode |
1988 // Set to full screen mode |
1966 ((CImageEditorUIView *) iEditorView)->ResetFullScreen(); |
1989 ((CImageEditorUIView *)iEditorView)->ResetFullScreen(); |
1967 |
1990 |
1968 // In the startup image controller might not be created yet |
1991 // In the startup image controller might not be created yet |
1969 if (iImageController) |
1992 if (iImageController) |
1970 { |
1993 { |
1971 UpdateScreenRectL(); |
1994 UpdateScreenRectL(); |
1972 } |
1995 } |
1973 |
1996 |
1974 } |
1997 } |
1975 |
1998 |
1976 //============================================================================= |
1999 //============================================================================= |
1977 void CImageEditorAppUi::SetUndoFlag() |
2000 void CImageEditorAppUi::SetUndoFlag () |
1978 { |
2001 { |
1979 if (iEditorView) |
2002 if (iEditorView) |
1980 { |
2003 { |
1981 ((CImageEditorUIView *) iEditorView)->SetUndoFlag(iEditorManager->CanUndo()); |
2004 ((CImageEditorUIView *)iEditorView)->SetUndoFlag( iEditorManager->CanUndo() ); |
1982 ((CImageEditorUIView *) iEditorView)->SetSaveFlag(iEditorManager->IsImageChanged()); |
2005 ((CImageEditorUIView *)iEditorView)->SetSaveFlag( iEditorManager->IsImageChanged() ); |
1983 } |
2006 } |
1984 } |
2007 } |
1985 |
2008 |
1986 //============================================================================= |
2009 //============================================================================= |
1987 void CImageEditorAppUi::SetTitlePaneTextL(const TDesC & aText) |
2010 void CImageEditorAppUi::SetTitlePaneTextL (const TDesC & aText) |
1988 { |
2011 { |
1989 const TInt KMaximumTitleTextLength = 13; |
2012 const TInt KMaximumTitleTextLength = 13; |
1990 |
2013 |
1991 if (iEditorView) |
2014 if (iEditorView) |
1992 { |
2015 { |
1993 HBufC * title_text = HBufC::NewLC(aText.Length()); |
2016 HBufC * title_text = HBufC::NewLC ( aText.Length() ); |
1994 TPtr title_text_ptr = title_text->Des(); |
2017 TPtr title_text_ptr = title_text->Des(); |
1995 |
2018 |
1996 // No truncation |
2019 // No truncation |
1997 if (aText.Length() - 4 < KMaximumTitleTextLength) |
2020 if ( aText.Length() - 4 < KMaximumTitleTextLength ) |
1998 { |
2021 { |
1999 // Copy whole file name |
2022 // Copy whole file name |
2000 title_text_ptr.Copy(aText); |
2023 title_text_ptr.Copy (aText); |
2001 } |
2024 } |
2002 // With truncation |
2025 |
2003 else |
2026 // With truncation |
2004 { |
2027 else |
2005 // Copy maximum amount of the file |
2028 { |
2006 title_text_ptr.Copy(aText.Left(KMaximumTitleTextLength)); |
2029 |
2007 |
2030 // Copy maximum amount of the file |
2008 // Append horizontal ellipsis |
2031 title_text_ptr.Copy ( aText.Left (KMaximumTitleTextLength) ); |
2009 title_text_ptr.Append(KBaflCharTruncation); |
2032 |
2010 // Append sequence number |
2033 // Append horizontal ellipsis |
2011 _LIT(KSearchWildcard, "*-???"); |
2034 title_text_ptr.Append ( KBaflCharTruncation ); |
2012 TInt offset = aText.Match(KSearchWildcard); |
2035 |
2013 if (offset != KErrNotFound) |
2036 // Append sequence number |
2014 { |
2037 _LIT(KSearchWildcard, "*-???"); |
2015 title_text_ptr.Append(aText.Mid(offset, 4)); |
2038 TInt offset = aText.Match (KSearchWildcard); |
2016 } |
2039 if ( offset != KErrNotFound ) |
2017 } |
2040 { |
2018 // Set title pane text |
2041 title_text_ptr.Append ( aText.Mid (offset, 4) ); |
2019 ((CImageEditorUIView *) iEditorView)->SetTitlePaneTextL(title_text_ptr); |
2042 } |
2020 |
2043 |
2021 CleanupStack::PopAndDestroy(); // title_text |
2044 } |
2022 } |
2045 |
2023 } |
2046 // Set title pane text |
2024 |
2047 ((CImageEditorUIView *)iEditorView)->SetTitlePaneTextL (title_text_ptr); |
2025 //============================================================================= |
2048 |
2026 void CImageEditorAppUi::ClearTitlePaneTextL() |
2049 CleanupStack::PopAndDestroy(); // title_text |
2027 { |
2050 } |
2028 if (iEditorView) |
2051 } |
2029 { |
2052 |
2030 ((CImageEditorUIView *) iEditorView)->ClearTitlePaneTextL(); |
2053 //============================================================================= |
2031 } |
2054 void CImageEditorAppUi::ClearTitlePaneTextL () |
2032 } |
2055 { |
2033 |
2056 if (iEditorView) |
2034 //============================================================================= |
2057 { |
2035 void CImageEditorAppUi::SetFileNameTitlePaneL(const TDesC& aFullFileName) |
2058 ((CImageEditorUIView *)iEditorView)->ClearTitlePaneTextL (); |
2036 { |
2059 } |
2037 TParsePtrC parser(aFullFileName); |
2060 } |
2038 SetTitlePaneTextL(parser.Name()); |
2061 |
2039 } |
2062 |
|
2063 //============================================================================= |
|
2064 void CImageEditorAppUi::SetFileNameTitlePaneL (const TDesC& aFullFileName) |
|
2065 { |
|
2066 TParsePtrC parser (aFullFileName); |
|
2067 SetTitlePaneTextL ( parser.Name() ); |
|
2068 } |
|
2069 |
2040 |
2070 //============================================================================= |
2041 //============================================================================= |
2071 void CImageEditorAppUi::ClearNaviPaneTextL() |
2042 void CImageEditorAppUi::ClearNaviPaneTextL() |
2072 { |
2043 { |
2073 if (iEditorView) |
2044 if (iEditorView) |
2074 { |
2045 { |
2075 ((CImageEditorUIView *)iEditorView)->ClearNaviPaneTextL(); |
2046 ((CImageEditorUIView *) iEditorView)->ClearNaviPaneTextL(); |
2076 } |
2047 } |
2077 } |
2048 } |
2078 |
|
2079 |
2049 |
2080 //============================================================================= |
2050 //============================================================================= |
2081 void CImageEditorAppUi::UpdateScreenRectL() |
2051 void CImageEditorAppUi::UpdateScreenRectL() |
2082 { |
2052 { |
2083 LOG(KImageEditorLogFile, "CImageEditorAppUi::UpdateScreenRectL()"); |
2053 LOG(KImageEditorLogFile, "CImageEditorAppUi::UpdateScreenRectL()"); |
2084 |
2054 |
2085 if (iEditorView == NULL || |
2055 if (iEditorView == NULL || iEditorManager == NULL || iImageController == NULL) |
2086 iEditorManager == NULL || |
|
2087 iImageController == NULL) |
|
2088 { |
2056 { |
2089 return; |
2057 return; |
2090 } |
2058 } |
2091 |
2059 |
2092 iEditorView->HandleCommandL (EImageEditorPreScreenModeChange); |
2060 iEditorView->HandleCommandL(EImageEditorPreScreenModeChange); |
2093 |
2061 |
2094 // Set Full screen parameter |
2062 // Set Full screen parameter |
2095 iResolutionUtil->SetFullScreen(iFullScreen); |
2063 iResolutionUtil->SetFullScreen(iFullScreen); |
2096 |
2064 |
2097 #ifdef LANDSCAPE_SUPPORT |
2065 #ifdef LANDSCAPE_SUPPORT |
2098 // Set landscape parameter |
2066 // Set landscape parameter |
2099 if (LandscapeScreenOrientation()) |
2067 if (LandscapeScreenOrientation()) |
2100 { |
2068 { |
2101 iResolutionUtil->SetLandscape(ETrue); |
2069 iResolutionUtil->SetLandscape(ETrue); |
2102 } |
2070 } |
2103 else |
2071 else |
2104 { |
2072 { |
2105 iResolutionUtil->SetLandscape(EFalse); |
2073 iResolutionUtil->SetLandscape(EFalse); |
2106 } |
2074 } |
2107 #else |
2075 #else |
2108 #ifdef LANDSCAPE_ONLY |
2076 #ifdef LANDSCAPE_ONLY |
2109 iResolutionUtil->SetLandscape(ETrue); |
2077 iResolutionUtil->SetLandscape(ETrue); |
2110 #else |
2078 #else |
2111 iResolutionUtil->SetLandscape(EFalse); |
2079 iResolutionUtil->SetLandscape(EFalse); |
2112 #endif |
2080 #endif |
2113 #endif |
2081 #endif |
2114 |
2082 |
2115 // Update view layout |
2083 // Update view layout |
2116 ((CImageEditorUIView *)iEditorView)->UpdateLayoutL( |
2084 ((CImageEditorUIView *) iEditorView)->UpdateLayoutL(iEikonEnv->ScreenDevice()->CurrentScreenMode()); |
2117 iEikonEnv->ScreenDevice()->CurrentScreenMode()); |
|
2118 |
2085 |
2119 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi: CurrentScreenMode() = %d", iEikonEnv->ScreenDevice()->CurrentScreenMode() ); |
2086 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi: CurrentScreenMode() = %d", iEikonEnv->ScreenDevice()->CurrentScreenMode() ); |
2120 |
2087 |
2121 // Set current screen size to resolution util |
2088 // Set current screen size to resolution util |
2122 iResolutionUtil->UpdateScreenMode(); |
2089 iResolutionUtil->UpdateScreenMode(); |
2123 |
2090 |
2124 // Check if screen size has changed |
2091 // Check if screen size has changed |
2125 TRect newScreenRect; |
2092 TRect newScreenRect; |
2126 CResolutionUtil::Self()->GetClientRect(newScreenRect); |
2093 CResolutionUtil::Self()->GetClientRect(newScreenRect); |
2127 if (iOldScreenRect == newScreenRect && !iOrientationChanged) |
2094 if (iOldScreenRect == newScreenRect && !iOrientationChanged) |
2128 { |
2095 { |
2129 LOG(KImageEditorLogFile, "CImageEditorAppUi: Not setting new preview image"); |
2096 LOG(KImageEditorLogFile, "CImageEditorAppUi: Not setting new preview image"); |
2130 return; |
2097 return; |
2131 } |
2098 } |
2132 iOldScreenRect = newScreenRect; |
2099 |
2133 |
2100 iOldScreenRect = newScreenRect; |
2134 LOG(KImageEditorLogFile, "CImageEditorAppUi: Setting new preview image"); |
2101 |
2135 |
2102 LOG(KImageEditorLogFile, "CImageEditorAppUi: Setting new preview image"); |
2136 // Create screen bitmap for new screen size |
2103 |
2137 iImageController->CreatePreviewBitmapL(); |
2104 // Create screen bitmap for new screen size |
2138 if ((iConstructionState == EConstructionStateReady || |
2105 iImageController->CreatePreviewBitmapL(); |
2139 iConstructionState == EConstructionStateInitUi) && |
2106 if ((iConstructionState == EConstructionStateReady || iConstructionState |
2140 !iSaving && iImageLoaded ) |
2107 == EConstructionStateInitUi) && !iSaving && iImageLoaded) |
2141 { |
2108 { |
2142 iEditorManager->SetScreenSizeL(); |
2109 iEditorManager->SetScreenSizeL(); |
2143 } |
2110 } |
2144 |
2111 |
2145 // Set the new image pointer to editor view |
2112 // Set the new image pointer to editor view |
2146 if (!iSaving) |
2113 if (!iSaving) |
2147 { |
2114 { |
2148 ((CImageEditorUIView *)iEditorView)->SetImageL ( |
2115 ((CImageEditorUIView *) iEditorView)->SetImageL( |
2149 iEditorManager->GetPreviewImage() |
2116 iEditorManager->GetPreviewImage()); |
2150 ); |
|
2151 } |
2117 } |
2152 else // if saving cannot update new image until saving is completed. |
2118 else // if saving cannot update new image until saving is completed. |
2153 { |
2119 { |
2154 iOrientationChanged = ETrue; |
2120 iOrientationChanged = ETrue; |
2155 ((CImageEditorUIView *)iEditorView)->SetImageL ( NULL ); |
2121 ((CImageEditorUIView *) iEditorView)->SetImageL(NULL); |
2156 } |
2122 } |
2157 |
2123 |
2158 // Set container extent to whole screen |
2124 // Set container extent to whole screen |
2159 CCoeControl * control = ((CImageEditorUIView *)iEditorView)->GetContainer(); |
2125 CCoeControl * control = |
|
2126 ((CImageEditorUIView *) iEditorView)->GetContainer(); |
2160 if (control) |
2127 if (control) |
2161 { |
2128 { |
2162 if (iFullScreen) |
2129 //if it is draw plug-in |
|
2130 if (iFullScreen || iPluginName == KDrawPlugin) |
2163 { |
2131 { |
2164 control->SetExtentToWholeScreen(); |
2132 control->SetExtentToWholeScreen(); |
2165 } |
2133 } |
2166 else |
2134 else |
2167 { |
2135 { |
2168 TRect rect; |
2136 TRect rect; |
2169 iResolutionUtil->GetClientRect(rect); |
2137 iResolutionUtil->GetClientRect(rect); |
2170 control->SetRect(rect); |
2138 control->SetRect(rect); |
2171 } |
2139 } |
2172 |
2140 |
2173 if (control->IsFocused()) |
2141 if (control->IsFocused()) |
2174 { |
2142 { |
2175 control->DrawNow(); |
2143 control->DrawNow(); |
2176 } |
2144 } |
2177 } |
2145 } |
2178 |
2146 |
2179 iEditorView->HandleCommandL (EImageEditorPostScreenModeChange); |
2147 iEditorView->HandleCommandL(EImageEditorPostScreenModeChange); |
2180 |
2148 |
2181 } |
2149 } |
2182 |
2150 |
2183 |
2151 //============================================================================= |
2184 //============================================================================= |
2152 void CImageEditorAppUi::ZoomL(const TZoom aZoom) |
2185 void CImageEditorAppUi::ZoomL (const TZoom aZoom) |
2153 { |
2186 { |
|
2187 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
|
2188 __ASSERT_ALWAYS( iEditorManager, User::Panic(KComponentName, EImageEditorPanicNoEditorManager) ); |
|
2189 SetBusy(); |
|
2190 |
|
2191 // Zoom |
|
2192 iEditorManager->ZoomL (aZoom); |
|
2193 |
|
2194 RenderL(); |
|
2195 iEditorManager->GetSystemParameters(); |
|
2196 |
|
2197 // Inform the view about current zoom mode |
|
2198 ((CImageEditorUIView *)iEditorView)-> |
|
2199 SetZoomModeL( iEditorManager->GetZoomMode() ); |
|
2200 } |
|
2201 |
|
2202 //============================================================================= |
|
2203 void CImageEditorAppUi::PanL (TDirection aDirection) |
|
2204 { |
|
2205 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
|
2206 __ASSERT_ALWAYS( iEditorManager, User::Panic(KComponentName, EImageEditorPanicNoEditorManager) ); |
|
2207 |
|
2208 iEditorView->HandleCommandL (EImageEditorPreGlobalPanChange); |
|
2209 |
|
2210 SetBusy(); |
|
2211 |
|
2212 // Pan |
|
2213 iEditorManager->PanL (aDirection); |
|
2214 |
|
2215 RenderL(); |
|
2216 iEditorManager->GetSystemParameters(); |
|
2217 |
|
2218 ResetBusy(); |
|
2219 |
|
2220 iEditorView->HandleCommandL (EImageEditorGlobalPanChanged); |
|
2221 } |
|
2222 |
|
2223 //============================================================================= |
|
2224 void CImageEditorAppUi::TouchPanL () |
|
2225 { |
|
2226 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
|
2227 __ASSERT_ALWAYS( iEditorManager, User::Panic(KComponentName, EImageEditorPanicNoEditorManager) ); |
|
2228 |
|
2229 iEditorView->HandleCommandL (EImageEditorPreGlobalPanChange); |
|
2230 |
|
2231 SetBusy(); |
|
2232 |
|
2233 // Fetch directions |
|
2234 TInt xMovement(0); |
|
2235 TInt yMovement(0); |
|
2236 |
|
2237 ((CImageEditorUIView *)iEditorView)->GetTouchPanDirections( xMovement, yMovement ); |
|
2238 |
|
2239 // Pan |
|
2240 iEditorManager->PanL( xMovement, yMovement ); |
|
2241 |
|
2242 RenderL(); |
|
2243 iEditorManager->GetSystemParameters(); |
|
2244 |
|
2245 ResetBusy(); |
|
2246 |
|
2247 iEditorView->HandleCommandL (EImageEditorGlobalPanChanged); |
|
2248 } |
|
2249 |
|
2250 //============================================================================= |
|
2251 void CImageEditorAppUi::RotateL (const TRotation aRot) |
|
2252 { |
|
2253 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2154 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2254 __ASSERT_ALWAYS( iEditorManager, User::Panic(KComponentName, EImageEditorPanicNoEditorManager) ); |
2155 __ASSERT_ALWAYS( iEditorManager, User::Panic(KComponentName, EImageEditorPanicNoEditorManager) ); |
|
2156 SetBusy(); |
|
2157 |
|
2158 // Zoom |
|
2159 iEditorManager->ZoomL(aZoom); |
|
2160 |
|
2161 RenderL(); |
|
2162 iEditorManager->GetSystemParameters(); |
|
2163 |
|
2164 // Inform the view about current zoom mode |
|
2165 ((CImageEditorUIView *) iEditorView)-> SetZoomModeL(iEditorManager->GetZoomMode()); |
|
2166 } |
|
2167 |
|
2168 //============================================================================= |
|
2169 void CImageEditorAppUi::PanL(TDirection aDirection) |
|
2170 { |
|
2171 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
|
2172 __ASSERT_ALWAYS( iEditorManager, User::Panic(KComponentName, EImageEditorPanicNoEditorManager) ); |
|
2173 |
|
2174 iEditorView->HandleCommandL(EImageEditorPreGlobalPanChange); |
|
2175 |
|
2176 SetBusy(); |
|
2177 |
|
2178 // Pan |
|
2179 iEditorManager->PanL(aDirection); |
|
2180 |
|
2181 RenderL(); |
|
2182 iEditorManager->GetSystemParameters(); |
|
2183 |
|
2184 ResetBusy(); |
|
2185 |
|
2186 iEditorView->HandleCommandL(EImageEditorGlobalPanChanged); |
|
2187 } |
|
2188 |
|
2189 //============================================================================= |
|
2190 void CImageEditorAppUi::TouchPanL() |
|
2191 { |
|
2192 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
|
2193 __ASSERT_ALWAYS( iEditorManager, User::Panic(KComponentName, EImageEditorPanicNoEditorManager) ); |
|
2194 |
|
2195 iEditorView->HandleCommandL(EImageEditorPreGlobalPanChange); |
|
2196 |
|
2197 SetBusy(); |
|
2198 |
|
2199 // Fetch directions |
|
2200 TInt xMovement(0); |
|
2201 TInt yMovement(0); |
|
2202 |
|
2203 ((CImageEditorUIView *) iEditorView)->GetTouchPanDirections(xMovement,yMovement); |
|
2204 |
|
2205 // Pan |
|
2206 iEditorManager->PanL(xMovement, yMovement); |
|
2207 |
|
2208 RenderL(); |
|
2209 iEditorManager->GetSystemParameters(); |
|
2210 |
|
2211 ResetBusy(); |
|
2212 |
|
2213 iEditorView->HandleCommandL(EImageEditorGlobalPanChanged); |
|
2214 } |
|
2215 |
|
2216 //============================================================================= |
|
2217 void CImageEditorAppUi::RotateL(const TRotation aRot) |
|
2218 { |
|
2219 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
|
2220 __ASSERT_ALWAYS( iEditorManager, User::Panic(KComponentName, EImageEditorPanicNoEditorManager) ); |
2255 |
2221 |
2256 if (!iEditorManager->IsPluginLoaded()) |
2222 if (!iEditorManager->IsPluginLoaded()) |
2257 { |
2223 { |
2258 iEditorManager->RotateL (aRot); |
2224 iEditorManager->RotateL(aRot); |
2259 RenderL(); |
2225 RenderL(); |
2260 SetUndoFlag(); |
2226 SetUndoFlag(); |
2261 iEditorView->HandleCommandL (EImageEditorGlobalRotationChanged); |
2227 iEditorView->HandleCommandL(EImageEditorGlobalRotationChanged); |
2262 } |
2228 } |
2263 } |
2229 } |
2264 |
2230 |
2265 //============================================================================= |
2231 //============================================================================= |
2266 void CImageEditorAppUi::LaunchLoadWaitNoteL () |
2232 void CImageEditorAppUi::LaunchLoadWaitNoteL() |
2267 { |
2233 { |
2268 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2234 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2269 |
2235 |
2270 SetBusy(); |
2236 SetBusy(); |
2271 ((CImageEditorUIView *)iEditorView)->LaunchWaitDialog( ); |
2237 ((CImageEditorUIView *) iEditorView)->LaunchWaitDialog(); |
2272 |
2238 |
2273 // if (!iWaitNote) |
2239 // if (!iWaitNote) |
2274 // { |
2240 // { |
2275 // ((CImageEditorUIView *)iEditorView)->LaunchLoadWaitDialogL( &iWaitNote, this ); |
2241 // ((CImageEditorUIView *)iEditorView)->LaunchLoadWaitDialogL( &iWaitNote, this ); |
2276 // } |
2242 // } |
2277 } |
2243 } |
2278 |
2244 |
2279 //============================================================================= |
2245 //============================================================================= |
2280 void CImageEditorAppUi::LaunchSaveWaitNoteL () |
2246 void CImageEditorAppUi::LaunchSaveWaitNoteL() |
2281 { |
2247 { |
2282 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2248 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2283 TAppUiOrientation orientation(EAppUiOrientationPortrait); |
2249 TAppUiOrientation orientation(EAppUiOrientationPortrait); |
2284 if(LandscapeScreenOrientation()) |
2250 if (LandscapeScreenOrientation()) |
2285 { |
2251 { |
2286 orientation = EAppUiOrientationLandscape; |
2252 orientation = EAppUiOrientationLandscape; |
2287 } |
2253 } |
2288 |
2254 |
2289 SetOrientationL(orientation); |
2255 SetOrientationL(orientation); |
2290 if (!iProgressNote) |
2256 if (!iProgressNote) |
2291 { |
2257 { |
2292 ((CImageEditorUIView *)iEditorView)->LaunchSaveWaitDialogL( &iProgressNote, 100, this ); |
2258 ((CImageEditorUIView *) iEditorView)->LaunchSaveWaitDialogL(&iProgressNote, 100, this); |
2293 iSaving = ETrue; |
2259 iSaving = ETrue; |
2294 } |
2260 } |
2295 } |
2261 } |
2296 |
2262 |
2297 //============================================================================= |
2263 //============================================================================= |
2298 void CImageEditorAppUi::KillWaitNote () |
2264 void CImageEditorAppUi::KillWaitNote() |
2299 { |
2265 { |
2300 |
2266 |
2301 |
2267 /* if (iWaitNote) |
2302 /* if (iWaitNote) |
2268 { |
2303 { |
2269 // If the application is exiting, iWaitNote->ProcessFinishedL() |
2304 // If the application is exiting, iWaitNote->ProcessFinishedL() |
2270 // apparently does not finish in time and does something after the |
2305 // apparently does not finish in time and does something after the |
2271 // application has been deleted, causing USER 0 panic on debug builds. |
2306 // application has been deleted, causing USER 0 panic on debug builds. |
2272 delete iWaitNote; |
2307 delete iWaitNote; |
2273 iWaitNote = NULL; |
2308 iWaitNote = NULL; |
2274 } */ |
2309 } */ |
2275 |
2310 |
2276 if (iProgressNote) |
2311 if (iProgressNote) |
2277 { |
2312 { |
2278 delete iProgressNote; |
2313 delete iProgressNote; |
2279 iProgressNote = NULL; |
2314 iProgressNote = NULL; |
2280 } |
2315 } |
2281 else |
2316 else |
2282 { |
2317 { |
2283 // This can be hidden in all cases. If dialog is not active, nothing |
2318 // This can be hidden in all cases. If dialog is not active, nothing |
2284 // special happens |
2319 // special happens |
2285 ((CImageEditorUIView *) iEditorView)->HideWaitDialog(); |
2320 ((CImageEditorUIView *)iEditorView)->HideWaitDialog( ); |
2286 // Commented due to multiple ResetBusy() call during initialization: |
2321 // Commented due to multiple ResetBusy() call during initialization: |
2287 //ResetBusy(); |
2322 //ResetBusy(); |
2288 } |
2323 } |
2289 } |
2324 } |
|
2325 |
|
2326 |
2290 |
2327 //============================================================================= |
2291 //============================================================================= |
2328 void CImageEditorAppUi::IncrementProgressBarL(const TInt aIncrement) |
2292 void CImageEditorAppUi::IncrementProgressBarL(const TInt aIncrement) |
2329 { |
2293 { |
2330 __ASSERT_ALWAYS( iProgressNote, User::Panic(KComponentName, EImageEditorPanicNoProgressDialog) ); |
2294 __ASSERT_ALWAYS( iProgressNote, User::Panic(KComponentName, EImageEditorPanicNoProgressDialog) ); |
2331 |
2295 |
2332 CEikProgressInfo * progi = iProgressNote->GetProgressInfoL(); |
2296 CEikProgressInfo * progi = iProgressNote->GetProgressInfoL(); |
2333 if (progi) |
2297 if (progi) |
2334 { |
2298 { |
2335 progi->IncrementAndDraw (aIncrement); |
2299 progi->IncrementAndDraw(aIncrement); |
2336 } |
2300 } |
2337 } |
2301 } |
2338 |
2302 |
2339 //============================================================================= |
2303 //============================================================================= |
2340 void CImageEditorAppUi::DialogDismissedL( TInt aButtonId ) |
2304 void CImageEditorAppUi::DialogDismissedL(TInt aButtonId) |
2341 { |
2305 { |
2342 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi::DialogDismissedL( %d )", aButtonId); |
2306 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi::DialogDismissedL( %d )", aButtonId); |
2343 |
2307 |
2344 if( aButtonId == EAknSoftkeyCancel ) |
2308 if (aButtonId == EAknSoftkeyCancel) |
2345 { |
2309 { |
2346 |
2310 if (!iSaving) |
2347 if ( !iSaving ) |
2311 { |
2348 { |
|
2349 iCallback->Cancel(); |
2312 iCallback->Cancel(); |
2350 iImageController->CancelOperation(ETrue); |
2313 iImageController->CancelOperation(ETrue); |
2351 } |
2314 } |
2352 else |
2315 else |
2353 { |
2316 { |
2354 iImageController->CancelOperation(); |
2317 iImageController->CancelOperation(); |
2355 } |
2318 } |
2356 |
2319 |
2357 iWaitNote = NULL; |
2320 iWaitNote = NULL; |
2358 |
2321 |
2359 ResetBusy(); |
2322 ResetBusy(); |
2360 } |
2323 } |
2361 } |
2324 } |
2362 |
2325 |
2363 //============================================================================= |
2326 //============================================================================= |
2364 TErrorHandlerResponse CImageEditorAppUi::HandleError ( |
2327 TErrorHandlerResponse CImageEditorAppUi::HandleError(TInt aError,const SExtendedError & aExtErr, TDes & aErrorText, TDes & aContextText) |
2365 TInt aError, |
2328 { |
2366 const SExtendedError & aExtErr, |
2329 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi::HandleError: %d", aError); |
2367 TDes & aErrorText, |
|
2368 TDes & aContextText |
|
2369 ) |
|
2370 { |
|
2371 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi::HandleError: %d", aError); |
|
2372 |
2330 |
2373 // Reset busy flag |
2331 // Reset busy flag |
2374 KillWaitNote (); |
2332 KillWaitNote(); |
2375 ResetBusy(); |
2333 ResetBusy(); |
2376 iCancelling = EFalse; |
2334 iCancelling = EFalse; |
2377 iSaving = EFalse; |
2335 iSaving = EFalse; |
2378 |
2336 |
2379 TErrorHandlerResponse ret = ENoDisplay; |
2337 TErrorHandlerResponse ret = ENoDisplay; |
2380 |
2338 |
2381 // Handle Image Editor errors |
2339 // Handle Image Editor errors |
2382 if ( (aError < KSIEEErrorBase) && (aError > KSIEEErrorMax) ) |
2340 if ((aError < KSIEEErrorBase) && (aError > KSIEEErrorMax)) |
2383 { |
2341 { |
2384 TRAPD ( err, HandleErrorL (aError) ); |
2342 TRAPD ( err, HandleErrorL (aError) ); |
2385 if ( err == KErrNoMemory ) |
2343 if (err == KErrNoMemory) |
2386 { |
2344 { |
2387 Exit(); |
2345 Exit(); |
2388 } |
2346 } |
2389 } |
2347 } |
2390 |
2348 |
2391 // Let the framework handle system errors |
2349 // Let the framework handle system errors |
2392 else if ( aError == KErrNoMemory ) |
2350 else if (aError == KErrNoMemory) |
2393 { |
2351 { |
2394 iImageController->Cancel(); |
2352 iImageController->Cancel(); |
2395 ret = CAknViewAppUi::HandleError (aError, aExtErr, aErrorText, aContextText); |
2353 ret = CAknViewAppUi::HandleError(aError, aExtErr, aErrorText,aContextText); |
2396 Exit (); |
2354 Exit(); |
2397 } |
2355 } |
2398 // KErrCancel is returned when Bluetooth send is cancelled |
2356 // KErrCancel is returned when Bluetooth send is cancelled |
2399 // No need to show error dialog |
2357 // No need to show error dialog |
2400 else if ( aError == KErrCancel ) |
2358 else if (aError == KErrCancel) |
2401 { |
2359 { |
2402 // Nothing to do |
2360 // Nothing to do |
2403 } |
2361 } |
2404 else if ((aError == KErrArgument) || (aError == KErrInUse)) |
2362 else if ((aError == KErrArgument) || (aError == KErrInUse)) |
2405 { |
2363 { |
2406 // Show error note |
2364 // Show error note |
2407 HandleErrorL (aError); |
2365 HandleErrorL(aError); |
2408 } |
2366 } |
2409 //end |
2367 //end |
2410 else if ( (aError <= KErrExtended) && (aError >= KLeaveExit) ) |
2368 else if ((aError <= KErrExtended) && (aError >= KLeaveExit)) |
2411 { |
2369 { |
2412 ret = CAknViewAppUi::HandleError (aError, aExtErr, aErrorText, aContextText); |
2370 ret = CAknViewAppUi::HandleError(aError, aExtErr, aErrorText,aContextText); |
2413 // Close plugin if error occurs, otherwise plugin may crash |
2371 // Close plugin if error occurs, otherwise plugin may crash |
2414 iEditorManager->ClosePlugin(); |
2372 iEditorManager->ClosePlugin(); |
2415 |
2373 |
2416 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2374 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2417 TRAP_IGNORE( ((CImageEditorUIView *)iEditorView)->ActivateMainViewL() ); |
2375 TRAP_IGNORE( ((CImageEditorUIView *)iEditorView)->ActivateMainViewL() ); |
2418 |
2376 |
2419 TRAP_IGNORE( ((CImageEditorUIView *)iEditorView)->SetImageL ( |
2377 TRAP_IGNORE( ((CImageEditorUIView *)iEditorView)->SetImageL (iEditorManager->GetPreviewImage()) ); |
2420 iEditorManager->GetPreviewImage()) ); |
2378 } |
2421 } |
2379 else |
2422 else |
2380 { |
2423 { |
2381 ret = CAknViewAppUi::HandleError(aError, aExtErr, aErrorText, |
2424 ret = CAknViewAppUi::HandleError (aError, aExtErr, aErrorText, aContextText); |
2382 aContextText); |
2425 // Close plugin if error occurs, otherwise plugin may crash |
2383 // Close plugin if error occurs, otherwise plugin may crash |
2426 iEditorManager->ClosePlugin(); |
2384 iEditorManager->ClosePlugin(); |
2427 |
2385 |
2428 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2386 __ASSERT_ALWAYS( iEditorView, User::Panic(KComponentName, EImageEditorPanicNoView) ); |
2429 |
2387 TRAPD( err, ((CImageEditorUIView *)iEditorView)->ActivateMainViewL() ); |
2430 TRAPD( err, ((CImageEditorUIView *)iEditorView)->ActivateMainViewL() ); |
2388 |
2431 |
2389 TRAP_IGNORE( ((CImageEditorUIView *)iEditorView)->SetImageL ( |
2432 TRAP_IGNORE( ((CImageEditorUIView *)iEditorView)->SetImageL ( |
2390 iEditorManager->GetPreviewImage()) ); |
2433 iEditorManager->GetPreviewImage()) ); |
2391 if (err == KErrNoMemory) |
2434 |
2392 { |
2435 if ( err == KErrNoMemory ) |
2393 Exit(); |
2436 { |
2394 } |
2437 Exit(); |
2395 } |
2438 } |
2396 return ret; |
2439 } |
2397 } |
2440 return ret; |
2398 |
2441 } |
2399 //============================================================================= |
2442 |
2400 void CImageEditorAppUi::HandleErrorL(const TInt aError) |
2443 //============================================================================= |
2401 { |
2444 void CImageEditorAppUi::HandleErrorL (const TInt aError) |
|
2445 { |
|
2446 |
2402 |
2447 // Show error note |
2403 // Show error note |
2448 ShowErrorNoteL (aError); |
2404 ShowErrorNoteL(aError); |
2449 |
2405 |
2450 // Handle error |
2406 // Handle error |
2451 switch ( aError ) |
2407 switch (aError) |
2452 { |
2408 { |
2453 |
2409 case KSIEEErrorOkToExit: |
2454 case KSIEEErrorOkToExit: |
2410 case KSIEEOpenFile: |
2455 case KSIEEOpenFile: |
2411 case KSIEEExifRead: |
2456 case KSIEEExifRead: |
2412 case KSIEEInternalNonRecoverable: |
2457 case KSIEEInternalNonRecoverable: |
2413 case KSIEEIncompatibleImage: |
2458 case KSIEEIncompatibleImage: |
2414 { |
2459 { |
|
2460 // For some weird reason, in some cases when trying to |
2415 // For some weird reason, in some cases when trying to |
2461 // exit from CImageEditorAppUi::OperationReadyL, calling |
2416 // exit from CImageEditorAppUi::OperationReadyL, calling |
2462 // Exit() here won't exit the application. |
2417 // Exit() here won't exit the application. |
2463 RunAppShutter(); |
2418 RunAppShutter(); |
2464 break; |
2419 break; |
2465 } |
2420 } |
2466 |
2421 |
2467 default: |
2422 default: |
2468 { |
2423 { |
2469 // Close plugin if error occurs, otherwise plugin may crash |
2424 // Close plugin if error occurs, otherwise plugin may crash |
2470 if (iEditorManager) |
2425 if (iEditorManager) |
2471 { |
2426 { |
2472 iEditorManager->ClosePlugin(); |
2427 iEditorManager->ClosePlugin(); |
2473 |
2428 |
2474 } |
2429 } |
2475 if (iEditorView) |
2430 if (iEditorView) |
2476 { |
2431 { |
2477 ((CImageEditorUIView *)iEditorView)->ActivateMainViewL(); |
2432 ((CImageEditorUIView *) iEditorView)->ActivateMainViewL(); |
2478 ((CImageEditorUIView *)iEditorView)->SetImageL ( |
2433 ((CImageEditorUIView *) iEditorView)->SetImageL(iEditorManager->GetPreviewImage()); |
2479 iEditorManager->GetPreviewImage()); |
2434 } |
2480 } |
2435 |
2481 |
2436 break; |
2482 break; |
2437 } |
2483 } |
2438 } |
2484 } |
2439 } |
2485 } |
2440 |
2486 |
2441 //============================================================================= |
2487 //============================================================================= |
2442 void CImageEditorAppUi::ShowErrorNoteL(const TInt aError) const |
2488 void CImageEditorAppUi::ShowErrorNoteL (const TInt aError) const |
2443 { |
2489 { |
|
2490 TInt res_id = -1; |
2444 TInt res_id = -1; |
2491 |
2445 |
2492 switch (aError) |
2446 switch (aError) |
2493 { |
2447 { |
2494 case KErrNotFound: |
2448 case KErrNotFound: |
2495 case KSIEEOpenFile: |
2449 case KSIEEOpenFile: |
2496 case KSIEEExifRead: |
2450 case KSIEEExifRead: |
2497 case KSIEEIncompatibleImage: |
2451 case KSIEEIncompatibleImage: |
2498 { |
2452 { |
2499 res_id = R_ERROR_LOADING; |
2453 res_id = R_ERROR_LOADING; |
2500 break; |
2454 break; |
2501 } |
2455 } |
2502 case KSIEESaveFile: |
2456 case KSIEESaveFile: |
2503 case KSIEEExifUpdate: |
2457 case KSIEEExifUpdate: |
2504 case KErrArgument: |
2458 case KErrArgument: |
2505 case KErrInUse: |
2459 case KErrInUse: |
2506 |
2460 |
2507 { |
2461 { |
2508 res_id = R_ERROR_SAVING; |
2462 res_id = R_ERROR_SAVING; |
2509 break; |
2463 break; |
2510 } |
2464 } |
2511 case KSIEENotEnoughDiskSpace: |
2465 case KSIEENotEnoughDiskSpace: |
2512 { |
2466 { |
2513 res_id = R_ERROR_NOT_ENOUGH_DISK_SPACE; |
2467 res_id = R_ERROR_NOT_ENOUGH_DISK_SPACE; |
2514 break; |
2468 break; |
2515 } |
2469 } |
2516 case KSIEEProcessFile: |
2470 case KSIEEProcessFile: |
2517 { |
2471 { |
2518 res_id = R_ERROR_PROCESSING; |
2472 res_id = R_ERROR_PROCESSING; |
2519 break; |
2473 break; |
2520 } |
2474 } |
2521 case KSIEEEngine: |
2475 case KSIEEEngine: |
2522 { |
2476 { |
2523 res_id = R_ERROR_ENGINE; |
2477 res_id = R_ERROR_ENGINE; |
2524 break; |
2478 break; |
2525 } |
2479 } |
2526 case KSIEEInternal: |
2480 case KSIEEInternal: |
2527 { |
2481 { |
2528 res_id = R_ERROR_INTERNAL; |
2482 res_id = R_ERROR_INTERNAL; |
2529 break; |
2483 break; |
2530 } |
2484 } |
2531 case KSIEEInternalNonRecoverable: |
2485 case KSIEEInternalNonRecoverable: |
2532 { |
2486 { |
2533 res_id = R_ERROR_INTERNAL_NON_RECOVERABLE; |
2487 res_id = R_ERROR_INTERNAL_NON_RECOVERABLE; |
2534 break; |
2488 break; |
2535 } |
2489 } |
2536 case KSIEEProtectedFile: |
2490 case KSIEEProtectedFile: |
2537 { |
2491 { |
2538 res_id = R_ERROR_PROTECTED_FILE; |
2492 res_id = R_ERROR_PROTECTED_FILE; |
2539 break; |
2493 break; |
2540 } |
2494 } |
2541 default: |
2495 default: |
2542 break; |
2496 break; |
2543 } |
2497 } |
2544 |
2498 |
2545 if (res_id != - 1) |
2499 if (res_id != -1) |
2546 { |
2500 { |
2547 HBufC * textdata = iEikonEnv->AllocReadResourceLC (res_id); |
2501 HBufC * textdata = iEikonEnv->AllocReadResourceLC(res_id); |
2548 TPtrC ptr = textdata->Des(); |
2502 TPtrC ptr = textdata->Des(); |
2549 |
2503 |
2550 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi::ShowErrorNoteL: \"%S\"", &ptr); |
2504 LOGFMT(KImageEditorLogFile, "CImageEditorAppUi::ShowErrorNoteL: \"%S\"", &ptr); |
2551 |
2505 |
2552 |
2506 CAknGlobalNote* globalNote = CAknGlobalNote::NewLC(); |
2553 CAknGlobalNote* globalNote = CAknGlobalNote::NewLC(); |
2507 TInt noteId = globalNote->ShowNoteL(EAknGlobalErrorNote, ptr); |
2554 TInt noteId = globalNote->ShowNoteL( EAknGlobalErrorNote, ptr ); |
2508 |
2555 |
2509 User::After(1500042); // waiting for 1 second |
2556 User::After(1500042); // waiting for 1 second |
2510 |
2557 |
2511 // discard note |
2558 // discard note |
2512 globalNote->CancelNoteL(noteId); |
2559 globalNote->CancelNoteL( noteId ); |
2513 |
2560 |
2514 CleanupStack::PopAndDestroy(); //textdata |
2561 |
2515 CleanupStack::PopAndDestroy(); // GlobalNote |
2562 CleanupStack::PopAndDestroy(); //textdata |
2516 } |
2563 CleanupStack::PopAndDestroy(); // GlobalNote |
2517 } |
2564 } |
|
2565 } |
|
2566 |
2518 |
2567 //============================================================================= |
2519 //============================================================================= |
2568 void CImageEditorAppUi::DeleteTempFiles() const |
2520 void CImageEditorAppUi::DeleteTempFiles() const |
2569 { |
2521 { |
2570 // Get the used temp directory path. |
2522 // Get the used temp directory path. |
2571 // Take drive letter from iDocumentName |
2523 // Take drive letter from iDocumentName |
2572 TParse parse; |
2524 TParse parse; |
2573 parse.Set (KTempPath, &iDocumentName, NULL); |
2525 parse.Set(KTempPath, &iDocumentName, NULL); |
2574 TPtrC tempDir = parse.DriveAndPath(); |
2526 TPtrC tempDir = parse.DriveAndPath(); |
2575 |
2527 |
2576 LOGFMT (KImageEditorLogFile, "CImageEditorAppUi::DeleteTempFiles(): %S", &tempDir); |
2528 LOGFMT (KImageEditorLogFile, "CImageEditorAppUi::DeleteTempFiles(): %S", &tempDir); |
2577 |
2529 // Delete all files in the temp directory |
2578 // Delete all files in the temp directory |
2530 _LIT(KAllFiles, "*.*"); |
2579 _LIT(KAllFiles, "*.*"); |
2531 TFindFile file_finder(iEikonEnv->FsSession()); |
2580 TFindFile file_finder (iEikonEnv->FsSession()); |
2532 CDir* file_list; |
2581 CDir* file_list; |
2533 TInt err = file_finder.FindWildByDir(KAllFiles, tempDir, file_list); |
2582 TInt err = file_finder.FindWildByDir (KAllFiles, tempDir, file_list); |
2534 while (err == KErrNone) |
2583 while (err==KErrNone) |
2535 { |
2584 { |
2536 TInt i; |
2585 TInt i; |
2537 for (i = 0; i < file_list->Count(); i++) |
2586 for (i=0; i<file_list->Count(); i++) |
2538 { |
2587 { |
2539 const TDesC& name = (*file_list)[i].iName; |
2588 const TDesC& name = (*file_list)[i].iName; |
2540 const TDesC& related = file_finder.File(); |
2589 const TDesC& related = file_finder.File(); |
2541 TParse fullentry; |
2590 TParse fullentry; |
2542 fullentry.Set(name, &related, NULL); |
2591 fullentry.Set (name, &related, NULL); |
2543 BaflUtils::DeleteFile(iEikonEnv->FsSession(), fullentry.FullName()); |
2592 BaflUtils::DeleteFile (iEikonEnv->FsSession(), fullentry.FullName()); |
2544 } |
2593 } |
2545 delete file_list; |
2594 delete file_list; |
2546 err = file_finder.FindWild(file_list); |
2595 err=file_finder.FindWild (file_list); |
2547 } |
2596 } |
2548 |
2597 |
2549 } |
2598 } |
|
2599 |
2550 |
2600 //============================================================================= |
2551 //============================================================================= |
2601 void CImageEditorAppUi::FinalizeSaveL() |
2552 void CImageEditorAppUi::FinalizeSaveL() |
2602 { |
2553 { |
2603 LOG(KImageEditorLogFile, "CImageEditorAppUi::FinalizeSaveL"); |
2554 LOG(KImageEditorLogFile, "CImageEditorAppUi::FinalizeSaveL"); |
2604 |
2555 |
2605 #ifdef FILE_TIME_STAMP_UPDATE |
2556 #ifdef FILE_TIME_STAMP_UPDATE |
2606 // Set the timestamp of the saved file to original file's timestamp + 2 seconds. |
2557 // Set the timestamp of the saved file to original file's timestamp + 2 seconds. |
2607 // The idea is to make the original and edited images appear next to each other. |
2558 // The idea is to make the original and edited images appear next to each other. |
2608 TEntry original; |
2559 TEntry original; |
2609 TInt err = iEikonEnv->FsSession().Entry( iSourceFileName, original ); |
2560 TInt err = iEikonEnv->FsSession().Entry( iSourceFileName, original ); |
2610 if (KErrNone == err) |
2561 if (KErrNone == err) |
2611 { |
2562 { |
2612 TTime newTime = original.iModified + TTimeIntervalSeconds (2); |
2563 TTime newTime = original.iModified + TTimeIntervalSeconds (2); |
2613 |
2564 |
2614 CFileMan* fileMan = CFileMan::NewL( iEikonEnv->FsSession() ); |
2565 CFileMan* fileMan = CFileMan::NewL( iEikonEnv->FsSession() ); |
2615 CleanupStack::PushL (fileMan); |
2566 CleanupStack::PushL (fileMan); |
2616 fileMan->Attribs(iDocumentName, 0, 0, newTime); // do not set or clear anything, mofify time |
2567 fileMan->Attribs(iDocumentName, 0, 0, newTime); // do not set or clear anything, mofify time |
2617 CleanupStack::PopAndDestroy (fileMan); |
2568 CleanupStack::PopAndDestroy (fileMan); |
2618 } |
2569 } |
2619 #endif |
2570 #endif |
2620 |
2571 |
2621 LOG(KImageEditorLogFile, "CImageEditorAppUi: Check if source image belongs to an album"); |
2572 LOG(KImageEditorLogFile, "CImageEditorAppUi: Check if source image belongs to an album"); |
2622 |
2573 |
2623 iSourceImageMgAlbumIdList.Reset(); |
2574 iSourceImageMgAlbumIdList.Reset(); |
2624 |
2575 |
2625 LOG(KImageEditorLogFile, "CImageEditorAppUi: publish the filename for provider"); |
2576 LOG(KImageEditorLogFile, "CImageEditorAppUi: publish the filename for provider"); |
2626 |
2577 |
2627 // Publish & Subscribe API used for delivering document name to AIW provider |
2578 // Publish & Subscribe API used for delivering document name to AIW provider |
2628 TInt err2 = RProperty::Define(KImageEditorProperties, EPropertyFilename, RProperty::EText); |
2579 TInt err2 = RProperty::Define(KImageEditorProperties, EPropertyFilename, |
2629 |
2580 RProperty::EText); |
2630 if (err2 != KErrAlreadyExists) |
2581 |
2631 { |
2582 if (err2 != KErrAlreadyExists) |
2632 User::LeaveIfError(err2); |
2583 { |
2633 } |
2584 User::LeaveIfError(err2); |
2634 |
2585 } |
2635 User::LeaveIfError(RProperty::Set(KImageEditorProperties, EPropertyFilename, iDocumentName)); |
2586 |
2636 |
2587 User::LeaveIfError(RProperty::Set(KImageEditorProperties, |
2637 LOG(KImageEditorLogFile, "CImageEditorAppUi::FinalizeSaveL out"); |
2588 EPropertyFilename, iDocumentName)); |
2638 } |
2589 |
|
2590 LOG(KImageEditorLogFile, "CImageEditorAppUi::FinalizeSaveL out"); |
|
2591 } |
2639 |
2592 |
2640 //============================================================================= |
2593 //============================================================================= |
2641 void CImageEditorAppUi::HandleVolumeUpL() |
2594 void CImageEditorAppUi::HandleVolumeUpL() |
2642 { |
2595 { |
2643 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleVolumeUpL: in"); |
2596 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleVolumeUpL: in"); |
2644 |
2597 |
2645 TKeyEvent key; |
2598 TKeyEvent key; |
2646 key.iScanCode = EStdKeyIncVolume; |
2599 key.iScanCode = EStdKeyIncVolume; |
2647 key.iCode = EKeyIncVolume; |
2600 key.iCode = EKeyIncVolume; |
2648 |
2601 |
2649 if( LandscapeScreenOrientation() ) |
2602 if (LandscapeScreenOrientation()) |
2650 { |
2603 { |
2651 key.iScanCode = EStdKeyDecVolume; |
2604 key.iScanCode = EStdKeyDecVolume; |
2652 key.iCode = EKeyDecVolume; |
2605 key.iCode = EKeyDecVolume; |
2653 } |
2606 } |
2654 |
2607 |
2655 key.iRepeats = 0; |
2608 key.iRepeats = 0; |
2656 iEikonEnv->SimulateKeyEventL( key, EEventKey ); |
2609 iEikonEnv->SimulateKeyEventL(key, EEventKey); |
2657 |
2610 |
2658 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleVolumeUpL: out"); |
2611 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleVolumeUpL: out"); |
2659 } |
2612 } |
2660 |
2613 |
2661 //============================================================================= |
2614 //============================================================================= |
2662 void CImageEditorAppUi::HandleVolumeDownL() |
2615 void CImageEditorAppUi::HandleVolumeDownL() |
2663 { |
2616 { |
2664 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleVolumeDownL: in"); |
2617 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleVolumeDownL: in"); |
2665 |
2618 |
2666 TKeyEvent key; |
2619 TKeyEvent key; |
2667 key.iScanCode = EStdKeyDecVolume; |
2620 key.iScanCode = EStdKeyDecVolume; |
2668 key.iCode = EKeyDecVolume; |
2621 key.iCode = EKeyDecVolume; |
2669 |
2622 |
2670 if( LandscapeScreenOrientation() ) |
2623 if (LandscapeScreenOrientation()) |
2671 { |
2624 { |
2672 key.iScanCode = EStdKeyIncVolume; |
2625 key.iScanCode = EStdKeyIncVolume; |
2673 key.iCode = EKeyIncVolume; |
2626 key.iCode = EKeyIncVolume; |
2674 } |
2627 } |
2675 |
2628 |
2676 key.iRepeats = 0; |
2629 key.iRepeats = 0; |
2677 iEikonEnv->SimulateKeyEventL( key, EEventKey ); |
2630 iEikonEnv->SimulateKeyEventL(key, EEventKey); |
2678 |
2631 |
2679 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleVolumeDownL: out"); |
2632 LOG(KImageEditorLogFile, "CImageEditorAppUi::HandleVolumeDownL: out"); |
2680 } |
2633 } |
2681 |
2634 |
2682 //============================================================================= |
2635 //============================================================================= |
2683 void CImageEditorAppUi::SaveImageOverWriteL(TBool aOverWrite) |
2636 void CImageEditorAppUi::SaveImageOverWriteL(TBool aOverWrite) |
2684 { |
2637 { |
2685 LOG(KImageEditorLogFile, "CImageEditorAppUi: SaveImageOverWriteL: in"); |
2638 LOG(KImageEditorLogFile, "CImageEditorAppUi: SaveImageOverWriteL: in"); |
2686 |
2639 |
2687 // Generate temporary save file name |
2640 // Generate temporary save file name |
2688 TParse tempFileParser; |
2641 TParse tempFileParser; |
2689 tempFileParser.Set (KTempSaveFile, &KTempPath, &iDocumentName); |
2642 tempFileParser.Set(KTempSaveFile, &KTempPath, &iDocumentName); |
2690 iTempSaveFileName.Copy (tempFileParser.FullName()); |
2643 iTempSaveFileName.Copy(tempFileParser.FullName()); |
2691 BaflUtils::EnsurePathExistsL (iEikonEnv->FsSession(), iTempSaveFileName); |
2644 BaflUtils::EnsurePathExistsL(iEikonEnv->FsSession(), iTempSaveFileName); |
2692 |
2645 |
2693 if (iExitFromApp) |
2646 if (iExitFromApp) |
2694 { |
2647 { |
2695 TInt exit = |
2648 TInt |
2696 ((CImageEditorUIView *)iEditorView)->LaunchExitWithoutSavingQueryL(); |
2649 exit = ((CImageEditorUIView *) iEditorView)->LaunchExitWithoutSavingQueryL(); |
2697 if (exit) |
2650 if (exit) |
2698 { |
2651 { |
2699 // Exit |
2652 // Exit |
2700 User::Leave (KSIEEErrorOkToExit); |
2653 User::Leave(KSIEEErrorOkToExit); |
2701 } |
2654 } |
2702 else |
2655 else |
2703 { |
2656 { |
2704 iExitFromApp = EFalse; |
2657 iExitFromApp = EFalse; |
2705 User::Leave(KSIEEInternal); |
2658 User::Leave(KSIEEInternal); |
2706 } |
2659 } |
2707 } |
2660 } |
2708 |
2661 |
2709 // overwrite the existing file |
2662 // overwrite the existing file |
2710 if (aOverWrite) |
2663 if (aOverWrite) |
2711 { |
2664 { |
2712 iDocumentName = iSourceFileName; |
2665 iDocumentName = iSourceFileName; |
2713 } |
2666 } |
2714 |
2667 |
2715 // save with a new file name |
2668 // save with a new file name |
2716 else |
2669 else |
2717 { |
2670 { |
2718 // Check document name if not saved yet or memory card removed |
2671 // Check document name if not saved yet or memory card removed |
2719 if ( !iImageSaved || |
2672 if (!iImageSaved || !BaflUtils::PathExists(iEikonEnv->FsSession(), |
2720 !BaflUtils::PathExists(iEikonEnv->FsSession(), iTempSaveFileName.Left(3))) |
2673 iTempSaveFileName.Left(3))) |
2721 { |
2674 { |
2722 // If not saved yet, check that document name is valid |
2675 // If not saved yet, check that document name is valid |
2723 CheckFileL (iDocumentName); |
2676 CheckFileL(iDocumentName); |
2724 } |
2677 } |
2725 } |
2678 } |
2726 |
2679 |
2727 // Set temp save image name to engine |
2680 // Set temp save image name to engine |
2728 iEditorManager->SetImageName (iTempSaveFileName); |
2681 iEditorManager->SetImageName(iTempSaveFileName); |
2729 |
2682 |
2730 // Launch save wait note |
2683 // Launch save wait note |
2731 LaunchSaveWaitNoteL (); |
2684 LaunchSaveWaitNoteL(); |
2732 |
2685 |
2733 iCallback->DoCallback (KObSaveCallbackID); |
2686 iCallback->DoCallback(KObSaveCallbackID); |
2734 LOG(KImageEditorLogFile, "CImageEditorAppUi: SaveImageOverWriteL: out"); |
2687 LOG(KImageEditorLogFile, "CImageEditorAppUi: SaveImageOverWriteL: out"); |
2735 } |
2688 } |
2736 |
2689 |
2737 //============================================================================= |
2690 //============================================================================= |
2738 TInt CImageEditorAppUi::QueryAndSaveL() |
2691 TInt CImageEditorAppUi::QueryAndSaveL() |
2739 { |
2692 { |
2740 |
2693 |
2741 TInt isSaved = 0; |
2694 TInt isSaved = 0; |
2742 TInt userSelection = 0; |
2695 TInt userSelection = 0; |
2743 TBool isFileOpen = EFalse; |
2696 TBool isFileOpen = EFalse; |
2744 RFs& fs = iEikonEnv->FsSession(); |
2697 RFs& fs = iEikonEnv->FsSession(); |
2745 TInt err = fs.IsFileOpen( iSourceFileName, isFileOpen ); |
2698 TInt err = fs.IsFileOpen(iSourceFileName, isFileOpen); |
2746 |
2699 |
2747 // Check if .jpg or .jpeg file |
2700 // Check if .jpg or .jpeg file |
2748 TBool isJpgExtension = EFalse; |
2701 TBool isJpgExtension = EFalse; |
2749 TParsePtrC fileParse ( iSourceFileName ); |
2702 TParsePtrC fileParse(iSourceFileName); |
2750 _LIT( KJpgExtension, ".jpg" ); |
2703 _LIT( KJpgExtension, ".jpg" ); |
2751 _LIT( KJpegExtension, ".jpeg" ); |
2704 _LIT( KJpegExtension, ".jpeg" ); |
2752 TPtrC extension( fileParse.Ext() ); |
2705 TPtrC extension(fileParse.Ext()); |
2753 if ( ( extension.MatchF( KJpgExtension ) == KErrNone ) || |
2706 if ((extension.MatchF(KJpgExtension) == KErrNone) || (extension.MatchF( |
2754 ( extension.MatchF( KJpegExtension ) == KErrNone ) ) |
2707 KJpegExtension) == KErrNone)) |
2755 { |
2708 { |
2756 isJpgExtension = ETrue; |
2709 isJpgExtension = ETrue; |
2757 } |
2710 } |
2758 |
2711 |
2759 // If source file is open (e.g. in ImageViewer application) don't give |
2712 // If source file is open (e.g. in ImageViewer application) don't give |
2760 // user an option to replace original but launch directly "Save with a |
2713 // user an option to replace original but launch directly "Save with a |
2761 // new name query. Don't give other that jpg originals. |
2714 // new name query. Don't give other that jpg originals. |
2762 if ( !isFileOpen && isJpgExtension ) |
2715 if (!isFileOpen && isJpgExtension) |
2763 { |
2716 { |
2764 // the user selects to save with a new file name |
2717 // the user selects to save with a new file name |
2765 // launch query with choices "Replace original" and |
2718 // launch query with choices "Replace original" and |
2766 // "Save with a new file name" |
2719 // "Save with a new file name" |
2767 userSelection = ( ( CImageEditorUIView *)iEditorView )->LaunchSaveImageQueryL(); |
2720 userSelection = ((CImageEditorUIView *) iEditorView)->LaunchSaveImageQueryL(); |
2768 } |
2721 } |
2769 SetOrientationL(Orientation()); |
2722 SetOrientationL(Orientation()); |
2770 SetLayoutAwareApp(EFalse); |
2723 SetLayoutAwareApp(EFalse); |
2771 // If user has selected "Save with a new file name" |
2724 // If user has selected "Save with a new file name" |
2772 if( userSelection == 0 ) |
2725 if (userSelection == 0) |
2773 { |
2726 { |
2774 |
2727 |
2775 // Multiple drive support enabled |
2728 // Multiple drive support enabled |
2776 #ifdef RD_MULTIPLE_DRIVE |
2729 #ifdef RD_MULTIPLE_DRIVE |
2777 |
2730 |
2778 TDriveNumber driveNumber; |
2731 TDriveNumber driveNumber; |
2779 TFileName driveAndPath; |
2732 TFileName driveAndPath; |
2780 // new multi drive dialog |
2733 // new multi drive dialog |
2781 CAknMemorySelectionDialogMultiDrive* multiDriveDlg = |
2734 CAknMemorySelectionDialogMultiDrive* multiDriveDlg = CAknMemorySelectionDialogMultiDrive::NewL(ECFDDialogTypeSave, |
2782 CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeSave, |
2735 EFalse); |
2783 EFalse ); |
2736 CleanupStack::PushL(multiDriveDlg); |
2784 CleanupStack::PushL( multiDriveDlg ); |
2737 |
2785 |
2738 // launch "Select memory" query (mds) |
2786 // launch "Select memory" query (mds) |
2739 if (multiDriveDlg->ExecuteL(driveNumber, &driveAndPath, NULL )) |
2787 if ( multiDriveDlg->ExecuteL( driveNumber, &driveAndPath, NULL ) ) |
2740 { |
2788 { |
2741 // Generate a default name for the new file |
2789 // Generate a default name for the new file |
2742 TInt err = ImageEditorUtils::GenerateNewFileNameL( |
2790 TInt err = ImageEditorUtils::GenerateNewFileNameL( |
2743 iEikonEnv->FsSession(), iSourceFileName, iDocumentName, |
2791 iEikonEnv->FsSession(), |
2744 driveAndPath, NULL ); |
2792 iSourceFileName, |
2745 |
2793 iDocumentName, |
2746 driveAndPath.Append(PathInfo::ImagesPath()); |
2794 driveAndPath, |
2747 |
2795 NULL ); |
2748 //Save as the original file format. |
2796 |
2749 iDocumentName.Delete(iDocumentName.Length() - 5, 4); |
2797 driveAndPath.Append( PathInfo::ImagesPath() ); |
2750 iDocumentName.Append(fileParse.Ext()); |
2798 |
2751 |
2799 // launch file name prompt dialog |
2752 // launch file name prompt dialog |
2800 // the generated name is shown as a default name in dialog |
2753 // the generated name is shown as a default name in dialog |
2801 TBuf<160> tmp( iDocumentName.Left(160) ); |
2754 |
2802 iSavingQuery = ETrue; |
2755 TBuf<160> tmp(iDocumentName.Left(160)); |
2803 if ( CAknFileNamePromptDialog::RunDlgLD( tmp, /* iDocumentName, */ |
2756 iSavingQuery = ETrue; |
2804 driveAndPath, |
2757 if (CAknFileNamePromptDialog::RunDlgLD(tmp, /* iDocumentName, */ |
2805 KNullDesC ) ) |
2758 driveAndPath, KNullDesC)) |
2806 { |
2759 { |
2807 iDocumentName.Copy( tmp ); |
2760 iDocumentName.Copy(tmp); |
2808 iSavingQuery = EFalse; |
2761 iSavingQuery = EFalse; |
2809 // add just queried filename to the path |
2762 // add just queried filename to the path |
2810 driveAndPath.Append( iDocumentName ); |
2763 driveAndPath.Append(iDocumentName); |
2811 |
2764 |
2812 iDocumentName = driveAndPath; |
2765 iDocumentName = driveAndPath; |
2813 |
2766 |
2814 SaveImageOverWriteL( EFalse ); |
2767 SaveImageOverWriteL(EFalse); |
2815 isSaved = 1; |
2768 isSaved = 1; |
2816 } |
2769 } |
2817 iSavingQuery = EFalse; |
2770 iSavingQuery = EFalse; |
2818 } |
2771 } |
2819 CleanupStack::PopAndDestroy( multiDriveDlg ); |
2772 CleanupStack::PopAndDestroy(multiDriveDlg); |
2820 |
2773 |
2821 #else // No multiple drive support |
2774 #else // No multiple drive support |
2822 CAknMemorySelectionDialog::TMemory selectedMemory( |
2775 CAknMemorySelectionDialog::TMemory selectedMemory( |
2823 CAknMemorySelectionDialog::EPhoneMemory ); |
2776 CAknMemorySelectionDialog::EPhoneMemory ); |
2824 |
2777 |
2825 // launch "Select memory" query |
2778 // launch "Select memory" query |
2826 if ( CAknMemorySelectionDialog::RunDlgLD( selectedMemory ) ) |
2779 if ( CAknMemorySelectionDialog::RunDlgLD( selectedMemory ) ) |
2827 { |
2780 { |
2828 // create path for the image |
2781 // create path for the image |
2829 TFileName driveAndPath; |
2782 TFileName driveAndPath; |
2830 ImageEditorUtils::TMemorySelection memorySelection = |
2783 ImageEditorUtils::TMemorySelection memorySelection = |
2831 ImageEditorUtils::ESelectPhone; |
2784 ImageEditorUtils::ESelectPhone; |
2832 if( selectedMemory == CAknMemorySelectionDialog::EPhoneMemory ) |
2785 if( selectedMemory == CAknMemorySelectionDialog::EPhoneMemory ) |
2833 { |
2786 { |
2834 memorySelection = ImageEditorUtils::ESelectPhone; |
2787 memorySelection = ImageEditorUtils::ESelectPhone; |
2835 driveAndPath.Copy( PathInfo::PhoneMemoryRootPath() ); |
2788 driveAndPath.Copy( PathInfo::PhoneMemoryRootPath() ); |
2836 driveAndPath.Append( PathInfo::ImagesPath() ); |
2789 driveAndPath.Append( PathInfo::ImagesPath() ); |
2837 } |
2790 } |
2838 else if ( selectedMemory == |
2791 else if ( selectedMemory == |
2839 CAknMemorySelectionDialog::EMemoryCard ) |
2792 CAknMemorySelectionDialog::EMemoryCard ) |
2840 { |
2793 { |
2841 memorySelection = ImageEditorUtils::ESelectMmc; |
2794 memorySelection = ImageEditorUtils::ESelectMmc; |
2842 driveAndPath.Copy( PathInfo::MemoryCardRootPath() ); |
2795 driveAndPath.Copy( PathInfo::MemoryCardRootPath() ); |
2843 driveAndPath.Append( PathInfo::ImagesPath() ); |
2796 driveAndPath.Append( PathInfo::ImagesPath() ); |
2844 } |
2797 } |
2845 |
2798 |
2846 TInt err = ImageEditorUtils::GenerateNewDocumentNameL( |
2799 TInt err = ImageEditorUtils::GenerateNewDocumentNameL( |
2847 iEikonEnv->FsSession(), |
2800 iEikonEnv->FsSession(), |
2848 iSourceFileName, |
2801 iSourceFileName, |
2849 iDocumentName, |
2802 iDocumentName, |
2850 &iSourceImageMgAlbumIdList, |
2803 &iSourceImageMgAlbumIdList, |
2851 NULL, |
2804 NULL, |
2852 memorySelection ); |
2805 memorySelection ); |
2853 |
2806 |
2854 |
2807 // launch file name prompt dialog |
2855 // launch file name prompt dialog |
2808 // the generated name is shown as a default name |
2856 // the generated name is shown as a default name |
2809 iSavingQuery = ETrue; |
2857 iSavingQuery = ETrue; |
2810 if ( CAknFileNamePromptDialog::RunDlgLD( iDocumentName, |
2858 if ( CAknFileNamePromptDialog::RunDlgLD( iDocumentName, |
2811 driveAndPath, |
2859 driveAndPath, |
2812 KNullDesC ) ) |
2860 KNullDesC ) ) |
2813 { |
2861 { |
2814 iSavingQuery = EFalse; |
2862 iSavingQuery = EFalse; |
2815 TInt err = ImageEditorUtils::GenerateFilePathL( |
2863 TInt err = ImageEditorUtils::GenerateFilePathL( |
2816 iEikonEnv->FsSession(), |
2864 iEikonEnv->FsSession(), |
2817 iSourceFileName, |
2865 iSourceFileName, |
2818 iDocumentName, |
2866 iDocumentName, |
2819 memorySelection |
2867 memorySelection |
2820 ); |
2868 ); |
2821 |
2869 |
2822 SaveImageOverWriteL( EFalse ); |
2870 SaveImageOverWriteL( EFalse ); |
2823 isSaved = 1; |
2871 isSaved = 1; |
2824 } |
2872 } |
2825 iSavingQuery = EFalse; |
2873 iSavingQuery = EFalse; |
2826 } |
2874 } |
|
2875 #endif |
2827 #endif |
2876 } |
2828 } |
2877 // the user selects to overwrite the original image |
2829 // the user selects to overwrite the original image |
2878 else if ( userSelection == 1 ) |
2830 else if (userSelection == 1) |
2879 { |
2831 { |
2880 SaveImageOverWriteL( ETrue ); |
2832 SaveImageOverWriteL(ETrue); |
2881 isSaved = 1; |
2833 isSaved = 1; |
2882 } |
2834 } |
2883 return isSaved; |
2835 return isSaved; |
2884 } |
2836 } |
2885 |
2837 |
2886 // ---------------------------------------------------------------------------- |
2838 // ---------------------------------------------------------------------------- |
2887 // CImageEditorAppUi::HandleVolumeKeyEvent |
2839 // CImageEditorAppUi::HandleVolumeKeyEvent |
2888 // ---------------------------------------------------------------------------- |
2840 // ---------------------------------------------------------------------------- |
2889 // |
2841 // |
2890 void CImageEditorAppUi::HandleVolumeKeyEvent( TRemConCoreApiOperationId aOperationId, |
2842 void CImageEditorAppUi::HandleVolumeKeyEvent( |
2891 TRemConCoreApiButtonAction /* aButtonAct */ ) |
2843 TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction /* aButtonAct */) |
2892 { |
2844 { |
2893 if (((CImageEditorUIView *)iEditorView)->GetContainer()) |
2845 if (((CImageEditorUIView *) iEditorView)->GetContainer()) |
2894 { |
2846 { |
2895 if(! ((CImageEditorUIView *)iEditorView)->GetContainer()->IsFocused() ) |
2847 if (!((CImageEditorUIView *) iEditorView)->GetContainer()->IsFocused()) |
2896 { |
2848 { |
2897 return; |
2849 return; |
2898 } |
2850 } |
2899 } |
2851 } |
2900 |
2852 |
2901 if( iForeground ) |
2853 if (iForeground) |
2902 { |
2854 { |
2903 TKeyEvent keyEvent; |
2855 TKeyEvent keyEvent; |
2904 if( aOperationId == ERemConCoreApiVolumeUp ) |
2856 if (aOperationId == ERemConCoreApiVolumeUp) |
2905 { |
2857 { |
2906 keyEvent.iScanCode = EStdKeyIncVolume; |
2858 keyEvent.iScanCode = EStdKeyIncVolume; |
2907 TRAP_IGNORE( HandleKeyEventL( keyEvent, EEventKey ) ); |
2859 TRAP_IGNORE( HandleKeyEventL( keyEvent, EEventKey ) ); |
2908 } |
2860 } |
2909 else if( aOperationId == ERemConCoreApiVolumeDown ) |
2861 else if (aOperationId == ERemConCoreApiVolumeDown) |
2910 { |
2862 { |
2911 keyEvent.iScanCode = EStdKeyDecVolume; |
2863 keyEvent.iScanCode = EStdKeyDecVolume; |
2912 TRAP_IGNORE( HandleKeyEventL( keyEvent, EEventKey ) ); |
2864 TRAP_IGNORE( HandleKeyEventL( keyEvent, EEventKey ) ); |
2913 } |
2865 } |
2914 } |
2866 } |
2915 } |
2867 } |
2916 |
2868 |
|
2869 void CImageEditorAppUi::InitialHorizontalDrawPlugin() |
|
2870 { |
|
2871 // // Get pointer to the view |
|
2872 CImageEditorUIView * view = (CImageEditorUIView *) iEditorView; |
|
2873 |
|
2874 TRect rect; |
|
2875 iResolutionUtil->GetClientRect(rect); |
|
2876 SetFullScreenL(); |
|
2877 // Create a plug-in control |
|
2878 // Ownership is moved to the plug-in |
|
2879 CCoeControl * control = NULL; |
|
2880 TInt err = iEditorManager->CreatePluginControlL(rect, view->GetContainer(), |
|
2881 control); |
|
2882 |
|
2883 LOG(KImageEditorLogFile, "CImageEditorAppUi: Plugin control created"); |
|
2884 |
|
2885 // The plug-in activation was cancelled |
|
2886 if (err != KErrNone) |
|
2887 { |
|
2888 // Cancel plug-in |
|
2889 iCancelling = ETrue; |
|
2890 iCallback->DoCallback(KObCancelCallbackID); |
|
2891 } |
|
2892 |
|
2893 // Activate plug-in |
|
2894 else |
|
2895 { |
|
2896 // Register control to UI |
|
2897 view->ActivatePluginL(control); |
|
2898 |
|
2899 LOG(KImageEditorLogFile, "CImageEditorAppUi: Plugin activated"); |
|
2900 |
|
2901 // If the filter did not have a control, close plug-in |
|
2902 if (!control) |
|
2903 { |
|
2904 iEditorManager->ClosePlugin(); |
|
2905 |
|
2906 } |
|
2907 |
|
2908 // Set the last opened image to editor view |
|
2909 ((CImageEditorUIView *) iEditorView)->SetImageL(iEditorManager->GetPreviewImage()); |
|
2910 |
|
2911 ResetBusy(); |
|
2912 } |
|
2913 } |
2917 // End of File |
2914 // End of File |