idlehomescreen/widgetmanager/src/wmmaincontainer.cpp
changeset 5 c743ef5928ba
parent 4 4d54b72983ae
child 9 f966699dea19
child 20 636d517f67e6
equal deleted inserted replaced
4:4d54b72983ae 5:c743ef5928ba
    63 #include "wmpersistentwidgetorder.h"
    63 #include "wmpersistentwidgetorder.h"
    64 #include "wmdetailsdlg.h"
    64 #include "wmdetailsdlg.h"
    65 #include "wmportalbutton.h"
    65 #include "wmportalbutton.h"
    66 #include "wmwidgetloaderao.h"
    66 #include "wmwidgetloaderao.h"
    67 #include "wmconfiguration.h"
    67 #include "wmconfiguration.h"
       
    68 #include "wminstaller.h"
    68 
    69 
    69 // CONSTANTS
    70 // CONSTANTS
    70 const TInt KTextLimit = 40; // Text-limit for find-field
    71 const TInt KTextLimit = 40; // Text-limit for find-field
    71 const TInt KMinWidgets = 1; // minimum number of widgets to show findpane
    72 const TInt KMinWidgets = 1; // minimum number of widgets to show findpane
    72 
    73 
   211 	    AknLayoutUtils::LayoutControl( iPortalButtonOne, rect, btnPane );
   212 	    AknLayoutUtils::LayoutControl( iPortalButtonOne, rect, btnPane );
   212 	    }
   213 	    }
   213 	else
   214 	else
   214 	    {
   215 	    {
   215 	    // two buttons
   216 	    // two buttons
   216         // **********************************
   217         TInt variety = (iLandscape ? 3 : 2);
   217         // we do not have layouts for two buttons yet - layout manually
   218         TAknWindowLineLayout oviBtnLayout = AknLayoutScalable_Apps
   218         TAknWindowLineLayout btnPane = AknLayoutScalable_Apps
   219                 ::wgtman_btn_pane( variety ).LayoutLine();
   219             ::wgtman_btn_pane( iLandscape ? 1 : 0 ).LayoutLine();
   220         TAknWindowLineLayout operatorBtnLayout = AknLayoutScalable_Apps
   220 	    TAknLayoutRect layoutrect;
   221                 ::wgtman_btn_pane_cp_01( variety ).LayoutLine();
   221 	    layoutrect.LayoutRect( rect, btnPane );
   222         AknLayoutUtils::LayoutControl( iPortalButtonOne, rect, oviBtnLayout );
   222 	    TRect r( layoutrect.Rect() );
   223         AknLayoutUtils::LayoutControl( iPortalButtonTwo, rect, operatorBtnLayout );
   223 	    TRect r1, r2;
       
   224 	    const TInt gap = 3;
       
   225 	    if ( iLandscape )
       
   226 	        {
       
   227 	        r1 = TRect( r.iTl, TSize( r.Width(), r.Height() / 2 - gap ) );
       
   228 	        r2 = r1;
       
   229             r2.Move( 0, r.Height() / 2 + gap );
       
   230 	        }
       
   231 	    else
       
   232 	        {
       
   233             r1 = TRect( r.iTl, TSize( r.Width() / 2 - gap, r.Height() ) );
       
   234             r2 = r1;
       
   235             if (iMirrored) r1.Move( r.Width() / 2 + gap, 0 );
       
   236             else r2.Move( r.Width() / 2 + gap, 0 );
       
   237             }
       
   238         iPortalButtonOne->SetRect( r1 );
       
   239         iPortalButtonTwo->SetRect( r2 );
       
   240         // *************************************
       
   241 	    }
   224 	    }
   242     
   225     
   243 	// layout iWidgetsList
   226 	// layout iWidgetsList
   244     TAknWindowLineLayout listPane = AknLayoutScalable_Apps
   227     TAknWindowLineLayout listPane = AknLayoutScalable_Apps
   245         ::listscroll_wgtman_pane( iLandscape ? 1 : 0 ).LayoutLine();
   228         ::listscroll_wgtman_pane( iLandscape ? 1 : 0 ).LayoutLine();
   925 //
   908 //
   926 TBool CWmMainContainer::CanDoAdd()
   909 TBool CWmMainContainer::CanDoAdd()
   927     {
   910     {
   928     TBool retVal = EFalse;
   911     TBool retVal = EFalse;
   929     CWmWidgetData* data = iWidgetsList->WidgetData();
   912     CWmWidgetData* data = iWidgetsList->WidgetData();
   930     if ( WidgetSelected() && data )
   913     if ( WidgetSelected() && data && !data->IsUninstalling() )
   931         {
   914         {
   932         if ( data->HsContentInfo().CanBeAdded() )
   915         if ( data->HsContentInfo().CanBeAdded() )
   933             retVal = ETrue;
   916             retVal = ETrue;
   934         }
   917         }
   935     return retVal;
   918     return retVal;
   941 //
   924 //
   942 TBool CWmMainContainer::CanDoUninstall() 
   925 TBool CWmMainContainer::CanDoUninstall() 
   943     {
   926     {
   944     TBool retVal( EFalse );
   927     TBool retVal( EFalse );
   945     CWmWidgetData* data = iWidgetsList->WidgetData();
   928     CWmWidgetData* data = iWidgetsList->WidgetData();
   946     if ( WidgetSelected() && data )
   929     if ( WidgetSelected() && data && !data->IsUninstalling() )
   947         {
   930         {
   948         if ( data->WidgetType() == CWmWidgetData::ECps &&
   931         if ( data->WidgetType() == CWmWidgetData::ECps &&
   949                 data->PublisherUid() != KNullUid )
   932                 data->PublisherUid() != KNullUid )
   950             {
   933             {
   951             retVal = ETrue;
   934             retVal = ETrue;
   959 // ---------------------------------------------------------
   942 // ---------------------------------------------------------
   960 //
   943 //
   961 TBool CWmMainContainer::CanDoLaunch() 
   944 TBool CWmMainContainer::CanDoLaunch() 
   962     {
   945     {
   963     TBool retVal(EFalse);
   946     TBool retVal(EFalse);
       
   947     
   964     if ( WidgetSelected() )
   948     if ( WidgetSelected() )
   965         {
   949         {
   966         CWmWidgetData* data = iWidgetsList->WidgetData();        
   950         CWmWidgetData* data = iWidgetsList->WidgetData();
   967         if ( data && data->WidgetType() == CWmWidgetData::ECps &&
   951         if ( data && !data->IsUninstalling() )
   968             data->PublisherUid() != KNullUid )
   952             {
   969             {
   953             if ( data->WidgetType() == CWmWidgetData::ECps &&
   970             retVal = ETrue;
   954                 data->PublisherUid() != KNullUid )
       
   955                 {
       
   956                 retVal = ETrue;
       
   957                 }
   971             }
   958             }
   972         }
   959         }
   973     return retVal;
   960     return retVal;
   974     }
   961     }
   975 
   962 
  1000 // CWmMainContainer::CanDoDetails
   987 // CWmMainContainer::CanDoDetails
  1001 // ---------------------------------------------------------
   988 // ---------------------------------------------------------
  1002 //
   989 //
  1003 TBool CWmMainContainer::CanDoDetails()
   990 TBool CWmMainContainer::CanDoDetails()
  1004     {
   991     {
  1005     return ( WidgetSelected() && iWidgetsList->WidgetData() );
   992     return ( WidgetSelected() && iWidgetsList->WidgetData() 
       
   993             && !iWidgetsList->WidgetData()->IsUninstalling() );
  1006     }
   994     }
  1007 
   995 
  1008 // ---------------------------------------------------------
   996 // ---------------------------------------------------------
  1009 // CWmMainContainer::CanDoHelp
   997 // CWmMainContainer::CanDoHelp
  1010 // ---------------------------------------------------------
   998 // ---------------------------------------------------------
  1019 // ---------------------------------------------------------------------------
  1007 // ---------------------------------------------------------------------------
  1020 //
  1008 //
  1021 void CWmMainContainer::AddWidgetToHomeScreenL()
  1009 void CWmMainContainer::AddWidgetToHomeScreenL()
  1022     {
  1010     {
  1023     CWmWidgetData* data = iWidgetsList->WidgetData();
  1011     CWmWidgetData* data = iWidgetsList->WidgetData();
  1024     if ( !iClosingDown && data )
  1012     if ( !iClosingDown && data && !data->IsUninstalling() )
  1025         {
  1013         {
  1026         if ( iFindbox && iFindPaneIsVisible )
  1014         if ( iFindbox && iFindPaneIsVisible )
  1027             {
  1015             {
  1028             DeactivateFindPaneL();
  1016             DeactivateFindPaneL();
  1029             }
  1017             }
  1198 //
  1186 //
  1199 void CWmMainContainer::UninstallWidgetL()
  1187 void CWmMainContainer::UninstallWidgetL()
  1200     {
  1188     {
  1201     if ( CanDoUninstall() )
  1189     if ( CanDoUninstall() )
  1202         {
  1190         {
  1203         iWidgetsList->WidgetData()->UnInstallL();
  1191         CWmWidgetData* data = iWidgetsList->WidgetData();
       
  1192         if ( data )
       
  1193             {
       
  1194             if ( iWmPlugin.ResourceLoader().QueryPopupL( 
       
  1195                     R_QTN_WM_UNINSTALL_WIDGET_QUERY, data->Name() ) )
       
  1196                 {
       
  1197                 
       
  1198                 TRAPD( err, iWmPlugin.WmInstaller().UninstallL( data ) );
       
  1199                 if ( err != KErrNone )
       
  1200                     {
       
  1201                     iWmPlugin.ResourceLoader().InfoPopupL( 
       
  1202                             R_QTN_WM_UNINST_PROCESS_BUSY, KNullDesC );
       
  1203                     }
       
  1204                 }
       
  1205             }
  1204         }
  1206         }
  1205     }
  1207     }
  1206 
  1208 
  1207 // ---------------------------------------------------------------------------
  1209 // ---------------------------------------------------------------------------
  1208 // CWmMainContainer::OpenPortalL
  1210 // CWmMainContainer::OpenPortalL
  1281 // ---------------------------------------------------------------------------
  1283 // ---------------------------------------------------------------------------
  1282 //
  1284 //
  1283 void CWmMainContainer::HandleListBoxEventL(
  1285 void CWmMainContainer::HandleListBoxEventL(
  1284         CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
  1286         CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
  1285     {
  1287     {
  1286     if ( aEventType == EEventEnterKeyPressed ||
  1288     if ( ( aEventType == EEventEnterKeyPressed ||
  1287         aEventType == EEventItemSingleClicked )
  1289            aEventType == EEventItemSingleClicked ) 
  1288         {
  1290            && !iClosingDown )    
  1289         if ( iFindPaneIsVisible )
  1291         {
  1290             {
  1292         AddWidgetToHomeScreenL();
  1291             DeactivateFindPaneL();
       
  1292             }
       
  1293         else if ( !iClosingDown )
       
  1294             {
       
  1295             AddWidgetToHomeScreenL();
       
  1296             }
       
  1297         }
  1293         }
  1298     }
  1294     }
  1299 
  1295 
  1300 // ----------------------------------------------------
  1296 // ----------------------------------------------------
  1301 // CWmMainContainer::LaunchDetailsDialogL
  1297 // CWmMainContainer::LaunchDetailsDialogL
  1312                     data->LogoImageMask() : iWidgetsList->DefaultMask();
  1308                     data->LogoImageMask() : iWidgetsList->DefaultMask();
  1313         
  1309         
  1314         CWmDetailsDlg* dlg = CWmDetailsDlg::NewL(
  1310         CWmDetailsDlg* dlg = CWmDetailsDlg::NewL(
  1315                 data->Name(), data->Description(), 
  1311                 data->Name(), data->Description(), 
  1316                 data->HsContentInfo().CanBeAdded(),
  1312                 data->HsContentInfo().CanBeAdded(),
  1317                 logo, mask, iBgContext );
  1313                 logo, mask );
  1318 
  1314 
  1319         if ( dlg && dlg->ExecuteLD() == ECbaAddToHs )
  1315         if ( dlg && dlg->ExecuteLD() == ECbaAddToHs )
  1320             {
  1316             {
  1321             AddWidgetToHomeScreenL();
  1317             AddWidgetToHomeScreenL();
  1322             }
  1318             }