psln/Src/PslnGeneralThemeView.cpp
branchRCL_3
changeset 18 0aa5fbdfbc30
parent 0 2f259fa3e83a
child 38 c52421ed5f07
equal deleted inserted replaced
16:71dd06cfe933 18:0aa5fbdfbc30
   158                 return;
   158                 return;
   159                 }
   159                 }
   160 
   160 
   161             TInt error = iModel->SetTransitionEffectsL( EPslnEnableAllEffects );
   161             TInt error = iModel->SetTransitionEffectsL( EPslnEnableAllEffects );
   162             
   162             
   163             if ( error == KErrNone )
       
   164                 {            
       
   165                 if ( PslnFeatures::IsSupported( KPslnSupportAnimBackground ) &&
       
   166                      iModel->IsSupportAnimBg(  iModel->ActiveSkinIndex() ) )
       
   167                     {
       
   168                     error = iModel->SetAnimBackground( EPslnEnableAllEffects );
       
   169                     }            
       
   170                 }
       
   171             
       
   172             if ( error == KErrNoMemory )
   163             if ( error == KErrNoMemory )
   173                 {
   164                 {
   174                 HBufC* errorBuf = StringLoader::LoadLC(
   165                 HBufC* errorBuf = StringLoader::LoadLC(
   175                     R_PSLN_NOT_ENOUGH_MEMORY );
   166                     R_PSLN_NOT_ENOUGH_MEMORY );
   176                 // Display global note.
   167                 // Display global note.
   184                 }
   175                 }
   185             }
   176             }
   186             break;
   177             break;
   187         case EPslnCmdTransitionEffectsDeactivate:
   178         case EPslnCmdTransitionEffectsDeactivate:
   188             iModel->SetTransitionEffectsL( EPslnDisableAllEffects );
   179             iModel->SetTransitionEffectsL( EPslnDisableAllEffects );
   189             //Deactive AnimBackground
       
   190             iModel->SetAnimBackground( EPslnDisableAllEffects );
       
   191             break;
   180             break;
   192         
   181         
   193         case EPslnCmdAnimBackgroundActivate:
   182         case EPslnCmdAnimBackgroundActivate:
   194             {
   183             {
       
   184             TInt PsmMode = 0;
       
   185             CPsmSettings *PsmSettings = CPsmSettings::NewL();
       
   186             PsmSettings->GetCurrentMode( PsmMode );
       
   187             delete PsmSettings;
       
   188 
       
   189             if ( PsmMode == EPsmsrvModePowerSave ) // PSM on, setting is protected
       
   190                 {
       
   191                 HBufC* buf = StringLoader::LoadLC( R_PSLN_QTN_PSM_INFONOTE );
       
   192                 CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
       
   193                 note->ExecuteLD( *buf );
       
   194                 CleanupStack::PopAndDestroy( buf );
       
   195                 return;
       
   196                 }
       
   197 
   195             TInt error = iModel->SetAnimBackground( EPslnEnableAllEffects );
   198             TInt error = iModel->SetAnimBackground( EPslnEnableAllEffects );
   196             if ( error == KErrNoMemory )
   199             if ( error == KErrNoMemory )
   197                 {
   200                 {
   198                 HBufC* errorBuf = StringLoader::LoadLC(
   201                 HBufC* errorBuf = StringLoader::LoadLC(
   199                         R_PSLN_NOT_ENOUGH_MEMORY );
   202                         R_PSLN_NOT_ENOUGH_MEMORY );
   210         case EPslnCmdEmptyCommand: // Fallthrough
   213         case EPslnCmdEmptyCommand: // Fallthrough
   211         case EPslnCmdAppActivate: // Fallthrough
   214         case EPslnCmdAppActivate: // Fallthrough
   212             {
   215             {
   213             if ( iContainer )
   216             if ( iContainer )
   214                 {
   217                 {
   215                 if ( iPreviewMode )
       
   216                     {
       
   217                     //stop preview
       
   218                     iToBeActivatedSkinIndex = activeSkinIndex; 
       
   219                     static_cast<CPslnGeneralThemeContainer*>(iContainer)->
       
   220                         LockUpAndDownKeys( ETrue );
       
   221                     static_cast<CPslnGeneralThemeContainer*>(iContainer)->
       
   222                         CancelThemePreviewL();
       
   223                         
       
   224                     HandlePreviewStateChange( EFalse );
       
   225                     }
       
   226                     
       
   227                 if ( iToBeActivatedSkinIndex != KErrNotFound )
   218                 if ( iToBeActivatedSkinIndex != KErrNotFound )
   228                     {
   219                     {
   229                     activeSkinIndex = iToBeActivatedSkinIndex;
   220                     activeSkinIndex = iToBeActivatedSkinIndex;
   230                     iToBeActivatedSkinIndex = -1;
   221                     iToBeActivatedSkinIndex = -1;
   231                     }
   222                     }
   232                 // Do nothing if active theme is selected.
   223                 // Do nothing if active theme is selected.
   233                 if ( iModel->IsActiveSkinSelected( activeSkinIndex  ) )
   224                 if ( iModel->IsActiveSkinSelected( activeSkinIndex  ) )
   234                     {
   225                     {
   235                     HandlePreviewStateChange( ETrue );
       
   236                     static_cast<CPslnGeneralThemeContainer*>(iContainer)->
       
   237                         StartThemePreviewL();
       
   238                     break;
   226                     break;
   239                     }
   227                     }
   240                 // Check is the theme corrupted.
   228                 // Check is the theme corrupted.
   241                 if ( !iModel->IsValidForActivation( activeSkinIndex ) )
   229                 if ( !iModel->IsValidForActivation( activeSkinIndex ) )
   242                     {
   230                     {
   250                     }
   238                     }
   251                 else
   239                 else
   252                     {
   240                     {
   253                     iModel->SetCurrentSelectedSkinIndex( activeSkinIndex );
   241                     iModel->SetCurrentSelectedSkinIndex( activeSkinIndex );
   254                     }
   242                     }
   255                 static_cast<CPslnGeneralThemeContainer*>(iContainer)->
       
   256                     LockUpAndDownKeys( EFalse );
       
   257                 }
   243                 }
   258             }
   244             }
   259         case EPslnCmdAppDownload: // Fallthrough
   245         case EPslnCmdAppDownload: // Fallthrough
   260         default:
   246         default:
   261             iPslnUi->HandleCommandL( aCommand );
   247             iPslnUi->HandleCommandL( aCommand );
   313     TInt currentlySelected  = iModel->ActiveSkinIndex();
   299     TInt currentlySelected  = iModel->ActiveSkinIndex();
   314     iModel->SetCurrentSelectedSkinIndex( currentlySelected );
   300     iModel->SetCurrentSelectedSkinIndex( currentlySelected );
   315 
   301 
   316     CheckMiddleSoftkeyLabelL();
   302     CheckMiddleSoftkeyLabelL();
   317 
   303 
   318     iPslnUi->ToggleScreenBlankerL( EFalse, EFalse );
       
   319     iToBeActivatedSkinIndex = -1;
   304     iToBeActivatedSkinIndex = -1;
   320     }
   305     }
   321 
   306 
   322 // -----------------------------------------------------------------------------
   307 // -----------------------------------------------------------------------------
   323 // CPslnGeneralThemeView::DoDeactivate
   308 // CPslnGeneralThemeView::DoDeactivate
   341     PSLN_TRACE_DEBUG("CPslnGeneralThemeView::DynInitMenuPaneL");
   326     PSLN_TRACE_DEBUG("CPslnGeneralThemeView::DynInitMenuPaneL");
   342     if( aResourceId == R_PSLN_GEN_VIEW_MENUPANE )
   327     if( aResourceId == R_PSLN_GEN_VIEW_MENUPANE )
   343         {
   328         {
   344         if ( iContainer )
   329         if ( iContainer )
   345             {
   330             {
   346             iCurrentItem = iContainer->CurrentItemIndex();
   331             if ( iContainer->iListBox->IsHighlightEnabled() )
       
   332                 {
       
   333                 iCurrentItem = iContainer->CurrentItemIndex();
       
   334                 }
       
   335             else
       
   336                 {
       
   337                 iCurrentItem = iModel->ActiveSkinIndex();
       
   338                 if ( iDownloadItemIndex != KErrNotFound )
       
   339                     {
       
   340                     iCurrentItem++;
       
   341                     }
       
   342                 }
   347             }
   343             }
   348 
   344 
   349         TBool downloadExists = ETrue;
   345         TBool downloadExists = ETrue;
   350         // Download theme is not selected, or it is not supported.
   346         // Download theme is not selected, or it is not supported.
   351         if ( iDownloadItemIndex == KErrNotFound )
   347         if ( iDownloadItemIndex == KErrNotFound )
   421             {
   417             {
   422             downloadExists = EFalse;
   418             downloadExists = EFalse;
   423             }
   419             }
   424         TInt skinIndex = iCurrentItem - (TInt) downloadExists;
   420         TInt skinIndex = iCurrentItem - (TInt) downloadExists;
   425 		
   421 		
   426         if ( ( iCurrentItem != iDownloadItemIndex &&
   422         if ( ( iCurrentItem == iDownloadItemIndex &&
   427              iDownloadItemIndex != KErrNotFound )||
   423              iDownloadItemIndex != KErrNotFound )||
   428              !iModel->IsActiveSkinSelected() ||
   424              !iModel->IsActiveSkinSelected() ||
   429              !PslnFeatures::IsSupported( KPslnSupportAnimBackground ) ||
   425              !PslnFeatures::IsSupported( KPslnSupportAnimBackground ) ||
   430              !iModel->IsSupportAnimBg(skinIndex))
   426              !iModel->IsSupportAnimBg(skinIndex))
   431             {
   427             {
   489         HandleCommandL( EPslnCmdAppActivate );
   485         HandleCommandL( EPslnCmdAppActivate );
   490         }
   486         }
   491     }
   487     }
   492 
   488 
   493 // -----------------------------------------------------------------------------
   489 // -----------------------------------------------------------------------------
   494 // Handle listbox item highlight.
       
   495 //
       
   496 // -----------------------------------------------------------------------------
       
   497 //
       
   498 void CPslnGeneralThemeView::HandleListBoxItemHighlightL()
       
   499     {
       
   500     PSLN_TRACE_DEBUG("CPslnGeneralThemeView::HandleListBoxItemHighlightL");
       
   501     if ( iContainer )
       
   502         {
       
   503         HandlePreviewStateChange( ETrue );
       
   504         static_cast<CPslnGeneralThemeContainer*>(iContainer)->StartThemePreviewL();
       
   505         }
       
   506     }
       
   507 
       
   508 // -----------------------------------------------------------------------------
       
   509 // Create container.
   490 // Create container.
   510 //
   491 //
   511 // -----------------------------------------------------------------------------
   492 // -----------------------------------------------------------------------------
   512 //
   493 //
   513 void CPslnGeneralThemeView::NewContainerL()
   494 void CPslnGeneralThemeView::NewContainerL()
   514     {
   495     {
   515     iContainer = new(ELeave) CPslnGeneralThemeContainer();
   496     iContainer = new(ELeave) CPslnGeneralThemeContainer();
   516     iContainer->SetMiddleSoftkeyObserver( this );
   497     iContainer->SetMiddleSoftkeyObserver( this );
   517     static_cast<CPslnGeneralThemeContainer*>(iContainer)->
       
   518         SetThemePreviewObserver( this );
       
   519     }
   498     }
   520 
   499 
   521 // -----------------------------------------------------------------------------
   500 // -----------------------------------------------------------------------------
   522 // Sets view specific title pane text.
   501 // Sets view specific title pane text.
   523 //
   502 //
   594         }
   573         }
   595     CheckMiddleSoftkeyLabelL();
   574     CheckMiddleSoftkeyLabelL();
   596     }
   575     }
   597 
   576 
   598 // -----------------------------------------------------------------------------
   577 // -----------------------------------------------------------------------------
   599 // New theme preview state available.
       
   600 // -----------------------------------------------------------------------------
       
   601 //
       
   602 void CPslnGeneralThemeView::HandlePreviewStateChange( const TBool& aPreviewMode )
       
   603     {
       
   604     iPreviewMode = aPreviewMode;
       
   605 //    TRAPD( state, iModel->GetTransitionEffectStateL() );
       
   606 //    if ( state != KMaxTInt )
       
   607 //        {        
       
   608 //        CAknView::StopDisplayingMenuBar();
       
   609 //        }
       
   610     if ( iDelayedSkinActivation && !iPreviewMode )
       
   611         {
       
   612         TRAP_IGNORE( HandleCommandL( EPslnCmdAppActivate ) );
       
   613         iDelayedSkinActivation = EFalse;
       
   614         }
       
   615     }
       
   616 
       
   617     
       
   618 // ---------------------------------------------------------------------------
       
   619 // Restart Quick Preview
       
   620 // ---------------------------------------------------------------------------
       
   621 //
       
   622 void CPslnGeneralThemeView::RestartQuickPreviewL()
       
   623     {
       
   624     CPslnGeneralThemeContainer* container = static_cast<CPslnGeneralThemeContainer*>(iContainer);
       
   625 
       
   626     container->RestartQuickPreviewL();
       
   627     }
       
   628 
       
   629 // -----------------------------------------------------------------------------
       
   630 // Remove local skin items.
       
   631 // -----------------------------------------------------------------------------
       
   632 //
       
   633 void CPslnGeneralThemeView::RemoveLocalSkinItems()
       
   634     {
       
   635     // Remove locally skinned items.
       
   636     MAknsSkinInstance* si = AknsUtils::SkinInstance();
       
   637     if ( si )
       
   638         {        
       
   639         si->SetChangeEventsEnabled( EFalse );
       
   640         si->RemoveLocalItemDefs();
       
   641         si->SetChangeEventsEnabled( ETrue );
       
   642         }
       
   643     }
       
   644 
       
   645 // -----------------------------------------------------------------------------
       
   646 // Remove MSK command mappings.
   578 // Remove MSK command mappings.
   647 // This method should do nothing but MSK issues.
   579 // This method should do nothing but MSK issues.
   648 // -----------------------------------------------------------------------------
   580 // -----------------------------------------------------------------------------
   649 //
   581 //
   650 void CPslnGeneralThemeView::RemoveCommandFromMSK()
   582 void CPslnGeneralThemeView::RemoveCommandFromMSK()
   656         {
   588         {
   657         cbaGroup->RemoveCommandFromStack( KPslnMSKControlID, EPslnCmdAppDownload );
   589         cbaGroup->RemoveCommandFromStack( KPslnMSKControlID, EPslnCmdAppDownload );
   658         cbaGroup->RemoveCommandFromStack( KPslnMSKControlID, EPslnCmdAppActivate );
   590         cbaGroup->RemoveCommandFromStack( KPslnMSKControlID, EPslnCmdAppActivate );
   659         }
   591         }
   660     }
   592     }
   661 // -----------------------------------------------------------------------------
   593 
   662 // Handle listbox stylus down event.
       
   663 // -----------------------------------------------------------------------------
       
   664 //
       
   665 void CPslnGeneralThemeView::HandleListBoxStylusDown()
       
   666     {
       
   667     }
       
   668     
       
   669 // -----------------------------------------------------------------------------
       
   670 // Handle listbox stylus move event.
       
   671 // -----------------------------------------------------------------------------
       
   672 //
       
   673 void CPslnGeneralThemeView::HandleListBoxStylusDrag()
       
   674     {
       
   675     }
       
   676 // -----------------------------------------------------------------------------
   594 // -----------------------------------------------------------------------------
   677 // Hightligt Default skin
   595 // Hightligt Default skin
   678 // -----------------------------------------------------------------------------
   596 // -----------------------------------------------------------------------------
   679 //
   597 //
   680 void CPslnGeneralThemeView::HightlightDefaultSkin()
   598 void CPslnGeneralThemeView::HightlightDefaultSkin()