author | harlekin <harlekin> | 2002-03-11 19:51:33 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-03-11 19:51:33 (UTC) |
commit | f1c93c0eb0d9599b0f5e0c0406defc2f2f6c6988 (patch) (unidiff) | |
tree | 39137a365e373fe3f50932b118308b20faf9ca08 | |
parent | 0f81c8354840d1c8e54e3b083d965e1b2489bb36 (diff) | |
download | opie-f1c93c0eb0d9599b0f5e0c0406defc2f2f6c6988.zip opie-f1c93c0eb0d9599b0f5e0c0406defc2f2f6c6988.tar.gz opie-f1c93c0eb0d9599b0f5e0c0406defc2f2f6c6988.tar.bz2 |
now opie grabs the powerkey on ipaq too, not only zaurus
-rw-r--r-- | core/launcher/desktop.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index da535d9..680cc06 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -178,128 +178,132 @@ void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | |||
178 | 178 | ||
179 | } | 179 | } |
180 | 180 | ||
181 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 181 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
182 | 182 | ||
183 | #ifdef Q_WS_QWS | 183 | #ifdef Q_WS_QWS |
184 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 184 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
185 | { | 185 | { |
186 | qpedesktop->checkMemory(); | 186 | qpedesktop->checkMemory(); |
187 | 187 | ||
188 | if ( e->type == QWSEvent::Key ) { | 188 | if ( e->type == QWSEvent::Key ) { |
189 | QWSKeyEvent *ke = (QWSKeyEvent *)e; | 189 | QWSKeyEvent *ke = (QWSKeyEvent *)e; |
190 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 190 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
191 | return TRUE; | 191 | return TRUE; |
192 | bool press = ke->simpleData.is_press; | 192 | bool press = ke->simpleData.is_press; |
193 | 193 | ||
194 | if (!keyRegisterList.isEmpty()) | 194 | if (!keyRegisterList.isEmpty()) |
195 | { | 195 | { |
196 | KeyRegisterList::Iterator it; | 196 | KeyRegisterList::Iterator it; |
197 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) | 197 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) |
198 | { | 198 | { |
199 | if ((*it).getKeyCode() == ke->simpleData.keycode) | 199 | if ((*it).getKeyCode() == ke->simpleData.keycode) |
200 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 200 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | if ( !keyboardGrabbed() ) { | 204 | if ( !keyboardGrabbed() ) { |
205 | if ( ke->simpleData.keycode == Key_F9 ) { | 205 | if ( ke->simpleData.keycode == Key_F9 ) { |
206 | if ( press ) emit datebook(); | 206 | if ( press ) emit datebook(); |
207 | return TRUE; | 207 | return TRUE; |
208 | } | 208 | } |
209 | if ( ke->simpleData.keycode == Key_F10 ) { | 209 | if ( ke->simpleData.keycode == Key_F10 ) { |
210 | if ( !press && cardSendTimer ) { | 210 | if ( !press && cardSendTimer ) { |
211 | emit contacts(); | 211 | emit contacts(); |
212 | delete cardSendTimer; | 212 | delete cardSendTimer; |
213 | } else if ( press ) { | 213 | } else if ( press ) { |
214 | cardSendTimer = new QTimer(); | 214 | cardSendTimer = new QTimer(); |
215 | cardSendTimer->start( 2000, TRUE ); | 215 | cardSendTimer->start( 2000, TRUE ); |
216 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 216 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
217 | } | 217 | } |
218 | return TRUE; | 218 | return TRUE; |
219 | } | 219 | } |
220 | /* menu key now opens application menu/toolbar | 220 | /* menu key now opens application menu/toolbar |
221 | if ( ke->simpleData.keycode == Key_F11 ) { | 221 | if ( ke->simpleData.keycode == Key_F11 ) { |
222 | if ( press ) emit menu(); | 222 | if ( press ) emit menu(); |
223 | return TRUE; | 223 | return TRUE; |
224 | } | 224 | } |
225 | */ | 225 | */ |
226 | if ( ke->simpleData.keycode == Key_F12 ) { | 226 | if ( ke->simpleData.keycode == Key_F12 ) { |
227 | while( activePopupWidget() ) | 227 | while( activePopupWidget() ) |
228 | activePopupWidget()->close(); | 228 | activePopupWidget()->close(); |
229 | if ( press ) emit launch(); | 229 | if ( press ) emit launch(); |
230 | return TRUE; | 230 | return TRUE; |
231 | } | 231 | } |
232 | if ( ke->simpleData.keycode == Key_F13 ) { | 232 | if ( ke->simpleData.keycode == Key_F13 ) { |
233 | if ( press ) emit email(); | 233 | if ( press ) emit email(); |
234 | return TRUE; | 234 | return TRUE; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
238 | if ( ke->simpleData.keycode == Key_F34 ) { | 238 | if ( ke->simpleData.keycode == Key_F34 ) { |
239 | if ( press ) emit power(); | 239 | if ( press ) emit power(); |
240 | return TRUE; | 240 | return TRUE; |
241 | } | 241 | } |
242 | if ( ke->simpleData.keycode == Key_SysReq ) { | ||
243 | if ( press ) emit power(); | ||
244 | return TRUE; | ||
245 | } | ||
242 | if ( ke->simpleData.keycode == Key_F35 ) { | 246 | if ( ke->simpleData.keycode == Key_F35 ) { |
243 | if ( press ) emit backlight(); | 247 | if ( press ) emit backlight(); |
244 | return TRUE; | 248 | return TRUE; |
245 | } | 249 | } |
246 | if ( ke->simpleData.keycode == Key_F32 ) { | 250 | if ( ke->simpleData.keycode == Key_F32 ) { |
247 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 251 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
248 | return TRUE; | 252 | return TRUE; |
249 | } | 253 | } |
250 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 254 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
251 | if ( press ) emit symbol(); | 255 | if ( press ) emit symbol(); |
252 | return TRUE; | 256 | return TRUE; |
253 | } | 257 | } |
254 | if ( ke->simpleData.keycode == Key_NumLock ) { | 258 | if ( ke->simpleData.keycode == Key_NumLock ) { |
255 | if ( press ) emit numLockStateToggle(); | 259 | if ( press ) emit numLockStateToggle(); |
256 | } | 260 | } |
257 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 261 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
258 | if ( press ) emit capsLockStateToggle(); | 262 | if ( press ) emit capsLockStateToggle(); |
259 | } | 263 | } |
260 | if ( press ) | 264 | if ( press ) |
261 | qpedesktop->keyClick(); | 265 | qpedesktop->keyClick(); |
262 | } else { | 266 | } else { |
263 | if ( e->type == QWSEvent::Mouse ) { | 267 | if ( e->type == QWSEvent::Mouse ) { |
264 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 268 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
265 | static bool up = TRUE; | 269 | static bool up = TRUE; |
266 | if ( me->simpleData.state&LeftButton ) { | 270 | if ( me->simpleData.state&LeftButton ) { |
267 | if ( up ) { | 271 | if ( up ) { |
268 | up = FALSE; | 272 | up = FALSE; |
269 | qpedesktop->screenClick(); | 273 | qpedesktop->screenClick(); |
270 | } | 274 | } |
271 | } else { | 275 | } else { |
272 | up = TRUE; | 276 | up = TRUE; |
273 | } | 277 | } |
274 | } | 278 | } |
275 | } | 279 | } |
276 | 280 | ||
277 | return QPEApplication::qwsEventFilter( e ); | 281 | return QPEApplication::qwsEventFilter( e ); |
278 | } | 282 | } |
279 | #endif | 283 | #endif |
280 | 284 | ||
281 | void DesktopApplication::psTimeout() | 285 | void DesktopApplication::psTimeout() |
282 | { | 286 | { |
283 | qpedesktop->checkMemory(); // in case no events are being generated | 287 | qpedesktop->checkMemory(); // in case no events are being generated |
284 | 288 | ||
285 | *ps = PowerStatusManager::readStatus(); | 289 | *ps = PowerStatusManager::readStatus(); |
286 | 290 | ||
287 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 291 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
288 | pa->alert( tr( "Battery is running very low." ), 6 ); | 292 | pa->alert( tr( "Battery is running very low." ), 6 ); |
289 | } | 293 | } |
290 | 294 | ||
291 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 295 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
292 | pa->alert( tr( "Battery level is critical!\n" | 296 | pa->alert( tr( "Battery level is critical!\n" |
293 | "Keep power off until power restored!" ), 1 ); | 297 | "Keep power off until power restored!" ), 1 ); |
294 | } | 298 | } |
295 | 299 | ||
296 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 300 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
297 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 301 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
298 | } | 302 | } |
299 | } | 303 | } |
300 | 304 | ||
301 | 305 | ||
302 | void DesktopApplication::sendCard() | 306 | void DesktopApplication::sendCard() |
303 | { | 307 | { |
304 | delete cardSendTimer; | 308 | delete cardSendTimer; |
305 | cardSendTimer = 0; | 309 | cardSendTimer = 0; |
@@ -491,139 +495,139 @@ void Desktop::raiseContacts() | |||
491 | 495 | ||
492 | void Desktop::raiseMenu() | 496 | void Desktop::raiseMenu() |
493 | { | 497 | { |
494 | Global::terminateBuiltin("calibrate"); | 498 | Global::terminateBuiltin("calibrate"); |
495 | tb->startMenu()->launch(); | 499 | tb->startMenu()->launch(); |
496 | } | 500 | } |
497 | 501 | ||
498 | void Desktop::raiseEmail() | 502 | void Desktop::raiseEmail() |
499 | { | 503 | { |
500 | executeOrModify("Applications/qtmail.desktop"); | 504 | executeOrModify("Applications/qtmail.desktop"); |
501 | } | 505 | } |
502 | 506 | ||
503 | // autoStarts apps on resume and start | 507 | // autoStarts apps on resume and start |
504 | void Desktop::execAutoStart() | 508 | void Desktop::execAutoStart() |
505 | { | 509 | { |
506 | QString appName; | 510 | QString appName; |
507 | Config cfg( "autostart" ); | 511 | Config cfg( "autostart" ); |
508 | cfg.setGroup( "AutoStart" ); | 512 | cfg.setGroup( "AutoStart" ); |
509 | appName = cfg.readEntry("Apps", ""); | 513 | appName = cfg.readEntry("Apps", ""); |
510 | QCopEnvelope e("QPE/System", "execute(QString)"); | 514 | QCopEnvelope e("QPE/System", "execute(QString)"); |
511 | e << QString(appName); | 515 | e << QString(appName); |
512 | } | 516 | } |
513 | 517 | ||
514 | #if defined(QPE_HAVE_TOGGLELIGHT) | 518 | #if defined(QPE_HAVE_TOGGLELIGHT) |
515 | #include <qpe/config.h> | 519 | #include <qpe/config.h> |
516 | 520 | ||
517 | #include <sys/ioctl.h> | 521 | #include <sys/ioctl.h> |
518 | #include <sys/types.h> | 522 | #include <sys/types.h> |
519 | #include <fcntl.h> | 523 | #include <fcntl.h> |
520 | #include <unistd.h> | 524 | #include <unistd.h> |
521 | #include <errno.h> | 525 | #include <errno.h> |
522 | #include <linux/ioctl.h> | 526 | #include <linux/ioctl.h> |
523 | #include <time.h> | 527 | #include <time.h> |
524 | #endif | 528 | #endif |
525 | 529 | ||
526 | static bool blanked=FALSE; | 530 | static bool blanked=FALSE; |
527 | 531 | ||
528 | static void blankScreen() | 532 | static void blankScreen() |
529 | { | 533 | { |
530 | if ( !qt_screen ) return; | 534 | if ( !qt_screen ) return; |
531 | /* Should use a big black window instead. | 535 | /* Should use a big black window instead. |
532 | QGfx* g = qt_screen->screenGfx(); | 536 | QGfx* g = qt_screen->screenGfx(); |
533 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); | 537 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); |
534 | delete g; | 538 | delete g; |
535 | */ | 539 | */ |
536 | blanked = TRUE; | 540 | blanked = TRUE; |
537 | } | 541 | } |
538 | 542 | ||
539 | static void darkScreen() | 543 | static void darkScreen() |
540 | { | 544 | { |
541 | extern void qpe_setBacklight(int); | 545 | extern void qpe_setBacklight(int); |
542 | qpe_setBacklight(0); // force off | 546 | qpe_setBacklight(0); // force off |
543 | } | 547 | } |
544 | 548 | ||
545 | 549 | ||
546 | void Desktop::togglePower() | 550 | void Desktop::togglePower() |
547 | { | 551 | { |
548 | bool wasloggedin = loggedin; | 552 | bool wasloggedin = loggedin; |
549 | loggedin=0; | 553 | loggedin=0; |
550 | darkScreen(); | 554 | darkScreen(); |
551 | if ( wasloggedin ) | 555 | if ( wasloggedin ) |
552 | blankScreen(); | 556 | blankScreen(); |
553 | 557 | ||
554 | system("apm --suspend"); | 558 | system("apm --suspend"); |
555 | execAutoStart(); | 559 | |
556 | QWSServer::screenSaverActivate( FALSE ); | 560 | QWSServer::screenSaverActivate( FALSE ); |
557 | { | 561 | { |
558 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 562 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
559 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 563 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
560 | e << -3; // Force on | 564 | e << -3; // Force on |
561 | } | 565 | } |
562 | if ( wasloggedin ) { | 566 | if ( wasloggedin ) { |
563 | login(TRUE); | 567 | login(TRUE); |
564 | } | 568 | } |
565 | 569 | execAutoStart(); | |
566 | //qcopBridge->closeOpenConnections(); | 570 | //qcopBridge->closeOpenConnections(); |
567 | //qDebug("called togglePower()!!!!!!"); | 571 | //qDebug("called togglePower()!!!!!!"); |
568 | } | 572 | } |
569 | 573 | ||
570 | void Desktop::toggleLight() | 574 | void Desktop::toggleLight() |
571 | { | 575 | { |
572 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 576 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
573 | e << -2; // toggle | 577 | e << -2; // toggle |
574 | } | 578 | } |
575 | 579 | ||
576 | void Desktop::toggleSymbolInput() | 580 | void Desktop::toggleSymbolInput() |
577 | { | 581 | { |
578 | tb->toggleSymbolInput(); | 582 | tb->toggleSymbolInput(); |
579 | } | 583 | } |
580 | 584 | ||
581 | void Desktop::toggleNumLockState() | 585 | void Desktop::toggleNumLockState() |
582 | { | 586 | { |
583 | tb->toggleNumLockState(); | 587 | tb->toggleNumLockState(); |
584 | } | 588 | } |
585 | 589 | ||
586 | void Desktop::toggleCapsLockState() | 590 | void Desktop::toggleCapsLockState() |
587 | { | 591 | { |
588 | tb->toggleCapsLockState(); | 592 | tb->toggleCapsLockState(); |
589 | } | 593 | } |
590 | 594 | ||
591 | void Desktop::styleChange( QStyle &s ) | 595 | void Desktop::styleChange( QStyle &s ) |
592 | { | 596 | { |
593 | QWidget::styleChange( s ); | 597 | QWidget::styleChange( s ); |
594 | int displayw = qApp->desktop()->width(); | 598 | int displayw = qApp->desktop()->width(); |
595 | int displayh = qApp->desktop()->height(); | 599 | int displayh = qApp->desktop()->height(); |
596 | 600 | ||
597 | QSize sz = tb->sizeHint(); | 601 | QSize sz = tb->sizeHint(); |
598 | 602 | ||
599 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 603 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
600 | } | 604 | } |
601 | 605 | ||
602 | void DesktopApplication::shutdown() | 606 | void DesktopApplication::shutdown() |
603 | { | 607 | { |
604 | if ( type() != GuiServer ) | 608 | if ( type() != GuiServer ) |
605 | return; | 609 | return; |
606 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 610 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
607 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 611 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
608 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 612 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
609 | sd->showMaximized(); | 613 | sd->showMaximized(); |
610 | } | 614 | } |
611 | 615 | ||
612 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 616 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
613 | { | 617 | { |
614 | switch ( t ) { | 618 | switch ( t ) { |
615 | case ShutdownImpl::ShutdownSystem: | 619 | case ShutdownImpl::ShutdownSystem: |
616 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); | 620 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); |
617 | break; | 621 | break; |
618 | case ShutdownImpl::RebootSystem: | 622 | case ShutdownImpl::RebootSystem: |
619 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); | 623 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); |
620 | break; | 624 | break; |
621 | case ShutdownImpl::RestartDesktop: | 625 | case ShutdownImpl::RestartDesktop: |
622 | restart(); | 626 | restart(); |
623 | break; | 627 | break; |
624 | case ShutdownImpl::TerminateDesktop: | 628 | case ShutdownImpl::TerminateDesktop: |
625 | prepareForTermination(FALSE); | 629 | prepareForTermination(FALSE); |
626 | quit(); | 630 | quit(); |
627 | break; | 631 | break; |
628 | } | 632 | } |
629 | } | 633 | } |