ui/viewutilities/settingutility/src/glxsetting.cpp
changeset 36 6481344a6d67
child 45 863223ea6961
equal deleted inserted replaced
33:1ee2af37811f 36:6481344a6d67
       
     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:
       
    13 *
       
    14 * Description:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 #include <xqsettingsmanager.h>
       
    19 #include <xqsettingskey.h>
       
    20 #include <QStringList>
       
    21 
       
    22 #include "glxsetting.h"
       
    23 #include "glxeffectpluginresolver.h"
       
    24 #include "glxuistd.h"
       
    25 
       
    26 
       
    27 const TUint32 KGlxTransitionEffect     = 0x1;
       
    28 const TUint32 KGlxTransitionDelay  = 0x2;
       
    29 const TUint32 KGlxSlow  = 0x3;
       
    30 const TUint32 KGlxMeduim  = 0x4;
       
    31 const TUint32 KGlxFast  = 0x5;
       
    32 const TUint32 KGlxSlideShowEffect[ ]  = { 0x6, 0x7, 0x8 };
       
    33 const TUint32 KCRUidGallery = 0x20007194;
       
    34 
       
    35 GlxSetting GlxSetting::mObj ;
       
    36 
       
    37 
       
    38 GlxSetting::GlxSetting(  ) 
       
    39 {
       
    40     mSettingsManager = new XQSettingsManager();
       
    41     mTransitionEffectCenrepKey = new XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidGallery , KGlxTransitionEffect );
       
    42     mTransitionDelayCenrepKey = new XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidGallery , KGlxTransitionDelay );
       
    43     mSlowCenRepKey = new XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidGallery ,KGlxSlow );
       
    44     mMediumCenRepKey = new XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidGallery ,KGlxMeduim );
       
    45     mFastCenRepKey = new XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidGallery ,KGlxFast );
       
    46 
       
    47     for ( int i = 0; i < NBR_SLIDESHOW_EFFECT; i++ ) {
       
    48         mSlideShowEffectCenRepKey[ i ] = new XQSettingsKey( XQSettingsKey::TargetCentralRepository, KCRUidGallery , KGlxSlideShowEffect[ i ] );
       
    49     }
       
    50 }
       
    51 
       
    52 GlxSetting::GlxSetting( GlxSetting & )
       
    53 {
       
    54 
       
    55 }
       
    56 
       
    57 GlxSetting::~GlxSetting( )
       
    58 {            
       
    59     delete mFastCenRepKey;
       
    60     delete mMediumCenRepKey;
       
    61     delete mSlowCenRepKey;
       
    62     delete mTransitionDelayCenrepKey;
       
    63     delete mTransitionEffectCenrepKey;
       
    64     delete mSettingsManager;
       
    65     
       
    66     for ( int i = 0 ; i < NBR_SLIDESHOW_EFFECT ; i++ ) {
       
    67         delete mSlideShowEffectCenRepKey[ i ];
       
    68     }
       
    69 }
       
    70 
       
    71 GlxSettingInterface * GlxSetting::instance()
       
    72 {
       
    73     return &mObj ;
       
    74 }
       
    75 
       
    76 int GlxSetting::slideShowEffectIndex()
       
    77 {
       
    78     QVariant effectvalue = mSettingsManager->readItemValue(*mTransitionEffectCenrepKey);
       
    79     return effectvalue.toInt();
       
    80 }
       
    81 
       
    82 void GlxSetting::setslideShowEffectIndex( int index )
       
    83 {
       
    84     mSettingsManager->writeItemValue( *mTransitionEffectCenrepKey, index ) ;
       
    85 }
       
    86 
       
    87 int GlxSetting::slideShowDelayIndex()
       
    88 {
       
    89     QVariant effectvalue = mSettingsManager->readItemValue(*mTransitionDelayCenrepKey);
       
    90     return effectvalue.toInt();
       
    91 }
       
    92 
       
    93 void GlxSetting::setSlideShowDelayIndex( int index )
       
    94 {
       
    95     mSettingsManager->writeItemValue(*mTransitionDelayCenrepKey, index);
       
    96 }
       
    97 
       
    98 int GlxSetting::slideShowDelayTime()
       
    99 {
       
   100     QVariant effectvalue = mSettingsManager->readItemValue(*mTransitionDelayCenrepKey);
       
   101     switch ( effectvalue.toInt() ) {
       
   102     case SLOW:
       
   103         return mSettingsManager->readItemValue(*mSlowCenRepKey).toInt();
       
   104         
       
   105     case MEDIUM:
       
   106         return mSettingsManager->readItemValue(*mMediumCenRepKey).toInt();
       
   107 
       
   108     case FAST:
       
   109         return mSettingsManager->readItemValue(*mFastCenRepKey).toInt();
       
   110 
       
   111      default:
       
   112         return 3000;
       
   113      }
       
   114 }
       
   115 
       
   116 QStringList GlxSetting::slideShowEffectList()
       
   117 {
       
   118     QStringList effectList;
       
   119     effectList.clear();
       
   120     int effectId = 0;
       
   121     
       
   122     for ( int i = 0 ; i < NBR_SLIDESHOW_EFFECT ; i++ ) {
       
   123         effectId = mSettingsManager->readItemValue( * mSlideShowEffectCenRepKey[ i ] ).toInt() ;
       
   124         effectList << GlxEffectPluginResolver::effectName ( effectId );
       
   125     }
       
   126     
       
   127     return effectList;
       
   128 }
       
   129 
       
   130 int GlxSetting::slideShowEffectId( int index )
       
   131 {
       
   132     if ( index >= NBR_SLIDESHOW_EFFECT || index < 0 ) {
       
   133        return NO_EFFECT ;
       
   134     }
       
   135     
       
   136     return mSettingsManager->readItemValue( * mSlideShowEffectCenRepKey[ index ] ).toInt() ;
       
   137 }
       
   138