ui/viewmanagement/viewmanager/src/glxmenumanager.cpp
changeset 49 f291796e213d
parent 29 2c833fc9e98f
child 50 a0f57508af73
child 55 fb37077c270f
equal deleted inserted replaced
48:d0b4e67b3a60 49:f291796e213d
    18 //include
    18 //include
    19 #include <QDebug>
    19 #include <QDebug>
    20 #include <hbaction.h>
    20 #include <hbaction.h>
    21 #include <hbmenu.h>
    21 #include <hbmenu.h>
    22 #include <hbmainwindow.h>
    22 #include <hbmainwindow.h>
    23 
    23 #include <featdiscovery.h>
       
    24 #include <publicruntimeids.hrh>
    24 //user include
    25 //user include
    25 #include "glxviewids.h"
    26 #include "glxviewids.h"
    26 #include "glxmenumanager.h"
    27 #include "glxmenumanager.h"
    27 #include "glxcommandhandlers.hrh"
    28 #include "glxcommandhandlers.hrh"
    28 #include "glxmodelparm.h"
    29 #include "glxmodelparm.h"
    29 #include "glxlocalisationstrings.h"
    30 #include "glxlocalisationstrings.h"
    30 
    31 
    31 
    32 
    32 
       
    33 GlxMenuManager::GlxMenuManager(HbMainWindow* mainWindow)
    33 GlxMenuManager::GlxMenuManager(HbMainWindow* mainWindow)
    34     : mModel( 0),
    34     : mModel( 0),
    35       mMainWindow( mainWindow ),
    35       mMainWindow( mainWindow ),
    36       mContextMenu( 0 )
    36       mContextMenu( 0 )
    37 {
    37 {
    46     qDebug()<< "GlxMenuManager::CreateMarkingModeMenu" ;  
    46     qDebug()<< "GlxMenuManager::CreateMarkingModeMenu" ;  
    47     HbAction *action = NULL;
    47     HbAction *action = NULL;
    48     
    48     
    49     action = menu->addAction(GLX_OPTION_MARK_ALL);
    49     action = menu->addAction(GLX_OPTION_MARK_ALL);
    50     action->setData(EGlxCmdMarkAll);
    50     action->setData(EGlxCmdMarkAll);
       
    51     action->setObjectName( "Menu MarkAll" );
    51     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
    52     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
    52     
    53     
    53     action = menu->addAction(GLX_OPTION_UN_MARK_ALL);
    54     action = menu->addAction(GLX_OPTION_UN_MARK_ALL);
    54     action->setDisabled(true);  //Dim UnMarkAll when no images are marked
    55     action->setDisabled(true);  //Dim UnMarkAll when no images are marked
    55     action->setData(EGlxCmdUnMarkAll);
    56     action->setData(EGlxCmdUnMarkAll);
       
    57     action->setObjectName( "Menu UnMarkAll" );
    56     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));    
    58     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));    
    57 }
    59 }
    58 
    60 
    59 void GlxMenuManager::disableAction(HbMenu* menu, bool disable)
    61 void GlxMenuManager::disableAction(HbMenu* menu, bool disable)
    60 {
    62 {
    61     QList<QAction*> actionList = menu->actions();
    63     QList<QAction*> actionList = menu->actions();
    62     for ( int i = 0 ; i < actionList.count(); i++) {
    64     for ( int i = 0 ; i < actionList.count(); i++) {
    63         if(actionList.at(i)->data()==EGlxCmdUnMarkAll) {
    65         if(actionList.at(i)->data()==EGlxCmdUnMarkAll) {
    64                actionList.at(i)->setDisabled(disable);
    66             actionList.at(i)->setDisabled(disable);
    65                break;
    67             break;
    66         }
    68         }
    67      }
    69      }
    68 }
    70 }
       
    71 
    69 void GlxMenuManager::addMenu(qint32 viewId, HbMenu* menu)
    72 void GlxMenuManager::addMenu(qint32 viewId, HbMenu* menu)
    70 {
    73 {
    71     switch(viewId) {
    74     switch(viewId) {
    72     case GLX_GRIDVIEW_ID:
    75     case GLX_GRIDVIEW_ID:
    73         connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateGridMenu() ) );
    76         connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateGridMenu() ) );
   106 
   109 
   107 void GlxMenuManager::CreateGridMenu(HbMenu* menu)
   110 void GlxMenuManager::CreateGridMenu(HbMenu* menu)
   108 {
   111 {
   109     qDebug()<<"GlxMenuManager::CreateGridMenu";
   112     qDebug()<<"GlxMenuManager::CreateGridMenu";
   110     HbAction *action = NULL;
   113     HbAction *action = NULL;
       
   114     menu->setObjectName( "GridMenu" );
   111     
   115     
   112     action = menu->addAction(GLX_OPTION_SHARE);
   116     action = menu->addAction(GLX_OPTION_SHARE);
   113     action->setData(EGlxCmdSend);
   117     action->setData(EGlxCmdSend);
       
   118     action->setObjectName( "GridMenu Send" );
   114     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   119     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   115    
   120    
   116     mSubMenu = menu->addMenu(GLX_OPTION_SLIDESHOW);
   121     mSubMenu = menu->addMenu(GLX_OPTION_SLIDESHOW);
       
   122     mSubMenu->setObjectName( "GridMenu SlideShow" );
       
   123 	
   117     action = mSubMenu->addAction(GLX_OPTION_SS_PLAY); 
   124     action = mSubMenu->addAction(GLX_OPTION_SS_PLAY); 
   118     action->setData(EGlxCmdFirstSlideshow);
   125     action->setData(EGlxCmdFirstSlideshow);
       
   126     action->setObjectName( "GridMenu Play" );
   119     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   127     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   120     
   128     
   121     action = mSubMenu->addAction(GLX_OPTION_SS_SETTINGS);
   129     action = mSubMenu->addAction(GLX_OPTION_SS_SETTINGS);
   122     action->setData(EGlxCmdSlideshowSettings);
   130     action->setData(EGlxCmdSlideshowSettings);
       
   131     action->setObjectName( "GridMenu Setting" );
   123     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
   132     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
       
   133     
   124     action = menu->addAction(GLX_OPTION_ADD_TO_ALBUM);
   134     action = menu->addAction(GLX_OPTION_ADD_TO_ALBUM);
   125     action->setData(EGlxCmdAddToAlbum);
   135     action->setData(EGlxCmdAddToAlbum);
       
   136     action->setObjectName( "GridMenu AddToAlbum" );
   126     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   137     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   127     
   138     
   128     action = menu->addAction(GLX_OPTION_REMOVE_FROM_ALBUM);
   139     action = menu->addAction(GLX_OPTION_REMOVE_FROM_ALBUM);
   129     action->setData(EGlxCmdRemoveFrom);
   140     action->setData(EGlxCmdRemoveFrom);
       
   141     action->setObjectName( "GridMenu RemoveAlbum" );
   130     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   142     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   131 
   143 
   132     action = menu->addAction(GLX_OPTION_DELETE);
   144     action = menu->addAction(GLX_OPTION_DELETE);
   133     action->setData(EGlxCmdDelete);
   145     action->setData(EGlxCmdDelete);
       
   146     action->setObjectName( "GridMenu Delete" );
   134     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   147     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   135 }
   148 }
   136 
   149 
   137 void GlxMenuManager::CreateListMenu(HbMenu* menu)
   150 void GlxMenuManager::CreateListMenu(HbMenu* menu)
   138 {
   151 {
   139     qDebug()<<"GlxMenuManager::CreateListMenu";
   152     qDebug()<<"GlxMenuManager::CreateListMenu";
   140     HbAction *action = NULL;
   153     HbAction *action = NULL;
       
   154     menu->setObjectName( "Listmenu" );
   141     
   155     
   142     action = menu->addAction(GLX_OPTION_NEW_ALBUM);
   156     action = menu->addAction(GLX_OPTION_NEW_ALBUM);
   143     action->setData(EGlxCmdAddMedia);
   157     action->setData(EGlxCmdAddMedia);
       
   158     action->setObjectName( "ListMenu NewAlbum" );
   144     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   159     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   145 }
   160 }
   146 
   161 
   147 void GlxMenuManager::CreateFullscreenMenu(HbMenu* menu)
   162 void GlxMenuManager::CreateFullscreenMenu(HbMenu* menu)
   148 {
   163 {
   149     qDebug()<<"GlxMenuManager::CreateFullscreenMenu";
   164     qDebug()<<"GlxMenuManager::CreateFullscreenMenu";
   150     HbAction *action = NULL;
   165     HbAction *action = NULL;
       
   166     menu->setObjectName( "FSMenu" );
   151     
   167     
   152     action = menu->addAction(GLX_OPTION_SHARE);
   168     action = menu->addAction(GLX_OPTION_SHARE);
   153     action->setData(EGlxCmdSend);
   169     action->setData(EGlxCmdSend);
       
   170     action->setObjectName( "FSMenu Share" );
   154     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   171     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   155     
   172     
   156     mSubMenu = menu->addMenu(GLX_OPTION_SLIDESHOW);
   173     mSubMenu = menu->addMenu(GLX_OPTION_SLIDESHOW);
   157     action = mSubMenu->addAction(GLX_OPTION_SS_PLAY); 
   174     mSubMenu->setObjectName( "FSMenu SlideShow" );
       
   175     
       
   176     action = mSubMenu->addAction(GLX_OPTION_SS_PLAY);
   158     action->setData(EGlxCmdSelectSlideshow);
   177     action->setData(EGlxCmdSelectSlideshow);
   159     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
   178     action->setObjectName( "FSMenu Play" );
       
   179     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   180     
   160     action = mSubMenu->addAction(GLX_OPTION_SS_SETTINGS);
   181     action = mSubMenu->addAction(GLX_OPTION_SS_SETTINGS);
   161     action->setData(EGlxCmdSlideshowSettings);
   182     action->setData(EGlxCmdSlideshowSettings);
   162     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   183     action->setObjectName( "FSMenu Setting" );
       
   184     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   185 #ifndef __WINSCW__
       
   186 	CFeatureDiscovery* featManager = CFeatureDiscovery::NewL();
       
   187     if(featManager->IsFeatureSupportedL(KFeatureIdFfImageEditor))
       
   188         {
       
   189 		mSubMenu = menu->addMenu(QString("Rotate"));
       
   190 		action = mSubMenu->addAction(QString("90 CW")); 
       
   191 		action->setData(EGlxCmdRotateImgCW);
       
   192 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); 
       
   193 		action = mSubMenu->addAction(QString("90 CCW"));
       
   194 		action->setData(EGlxCmdRotateImgCCW);
       
   195 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   196 		
       
   197 		action = menu->addAction(QString("Crop"));
       
   198 		action->setData(EGlxCmdRotateImgCrop);
       
   199 		connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));   
       
   200         }
       
   201     delete featManager;
       
   202 #endif //__WINSCW__	
   163     
   203     
   164     action = menu->addAction(GLX_OPTION_ADD_TO_ALBUM);
   204     action = menu->addAction(GLX_OPTION_ADD_TO_ALBUM);
   165     action->setData(EGlxCmdAddToAlbum);
   205     action->setData(EGlxCmdAddToAlbum);
       
   206     action->setObjectName( "FSMenu AddToAlbum" );
   166     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   207     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   167 }
   208 }
   168 
   209 
   169 void GlxMenuManager::setAllActionVisibility( QList<QAction*> actionList, bool visible )
   210 void GlxMenuManager::setAllActionVisibility( QList<QAction*> actionList, bool visible )
   170 {
   211 {
   247 
   288 
   248 void GlxMenuManager::ShowItemSpecificMenu(qint32 viewId,QPointF pos)
   289 void GlxMenuManager::ShowItemSpecificMenu(qint32 viewId,QPointF pos)
   249 {
   290 {
   250     qDebug("GlxMenuManager::showContextMenu " );
   291     qDebug("GlxMenuManager::showContextMenu " );
   251     mContextMenu = new HbMenu();
   292     mContextMenu = new HbMenu();
       
   293     mContextMenu->setObjectName( "ContextMenu" );
   252     HbAction *action = NULL;
   294     HbAction *action = NULL;
   253 
   295 
   254     switch ( viewId ) {
   296     switch ( viewId ) {
   255 	    case GLX_GRIDVIEW_ID :
   297 	    case GLX_GRIDVIEW_ID :
   256 	        action = mContextMenu->addAction(GLX_MENU_SHARE);
   298 	        action = mContextMenu->addAction(GLX_MENU_SHARE);
   257 	        action->setData(EGlxCmdContextSend);
   299 	        action->setData(EGlxCmdContextSend);
       
   300 	        action->setObjectName( "CM Send" );
   258 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   301 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   259 	        
   302 	        
   260 	        action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
   303 	        action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
   261 	        action->setData(EGlxCmdSelectSlideshow);
   304 	        action->setData(EGlxCmdSelectSlideshow);
       
   305 	        action->setObjectName( "CM SlideShow" );
   262 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   306 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   263 
   307 
   264 	        if ( viewSubState() == ALBUM_ITEM_S ) {        
   308 	        if ( viewSubState() == ALBUM_ITEM_S ) {        
   265 	        action = mContextMenu->addAction(GLX_OPTION_REMOVE_FROM_ALBUM);
   309                 action = mContextMenu->addAction(GLX_OPTION_REMOVE_FROM_ALBUM);
   266 	        action->setData(EGlxCmdContextRemoveFrom);
   310                 action->setData(EGlxCmdContextRemoveFrom);
   267 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   311                 action->setObjectName( "CM RemoveAlbum" );
       
   312                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   268 	        }
   313 	        }
   269 	        
   314 	        
   270 	        action = mContextMenu->addAction(GLX_MENU_ADD_TO_ALBUM);
   315 	        action = mContextMenu->addAction(GLX_MENU_ADD_TO_ALBUM);
   271 		    action->setData(EGlxCmdContextAddToAlbum);
   316 		    action->setData(EGlxCmdContextAddToAlbum);
       
   317 		    action->setObjectName( "CM AddToAlbum" );
   272 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   318 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   273 		    
   319 		    
   274 		    action = mContextMenu->addAction(GLX_MENU_DELETE);
   320 		    action = mContextMenu->addAction(GLX_MENU_DELETE);
   275 		    action->setData(EGlxCmdContextDelete);
   321 		    action->setData(EGlxCmdContextDelete);
       
   322 		    action->setObjectName( "CM Delete" );
   276 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   323 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   277 			break;
   324 			break;
   278 	    	
   325 	    	
   279 	    case GLX_LISTVIEW_ID : {
   326 	    case GLX_LISTVIEW_ID : {
   280 	        int count = 0;
   327 	        int count = 0;
   284 	        }  
   331 	        }  
   285 
   332 
   286 	        if ( count ) {
   333 	        if ( count ) {
   287                 action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
   334                 action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
   288                 action->setData(EGlxCmdAlbumSlideShow);
   335                 action->setData(EGlxCmdAlbumSlideShow);
       
   336                 action->setObjectName( "CM Album SlideShow" );
   289                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   337                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   290 	        }
   338 	        }
   291 	        
   339 	        
   292 	        variant = mModel->data( mModel->index(0,0), GlxSystemItemRole );    
   340 	        variant = mModel->data( mModel->index(0,0), GlxSystemItemRole );    
   293             if ( variant.isValid() &&  variant.canConvert<bool> () && ( variant.value<bool>() == false ) ) {           
   341             if ( variant.isValid() &&  variant.canConvert<bool> () && ( variant.value<bool>() == false ) ) {           
   294                 action = mContextMenu->addAction(GLX_MENU_RENAME);
   342                 action = mContextMenu->addAction(GLX_MENU_RENAME);
   295                 action->setData(EGlxCmdContextRename);
   343                 action->setData(EGlxCmdContextRename);
       
   344                 action->setObjectName( "CM Rename" );
   296                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   345                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   297                             
   346                             
   298                 action = mContextMenu->addAction(GLX_MENU_DELETE);
   347                 action = mContextMenu->addAction(GLX_MENU_DELETE);
   299                 action->setData(EGlxCmdContextAlbumDelete);
   348                 action->setData(EGlxCmdContextAlbumDelete);
       
   349                 action->setObjectName( "CM Album Delete" );
   300                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   350                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   301             }
   351             }
   302 	    }
   352 	    }
   303 			break;
   353 			break;
   304 			
   354