ui/viewmanagement/viewmanager/src/glxmenumanager.cpp
changeset 24 99ad1390cd33
parent 23 74c9f037fd5d
child 26 c499df2dbb33
equal deleted inserted replaced
23:74c9f037fd5d 24:99ad1390cd33
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 #include <glxviewids.h>
    17 
    18 #include <glxmenumanager.h>
    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 <glxcommandhandlers.hrh>
    22 #include <hbmainwindow.h>
    23 #include <QDebug>
    23 
    24 
    24 //user include
    25 GlxMenuManager::GlxMenuManager()
    25 #include "glxviewids.h"
    26 {
    26 #include "glxmenumanager.h"
    27 }
    27 #include "glxcommandhandlers.hrh"
       
    28 #include "glxmodelparm.h"
       
    29 
       
    30 GlxMenuManager::GlxMenuManager(HbMainWindow* mainWindow):mMainWindow(mainWindow)
       
    31 {
       
    32 }
       
    33 
    28 GlxMenuManager::~GlxMenuManager()
    34 GlxMenuManager::~GlxMenuManager()
    29 {
    35 {
    30 }
       
    31 void GlxMenuManager::CreateViewMenu(qint32 viewId,HbMenu* menu,bool empty, int subState)
       
    32 {
       
    33 	Q_UNUSED(empty);
       
    34     switch(viewId)
       
    35     {
       
    36     case GLX_GRIDVIEW_ID:   {
       
    37                             qDebug()<<"GRIDVIEW MENU CREATED";
       
    38                             CreateGridMenu(menu);
       
    39                             }
       
    40                             break;
       
    41 
       
    42     case GLX_LISTVIEW_ID:   {
       
    43                             qDebug()<<"LISTVIEW MENU CREATED";
       
    44                             CreateListMenu(menu);
       
    45                             }
       
    46                             break;
       
    47     case GLX_FULLSCREENVIEW_ID:{
       
    48 								//image viewer state 
       
    49                                 if(2 == subState){
       
    50                                     CreateImageViewerMenu(menu);
       
    51                                 }
       
    52                                 else{
       
    53                                     qDebug()<<"FULLSCREENVIEW MENU CREATED";
       
    54                                     CreateFullscreenMenu(menu);
       
    55                                 }
       
    56                                }
       
    57                             break;
       
    58 							
       
    59     case GLX_DETAILSVIEW_ID: {
       
    60 	//will create details specific menu later
       
    61                             qDebug()<<"DETAILS VIEW MENU CREATE";
       
    62                              }  
       
    63 	                          
       
    64     case GLX_SLIDESHOWVIEW_ID :
       
    65         break;                            
       
    66                             
       
    67     default:                
       
    68                             break;
       
    69 
       
    70     }
       
    71 }
    36 }
    72 
    37 
    73 void GlxMenuManager::createMarkingModeMenu(HbMenu* menu)
    38 void GlxMenuManager::createMarkingModeMenu(HbMenu* menu)
    74 {
    39 {
    75     qDebug()<< "GlxMenuManager::CreateMarkingModeMenu" ;  
    40     qDebug()<< "GlxMenuManager::CreateMarkingModeMenu" ;  
    85     
    50     
    86     action = menu->addAction("Help");
    51     action = menu->addAction("Help");
    87     action->setData(EGlxCmdUnMarkAll);
    52     action->setData(EGlxCmdUnMarkAll);
    88     action->setVisible(FALSE);
    53     action->setVisible(FALSE);
    89     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
    54     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
    90     menu->setVisible(FALSE);
       
    91     
    55     
    92     action = menu->addAction("Exit");
    56     action = menu->addAction("Exit");
    93     action->setData(EGlxCmdUnMarkAll);
    57     action->setData(EGlxCmdUnMarkAll);
    94     action->setVisible(FALSE);
    58     action->setVisible(FALSE);
    95     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
    59     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
    96     menu->setVisible(FALSE);
    60 }
       
    61 
       
    62 void GlxMenuManager::addMenu(qint32 viewId, HbMenu* menu)
       
    63 {
       
    64     switch(viewId) {
       
    65     case GLX_GRIDVIEW_ID:
       
    66         connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateGridMenu() ) );
       
    67         CreateGridMenu( menu );
       
    68         break;                            
       
    69 
       
    70     case GLX_LISTVIEW_ID: 
       
    71         CreateListMenu ( menu );
       
    72         break;
       
    73         
       
    74     case GLX_FULLSCREENVIEW_ID:
       
    75         connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateFullscreenMenu() ) );
       
    76         CreateFullscreenMenu( menu );
       
    77         break;
       
    78                 
       
    79     default:
       
    80         break;
       
    81     }  
       
    82 }
       
    83 
       
    84 void GlxMenuManager::removeMenu(qint32 viewId, HbMenu* menu)
       
    85 {
       
    86     switch(viewId) {
       
    87     case GLX_GRIDVIEW_ID:
       
    88         disconnect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateGridMenu() ) );
       
    89         break;                            
       
    90         
       
    91     case GLX_FULLSCREENVIEW_ID:
       
    92         disconnect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateFullscreenMenu() ) );
       
    93         break;
       
    94                 
       
    95     default:
       
    96         break;
       
    97     }  
    97 }
    98 }
    98 
    99 
    99 void GlxMenuManager::CreateGridMenu(HbMenu* menu)
   100 void GlxMenuManager::CreateGridMenu(HbMenu* menu)
   100 {
   101 {
   101     qDebug()<<"GlxMenuManager::CreateGridMenu";
   102     qDebug()<<"GlxMenuManager::CreateGridMenu";
   102     HbAction *action = NULL;
   103     HbAction *action = NULL;
       
   104     
   103     action = menu->addAction("Send");
   105     action = menu->addAction("Send");
   104     action->setData(EGlxCmdSend);
   106     action->setData(EGlxCmdSend);
   105     // action->setVisible(EFalse);
       
   106     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   107     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   107    
   108    
   108     /*action = menu->addAction("Upload to web");
       
   109     action->setData(EGlxCmdUpload);
       
   110     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/
       
   111     action = menu->addAction("Slide Show");
   109     action = menu->addAction("Slide Show");
   112     action->setData(EGlxCmdFirstSlideshow);
   110     action->setData(EGlxCmdFirstSlideshow);
   113     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   111     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   112     
   114     action = menu->addAction("Add to album");
   113     action = menu->addAction("Add to album");
   115     action->setData(EGlxCmdAddToAlbum);
   114     action->setData(EGlxCmdAddToAlbum);
   116     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   115     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   117     /*action = menu->addAction("Sort by");
   116     
   118     //action->setData();
   117     action = menu->addAction("Remove From Album");
   119     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   118     action->setData(EGlxCmdRemoveFrom);
   120     action = menu->addAction("Setting");
   119     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   121     //action->setData();
   120 
   122     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/
       
   123     action = menu->addAction("Delete");
   121     action = menu->addAction("Delete");
   124     action->setData(EGlxCmdDelete);
   122     action->setData(EGlxCmdDelete);
   125     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   123     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   126     /*action = menu->addAction("Help");
       
   127     //action->setData();
       
   128     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   129     action = menu->addAction("Exit");*/
       
   130 }
   124 }
   131 
   125 
   132 void GlxMenuManager::CreateListMenu(HbMenu* menu)
   126 void GlxMenuManager::CreateListMenu(HbMenu* menu)
   133 {
   127 {
   134     qDebug()<<"GlxMenuManager::CreateListMenu";
   128     qDebug()<<"GlxMenuManager::CreateListMenu";
   135     /*HbAction *action = menu->addAction("Setting");
   129     HbAction *action = NULL;
   136     //action->setData();
   130     
   137     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   131     action = menu->addAction("New album");
   138     action = menu->addAction("Help");
   132     action->setData(EGlxCmdAddMedia);
   139     //action->setData();
   133     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   140     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   141     action = menu->addAction("Exit");
       
   142     //action->setData();
       
   143     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/
       
   144 }
   134 }
   145 
   135 
   146 void GlxMenuManager::CreateFullscreenMenu(HbMenu* menu)
   136 void GlxMenuManager::CreateFullscreenMenu(HbMenu* menu)
   147 {
   137 {
   148     qDebug()<<"GlxMenuManager::CreateFullscreenMenu";
   138     qDebug()<<"GlxMenuManager::CreateFullscreenMenu";
   149     HbAction *action = NULL;
   139     HbAction *action = NULL;
       
   140     
   150     action = menu->addAction("Send");
   141     action = menu->addAction("Send");
   151     action->setData(EGlxCmdSend);
   142     action->setData(EGlxCmdSend);
   152     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   143     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   144     
   153     action = menu->addAction("Slide Show");
   145     action = menu->addAction("Slide Show");
   154     action->setData(EGlxCmdSelectSlideshow);
   146     action->setData(EGlxCmdSelectSlideshow);
   155     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   147     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   148     
   156     action = menu->addAction("Add to album");
   149     action = menu->addAction("Add to album");
   157     action->setData(EGlxCmdAddToAlbum);
   150     action->setData(EGlxCmdAddToAlbum);
   158     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   151     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   159 	action = menu->addAction("Rotate");
   152 	
       
   153     action = menu->addAction("Rotate");
   160     action->setData(EGlxCmdRotate);
   154     action->setData(EGlxCmdRotate);
   161     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   155     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   162     /*action = menu->addAction("Upload to web");
   156 }
   163     action->setData(EGlxCmdUpload);
   157 
   164     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   158 void GlxMenuManager::setAllActionVisibility( QList<QAction*> actionList, bool visible )
   165     action = menu->addAction("Use Image");
   159 {
   166     //action->setData();
   160     qDebug() << "GlxMenuManager::setAllActionVisibility count " << actionList.count() << " visible" << visible;
   167     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   161     for ( int i = 0 ; i < actionList.count(); i++) {
   168     action = menu->addAction("Print");
   162         actionList.at(i)->setVisible(visible);
   169     //action->setData();
   163     }
   170     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   164 }
   171     action = menu->addAction("Edit");
   165 
   172     //action->setData();
   166 int GlxMenuManager::viewSubState()
   173     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   167 {
   174     action = menu->addAction("Details");
   168     QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );    
   175     action->setData(EGlxCmdDetailsOption);
   169     if ( variant.isValid() &&  variant.canConvert<int> () ) {
   176     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   170         return variant.value<int>() ;
   177     action = menu->addAction("Help");
   171     }
   178     //action->setData();
   172     return -1;
   179     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   173 }
   180     action = menu->addAction("Exit");
   174 
   181     //action->setData();
   175 void GlxMenuManager::updateGridMenu()
   182     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/
   176 {
   183 }
   177     qDebug() << "GlxMenuManager::updateGridMenu";
   184 
   178 
   185 void GlxMenuManager::CreateImageViewerMenu(HbMenu* menu)
   179     HbMenu *menu = qobject_cast<HbMenu*>( sender() );
   186 {
   180     static bool isAllActionDisable = FALSE;
       
   181     int rowCount = mModel->rowCount();    
       
   182     QList<QAction*> actionList = menu->actions();
       
   183     
       
   184     if ( rowCount == 0 && isAllActionDisable == FALSE) {
       
   185         qDebug() << "GlxMenuManager::updateGridMenu set all visible FALSE";
       
   186         setAllActionVisibility( actionList, FALSE );
       
   187         isAllActionDisable = TRUE;
       
   188     }    
       
   189     
       
   190     if ( rowCount && isAllActionDisable == TRUE ) {
       
   191         setAllActionVisibility( actionList, TRUE );
       
   192         isAllActionDisable = FALSE;
       
   193         qDebug() << "GlxMenuManager::updateGridMenu set all visible TRUE" ;
       
   194     }
       
   195     
       
   196     if ( rowCount ) {
       
   197         int state =  viewSubState();
       
   198         
       
   199         switch ( state ) {
       
   200         case ALBUM_ITEM_S :
       
   201             actionList.at(GlxGridViewRemoveFromAlbum)->setVisible( TRUE );
       
   202             break ;
       
   203             
       
   204         default :    
       
   205             actionList.at(GlxGridViewRemoveFromAlbum)->setVisible( FALSE );
       
   206             break ;
       
   207         }       
       
   208     }    
       
   209 }
       
   210 
       
   211 void GlxMenuManager::updateFullscreenMenu()
       
   212 {
       
   213     HbMenu *menu = qobject_cast<HbMenu*>( sender() );
       
   214     QList<QAction*> actionList = menu->actions();
       
   215     static bool isAllActionDisable = FALSE;
       
   216     int state = viewSubState() ;
       
   217     
       
   218     if ( state == IMAGEVIEWER_S &&  isAllActionDisable == FALSE ) {        
       
   219         setAllActionVisibility( actionList, FALSE );
       
   220         isAllActionDisable = TRUE;
       
   221     }
       
   222   
       
   223     if ( state != IMAGEVIEWER_S &&  isAllActionDisable == TRUE ) {
       
   224         setAllActionVisibility( actionList, TRUE );
       
   225         isAllActionDisable = FALSE;
       
   226     }    
   187 }
   227 }
   188 
   228 
   189 void GlxMenuManager::menuItemSelected()
   229 void GlxMenuManager::menuItemSelected()
   190 {
   230 {
   191     HbAction *action = qobject_cast<HbAction*>(sender());
   231     HbAction *action = qobject_cast<HbAction*>(sender());
   200     HbMenu *mainMenu = new HbMenu();
   240     HbMenu *mainMenu = new HbMenu();
   201     HbAction *action = NULL;
   241     HbAction *action = NULL;
   202 	switch ( viewId ) {
   242 	switch ( viewId ) {
   203 	    case GLX_GRIDVIEW_ID :
   243 	    case GLX_GRIDVIEW_ID :
   204 	        action = mainMenu->addAction("Send");
   244 	        action = mainMenu->addAction("Send");
   205 	        action->setData(EGlxCmdSend);
   245 	        action->setData(EGlxCmdContextSend);
   206 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   246 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   207 	        
   247 	        
   208 	        action = mainMenu->addAction("Slide Show");
   248 	        action = mainMenu->addAction("Slide Show");
   209 	        action->setData(EGlxCmdSelectSlideshow);
   249 	        action->setData(EGlxCmdSelectSlideshow);
   210 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   250 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   221 	    case GLX_LISTVIEW_ID :
   261 	    case GLX_LISTVIEW_ID :
   222 	        action = mainMenu->addAction("Slide Show");
   262 	        action = mainMenu->addAction("Slide Show");
   223 	        action->setData(EGlxCmdAlbumSlideShow);
   263 	        action->setData(EGlxCmdAlbumSlideShow);
   224 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   264 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   225 	                    
   265 	                    
   226 		    /*action = mainMenu->addAction("Delete");
   266 		    action = mainMenu->addAction("Delete");
   227 		    action->setData(EGlxCmdContextAlbumDelete);
   267 		    action->setData(EGlxCmdContextAlbumDelete);
   228 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/
   268 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   229 			break;
   269 			break;
   230 		default:
   270 		default:
   231 		    break;	
   271 		    break;	
   232 		}
   272 		}
   233 
   273 
       
   274 	connect(mMainWindow, SIGNAL(aboutToChangeOrientation ()), mainMenu, SLOT(close()));
   234     mainMenu->exec(pos);
   275     mainMenu->exec(pos);
   235 
   276     disconnect(mMainWindow, SIGNAL(aboutToChangeOrientation ()), mainMenu, SLOT(close()));
   236     delete mainMenu;
   277     delete mainMenu;
   237 
   278 
   238 }
   279 }