psln/pslnslidesetdialog/src/pslnslidesetscreensaverdialog.cpp
changeset 37 89c890c70182
parent 34 6b5204869ed5
child 45 667edd0b8678
equal deleted inserted replaced
34:6b5204869ed5 37:89c890c70182
     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:  Screensaver slide set settings dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // General
       
    20 #include <e32std.h>
       
    21 #include <StringLoader.h>
       
    22 #include <e32property.h>
       
    23 #include <csxhelp/skins.hlp.hrh>
       
    24 
       
    25 // From AVKON
       
    26 #include <avkon.hrh>
       
    27 #include <aknappui.h>
       
    28 #include <aknslidersettingpage.h>
       
    29 #include <AknsSrvClient.h>
       
    30 
       
    31 // Psln Slide set specific.
       
    32 #include "pslnslidesetscreensaverdialog.h"
       
    33 #include "pslnslidesetdialog.hrh"
       
    34 #include "pslnslidesetmodel.h"
       
    35 #include "pslnslidesetconst.h"
       
    36 
       
    37 // Resources
       
    38 #include <pslnslidesetdialogrsc.rsg>
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // C++ default constructor can NOT contain any code, that might leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CPslnSlidesetScreensaverDialog::CPslnSlidesetScreensaverDialog()
       
    47     {
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // Symbian 2nd phase constructor can leave.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CPslnSlidesetScreensaverDialog::ConstructL()
       
    55     {
       
    56 #ifndef RD_SLIDESHOW_SCREENSAVER
       
    57     User::Leave( KErrNotSupported );
       
    58 #endif // RD_SLIDESHOW_SCREENSAVER
       
    59     BaseConstructL(
       
    60         GetDialogFlag( CPslnSlidesetDialogInterface::EPslnDialogType ) );
       
    61 
       
    62     iSlideSetTypeItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
    63         R_PSLN_SLIDESET_TYPE_SS_SETTING_PAGE_LBX );
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // Two-phased constructor.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CPslnSlidesetScreensaverDialog* CPslnSlidesetScreensaverDialog::NewL()
       
    71     {
       
    72     CPslnSlidesetScreensaverDialog* self = NewLC();
       
    73     CleanupStack::Pop(); // Self
       
    74     return self;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // Two-phased constructor.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CPslnSlidesetScreensaverDialog* CPslnSlidesetScreensaverDialog::NewLC()
       
    82     {
       
    83     CPslnSlidesetScreensaverDialog* self =
       
    84         new ( ELeave ) CPslnSlidesetScreensaverDialog();
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL();
       
    87     return self;
       
    88     }
       
    89 
       
    90 // Destructor
       
    91 CPslnSlidesetScreensaverDialog::~CPslnSlidesetScreensaverDialog()
       
    92     {
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // Executes dialog.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 TInt CPslnSlidesetScreensaverDialog::ExecuteDialogLD()
       
   100     {
       
   101     return CAknDialog::ExecuteLD( R_PSLN_SETTINGS_DIALOG );
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // Configures dialog.
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CPslnSlidesetScreensaverDialog::SetDialogFlag(
       
   109     const TInt aFlag, const TInt aValue )
       
   110     {
       
   111     switch( aFlag )
       
   112         {
       
   113         case CPslnSlidesetDialogInterface::EPslnConfigurability:
       
   114         case CPslnSlidesetDialogInterface::EPslnDialogType:
       
   115             // Cannot be changed dynamically.
       
   116             break;
       
   117         case CPslnSlidesetDialogInterface::EPslnLaunchMode:
       
   118             if ( aValue == CPslnSlidesetDialogInterface::EPslnNormal ||
       
   119                  aValue == CPslnSlidesetDialogInterface::EPslnConfigureOnly )
       
   120                 {
       
   121                 iLaunchMode = aValue;
       
   122                 }
       
   123             break;
       
   124         default:
       
   125             break;
       
   126         }
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // Queries for dialog parameter.
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 TInt CPslnSlidesetScreensaverDialog::GetDialogFlag( const TInt aFlag )
       
   134     {
       
   135     TInt flagValue = KErrNotFound;
       
   136     switch( aFlag )
       
   137         {
       
   138         case CPslnSlidesetDialogInterface::EPslnDialogType:
       
   139             flagValue = EPslnScreensaverDialog;
       
   140             break;
       
   141         case CPslnSlidesetDialogInterface::EPslnLaunchMode:
       
   142             // Configuring Screensaver is handled using screensaver framework.
       
   143             flagValue = iLaunchMode;
       
   144             break;
       
   145         case CPslnSlidesetDialogInterface::EPslnConfigurability:
       
   146             // Activation is handled by screensaver framework and Psln application.
       
   147             flagValue = CPslnSlidesetDialogInterface::EPslnUnknown;
       
   148             break;
       
   149         default:
       
   150             break;
       
   151         }
       
   152     return flagValue;
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // Layouts dialog before showing it.
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CPslnSlidesetScreensaverDialog::PreLayoutDynInitL()
       
   160     {
       
   161     // Set title pane text.
       
   162     SetTitlePaneL( R_PSLN_SLIDESET_SCREENSAVER_DIALOG_TITLE );
       
   163     // Set middle softkey as Change.
       
   164     CPslnSlidesetDialog::SetMiddleSoftKeyLabelL(
       
   165         R_PSLN_MSK_CHANGE,
       
   166         EPslnCmdAppSetScreenSaver );
       
   167     CPslnSlidesetDialog::PreLayoutDynInitL();
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // Reimplements CAknDialog::OkToExitL inorder to indicate to the
       
   172 // screensaver that new settings have been defined.
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 TBool CPslnSlidesetScreensaverDialog::OkToExitL( TInt aButtonId )
       
   176     {
       
   177     return CPslnSlidesetDialog::OkToExitL( aButtonId );
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // Adds setting list items to listbox.
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 void CPslnSlidesetScreensaverDialog::CreateListBoxItemsL()
       
   185     {
       
   186     iItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   187         R_PSLN_SCREENSAVER_SLIDE_SETTING_LBX_ITEMS );
       
   188     CPslnSlidesetDialog::MakeItemL( EPslnSlideSetImagesId );
       
   189     CPslnSlidesetDialog::MakeItemL( EPslnSlideSetDurationId );
       
   190     
       
   191     if ( !IsFeatureSupported( EPslnSlideSetBacklightRemoved ) )
       
   192         {        
       
   193         CPslnSlidesetDialog::MakeItemL( EPslnSlideSetBacklightId );
       
   194         }
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // Gets help context for Help application.
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 void CPslnSlidesetScreensaverDialog::GetHelpContext(
       
   202     TCoeHelpContext& aContext ) const
       
   203     {
       
   204     aContext.iMajor = KUidPsln;
       
   205     aContext.iContext = KSKINS_HLP_SCREENS_SETTINGS;
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // Shows duration slider setting page.
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 void CPslnSlidesetScreensaverDialog::ShowDurationSliderL()
       
   213     {
       
   214     TInt currentValue = iModel->GetSlideSetDuration();
       
   215 
       
   216     // Retrieve title txt.
       
   217     HBufC* sliderTitle = StringLoader::LoadLC( R_PSLN_DURATION_SLIDE_PAGE_TITLE );
       
   218 
       
   219     // Instantiate setting page.
       
   220     CAknSliderSettingPage* dlg = new( ELeave ) CAknSliderSettingPage(
       
   221         sliderTitle,
       
   222         EAknSettingPageNoOrdinalDisplayed,
       
   223         EAknCtSlider,
       
   224         R_PSLN_DURATION_SLIDER,
       
   225         R_PSLN_IMAGE_SELECTION_SETTING_PAGE,
       
   226         currentValue );
       
   227 
       
   228     dlg->SetSettingId( EPslnSlideSetDurationId );
       
   229     dlg->SetSettingPageObserver( this );
       
   230     dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
   231     // New value is stored in base class to CenRep.
       
   232 
       
   233     CleanupStack::PopAndDestroy( sliderTitle );
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // Shows backlight slider setting page.
       
   238 // ---------------------------------------------------------------------------
       
   239 //
       
   240 void CPslnSlidesetScreensaverDialog::ShowBacklightSliderL()
       
   241     {
       
   242     // Empty implementation to be overloaded.
       
   243     TInt currentValue = iModel->GetSlideSetBacklight();
       
   244 
       
   245     // Retrieve title txt.
       
   246     HBufC* sliderTitle = StringLoader::LoadLC( R_PSLN_BACKLIGHT_SLIDE_PAGE_TITLE );
       
   247 
       
   248     CAknSliderSettingPage* dlg = new( ELeave ) CAknSliderSettingPage(
       
   249         sliderTitle,
       
   250         EAknSettingPageNoOrdinalDisplayed,
       
   251         EAknCtSlider,
       
   252         R_PSLN_BACKLIGHT_SLIDER,
       
   253         R_PSLN_IMAGE_SELECTION_SETTING_PAGE,
       
   254         currentValue );
       
   255 
       
   256     dlg->SetSettingId( EPslnSlideSetBacklightId );
       
   257     dlg->SetSettingPageObserver( this );
       
   258     dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
   259     // New value is stored in base class to CenRep.
       
   260 
       
   261     CleanupStack::PopAndDestroy( sliderTitle );
       
   262     }
       
   263 
       
   264 // End of File