56
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Slide set dialog base class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// General.
|
|
20 |
#include <e32std.h>
|
|
21 |
#include <barsread.h>
|
|
22 |
#include <data_caging_path_literals.hrh>
|
|
23 |
#include <hlplch.h>
|
|
24 |
|
|
25 |
// UI components.
|
|
26 |
#include <avkon.hrh>
|
|
27 |
#include <AknUtils.h>
|
|
28 |
#include <aknappui.h>
|
|
29 |
#include <aknnavi.h>
|
|
30 |
#include <akntitle.h>
|
|
31 |
#include <aknlists.h>
|
|
32 |
#include <aknradiobuttonsettingpage.h>
|
|
33 |
#include <aknslidersettingpage.h>
|
|
34 |
#include <AknsSrvClient.h>
|
|
35 |
|
|
36 |
#include <AknsWallpaperUtils.h>
|
|
37 |
#include <centralrepository.h>
|
|
38 |
#include <AknSkinsInternalCRKeys.h>
|
|
39 |
|
|
40 |
// Other services.
|
|
41 |
#include <MGFetch.h>
|
|
42 |
#include <StringLoader.h>
|
|
43 |
#include <featmgr.h>
|
|
44 |
|
|
45 |
// Psln slide set specific.
|
|
46 |
#include "pslnslidesetdialog.h"
|
|
47 |
#include "pslnslidesetmodel.h"
|
|
48 |
#include "pslnslidesetdrmverifier.h"
|
|
49 |
#include "pslnslidesetconst.h"
|
|
50 |
|
|
51 |
// Local resources and definitions.
|
|
52 |
#include "pslnslidesetdialog.hrh"
|
|
53 |
#include <pslnslidesetdialogrsc.rsg>
|
|
54 |
#include <bautils.h>
|
|
55 |
|
|
56 |
// CONSTANTS
|
|
57 |
// Image fetch granularity.
|
|
58 |
const TInt KPslnSlideSetImagesGranualarity = 6;
|
|
59 |
// Middle softkey command ID
|
|
60 |
const TInt KPslnMSKControlID = 3;
|
|
61 |
// Size of ending '\t' in string.
|
|
62 |
const TInt KPslnStringEndMarkSize = 2;
|
|
63 |
// Length of setting item value.
|
|
64 |
const TInt KPslnSettingItemLength = 64;
|
|
65 |
|
|
66 |
// Path to compiled resource file.
|
|
67 |
_LIT( KPslnSlideSetDialogResourceFileName,
|
|
68 |
"z:pslnslidesetdialogrsc.rsc" );
|
|
69 |
|
|
70 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
71 |
|
|
72 |
void CPslnSlidesetDialog::BaseConstructL( const TInt aType )
|
|
73 |
{
|
|
74 |
FeatureManager::InitializeLibL();
|
|
75 |
|
|
76 |
// Validate type parameter.
|
|
77 |
if ( aType != EPslnScreensaverDialog &&
|
|
78 |
aType != EPslnWallpaperDialog )
|
|
79 |
{
|
|
80 |
User::Leave( KErrArgument );
|
|
81 |
}
|
|
82 |
iType = aType;
|
|
83 |
|
|
84 |
iModel = CPslnSlideSetModel::NewL();
|
|
85 |
// Feature support should only be read once. It should not change run-time.
|
|
86 |
iModel->GetFeatureSupportL( iFeaturesSupport );
|
|
87 |
|
|
88 |
// Find the resource file:
|
|
89 |
TParse* parse = new (ELeave) TParse;
|
|
90 |
CleanupStack::PushL( parse );
|
|
91 |
parse->Set(
|
|
92 |
KPslnSlideSetDialogResourceFileName,
|
|
93 |
&KDC_RESOURCE_FILES_DIR, NULL );
|
|
94 |
|
|
95 |
TFileName* fileName = new (ELeave) TFileName( parse->FullName() );
|
|
96 |
CleanupStack::PushL( fileName );
|
|
97 |
|
|
98 |
// Open resource file:
|
|
99 |
RFs& fs = iEikonEnv->FsSession();
|
|
100 |
BaflUtils::NearestLanguageFile( fs, *fileName );
|
|
101 |
iResourceOffset = iEikonEnv->AddResourceFileL( *fileName );
|
|
102 |
|
|
103 |
CleanupStack::PopAndDestroy( 2, parse );
|
|
104 |
|
|
105 |
CAknDialog::ConstructL( R_PSLN_SLIDE_DIALOG_MENUBAR );
|
|
106 |
|
|
107 |
// Remove tab group (if applicable).
|
|
108 |
ToggleDefaultNaviPaneL( ETrue );
|
|
109 |
|
|
110 |
// Retrieve previous title so that we can set it back when
|
|
111 |
// dialog exits.
|
|
112 |
if ( iAvkonAppUi )
|
|
113 |
{
|
|
114 |
CEikStatusPane* sp = iAvkonAppUi->StatusPane();
|
|
115 |
if ( sp )
|
|
116 |
{
|
|
117 |
CAknTitlePane* title = static_cast<CAknTitlePane*>(
|
|
118 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
119 |
|
|
120 |
if ( title )
|
|
121 |
{
|
|
122 |
const TDesC* prevTitle = title->Text();
|
|
123 |
iPreviousTitleTxt = prevTitle->AllocL();
|
|
124 |
}
|
|
125 |
}
|
|
126 |
}
|
|
127 |
iMGFetchRunning = EFalse;
|
|
128 |
}
|
|
129 |
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
132 |
// -----------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
CPslnSlidesetDialog::CPslnSlidesetDialog()
|
|
135 |
{
|
|
136 |
}
|
|
137 |
|
|
138 |
// Destructor
|
|
139 |
CPslnSlidesetDialog::~CPslnSlidesetDialog()
|
|
140 |
{
|
|
141 |
if ( this->IsFocused() )
|
|
142 |
{
|
|
143 |
CEikDialog::ButtonGroupContainer().RemoveCommandObserver( KPslnMSKControlID );
|
|
144 |
}
|
|
145 |
|
|
146 |
// Remove empty navi pane.
|
|
147 |
TRAP_IGNORE( ToggleDefaultNaviPaneL( EFalse ) );
|
|
148 |
|
|
149 |
iEikonEnv->EikAppUi()->RemoveFromStack( this );
|
|
150 |
|
|
151 |
delete iListBox;
|
|
152 |
delete iItems;
|
|
153 |
delete iModel;
|
|
154 |
delete iPreviousTitleTxt;
|
|
155 |
delete iSlideSetTypeItems;
|
|
156 |
|
|
157 |
if ( iResourceOffset != 0 )
|
|
158 |
{
|
|
159 |
iEikonEnv->DeleteResourceFile( iResourceOffset );
|
|
160 |
}
|
|
161 |
|
|
162 |
FeatureManager::UnInitializeLib();
|
|
163 |
}
|
|
164 |
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
// Gets current item.
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
TInt CPslnSlidesetDialog::CurrentItemIndex() const
|
|
170 |
{
|
|
171 |
return iListBox->CurrentItemIndex();
|
|
172 |
}
|
|
173 |
|
|
174 |
// ---------------------------------------------------------------------------
|
|
175 |
// Sets current item and re-draws the listbox.
|
|
176 |
// ---------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CPslnSlidesetDialog::SetCurrentItemIndexAndDraw( TInt aNewIndex )
|
|
179 |
{
|
|
180 |
if( ( aNewIndex >= 0 ) &&
|
|
181 |
( aNewIndex < iListBox->Model()->NumberOfItems() ) )
|
|
182 |
{
|
|
183 |
iListBox->SetCurrentItemIndexAndDraw( aNewIndex );
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
// Checks if feature is supported.
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
TBool CPslnSlidesetDialog::IsFeatureSupported( TInt aFeatureID )
|
|
192 |
{
|
|
193 |
if ( ( aFeatureID >= 0 ) && ( aFeatureID < KPslnMaxFeatureID ) )
|
|
194 |
{
|
|
195 |
return iFeaturesSupport.IsSet( aFeatureID );
|
|
196 |
}
|
|
197 |
else
|
|
198 |
{
|
|
199 |
// invalid feature value.
|
|
200 |
return EFalse;
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
// ---------------------------------------------------------------------------
|
|
205 |
// Sets title pane text.
|
|
206 |
// ---------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
void CPslnSlidesetDialog::SetTitlePaneL( const TInt aResourceId )
|
|
209 |
{
|
|
210 |
CEikStatusPane* sp = iAvkonAppUi->StatusPane();
|
|
211 |
CAknTitlePane* titlePane =
|
|
212 |
static_cast<CAknTitlePane*> (
|
|
213 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
214 |
if ( titlePane )
|
|
215 |
{
|
|
216 |
HBufC* titleBuf = StringLoader::LoadLC( aResourceId );
|
|
217 |
titlePane->SetTextL( *titleBuf );
|
|
218 |
CleanupStack::PopAndDestroy( titleBuf );
|
|
219 |
}
|
|
220 |
}
|
|
221 |
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
// Creates a specific setting item.
|
|
224 |
// ---------------------------------------------------------------------------
|
|
225 |
//
|
|
226 |
void CPslnSlidesetDialog::MakeItemL( const TInt aIndex )
|
|
227 |
{
|
|
228 |
// Check that parameter is valid.
|
|
229 |
if ( aIndex > iItems->Count() || aIndex < 0 )
|
|
230 |
{
|
|
231 |
User::Leave( KErrArgument );
|
|
232 |
}
|
|
233 |
TInt currentValue = KErrNotFound;
|
|
234 |
switch( aIndex )
|
|
235 |
{
|
|
236 |
case EPslnSlideSetImagesId:
|
|
237 |
{
|
|
238 |
if ( IsFeatureSupported( EPslnSlideSetFeatureRandom ) &&
|
|
239 |
( iType == EPslnScreensaverDialog ) )
|
|
240 |
{
|
|
241 |
currentValue = iModel->GetSlideSetType( iType );
|
|
242 |
SetSettingPageValueToListL(
|
|
243 |
*iSlideSetTypeItems,
|
|
244 |
aIndex,
|
|
245 |
currentValue,
|
|
246 |
EFalse );
|
|
247 |
}
|
|
248 |
else
|
|
249 |
{
|
|
250 |
// Get number of images.
|
|
251 |
HBufC* item = (*iItems)[aIndex].AllocL();
|
|
252 |
TInt slideSetFileType = EAknsSrvInifileSSWP;
|
|
253 |
if ( iType == EPslnScreensaverDialog )
|
|
254 |
{
|
|
255 |
slideSetFileType = EAknsSrvInifileSSSS;
|
|
256 |
}
|
|
257 |
currentValue =
|
|
258 |
iModel->GetImageCountInSlideSetL( slideSetFileType );
|
|
259 |
|
|
260 |
// If there are images already selected, the number of images
|
|
261 |
// needs to be shown in the setting page.
|
|
262 |
if ( currentValue > 0 )
|
|
263 |
{
|
|
264 |
TInt resourceId =
|
|
265 |
SelectResourceStringForImages( currentValue );
|
|
266 |
HBufC* valueStr = NULL;
|
|
267 |
// Use singular form, if only one image.
|
|
268 |
if ( currentValue == 1 )
|
|
269 |
{
|
|
270 |
valueStr = StringLoader::LoadLC( resourceId );
|
|
271 |
}
|
|
272 |
// Otherwise plural.
|
|
273 |
else
|
|
274 |
{
|
|
275 |
valueStr = StringLoader::LoadLC(
|
|
276 |
resourceId,
|
|
277 |
currentValue );
|
|
278 |
}
|
|
279 |
// for A&H number conversion
|
|
280 |
TPtr bufPtr = valueStr->Des();
|
|
281 |
if( AknTextUtils::DigitModeQuery(
|
|
282 |
AknTextUtils::EDigitModeShownToUser ) )
|
|
283 |
{
|
|
284 |
AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
|
|
285 |
}
|
|
286 |
// make room for value and end mark.
|
|
287 |
item = item->ReAllocL(
|
|
288 |
item->Length() +
|
|
289 |
bufPtr.Length() +
|
|
290 |
KPslnStringEndMarkSize );
|
|
291 |
TPtr expandedPtr = item->Des();
|
|
292 |
expandedPtr.Insert( item->Length(), bufPtr );
|
|
293 |
CleanupStack::PopAndDestroy( valueStr );
|
|
294 |
}
|
|
295 |
else
|
|
296 |
{
|
|
297 |
if ( iType == EPslnWallpaperDialog )
|
|
298 |
{
|
|
299 |
TInt type = KErrNone;
|
|
300 |
CRepository* rep = CRepository::NewL( KCRUidPersonalisation );
|
|
301 |
rep->Get( KPslnWallpaperType,type );
|
|
302 |
const TInt SlideSetWPType = 2;
|
|
303 |
if ( type == SlideSetWPType )
|
|
304 |
{
|
|
305 |
AknsWallpaperUtils::SetIdleWallpaper( KNullDesC, NULL );
|
|
306 |
}
|
|
307 |
delete rep;
|
|
308 |
}
|
|
309 |
}
|
|
310 |
CleanupStack::PushL( item );
|
|
311 |
TPtr ptr = item->Des();
|
|
312 |
iItemArray->InsertL( aIndex, ptr );
|
|
313 |
CleanupStack::PopAndDestroy( item );
|
|
314 |
}
|
|
315 |
}
|
|
316 |
break;
|
|
317 |
case EPslnSlideSetDurationId:
|
|
318 |
{
|
|
319 |
if ( iType == EPslnScreensaverDialog )
|
|
320 |
{
|
|
321 |
currentValue = iModel->GetSlideSetDuration();
|
|
322 |
|
|
323 |
SetSliderValueToListL(
|
|
324 |
aIndex,
|
|
325 |
currentValue,
|
|
326 |
R_PSLN_DURATION_SLIDER );
|
|
327 |
}
|
|
328 |
else
|
|
329 |
{
|
|
330 |
currentValue = iModel->GetSlideSetInterval();
|
|
331 |
|
|
332 |
// Last parameter is whether or not A&H numeric conversion should be done.
|
|
333 |
SetSettingPageValueToListL(
|
|
334 |
*iIntervalItems,
|
|
335 |
aIndex,
|
|
336 |
currentValue,
|
|
337 |
ETrue );
|
|
338 |
}
|
|
339 |
}
|
|
340 |
break;
|
|
341 |
case EPslnSlideSetBacklightId:
|
|
342 |
{
|
|
343 |
currentValue = iModel->GetSlideSetBacklight();
|
|
344 |
|
|
345 |
SetSliderValueToListL(
|
|
346 |
aIndex,
|
|
347 |
currentValue,
|
|
348 |
R_PSLN_BACKLIGHT_SLIDER );
|
|
349 |
}
|
|
350 |
break;
|
|
351 |
default:
|
|
352 |
break;
|
|
353 |
}
|
|
354 |
}
|
|
355 |
|
|
356 |
// ---------------------------------------------------------------------------
|
|
357 |
// Sets middle softkey label.
|
|
358 |
// ---------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
void CPslnSlidesetDialog::SetMiddleSoftKeyLabelL(
|
|
361 |
const TInt aResourceId, const TInt aCommandId )
|
|
362 |
{
|
|
363 |
HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
|
|
364 |
TPtr mskPtr = middleSKText->Des();
|
|
365 |
CEikDialog::ButtonGroupContainer().AddCommandToStackL(
|
|
366 |
KPslnMSKControlID,
|
|
367 |
aCommandId,
|
|
368 |
mskPtr );
|
|
369 |
CEikDialog::ButtonGroupContainer().UpdateCommandObserverL(
|
|
370 |
KPslnMSKControlID,
|
|
371 |
*this );
|
|
372 |
CleanupStack::PopAndDestroy( middleSKText );
|
|
373 |
}
|
|
374 |
|
|
375 |
// -----------------------------------------------------------------------------
|
|
376 |
// Layouts dialog before it is visible.
|
|
377 |
// -----------------------------------------------------------------------------
|
|
378 |
//
|
|
379 |
void CPslnSlidesetDialog::PreLayoutDynInitL()
|
|
380 |
{
|
|
381 |
iEikonEnv->EikAppUi()->AddToStackL( this, ECoeStackPriorityDialog );
|
|
382 |
CreateSettingsListL();
|
|
383 |
CEikDialog::PreLayoutDynInitL();
|
|
384 |
}
|
|
385 |
|
|
386 |
// -----------------------------------------------------------------------------
|
|
387 |
// Reimplements CAknDialog::ProcessCommandL inorder to handle dialog menu
|
|
388 |
// commands.
|
|
389 |
// -----------------------------------------------------------------------------
|
|
390 |
//
|
|
391 |
void CPslnSlidesetDialog::ProcessCommandL( TInt aCommandId )
|
|
392 |
{
|
|
393 |
CAknDialog::ProcessCommandL( aCommandId );
|
|
394 |
switch ( aCommandId )
|
|
395 |
{
|
|
396 |
case EPslnCmdAppSetWallpaper: // Fallthrough
|
|
397 |
case EPslnCmdAppSetScreenSaver: // Fallthrough
|
|
398 |
case EPslnSlideSetCmdChange:
|
|
399 |
if ( iListBox )
|
|
400 |
{
|
|
401 |
HandleListBoxSelectionL();
|
|
402 |
}
|
|
403 |
break;
|
|
404 |
case EAknCmdHelp:
|
|
405 |
HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
|
|
406 |
iAvkonAppUi->AppHelpContextL() );
|
|
407 |
break;
|
|
408 |
case EAknSoftkeyBack: // -Fallthrough
|
|
409 |
// Remove empty navi pane.
|
|
410 |
ToggleDefaultNaviPaneL( EFalse );
|
|
411 |
case EEikCmdExit: // -Fallthrough
|
|
412 |
case EAknCmdExit:
|
|
413 |
// Close this dialog
|
|
414 |
TryExitL( aCommandId );
|
|
415 |
iAvkonAppUi->ProcessCommandL( aCommandId );
|
|
416 |
break;
|
|
417 |
default:
|
|
418 |
break;
|
|
419 |
}
|
|
420 |
}
|
|
421 |
|
|
422 |
// -----------------------------------------------------------------------------
|
|
423 |
// Reimplements CAknDialog::OkToExitL.
|
|
424 |
// -----------------------------------------------------------------------------
|
|
425 |
//
|
|
426 |
TBool CPslnSlidesetDialog::OkToExitL( TInt aButtonId )
|
|
427 |
{
|
|
428 |
//Check if MGFetch is running.
|
|
429 |
if( iMGFetchRunning )
|
|
430 |
{
|
|
431 |
return EFalse;
|
|
432 |
}
|
|
433 |
|
|
434 |
if ( iPreviousTitleTxt &&
|
|
435 |
iPreviousTitleTxt->Length() > 0 &&
|
|
436 |
aButtonId != EAknSoftkeyOptions )
|
|
437 |
{
|
|
438 |
if ( iAvkonAppUi )
|
|
439 |
{
|
|
440 |
CEikStatusPane* sp = iAvkonAppUi->StatusPane();
|
|
441 |
if ( sp )
|
|
442 |
{
|
|
443 |
CAknTitlePane* title = static_cast<CAknTitlePane*>(
|
|
444 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
445 |
|
|
446 |
if ( title )
|
|
447 |
{
|
|
448 |
title->SetTextL( *iPreviousTitleTxt );
|
|
449 |
}
|
|
450 |
}
|
|
451 |
}
|
|
452 |
}
|
|
453 |
return CAknDialog::OkToExitL( aButtonId );
|
|
454 |
}
|
|
455 |
|
|
456 |
// -----------------------------------------------------------------------------
|
|
457 |
// Reimplements CAknDialog::DynInitMenuPaneL inorder to support dynamic hiding
|
|
458 |
// of menu items based on current state of the viewer.
|
|
459 |
// -----------------------------------------------------------------------------
|
|
460 |
//
|
|
461 |
void CPslnSlidesetDialog::DynInitMenuPaneL(
|
|
462 |
TInt aResourceId, CEikMenuPane* aMenuPane )
|
|
463 |
{
|
|
464 |
if ( aResourceId == R_PSLN_SLIDE_DIALOG_MENU &&
|
|
465 |
!FeatureManager::FeatureSupported( KFeatureIdHelp ) )
|
|
466 |
{
|
|
467 |
// Disable help if not supported
|
|
468 |
aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
|
|
469 |
}
|
|
470 |
}
|
|
471 |
|
|
472 |
// -----------------------------------------------------------------------------
|
|
473 |
// Reimplements CAknDialog::SizeChanged inorder to support the resize of the
|
|
474 |
// dialog when functions such as SetRect, SetExtent are called on the dialog.
|
|
475 |
// -----------------------------------------------------------------------------
|
|
476 |
//
|
|
477 |
void CPslnSlidesetDialog::SizeChanged()
|
|
478 |
{
|
|
479 |
CAknDialog::SizeChanged();
|
|
480 |
if ( iListBox )
|
|
481 |
{
|
|
482 |
// Get size from main pane, place from this rect
|
|
483 |
TRect mainPaneRect;
|
|
484 |
AknLayoutUtils::LayoutMetricsRect(
|
|
485 |
AknLayoutUtils::EMainPane,
|
|
486 |
mainPaneRect );
|
|
487 |
|
|
488 |
iListBox->SetExtent( Rect().iTl, mainPaneRect.Size() );
|
|
489 |
}
|
|
490 |
}
|
|
491 |
|
|
492 |
// -----------------------------------------------------------------------------
|
|
493 |
// Handles Key events by reimplementing CCoeControl::OfferKeyEventL.
|
|
494 |
// -----------------------------------------------------------------------------
|
|
495 |
//
|
|
496 |
TKeyResponse CPslnSlidesetDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
497 |
TEventCode aType )
|
|
498 |
{
|
|
499 |
switch ( aKeyEvent.iCode )
|
|
500 |
{
|
|
501 |
case EKeyLeftArrow: // -Fallthrough
|
|
502 |
case EKeyRightArrow:
|
|
503 |
// Listbox takes all event even if it doesn't use them
|
|
504 |
if ( !iMGFetchRunning )
|
|
505 |
{
|
|
506 |
return EKeyWasConsumed;
|
|
507 |
}
|
|
508 |
break;
|
|
509 |
default:
|
|
510 |
break;
|
|
511 |
}
|
|
512 |
// If MGFetch is running, do not give key events to listbox.
|
|
513 |
if ( iListBox && !iMGFetchRunning )
|
|
514 |
{
|
|
515 |
iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
516 |
}
|
|
517 |
return CAknDialog::OfferKeyEventL( aKeyEvent, aType );
|
|
518 |
}
|
|
519 |
|
|
520 |
// -----------------------------------------------------------------------------
|
|
521 |
// Handles setting page events.
|
|
522 |
// -----------------------------------------------------------------------------
|
|
523 |
//
|
|
524 |
void CPslnSlidesetDialog::HandleSettingPageEventL(
|
|
525 |
CAknSettingPage* aSettingPage,
|
|
526 |
TAknSettingPageEvent aEventType )
|
|
527 |
{
|
|
528 |
TInt settingPageId = aSettingPage->SettingId();
|
|
529 |
TInt current = KErrNotFound;
|
|
530 |
if ( aEventType == EEventSettingOked )
|
|
531 |
{
|
|
532 |
switch( settingPageId )
|
|
533 |
{
|
|
534 |
case EPslnSlideSetImagesId:
|
|
535 |
if ( IsFeatureSupported( EPslnSlideSetFeatureRandom ) )
|
|
536 |
{
|
|
537 |
current = static_cast<CAknRadioButtonSettingPage*>(
|
|
538 |
aSettingPage)->ListBoxControl()->CurrentItemIndex();
|
|
539 |
// If images is selected, start MGFetch.
|
|
540 |
if ( current != KPslnSlideSetRandomIndex )
|
|
541 |
{
|
|
542 |
aSettingPage->MakeVisible( EFalse );
|
|
543 |
HandleLaunchMGFetchL();
|
|
544 |
}
|
|
545 |
else
|
|
546 |
{
|
|
547 |
iModel->SetSlideSetType( iType, current );
|
|
548 |
}
|
|
549 |
}
|
|
550 |
break;
|
|
551 |
|
|
552 |
case EPslnSlideSetDurationId:
|
|
553 |
current = static_cast<CAknSliderSettingPage*>
|
|
554 |
(aSettingPage)->SliderControl()->Value();
|
|
555 |
iModel->SetSlideSetDuration( current );
|
|
556 |
break;
|
|
557 |
case EPslnSlideSetBacklightId:
|
|
558 |
current = static_cast<CAknSliderSettingPage*>
|
|
559 |
(aSettingPage)->SliderControl()->Value();
|
|
560 |
iModel->SetSlideSetBacklight( current );
|
|
561 |
break;
|
|
562 |
case EPslnSlideSetIntervalId:
|
|
563 |
current = static_cast<CAknRadioButtonSettingPage*>(
|
|
564 |
aSettingPage)->ListBoxControl()->CurrentItemIndex();
|
|
565 |
iModel->SetSlideSetInterval( current );
|
|
566 |
// interval is regarded as duration
|
|
567 |
settingPageId = EPslnSlideSetDurationId;
|
|
568 |
break;
|
|
569 |
default:
|
|
570 |
break;
|
|
571 |
}
|
|
572 |
UpdateDialogL( settingPageId );
|
|
573 |
}
|
|
574 |
}
|
|
575 |
|
|
576 |
// -----------------------------------------------------------------------------
|
|
577 |
// Handles change of skin/Layout
|
|
578 |
// -----------------------------------------------------------------------------
|
|
579 |
//
|
|
580 |
void CPslnSlidesetDialog::HandleResourceChange( TInt aType )
|
|
581 |
{
|
|
582 |
CAknDialog::HandleResourceChange( aType );
|
|
583 |
if ( iListBox )
|
|
584 |
{
|
|
585 |
iListBox->HandleResourceChange( aType );
|
|
586 |
}
|
|
587 |
}
|
|
588 |
|
|
589 |
// ---------------------------------------------------------------------------
|
|
590 |
// Handles list animation events.
|
|
591 |
// ---------------------------------------------------------------------------
|
|
592 |
//
|
|
593 |
void CPslnSlidesetDialog::FocusChanged( TDrawNow aDrawNow )
|
|
594 |
{
|
|
595 |
CAknDialog::FocusChanged( aDrawNow );
|
|
596 |
if( iListBox )
|
|
597 |
{
|
|
598 |
iListBox->SetFocus( IsFocused(), aDrawNow );
|
|
599 |
}
|
|
600 |
}
|
|
601 |
|
|
602 |
// ---------------------------------------------------------------------------
|
|
603 |
// Count components.
|
|
604 |
// ---------------------------------------------------------------------------
|
|
605 |
//
|
|
606 |
TInt CPslnSlidesetDialog::CountComponentControls() const
|
|
607 |
{
|
|
608 |
return iListBox ? 1 : 0;
|
|
609 |
}
|
|
610 |
|
|
611 |
// ---------------------------------------------------------------------------
|
|
612 |
// Give pointer to component matching to the index.
|
|
613 |
// ---------------------------------------------------------------------------
|
|
614 |
//
|
|
615 |
CCoeControl* CPslnSlidesetDialog::ComponentControl( TInt aIndex ) const
|
|
616 |
{
|
|
617 |
return ( aIndex == 0 ) ? iListBox : NULL;
|
|
618 |
}
|
|
619 |
|
|
620 |
// ---------------------------------------------------------------------------
|
|
621 |
// Handle listbox event.
|
|
622 |
// ---------------------------------------------------------------------------
|
|
623 |
//
|
|
624 |
void CPslnSlidesetDialog::HandleListBoxEventL(
|
|
625 |
CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
|
|
626 |
{
|
|
627 |
switch ( aEventType )
|
|
628 |
{
|
|
629 |
case EEventEnterKeyPressed: // Fallthrough
|
|
630 |
case EEventItemDoubleClicked:
|
|
631 |
case EEventItemSingleClicked:
|
|
632 |
HandleListBoxSelectionL();
|
|
633 |
break;
|
|
634 |
default:
|
|
635 |
break;
|
|
636 |
}
|
|
637 |
}
|
|
638 |
|
|
639 |
// -----------------------------------------------------------------------------
|
|
640 |
// Create setting items.
|
|
641 |
// -----------------------------------------------------------------------------
|
|
642 |
//
|
|
643 |
void CPslnSlidesetDialog::CreateSettingsListL()
|
|
644 |
{
|
|
645 |
// Create settings listbox.
|
|
646 |
iListBox = new (ELeave) CAknSettingStyleListBox;
|
|
647 |
iListBox->ConstructL( this, EAknListBoxSelectionList );
|
|
648 |
|
|
649 |
// Create listbox items.
|
|
650 |
iItemArray = static_cast<CDesCArray*>
|
|
651 |
( iListBox->Model()->ItemTextArray() );
|
|
652 |
iListBox->SetContainerWindowL( *this );
|
|
653 |
iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
|
|
654 |
|
|
655 |
iListBox->CreateScrollBarFrameL( ETrue );
|
|
656 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
657 |
CEikScrollBarFrame::EOff,
|
|
658 |
CEikScrollBarFrame::EAuto );
|
|
659 |
iListBox->SetListBoxObserver( this );
|
|
660 |
iListBox->SetMopParent( this );
|
|
661 |
iListBox->MakeVisible( ETrue );
|
|
662 |
|
|
663 |
CreateListBoxItemsL();
|
|
664 |
iListBox->HandleItemAdditionL();
|
|
665 |
|
|
666 |
SetRect( iAvkonAppUi->ClientRect() );
|
|
667 |
ActivateL();
|
|
668 |
}
|
|
669 |
|
|
670 |
// ---------------------------------------------------------------------------
|
|
671 |
// CPslnSlidesetDialog::HandleListBoxSelectionL()
|
|
672 |
// ---------------------------------------------------------------------------
|
|
673 |
//
|
|
674 |
void CPslnSlidesetDialog::HandleListBoxSelectionL()
|
|
675 |
{
|
|
676 |
TInt index = iListBox->CurrentItemIndex();
|
|
677 |
|
|
678 |
switch ( index )
|
|
679 |
{
|
|
680 |
case EPslnSlideSetImagesId:
|
|
681 |
if( iMGFetchRunning )
|
|
682 |
{
|
|
683 |
return;
|
|
684 |
}
|
|
685 |
if ( IsFeatureSupported( EPslnSlideSetFeatureRandom )
|
|
686 |
&& ( iType == EPslnScreensaverDialog ) )
|
|
687 |
{
|
|
688 |
ShowSlideSetTypeSelectionL();
|
|
689 |
}
|
|
690 |
else
|
|
691 |
{
|
|
692 |
ShowSlideSetImageListL();
|
|
693 |
}
|
|
694 |
break;
|
|
695 |
case EPslnSlideSetDurationId:
|
|
696 |
if ( iType == EPslnScreensaverDialog )
|
|
697 |
{
|
|
698 |
ShowDurationSliderL();
|
|
699 |
}
|
|
700 |
else
|
|
701 |
{
|
|
702 |
ShowIntervalListL();
|
|
703 |
}
|
|
704 |
break;
|
|
705 |
case EPslnSlideSetBacklightId:
|
|
706 |
ShowBacklightSliderL();
|
|
707 |
break;
|
|
708 |
default:
|
|
709 |
break;
|
|
710 |
}
|
|
711 |
}
|
|
712 |
|
|
713 |
// ---------------------------------------------------------------------------
|
|
714 |
// Show slide set type setting page. Since it is used by both slide sets
|
|
715 |
// (wallpaper and screen saver), the default implementation is in the base
|
|
716 |
// class.
|
|
717 |
// ---------------------------------------------------------------------------
|
|
718 |
//
|
|
719 |
void CPslnSlidesetDialog::ShowSlideSetTypeSelectionL()
|
|
720 |
{
|
|
721 |
// Retrieve title txt.
|
|
722 |
TInt titleResourceID = R_PSLN_IMAGES_SLIDE_SS_PAGE_TITLE;
|
|
723 |
if ( iType != EPslnScreensaverDialog )
|
|
724 |
{
|
|
725 |
titleResourceID = R_PSLN_IMAGES_SLIDE_WP_PAGE_TITLE;
|
|
726 |
}
|
|
727 |
HBufC* titleText = StringLoader::LoadLC( titleResourceID );
|
|
728 |
|
|
729 |
// Retrieve current setting page value.
|
|
730 |
TInt currentValue = iModel->GetSlideSetType( iType );
|
|
731 |
|
|
732 |
// Create & show the setting page.
|
|
733 |
CAknRadioButtonSettingPage* dlg =
|
|
734 |
new( ELeave ) CAknRadioButtonSettingPage(
|
|
735 |
titleText,
|
|
736 |
EAknSettingPageNoOrdinalDisplayed,
|
|
737 |
EAknCtSettingPage,
|
|
738 |
0,
|
|
739 |
R_PSLN_IMAGE_SELECTION_SETTING_PAGE,
|
|
740 |
currentValue,
|
|
741 |
iSlideSetTypeItems );
|
|
742 |
dlg->SetSettingId( EPslnSlideSetImagesId );
|
|
743 |
dlg->SetSettingPageObserver( this );
|
|
744 |
dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted );
|
|
745 |
|
|
746 |
CleanupStack::PopAndDestroy( titleText );
|
|
747 |
}
|
|
748 |
|
|
749 |
// ---------------------------------------------------------------------------
|
|
750 |
// Shows backlight slider setting page.
|
|
751 |
// ---------------------------------------------------------------------------
|
|
752 |
//
|
|
753 |
void CPslnSlidesetDialog::ShowBacklightSliderL()
|
|
754 |
{
|
|
755 |
// Empty implementation to be overloaded.
|
|
756 |
}
|
|
757 |
|
|
758 |
// ---------------------------------------------------------------------------
|
|
759 |
// Shows duration slider setting page.
|
|
760 |
// ---------------------------------------------------------------------------
|
|
761 |
//
|
|
762 |
void CPslnSlidesetDialog::ShowDurationSliderL()
|
|
763 |
{
|
|
764 |
// Empty implementation to be overloaded.
|
|
765 |
}
|
|
766 |
|
|
767 |
// ---------------------------------------------------------------------------
|
|
768 |
// Show wallpaper slide set's interval selection.
|
|
769 |
// ---------------------------------------------------------------------------
|
|
770 |
//
|
|
771 |
void CPslnSlidesetDialog::ShowIntervalListL()
|
|
772 |
{
|
|
773 |
// Empty implementation to be overloaded.
|
|
774 |
}
|
|
775 |
|
|
776 |
// ---------------------------------------------------------------------------
|
|
777 |
// Starts image fetch.
|
|
778 |
// ---------------------------------------------------------------------------
|
|
779 |
//
|
|
780 |
TBool CPslnSlidesetDialog::ShowSlideSetImageListL()
|
|
781 |
{
|
|
782 |
CDesCArrayFlat* files =
|
|
783 |
new (ELeave) CDesCArrayFlat( KPslnSlideSetImagesGranualarity );
|
|
784 |
CleanupStack::PushL( files );
|
|
785 |
|
|
786 |
CPslnSlideSetDRMVerifier* verifier = CPslnSlideSetDRMVerifier::NewL( iType );
|
|
787 |
CleanupStack::PushL( verifier );
|
|
788 |
|
|
789 |
iMGFetchRunning = ETrue;
|
|
790 |
TBool selected = EFalse;
|
|
791 |
TRAPD( err,selected = MGFetch::RunL( *files, EImageFile, ETrue, verifier ) );
|
|
792 |
iMGFetchRunning = EFalse;
|
|
793 |
User::LeaveIfError( err );
|
|
794 |
CleanupStack::PopAndDestroy( verifier );
|
|
795 |
|
|
796 |
// Handle selection
|
|
797 |
if ( selected && ( files->MdcaCount() > 0 ) )
|
|
798 |
{
|
|
799 |
iModel->SetImageListL( iType, *files, iLaunchMode );
|
|
800 |
iModel->SetSlideSetType( iType, 0 );
|
|
801 |
UpdateDialogL( EPslnSlideSetImagesId );
|
|
802 |
}
|
|
803 |
// else - either: User made a selection, but all the images had issues with DRM.
|
|
804 |
// or: MGFetch was cancelled
|
|
805 |
else
|
|
806 |
{
|
|
807 |
selected = EFalse;
|
|
808 |
}
|
|
809 |
|
|
810 |
CleanupStack::PopAndDestroy( files );
|
|
811 |
return selected;
|
|
812 |
}
|
|
813 |
|
|
814 |
// ---------------------------------------------------------------------------
|
|
815 |
// Toggles navi pane to default and back.
|
|
816 |
// ---------------------------------------------------------------------------
|
|
817 |
//
|
|
818 |
#ifdef RD_CONTROL_PANEL
|
|
819 |
void CPslnSlidesetDialog::ToggleDefaultNaviPaneL( const TBool /*aNaviPaneToggle*/ )
|
|
820 |
#else
|
|
821 |
void CPslnSlidesetDialog::ToggleDefaultNaviPaneL( const TBool aNaviPaneToggle )
|
|
822 |
#endif // RD_CONTROL_PANEL
|
|
823 |
{
|
|
824 |
// Remove tab group (if applicable).
|
|
825 |
CEikStatusPane* sp = iAvkonAppUi->StatusPane();
|
|
826 |
// Fetch pointer to the default navi pane control
|
|
827 |
CAknNavigationControlContainer* naviPane =
|
|
828 |
(CAknNavigationControlContainer*)sp->ControlL(
|
|
829 |
TUid::Uid(EEikStatusPaneUidNavi));
|
|
830 |
// Show again previous navipane
|
|
831 |
if ( naviPane )
|
|
832 |
{
|
|
833 |
#ifndef RD_CONTROL_PANEL
|
|
834 |
if ( !aNaviPaneToggle )
|
|
835 |
{
|
|
836 |
naviPane->Pop();
|
|
837 |
}
|
|
838 |
// Show default navi pane.
|
|
839 |
else
|
|
840 |
#endif // !RD_CONTROL_PANEL
|
|
841 |
{
|
|
842 |
naviPane->PushDefaultL();
|
|
843 |
}
|
|
844 |
}
|
|
845 |
}
|
|
846 |
|
|
847 |
// -----------------------------------------------------------------------------
|
|
848 |
// Updates dialog based on new value of setting item.
|
|
849 |
// -----------------------------------------------------------------------------
|
|
850 |
//
|
|
851 |
void CPslnSlidesetDialog::UpdateDialogL( const TInt aSettingId )
|
|
852 |
{
|
|
853 |
if ( aSettingId >= 0 &&
|
|
854 |
aSettingId < iItemArray->Count() )
|
|
855 |
{
|
|
856 |
iItemArray->Delete( aSettingId );
|
|
857 |
MakeItemL( aSettingId );
|
|
858 |
iListBox->HandleItemAdditionL();
|
|
859 |
}
|
|
860 |
}
|
|
861 |
|
|
862 |
// -----------------------------------------------------------------------------
|
|
863 |
// Updates dialog based on new value of setting item.
|
|
864 |
// -----------------------------------------------------------------------------
|
|
865 |
//
|
|
866 |
void CPslnSlidesetDialog::SetSettingPageValueToListL(
|
|
867 |
const CDesCArrayFlat& aArray,
|
|
868 |
const TInt aCurrentIndex,
|
|
869 |
const TInt aCurrentValue,
|
|
870 |
const TBool aNumericConversionNeeded )
|
|
871 |
{
|
|
872 |
if ( aCurrentIndex >= iItems->Count() )
|
|
873 |
{
|
|
874 |
User::Leave( KErrArgument );
|
|
875 |
}
|
|
876 |
HBufC* item = (*iItems)[aCurrentIndex].AllocL();
|
|
877 |
HBufC* settingItemValue = HBufC::NewLC( KPslnSettingItemLength );
|
|
878 |
TPtr valuePtr ( settingItemValue->Des() );
|
|
879 |
valuePtr = aArray[ aCurrentValue ];
|
|
880 |
|
|
881 |
// A&H conversion.
|
|
882 |
if( aNumericConversionNeeded &&
|
|
883 |
AknTextUtils::DigitModeQuery( AknTextUtils::EDigitModeShownToUser ) )
|
|
884 |
{
|
|
885 |
AknTextUtils::LanguageSpecificNumberConversion( valuePtr );
|
|
886 |
}
|
|
887 |
|
|
888 |
// Re-allocate string, so that setting item name and current value fit.
|
|
889 |
item = item->ReAllocL(
|
|
890 |
item->Length() + valuePtr.Length() + KPslnStringEndMarkSize );
|
|
891 |
TPtr expandedPtr = item->Des();
|
|
892 |
|
|
893 |
expandedPtr.Insert( item->Length(), valuePtr );
|
|
894 |
CleanupStack::PopAndDestroy( settingItemValue );
|
|
895 |
CleanupStack::PushL( item );
|
|
896 |
|
|
897 |
TPtr ptr = item->Des();
|
|
898 |
iItemArray->InsertL( aCurrentIndex, ptr );
|
|
899 |
CleanupStack::PopAndDestroy( item );
|
|
900 |
}
|
|
901 |
|
|
902 |
// -----------------------------------------------------------------------------
|
|
903 |
// Updates dialog based on new value of setting item.
|
|
904 |
// -----------------------------------------------------------------------------
|
|
905 |
//
|
|
906 |
void CPslnSlidesetDialog::SetSliderValueToListL(
|
|
907 |
const TInt aCurrentIndex,
|
|
908 |
const TInt aCurrentValue,
|
|
909 |
const TInt aResourceID )
|
|
910 |
{
|
|
911 |
if ( aCurrentIndex >= iItems->Count() )
|
|
912 |
{
|
|
913 |
User::Leave( KErrArgument );
|
|
914 |
}
|
|
915 |
|
|
916 |
HBufC* item = (*iItems)[aCurrentIndex].AllocL();
|
|
917 |
// If minimum value for backlight, use "Off".
|
|
918 |
if ( aResourceID == R_PSLN_BACKLIGHT_SLIDER && aCurrentValue == 0 )
|
|
919 |
{
|
|
920 |
HBufC* settingItem = StringLoader::LoadLC( R_PSLN_SANIM_SLIDER_OFF );
|
|
921 |
TPtr bufPtr = settingItem->Des();
|
|
922 |
item = item->ReAllocL(
|
|
923 |
item->Length() + bufPtr.Length() + KPslnStringEndMarkSize );
|
|
924 |
TPtr expandedPtr = item->Des();
|
|
925 |
|
|
926 |
expandedPtr.Insert( item->Length(), bufPtr );
|
|
927 |
CleanupStack::PopAndDestroy( settingItem );
|
|
928 |
|
|
929 |
}
|
|
930 |
else
|
|
931 |
{
|
|
932 |
HBufC* settingItem = CAknSlider::CreateValueTextInHBufCL(
|
|
933 |
aCurrentValue,
|
|
934 |
aResourceID );
|
|
935 |
CleanupStack::PushL( settingItem );
|
|
936 |
|
|
937 |
// for A&H number conversion
|
|
938 |
TPtr bufPtr = settingItem->Des();
|
|
939 |
if( AknTextUtils::DigitModeQuery( AknTextUtils::EDigitModeShownToUser ) )
|
|
940 |
{
|
|
941 |
AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
|
|
942 |
}
|
|
943 |
item = item->ReAllocL(
|
|
944 |
item->Length() + bufPtr.Length() + KPslnStringEndMarkSize );
|
|
945 |
TPtr expandedPtr = item->Des();
|
|
946 |
|
|
947 |
expandedPtr.Insert( item->Length(), bufPtr );
|
|
948 |
CleanupStack::PopAndDestroy( settingItem );
|
|
949 |
}
|
|
950 |
CleanupStack::PushL( item );
|
|
951 |
TPtr ptr = item->Des();
|
|
952 |
iItemArray->InsertL( aCurrentIndex, ptr );
|
|
953 |
CleanupStack::PopAndDestroy( item );
|
|
954 |
}
|
|
955 |
|
|
956 |
// -----------------------------------------------------------------------------
|
|
957 |
// Select appropriate resource text for setting item value.
|
|
958 |
// -----------------------------------------------------------------------------
|
|
959 |
//
|
|
960 |
TInt CPslnSlidesetDialog::SelectResourceStringForImages( TInt aCurrentValue )
|
|
961 |
{
|
|
962 |
TInt resourceId = R_PSLN_SLIDE_SET_WP_IMAGES;
|
|
963 |
if ( aCurrentValue == 1 )
|
|
964 |
{
|
|
965 |
if ( iType == EPslnScreensaverDialog )
|
|
966 |
{
|
|
967 |
resourceId = R_PSLN_SLIDE_SET_SS_IMAGE;
|
|
968 |
}
|
|
969 |
else
|
|
970 |
{
|
|
971 |
resourceId = R_PSLN_SLIDE_SET_WP_IMAGE;
|
|
972 |
}
|
|
973 |
}
|
|
974 |
else
|
|
975 |
{
|
|
976 |
if ( iType == EPslnScreensaverDialog )
|
|
977 |
{
|
|
978 |
resourceId = R_PSLN_SLIDE_SET_SS_IMAGES;
|
|
979 |
}
|
|
980 |
}
|
|
981 |
return resourceId;
|
|
982 |
}
|
|
983 |
|
|
984 |
// -----------------------------------------------------------------------------
|
|
985 |
// Handles idle time. Starts MGFetch.
|
|
986 |
// -----------------------------------------------------------------------------
|
|
987 |
//
|
|
988 |
void CPslnSlidesetDialog::HandleLaunchMGFetchL()
|
|
989 |
{
|
|
990 |
TBool selected = ShowSlideSetImageListL();
|
|
991 |
if ( !selected )
|
|
992 |
{
|
|
993 |
ShowSlideSetTypeSelectionL();
|
|
994 |
}
|
|
995 |
}
|
|
996 |
|
|
997 |
// End of File
|