author | llornkcor <llornkcor> | 2002-10-20 23:00:49 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-20 23:00:49 (UTC) |
commit | 8bbd3bca858939b15b8775b4811149b8d83bb6cc (patch) (unidiff) | |
tree | 3ec2f82cf31c49debdf46f21746c71c0d69ec1db | |
parent | 706b3e155ad713f388606b4ae15c70a2be4c2294 (diff) | |
download | opie-8bbd3bca858939b15b8775b4811149b8d83bb6cc.zip opie-8bbd3bca858939b15b8775b4811149b8d83bb6cc.tar.gz opie-8bbd3bca858939b15b8775b4811149b8d83bb6cc.tar.bz2 |
better implementation of F11 menu handling
-rw-r--r-- | core/launcher/desktop.cpp | 23 | ||||
-rw-r--r-- | core/launcher/desktop.h | 1 |
2 files changed, 20 insertions, 4 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 9863187..387650b 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -415,132 +415,132 @@ void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & | |||
415 | } | 415 | } |
416 | else if ( msg == "setDisplayState(int)" ) { | 416 | else if ( msg == "setDisplayState(int)" ) { |
417 | int state; | 417 | int state; |
418 | stream >> state; | 418 | stream >> state; |
419 | m_screensaver-> setDisplayState ( state != 0 ); | 419 | m_screensaver-> setDisplayState ( state != 0 ); |
420 | } | 420 | } |
421 | else if ( msg == "suspend()" ) { | 421 | else if ( msg == "suspend()" ) { |
422 | emit power(); | 422 | emit power(); |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 426 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
427 | 427 | ||
428 | #ifdef Q_WS_QWS | 428 | #ifdef Q_WS_QWS |
429 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 429 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
430 | { | 430 | { |
431 | qpedesktop->checkMemory(); | 431 | qpedesktop->checkMemory(); |
432 | 432 | ||
433 | if ( e->type == QWSEvent::Key ) { | 433 | if ( e->type == QWSEvent::Key ) { |
434 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 434 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
435 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 435 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
436 | return TRUE; | 436 | return TRUE; |
437 | bool press = ke->simpleData.is_press; | 437 | bool press = ke->simpleData.is_press; |
438 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 438 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
439 | 439 | ||
440 | /* | 440 | /* |
441 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 441 | app that registers key/message to be sent back to the app, when it doesn't have focus, |
442 | when user presses key, unless keyboard has been requested from app. | 442 | when user presses key, unless keyboard has been requested from app. |
443 | will not send multiple repeats if user holds key | 443 | will not send multiple repeats if user holds key |
444 | i.e. one shot | 444 | i.e. one shot |
445 | */ | 445 | */ |
446 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { | 446 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { |
447 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); | 447 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); |
448 | KeyRegisterList::Iterator it; | 448 | KeyRegisterList::Iterator it; |
449 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 449 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
450 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { | 450 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { |
451 | if ( press ) | 451 | if ( press ) |
452 | qDebug( "press" ); | 452 | qDebug( "press" ); |
453 | else | 453 | else |
454 | qDebug( "release" ); | 454 | qDebug( "release" ); |
455 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); | 455 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | if ( !keyboardGrabbed() ) { | 460 | if ( !keyboardGrabbed() ) { |
461 | if ( ke->simpleData.keycode == Key_F9 ) { | 461 | if ( ke->simpleData.keycode == Key_F9 ) { |
462 | if ( press ) | 462 | if ( press ) |
463 | emit datebook(); | 463 | emit datebook(); |
464 | return TRUE; | 464 | return TRUE; |
465 | } | 465 | } |
466 | if ( ke->simpleData.keycode == Key_F10 ) { | 466 | if ( ke->simpleData.keycode == Key_F10 ) { |
467 | if ( !press && cardSendTimer ) { | 467 | if ( !press && cardSendTimer ) { |
468 | emit contacts(); | 468 | emit contacts(); |
469 | delete cardSendTimer; | 469 | delete cardSendTimer; |
470 | } | 470 | } |
471 | else if ( press ) { | 471 | else if ( press ) { |
472 | cardSendTimer = new QTimer(); | 472 | cardSendTimer = new QTimer(); |
473 | cardSendTimer->start( 2000, TRUE ); | 473 | cardSendTimer->start( 2000, TRUE ); |
474 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 474 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
475 | } | 475 | } |
476 | return TRUE; | 476 | return TRUE; |
477 | } | 477 | } |
478 | // menu key now opens application menu/toolbar | 478 | // menu key now opens application menu/toolbar |
479 | if ( ke->simpleData.keycode == Key_F11 ) { | 479 | // if ( ke->simpleData.keycode == Key_F11 ) { |
480 | if ( press ) emit menu(); | 480 | // if ( press ) emit menu(); |
481 | return TRUE; | 481 | // return TRUE; |
482 | } | 482 | // } |
483 | 483 | ||
484 | if ( ke->simpleData.keycode == Key_F12 ) { | 484 | if ( ke->simpleData.keycode == Key_F12 ) { |
485 | while ( activePopupWidget() ) | 485 | while ( activePopupWidget() ) |
486 | activePopupWidget() ->close(); | 486 | activePopupWidget() ->close(); |
487 | if ( press ) | 487 | if ( press ) |
488 | emit launch(); | 488 | emit launch(); |
489 | return TRUE; | 489 | return TRUE; |
490 | } | 490 | } |
491 | if ( ke->simpleData.keycode == Key_F13 ) { | 491 | if ( ke->simpleData.keycode == Key_F13 ) { |
492 | if ( press ) | 492 | if ( press ) |
493 | emit email(); | 493 | emit email(); |
494 | return TRUE; | 494 | return TRUE; |
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | if ( ke->simpleData.keycode == Key_F34 ) { | 498 | if ( ke->simpleData.keycode == Key_F34 ) { |
499 | if ( press ) | 499 | if ( press ) |
500 | emit power(); | 500 | emit power(); |
501 | return TRUE; | 501 | return TRUE; |
502 | } | 502 | } |
503 | // This was used for the iPAQ PowerButton | 503 | // This was used for the iPAQ PowerButton |
504 | // See main.cpp for new KeyboardFilter | 504 | // See main.cpp for new KeyboardFilter |
505 | // | 505 | // |
506 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 506 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
507 | // if ( press ) emit power(); | 507 | // if ( press ) emit power(); |
508 | // return TRUE; | 508 | // return TRUE; |
509 | // } | 509 | // } |
510 | if ( ke->simpleData.keycode == Key_F35 ) { | 510 | if ( ke->simpleData.keycode == Key_F35 ) { |
511 | if ( press ) | 511 | if ( press ) |
512 | emit backlight(); | 512 | emit backlight(); |
513 | return TRUE; | 513 | return TRUE; |
514 | } | 514 | } |
515 | if ( ke->simpleData.keycode == Key_F32 ) { | 515 | if ( ke->simpleData.keycode == Key_F32 ) { |
516 | if ( press ) | 516 | if ( press ) |
517 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 517 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
518 | return TRUE; | 518 | return TRUE; |
519 | } | 519 | } |
520 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 520 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
521 | if ( press ) | 521 | if ( press ) |
522 | emit symbol(); | 522 | emit symbol(); |
523 | return TRUE; | 523 | return TRUE; |
524 | } | 524 | } |
525 | if ( ke->simpleData.keycode == Key_NumLock ) { | 525 | if ( ke->simpleData.keycode == Key_NumLock ) { |
526 | if ( press ) | 526 | if ( press ) |
527 | emit numLockStateToggle(); | 527 | emit numLockStateToggle(); |
528 | } | 528 | } |
529 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 529 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
530 | if ( press ) | 530 | if ( press ) |
531 | emit capsLockStateToggle(); | 531 | emit capsLockStateToggle(); |
532 | } | 532 | } |
533 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | 533 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) |
534 | qpedesktop->keyClick(); | 534 | qpedesktop->keyClick(); |
535 | } | 535 | } |
536 | else { | 536 | else { |
537 | if ( e->type == QWSEvent::Mouse ) { | 537 | if ( e->type == QWSEvent::Mouse ) { |
538 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 538 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
539 | static bool up = TRUE; | 539 | static bool up = TRUE; |
540 | if ( me->simpleData.state & LeftButton ) { | 540 | if ( me->simpleData.state & LeftButton ) { |
541 | if ( up ) { | 541 | if ( up ) { |
542 | up = FALSE; | 542 | up = FALSE; |
543 | qpedesktop->screenClick(); | 543 | qpedesktop->screenClick(); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | else { | 546 | else { |
@@ -986,64 +986,79 @@ void DesktopApplication::restart() | |||
986 | 986 | ||
987 | exit( 1 ); | 987 | exit( 1 ); |
988 | #endif | 988 | #endif |
989 | } | 989 | } |
990 | 990 | ||
991 | void Desktop::startTransferServer() | 991 | void Desktop::startTransferServer() |
992 | { | 992 | { |
993 | // start qcop bridge server | 993 | // start qcop bridge server |
994 | qcopBridge = new QCopBridge( 4243 ); | 994 | qcopBridge = new QCopBridge( 4243 ); |
995 | if ( !qcopBridge->ok() ) { | 995 | if ( !qcopBridge->ok() ) { |
996 | delete qcopBridge; | 996 | delete qcopBridge; |
997 | qcopBridge = 0; | 997 | qcopBridge = 0; |
998 | } | 998 | } |
999 | // start transfer server | 999 | // start transfer server |
1000 | transferServer = new TransferServer( 4242 ); | 1000 | transferServer = new TransferServer( 4242 ); |
1001 | if ( !transferServer->ok() ) { | 1001 | if ( !transferServer->ok() ) { |
1002 | delete transferServer; | 1002 | delete transferServer; |
1003 | transferServer = 0; | 1003 | transferServer = 0; |
1004 | } | 1004 | } |
1005 | if ( !transferServer || !qcopBridge ) | 1005 | if ( !transferServer || !qcopBridge ) |
1006 | startTimer( 2000 ); | 1006 | startTimer( 2000 ); |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void Desktop::timerEvent( QTimerEvent *e ) | 1009 | void Desktop::timerEvent( QTimerEvent *e ) |
1010 | { | 1010 | { |
1011 | killTimer( e->timerId() ); | 1011 | killTimer( e->timerId() ); |
1012 | startTransferServer(); | 1012 | startTransferServer(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | void Desktop::terminateServers() | 1015 | void Desktop::terminateServers() |
1016 | { | 1016 | { |
1017 | delete transferServer; | 1017 | delete transferServer; |
1018 | delete qcopBridge; | 1018 | delete qcopBridge; |
1019 | transferServer = 0; | 1019 | transferServer = 0; |
1020 | qcopBridge = 0; | 1020 | qcopBridge = 0; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void Desktop::rereadVolumes() | 1023 | void Desktop::rereadVolumes() |
1024 | { | 1024 | { |
1025 | Config cfg( "qpe" ); | 1025 | Config cfg( "qpe" ); |
1026 | cfg.setGroup( "Volume" ); | 1026 | cfg.setGroup( "Volume" ); |
1027 | touchclick = cfg.readBoolEntry( "TouchSound" ); | 1027 | touchclick = cfg.readBoolEntry( "TouchSound" ); |
1028 | keyclick = cfg.readBoolEntry( "KeySound" ); | 1028 | keyclick = cfg.readBoolEntry( "KeySound" ); |
1029 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); | 1029 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | void Desktop::keyClick() | 1032 | void Desktop::keyClick() |
1033 | { | 1033 | { |
1034 | if ( keyclick ) | 1034 | if ( keyclick ) |
1035 | ODevice::inst ( ) -> keySound ( ); | 1035 | ODevice::inst ( ) -> keySound ( ); |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | void Desktop::screenClick() | 1038 | void Desktop::screenClick() |
1039 | { | 1039 | { |
1040 | if ( touchclick ) | 1040 | if ( touchclick ) |
1041 | ODevice::inst ( ) -> touchSound ( ); | 1041 | ODevice::inst ( ) -> touchSound ( ); |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | void Desktop::soundAlarm() | 1044 | void Desktop::soundAlarm() |
1045 | { | 1045 | { |
1046 | if ( qpedesktop-> alarmsound ) | 1046 | if ( qpedesktop-> alarmsound ) |
1047 | ODevice::inst ( ) -> alarmSound ( ); | 1047 | ODevice::inst ( ) -> alarmSound ( ); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | ||
1051 | { | ||
1052 | if ( ev->type() == QEvent::KeyPress ) { | ||
1053 | QKeyEvent *ke = (QKeyEvent *)ev; | ||
1054 | if ( ke->key() == Qt::Key_F11 ) { // menu key | ||
1055 | QWidget *active = qApp->activeWindow(); | ||
1056 | if ( active && active->isPopup() ) { | ||
1057 | active->close(); | ||
1058 | } | ||
1059 | raiseMenu(); | ||
1060 | return TRUE; | ||
1061 | } | ||
1062 | } | ||
1063 | return FALSE; | ||
1064 | } | ||
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index 5de85f4..04c2f61 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -64,84 +64,85 @@ signals: | |||
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | #ifdef Q_WS_QWS | 66 | #ifdef Q_WS_QWS |
67 | 67 | ||
68 | bool qwsEventFilter( QWSEvent * ); | 68 | bool qwsEventFilter( QWSEvent * ); |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | void shutdown(); | 71 | void shutdown(); |
72 | void restart(); | 72 | void restart(); |
73 | 73 | ||
74 | public slots: | 74 | public slots: |
75 | virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); | 75 | virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); |
76 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); | 76 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); |
77 | 77 | ||
78 | protected slots: | 78 | protected slots: |
79 | void shutdown( ShutdownImpl::Type ); | 79 | void shutdown( ShutdownImpl::Type ); |
80 | void psTimeout(); | 80 | void psTimeout(); |
81 | void sendCard(); | 81 | void sendCard(); |
82 | private: | 82 | private: |
83 | DesktopPowerAlerter *pa; | 83 | DesktopPowerAlerter *pa; |
84 | PowerStatus *ps; | 84 | PowerStatus *ps; |
85 | QTimer *cardSendTimer; | 85 | QTimer *cardSendTimer; |
86 | QCopChannel *channel; | 86 | QCopChannel *channel; |
87 | QPEScreenSaver *m_screensaver; | 87 | QPEScreenSaver *m_screensaver; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | class Desktop : public QWidget | 91 | class Desktop : public QWidget |
92 | { | 92 | { |
93 | Q_OBJECT | 93 | Q_OBJECT |
94 | public: | 94 | public: |
95 | Desktop(); | 95 | Desktop(); |
96 | ~Desktop(); | 96 | ~Desktop(); |
97 | 97 | ||
98 | static bool screenLocked(); | 98 | static bool screenLocked(); |
99 | 99 | ||
100 | void show(); | 100 | void show(); |
101 | void checkMemory(); | 101 | void checkMemory(); |
102 | 102 | ||
103 | void keyClick(); | 103 | void keyClick(); |
104 | void screenClick(); | 104 | void screenClick(); |
105 | static void soundAlarm(); | 105 | static void soundAlarm(); |
106 | 106 | ||
107 | public slots: | 107 | public slots: |
108 | void raiseDatebook(); | 108 | void raiseDatebook(); |
109 | void raiseContacts(); | 109 | void raiseContacts(); |
110 | void raiseMenu(); | 110 | void raiseMenu(); |
111 | void raiseLauncher(); | 111 | void raiseLauncher(); |
112 | void raiseEmail(); | 112 | void raiseEmail(); |
113 | void execAutoStart(); | 113 | void execAutoStart(); |
114 | void togglePower(); | 114 | void togglePower(); |
115 | void toggleLight(); | 115 | void toggleLight(); |
116 | void toggleNumLockState(); | 116 | void toggleNumLockState(); |
117 | void toggleCapsLockState(); | 117 | void toggleCapsLockState(); |
118 | void toggleSymbolInput(); | 118 | void toggleSymbolInput(); |
119 | void terminateServers(); | 119 | void terminateServers(); |
120 | void rereadVolumes(); | 120 | void rereadVolumes(); |
121 | 121 | ||
122 | void home ( ); | 122 | void home ( ); |
123 | 123 | ||
124 | protected: | 124 | protected: |
125 | void executeOrModify( const QString& appLnkFile ); | 125 | void executeOrModify( const QString& appLnkFile ); |
126 | void styleChange( QStyle & ); | 126 | void styleChange( QStyle & ); |
127 | void timerEvent( QTimerEvent *e ); | 127 | void timerEvent( QTimerEvent *e ); |
128 | bool eventFilter( QObject *, QEvent * ); | ||
128 | 129 | ||
129 | QWidget *bg; | 130 | QWidget *bg; |
130 | Launcher *launcher; | 131 | Launcher *launcher; |
131 | TaskBar *tb; | 132 | TaskBar *tb; |
132 | 133 | ||
133 | private: | 134 | private: |
134 | void startTransferServer(); | 135 | void startTransferServer(); |
135 | bool recoverMemory(); | 136 | bool recoverMemory(); |
136 | 137 | ||
137 | QCopBridge *qcopBridge; | 138 | QCopBridge *qcopBridge; |
138 | TransferServer *transferServer; | 139 | TransferServer *transferServer; |
139 | PackageSlave *packageSlave; | 140 | PackageSlave *packageSlave; |
140 | 141 | ||
141 | QDateTime suspendTime; | 142 | QDateTime suspendTime; |
142 | bool keyclick, touchclick, alarmsound; | 143 | bool keyclick, touchclick, alarmsound; |
143 | }; | 144 | }; |
144 | 145 | ||
145 | 146 | ||
146 | #endif // __DESKTOP_H__ | 147 | #endif // __DESKTOP_H__ |
147 | 148 | ||