author | harlekin <harlekin> | 2002-08-29 13:18:26 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-29 13:18:26 (UTC) |
commit | 4eb76f825e6dd06252316f4fe682d6ec4c7a1a2f (patch) (unidiff) | |
tree | 037a96053aff72cc0e708f80f11570599b28c156 | |
parent | 178bd471d12a88862fb4ac1a17842ea0fd63c160 (diff) | |
download | opie-4eb76f825e6dd06252316f4fe682d6ec4c7a1a2f.zip opie-4eb76f825e6dd06252316f4fe682d6ec4c7a1a2f.tar.gz opie-4eb76f825e6dd06252316f4fe682d6ec4c7a1a2f.tar.bz2 |
fixed hardware start keys to be more flexible
-rw-r--r-- | core/launcher/desktop.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 1ec477c..5aba8dd 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -423,194 +423,194 @@ void Desktop::checkMemory() | |||
423 | break; | 423 | break; |
424 | case Normal: | 424 | case Normal: |
425 | memstate = Unknown; | 425 | memstate = Unknown; |
426 | if ( ignoreNormal ) | 426 | if ( ignoreNormal ) |
427 | ignoreNormal = FALSE; | 427 | ignoreNormal = FALSE; |
428 | else | 428 | else |
429 | QMessageBox::information ( 0 , "Memory Status", | 429 | QMessageBox::information ( 0 , "Memory Status", |
430 | "There is enough memory again." ); | 430 | "There is enough memory again." ); |
431 | break; | 431 | break; |
432 | case VeryLow: | 432 | case VeryLow: |
433 | memstate = Unknown; | 433 | memstate = Unknown; |
434 | QMessageBox::critical( 0 , "Memory Status", | 434 | QMessageBox::critical( 0 , "Memory Status", |
435 | "The memory is very low. \n" | 435 | "The memory is very low. \n" |
436 | "Please end this application \n" | 436 | "Please end this application \n" |
437 | "immediately." ); | 437 | "immediately." ); |
438 | recoverMemory(); | 438 | recoverMemory(); |
439 | } | 439 | } |
440 | existingMessage = FALSE; | 440 | existingMessage = FALSE; |
441 | #endif | 441 | #endif |
442 | } | 442 | } |
443 | 443 | ||
444 | static bool isVisibleWindow(int wid) | 444 | static bool isVisibleWindow(int wid) |
445 | { | 445 | { |
446 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 446 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
447 | QWSWindow* w; | 447 | QWSWindow* w; |
448 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 448 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
449 | if ( w->winId() == wid ) | 449 | if ( w->winId() == wid ) |
450 | return !w->isFullyObscured(); | 450 | return !w->isFullyObscured(); |
451 | } | 451 | } |
452 | return FALSE; | 452 | return FALSE; |
453 | } | 453 | } |
454 | 454 | ||
455 | static bool hasVisibleWindow(const QString& clientname) | 455 | static bool hasVisibleWindow(const QString& clientname) |
456 | { | 456 | { |
457 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 457 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
458 | QWSWindow* w; | 458 | QWSWindow* w; |
459 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 459 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
460 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) | 460 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) |
461 | return TRUE; | 461 | return TRUE; |
462 | } | 462 | } |
463 | return FALSE; | 463 | return FALSE; |
464 | } | 464 | } |
465 | 465 | ||
466 | void Desktop::raiseLauncher() | 466 | void Desktop::raiseLauncher() |
467 | { | 467 | { |
468 | Config cfg("qpe"); //F12 'Home' | 468 | Config cfg("qpe"); //F12 'Home' |
469 | cfg.setGroup("AppsKey"); | 469 | cfg.setGroup("AppsKey"); |
470 | QString tempItem; | 470 | QString tempItem; |
471 | tempItem = cfg.readEntry("Middle","Home"); | 471 | tempItem = cfg.readEntry("Middle","Home"); |
472 | if(tempItem == "Home" || tempItem.isEmpty()) { | 472 | if(tempItem == "Home" || tempItem.isEmpty()) { |
473 | if ( isVisibleWindow(launcher->winId()) ) | 473 | if ( isVisibleWindow(launcher->winId()) ) |
474 | launcher->nextView(); | 474 | launcher->nextView(); |
475 | else | 475 | else |
476 | launcher->raise(); | 476 | launcher->raise(); |
477 | } else { | 477 | } else { |
478 | QCopEnvelope e("QPE/System","execute(QString)"); | 478 | QCopEnvelope e("QPE/System","execute(QString)"); |
479 | e << tempItem; | 479 | e << tempItem; |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | void Desktop::executeOrModify(const QString& appLnkFile) | 483 | void Desktop::executeOrModify(const QString& appLnkFile) |
484 | { | 484 | { |
485 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); | 485 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); |
486 | if ( lnk.isValid() ) { | 486 | if ( lnk.isValid() ) { |
487 | QCString app = lnk.exec().utf8(); | 487 | QCString app = lnk.exec().utf8(); |
488 | Global::terminateBuiltin("calibrate"); | 488 | Global::terminateBuiltin("calibrate"); |
489 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { | 489 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { |
490 | MRUList::addTask(&lnk); | 490 | MRUList::addTask(&lnk); |
491 | if ( hasVisibleWindow(app) ) | 491 | if ( hasVisibleWindow(app) ) |
492 | QCopChannel::send("QPE/Application/" + app, "nextView()"); | 492 | QCopChannel::send("QPE/Application/" + app, "nextView()"); |
493 | else | 493 | else |
494 | QCopChannel::send("QPE/Application/" + app, "raise()"); | 494 | QCopChannel::send("QPE/Application/" + app, "raise()"); |
495 | } else { | 495 | } else { |
496 | lnk.execute(); | 496 | lnk.execute(); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | void Desktop::raiseDatebook() | 501 | void Desktop::raiseDatebook() |
502 | { | 502 | { |
503 | Config cfg("qpe"); //F9 'Activity' | 503 | Config cfg( "qpe" ); //F9 'Activity' |
504 | cfg.setGroup("AppsKey"); | 504 | cfg.setGroup( "AppsKey" ); |
505 | QString tempItem; | 505 | QString tempItem; |
506 | tempItem = cfg.readEntry("LeftEnd","Calender"); | 506 | tempItem = cfg.readEntry( "LeftEnd" , "Calender" ); |
507 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); | 507 | if ( tempItem == "Calender" || tempItem.isEmpty() ) { |
508 | else { | 508 | tempItem = "datebook"; |
509 | QCopEnvelope e("QPE/System","execute(QString)"); | ||
510 | e << tempItem; | ||
511 | } | 509 | } |
510 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
511 | e << tempItem; | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void Desktop::raiseContacts() | 514 | void Desktop::raiseContacts() |
515 | { | 515 | { |
516 | Config cfg("qpe"); //F10, 'Contacts' | 516 | Config cfg( "qpe" ); //F10, 'Contacts' |
517 | cfg.setGroup("AppsKey"); | 517 | cfg.setGroup( "AppsKey" ); |
518 | QString tempItem; | 518 | QString tempItem; |
519 | tempItem = cfg.readEntry("Left2nd","Address Book"); | 519 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
520 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); | 520 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
521 | else { | 521 | tempItem = "addressbook"; |
522 | QCopEnvelope e("QPE/System","execute(QString)"); | ||
523 | e << tempItem; | ||
524 | } | 522 | } |
523 | QCopEnvelope e("QPE/System","execute(QString)"); | ||
524 | e << tempItem; | ||
525 | } | 525 | } |
526 | 526 | ||
527 | void Desktop::raiseMenu() | 527 | void Desktop::raiseMenu() |
528 | { | 528 | { |
529 | Config cfg("qpe"); //F11, 'Menu' | 529 | Config cfg( "qpe" ); //F11, 'Menu |
530 | cfg.setGroup("AppsKey"); | 530 | cfg.setGroup( "AppsKey" ); |
531 | QString tempItem; | 531 | QString tempItem; |
532 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); | 532 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); |
533 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { | 533 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
534 | Global::terminateBuiltin("calibrate"); | 534 | Global::terminateBuiltin("calibrate"); |
535 | tb->startMenu()->launch(); | 535 | tb->startMenu()->launch(); |
536 | } else { | 536 | } else { |
537 | QCopEnvelope e("QPE/System","execute(QString)"); | 537 | QCopEnvelope e("QPE/System","execute(QString)"); |
538 | e << tempItem; | 538 | e << tempItem; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | void Desktop::raiseEmail() | 542 | void Desktop::raiseEmail() |
543 | { | 543 | { |
544 | Config cfg("qpe"); //F13, 'Mail' | 544 | Config cfg( "qpe" ); //F13, 'Mail' |
545 | cfg.setGroup("AppsKey"); | 545 | cfg.setGroup( "AppsKey" ); |
546 | QString tempItem; | 546 | QString tempItem; |
547 | tempItem = cfg.readEntry("RightEnd","Mail"); | 547 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); |
548 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); | 548 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { |
549 | else { | 549 | tempItem = "mail"; |
550 | QCopEnvelope e("QPE/System","execute(QString)"); | ||
551 | e << tempItem; | ||
552 | } | 550 | } |
551 | QCopEnvelope e("QPE/System","execute(QString)"); | ||
552 | e << tempItem; | ||
553 | } | 553 | } |
554 | 554 | ||
555 | // autoStarts apps on resume and start | 555 | // autoStarts apps on resume and start |
556 | void Desktop::execAutoStart() { | 556 | void Desktop::execAutoStart() { |
557 | QString appName; | 557 | QString appName; |
558 | int delay; | 558 | int delay; |
559 | QDateTime now = QDateTime::currentDateTime(); | 559 | QDateTime now = QDateTime::currentDateTime(); |
560 | Config cfg( "autostart" ); | 560 | Config cfg( "autostart" ); |
561 | cfg.setGroup( "AutoStart" ); | 561 | cfg.setGroup( "AutoStart" ); |
562 | appName = cfg.readEntry( "Apps", "" ); | 562 | appName = cfg.readEntry( "Apps", "" ); |
563 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 563 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
564 | // If the time between suspend and resume was longer then the | 564 | // If the time between suspend and resume was longer then the |
565 | // value saved as delay, start the app | 565 | // value saved as delay, start the app |
566 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 566 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
567 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 567 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
568 | e << QString( appName ); | 568 | e << QString( appName ); |
569 | } | 569 | } |
570 | } | 570 | } |
571 | 571 | ||
572 | #if defined(QPE_HAVE_TOGGLELIGHT) | 572 | #if defined(QPE_HAVE_TOGGLELIGHT) |
573 | #include <qpe/config.h> | 573 | #include <qpe/config.h> |
574 | 574 | ||
575 | #include <sys/ioctl.h> | 575 | #include <sys/ioctl.h> |
576 | #include <sys/types.h> | 576 | #include <sys/types.h> |
577 | #include <fcntl.h> | 577 | #include <fcntl.h> |
578 | #include <unistd.h> | 578 | #include <unistd.h> |
579 | #include <errno.h> | 579 | #include <errno.h> |
580 | #include <linux/ioctl.h> | 580 | #include <linux/ioctl.h> |
581 | #include <time.h> | 581 | #include <time.h> |
582 | #endif | 582 | #endif |
583 | 583 | ||
584 | static bool blanked=FALSE; | 584 | static bool blanked=FALSE; |
585 | 585 | ||
586 | static void blankScreen() | 586 | static void blankScreen() |
587 | { | 587 | { |
588 | if ( !qt_screen ) return; | 588 | if ( !qt_screen ) return; |
589 | /* Should use a big black window instead. | 589 | /* Should use a big black window instead. |
590 | QGfx* g = qt_screen->screenGfx(); | 590 | QGfx* g = qt_screen->screenGfx(); |
591 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); | 591 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); |
592 | delete g; | 592 | delete g; |
593 | */ | 593 | */ |
594 | blanked = TRUE; | 594 | blanked = TRUE; |
595 | } | 595 | } |
596 | 596 | ||
597 | static void darkScreen() | 597 | static void darkScreen() |
598 | { | 598 | { |
599 | extern void qpe_setBacklight(int); | 599 | extern void qpe_setBacklight(int); |
600 | qpe_setBacklight(0); // force off | 600 | qpe_setBacklight(0); // force off |
601 | } | 601 | } |
602 | 602 | ||
603 | 603 | ||
604 | void Desktop::togglePower() | 604 | void Desktop::togglePower() |
605 | { | 605 | { |
606 | extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop | 606 | extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop |
607 | 607 | ||
608 | static bool excllock = false; | 608 | static bool excllock = false; |
609 | 609 | ||
610 | if ( excllock ) | 610 | if ( excllock ) |
611 | return; | 611 | return; |
612 | 612 | ||
613 | excllock = true; | 613 | excllock = true; |
614 | 614 | ||
615 | bool wasloggedin = loggedin; | 615 | bool wasloggedin = loggedin; |
616 | loggedin=0; | 616 | loggedin=0; |