src/hbcore/gui/hbmenu.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    34 #include "hbeffect.h"
    34 #include "hbeffect.h"
    35 #include "hbeffectinternal_p.h"
    35 #include "hbeffectinternal_p.h"
    36 bool HbMenuPrivate::menuEffectsLoaded = false;
    36 bool HbMenuPrivate::menuEffectsLoaded = false;
    37 #endif
    37 #endif
    38 #include "hbglobal_p.h"
    38 #include "hbglobal_p.h"
    39 
    39 #include <QGraphicsSceneMouseEvent>
    40 #include <QPointer>
    40 #include <QPointer>
    41 
    41 
    42 Q_DECLARE_METATYPE (QAction*)// krazy:exclude=qclasses
    42 Q_DECLARE_METATYPE (QAction*)// krazy:exclude=qclasses
    43 
    43 
    44 HbMenuPrivate::HbMenuPrivate():
    44 HbMenuPrivate::HbMenuPrivate():
    51     mSubMenuItem(0),
    51     mSubMenuItem(0),
    52     mRightMargin(0.0),
    52     mRightMargin(0.0),
    53     mDownMargin(0.0),
    53     mDownMargin(0.0),
    54     delayMenuConstruction(true),
    54     delayMenuConstruction(true),
    55     receiverToDisconnectOnClose(0),
    55     receiverToDisconnectOnClose(0),
    56     mNumberOfColumns(1)
    56     mNumberOfColumns(1),
       
    57     mCloseAllMenus(false)
    57 {
    58 {
    58 }
    59 }
    59 
    60 
    60 HbMenuPrivate::~HbMenuPrivate()
    61 HbMenuPrivate::~HbMenuPrivate()
    61 {
    62 {
   173     Q_Q(HbMenu);    
   174     Q_Q(HbMenu);    
   174  
   175  
   175     // do not close the menu tree if the triggered action is
   176     // do not close the menu tree if the triggered action is
   176     // submenu item
   177     // submenu item
   177     if (!action->menu()) { 
   178     if (!action->menu()) { 
       
   179         mCloseAllMenus = true;
   178         q->close();
   180         q->close();
   179     } else {
   181     } else {
   180         stopTimeout();
   182         stopTimeout();
   181     }
   183     }
   182 }
   184 }
   269             // huh ? activeSubMenu = 0;
   271             // huh ? activeSubMenu = 0;
   270         }
   272         }
   271     }
   273     }
   272 }
   274 }
   273 
   275 
       
   276 /*
       
   277     reimp
       
   278 */
       
   279 void HbMenuPrivate::handleBackgroundMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
       
   280 {
       
   281     Q_Q(HbMenu);
       
   282 
       
   283     // Handle cases only for Background or Popup originated mouse presses and when
       
   284     // any dismiss policy defined
       
   285     if (mousePressLocation != None && dismissPolicy != HbPopup::NoDismiss) {
       
   286 
       
   287         MouseEventLocationType mouseReleaseLocation = Background;
       
   288         HbMenu* tempMenu = 0;
       
   289         QList<QGraphicsItem*> itemList = q->scene()->items(event->pos());
       
   290         foreach (QGraphicsItem* sceneItem, itemList ){
       
   291             QGraphicsWidget *focusWidget = 0;
       
   292             HbMenu *focusMenu = 0;
       
   293             if (sceneItem && sceneItem->isWidget()) {
       
   294                 focusWidget = static_cast<QGraphicsWidget*>(sceneItem);
       
   295                 focusMenu = qobject_cast<HbMenu *>(focusWidget);
       
   296             }
       
   297             if( focusMenu ) {
       
   298                 mouseReleaseLocation = Popup;
       
   299                 tempMenu = focusMenu;
       
   300                 break;
       
   301             }
       
   302         }
       
   303         // Mouse is released within menu
       
   304         if (mouseReleaseLocation == Popup) {
       
   305             HbAction* menuAction = tempMenu->activeAction();
       
   306             if(menuAction){
       
   307                 mCloseAllMenus = false;
       
   308                 closeMenuRecursively(menuAction);
       
   309             }
       
   310         mousePressLocation = None;
       
   311         }
       
   312         else {
       
   313             // trigger the menu to close whole menu
       
   314             mCloseAllMenus = true;
       
   315             q->close();
       
   316             mousePressLocation = None;
       
   317         }
       
   318     }
       
   319 }
       
   320 
   274 void HbMenuPrivate::_q_subMenuTimedOut()
   321 void HbMenuPrivate::_q_subMenuTimedOut()
   275 {
   322 {
   276     Q_Q(HbMenu);
   323     Q_Q(HbMenu);
   277     if( menuTimedOut (activeSubMenu) ) {
   324     if( menuTimedOut (activeSubMenu) ) {
   278         if ( activeSubMenu ) {
   325         if ( activeSubMenu ) {
   280         }
   327         }
   281         timedOut = true;
   328         timedOut = true;
   282         q->close();
   329         q->close();
   283     } else {
   330     } else {
   284         startTimeout();
   331         startTimeout();
   285     }
   332         mCloseAllMenus = false;
       
   333     }
       
   334     if (activeSubMenu && HbMenuPrivate::d_ptr(activeSubMenu)->mCloseAllMenus) {
       
   335         mCloseAllMenus = true;
       
   336         q->close();
       
   337    }
   286 }
   338 }
   287 
   339 
   288 void HbMenuPrivate::_q_handleMenuClose()
   340 void HbMenuPrivate::_q_handleMenuClose()
   289 {
   341 {
   290     Q_Q(HbMenu);
   342     Q_Q(HbMenu);