28 #define YUILogComponent "qt-ui" 29 #include <yui/YUILog.h> 33 #include "YQContextMenu.h" 34 #include <yui/YEvent.h> 43 , _suppressCancelEvent(false )
46 yuiWarning() <<
"YQContextMenu";
53 , _position ( position )
69 QMenu * menu =
new QMenu( _parent );
70 YUI_CHECK_NEW( menu );
71 menu->setProperty(
"class",
"ycontextmenu QMenu" );
73 connect( menu, &pclass(menu)::triggered,
76 connect( menu, &pclass(menu)::aboutToHide,
83 menu->popup( _position );
90 for ( YItemIterator it = begin; it != end; ++it )
95 if ( item->hasIconName() )
100 if ( item->hasChildren() )
105 subMenu = parentMenu->addMenu( fromUTF8( item->label() ));
107 subMenu = parentMenu->addMenu( QIcon( icon ), fromUTF8( item->label() ));
109 connect( subMenu, &pclass(subMenu)::triggered,
112 rebuildMenuTree( subMenu, item->childrenBegin(), item->childrenEnd() );
123 act = parentMenu->addAction( fromUTF8( item->label() ) );
125 act = parentMenu->addAction( QIcon( icon ), fromUTF8( item->label() ) );
127 _serials[act] = item->index();
144 if ( ! _suppressCancelEvent )
147 _suppressCancelEvent =
false;
155 if ( _serials.contains( action ) )
156 serialNo = _serials[action];
159 _selectedItem = findMenuItem( serialNo );
174 _suppressCancelEvent =
true;
175 QTimer::singleShot( 100,
this, SLOT(
returnNow() ) );
179 yuiError() <<
"No menu item with serial no. " << serialNo << endl;
QIcon loadIcon(const string &iconName) const
Load an icon.
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...
static YQUI * ui()
Access the global Qt-UI.