ui/viewmanagement/viewmanager/src/glxmenumanager.cpp
changeset 54 0f0f3f26f787
parent 50 a0f57508af73
child 71 27f2d7aec52a
equal deleted inserted replaced
52:a3a4c0de738e 54:0f0f3f26f787
    71      }
    71      }
    72 }
    72 }
    73 
    73 
    74 void GlxMenuManager::addMenu(qint32 viewId, HbMenu* menu)
    74 void GlxMenuManager::addMenu(qint32 viewId, HbMenu* menu)
    75 {
    75 {
       
    76     int curState = viewSubState();
       
    77     if( curState == FETCHER_ITEM_S || curState == FETCHER_S || curState == FETCHER_ALBUM_S ||  curState == IMAGEVIEWER_S)
       
    78         return;
       
    79     
    76     switch(viewId) {
    80     switch(viewId) {
    77     case GLX_GRIDVIEW_ID:
    81     case GLX_GRIDVIEW_ID:
    78         CreateGridMenu( menu );
    82         CreateGridMenu( menu );
    79         connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateGridMenu() ) );
    83         connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateGridMenu() ) );
    80         break;                            
    84         break;                            
   150     action = menu->addAction(GLX_OPTION_DELETE);
   154     action = menu->addAction(GLX_OPTION_DELETE);
   151     action->setData(EGlxCmdDelete);
   155     action->setData(EGlxCmdDelete);
   152     action->setObjectName( "GridMenu Delete" );
   156     action->setObjectName( "GridMenu Delete" );
   153     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   157     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   154     
   158     
   155     m3DEffectSubMenu = menu->addMenu("3D Effect");
   159     m3DEffectSubMenu = menu->addMenu(GLX_GRID_OPT_EFFECT);
   156     m3DEffectSubMenu->setObjectName( "GridMenu 3DEffect" );
   160     m3DEffectSubMenu->setObjectName( "GridMenu 3DEffect" );
   157     
   161     
   158     action = m3DEffectSubMenu->addAction("On"); 
   162     action = m3DEffectSubMenu->addAction(GLX_GRID_OPT_ON); 
   159     action->setCheckable(ETrue);
   163     action->setCheckable(ETrue);
   160     action->setData(EGlxCmd3DEffectOn);
   164     action->setData(EGlxCmd3DEffectOn);
   161     action->setObjectName( "GridMenu 3DOn" );
   165     action->setObjectName( "GridMenu 3DOn" );
   162     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   166     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   163     
   167     
   164     action = m3DEffectSubMenu->addAction("Off");
   168     action = m3DEffectSubMenu->addAction(GLX_GRID_OPT_OFF);
   165     action->setCheckable(ETrue);
   169     action->setCheckable(ETrue);
   166     action->setData(EGlxCmd3DEffectOff);
   170     action->setData(EGlxCmd3DEffectOff);
   167     action->setObjectName( "GridMenu 3DOff" );
   171     action->setObjectName( "GridMenu 3DOff" );
   168     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
   172     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
   169 
   173 
   206     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   210     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   207 #ifndef __WINSCW__
   211 #ifndef __WINSCW__
   208 	CFeatureDiscovery* featManager = CFeatureDiscovery::NewL();
   212 	CFeatureDiscovery* featManager = CFeatureDiscovery::NewL();
   209     if(featManager->IsFeatureSupportedL(KFeatureIdFfImageEditor))
   213     if(featManager->IsFeatureSupportedL(KFeatureIdFfImageEditor))
   210         {
   214         {
   211         mSubMenu = menu->addMenu(GLX_MENU_USE_IMAGE);
   215         mUseImgSubMenu = menu->addMenu(GLX_MENU_USE_IMAGE);
   212         action = mSubMenu->addAction(GLX_MENU_SET_WALLPAPER); 
   216         action = mUseImgSubMenu->addAction(GLX_MENU_SET_WALLPAPER); 
   213         action->setData(EGlxCmdSetWallpaper);
   217         action->setData(EGlxCmdSetWallpaper);
   214         connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
   218         connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
   215         
   219         
   216             
   220             
   217 		mSubMenu = menu->addMenu(GLX_MENU_ROTATE);
   221         mRotateSubMenu = menu->addMenu(GLX_MENU_ROTATE);
   218 		action = mSubMenu->addAction(GLX_MENU_90_CW); 
   222 		action = mRotateSubMenu->addAction(GLX_MENU_90_CW); 
   219 		action->setData(EGlxCmdRotateImgCW);
   223 		action->setData(EGlxCmdRotateImgCW);
   220 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
   224 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
   221 		action = mSubMenu->addAction(GLX_MENU_90_CCW);
   225 		action = mRotateSubMenu->addAction(GLX_MENU_90_CCW);
   222 		action->setData(EGlxCmdRotateImgCCW);
   226 		action->setData(EGlxCmdRotateImgCCW);
   223 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   227 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   224 		
   228 		
   225 		action = menu->addAction(GLX_MENU_CROP);
   229 		action = menu->addAction(GLX_MENU_CROP);
   226 		action->setData(EGlxCmdRotateImgCrop);
   230 		action->setData(EGlxCmdRotateImgCrop);
   231     
   235     
   232     action = menu->addAction(GLX_OPTION_ADD_TO_ALBUM);
   236     action = menu->addAction(GLX_OPTION_ADD_TO_ALBUM);
   233     action->setData(EGlxCmdAddToAlbum);
   237     action->setData(EGlxCmdAddToAlbum);
   234     action->setObjectName( "FSMenu AddToAlbum" );
   238     action->setObjectName( "FSMenu AddToAlbum" );
   235     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   239     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   240 	action = menu->addAction( GLX_OPTION_REMOVE_FROM_ALBUM );
       
   241 	action->setData( EGlxCmdRemoveFrom );
       
   242 	action->setObjectName( "FSMenu RemoveAlbum" );
       
   243 	connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
   236 }
   244 }
   237 
   245 
   238 void GlxMenuManager::createSlideShowMenu( HbMenu* menu )
   246 void GlxMenuManager::createSlideShowMenu( HbMenu* menu )
   239 {
   247 {
   240     HbAction *action = NULL;
   248     HbAction *action = NULL;
   254     }
   262     }
   255 }
   263 }
   256 
   264 
   257 int GlxMenuManager::viewSubState()
   265 int GlxMenuManager::viewSubState()
   258 {
   266 {
   259     QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );    
   267     if(mModel){
   260     if ( variant.isValid() &&  variant.canConvert<int> () ) {
   268         QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );
   261         return variant.value<int>() ;
   269         if ( variant.isValid() &&  variant.canConvert<int> () ) {
       
   270             return variant.value<int>() ;
       
   271         }
   262     }
   272     }
   263     return -1;
   273     return -1;
   264 }
   274 }
   265 
   275 
   266 void GlxMenuManager::updateGridMenu()
   276 void GlxMenuManager::updateGridMenu()
   333   
   343   
   334     if ( state != IMAGEVIEWER_S &&  isAllActionDisable == TRUE ) {
   344     if ( state != IMAGEVIEWER_S &&  isAllActionDisable == TRUE ) {
   335         setAllActionVisibility( actionList, TRUE );
   345         setAllActionVisibility( actionList, TRUE );
   336         isAllActionDisable = FALSE;
   346         isAllActionDisable = FALSE;
   337     }    
   347     }    
       
   348     
       
   349 
       
   350 
       
   351 #ifndef __WINSCW__
       
   352     if ( state != IMAGEVIEWER_S)
       
   353         {
       
   354         int frameCount = (mModel->data(mModel->index((
       
   355                 mModel->data(mModel->index(0, 0),GlxFocusIndexRole)).value<int> (), 0),
       
   356                         GlxFrameCount)).value<int>();
       
   357         bool setVisible = true;
       
   358         if (frameCount > 1) 
       
   359             {
       
   360             //Check for animated image, if found hide editor specific menu
       
   361             setVisible = false;
       
   362             }
       
   363 		//If Use Image contains any sub menu item other then related to Editor
       
   364 		//then individual sub menu item needs to be hidden rather then
       
   365 		//complete "Use Image"menu
       
   366         actionList[GlxFullScreenViewUseImage]->setVisible(setVisible);
       
   367         actionList[GlxFullScreenViewMenuRotate]->setVisible(setVisible);
       
   368         actionList[GlxFullScreenViewCrop]->setVisible(setVisible);
       
   369         }
       
   370 #endif    
       
   371 	if( state != ALBUM_FULLSCREEN_S ){
       
   372 		actionList[GlxFullScreenViewRemoveoAlbum]->setVisible(false);
       
   373 	}else{
       
   374 		actionList[GlxFullScreenViewRemoveoAlbum]->setVisible(true);
       
   375 	}
   338 }
   376 }
   339 
   377 
   340 void GlxMenuManager::menuItemSelected()
   378 void GlxMenuManager::menuItemSelected()
   341 {
   379 {
   342     HbAction *action = qobject_cast<HbAction*>(sender());
   380     HbAction *action = qobject_cast<HbAction*>(sender());
   349 {
   387 {
   350     qDebug("GlxMenuManager::showContextMenu " );
   388     qDebug("GlxMenuManager::showContextMenu " );
   351     mContextMenu = new HbMenu();
   389     mContextMenu = new HbMenu();
   352     mContextMenu->setObjectName( "ContextMenu" );
   390     mContextMenu->setObjectName( "ContextMenu" );
   353     HbAction *action = NULL;
   391     HbAction *action = NULL;
   354 
       
   355     switch ( viewId ) {
   392     switch ( viewId ) {
   356 	    case GLX_GRIDVIEW_ID :
   393 	    case GLX_GRIDVIEW_ID :
       
   394 			if ( viewSubState() == FETCHER_ITEM_S || viewSubState() == FETCHER_ALBUM_ITEM_S) {        
       
   395                 action = mContextMenu->addAction( GLX_MENU_OPEN );
       
   396                 action->setData( EGlxCmdFetcherFullScreenOpen );
       
   397                 action->setObjectName( "CM Open1" );
       
   398                 connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
       
   399 				break;
       
   400 	        }
       
   401 			
   357 	        action = mContextMenu->addAction( GLX_MENU_OPEN );
   402 	        action = mContextMenu->addAction( GLX_MENU_OPEN );
   358             action->setData( EGlxCmdFullScreenOpen );
   403             action->setData( EGlxCmdFullScreenOpen );
   359             action->setObjectName( "CM Open" );
   404             action->setObjectName( "CM Open" );
   360             connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );	        
   405             connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );	        
   361 	        
   406 	        
   367 	        action = mContextMenu->addAction( GLX_MENU_SLIDESHOW );
   412 	        action = mContextMenu->addAction( GLX_MENU_SLIDESHOW );
   368 	        action->setData( EGlxCmdSelectSlideshow );
   413 	        action->setData( EGlxCmdSelectSlideshow );
   369 	        action->setObjectName( "CM SlideShow" );
   414 	        action->setObjectName( "CM SlideShow" );
   370 	        connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
   415 	        connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
   371 
   416 
       
   417 	        action = mContextMenu->addAction( GLX_MENU_ADD_TO_ALBUM );
       
   418 		    action->setData( EGlxCmdContextAddToAlbum );
       
   419 		    action->setObjectName( "CM AddToAlbum" );
       
   420 		    connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
       
   421 		    
   372 	        if ( viewSubState() == ALBUM_ITEM_S ) {        
   422 	        if ( viewSubState() == ALBUM_ITEM_S ) {        
   373                 action = mContextMenu->addAction( GLX_OPTION_REMOVE_FROM_ALBUM );
   423                 action = mContextMenu->addAction( GLX_OPTION_REMOVE_FROM_ALBUM );
   374                 action->setData( EGlxCmdContextRemoveFrom );
   424                 action->setData( EGlxCmdContextRemoveFrom );
   375                 action->setObjectName( "CM RemoveAlbum" );
   425                 action->setObjectName( "CM RemoveAlbum" );
   376                 connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
   426                 connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
   377 	        }
   427 	        }
   378 	        
   428 	        
   379 	        action = mContextMenu->addAction( GLX_MENU_ADD_TO_ALBUM );
       
   380 		    action->setData( EGlxCmdContextAddToAlbum );
       
   381 		    action->setObjectName( "CM AddToAlbum" );
       
   382 		    connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
       
   383 		    
       
   384 		    action = mContextMenu->addAction( GLX_MENU_DELETE );
   429 		    action = mContextMenu->addAction( GLX_MENU_DELETE );
   385 		    action->setData( EGlxCmdContextDelete );
   430 		    action->setData( EGlxCmdContextDelete );
   386 		    action->setObjectName( "CM Delete" );
   431 		    action->setObjectName( "CM Delete" );
   387 		    connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
   432 		    connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
   388 			break;
   433 			break;
   389 	    	
   434 	    	
   390 	    case GLX_LISTVIEW_ID : {
   435 	    case GLX_LISTVIEW_ID : {
       
   436             if ( viewSubState() == FETCHER_ALBUM_S ) {        
       
   437                 action = mContextMenu->addAction( GLX_MENU_OPEN );
       
   438                 action->setData( EGlxCmdFetcherAlbumGridOpen );
       
   439                 action->setObjectName( "CM Open1" );
       
   440                 connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
       
   441                 break;
       
   442             }
       
   443 	    
   391 	        int count = 0;
   444 	        int count = 0;
   392             QVariant variant = mModel->data( mModel->index(0,0), GlxListItemCount );    
   445             QVariant variant = mModel->data( mModel->index(0,0), GlxListItemCount );    
   393 	        if ( variant.isValid() &&  variant.canConvert<int> () ) {
   446 	        if ( variant.isValid() &&  variant.canConvert<int> () ) {
   394 	            count = variant.value<int>();  
   447 	            count = variant.value<int>();  
   395 	        }
   448 	        }