3
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors: Juha Kauppinen, Mika Hokkanen
|
|
13 |
*
|
|
14 |
* Description: Photo Browser
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <viewcli.h>
|
|
21 |
#include <aknviewappui.h>
|
|
22 |
#include <avkon.hrh>
|
|
23 |
#include <aknquerydialog.h>
|
|
24 |
#include <PhotoBrowser.rsg>
|
|
25 |
#include "ImagicViewBrowser.h"
|
|
26 |
#include "ImagicContainerBrowser.h"
|
|
27 |
#include "Imagic.hrh"
|
|
28 |
#include "ImagicAppUi.h"
|
|
29 |
#include <S32FILE.H>
|
|
30 |
#include "ImagicUtils.h"
|
|
31 |
#include "SendImageFile.h"
|
|
32 |
|
|
33 |
// ================= MEMBER FUNCTIONS =======================
|
|
34 |
|
|
35 |
// ---------------------------------------------------------
|
|
36 |
// CImagicViewBrowser::ConstructL(const TRect& aRect)
|
|
37 |
// EPOC two-phased constructor
|
|
38 |
// ---------------------------------------------------------
|
|
39 |
//
|
|
40 |
void CImagicViewBrowser::ConstructL(CImagicAppUi* aImagicAppUi)
|
|
41 |
{
|
|
42 |
DP0_IMAGIC(_L("CImagicViewBrowser::ConstructL++"));
|
|
43 |
|
|
44 |
iImagicAppUi = aImagicAppUi;
|
|
45 |
iApplicationFeature = EAppFeatureNone;
|
|
46 |
iFaceCroppingComplete = ETrue;
|
|
47 |
|
|
48 |
BaseConstructL( R_IMAGIC_VIEWBROWSER );
|
|
49 |
|
|
50 |
//Create bitmap for high res image loading
|
|
51 |
iBitmap = new (ELeave) CFbsBitmap();
|
|
52 |
#ifdef USE_RGBA
|
|
53 |
iBitmap->Create(TSize(10,10), EColor16MU);
|
|
54 |
#else
|
|
55 |
iBitmap->Create(TSize(10,10), EColor16M);
|
|
56 |
#endif
|
|
57 |
iTNCreationComplete = EFalse;
|
|
58 |
iFaceBrowsingComplete = EFalse;
|
|
59 |
|
|
60 |
//For dynamic options menu
|
|
61 |
iEditModeEnabledCmd1 = ETrue;
|
|
62 |
|
|
63 |
User::LeaveIfError(iFsSession.Connect());
|
|
64 |
|
|
65 |
#ifdef USE_SETTINGS_FILE
|
|
66 |
// Load user settings
|
|
67 |
TRAP_IGNORE(ReadSettingsFileL(KSettingFileName));
|
|
68 |
#endif
|
|
69 |
SetGridMode((TGridMode)iSettings.GetValue(CSettings::ESettingGridMode));
|
|
70 |
|
|
71 |
DP0_IMAGIC(_L("CImagicViewBrowser::ConstructL--"));
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------
|
|
75 |
// CImagicViewBrowser::~CImagicViewBrowser()
|
|
76 |
// Default destructor
|
|
77 |
// ---------------------------------------------------------
|
|
78 |
//
|
|
79 |
CImagicViewBrowser::~CImagicViewBrowser()
|
|
80 |
{
|
|
81 |
DP0_IMAGIC(_L("CImagicViewBrowser::~ConstructL++"));
|
|
82 |
|
|
83 |
#ifdef USE_SETTINGS_FILE
|
|
84 |
// Save user settings
|
|
85 |
if (iSettings.IsChanged())
|
|
86 |
TRAP_IGNORE(WriteSettingsFileL(KSettingFileName));
|
|
87 |
#endif
|
|
88 |
|
|
89 |
if ( iContainer )
|
|
90 |
{
|
|
91 |
AppUi()->RemoveFromViewStack( *this, iContainer );
|
|
92 |
}
|
|
93 |
iBitmap->Reset();
|
|
94 |
delete iBitmap;
|
|
95 |
delete iContainer;
|
|
96 |
iFsSession.Close();
|
|
97 |
|
|
98 |
iTempCordArray.Close();
|
|
99 |
iCoordinates.Close();
|
|
100 |
|
|
101 |
DP0_IMAGIC(_L("CImagicViewBrowser::~ConstructL--"));
|
|
102 |
}
|
|
103 |
|
|
104 |
// ---------------------------------------------------------
|
|
105 |
// TUid CImagicViewBrowser::Id()
|
|
106 |
// This returns the view ID
|
|
107 |
// ---------------------------------------------------------
|
|
108 |
//
|
|
109 |
TUid CImagicViewBrowser::Id() const
|
|
110 |
{
|
|
111 |
DP0_IMAGIC(_L("CImagicViewBrowser::id"));
|
|
112 |
return BrowserView;
|
|
113 |
}
|
|
114 |
|
|
115 |
// ---------------------------------------------------------
|
|
116 |
// CImagicViewBrowser::HandleCommandL(TInt aCommand)
|
|
117 |
// Here we handle commands for this view.
|
|
118 |
// Each view has their own HandleCommandL()
|
|
119 |
// ---------------------------------------------------------
|
|
120 |
//
|
|
121 |
void CImagicViewBrowser::HandleCommandL(TInt aCommand)
|
|
122 |
{
|
|
123 |
DP0_IMAGIC(_L("CImagicViewBrowser::HandleCommandL++"));
|
|
124 |
|
|
125 |
CIEEngine* engine = iImagicAppUi->GetEngine();
|
|
126 |
|
|
127 |
switch ( aCommand )
|
|
128 |
{
|
|
129 |
iContainer->DrawNow();
|
|
130 |
//case EAknSoftkeyOk:
|
|
131 |
case EAknSoftkeyBack:
|
|
132 |
{
|
|
133 |
if(iContainer->GetDrawMode() == CImagicContainerBrowser::EOneByOne){
|
|
134 |
iContainer->SetDrawMode(CImagicContainerBrowser::EGrid);
|
|
135 |
}
|
|
136 |
else if(iContainer->GetDrawMode() == CImagicContainerBrowser::EFaceBrowser){
|
|
137 |
iContainer->SetDrawMode(CImagicContainerBrowser::EOneByOne);
|
|
138 |
iFaceBrowsingMode = EFaceBrowserNone;
|
|
139 |
}
|
|
140 |
else if(iContainer->GetDrawMode() == CImagicContainerBrowser::EGrid){
|
|
141 |
AppUi()->HandleCommandL(EEikCmdExit);
|
|
142 |
}
|
|
143 |
//iContainer->DrawNow();
|
|
144 |
break;
|
|
145 |
}
|
|
146 |
|
|
147 |
case EAknSoftkeyExit:
|
|
148 |
{
|
|
149 |
AppUi()->HandleCommandL(EEikCmdExit);
|
|
150 |
break;
|
|
151 |
}
|
|
152 |
|
|
153 |
case EAknCmdExit:
|
|
154 |
{
|
|
155 |
AppUi()->HandleCommandL(EEikCmdExit);
|
|
156 |
break;
|
|
157 |
}
|
|
158 |
|
|
159 |
case EImagicCmdViewBrowserRotateRight:
|
|
160 |
{
|
|
161 |
CImageData* imageData = engine->GetImageData(iImagicAppUi->GetImageIndex());
|
|
162 |
TInt rotAngle = imageData->GetOrientation();
|
|
163 |
imageData->SetOrientation((rotAngle + 270)%360);
|
|
164 |
engine->SetImageRotation(iImagicAppUi->GetImageIndex());
|
|
165 |
engine->SetDBChanged(imageData);
|
|
166 |
break;
|
|
167 |
}
|
|
168 |
|
|
169 |
case EImagicCmdViewBrowserRotateLeft:
|
|
170 |
{
|
|
171 |
CImageData* imageData = engine->GetImageData(iImagicAppUi->GetImageIndex());
|
|
172 |
TInt rotAngle = imageData->GetOrientation();
|
|
173 |
imageData->SetOrientation((rotAngle + 90)%360);
|
|
174 |
engine->SetImageRotation(iImagicAppUi->GetImageIndex());
|
|
175 |
engine->SetDBChanged(imageData);
|
|
176 |
break;
|
|
177 |
}
|
|
178 |
|
|
179 |
//Deleting the Image...
|
|
180 |
case EImagicCmdViewBrowserDelete:
|
|
181 |
{
|
|
182 |
iContainer->DisplayDeleteQueryDialogL(R_DELETE_QUERY);
|
|
183 |
break;
|
|
184 |
}
|
|
185 |
|
|
186 |
//Switch grid mode
|
|
187 |
case EImagicCmdViewBrowserGridModeFolder:
|
|
188 |
SetGridMode(EGridModeFolder);
|
|
189 |
break;
|
|
190 |
|
|
191 |
case EImagicCmdViewBrowserGridModeTime:
|
|
192 |
SetGridMode(EGridModeTime);
|
|
193 |
break;
|
|
194 |
|
|
195 |
case EImagicCmdViewBrowserGridModePeople:
|
|
196 |
SetGridMode(EGridModePeople);
|
|
197 |
break;
|
|
198 |
|
|
199 |
//Show Image info
|
|
200 |
case EImagicCmdViewBrowserShowImageInfo:
|
|
201 |
{
|
|
202 |
//Get image Info ----------------->
|
|
203 |
|
|
204 |
const TInt KMaxInfoFileNameLength = 50;
|
|
205 |
|
|
206 |
TBuf<1024> buf;
|
|
207 |
//TPtr ptr(buf.Des());
|
|
208 |
TFileName fileName;
|
|
209 |
CImageData* imageData = engine->GetImageData(iImagicAppUi->GetImageIndex());
|
|
210 |
imageData->GetFileName(fileName, EFullSize);
|
|
211 |
|
|
212 |
// Make file name shorter if doesn't fit to info box well
|
|
213 |
if (fileName.Length() > KMaxInfoFileNameLength)
|
|
214 |
{
|
|
215 |
for(TInt i = fileName.Length() - KMaxInfoFileNameLength;i < fileName.Length();i++)
|
|
216 |
{
|
|
217 |
if (i > 3 && fileName[i] == '\\')
|
|
218 |
{
|
|
219 |
fileName.Replace(3, i - 3, _L("..."));
|
|
220 |
break;
|
|
221 |
}
|
|
222 |
}
|
|
223 |
}
|
|
224 |
|
|
225 |
buf.Append(fileName);
|
|
226 |
buf.Append(_L("\n"));
|
|
227 |
|
|
228 |
TDateTime dateTime = imageData->GetCreatedTime().DateTime();
|
|
229 |
TInt year, month, day, hour, minute, second;
|
|
230 |
day = dateTime.Day() + 1;
|
|
231 |
month = dateTime.Month() + 1;
|
|
232 |
year = dateTime.Year();
|
|
233 |
hour = dateTime.Hour();
|
|
234 |
minute = dateTime.Minute();
|
|
235 |
second = dateTime.Second();
|
|
236 |
|
|
237 |
TLocale locale;
|
|
238 |
TDateFormat dateFormat = locale.DateFormat();
|
|
239 |
|
|
240 |
TBuf<20> num1, num2, num3;
|
|
241 |
switch (dateFormat)
|
|
242 |
{
|
|
243 |
case EDateEuropean:
|
|
244 |
num1.Num(day);
|
|
245 |
buf.Append(num1);
|
|
246 |
buf.Append(locale.DateSeparator(1));
|
|
247 |
num1.Num(month);
|
|
248 |
buf.Append(num1);
|
|
249 |
buf.Append(locale.DateSeparator(2));
|
|
250 |
num1.Num(year);
|
|
251 |
buf.Append(num1);
|
|
252 |
break;
|
|
253 |
|
|
254 |
case EDateAmerican:
|
|
255 |
num1.Num(month);
|
|
256 |
buf.Append(num1);
|
|
257 |
buf.Append(locale.DateSeparator(1));
|
|
258 |
num1.Num(day);
|
|
259 |
buf.Append(num1);
|
|
260 |
buf.Append(locale.DateSeparator(2));
|
|
261 |
num1.Num(year);
|
|
262 |
buf.Append(num1);
|
|
263 |
break;
|
|
264 |
|
|
265 |
case EDateJapanese:
|
|
266 |
num1.Num(year);
|
|
267 |
buf.Append(num1);
|
|
268 |
buf.Append(locale.DateSeparator(1));
|
|
269 |
num1.Num(day);
|
|
270 |
buf.Append(num1);
|
|
271 |
buf.Append(locale.DateSeparator(2));
|
|
272 |
num1.Num(month);
|
|
273 |
buf.Append(num1);
|
|
274 |
break;
|
|
275 |
}
|
|
276 |
buf.Append(KSpace);
|
|
277 |
|
|
278 |
TTimeFormat timeFormat = locale.TimeFormat();
|
|
279 |
num2.Num(minute); if(minute < 10) num2.Insert(0, _L("0"));
|
|
280 |
num3.Num(second); if(second < 10) num3.Insert(0, _L("0"));
|
|
281 |
if (timeFormat == ETime12)
|
|
282 |
{
|
|
283 |
num1.Num(hour > 12 ? hour - 12 : hour);
|
|
284 |
if (locale.AmPmSymbolPosition() == ELocaleBefore)
|
|
285 |
{
|
|
286 |
buf.Append(hour < 12 ? _L("AM") : _L("PM"));
|
|
287 |
if (locale.AmPmSpaceBetween())
|
|
288 |
buf.Append(KSpace);
|
|
289 |
buf.Append(num1);
|
|
290 |
buf.Append(locale.TimeSeparator(1));
|
|
291 |
buf.Append(num2);
|
|
292 |
buf.Append(locale.TimeSeparator(2));
|
|
293 |
buf.Append(num3);
|
|
294 |
}
|
|
295 |
else
|
|
296 |
{
|
|
297 |
buf.Append(num1);
|
|
298 |
buf.Append(locale.TimeSeparator(1));
|
|
299 |
buf.Append(num2);
|
|
300 |
buf.Append(locale.TimeSeparator(2));
|
|
301 |
buf.Append(num3);
|
|
302 |
if (locale.AmPmSpaceBetween())
|
|
303 |
buf.Append(KSpace);
|
|
304 |
buf.Append(hour < 12 ? _L("AM") : _L("PM"));
|
|
305 |
}
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
num1.Num(hour);
|
|
310 |
buf.Append(num1);
|
|
311 |
buf.Append(locale.TimeSeparator(1));
|
|
312 |
buf.Append(num2);
|
|
313 |
buf.Append(locale.TimeSeparator(2));
|
|
314 |
buf.Append(num3);
|
|
315 |
}
|
|
316 |
buf.Append(KNewLine);
|
|
317 |
|
|
318 |
num1.Num(imageData->GetSize().iWidth);
|
|
319 |
num2.Num(imageData->GetSize().iHeight);
|
|
320 |
buf.Append(num1);
|
|
321 |
buf.Append(_L(" x "));
|
|
322 |
buf.Append(num2);
|
|
323 |
|
|
324 |
//buf.Append(_L("\n"));
|
|
325 |
//dateTime.TDateTime(aYear, aMonth, aDay, aHour, aMinute, aSecond, aMicroSecond);
|
|
326 |
|
|
327 |
iImagicAppUi->GetImagicUtils()->ExecutePopUpNote(buf, 10000, iContainer->GetScreenOrientation());
|
|
328 |
break;
|
|
329 |
}
|
|
330 |
|
|
331 |
//FaceBrowsing
|
|
332 |
case EImagicCmdViewFaceBrowsing:
|
|
333 |
{
|
|
334 |
//Set Face Browsing Mode
|
|
335 |
//iFaceBrowsingMode = EFaceBrowsing;
|
|
336 |
iFaceBrowsingMode = EFaceBrowsingShowRect;
|
|
337 |
iContainer->InitFaceBrowsing();
|
|
338 |
|
|
339 |
//Clear if face browser had old data
|
|
340 |
iContainer->ClearFaceArray();
|
|
341 |
ResetFaceCoords();
|
|
342 |
|
|
343 |
//Get the file for FB processing
|
|
344 |
TFileName fileName;
|
|
345 |
engine->GetFileNameL(iImagicAppUi->GetImageIndex(), ESize512x512, fileName);
|
|
346 |
|
|
347 |
//Check if background face browsing is still going on
|
|
348 |
//if(iFaceBrowsingComplete)
|
|
349 |
{
|
|
350 |
//If face browsing is complete just get face coordinates
|
|
351 |
engine->GetFaceCoordinates(fileName, iCoordinates);
|
|
352 |
|
|
353 |
if(iCoordinates.Count() >= 1)
|
|
354 |
{
|
|
355 |
if(iContainer)
|
|
356 |
iContainer->SetFaceCoords(iCoordinates);
|
|
357 |
|
|
358 |
iContainer->SetDrawMode(CImagicContainerBrowser::EFaceBrowser);
|
|
359 |
}
|
|
360 |
else
|
|
361 |
{
|
|
362 |
iImagicAppUi->GetImagicUtils()->ShowInfoNote(R_IMAGE_EDITOR_NO_FACES_FOUND_TEXT);
|
|
363 |
}
|
|
364 |
}
|
|
365 |
break;
|
|
366 |
}
|
|
367 |
|
|
368 |
// unno begin
|
|
369 |
//#ifdef DOUBLETAP_FACEBROWSING
|
|
370 |
//FaceBrowsing with coordinates
|
|
371 |
case EImagicCmdViewFaceBrowsingWithCoordinates:
|
|
372 |
{
|
|
373 |
CImageData* imageData = engine->GetImageData(iImagicAppUi->GetImageIndex());
|
|
374 |
if(imageData->IsImageReady(ESize512x512))
|
|
375 |
{
|
|
376 |
//Get the original file, and reset local coord storage
|
|
377 |
TFileName fileName;
|
|
378 |
engine->GetFileNameL(iImagicAppUi->GetImageIndex(), ESize512x512, fileName);
|
|
379 |
|
|
380 |
ResetFaceCoords();
|
|
381 |
|
|
382 |
//Check if background face browsing is still going on
|
|
383 |
if(/*iFaceBrowsingComplete &&*/ iContainer) // also make sure container exists
|
|
384 |
{
|
|
385 |
//ResetFaceCoords();
|
|
386 |
|
|
387 |
//If face browsing is complete just get face coordinates
|
|
388 |
engine->GetFaceCoordinates(fileName, iCoordinates);
|
|
389 |
|
|
390 |
if(iCoordinates.Count() >= 1)
|
|
391 |
{
|
|
392 |
iContainer->SetFaceCoords(iCoordinates);
|
|
393 |
|
|
394 |
TInt faceid;
|
|
395 |
if (iContainer->FindNearestFace(iContainer->GetLastTouchPoint(), faceid))
|
|
396 |
{
|
|
397 |
// start face browsing view if there are faces
|
|
398 |
iContainer->SetDrawMode(CImagicContainerBrowser::EFaceBrowser);
|
|
399 |
iContainer->SetCurrentFaceNro(faceid);
|
|
400 |
//iFaceBrowsingMode = EFaceBrowsing;
|
|
401 |
iFaceBrowsingMode = EFaceBrowsingShowRect;
|
|
402 |
iContainer->InitFaceBrowsing();
|
|
403 |
|
|
404 |
//unno
|
|
405 |
DP0_IMAGIC(_L(" ------------------ Face browsing"));
|
|
406 |
}
|
|
407 |
else
|
|
408 |
{
|
|
409 |
DP1_IMAGIC(_L(" ------------------ No near faces (%d)"), faceid);
|
|
410 |
}
|
|
411 |
}
|
|
412 |
else
|
|
413 |
{
|
|
414 |
DP0_IMAGIC(_L(" ------------------ No faces in picture"));
|
|
415 |
}
|
|
416 |
}
|
|
417 |
else
|
|
418 |
{
|
|
419 |
//Prioritise face browsing of selected picture if background process not completed
|
|
420 |
iContainer->ClearFaceArray();
|
|
421 |
|
|
422 |
DP0_IMAGIC(_L(" ------------------ Background process ongoing"));
|
|
423 |
}
|
|
424 |
}
|
|
425 |
break;
|
|
426 |
}
|
|
427 |
//#endif
|
|
428 |
|
|
429 |
//Remove false face detection Coords from exif data
|
|
430 |
case EImagicCmdViewBrowserRemoveFace:
|
|
431 |
{
|
|
432 |
break;
|
|
433 |
}
|
|
434 |
|
|
435 |
//Add new face detection to exif data
|
|
436 |
case EImagicCmdViewBrowserAddNewFace:
|
|
437 |
{
|
|
438 |
//Set Face Browsing Mode
|
|
439 |
iFaceBrowsingMode = EFaceBrowsingAddNewFace;
|
|
440 |
iImagicAppUi->GetImagicUtils()->ExecutePopUpNote(R_IMAGE_ADD_NEW_FACE_HELP_TEXT, 15000);
|
|
441 |
|
|
442 |
//Just set draw mode as oneByOne here
|
|
443 |
iContainer->SetDrawMode(CImagicContainerBrowser::EOneByOne);
|
|
444 |
break;
|
|
445 |
}
|
|
446 |
|
|
447 |
//Add as new face to exif data
|
|
448 |
case EImagicCmdViewBrowserAddAsThisNewFace:
|
|
449 |
{
|
|
450 |
break;
|
|
451 |
}
|
|
452 |
|
|
453 |
//Face cropping
|
|
454 |
case EImagicCmdViewBrowserFaceCropping:
|
|
455 |
{
|
|
456 |
iContainer->SetBGPSStatus(EFalse);
|
|
457 |
|
|
458 |
iFaceCroppingComplete = EFalse;
|
|
459 |
//iImagicAppUi->GetEngine()->StartFaceCropping(iImagicAppUi->GetImageIndex());
|
|
460 |
break;
|
|
461 |
}
|
|
462 |
|
|
463 |
case EImagicCmdViewBrowserHelp:
|
|
464 |
{
|
|
465 |
CArrayFix<TCoeHelpContext>* buf = iImagicAppUi->AppHelpContextL();
|
|
466 |
//TBuf<10> buf;
|
|
467 |
HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
|
|
468 |
break;
|
|
469 |
}
|
|
470 |
|
|
471 |
case EImagicCmdViewBrowserSend:
|
|
472 |
{
|
|
473 |
TFileName imageFileName;
|
|
474 |
|
|
475 |
iImagicAppUi->GetEngine()->GetFileNameL(iContainer->GetCurrentIndex(), EFullSize, imageFileName);
|
|
476 |
|
|
477 |
CSendImageFile *sender;
|
|
478 |
sender = CSendImageFile::NewL();
|
|
479 |
sender->SendFileViaSendUiL(imageFileName);
|
|
480 |
delete sender;
|
|
481 |
break;
|
|
482 |
}
|
|
483 |
|
|
484 |
default:
|
|
485 |
{
|
|
486 |
AppUi()->HandleCommandL( aCommand );
|
|
487 |
break;
|
|
488 |
}
|
|
489 |
}
|
|
490 |
DP0_IMAGIC(_L("CImagicViewBrowser::HandleCommandL--"));
|
|
491 |
}
|
|
492 |
|
|
493 |
void CImagicViewBrowser::SetGridMode(TGridMode aGridMode)
|
|
494 |
{
|
|
495 |
CIEEngine* engine = iImagicAppUi->GetEngine();
|
|
496 |
CIEImageList& imageList = engine->GetImageList();
|
|
497 |
//if (imageList.IsGroupingFolders() != aEnable)
|
|
498 |
{
|
|
499 |
iSettings.SetValue(CSettings::ESettingGridMode, aGridMode);
|
|
500 |
|
|
501 |
CImageData* imageData = NULL;
|
|
502 |
TInt index = 0;
|
|
503 |
|
|
504 |
if (iContainer)
|
|
505 |
{
|
|
506 |
// Get index of currently selected image
|
|
507 |
index = iContainer->GetCurrentIndex();
|
|
508 |
if (iContainer->IsUserInputGiven())
|
|
509 |
imageData = engine->GetImageData(iContainer->GetCurrentIndex());
|
|
510 |
}
|
|
511 |
|
|
512 |
imageList.SetGridMode(aGridMode);
|
|
513 |
|
|
514 |
if (iContainer)
|
|
515 |
{
|
|
516 |
// Update grid order
|
|
517 |
iContainer->ImageListChanged(0, EFalse);
|
|
518 |
|
|
519 |
// Set index of same image in new grid
|
|
520 |
if (imageData)
|
|
521 |
{
|
|
522 |
index = imageList.GetImageIndex(imageData);
|
|
523 |
iContainer->SetCurrentIndex(index);
|
|
524 |
}
|
|
525 |
}
|
|
526 |
}
|
|
527 |
}
|
|
528 |
|
|
529 |
/*
|
|
530 |
void CImagicViewBrowser::SingleFaceBrowsingComplete()
|
|
531 |
{
|
|
532 |
//iImagicAppUi->GetEngineL()->GetFaceCoordinates(tmpFileName, iCoordinates);
|
|
533 |
|
|
534 |
if(iCoordinates.Count() >= 1)
|
|
535 |
{
|
|
536 |
if(iContainer)
|
|
537 |
iContainer->SetFaceCoords(iCoordinates);
|
|
538 |
|
|
539 |
iContainer->SetDrawMode(CImagicContainerBrowser::EFaceBrowser);
|
|
540 |
}
|
|
541 |
else
|
|
542 |
{
|
|
543 |
iImagicAppUi->GetImagicUtils()->ShowInfoNote(R_IMAGE_EDITOR_NO_FACES_FOUND_TEXT);
|
|
544 |
//DisplayAddFacesQueryDialogL(R_ADD_FACE_MANUALLY_QUERY);
|
|
545 |
}
|
|
546 |
}
|
|
547 |
*/
|
|
548 |
|
|
549 |
|
|
550 |
void CImagicViewBrowser::DisplayAddFacesQueryDialogL(TInt aResourceId)
|
|
551 |
{
|
|
552 |
CAknQueryDialog* dlg;
|
|
553 |
dlg = new ( ELeave ) CAknQueryDialog();
|
|
554 |
TInt result = dlg->ExecuteLD( aResourceId );
|
|
555 |
|
|
556 |
if(result != KErrNone)
|
|
557 |
{
|
|
558 |
iFaceBrowsingMode = EFaceBrowsingAddNewFace;
|
|
559 |
//iImagicAppUi->GetImagicUtils()->ShowInfoNote(R_IMAGE_ADD_NEW_FACE_HELP_TEXT);
|
|
560 |
iImagicAppUi->GetImagicUtils()->ExecutePopUpNote(R_IMAGE_ADD_NEW_FACE_HELP_TEXT, 15000);
|
|
561 |
}
|
|
562 |
else
|
|
563 |
{
|
|
564 |
iFaceBrowsingMode = EFaceBrowserNone;
|
|
565 |
}
|
|
566 |
}
|
|
567 |
|
|
568 |
void CImagicViewBrowser::SetFaceBrowsingMode(TFaceBrowsingModes aMode)
|
|
569 |
{
|
|
570 |
DP0_IMAGIC(_L("CImagicViewBrowser::SetFaceBrowsingMode"));
|
|
571 |
iFaceBrowsingMode = aMode;
|
|
572 |
}
|
|
573 |
|
|
574 |
TFaceBrowsingModes CImagicViewBrowser::GetFaceBrowsingMode()
|
|
575 |
{
|
|
576 |
DP0_IMAGIC(_L("CImagicViewBrowser::GetFaceBrowsingMode"));
|
|
577 |
return iFaceBrowsingMode;
|
|
578 |
}
|
|
579 |
|
|
580 |
|
|
581 |
// ---------------------------------------------------------
|
|
582 |
// CImagicViewBrowser::HandleClientRectChange()
|
|
583 |
// ---------------------------------------------------------
|
|
584 |
//
|
|
585 |
void CImagicViewBrowser::HandleClientRectChange()
|
|
586 |
{
|
|
587 |
DP0_IMAGIC(_L("CImagicViewBrowser::HandleClientRectChange++"));
|
|
588 |
if ( iContainer )
|
|
589 |
{
|
|
590 |
iContainer->SetRect( ClientRect() );
|
|
591 |
iContainer->SetFullScreen();
|
|
592 |
}
|
|
593 |
DP0_IMAGIC(_L("CImagicViewBrowser::HandleClientRectChange--"));
|
|
594 |
}
|
|
595 |
|
|
596 |
// ---------------------------------------------------------
|
|
597 |
// CImagicViewBrowser::DoActivateL(...)
|
|
598 |
// This is called when a view needs to be activated.
|
|
599 |
// This creates container with its controls.
|
|
600 |
// ---------------------------------------------------------
|
|
601 |
//
|
|
602 |
void CImagicViewBrowser::DoActivateL(
|
|
603 |
const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
|
|
604 |
const TDesC8& /*aCustomMessage*/)
|
|
605 |
{
|
|
606 |
DP0_IMAGIC(_L("CImagicViewBrowser::DoActivateL++"));
|
|
607 |
|
|
608 |
// Create Container
|
|
609 |
if (!iContainer)
|
|
610 |
{
|
|
611 |
DP0_IMAGIC(_L("CImagicViewBrowser::DoActivateL - create container"));
|
|
612 |
iContainer = new (ELeave) CImagicContainerBrowser;
|
|
613 |
iContainer->SetMopParent(this);
|
|
614 |
iContainer->ConstructL( iImagicAppUi, this, ClientRect() );
|
|
615 |
AppUi()->AddToStackL( *this, iContainer );
|
|
616 |
|
|
617 |
if(iTNCreationComplete)
|
|
618 |
iContainer->SetBGPSStatus(ETrue);
|
|
619 |
else
|
|
620 |
iContainer->SetBGPSStatus(EFalse);
|
|
621 |
}
|
|
622 |
|
|
623 |
iImagicAppUi->CImagicAppUiReady();
|
|
624 |
iImagicAppUi->BrowserContainerInitialized();
|
|
625 |
|
|
626 |
DP0_IMAGIC(_L("CImagicViewBrowser::DoActivateL--"));
|
|
627 |
}
|
|
628 |
|
|
629 |
// ---------------------------------------------------------
|
|
630 |
// CImagicViewBrowser::HandleCommandL(TInt aCommand)
|
|
631 |
// This is called when a view needs to be deactivated.
|
|
632 |
// This destroys container with its controls.
|
|
633 |
// ---------------------------------------------------------
|
|
634 |
//
|
|
635 |
void CImagicViewBrowser::DoDeactivate()
|
|
636 |
{
|
|
637 |
DP0_IMAGIC(_L("CImagicViewBrowser::DoDeactivate++"));
|
|
638 |
if ( iContainer )
|
|
639 |
{
|
|
640 |
AppUi()->RemoveFromViewStack( *this, iContainer );
|
|
641 |
delete iContainer;
|
|
642 |
iContainer = NULL;
|
|
643 |
}
|
|
644 |
DP0_IMAGIC(_L("CImagicViewBrowser::DoDeactivate--"));
|
|
645 |
}
|
|
646 |
|
|
647 |
|
|
648 |
// Set bitmap to draw
|
|
649 |
void CImagicViewBrowser::SetActiveViewL(TUid /*aViewNro*/)
|
|
650 |
{
|
|
651 |
DP0_IMAGIC(_L("CImagicViewBrowser::SetActiveView"));
|
|
652 |
AppUi()->ActivateLocalViewL(BrowserView);
|
|
653 |
}
|
|
654 |
|
|
655 |
//void CImagicViewBrowser::LoadBitmapsToBrowserL(TInt aIndex, TBool aHighRes)
|
|
656 |
void CImagicViewBrowser::LoadBitmapsToBrowserL(CImageData* aImageData, TThumbSize aImageResolution)
|
|
657 |
{
|
|
658 |
DP0_IMAGIC(_L("CImagicViewBrowser::LoadBitmapsToBrowserL++"));
|
|
659 |
|
|
660 |
ASSERT(iContainer);
|
|
661 |
|
|
662 |
if (iContainer)
|
|
663 |
{
|
|
664 |
iImagicAppUi->GetEngine()->GetBitmapL(aImageData, iBitmap, aImageResolution);
|
|
665 |
iImageResolution = aImageResolution;
|
|
666 |
}
|
|
667 |
DP0_IMAGIC(_L("CImagicViewBrowser::LoadBitmapsToBrowserL--"));
|
|
668 |
}
|
|
669 |
|
|
670 |
|
|
671 |
//Callback from engine that bitmap has been loaded
|
|
672 |
void CImagicViewBrowser::BitmapLoadedByEngineL(TInt aError)
|
|
673 |
{
|
|
674 |
DP0_IMAGIC(_L("CImagicViewBrowser::BitmapLoadedByEngine++"));
|
|
675 |
|
|
676 |
iContainer->ImageLoadedL(aError, iBitmap, iImageResolution);
|
|
677 |
|
|
678 |
iContainer->SetLoadingOn(ETrue);
|
|
679 |
|
|
680 |
// Request to load next thumbnail
|
|
681 |
if (aError == KErrNone)
|
|
682 |
iContainer->DynamicLoadingL();
|
|
683 |
|
|
684 |
DP0_IMAGIC(_L("CImagicViewBrowser::BitmapLoadedByEngine--"));
|
|
685 |
}
|
|
686 |
|
|
687 |
CImagicContainerBrowser* CImagicViewBrowser::GetContainer()
|
|
688 |
{
|
|
689 |
DP0_IMAGIC(_L("CImagicViewBrowser::GetContainer"));
|
|
690 |
//We return null on purpose if container does not exits
|
|
691 |
return iContainer;
|
|
692 |
}
|
|
693 |
|
|
694 |
void CImagicViewBrowser::TNCreationComplete()
|
|
695 |
{
|
|
696 |
DP0_IMAGIC(_L("CImagicViewBrowser::TNCreationComplete++"));
|
|
697 |
iTNCreationComplete = ETrue;
|
|
698 |
|
|
699 |
if(iContainer)
|
|
700 |
iContainer->SetBGPSStatus(ETrue);
|
|
701 |
|
|
702 |
DP0_IMAGIC(_L("CImagicViewBrowser::TNCreationComplete--"));
|
|
703 |
}
|
|
704 |
|
|
705 |
void CImagicViewBrowser::FaceDetectionComplete()
|
|
706 |
{
|
|
707 |
DP0_IMAGIC(_L("CImagicViewBrowser::FaceBrowsingComplete++"));
|
|
708 |
iFaceBrowsingComplete = ETrue;
|
|
709 |
|
|
710 |
/*if(iContainer)
|
|
711 |
iContainer->SetTNCreationComplete(ETrue);*/
|
|
712 |
|
|
713 |
DP0_IMAGIC(_L("CImagicViewBrowser::FaceBrowsingComplete--"));
|
|
714 |
}
|
|
715 |
|
|
716 |
void CImagicViewBrowser::TNCreationBegin()
|
|
717 |
{
|
|
718 |
DP0_IMAGIC(_L("CImagicViewBrowser::TNCreationBegin++"));
|
|
719 |
iTNCreationComplete = EFalse;
|
|
720 |
|
|
721 |
if(iContainer)
|
|
722 |
iContainer->SetBGPSStatus(EFalse);
|
|
723 |
DP0_IMAGIC(_L("CImagicViewBrowser::TNCreationBegin--"));
|
|
724 |
}
|
|
725 |
|
|
726 |
TApplicationFeature CImagicViewBrowser::GetAppFeature()
|
|
727 |
{
|
|
728 |
return iApplicationFeature;
|
|
729 |
}
|
|
730 |
|
|
731 |
// ----------------------------------------------------------------------------
|
|
732 |
// CImagicViewBrowser::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
|
|
733 |
// This function is called by the EIKON framework just before it displays
|
|
734 |
// a menu pane. Sets the state of menu items dynamically according
|
|
735 |
// to the state of application data.
|
|
736 |
// ----------------------------------------------------------------------------
|
|
737 |
//
|
|
738 |
void CImagicViewBrowser::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
|
|
739 |
{
|
|
740 |
DP0_IMAGIC(_L("CImagicViewBrowser::DynInitMenuPaneL++"));
|
|
741 |
|
|
742 |
CTextureLoader* textLoader = iContainer->GetTextureLoader();
|
|
743 |
CImagicContainerBrowser::TDrawFunction drawMode = iContainer->GetDrawMode();
|
|
744 |
|
|
745 |
if(aResourceId == R_IMAGIC_VIEWBROWSER_MENU)
|
|
746 |
{
|
|
747 |
//Initialaly hide Edit, Crop and Delete
|
|
748 |
aMenuPane->SetItemDimmed(EImagicCmdViewEdit, ETrue); //Edit
|
|
749 |
aMenuPane->SetItemDimmed(EImagicCmdViewFaceBrowsing, ETrue); //FaceBrowsing
|
|
750 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserCropping, ETrue); //Crop
|
|
751 |
//aMenuPane->SetItemDimmed(EImagicCmdViewBrowserDelete, EFalse); //Delete
|
|
752 |
|
|
753 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserRemoveFace, ETrue);//Remove false detection Coords from exif data
|
|
754 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserAddNewFace, ETrue);//Add new face detection to exif data
|
|
755 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserAddAsThisNewFace, ETrue);//Add as new face to exif data
|
|
756 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserFaceCropping, ETrue);//Face cropping
|
|
757 |
|
|
758 |
aMenuPane->SetItemDimmed(ECmdRotateImage, EFalse); //Layouts
|
|
759 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserShowImageInfo, EFalse); //Image Info
|
|
760 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserHelp, ETrue); //Image Info
|
|
761 |
|
|
762 |
if((drawMode == CImagicContainerBrowser::EOneByOne || drawMode == CImagicContainerBrowser::EFaceBrowser))
|
|
763 |
{
|
|
764 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserGridModeFolder, ETrue);
|
|
765 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserGridModeTime, ETrue);
|
|
766 |
|
|
767 |
//if(iTNCreationComplete && iFaceCroppingComplete)
|
|
768 |
CImageData* imageData = iImagicAppUi->GetEngine()->GetImageData(iImagicAppUi->GetImageIndex());
|
|
769 |
if(imageData->IsImageReady(ESize512x512))
|
|
770 |
{
|
|
771 |
aMenuPane->SetItemDimmed(EImagicCmdViewEdit, ETrue); //Edit
|
|
772 |
if(imageData->GetNumberOfFaces() > 0)
|
|
773 |
aMenuPane->SetItemDimmed(EImagicCmdViewFaceBrowsing, EFalse); //FaceBrowsing
|
|
774 |
|
|
775 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserCropping, ETrue); //Crop
|
|
776 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserFaceCropping, ETrue);//Face cropping
|
|
777 |
|
|
778 |
if(iFaceBrowsingMode == EFaceBrowsing)
|
|
779 |
{
|
|
780 |
aMenuPane->SetItemDimmed(EImagicCmdViewFaceBrowsing, ETrue); //FaceBrowsing
|
|
781 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserAddAsThisNewFace, ETrue);//Add as new face to exif data
|
|
782 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserCropping, ETrue); //Crop
|
|
783 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserDelete, ETrue); //Delete
|
|
784 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserFaceCropping, ETrue);//Face cropping
|
|
785 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserShowImageInfo, EFalse); //Image Info
|
|
786 |
}
|
|
787 |
}
|
|
788 |
}
|
|
789 |
else
|
|
790 |
{
|
|
791 |
TGridMode gridMode = (TGridMode)iSettings.GetValue(CSettings::ESettingGridMode);
|
|
792 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserGridModeFolder, gridMode != EGridModeFolder);
|
|
793 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserGridModeTime, gridMode != EGridModeTime);
|
|
794 |
aMenuPane->SetItemDimmed(EImagicCmdViewBrowserGridModePeople,
|
|
795 |
#ifdef PEOPLE_VIEW
|
|
796 |
ETrue);
|
|
797 |
#else
|
|
798 |
gridMode != EGridModePeople);
|
|
799 |
#endif
|
|
800 |
}
|
|
801 |
}
|
|
802 |
|
|
803 |
DP0_IMAGIC(_L("CImagicViewBrowser::DynInitMenuPaneL--"));
|
|
804 |
}
|
|
805 |
|
|
806 |
void CImagicViewBrowser::WriteSettingsFileL(const TDesC& aName)
|
|
807 |
{
|
|
808 |
DP0_IMAGIC(_L("CImagicViewBrowser::WriteSettingsFileL++"));
|
|
809 |
|
|
810 |
TParse filestorename;
|
|
811 |
iFsSession.Parse(aName,filestorename);
|
|
812 |
|
|
813 |
RFileWriteStream writer;
|
|
814 |
writer.PushL();
|
|
815 |
User::LeaveIfError(writer.Replace(iFsSession, filestorename.FullName(), EFileWrite));
|
|
816 |
|
|
817 |
writer << iSettings;
|
|
818 |
writer.CommitL();
|
|
819 |
|
|
820 |
CleanupStack::PopAndDestroy();
|
|
821 |
|
|
822 |
DP0_IMAGIC(_L("CImagicViewBrowser::WriteSettingsFileL--"));
|
|
823 |
}
|
|
824 |
|
|
825 |
|
|
826 |
void CImagicViewBrowser::ReadSettingsFileL(const TDesC& aName)
|
|
827 |
{
|
|
828 |
DP0_IMAGIC(_L("CImagicViewBrowser::ReadSettingsFileL++"));
|
|
829 |
TParse filestorename;
|
|
830 |
iFsSession.Parse(aName,filestorename);
|
|
831 |
|
|
832 |
RFileReadStream reader;
|
|
833 |
reader.PushL();
|
|
834 |
|
|
835 |
User::LeaveIfError(reader.Open(iFsSession, filestorename.FullName(),EFileRead));
|
|
836 |
reader >> iSettings;
|
|
837 |
|
|
838 |
// Cleanup the stream object
|
|
839 |
CleanupStack::PopAndDestroy();
|
|
840 |
DP0_IMAGIC(_L("CImagicViewBrowser::ReadSettingsFileL--"));
|
|
841 |
}
|
|
842 |
|
|
843 |
//Returns true if file exists
|
|
844 |
/*TBool CImagicViewBrowser::FindFileName(const TDesC& aName)
|
|
845 |
{
|
|
846 |
DP0_IMAGIC(_L("CImagicViewBrowser::FindFileName++"));
|
|
847 |
TBool result = BaflUtils::FileExists(iFsSession, aName);
|
|
848 |
DP0_IMAGIC(_L("CImagicViewBrowser::FindFileName--"));
|
|
849 |
return result;
|
|
850 |
}*/
|
|
851 |
|
|
852 |
CSettings::CSettings()
|
|
853 |
{
|
|
854 |
iChanged = EFalse;
|
|
855 |
Mem::FillZ(iValues, sizeof(iValues));
|
|
856 |
}
|
|
857 |
|
|
858 |
//Functions from TModeSettings class
|
|
859 |
void CSettings::ExternalizeL(RWriteStream& aStream) const
|
|
860 |
{
|
|
861 |
aStream.WriteL((TUint8*)iValues, sizeof(iValues));
|
|
862 |
}
|
|
863 |
|
|
864 |
void CSettings::InternalizeL(RReadStream& aStream)
|
|
865 |
{
|
|
866 |
aStream.ReadL((TUint8*)iValues, sizeof(iValues));
|
|
867 |
}
|
|
868 |
|
|
869 |
void CSettings::SetValue(TSettingsValue aIndex, TInt aValue)
|
|
870 |
{
|
|
871 |
if (iValues[aIndex] != aValue)
|
|
872 |
{
|
|
873 |
iValues[aIndex] = aValue;
|
|
874 |
iChanged = ETrue;
|
|
875 |
}
|
|
876 |
}
|
|
877 |
|
|
878 |
TInt CSettings::GetValue(TSettingsValue aIndex) const
|
|
879 |
{
|
|
880 |
return iValues[aIndex];
|
|
881 |
}
|
|
882 |
|
|
883 |
TBool CSettings::IsChanged() const
|
|
884 |
{
|
|
885 |
return iChanged;
|
|
886 |
}
|
|
887 |
|
|
888 |
/*
|
|
889 |
void CImagicViewBrowser::SetFaceCoords(RArray<TRect>& aCoordinates)
|
|
890 |
{
|
|
891 |
DP0_IMAGIC(_L("CImagicViewBrowser::SetFaceCoords++"));
|
|
892 |
|
|
893 |
iCoordinates = aCoordinates;
|
|
894 |
|
|
895 |
if(iContainer)
|
|
896 |
iContainer->SetFaceCoords(aCoordinates);
|
|
897 |
|
|
898 |
TInt tmp = iCoordinates.Count();
|
|
899 |
for(TInt i = 0; i < tmp; i++)
|
|
900 |
{
|
|
901 |
iCoordinates.Remove(0);
|
|
902 |
}
|
|
903 |
|
|
904 |
DP0_IMAGIC(_L("CImagicViewBrowser::SetFaceCoords--"));
|
|
905 |
}
|
|
906 |
*/
|
|
907 |
void CImagicViewBrowser::ResetFaceCoords()
|
|
908 |
{
|
|
909 |
DP0_IMAGIC(_L("CImagicViewBrowser::ResetFaceCoords++"));
|
|
910 |
|
|
911 |
//iCoordinates.Reset();
|
|
912 |
TInt tmp = iCoordinates.Count();
|
|
913 |
for(TInt i = 0; i < tmp; i++)
|
|
914 |
{
|
|
915 |
iCoordinates.Remove(0);
|
|
916 |
}
|
|
917 |
}
|
|
918 |
|
|
919 |
// End of File
|
|
920 |
|