menufw/menufwui/matrixmenu/src/mmappui.cpp
branchRCL_3
changeset 23 7be2816dbabd
parent 19 79311d856354
child 25 137ebc85284b
equal deleted inserted replaced
19:79311d856354 23:7be2816dbabd
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Application UI class
    14 * Description:  Application UI class
    15 *  Version     : %version: MM_176.1.28.1.69 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: MM_176.1.28.1.75 % << Don't touch! Updated by Synergy at check-out.
    16 *  Version     : %version: MM_176.1.28.1.69 % << Don't touch! Updated by Synergy at check-out.
    16 *  Version     : %version: MM_176.1.28.1.75 % << Don't touch! Updated by Synergy at check-out.
    17 *
    17 *
    18 */
    18 */
    19 
    19 
    20 #include <e32base.h>
    20 #include <e32base.h>
    21 #include <e32cmn.h>
    21 #include <e32cmn.h>
    44 #include <apgcli.h>
    44 #include <apgcli.h>
    45 #include <AknDef.hrh>
    45 #include <AknDef.hrh>
    46 #include <AknDlgShut.h>
    46 #include <AknDlgShut.h>
    47 #include <mmenuinternalPSkeys.h>
    47 #include <mmenuinternalPSkeys.h>
    48 #include <aknstyluspopupmenu.h> //stylus popup for long tap event
    48 #include <aknstyluspopupmenu.h> //stylus popup for long tap event
       
    49 #include <APGWGNAM.H>
    49 
    50 
    50 #include "mmgui.hrh"
    51 #include "mmgui.hrh"
    51 #include "mmguiconstants.h"
    52 #include "mmguiconstants.h"
    52 #include "mmappui.h"
    53 #include "mmappui.h"
    53 #include "menudebug.h"
    54 #include "menudebug.h"
   216         if ( lastItemIndex >= 0 && iCurrentContainer->ItemIsFullyVisible( lastItemIndex )
   217         if ( lastItemIndex >= 0 && iCurrentContainer->ItemIsFullyVisible( lastItemIndex )
   217                 && !iCurrentContainer->IsHighlightVisible() )
   218                 && !iCurrentContainer->IsHighlightVisible() )
   218             {
   219             {
   219             iCurrentContainer->SetManualHighlightL( lastItemIndex, EFalse );
   220             iCurrentContainer->SetManualHighlightL( lastItemIndex, EFalse );
   220             }
   221             }
   221 /*        else if( !iCurrentContainer->IsHighlightVisible()
   222         else if( !iCurrentContainer->IsHighlightVisible()
   222                 && iCurrentContainer->Widget()->TopItemIndex() > -1)
   223                 && iCurrentContainer->Widget()->TopItemIndex() > -1)
   223             {
   224             {
   224             iCurrentContainer->SetManualHighlightL(
   225             iCurrentContainer->SetManualHighlightL(
   225                     iCurrentContainer->Widget()->TopItemIndex(), EFalse );
   226                     iCurrentContainer->Widget()->TopItemIndex(), EFalse );
   226             } */
   227             }
   227 
   228 
   228         iCurrentContainer->SetRect( ClientRect() );
   229         iCurrentContainer->SetRect( ClientRect() );
   229         iDummyContainer->SetRect( ClientRect() );
   230         iDummyContainer->SetRect( ClientRect() );
   230 
   231 
   231         THashMapIter< TInt, CMmWidgetContainer* > iterator( iContainerMap );
   232         THashMapIter< TInt, CMmWidgetContainer* > iterator( iContainerMap );
  1275       RArray<TInt> positionArray;
  1276       RArray<TInt> positionArray;
  1276       CleanupClosePushL( positionArray );
  1277       CleanupClosePushL( positionArray );
  1277       RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap;
  1278       RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap;
  1278       CleanupClosePushL( menuItemMap );
  1279       CleanupClosePushL( menuItemMap );
  1279 
  1280 
  1280             while ( menuIterator->HasNextSpecific() )
  1281       while ( menuIterator->HasNextSpecific() )
  1281                 {
  1282           {
  1282                 CHnMenuItemModel* childItem = menuIterator->GetNextSpecific();
  1283           CHnMenuItemModel* childItem = menuIterator->GetNextSpecific();
  1283         CEikMenuPaneItem::SData childData;
  1284           CEikMenuPaneItem::SData childData;
  1284         childData.iCommandId = childItem->Command();
  1285           childData.iCommandId = childItem->Command();
  1285         childData.iText = childItem->NameL().
  1286           childData.iText = childItem->NameL().
  1286           Left( CEikMenuPaneItem::SData::ENominalTextLength );
  1287                   Left( CEikMenuPaneItem::SData::ENominalTextLength );
  1287         childData.iFlags = 0;
  1288           childData.iFlags = 0;
  1288         childData.iCascadeId = 0;
  1289           childData.iCascadeId = 0;
  1289 
  1290 
  1290         positionArray.AppendL( childItem->Position() );
  1291           positionArray.AppendL( childItem->Position() );
  1291         menuItemMap.InsertL( childItem->Position(), childData );
  1292           menuItemMap.InsertL( childItem->Position(), childData );
  1292                 }
  1293           }
  1293 
  1294 
  1294       positionArray.Sort();
  1295       positionArray.Sort();
  1295 
  1296 
  1296       //add items in correct order
  1297       //add items in correct order
  1297       for ( TInt i = 0; i < positionArray.Count(); ++i )
  1298       for ( TInt i = 0; i < positionArray.Count(); ++i )
  1311       CleanupStack::PopAndDestroy( &positionArray );
  1312       CleanupStack::PopAndDestroy( &positionArray );
  1312       }
  1313       }
  1313     MMPERF(("CMmAppUi::DynInitMenuPaneL - STOP"));
  1314     MMPERF(("CMmAppUi::DynInitMenuPaneL - STOP"));
  1314     }
  1315     }
  1315 
  1316 
  1316   if ( !popupMenuDisplayed && iCurrentContainer )
  1317     if ( !popupMenuDisplayed && iCurrentContainer )
  1317     {
  1318         {
  1318     iCurrentContainer->EndLongTapL( ETrue );
  1319         iCurrentContainer->EndLongTapL( ETrue );
  1319     HandleHighlightItemSingleClickedL(
  1320         HandleHighlightItemSingleClickedL(
  1320         iCurrentContainer->Widget()->CurrentItemIndex() );
  1321             iCurrentContainer->Widget()->CurrentItemIndex() );
  1321     }
  1322         }
  1322     }
  1323     }
  1323 
  1324 
  1324 // ---------------------------------------------------------------------------
  1325 // ---------------------------------------------------------------------------
  1325 //
  1326 //
  1326 // ---------------------------------------------------------------------------
  1327 // ---------------------------------------------------------------------------
  1805         iToolbar->SetToolbarVisibility( EFalse );
  1806         iToolbar->SetToolbarVisibility( EFalse );
  1806         }
  1807         }
  1807 
  1808 
  1808     if( iCurrentContainer != aWidgetContainer )
  1809     if( iCurrentContainer != aWidgetContainer )
  1809         {
  1810         {
       
  1811         // During open new folder cancel longTap. 
       
  1812         if( iCurrentContainer && iCurrentContainer->IsEditMode() )
       
  1813             iCurrentContainer->EnableLongTapAnimation( EFalse );
       
  1814 
  1810         // We want a highlight to be visible while switching between
  1815         // We want a highlight to be visible while switching between
  1811         // grid and list views but no highlight should be visible
  1816         // grid and list views but no highlight should be visible
  1812         // after opening a folder.
  1817         // after opening a folder.
  1813         TBool highlightVisibleBefore =
  1818         TBool highlightVisibleBefore =
  1814                 iCurrentContainer &&
  1819                 iCurrentContainer &&
  1820 
  1825 
  1821         if ( highlightVisibleBefore )
  1826         if ( highlightVisibleBefore )
  1822             {
  1827             {
  1823             iCurrentContainer->SetHighlightVisibilityL( ETrue );
  1828             iCurrentContainer->SetHighlightVisibilityL( ETrue );
  1824             }
  1829             }
       
  1830 
       
  1831         // force scroll view to highlighted item in case we've been backing back
       
  1832         // and change presentation mode (to list view) had been done.
       
  1833         if( iCurrentContainer->WidgetType() == EListWidget )
       
  1834             {
       
  1835             TInt offsetBottom =
       
  1836                     iCurrentContainer->Widget()->View()->ItemPos(
       
  1837                         iCurrentSuiteModel->GetSuiteHighlight() ).iY
       
  1838                         + iCurrentContainer->Widget()->ItemHeight()
       
  1839                         - iCurrentContainer->Widget()->View()->ViewRect().Height();
       
  1840             TInt offsetTop = iCurrentContainer->Widget()->View()->ItemPos(
       
  1841                     iCurrentSuiteModel->GetSuiteHighlight() ).iY;
       
  1842             TBool takeTop = Abs( offsetTop ) < Abs( offsetBottom );
       
  1843             TInt offset = ( takeTop ) ? offsetTop : offsetBottom;
       
  1844             if( offset != 0 )
       
  1845                 {
       
  1846                 iCurrentContainer->Widget()->HandlePhysicsScrollEventL(
       
  1847                         offset );
       
  1848                 }
       
  1849             }
  1825         }
  1850         }
  1826     else
  1851     else
  1827         {
  1852         {
  1828         HandleNoWidgetChangeRefreshL();
  1853         HandleNoWidgetChangeRefreshL();
  1829         }
  1854         }
  1830 
  1855 
  1831     if( iCurrentContainer )
  1856     if( iCurrentContainer )
  1832         {
  1857         {
  1833         iCurrentContainer->SetRect(ClientRect());
  1858         iCurrentContainer->SetRect(ClientRect());
  1834         iDummyContainer->SetRect(ClientRect());
  1859         iDummyContainer->SetRect(ClientRect());
  1835         if( IsForeground() )
  1860         if( IsForeground() || IsFaded() )
  1836             {
  1861             {
  1837             // should be called before MakeVisible (and after SetRect or SetupLayout,
  1862             // should be called before MakeVisible (and after SetRect or SetupLayout,
  1838             // so that default highlight is displayed correctly when zoomed)
  1863             // so that default highlight is displayed correctly when zoomed)
  1839             ApplyHighlightFromModelL();
  1864             ApplyHighlightFromModelL();
  1840 
  1865 
  1911 // ---------------------------------------------------------------------------
  1936 // ---------------------------------------------------------------------------
  1912 //
  1937 //
  1913 TInt CMmAppUi::ExecuteExtensionActionL( const TUid aUid , const TDesC& aCommand,
  1938 TInt CMmAppUi::ExecuteExtensionActionL( const TUid aUid , const TDesC& aCommand,
  1914                 CLiwGenericParamList* aEventParamList )
  1939                 CLiwGenericParamList* aEventParamList )
  1915     {
  1940     {
       
  1941     iCurrentContainer->SetExDialogOpened( ETrue );
  1916     return iMmExtManager->ExecuteActionL( aUid, aCommand, aEventParamList);
  1942     return iMmExtManager->ExecuteActionL( aUid, aCommand, aEventParamList);
  1917     }
  1943     }
  1918 // ---------------------------------------------------------------------------
  1944 // ---------------------------------------------------------------------------
  1919 //
  1945 //
  1920 // ---------------------------------------------------------------------------
  1946 // ---------------------------------------------------------------------------
  2449         // immediately after exiting the menu via Options->Exit.
  2475         // immediately after exiting the menu via Options->Exit.
  2450         // The bug would be that on pressing the appkey homescreen would be
  2476         // The bug would be that on pressing the appkey homescreen would be
  2451         // displayed and then the menu would appear again on the screen for
  2477         // displayed and then the menu would appear again on the screen for
  2452         // a fraction of second causing an ugly and confusing flicker effect.
  2478         // a fraction of second causing an ugly and confusing flicker effect.
  2453         TRAP_IGNORE( PrepareHomescreenForMatrixExitL() );
  2479         TRAP_IGNORE( PrepareHomescreenForMatrixExitL() );
  2454 //        ShowHomescreenL( aExitType );
  2480         //ShowHomescreenL( aExitType );
  2455         //if we got exit cmd from OS, let's really exit.
  2481         //if we got exit cmd from OS, let's really exit.
  2456         Exit();
  2482         Exit();
  2457         }
  2483         }
  2458     else
  2484     else
  2459         {
  2485         {
  2506         if ( iCurrentContainer && mustDrawImmediately )
  2532         if ( iCurrentContainer && mustDrawImmediately )
  2507             {
  2533             {
  2508             DEBUG(("\t_Mm_:Top item index reset"));
  2534             DEBUG(("\t_Mm_:Top item index reset"));
  2509             iCurrentContainer->ResetWidgetPosition();
  2535             iCurrentContainer->ResetWidgetPosition();
  2510             iCurrentContainer->Widget()->UpdateScrollBarsL();
  2536             iCurrentContainer->Widget()->UpdateScrollBarsL();
  2511       iCurrentContainer->MakeVisible( ETrue );
  2537             iCurrentContainer->MakeVisible( ETrue );
  2512       iCurrentContainer->DrawNow();
  2538             iCurrentContainer->DrawNow();
  2513             }
  2539             }
  2514         }
  2540         }
  2515 
  2541 
  2516     DEBUG(("_Mm_:CMmAppUi::CleanupForExitL - OUT"));
  2542     DEBUG(("_Mm_:CMmAppUi::CleanupForExitL - OUT"));
  2517     }
  2543     }
  2522 //
  2548 //
  2523 void CMmAppUi::ShowHomescreenL( TExitType  aExitType  )
  2549 void CMmAppUi::ShowHomescreenL( TExitType  aExitType  )
  2524     {
  2550     {
  2525     TInt appToShowUid(0);
  2551     TInt appToShowUid(0);
  2526     TInt idleid(0);
  2552     TInt idleid(0);
  2527     if (aExitType == EExitToIdle || aExitType == EExitToPhone)
  2553     switch( aExitType )
  2528         {
  2554         {
  2529         User::LeaveIfError(RProperty::Get(KPSUidAiInformation, KActiveIdleUid,
  2555         case EExitToIdle:
  2530                 appToShowUid));
  2556             {
  2531         OpenAppL(TUid::Uid(appToShowUid));
  2557             User::LeaveIfError( RProperty::Get( KPSUidAiInformation,
  2532         }
  2558                     KActiveIdleUid, appToShowUid ) );
  2533     else if (KErrNone == RProperty::Get(KPSUidUikon, KUikVideoCallTopApp,
  2559             OpenAppL( TUid::Uid( appToShowUid ) );
  2534             idleid))
  2560             }
  2535         {
  2561             break;
  2536         // Possible error code not relevant, as we have valid id anyway
  2562         case EExitToPhone:
  2537         if (idleid != KVideoCallAppUid) // idle or phone
  2563             {
  2538             {
  2564             if( !RProperty::Get( KPSUidUikon, KUikVideoCallTopApp, idleid ) )
  2539             OpenAppL(TUid::Uid(KPhoneAppUid));
  2565                 {
  2540             }
  2566                 // Possible error code not relevant, as we have valid id anyway
  2541         else
  2567                 if( idleid == KVideoCallAppUid )
  2542             {
  2568                     {
  2543             CreateActivateViewEventL(TVwsViewId(TUid::Uid(idleid),
  2569                     CreateActivateViewEventL( TVwsViewId(
  2544                     TUid::Uid(idleid)), KNullUid, KNullDesC8());
  2570                             TUid::Uid( idleid ), TUid::Uid( idleid ) ),
  2545             }
  2571                             KNullUid, KNullDesC8() );
  2546         }
  2572                     break;
  2547     else
  2573                     }
  2548         {
  2574                 }
  2549         OpenAppL(TUid::Uid(KPhoneAppUid));
  2575             CAknTaskList* taskList = CAknTaskList::NewL(
       
  2576                     iCoeEnv->WsSession() );
       
  2577             TApaTask task = taskList->FindRootApp( TUid::Uid( KPhoneAppUid ) );
       
  2578             delete taskList;
       
  2579             if( task.Exists() )
       
  2580                 {
       
  2581                 CApaWindowGroupName* windowName = CApaWindowGroupName::NewLC(
       
  2582                                 iCoeEnv->WsSession(), task.WgId() );
       
  2583                 TBool hidden = windowName->Hidden();
       
  2584                 CleanupStack::PopAndDestroy( windowName );
       
  2585                 if( !hidden )
       
  2586                     {
       
  2587                     OpenAppL( TUid::Uid( KPhoneAppUid ) );
       
  2588                     break;
       
  2589                     }
       
  2590                 }
       
  2591             ShowHomescreenL( EExitToIdle );
       
  2592             }
       
  2593             break;
       
  2594         default:
       
  2595             ShowHomescreenL( EExitToPhone );
  2550         }
  2596         }
  2551     }
  2597     }
  2552 
  2598 
  2553 // ---------------------------------------------------------------------------
  2599 // ---------------------------------------------------------------------------
  2554 //
  2600 //
  2560 
  2606 
  2561     CAknTaskList* taskList = CAknTaskList::NewL( iCoeEnv->WsSession() );
  2607     CAknTaskList* taskList = CAknTaskList::NewL( iCoeEnv->WsSession() );
  2562     TApaTask task = taskList->FindRootApp( TUid::Uid( KPhoneAppUid ) );
  2608     TApaTask task = taskList->FindRootApp( TUid::Uid( KPhoneAppUid ) );
  2563     delete taskList;
  2609     delete taskList;
  2564 
  2610 
  2565     if ( task.Exists() )
  2611     if( task.Exists() )
  2566         {
  2612         {
  2567         succeeded = !iCoeEnv->WsSession().SetWindowGroupOrdinalPosition(
  2613         CApaWindowGroupName* windowName = CApaWindowGroupName::NewLC(
  2568                     task.WgId(), 1 );
  2614                 iCoeEnv->WsSession(), task.WgId() );
       
  2615         if( !windowName->Hidden() )
       
  2616             {
       
  2617             succeeded = !iCoeEnv->WsSession().SetWindowGroupOrdinalPosition(
       
  2618                             task.WgId(), 1 );
       
  2619             }
       
  2620         CleanupStack::PopAndDestroy( windowName );
  2569         }
  2621         }
  2570 
  2622 
  2571     if( !succeeded )
  2623     if( !succeeded )
  2572         {
  2624         {
  2573         ShowHomescreenL( EExitReally );
  2625         ShowHomescreenL( EExitReally );