connect( myMenu, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
#ifdef ENABLE_DYNAMIC_MENU
if ( myMenu->inherits( "QMenuBar" ) )
- connect( myMenu, SIGNAL( highlighted( int ) ), this, SLOT( onHighlighted( int ) ) );
+ connect( myMenu, SIGNAL( hovered( QAction* ) ), this, SLOT( onHighlighted( QAction* ) ) );
#endif
}
}
connect( myMenu, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
#ifdef ENABLE_DYNAMIC_MENU
if ( myMenu->inherits( "QMenuBar" ) )
- connect( myMenu, SIGNAL( highlighted( int ) ), this, SLOT( onHighlighted( int ) ) );
+ connect( myMenu, SIGNAL( hovered( QAction* ) ), this, SLOT( onHighlighted( QAction* ) ) );
#endif
}
}
connect( ma->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
connect( ma->menu(), SIGNAL( aboutToHide() ), this, SLOT( onAboutToHide() ) );
#ifdef ENABLE_DYNAMIC_MENU
- connect( ma->menu(), SIGNAL( highlighted( int ) ), this, SLOT( onHighlighted( int ) ) );
+ connect( ma->menu(), SIGNAL( hovered( QAction* ) ), this, SLOT( onHighlighted( QAction* ) ) );
#endif
MenuNode* node = new MenuNode( pNode, myMenus.insert( gid, ma ).key(), idx, group );
\brief Called when menu item is highlighted.
\param id menu item being highlighted ID
*/
-void QtxActionMenuMgr::onHighlighted( int id )
+void QtxActionMenuMgr::onHighlighted( QAction* a )
{
const QObject* snd = sender();
- int pid = 0, realId;
+ int pid = 0;
if ( myMenu && snd == myMenu )
pid = -1;
else
for ( MenuMap::Iterator itr = myMenus.begin(); itr != myMenus.end(); ++itr )
{
if ( itr.value()->menu() && itr.value()->menu() == snd )
- pid = itr.key();
+ pid = itr.key();
}
}
if ( pid )
{
- realId = findId( id, pid );
+ int realId = menuActionId( a );
if ( realId != -1 )
{
emit menuHighlighted( pid, realId );
return a;
}
+/*!
+ \brief Get submenu action by \a id.
+ \param id submenu ID
+ \return submenu action or 0 if not found
+*/
+int QtxActionMenuMgr::menuActionId( QAction* a ) const
+{
+ int id = -1;
+ for ( MenuMap::ConstIterator itr = myMenus.begin(); itr != myMenus.end() && id == -1; ++itr )
+ {
+ if ( itr.value() == a )
+ id = itr.key();
+ }
+ return id;
+}
+
/*!
\brief Update menu.