summaryrefslogtreecommitdiff
path: root/library/qpemenubar.cpp
authorharlekin <harlekin>2002-05-30 20:31:18 (UTC)
committer harlekin <harlekin>2002-05-30 20:31:18 (UTC)
commit82f086d29f36ca631d26f8a4a70fd1e809c58364 (patch) (unidiff)
tree197cd323a7cdb868c3aa839181fcb7dbb5cab252 /library/qpemenubar.cpp
parentf4f00234985e5864229b3e95a3ac0d004c09b10d (diff)
downloadopie-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
Diffstat (limited to 'library/qpemenubar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpemenubar.cpp16
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
@@ -181,128 +181,144 @@ bool QPEMenuToolFocusManager::eventFilter( QObject *object, QEvent *event )
181 QTimer::singleShot( 0, this, SLOT(deactivate()) ); 181 QTimer::singleShot( 0, this, SLOT(deactivate()) );
182 } 182 }
183 } else if ( object->inherits( "QMenuBar" ) ) { 183 } else if ( object->inherits( "QMenuBar" ) ) {
184 int dx = 0; 184 int dx = 0;
185 switch ( ke->key() ) { 185 switch ( ke->key() ) {
186 case Key_Left: 186 case Key_Left:
187 dx = -1; 187 dx = -1;
188 break; 188 break;
189 189
190 case Key_Right: 190 case Key_Right:
191 dx = 1; 191 dx = 1;
192 break; 192 break;
193 } 193 }
194 194
195 QMenuBarHack *mb = (QMenuBarHack *)object; 195 QMenuBarHack *mb = (QMenuBarHack *)object;
196 if ( dx && mb->activeItem() >= 0 ) { 196 if ( dx && mb->activeItem() >= 0 ) {
197 int i = mb->activeItem(); 197 int i = mb->activeItem();
198 int c = mb->count(); 198 int c = mb->count();
199 int n = c; 199 int n = c;
200 while ( n-- ) { 200 while ( n-- ) {
201 i = i + dx; 201 i = i + dx;
202 if ( i == c ) { 202 if ( i == c ) {
203 mb->goodbye(); 203 mb->goodbye();
204 moveFocus( TRUE ); 204 moveFocus( TRUE );
205 return TRUE; 205 return TRUE;
206 } else if ( i < 0 ) { 206 } else if ( i < 0 ) {
207 mb->goodbye(); 207 mb->goodbye();
208 moveFocus( FALSE ); 208 moveFocus( FALSE );
209 return TRUE; 209 return TRUE;
210 } 210 }
211 QMenuItem *mi = mb->findItem( mb->idAt(i) ); 211 QMenuItem *mi = mb->findItem( mb->idAt(i) );
212 if ( mi->isEnabled() && !mi->isSeparator() ) { 212 if ( mi->isEnabled() && !mi->isSeparator() ) {
213 break; 213 break;
214 } 214 }
215 } 215 }
216 } 216 }
217 } 217 }
218 } 218 }
219 if ( ke->key() == Key_F11 ) { 219 if ( ke->key() == Key_F11 ) {
220 setActive( !isActive() ); 220 setActive( !isActive() );
221 return TRUE; 221 return TRUE;
222 } 222 }
223 } else if ( event->type() == QEvent::KeyRelease ) { 223 } else if ( event->type() == QEvent::KeyRelease ) {
224 QKeyEvent *ke = (QKeyEvent *)event; 224 QKeyEvent *ke = (QKeyEvent *)event;
225 if ( isActive() ) { 225 if ( isActive() ) {
226 if ( object->inherits( "QButton" ) ) { 226 if ( object->inherits( "QButton" ) ) {
227 // Deactivate when a button is selected 227 // Deactivate when a button is selected
228 if ( ke->key() == Key_Space ) 228 if ( ke->key() == Key_Space )
229 QTimer::singleShot( 0, this, SLOT(deactivate()) ); 229 QTimer::singleShot( 0, this, SLOT(deactivate()) );
230 } 230 }
231 } 231 }
232 } else if ( event->type() == QEvent::FocusIn ) { 232 } else if ( event->type() == QEvent::FocusIn ) {
233 if ( isActive() ) { 233 if ( isActive() ) {
234 // A non-menu/tool widget has been selected - we're deactivated 234 // A non-menu/tool widget has been selected - we're deactivated
235 QWidget *w = (QWidget *)object; 235 QWidget *w = (QWidget *)object;
236 if ( !w->isPopup() && !list.contains( GuardedWidget( w ) ) ) { 236 if ( !w->isPopup() && !list.contains( GuardedWidget( w ) ) ) {
237 inFocus = 0; 237 inFocus = 0;
238 } 238 }
239 } 239 }
240 } else if ( event->type() == QEvent::Hide ) { 240 } else if ( event->type() == QEvent::Hide ) {
241 if ( isActive() ) { 241 if ( isActive() ) {
242 // Deaticvate if a menu/tool has been hidden 242 // Deaticvate if a menu/tool has been hidden
243 QWidget *w = (QWidget *)object; 243 QWidget *w = (QWidget *)object;
244 if ( !w->isPopup() && !list.contains( GuardedWidget( w ) ) ) { 244 if ( !w->isPopup() && !list.contains( GuardedWidget( w ) ) ) {
245 setActive( FALSE ); 245 setActive( FALSE );
246 } 246 }
247 } 247 }
248 } else if ( event->type() == QEvent::ChildInserted ) { 248 } else if ( event->type() == QEvent::ChildInserted ) {
249 QChildEvent *ce = (QChildEvent *)event; 249 QChildEvent *ce = (QChildEvent *)event;
250 if ( ce->child()->inherits( "QMenuBar" ) ) { 250 if ( ce->child()->inherits( "QMenuBar" ) ) {
251 addWidget( (QWidget *)ce->child() ); 251 addWidget( (QWidget *)ce->child() );
252 ce->child()->installEventFilter( this ); 252 ce->child()->installEventFilter( this );
253 } else if ( object->inherits( "QToolBar" ) && ce->child()->isWidgetType() ) { 253 } else if ( object->inherits( "QToolBar" ) && ce->child()->isWidgetType() ) {
254 addWidget( (QWidget *)ce->child() ); 254 addWidget( (QWidget *)ce->child() );
255 } 255 }
256 } else if ( event->type() == QEvent::ChildRemoved ) { 256 } else if ( event->type() == QEvent::ChildRemoved ) {
257 QChildEvent *ce = (QChildEvent *)event; 257 QChildEvent *ce = (QChildEvent *)event;
258 if ( ce->child()->inherits( "QMenuBar" ) ) { 258 if ( ce->child()->inherits( "QMenuBar" ) ) {
259 removeWidget( (QWidget *)ce->child() ); 259 removeWidget( (QWidget *)ce->child() );
260 ce->child()->removeEventFilter( this ); 260 ce->child()->removeEventFilter( this );
261 } else if ( object->inherits( "QToolBar" ) && ce->child()->isWidgetType() ) { 261 } else if ( object->inherits( "QToolBar" ) && ce->child()->isWidgetType() ) {
262 removeWidget( (QWidget *)ce->child() ); 262 removeWidget( (QWidget *)ce->child() );
263 } 263 }
264 } 264 }
265 265
266 return FALSE; 266 return FALSE;
267} 267}
268 268
269void QPEMenuToolFocusManager::deactivate() 269void QPEMenuToolFocusManager::deactivate()
270{ 270{
271 setActive( FALSE ); 271 setActive( FALSE );
272} 272}
273 273
274/*! 274/*!
275 \class QPEMenuBar qpemenubar.h 275 \class QPEMenuBar qpemenubar.h
276 \brief The QPEMenuBar class is obsolete. Use QMenuBar instead. 276 \brief The QPEMenuBar class is obsolete. Use QMenuBar instead.
277 277
278 \obsolete 278 \obsolete
279 279
280 This class is obsolete. Use QMenuBar instead. 280 This class is obsolete. Use QMenuBar instead.
281 281
282 \sa QMenuBar 282 \sa QMenuBar
283*/ 283*/
284 284
285/*! 285/*!
286 Constructs a QPEMenuBar just as you would construct 286 Constructs a QPEMenuBar just as you would construct
287 a QMenuBar, passing \a parent and \a name. 287 a QMenuBar, passing \a parent and \a name.
288*/ 288*/
289QPEMenuBar::QPEMenuBar( QWidget *parent, const char *name ) 289QPEMenuBar::QPEMenuBar( QWidget *parent, const char *name )
290 : QMenuBar( parent, name ) 290 : QMenuBar( parent, name )
291{ 291{
292} 292}
293 293
294/*! 294/*!
295 \reimp 295 \reimp
296*/ 296*/
297QPEMenuBar::~QPEMenuBar() 297QPEMenuBar::~QPEMenuBar()
298{ 298{
299} 299}
300 300
301/*! 301/*!
302 \internal 302 \internal
303*/ 303*/
304void QPEMenuBar::keyPressEvent( QKeyEvent *e ) 304void QPEMenuBar::keyPressEvent( QKeyEvent *e )
305{ 305{
306 QMenuBar::keyPressEvent( e ); 306 QMenuBar::keyPressEvent( e );
307} 307}
308 308
309
310void QPEMenuBar::activateItem( int index )
311{
312 activateItemAt( index );
313}
314
315void QPEMenuBar::goodbye()
316{
317 activateItemAt(-1);
318 for ( unsigned int i = 0; i < count(); i++ ) {
319 QMenuItem *mi = findItem( idAt(i) );
320 if ( mi->popup() ) {
321 mi->popup()->hide();
322 }
323 }
324}