22 #include <tqpopupmenu.h>
23 #include "kcmenumngr.h"
24 #include "tdeglobal.h"
25 #include "tdeconfig.h"
26 #include "tdeshortcut.h"
31 template class TQPtrDict<TQPopupMenu>;
35 KContextMenuManager::KContextMenuManager( TQObject* parent,
const char* name )
36 : TQObject( parent,
name)
39 menuKey =
TDEShortcut( saver.config()->readEntry(TQString::fromLatin1(
"PopupContextMenu"), TQString::fromLatin1(
"Menu") ) ).
keyCodeQt();
40 saver.config()->setGroup( TQString::fromLatin1(
"ContextMenus") ) ;
41 showOnPress = saver.config()->readBoolEntry(TQString::fromLatin1(
"ShowOnPress"),
true );
44 KContextMenuManager::~KContextMenuManager()
53 return manager->showOnPress;
62 manager->connect( widget, TQ_SIGNAL( destroyed() ), manager, TQ_SLOT( widgetDestroyed() ) );
63 manager->menus.insert( widget, popup );
64 widget->installEventFilter( manager );
67 bool KContextMenuManager::eventFilter( TQObject *o, TQEvent * e)
69 TQPopupMenu* popup = 0;
71 switch ( e->type() ) {
72 case TQEvent::MouseButtonPress:
73 if (((TQMouseEvent*) e )->button() != TQt::RightButton )
78 pos = ((TQMouseEvent*) e )->globalPos();
80 case TQEvent::MouseButtonRelease:
81 if ( showOnPress || ((TQMouseEvent*) e )->button() != TQt::RightButton )
84 pos = ((TQMouseEvent*) e )->globalPos();
86 case TQEvent::KeyPress:
88 if ( !o->isWidgetType() )
90 TQKeyEvent *k = (TQKeyEvent *)e;
92 if ( k->state() & ShiftButton )
94 if ( k->state() & ControlButton )
96 if ( k->state() & AltButton )
102 TQWidget* w = (TQWidget*) o ;
105 pos = w->mapToGlobal( w->rect().center() );
123 void KContextMenuManager::widgetDestroyed()
125 if ( menus.find( (TQObject*)sender() ) )
126 menus.remove( (TQObject*)sender() );
129 #include "kcmenumngr.moc"
static TDEConfig * config()
TQString name(StdAccel id)