diff -r b023a8d2866a -r ea65f74e6de4 photosgallery/slideshow/view/src/shwslideshowview.cpp --- a/photosgallery/slideshow/view/src/shwslideshowview.cpp Thu Jul 15 18:39:01 2010 +0300 +++ b/photosgallery/slideshow/view/src/shwslideshowview.cpp Thu Aug 19 09:55:03 2010 +0300 @@ -40,6 +40,7 @@ #include // for CGlxResolutionUtility #include // view's resource #include // for resource directory path +#include // for EGlxCmdResetView #include #include #include // for CAknKeySoundSystem @@ -247,6 +248,10 @@ { // The list should now be populated, so set the focus SetListFocusL(); + + // Initialize control textures + iVolumeControl->InitControlTextureL(); + // Need to take latest screen size as layout has changed TRect currentScreen; AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, @@ -292,6 +297,8 @@ // we need the full path for the filter creation so that the selection can be // extracted from there CMPXCollectionPath* fullpath = iMediaList->PathLC(); + // CreateSlideShowFilterFromExistingFilterL() takes ownership of the fullpath so no need to destroy it. + CleanupStack::Pop( fullpath ); // create the filter filter = TGlxFilterFactory::CreateSlideShowFilterFromExistingFilterL( iMediaList->Filter(), fullpath, @@ -304,7 +311,6 @@ iFilteredList->AddMediaListObserverL( this ); CleanupStack::PopAndDestroy( filter ); - CleanupStack::PopAndDestroy( fullpath ); // return value needed as this is a TCallBack return KErrNone; @@ -375,6 +381,8 @@ &CShwSlideshowView::PopulateListL> (this)); iMSKPressed = EFalse; iLSKPressed = EFalse; + iAknEventMonitor + = static_cast (CCoeEnv::Static()->AppUi())->EventMonitor(); } // --------------------------------------------------------------------------- @@ -391,15 +399,16 @@ // --------------------------------------------------------------------------- // From CAknView -// Foreground event handling function. +// Background event handling in HandleWsEventL. +// Foreground event handling this function. // --------------------------------------------------------------------------- // void CShwSlideshowView::HandleForegroundEventL(TBool aForeground) { - TRACER("CShwSlideshowView::HandleForegroundEventL"); - GLX_LOG_INFO( "CShwSlideshowView::HandleForegroundEventL()" ); + TRACER("CShwSlideshowView::HandleForegroundEventL"); + GLX_LOG_INFO1("CShwSlideshowView::HandleForegroundEventL(%d)", aForeground); iIsForegrnd = aForeground; - if( aForeground ) + if (aForeground) { if (iHdmiController && iHdmiActive) { @@ -416,16 +425,6 @@ iEngine->GetMusicVolumeL(); } } - else - { - if (iHdmiController && iHdmiActive) - { - iHdmiController->ShiftToCloningMode(); - } - // Something else has gained the foreground - iPauseHandler->SwitchToBackgroundL(); - } - CAknView::HandleForegroundEventL(aForeground); } @@ -507,6 +506,8 @@ // We will require to act on events ONLY when the view is active. // So listen to them only when the view is active. iShwGestureControl->AddObserverL(this); + iAknEventMonitor->Enable(ETrue); + iAknEventMonitor->AddObserverL(this); } // ----------------------------------------------------------------------------- @@ -547,6 +548,8 @@ //are always valid so no need to test for != NULL iDisplay->Roster().Hide( *iVolumeControlGroup ); + iAknEventMonitor->Enable(EFalse); + iAknEventMonitor->RemoveObserver(this); //Ensure we revert to a proper background TRAP_IGNORE( @@ -760,23 +763,23 @@ // --------------------------------------------------------------------------- // void CShwSlideshowView::EngineStartedL() - { - TRACER("CShwSlideshowView::EngineStartedL"); - GLX_LOG_INFO( "CShwSlideshowView::EngineStartedL()" ); - - if (iWaitDialog) - { - // cancel the progress bar - iWaitDialog->ProcessFinishedL(); - } - if (iHdmiController) - { - iHdmiController->ShiftToPostingMode(); - } - iShwState = EShwPlay; - ReplaceCommandSetL(R_SHW_SOFTKEYS_END_PAUSE, R_SHW_SOFTKEYS_END_PAUSE); - ShowShwFurnitureL(); - } + { + TRACER("CShwSlideshowView::EngineStartedL"); + GLX_LOG_INFO( "CShwSlideshowView::EngineStartedL()" ); + if (iWaitDialog) + { + // cancel the progress bar + iWaitDialog->ProcessFinishedL(); + } + if (iHdmiController) + { + iHdmiController->ShiftToPostingMode(); + } + // Here, iShwState value is either 0(first instance) + // or EShwExiting(remembered from previous instance) + iShwState = EShwPlay; + ShowShwFurnitureL(); + } // --------------------------------------------------------------------------- // From MShwEngineObserver @@ -786,20 +789,19 @@ void CShwSlideshowView::EnginePausedL() { TRACER("CShwSlideshowView::EnginePausedL"); - GLX_LOG_INFO( "CShwSlideshowView::EnginePausedL()" ); - + GLX_LOG_INFO( "CShwSlideshowView::EnginePausedL()" ); // Cancel the backlight if it's on - if ( iBackLightTimer->IsRunning() ) + if (iBackLightTimer->IsRunning()) { iBackLightTimer->Cancel(); } - - if(!iUiUtility->IsExitingState()) - { - iShwState = EShwPause; - ReplaceCommandSetL(R_SHW_SOFTKEYS_END_CONTINUE,R_SHW_SOFTKEYS_END_PAUSE); - ShowShwFurnitureL(); - } + if (!iUiUtility->IsExitingState() && (iShwState != EShwExiting)) + { + iShwState = EShwPause; + ReplaceCommandSetL(R_SHW_SOFTKEYS_END_CONTINUE, + R_SHW_SOFTKEYS_END_PAUSE); + ShowShwFurnitureL(); + } } // --------------------------------------------------------------------------- @@ -807,20 +809,24 @@ // Engine resumed callback. // --------------------------------------------------------------------------- // -void CShwSlideshowView::EngineResumedL() - { - TRACER("CShwSlideshowView::EngineResumedL"); - GLX_LOG_INFO( "CShwSlideshowView::EngineResumedL" ); - iEngine->GetMusicVolumeL(); +void CShwSlideshowView::EngineResumedL() + { + TRACER("CShwSlideshowView::EngineResumedL"); + GLX_LOG_INFO( "CShwSlideshowView::EngineResumedL" ); + iEngine->GetMusicVolumeL(); // Re-enable the backlight if it's off - if ( !iBackLightTimer->IsRunning() ) + if (!iBackLightTimer->IsRunning()) { iBackLightTimer->StartL(); } - iShwState = EShwPlay; - ReplaceCommandSetL(R_SHW_SOFTKEYS_END_PAUSE,R_SHW_SOFTKEYS_END_CONTINUE); - ShowShwFurnitureL(); - } + if (iShwState != EShwExiting) + { + iShwState = EShwPlay; + ReplaceCommandSetL(R_SHW_SOFTKEYS_END_PAUSE, + R_SHW_SOFTKEYS_END_CONTINUE); + ShowShwFurnitureL(); + } + } // --------------------------------------------------------------------------- // From MShwEngineObserver // Engine LSK Pressed @@ -1008,17 +1014,13 @@ CleanupClosePushL( stream ); stream.ReadInt32L(); - //Get the play direction. - CShwSettingsModel* shwSettingsMdl = CShwSettingsModel::NewL(); - CleanupStack::PushL( shwSettingsMdl ); - iPlayDirection = static_cast< NShwSlideshow:: - TPlayDirection>(shwSettingsMdl->PlayOrderL()); + CleanupStack::PushL(shwSettingsMdl); + iPlayDirection + = static_cast (shwSettingsMdl->PlayOrderL()); CleanupStack::PopAndDestroy( shwSettingsMdl ); - - // Retrieve the path iCollectionPath = CMPXCollectionPath::NewL(); iCollectionPath->InternalizeL( stream ); @@ -1049,28 +1051,31 @@ void CShwSlideshowView::SetListFocusL() { TRACER("CShwSlideshowView::SetListFocusL"); - GLX_LOG_INFO( "CShwSlideshowView::SetListFocusL" ); + GLX_LOG_INFO("CShwSlideshowView::SetListFocusL"); // Ensure that we start the slideshow from the correct image index: // if there are any selected images we always start from the first one, // otherwise we try to use the item with focus from the unfiltered list // so long as it hasn't been filtered out, in which case we use the first image. TInt selectionCount = iCollectionPath->Selection().Count(); TInt focusIndex = 0; - if ( selectionCount == 0 ) + if (selectionCount == 0) { + // nothing selected, so determine which item has focus in the original list focusIndex = iMediaList->FocusIndex(); - const TGlxMedia& mediaItem = iMediaList->Item( focusIndex ); + GLX_LOG_INFO1("SlideshowView::SetListFocusL focusIndex(%d)", focusIndex); + + const TGlxMedia& mediaItem = iMediaList->Item(focusIndex); // Check if this item is in the filtered list - TGlxIdSpaceId spaceId = iMediaList->IdSpaceId( focusIndex ); - focusIndex = iFilteredList->Index( spaceId, mediaItem.Id() ); - if ( focusIndex == KErrNotFound ) + TGlxIdSpaceId spaceId = iMediaList->IdSpaceId(focusIndex); + focusIndex = iFilteredList->Index(spaceId, mediaItem.Id()); + if (focusIndex == KErrNotFound) { - // it's been filtered out so just use the first item - focusIndex = 0; + focusIndex = ((iPlayDirection == NShwSlideshow::EPlayBackwards) + ? 0 : iFilteredList->Count() - 1); } } - iFilteredList->SetFocusL( NGlxListDefs::EAbsolute, focusIndex ); + iFilteredList->SetFocusL(NGlxListDefs::EAbsolute, focusIndex); } @@ -1183,8 +1188,6 @@ CEikButtonGroupContainer::EVertical, this, R_SHW_SOFTKEYS_END_PAUSE ); iShwCba->MakeVisible(EFalse); - //set the current active command set - ReplaceCommandSetL(R_SHW_SOFTKEYS_END_PAUSE,R_SHW_SOFTKEYS_END_PAUSE); } // ----------------------------------------------------------------------------- @@ -1204,8 +1207,6 @@ } // set the new command set iShwCba->SetCommandSetL( aNewComandId ); - // keep the current active command set - iCurrentActiveCommandSet = aNewComandId; } @@ -1226,7 +1227,6 @@ iVolumeControl->Hide(); } iShwFurniture = EFurnitureHidden; - } // ----------------------------------------------------------------------------- @@ -1259,13 +1259,19 @@ { TRACER("CShwSlideshowView::ProcessCommandL"); GLX_LOG_INFO( "CShwSlideshowView::ProcessCommandL" ); - switch(aCommandId) + switch (aCommandId) { case EShwSlideshowCmdEnd: + case EAknSoftkeyBack: + case EGlxCmdResetView: { iShwState = EShwExiting; - aCommandId = EAknSoftkeyBack; - iDisplay->Roster().Hide( *iGestureControlGroup ); + iDisplay->Roster().Hide(*iGestureControlGroup); + HideShwFurniture(); + if (aCommandId == EShwSlideshowCmdEnd) + { + aCommandId = EAknSoftkeyBack; + } break; } //When user presses MSK or LSK this cmd will Generated @@ -1273,11 +1279,11 @@ case EShwSlideshowCmdContinue: { // If MSK preesed to toggle visibility of softekey - if(iMSKPressed) + if (iMSKPressed) { iMSKPressed = EFalse; - } - else if(iLSKPressed) + } + else if (iLSKPressed) { iLSKPressed = EFalse;// Already Handlled } @@ -1285,9 +1291,8 @@ { iPauseHandler->UserToggledPauseL(); } - break; + break; } - default: { break; @@ -1538,3 +1543,50 @@ TRACER("CShwSlideshowView::HandleHDMIDecodingEventL()"); iEngine->HandleHDMIDecodingEventL(aStatus); } +// ------------------------------------------------------------------------------------------------- +// CShwSlideshowView::IsAppInForegroundL() +// ------------------------------------------------------------------------------------------------- +// +TBool CShwSlideshowView::IsAppInForegroundL() + { + TRACER("CShwSlideshowView::IsAppInForegroundL()"); + TBool ret = EFalse; + CArrayFixFlat* wgList = new (ELeave) CArrayFixFlat ( + iEikonEnv->WsSession().NumWindowGroups()); + CleanupStack::PushL(wgList); + if (iEikonEnv->WsSession().WindowGroupList(0, wgList) == KErrNone) + { + // Check if Photos App window group is in foreground + ret = (iCoeEnv->RootWin().Identifier() == wgList->At(0)); + GLX_LOG_INFO2("SlideshowView::IsAppInForegroundL() ret=%d, wgId=%u", + ret, wgList->At(0)); + } + + CleanupStack::PopAndDestroy(wgList); + return ret; + } + +// ------------------------------------------------------------------------------------------------- +// CShwSlideshowView::HandleWsEventL() +// WS Events handling function +// ------------------------------------------------------------------------------------------------- +// +void CShwSlideshowView::HandleWsEventL(const TWsEvent& aEvent, + CCoeControl* /*aDestination*/) + { + TRACER("CShwSlideshowView::HandleWsEventL()"); + TInt event = aEvent.Type(); + GLX_LOG_INFO1("CShwSlideshowView::HandleWsEventL() event=%d", event); + + // If we are sent to full background, shift to cloning mode + if ((event == KAknFullOrPartialForegroundLost) && !IsAppInForegroundL()) + { + GLX_LOG_INFO("SlideshowView::HandleWsEventL() App is in background!"); + if (iHdmiController && iHdmiActive) + { + iHdmiController->ShiftToCloningMode(); + } + // Something else has gained the foreground + iPauseHandler->SwitchToBackgroundL(); + } + }