ui/viewmanagement/viewmanager/src/glxmenumanager.cpp
changeset 55 fb37077c270f
parent 49 f291796e213d
--- a/ui/viewmanagement/viewmanager/src/glxmenumanager.cpp	Tue Jul 06 14:16:16 2010 +0300
+++ b/ui/viewmanagement/viewmanager/src/glxmenumanager.cpp	Wed Aug 18 09:48:53 2010 +0300
@@ -28,6 +28,7 @@
 #include "glxcommandhandlers.hrh"
 #include "glxmodelparm.h"
 #include "glxlocalisationstrings.h"
+#include "glxsettinginterface.h"
 
 
 GlxMenuManager::GlxMenuManager(HbMainWindow* mainWindow)
@@ -35,6 +36,7 @@
       mMainWindow( mainWindow ),
       mContextMenu( 0 )
 {
+    mSettings = GlxSettingInterface::instance();
 }
 
 GlxMenuManager::~GlxMenuManager()
@@ -71,10 +73,14 @@
 
 void GlxMenuManager::addMenu(qint32 viewId, HbMenu* menu)
 {
+    int curState = viewSubState();
+    if( curState == FETCHER_ITEM_S || curState == FETCHER_S || curState == FETCHER_ALBUM_S ||  curState == IMAGEVIEWER_S)
+        return;
+    
     switch(viewId) {
     case GLX_GRIDVIEW_ID:
+        CreateGridMenu( menu );
         connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateGridMenu() ) );
-        CreateGridMenu( menu );
         break;                            
 
     case GLX_LISTVIEW_ID: 
@@ -82,9 +88,13 @@
         break;
         
     case GLX_FULLSCREENVIEW_ID:
+        CreateFullscreenMenu( menu );
         connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateFullscreenMenu() ) );
-        CreateFullscreenMenu( menu );
         break;
+        
+    case GLX_SLIDESHOWVIEW_ID :
+        createSlideShowMenu( menu );
+        break ;
                 
     default:
         break;
@@ -145,6 +155,22 @@
     action->setData(EGlxCmdDelete);
     action->setObjectName( "GridMenu Delete" );
     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+    
+    m3DEffectSubMenu = menu->addMenu(GLX_GRID_OPT_EFFECT);
+    m3DEffectSubMenu->setObjectName( "GridMenu 3DEffect" );
+    
+    action = m3DEffectSubMenu->addAction(GLX_GRID_OPT_ON); 
+    action->setCheckable(ETrue);
+    action->setData(EGlxCmd3DEffectOn);
+    action->setObjectName( "GridMenu 3DOn" );
+    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+    
+    action = m3DEffectSubMenu->addAction(GLX_GRID_OPT_OFF);
+    action->setCheckable(ETrue);
+    action->setData(EGlxCmd3DEffectOff);
+    action->setObjectName( "GridMenu 3DOff" );
+    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
+
 }
 
 void GlxMenuManager::CreateListMenu(HbMenu* menu)
@@ -186,15 +212,21 @@
 	CFeatureDiscovery* featManager = CFeatureDiscovery::NewL();
     if(featManager->IsFeatureSupportedL(KFeatureIdFfImageEditor))
         {
-		mSubMenu = menu->addMenu(QString("Rotate"));
-		action = mSubMenu->addAction(QString("90 CW")); 
+        mUseImgSubMenu = menu->addMenu(GLX_MENU_USE_IMAGE);
+        action = mUseImgSubMenu->addAction(GLX_MENU_SET_WALLPAPER); 
+        action->setData(EGlxCmdSetWallpaper);
+        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
+        
+            
+        mRotateSubMenu = menu->addMenu(GLX_MENU_ROTATE);
+		action = mRotateSubMenu->addAction(GLX_MENU_90_CW); 
 		action->setData(EGlxCmdRotateImgCW);
 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
-		action = mSubMenu->addAction(QString("90 CCW"));
+		action = mRotateSubMenu->addAction(GLX_MENU_90_CCW);
 		action->setData(EGlxCmdRotateImgCCW);
 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
 		
-		action = menu->addAction(QString("Crop"));
+		action = menu->addAction(GLX_MENU_CROP);
 		action->setData(EGlxCmdRotateImgCrop);
 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));   
         }
@@ -205,6 +237,21 @@
     action->setData(EGlxCmdAddToAlbum);
     action->setObjectName( "FSMenu AddToAlbum" );
     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+	action = menu->addAction( GLX_OPTION_REMOVE_FROM_ALBUM );
+	action->setData( EGlxCmdRemoveFrom );
+	action->setObjectName( "FSMenu RemoveAlbum" );
+	connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
+}
+
+void GlxMenuManager::createSlideShowMenu( HbMenu* menu )
+{
+    HbAction *action = NULL;
+    menu->setObjectName( "SSMenu" );
+    
+    action = menu->addAction( GLX_OPTION_SS_SETTINGS );
+    action->setData( EGlxCmdSlideshowSettings );
+    action->setObjectName( "SSMenu Setting" );
+    connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) ); 
 }
 
 void GlxMenuManager::setAllActionVisibility( QList<QAction*> actionList, bool visible )
@@ -217,9 +264,11 @@
 
 int GlxMenuManager::viewSubState()
 {
-    QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );    
-    if ( variant.isValid() &&  variant.canConvert<int> () ) {
-        return variant.value<int>() ;
+    if(mModel){
+        QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );
+        if ( variant.isValid() &&  variant.canConvert<int> () ) {
+            return variant.value<int>() ;
+        }
     }
     return -1;
 }
@@ -257,6 +306,26 @@
             actionList.at(GlxGridViewRemoveFromAlbum)->setVisible( FALSE );
             break ;
         }       
+        
+        if(mMainWindow->orientation() == Qt::Horizontal)
+            {
+            actionList.at(GlxGridView3DEffect)->setVisible( TRUE );
+            QList<QAction*> subActionList = m3DEffectSubMenu->actions();
+            if(mSettings->mediaWall3DEffect())
+                {
+                subActionList.at(0)->setChecked(ETrue);
+                subActionList.at(1)->setChecked(EFalse);
+                }
+            else
+                {
+                subActionList.at(0)->setChecked(EFalse);
+                subActionList.at(1)->setChecked(ETrue);
+                }
+            }
+        else
+            {
+            actionList.at(GlxGridView3DEffect)->setVisible( FALSE );
+            }
     }    
 }
 
@@ -276,6 +345,34 @@
         setAllActionVisibility( actionList, TRUE );
         isAllActionDisable = FALSE;
     }    
+    
+
+
+#ifndef __WINSCW__
+    if ( state != IMAGEVIEWER_S)
+        {
+        int frameCount = (mModel->data(mModel->index((
+                mModel->data(mModel->index(0, 0),GlxFocusIndexRole)).value<int> (), 0),
+                        GlxFrameCount)).value<int>();
+        bool setVisible = true;
+        if (frameCount > 1) 
+            {
+            //Check for animated image, if found hide editor specific menu
+            setVisible = false;
+            }
+		//If Use Image contains any sub menu item other then related to Editor
+		//then individual sub menu item needs to be hidden rather then
+		//complete "Use Image"menu
+        actionList[GlxFullScreenViewUseImage]->setVisible(setVisible);
+        actionList[GlxFullScreenViewMenuRotate]->setVisible(setVisible);
+        actionList[GlxFullScreenViewCrop]->setVisible(setVisible);
+        }
+#endif    
+	if( state != ALBUM_FULLSCREEN_S ){
+		actionList[GlxFullScreenViewRemoveoAlbum]->setVisible(false);
+	}else{
+		actionList[GlxFullScreenViewRemoveoAlbum]->setVisible(true);
+	}
 }
 
 void GlxMenuManager::menuItemSelected()
@@ -292,62 +389,87 @@
     mContextMenu = new HbMenu();
     mContextMenu->setObjectName( "ContextMenu" );
     HbAction *action = NULL;
-
     switch ( viewId ) {
 	    case GLX_GRIDVIEW_ID :
-	        action = mContextMenu->addAction(GLX_MENU_SHARE);
-	        action->setData(EGlxCmdContextSend);
+			if ( viewSubState() == FETCHER_ITEM_S || viewSubState() == FETCHER_ALBUM_ITEM_S) {        
+                action = mContextMenu->addAction( GLX_MENU_OPEN );
+                action->setData( EGlxCmdFetcherFullScreenOpen );
+                action->setObjectName( "CM Open1" );
+                connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
+				break;
+	        }
+			
+	        action = mContextMenu->addAction( GLX_MENU_OPEN );
+            action->setData( EGlxCmdFullScreenOpen );
+            action->setObjectName( "CM Open" );
+            connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );	        
+	        
+            action = mContextMenu->addAction( GLX_MENU_SHARE );
+	        action->setData( EGlxCmdContextSend );
 	        action->setObjectName( "CM Send" );
-	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+	        connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
 	        
-	        action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
-	        action->setData(EGlxCmdSelectSlideshow);
+	        action = mContextMenu->addAction( GLX_MENU_SLIDESHOW );
+	        action->setData( EGlxCmdSelectSlideshow );
 	        action->setObjectName( "CM SlideShow" );
-	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+	        connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
 
+	        action = mContextMenu->addAction( GLX_MENU_ADD_TO_ALBUM );
+		    action->setData( EGlxCmdContextAddToAlbum );
+		    action->setObjectName( "CM AddToAlbum" );
+		    connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
+		    
 	        if ( viewSubState() == ALBUM_ITEM_S ) {        
-                action = mContextMenu->addAction(GLX_OPTION_REMOVE_FROM_ALBUM);
-                action->setData(EGlxCmdContextRemoveFrom);
+                action = mContextMenu->addAction( GLX_OPTION_REMOVE_FROM_ALBUM );
+                action->setData( EGlxCmdContextRemoveFrom );
                 action->setObjectName( "CM RemoveAlbum" );
-                connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+                connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
 	        }
 	        
-	        action = mContextMenu->addAction(GLX_MENU_ADD_TO_ALBUM);
-		    action->setData(EGlxCmdContextAddToAlbum);
-		    action->setObjectName( "CM AddToAlbum" );
-		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
-		    
-		    action = mContextMenu->addAction(GLX_MENU_DELETE);
-		    action->setData(EGlxCmdContextDelete);
+		    action = mContextMenu->addAction( GLX_MENU_DELETE );
+		    action->setData( EGlxCmdContextDelete );
 		    action->setObjectName( "CM Delete" );
-		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+		    connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
 			break;
 	    	
 	    case GLX_LISTVIEW_ID : {
+            if ( viewSubState() == FETCHER_ALBUM_S ) {        
+                action = mContextMenu->addAction( GLX_MENU_OPEN );
+                action->setData( EGlxCmdFetcherAlbumGridOpen );
+                action->setObjectName( "CM Open1" );
+                connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
+                break;
+            }
+	    
 	        int count = 0;
             QVariant variant = mModel->data( mModel->index(0,0), GlxListItemCount );    
 	        if ( variant.isValid() &&  variant.canConvert<int> () ) {
 	            count = variant.value<int>();  
-	        }  
+	        }
+	        
+	        action = mContextMenu->addAction( GLX_MENU_OPEN );
+            action->setData( EGlxCmdAlbumGridOpen );
+            action->setObjectName( "CM Album Open" );
+            connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
 
 	        if ( count ) {
-                action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
-                action->setData(EGlxCmdAlbumSlideShow);
+                action = mContextMenu->addAction( GLX_MENU_SLIDESHOW );
+                action->setData( EGlxCmdAlbumSlideShow );
                 action->setObjectName( "CM Album SlideShow" );
-                connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+                connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
 	        }
 	        
 	        variant = mModel->data( mModel->index(0,0), GlxSystemItemRole );    
             if ( variant.isValid() &&  variant.canConvert<bool> () && ( variant.value<bool>() == false ) ) {           
-                action = mContextMenu->addAction(GLX_MENU_RENAME);
-                action->setData(EGlxCmdContextRename);
+                action = mContextMenu->addAction( GLX_MENU_RENAME );
+                action->setData( EGlxCmdContextRename );
                 action->setObjectName( "CM Rename" );
-                connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+                connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
                             
-                action = mContextMenu->addAction(GLX_MENU_DELETE);
-                action->setData(EGlxCmdContextAlbumDelete);
+                action = mContextMenu->addAction( GLX_MENU_DELETE );
+                action->setData( EGlxCmdContextAlbumDelete );
                 action->setObjectName( "CM Album Delete" );
-                connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
+                connect( action, SIGNAL( triggered() ), this, SLOT( menuItemSelected() ) );
             }
 	    }
 			break;