idlehomescreen/widgetmanager/src/wmmaincontainer.cpp
branchRCL_3
changeset 34 d05a55b217df
parent 30 b8fae6b8a148
child 38 79311d856354
equal deleted inserted replaced
30:b8fae6b8a148 34:d05a55b217df
    66 #include "wmportalbutton.h"
    66 #include "wmportalbutton.h"
    67 #include "wmwidgetloaderao.h"
    67 #include "wmwidgetloaderao.h"
    68 #include "wmconfiguration.h"
    68 #include "wmconfiguration.h"
    69 #include "wminstaller.h"
    69 #include "wminstaller.h"
    70 
    70 
       
    71 #include <hscontentcontroller.h> // content control api
       
    72 #include <hscontentinfoarray.h> // content control api
       
    73 
    71 // CONSTANTS
    74 // CONSTANTS
    72 const TInt KTextLimit = 40; // Text-limit for find-field
    75 const TInt KTextLimit = 40; // Text-limit for find-field
    73 const TInt KMinWidgets = 1; // minimum number of widgets to show findpane
    76 const TInt KMinWidgets = 1; // minimum number of widgets to show findpane
    74 
    77 
    75 // ---------------------------------------------------------
    78 // ---------------------------------------------------------
    91 // CWmMainContainer::~CWmMainContainer()
    94 // CWmMainContainer::~CWmMainContainer()
    92 // ---------------------------------------------------------
    95 // ---------------------------------------------------------
    93 //
    96 //
    94 CWmMainContainer::~CWmMainContainer()
    97 CWmMainContainer::~CWmMainContainer()
    95 	{
    98 	{
       
    99     TRAP_IGNORE(DeactivateFindPaneL(EFalse));
       
   100     
    96     delete iWidgetLoader;
   101     delete iWidgetLoader;
    97 
   102 
    98     RemoveCtrlsFromStack();
   103     RemoveCtrlsFromStack();
    99     Components().ResetAndDestroy();
   104     Components().ResetAndDestroy();
   100     
   105     
   220         TInt variety = (iLandscape ? 3 : 2);
   225         TInt variety = (iLandscape ? 3 : 2);
   221         TAknWindowLineLayout oviBtnLayout = AknLayoutScalable_Apps
   226         TAknWindowLineLayout oviBtnLayout = AknLayoutScalable_Apps
   222                 ::wgtman_btn_pane( variety ).LayoutLine();
   227                 ::wgtman_btn_pane( variety ).LayoutLine();
   223         TAknWindowLineLayout operatorBtnLayout = AknLayoutScalable_Apps
   228         TAknWindowLineLayout operatorBtnLayout = AknLayoutScalable_Apps
   224                 ::wgtman_btn_pane_cp_01( variety ).LayoutLine();
   229                 ::wgtman_btn_pane_cp_01( variety ).LayoutLine();
   225         AknLayoutUtils::LayoutControl( iPortalButtonOne, rect, oviBtnLayout );
   230         
   226         AknLayoutUtils::LayoutControl( iPortalButtonTwo, rect, operatorBtnLayout );
   231         // button placement
       
   232         if ( iConfiguration->PortalButtonsMirrored() )
       
   233             {
       
   234             AknLayoutUtils::LayoutControl( iPortalButtonOne, rect, operatorBtnLayout );
       
   235             AknLayoutUtils::LayoutControl( iPortalButtonTwo, rect, oviBtnLayout );
       
   236             }
       
   237         else
       
   238             {
       
   239             AknLayoutUtils::LayoutControl( iPortalButtonOne, rect, oviBtnLayout );
       
   240             AknLayoutUtils::LayoutControl( iPortalButtonTwo, rect, operatorBtnLayout );
       
   241             }
   227 	    }
   242 	    }
   228     
   243     
   229 	// layout iWidgetsList
   244 	// layout iWidgetsList
   230     TAknWindowLineLayout listPane = AknLayoutScalable_Apps
   245     TAknWindowLineLayout listPane = AknLayoutScalable_Apps
   231         ::listscroll_wgtman_pane( iLandscape ? 1 : 0 ).LayoutLine();
   246         ::listscroll_wgtman_pane( iLandscape ? 1 : 0 ).LayoutLine();
   254     {
   269     {
   255     TKeyResponse keyResponse( EKeyWasNotConsumed );
   270     TKeyResponse keyResponse( EKeyWasNotConsumed );
   256 
   271 
   257     // This is a bug fix for ou1cimx1#217716 & ou1cimx1#217667.
   272     // This is a bug fix for ou1cimx1#217716 & ou1cimx1#217667.
   258     // For some weird reason homescreen is genarating one extra EEventKey 
   273     // For some weird reason homescreen is genarating one extra EEventKey 
   259     // when using Nokia SU-8W bluetooth keyboard & backspace key. This if is to 
   274     // when using bluetooth keyboard & backspace key. This if is to 
   260     // ignore that event. Extra event allways has iModifiers set to 
   275     // ignore that event. Extra event allways has iModifiers set to 
   261     // EModifierAutorepeatable.
   276     // EModifierAutorepeatable, EModifierKeyboardExtend and 
       
   277     // EModifierNumLock.
   262     if ( aType == EEventKey && 
   278     if ( aType == EEventKey && 
   263              aKeyEvent.iScanCode == EStdKeyBackspace && 
   279          aKeyEvent.iScanCode == EStdKeyBackspace &&
   264              aKeyEvent.iModifiers == EModifierAutorepeatable )
   280          aKeyEvent.iModifiers&EModifierKeyboardExtend &&
       
   281          aKeyEvent.iModifiers&EModifierNumLock &&
       
   282          aKeyEvent.iModifiers&EModifierAutorepeatable )
   265         {
   283         {
   266         return EKeyWasConsumed;
   284         return EKeyWasConsumed;
   267         }
   285         }
   268     
   286     
   269     // Handle search keyevent
   287     // Handle search keyevent
   439                 aKeyEvent.iScanCode == EStdKeyUpArrow &&
   457                 aKeyEvent.iScanCode == EStdKeyUpArrow &&
   440                 iWidgetsList->CurrentItemIndex() == 0 )
   458                 iWidgetsList->CurrentItemIndex() == 0 )
   441             {
   459             {
   442             // widget list top -> up -> ovi button (portrait)
   460             // widget list top -> up -> ovi button (portrait)
   443             if ( aType == EEventKey )
   461             if ( aType == EEventKey )
   444                 SetFocusToPortalButton( 0 );
   462                 SetFocusToPortalButton( OperatorButtonHigherPriority ( 0 ) );
   445             keyResponse = EKeyWasConsumed;
   463             keyResponse = EKeyWasConsumed;
   446             }
   464             }
   447         else if ( !iLandscape &&
   465         else if ( !iLandscape &&
   448                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
   466                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
   449                 iWidgetsList->CurrentItemIndex() ==
   467                 iWidgetsList->CurrentItemIndex() ==
   450                    iWidgetsList->Model()->NumberOfItems() - 1 )
   468                    iWidgetsList->Model()->NumberOfItems() - 1 )
   451             {
   469             {
   452             // widget list bottom -> down -> ovi button (portrait)
   470             // widget list bottom -> down -> ovi button (portrait)
   453             if ( aType == EEventKey )
   471             if ( aType == EEventKey )
   454                 SetFocusToPortalButton( 0 );
   472                 SetFocusToPortalButton( OperatorButtonHigherPriority ( 0 ) );
   455             keyResponse = EKeyWasConsumed;
   473             keyResponse = EKeyWasConsumed;
   456             }
   474             }
   457         else if ( iLandscape && !iMirrored &&
   475         else if ( iLandscape && !iMirrored &&
   458                 aKeyEvent.iScanCode == EStdKeyRightArrow )
   476                 aKeyEvent.iScanCode == EStdKeyRightArrow )
   459             {
   477             {
   460             // widget list -> right -> ovi button (landscape normal)
   478             // widget list -> right -> ovi button (landscape normal)
   461             if ( aType == EEventKey )
   479             if ( aType == EEventKey )
   462                 SetFocusToPortalButton( 0 );
   480                 SetFocusToPortalButton( OperatorButtonHigherPriority ( 0 ) );
   463             keyResponse = EKeyWasConsumed;
   481             keyResponse = EKeyWasConsumed;
   464             }
   482             }
   465         else if ( iLandscape && iMirrored &&
   483         else if ( iLandscape && iMirrored &&
   466                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
   484                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
   467             {
   485             {
   491             if ( aType == EEventKey )
   509             if ( aType == EEventKey )
   492                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
   510                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
   493             keyResponse = EKeyWasConsumed;
   511             keyResponse = EKeyWasConsumed;
   494             }
   512             }
   495         else if ( !iLandscape && !iMirrored &&
   513         else if ( !iLandscape && !iMirrored &&
       
   514                 aKeyEvent.iScanCode == EStdKeyLeftArrow &&
       
   515                 iConfiguration->PortalButtonCount() > 1 && 
       
   516                 iConfiguration->PortalButtonsMirrored() )
       
   517             {
       
   518             // right portal -> left -> left portal
       
   519             // (portrait, operator button higher priority )
       
   520             if ( aType == EEventKey )
       
   521                 SetFocusToPortalButton( 1 );
       
   522             keyResponse = EKeyWasConsumed;
       
   523             }
       
   524         else if ( !iLandscape && !iMirrored &&
   496                 aKeyEvent.iScanCode == EStdKeyRightArrow &&
   525                 aKeyEvent.iScanCode == EStdKeyRightArrow &&
   497                 iConfiguration->PortalButtonCount() > 1 )
   526                 iConfiguration->PortalButtonCount() > 1 && 
       
   527                 !iConfiguration->PortalButtonsMirrored() )
   498             {
   528             {
   499             // left portal -> right -> right portal (portrait normal)
   529             // left portal -> right -> right portal (portrait normal)
   500             if ( aType == EEventKey )
   530             if ( aType == EEventKey )
   501                 SetFocusToPortalButton( 1 );
   531                 SetFocusToPortalButton( 1 );
   502             keyResponse = EKeyWasConsumed;
   532             keyResponse = EKeyWasConsumed;
   525             if ( aType == EEventKey )
   555             if ( aType == EEventKey )
   526                 SetFocusToWidgetList();
   556                 SetFocusToWidgetList();
   527             keyResponse = EKeyWasConsumed;
   557             keyResponse = EKeyWasConsumed;
   528             }
   558             }
   529         else if ( iLandscape &&
   559         else if ( iLandscape &&
       
   560                 aKeyEvent.iScanCode == EStdKeyUpArrow &&
       
   561                 iConfiguration->PortalButtonCount() > 1 &&
       
   562                 iConfiguration->PortalButtonsMirrored() )
       
   563             {
       
   564             // lower portal -> up -> upper portal 
       
   565             // (landscape, operator button higher priority )
       
   566             if ( aType == EEventKey )
       
   567                 SetFocusToPortalButton( 1 );
       
   568             keyResponse = EKeyWasConsumed;
       
   569             }
       
   570         else if ( iLandscape &&
   530                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
   571                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
   531                 iConfiguration->PortalButtonCount() > 1 )
   572                 iConfiguration->PortalButtonCount() > 1 && 
       
   573                 !iConfiguration->PortalButtonsMirrored() )
   532             {
   574             {
   533             // upper portal -> down -> lower portal (landscape)
   575             // upper portal -> down -> lower portal (landscape)
   534             if ( aType == EEventKey )
   576             if ( aType == EEventKey )
   535                 SetFocusToPortalButton( 1 );
   577                 SetFocusToPortalButton( 1 );
   536             keyResponse = EKeyWasConsumed;
   578             keyResponse = EKeyWasConsumed;
   556             if ( aType == EEventKey )
   598             if ( aType == EEventKey )
   557                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
   599                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
   558             keyResponse = EKeyWasConsumed;
   600             keyResponse = EKeyWasConsumed;
   559             }
   601             }
   560         else if ( !iLandscape && !iMirrored &&
   602         else if ( !iLandscape && !iMirrored &&
       
   603                 aKeyEvent.iScanCode == EStdKeyRightArrow &&
       
   604                 iConfiguration->PortalButtonCount() > 1  && 
       
   605                 iConfiguration->PortalButtonsMirrored() )
       
   606             {
       
   607             // left portal -> right -> right portal
       
   608             // (portrait, operator button higher priority )
       
   609             if ( aType == EEventKey )
       
   610                 SetFocusToPortalButton( 0 );
       
   611             keyResponse = EKeyWasConsumed;
       
   612             }
       
   613         else if ( !iLandscape && !iMirrored &&
   561                 aKeyEvent.iScanCode == EStdKeyLeftArrow &&
   614                 aKeyEvent.iScanCode == EStdKeyLeftArrow &&
   562                 iConfiguration->PortalButtonCount() > 1 )
   615                 iConfiguration->PortalButtonCount() > 1  && 
       
   616                 !iConfiguration->PortalButtonsMirrored() )
   563             {
   617             {
   564             // right portal -> left -> left portal (portrait normal)
   618             // right portal -> left -> left portal (portrait normal)
   565             if ( aType == EEventKey )
   619             if ( aType == EEventKey )
   566                 SetFocusToPortalButton( 0 );
   620                 SetFocusToPortalButton( 0 );
   567             keyResponse = EKeyWasConsumed;
   621             keyResponse = EKeyWasConsumed;
   590             if ( aType == EEventKey )
   644             if ( aType == EEventKey )
   591                 SetFocusToWidgetList();
   645                 SetFocusToWidgetList();
   592             keyResponse = EKeyWasConsumed;
   646             keyResponse = EKeyWasConsumed;
   593             }
   647             }
   594         else if ( iLandscape &&
   648         else if ( iLandscape &&
   595                 aKeyEvent.iScanCode == EStdKeyUpArrow )
   649                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
       
   650                 iConfiguration->PortalButtonsMirrored() )
       
   651             {
       
   652             // upper portal -> down -> lower portal 
       
   653             // ( landscape operator button higher priority )
       
   654             if ( aType == EEventKey )
       
   655                 SetFocusToPortalButton( 0 );
       
   656             keyResponse = EKeyWasConsumed;
       
   657             }
       
   658         else if ( iLandscape &&
       
   659                 aKeyEvent.iScanCode == EStdKeyUpArrow &&
       
   660                 !iConfiguration->PortalButtonsMirrored() )
   596             {
   661             {
   597             // lower portal -> up -> upper portal (landscape)
   662             // lower portal -> up -> upper portal (landscape)
   598             if ( aType == EEventKey )
   663             if ( aType == EEventKey )
   599                 SetFocusToPortalButton( 0 );
   664                 SetFocusToPortalButton( 0 );
   600             keyResponse = EKeyWasConsumed;
   665             keyResponse = EKeyWasConsumed;
   616                 }
   681                 }
   617             }
   682             }
   618         }
   683         }
   619 
   684 
   620     return keyResponse;
   685     return keyResponse;
       
   686     }
       
   687 
       
   688 
       
   689 // ---------------------------------------------------------
       
   690 // CWmMainContainer::OperatorButtonHigherPriority
       
   691 // ---------------------------------------------------------
       
   692 //
       
   693 TInt CWmMainContainer::OperatorButtonHigherPriority( TInt aIndex )
       
   694     {
       
   695     TInt ret = aIndex;
       
   696     if ( iConfiguration->PortalButtonsMirrored() )
       
   697         {
       
   698         if ( aIndex == 0 )
       
   699             {
       
   700             ret = 1;
       
   701             }
       
   702         else if ( aIndex == 1 )
       
   703             {
       
   704             ret = 0;
       
   705             }
       
   706         }
       
   707     return ret;
   621     }
   708     }
   622 
   709 
   623 // ---------------------------------------------------------
   710 // ---------------------------------------------------------
   624 // CWmMainContainer::SetFocusToPortalButton
   711 // CWmMainContainer::SetFocusToPortalButton
   625 // ---------------------------------------------------------
   712 // ---------------------------------------------------------
  1058     CWmWidgetData* data = iWidgetsList->WidgetData();
  1145     CWmWidgetData* data = iWidgetsList->WidgetData();
  1059     if ( !iClosingDown )
  1146     if ( !iClosingDown )
  1060         {
  1147         {
  1061         if ( iFindbox && iFindPaneIsVisible )
  1148         if ( iFindbox && iFindPaneIsVisible )
  1062             {
  1149             {
  1063             DeactivateFindPaneL();
  1150             DeactivateFindPaneL(EFalse);
  1064             }
  1151             }
  1065         
  1152         
  1066         if ( data && !data->IsUninstalling() )
  1153         if ( data && !data->IsUninstalling() )
  1067             {
  1154             {
  1068             // set add to homescreen to be executed later
  1155             // set add to homescreen to be executed later
  1158 
  1245 
  1159 // ---------------------------------------------------------------------------
  1246 // ---------------------------------------------------------------------------
  1160 // CWmMainContainer::DeactivateFindPaneL
  1247 // CWmMainContainer::DeactivateFindPaneL
  1161 // ---------------------------------------------------------------------------
  1248 // ---------------------------------------------------------------------------
  1162 //
  1249 //
  1163 void CWmMainContainer::DeactivateFindPaneL()
  1250 void CWmMainContainer::DeactivateFindPaneL(TBool aLayout)
  1164     {
  1251     {
  1165     if( iFindbox && iFindPaneIsVisible )
  1252     if( iFindbox && iFindPaneIsVisible )
  1166 	    {
  1253         {
  1167         // notify search field we're shutting down
  1254         // notify search field we're shutting down
  1168         TKeyEvent keyEvent = { EKeyNo, EStdKeyNo, 0, 0  };
  1255         TKeyEvent keyEvent = { EKeyNo, EStdKeyNo, 0, 0  };
  1169         iFindbox->OfferKeyEventL( keyEvent, EEventKey );
  1256         iFindbox->OfferKeyEventL( keyEvent, EEventKey );
  1170         
  1257         
  1171         // reset findbox
  1258         // reset findbox
  1184 
  1271 
  1185         iFindbox->MakeVisible( EFalse );        
  1272         iFindbox->MakeVisible( EFalse );        
  1186         iFindPaneIsVisible = EFalse;        
  1273         iFindPaneIsVisible = EFalse;        
  1187         iWidgetsList->SetFindPaneIsVisible( EFalse );       
  1274         iWidgetsList->SetFindPaneIsVisible( EFalse );       
  1188         
  1275         
  1189         LayoutControls();
  1276         if (aLayout) //no need to draw UI if exiting list
  1190 
  1277             {
  1191         // set soft key set
  1278             LayoutControls();
  1192         CEikButtonGroupContainer* cbaGroup =
  1279     
  1193             CEikButtonGroupContainer::Current();
  1280             // set soft key set
  1194         TInt cbaResourceId = ( AknLayoutUtils::MSKEnabled() ?
  1281             CEikButtonGroupContainer* cbaGroup =
  1195                                     R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT : 
  1282                 CEikButtonGroupContainer::Current();
  1196                                     R_AVKON_SOFTKEYS_OPTIONS_BACK );
  1283             TInt cbaResourceId = ( AknLayoutUtils::MSKEnabled() ?
  1197 
  1284                                         R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT : 
  1198         cbaGroup->SetCommandSetL( cbaResourceId );
  1285                                         R_AVKON_SOFTKEYS_OPTIONS_BACK );
  1199         cbaGroup->DrawNow();
  1286     
  1200 
  1287             cbaGroup->SetCommandSetL( cbaResourceId );
  1201         UpdateFocusMode();
  1288             cbaGroup->DrawNow();
  1202         DrawNow();
  1289     
       
  1290             UpdateFocusMode();
       
  1291             DrawNow();
       
  1292             }
  1203         }
  1293         }
  1204     }
  1294     }
  1205 
  1295 
  1206 // ---------------------------------------------------------------------------
  1296 // ---------------------------------------------------------------------------
  1207 // CWmMainContainer::SortListAlphabeticallyL
  1297 // CWmMainContainer::SortListAlphabeticallyL
  1349         const CFbsBitmap* logo = ( data->LogoImage() ) ? 
  1439         const CFbsBitmap* logo = ( data->LogoImage() ) ? 
  1350                     data->LogoImage() : iWidgetsList->DefaultLogo();
  1440                     data->LogoImage() : iWidgetsList->DefaultLogo();
  1351         const CFbsBitmap* mask = ( data->LogoImageMask() ) ? 
  1441         const CFbsBitmap* mask = ( data->LogoImageMask() ) ? 
  1352                     data->LogoImageMask() : iWidgetsList->DefaultMask();
  1442                     data->LogoImageMask() : iWidgetsList->DefaultMask();
  1353         
  1443         
       
  1444         // Find out if HS is full
       
  1445         TBool hsFull = ETrue;
       
  1446         MHsContentController& controller = iWmPlugin.ContentController();
       
  1447         CHsContentInfo* activeView = CHsContentInfo::NewLC();
       
  1448         if ( controller.ActiveViewL( *activeView ) == KErrNone )
       
  1449             {
       
  1450             hsFull = activeView->IsFull();
       
  1451             }
       
  1452         CleanupStack::PopAndDestroy( activeView );
       
  1453         
  1354         CWmDetailsDlg* dlg = CWmDetailsDlg::NewL(
  1454         CWmDetailsDlg* dlg = CWmDetailsDlg::NewL(
  1355                 data->Name(), data->Description(), 
  1455                 data->Name(), 
  1356                 data->HsContentInfo().CanBeAdded(),
  1456                 data->Description(), 
       
  1457                 !hsFull,
  1357                 logo, mask );
  1458                 logo, mask );
  1358 
  1459 
  1359         if ( dlg && dlg->ExecuteLD() == ECbaAddToHs )
  1460         if ( dlg && dlg->ExecuteLD() == ECbaAddToHs )
  1360             {
  1461             {
  1361             AddWidgetToHomeScreenL();
  1462             AddWidgetToHomeScreenL();
  1464 CWmListBox& CWmMainContainer::WmListBox()
  1565 CWmListBox& CWmMainContainer::WmListBox()
  1465     {
  1566     {
  1466     return *iWidgetsList;
  1567     return *iWidgetsList;
  1467     }
  1568     }
  1468 
  1569 
       
  1570 // ----------------------------------------------------
       
  1571 // CWmMainContainer::FocusChanged
       
  1572 // ----------------------------------------------------
       
  1573 //
       
  1574 void CWmMainContainer::FocusChanged( TDrawNow aDrawNow )
       
  1575     {
       
  1576     CCoeControl::FocusChanged( aDrawNow );
       
  1577 
       
  1578     if ( iFindbox && iFindPaneIsVisible && 
       
  1579         !iFindbox->IsFocused() && IsFocused() )
       
  1580         {
       
  1581         // reset focus to find pane if its lost ( ou1cimx1#308019 )
       
  1582         ResetFocus();
       
  1583         iFindbox->SetFocus( ETrue );
       
  1584         UpdateFocusMode();
       
  1585         }
       
  1586     }
       
  1587 
       
  1588 
  1469 // End of File
  1589 // End of File
  1470 
  1590