author | harlekin <harlekin> | 2002-05-30 20:31:18 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-05-30 20:31:18 (UTC) |
commit | 82f086d29f36ca631d26f8a4a70fd1e809c58364 (patch) (side-by-side diff) | |
tree | 197cd323a7cdb868c3aa839181fcb7dbb5cab252 /library/qpemenubar.cpp | |
parent | f4f00234985e5864229b3e95a3ac0d004c09b10d (diff) | |
download | opie-82f086d29f36ca631d26f8a4a70fd1e809c58364.zip opie-82f086d29f36ca631d26f8a4a70fd1e809c58364.tar.gz opie-82f086d29f36ca631d26f8a4a70fd1e809c58364.tar.bz2 |
applyed patch from Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>, looks like the qtopia on zaurus has a modified qpemenubar, which prevented PyQt to work with opie right. Potentially closes bug #388 hh.org bugzilla
-rw-r--r-- | library/qpemenubar.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/library/qpemenubar.cpp b/library/qpemenubar.cpp index 39f8fd6..bb3ad8d 100644 --- a/library/qpemenubar.cpp +++ b/library/qpemenubar.cpp @@ -117,192 +117,208 @@ void QPEMenuToolFocusManager::moveFocus( bool next ) if ( it == list.begin() ) it = list.end(); --it; } QWidget *w = (*it); if ( w && w->isEnabled() && w->isVisible() && w->topLevelWidget() == qApp->activeWindow() ) { setFocus( w, next ); return; } } } void QPEMenuToolFocusManager::initialize() { if ( !me ) me = new QPEMenuToolFocusManager; } QPEMenuToolFocusManager *QPEMenuToolFocusManager::manager() { if ( !me ) me = new QPEMenuToolFocusManager; return me; } void QPEMenuToolFocusManager::setFocus( QWidget *w, bool next ) { inFocus = w; // qDebug( "Set focus on %s", w->className() ); if ( inFocus->inherits( "QMenuBar" ) ) { QMenuBar *mb = (QMenuBar *)(QWidget *)inFocus; if ( next ) mb->activateItemAt( 0 ); else mb->activateItemAt( mb->count()-1 ); } inFocus->setFocus(); } bool QPEMenuToolFocusManager::eventFilter( QObject *object, QEvent *event ) { if ( event->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent *)event; if ( isActive() ) { if ( object->inherits( "QButton" ) ) { switch ( ke->key() ) { case Key_Left: moveFocus( FALSE ); return TRUE; case Key_Right: moveFocus( TRUE ); return TRUE; case Key_Up: case Key_Down: return TRUE; } } else if ( object->inherits( "QPopupMenu" ) ) { // Deactivate when a menu item is selected if ( ke->key() == Key_Enter || ke->key() == Key_Return || ke->key() == Key_Escape ) { QTimer::singleShot( 0, this, SLOT(deactivate()) ); } } else if ( object->inherits( "QMenuBar" ) ) { int dx = 0; switch ( ke->key() ) { case Key_Left: dx = -1; break; case Key_Right: dx = 1; break; } QMenuBarHack *mb = (QMenuBarHack *)object; if ( dx && mb->activeItem() >= 0 ) { int i = mb->activeItem(); int c = mb->count(); int n = c; while ( n-- ) { i = i + dx; if ( i == c ) { mb->goodbye(); moveFocus( TRUE ); return TRUE; } else if ( i < 0 ) { mb->goodbye(); moveFocus( FALSE ); return TRUE; } QMenuItem *mi = mb->findItem( mb->idAt(i) ); if ( mi->isEnabled() && !mi->isSeparator() ) { break; } } } } } if ( ke->key() == Key_F11 ) { setActive( !isActive() ); return TRUE; } } else if ( event->type() == QEvent::KeyRelease ) { QKeyEvent *ke = (QKeyEvent *)event; if ( isActive() ) { if ( object->inherits( "QButton" ) ) { // Deactivate when a button is selected if ( ke->key() == Key_Space ) QTimer::singleShot( 0, this, SLOT(deactivate()) ); } } } else if ( event->type() == QEvent::FocusIn ) { if ( isActive() ) { // A non-menu/tool widget has been selected - we're deactivated QWidget *w = (QWidget *)object; if ( !w->isPopup() && !list.contains( GuardedWidget( w ) ) ) { inFocus = 0; } } } else if ( event->type() == QEvent::Hide ) { if ( isActive() ) { // Deaticvate if a menu/tool has been hidden QWidget *w = (QWidget *)object; if ( !w->isPopup() && !list.contains( GuardedWidget( w ) ) ) { setActive( FALSE ); } } } else if ( event->type() == QEvent::ChildInserted ) { QChildEvent *ce = (QChildEvent *)event; if ( ce->child()->inherits( "QMenuBar" ) ) { addWidget( (QWidget *)ce->child() ); ce->child()->installEventFilter( this ); } else if ( object->inherits( "QToolBar" ) && ce->child()->isWidgetType() ) { addWidget( (QWidget *)ce->child() ); } } else if ( event->type() == QEvent::ChildRemoved ) { QChildEvent *ce = (QChildEvent *)event; if ( ce->child()->inherits( "QMenuBar" ) ) { removeWidget( (QWidget *)ce->child() ); ce->child()->removeEventFilter( this ); } else if ( object->inherits( "QToolBar" ) && ce->child()->isWidgetType() ) { removeWidget( (QWidget *)ce->child() ); } } return FALSE; } void QPEMenuToolFocusManager::deactivate() { setActive( FALSE ); } /*! \class QPEMenuBar qpemenubar.h \brief The QPEMenuBar class is obsolete. Use QMenuBar instead. \obsolete This class is obsolete. Use QMenuBar instead. \sa QMenuBar */ /*! Constructs a QPEMenuBar just as you would construct a QMenuBar, passing \a parent and \a name. */ QPEMenuBar::QPEMenuBar( QWidget *parent, const char *name ) : QMenuBar( parent, name ) { } /*! \reimp */ QPEMenuBar::~QPEMenuBar() { } /*! \internal */ void QPEMenuBar::keyPressEvent( QKeyEvent *e ) { QMenuBar::keyPressEvent( e ); } + +void QPEMenuBar::activateItem( int index ) +{ + activateItemAt( index ); +} + +void QPEMenuBar::goodbye() +{ + activateItemAt(-1); + for ( unsigned int i = 0; i < count(); i++ ) { + QMenuItem *mi = findItem( idAt(i) ); + if ( mi->popup() ) { + mi->popup()->hide(); + } + } +} |