8 #include <tqpopupmenu.h>
10 #include "tdeaccelmenuwatch.h"
17 _accList.setAutoDelete(
true );
18 _menuList.setAutoDelete(
false );
28 if ( !_menuList.findRef( menu ) ) {
29 _menuList.append( menu );
30 connect( menu, TQ_SIGNAL(destroyed()),
this, TQ_SLOT(removeDeadMenu()) );
38 AccelItem *item = newAccelItem( _menu, itemId, StringAccel ) ;
39 item->action = TQString::fromLocal8Bit( action );
44 AccelItem *item = newAccelItem( _menu, itemId, StdAccel ) ;
45 item->stdAction = accel;
50 assert( _accel != 0 );
52 TQPtrListIterator<AccelItem> iter( _accList );
55 for( ; (item = iter.current()) ; ++iter ) {
58 switch( item->type ) {
60 item->menu->setAccel( _accel->shortcut( item->action ).keyCodeQt(), item->itemId );
63 item->menu->setAccel( TDEStdAccel::shortcut( item->stdAction ).keyCodeQt(), item->itemId );
72 void TDEAccelMenuWatch::removeDeadMenu()
74 TQPopupMenu *sdr = (TQPopupMenu *) sender();
77 if ( !_menuList.findRef( sdr ) )
83 for ( accel = _accList.first(); accel; accel = _accList.next() )
86 if( accel && accel->menu == sdr ) {
88 accel = _accList.current();
94 _menuList.remove( sdr );
99 TDEAccelMenuWatch::AccelItem *TDEAccelMenuWatch::newAccelItem( TQPopupMenu *,
100 int itemId, AccelType type )
102 AccelItem *item =
new AccelItem;
105 item->itemId = itemId;
108 _accList.append( item );
113 #include "tdeaccelmenuwatch.moc"