diff -r b7da29130b0e -r 80e4d18b72f5 src/hbcore/gui/hbmenu.cpp --- a/src/hbcore/gui/hbmenu.cpp Fri Sep 17 08:32:10 2010 +0300 +++ b/src/hbcore/gui/hbmenu.cpp Mon Oct 04 00:38:12 2010 +0300 @@ -76,19 +76,28 @@ void HbMenuPrivate::addPopupEffects() { #ifdef HB_EFFECTS - effectType = "HB_MENU"; + if (menuType == HbMenu::OptionsMenu) { + effectType = "HB_MENU"; + } else { + effectType = "HB_SUBMENU"; + } hasEffects = menuEffectsLoaded; if (menuEffectsLoaded) return; menuEffectsLoaded = true; hasEffects = HbEffectInternal::add("HB_MENU", "menu_appear", "appear"); if (hasEffects) { - //We load the disappear effect only if appear effect was also loaded hasEffects = HbEffectInternal::add("HB_MENU", "menu_disappear", "disappear"); if (hasEffects) { hasEffects = HbEffectInternal::add("HB_menuitem", "menuitem_press", "clicked"); } + if (hasEffects) { + hasEffects = HbEffectInternal::add("HB_SUBMENU", "submenu_appear", "appear"); + } + if (hasEffects) { + hasEffects = HbEffectInternal::add("HB_SUBMENU", "submenu_disappear", "disappear"); + } } #endif } @@ -104,7 +113,6 @@ } #endif HbAction *hbAction = qobject_cast(currentItem->action()); - q->setActiveAction(hbAction); if (hbAction && hbAction->menu() && !actionTriggered) { hbAction->trigger(); stopTimeout(); @@ -148,6 +156,7 @@ void HbMenuPrivate::changeToOptionsMenu() { menuType = HbMenu::OptionsMenu; + effectType = "HB_MENU"; } HbMenuItem *HbMenuPrivate::subMenuItem() @@ -163,9 +172,12 @@ void HbMenuPrivate::_q_onActionTriggered() { Q_Q(HbMenu); - HbAction *action = qobject_cast(q->sender()); - if (action && !action->menu() ) { // do not trigger from opening submenu - emit q->triggered(action); + HbAction *action = qobject_cast(q->sender()); + if (action) { + q->setActiveAction(action); + if (!action->menu()) { // do not trigger from opening submenu + emit q->triggered(action); + } } } @@ -415,7 +427,7 @@ mSubMenuItem->size().width() + mRightMargin - q->size().width(); } - q->setPreferredPos(QPointF(leftEdge, upperEdge)); + q->setPreferredPos(QPointF(leftEdge, upperEdge), HbPopup::TopLeftCorner); } else { qreal rightEdge = mSubMenuItem->scenePos().x() + mRightMargin; if ((rightEdge - q->size().width()) < 0) { @@ -972,4 +984,41 @@ HbMenu::show(); } +/*! + Overidden from popup. Sets the preferred position of the menu. + + \param preferredPos Defines the coordinates of preferred position on the screen where + the menu is to open. + \param placement The corner or edge of the dialog that is to be placed at \a preferredPos. + + \b Example: + \code + HbMenu *menu = new HbMenu(); + + menu->setPreferredPos( QPointF(x,y), HbPopup::BottomEdgeCenter ); + menu->show(); + \endcode + */ +void HbMenu::setPreferredPos( const QPointF& preferredPos, + HbPopup::Placement placement ) +{ + Q_D(HbMenu); + bool layoutFlag = false; + if (d->preferredPos != preferredPos ) { + d->preferredPos = preferredPos; + layoutFlag = true; + } + if (d->placement != placement) { + d->placement = placement; + layoutFlag = true; + } + d->preferredPosSet = true; + //If position updated, informing layoutproxy with layoutrequest + if (layoutFlag) { + QEvent layoutRequest = QEvent::LayoutRequest; + QApplication::sendEvent(this, &layoutRequest); + } +} + + #include "moc_hbmenu.cpp"