summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 8756d37..bf19280 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -313,500 +313,500 @@ void DesktopApplication::psTimeout()
313 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 313 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
314 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 314 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
315 } 315 }
316} 316}
317 317
318 318
319void DesktopApplication::sendCard() 319void DesktopApplication::sendCard()
320{ 320{
321 delete cardSendTimer; 321 delete cardSendTimer;
322 cardSendTimer = 0; 322 cardSendTimer = 0;
323 QString card = getenv("HOME"); 323 QString card = getenv("HOME");
324 card += "/Applications/addressbook/businesscard.vcf"; 324 card += "/Applications/addressbook/businesscard.vcf";
325 325
326 if ( QFile::exists( card ) ) { 326 if ( QFile::exists( card ) ) {
327 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 327 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
328 QString mimetype = "text/x-vCard"; 328 QString mimetype = "text/x-vCard";
329 e << tr("business card") << card << mimetype; 329 e << tr("business card") << card << mimetype;
330 } 330 }
331} 331}
332 332
333#if defined(QPE_HAVE_MEMALERTER) 333#if defined(QPE_HAVE_MEMALERTER)
334QPE_MEMALERTER_IMPL 334QPE_MEMALERTER_IMPL
335#endif 335#endif
336 336
337//=========================================================================== 337//===========================================================================
338 338
339Desktop::Desktop() : 339Desktop::Desktop() :
340 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 340 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
341 qcopBridge( 0 ), 341 qcopBridge( 0 ),
342 transferServer( 0 ), 342 transferServer( 0 ),
343 packageSlave( 0 ) 343 packageSlave( 0 )
344{ 344{
345 qpedesktop = this; 345 qpedesktop = this;
346 346
347// bg = new Info( this ); 347// bg = new Info( this );
348 tb = new TaskBar; 348 tb = new TaskBar;
349 349
350 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 350 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
351 351
352 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 352 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
353 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 353 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
354 354
355 int displayw = qApp->desktop()->width(); 355 int displayw = qApp->desktop()->width();
356 int displayh = qApp->desktop()->height(); 356 int displayh = qApp->desktop()->height();
357 357
358 358
359 QSize sz = tb->sizeHint(); 359 QSize sz = tb->sizeHint();
360 360
361 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 361 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
362 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 362 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
363 363
364 tb->show(); 364 tb->show();
365 launcher->showMaximized(); 365 launcher->showMaximized();
366 launcher->show(); 366 launcher->show();
367 launcher->raise(); 367 launcher->raise();
368#if defined(QPE_HAVE_MEMALERTER) 368#if defined(QPE_HAVE_MEMALERTER)
369 initMemalerter(); 369 initMemalerter();
370#endif 370#endif
371 // start services 371 // start services
372 startTransferServer(); 372 startTransferServer();
373 (void) new IrServer( this ); 373 (void) new IrServer( this );
374 rereadVolumes(); 374 rereadVolumes();
375 375
376 packageSlave = new PackageSlave( this ); 376 packageSlave = new PackageSlave( this );
377 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 377 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
378 378
379 qApp->installEventFilter( this ); 379 qApp->installEventFilter( this );
380} 380}
381 381
382void Desktop::show() 382void Desktop::show()
383{ 383{
384 login(TRUE); 384 login(TRUE);
385 QWidget::show(); 385 QWidget::show();
386} 386}
387 387
388Desktop::~Desktop() 388Desktop::~Desktop()
389{ 389{
390 delete launcher; 390 delete launcher;
391 delete tb; 391 delete tb;
392 delete qcopBridge; 392 delete qcopBridge;
393 delete transferServer; 393 delete transferServer;
394} 394}
395 395
396bool Desktop::recoverMemory() 396bool Desktop::recoverMemory()
397{ 397{
398 return tb->recoverMemory(); 398 return tb->recoverMemory();
399} 399}
400 400
401void Desktop::checkMemory() 401void Desktop::checkMemory()
402{ 402{
403#if defined(QPE_HAVE_MEMALERTER) 403#if defined(QPE_HAVE_MEMALERTER)
404 static bool ignoreNormal=FALSE; 404 static bool ignoreNormal=FALSE;
405 static bool existingMessage=FALSE; 405 static bool existingMessage=FALSE;
406 406
407 if(existingMessage) 407 if(existingMessage)
408 return; // don't show a second message while still on first 408 return; // don't show a second message while still on first
409 409
410 existingMessage = TRUE; 410 existingMessage = TRUE;
411 switch ( memstate ) { 411 switch ( memstate ) {
412 case Unknown: 412 case Unknown:
413 break; 413 break;
414 case Low: 414 case Low:
415 memstate = Unknown; 415 memstate = Unknown;
416 if ( recoverMemory() ) 416 if ( recoverMemory() )
417 ignoreNormal = TRUE; 417 ignoreNormal = TRUE;
418 else 418 else
419 QMessageBox::warning( 0 , "Memory Status", 419 QMessageBox::warning( 0 , "Memory Status",
420 "The memory smacks of shortage. \n" 420 "The memory smacks of shortage. \n"
421 "Please save data. " ); 421 "Please save data. " );
422 break; 422 break;
423 case Normal: 423 case Normal:
424 memstate = Unknown; 424 memstate = Unknown;
425 if ( ignoreNormal ) 425 if ( ignoreNormal )
426 ignoreNormal = FALSE; 426 ignoreNormal = FALSE;
427 else 427 else
428 QMessageBox::information ( 0 , "Memory Status", 428 QMessageBox::information ( 0 , "Memory Status",
429 "There is enough memory again." ); 429 "There is enough memory again." );
430 break; 430 break;
431 case VeryLow: 431 case VeryLow:
432 memstate = Unknown; 432 memstate = Unknown;
433 QMessageBox::critical( 0 , "Memory Status", 433 QMessageBox::critical( 0 , "Memory Status",
434 "The memory is very low. \n" 434 "The memory is very low. \n"
435 "Please end this application \n" 435 "Please end this application \n"
436 "immediately." ); 436 "immediately." );
437 recoverMemory(); 437 recoverMemory();
438 } 438 }
439 existingMessage = FALSE; 439 existingMessage = FALSE;
440#endif 440#endif
441} 441}
442 442
443static bool isVisibleWindow(int wid) 443static bool isVisibleWindow(int wid)
444{ 444{
445 const QList<QWSWindow> &list = qwsServer->clientWindows(); 445 const QList<QWSWindow> &list = qwsServer->clientWindows();
446 QWSWindow* w; 446 QWSWindow* w;
447 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 447 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
448 if ( w->winId() == wid ) 448 if ( w->winId() == wid )
449 return !w->isFullyObscured(); 449 return !w->isFullyObscured();
450 } 450 }
451 return FALSE; 451 return FALSE;
452} 452}
453 453
454static bool hasVisibleWindow(const QString& clientname) 454static bool hasVisibleWindow(const QString& clientname)
455{ 455{
456 const QList<QWSWindow> &list = qwsServer->clientWindows(); 456 const QList<QWSWindow> &list = qwsServer->clientWindows();
457 QWSWindow* w; 457 QWSWindow* w;
458 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 458 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
459 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 459 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
460 return TRUE; 460 return TRUE;
461 } 461 }
462 return FALSE; 462 return FALSE;
463} 463}
464 464
465void Desktop::raiseLauncher() 465void Desktop::raiseLauncher()
466{ 466{
467 Config cfg("qpe"); //F12 'Home' 467 Config cfg("qpe"); //F12 'Home'
468 cfg.setGroup("AppsKey"); 468 cfg.setGroup("AppsKey");
469 QString tempItem; 469 QString tempItem;
470 tempItem = cfg.readEntry("Middle","Home"); 470 tempItem = cfg.readEntry("Middle","Home");
471 if(tempItem == "Home" || tempItem.isEmpty()) { 471 if(tempItem == "Home" || tempItem.isEmpty()) {
472 if ( isVisibleWindow(launcher->winId()) ) 472 if ( isVisibleWindow(launcher->winId()) )
473 launcher->nextView(); 473 launcher->nextView();
474 else 474 else
475 launcher->raise(); 475 launcher->raise();
476 } else { 476 } else {
477 QCopEnvelope e("QPE/System","execute(QString)"); 477 QCopEnvelope e("QPE/System","execute(QString)");
478 e << tempItem; 478 e << tempItem;
479 } 479 }
480} 480}
481 481
482void Desktop::executeOrModify(const QString& appLnkFile) 482void Desktop::executeOrModify(const QString& appLnkFile)
483{ 483{
484 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 484 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
485 if ( lnk.isValid() ) { 485 if ( lnk.isValid() ) {
486 QCString app = lnk.exec().utf8(); 486 QCString app = lnk.exec().utf8();
487 Global::terminateBuiltin("calibrate"); 487 Global::terminateBuiltin("calibrate");
488 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 488 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
489 MRUList::addTask(&lnk); 489 MRUList::addTask(&lnk);
490 if ( hasVisibleWindow(app) ) 490 if ( hasVisibleWindow(app) )
491 QCopChannel::send("QPE/Application/" + app, "nextView()"); 491 QCopChannel::send("QPE/Application/" + app, "nextView()");
492 else 492 else
493 QCopChannel::send("QPE/Application/" + app, "raise()"); 493 QCopChannel::send("QPE/Application/" + app, "raise()");
494 } else { 494 } else {
495 lnk.execute(); 495 lnk.execute();
496 } 496 }
497 } 497 }
498} 498}
499 499
500void Desktop::raiseDatebook() 500void Desktop::raiseDatebook()
501{ 501{
502 Config cfg( "qpe" ); //F9 'Activity' 502 Config cfg( "qpe" ); //F9 'Activity'
503 cfg.setGroup( "AppsKey" ); 503 cfg.setGroup( "AppsKey" );
504 QString tempItem; 504 QString tempItem;
505 tempItem = cfg.readEntry( "LeftEnd" , "Calender" ); 505 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" );
506 if ( tempItem == "Calender" || tempItem.isEmpty() ) { 506 if ( tempItem == "Calendar" || tempItem.isEmpty() ) {
507 tempItem = "datebook"; 507 tempItem = "datebook";
508 } 508 }
509 QCopEnvelope e( "QPE/System", "execute(QString)" ); 509 QCopEnvelope e( "QPE/System", "execute(QString)" );
510 e << tempItem; 510 e << tempItem;
511} 511}
512 512
513void Desktop::raiseContacts() 513void Desktop::raiseContacts()
514{ 514{
515 Config cfg( "qpe" ); //F10, 'Contacts' 515 Config cfg( "qpe" ); //F10, 'Contacts'
516 cfg.setGroup( "AppsKey" ); 516 cfg.setGroup( "AppsKey" );
517 QString tempItem; 517 QString tempItem;
518 tempItem = cfg.readEntry( "Left2nd", "Address Book" ); 518 tempItem = cfg.readEntry( "Left2nd", "Address Book" );
519 if ( tempItem == "Address Book" || tempItem.isEmpty() ) { 519 if ( tempItem == "Address Book" || tempItem.isEmpty() ) {
520 tempItem = "addressbook"; 520 tempItem = "addressbook";
521 } 521 }
522 QCopEnvelope e("QPE/System","execute(QString)"); 522 QCopEnvelope e("QPE/System","execute(QString)");
523 e << tempItem; 523 e << tempItem;
524} 524}
525 525
526void Desktop::raiseMenu() 526void Desktop::raiseMenu()
527{ 527{
528 Config cfg( "qpe" ); //F11, 'Menu 528 Config cfg( "qpe" ); //F11, 'Menu
529 cfg.setGroup( "AppsKey" ); 529 cfg.setGroup( "AppsKey" );
530 QString tempItem; 530 QString tempItem;
531 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); 531 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" );
532 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { 532 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) {
533 Global::terminateBuiltin( "calibrate" ); 533 Global::terminateBuiltin( "calibrate" );
534 tb->startMenu()->launch(); 534 tb->startMenu()->launch();
535 } else { 535 } else {
536 QCopEnvelope e("QPE/System","execute(QString)"); 536 QCopEnvelope e("QPE/System","execute(QString)");
537 e << tempItem; 537 e << tempItem;
538 } 538 }
539} 539}
540 540
541void Desktop::raiseEmail() 541void Desktop::raiseEmail()
542{ 542{
543 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 543 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11
544 cfg.setGroup( "AppsKey" ); 544 cfg.setGroup( "AppsKey" );
545 QString tempItem; 545 QString tempItem;
546 tempItem = cfg.readEntry( "RightEnd", "Mail" ); 546 tempItem = cfg.readEntry( "RightEnd", "Mail" );
547 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { 547 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) {
548 tempItem = "mail"; 548 tempItem = "mail";
549 } 549 }
550 QCopEnvelope e("QPE/System","execute(QString)"); 550 QCopEnvelope e("QPE/System","execute(QString)");
551 e << tempItem; 551 e << tempItem;
552} 552}
553 553
554// autoStarts apps on resume and start 554// autoStarts apps on resume and start
555void Desktop::execAutoStart() 555void Desktop::execAutoStart()
556{ 556{
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
584static bool blanked=FALSE; 584static bool blanked=FALSE;
585 585
586static void blankScreen() 586static 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
597static void darkScreen() 597static 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
604void Desktop::togglePower() 604void 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;
617 suspendTime = QDateTime::currentDateTime(); 617 suspendTime = QDateTime::currentDateTime();
618 618
619 //qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????) 619// qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????)
620 620
621 if ( wasloggedin ) 621 if ( wasloggedin )
622 blankScreen(); 622 blankScreen();
623 623
624 ODevice::inst ( )-> suspend ( ); 624 ODevice::inst ( )-> suspend ( );
625 625
626 QWSServer::screenSaverActivate ( false ); 626 QWSServer::screenSaverActivate ( false );
627 627
628 qpe_setBacklight ( -3 ); // force LCD on 628 qpe_setBacklight ( -3 ); // force LCD on
629 629
630 { 630 {
631 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 631 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
632 } 632 }
633 633
634 if ( wasloggedin ) 634 if ( wasloggedin )
635 login(TRUE); 635 login(TRUE);
636 636
637 execAutoStart(); 637 execAutoStart();
638 //qcopBridge->closeOpenConnections(); 638 //qcopBridge->closeOpenConnections();
639 639
640 excllock = false; 640 excllock = false;
641} 641}
642 642
643void Desktop::toggleLight() 643void Desktop::toggleLight()
644{ 644{
645 QCopEnvelope e("QPE/System", "setBacklight(int)"); 645 QCopEnvelope e("QPE/System", "setBacklight(int)");
646 e << -2; // toggle 646 e << -2; // toggle
647} 647}
648 648
649void Desktop::toggleSymbolInput() 649void Desktop::toggleSymbolInput()
650{ 650{
651 tb->toggleSymbolInput(); 651 tb->toggleSymbolInput();
652} 652}
653 653
654void Desktop::toggleNumLockState() 654void Desktop::toggleNumLockState()
655{ 655{
656 tb->toggleNumLockState(); 656 tb->toggleNumLockState();
657} 657}
658 658
659void Desktop::toggleCapsLockState() 659void Desktop::toggleCapsLockState()
660{ 660{
661 tb->toggleCapsLockState(); 661 tb->toggleCapsLockState();
662} 662}
663 663
664void Desktop::styleChange( QStyle &s ) 664void Desktop::styleChange( QStyle &s )
665{ 665{
666 QWidget::styleChange( s ); 666 QWidget::styleChange( s );
667 int displayw = qApp->desktop()->width(); 667 int displayw = qApp->desktop()->width();
668 int displayh = qApp->desktop()->height(); 668 int displayh = qApp->desktop()->height();
669 669
670 QSize sz = tb->sizeHint(); 670 QSize sz = tb->sizeHint();
671 671
672 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 672 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
673} 673}
674 674
675void DesktopApplication::shutdown() 675void DesktopApplication::shutdown()
676{ 676{
677 if ( type() != GuiServer ) 677 if ( type() != GuiServer )
678 return; 678 return;
679 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 679 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
680 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 680 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
681 this, SLOT(shutdown(ShutdownImpl::Type)) ); 681 this, SLOT(shutdown(ShutdownImpl::Type)) );
682 sd->showMaximized(); 682 sd->showMaximized();
683} 683}
684 684
685void DesktopApplication::shutdown( ShutdownImpl::Type t ) 685void DesktopApplication::shutdown( ShutdownImpl::Type t )
686{ 686{
687 switch ( t ) { 687 switch ( t ) {
688 case ShutdownImpl::ShutdownSystem: 688 case ShutdownImpl::ShutdownSystem:
689 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 689 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
690 break; 690 break;
691 case ShutdownImpl::RebootSystem: 691 case ShutdownImpl::RebootSystem:
692 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 692 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
693 break; 693 break;
694 case ShutdownImpl::RestartDesktop: 694 case ShutdownImpl::RestartDesktop:
695 restart(); 695 restart();
696 break; 696 break;
697 case ShutdownImpl::TerminateDesktop: 697 case ShutdownImpl::TerminateDesktop:
698 prepareForTermination(FALSE); 698 prepareForTermination(FALSE);
699 699
700 // This is a workaround for a Qt bug 700 // This is a workaround for a Qt bug
701 // clipboard applet has to stop its poll timer, or Qt/E 701 // clipboard applet has to stop its poll timer, or Qt/E
702 // will hang on quit() right before it emits aboutToQuit() 702 // will hang on quit() right before it emits aboutToQuit()
703 emit aboutToQuit ( ); 703 emit aboutToQuit ( );
704 704
705 quit(); 705 quit();
706 break; 706 break;
707 } 707 }
708} 708}
709 709
710void DesktopApplication::restart() 710void DesktopApplication::restart()
711{ 711{
712 prepareForTermination(TRUE); 712 prepareForTermination(TRUE);
713 713
714#ifdef Q_WS_QWS 714#ifdef Q_WS_QWS
715 for ( int fd = 3; fd < 100; fd++ ) 715 for ( int fd = 3; fd < 100; fd++ )
716 close( fd ); 716 close( fd );
717#if defined(QT_DEMO_SINGLE_FLOPPY) 717#if defined(QT_DEMO_SINGLE_FLOPPY)
718 execl( "/sbin/init", "qpe", 0 ); 718 execl( "/sbin/init", "qpe", 0 );
719#elif defined(QT_QWS_CASSIOPEIA) 719#elif defined(QT_QWS_CASSIOPEIA)
720 execl( "/bin/sh", "sh", 0 ); 720 execl( "/bin/sh", "sh", 0 );
721#else 721#else
722 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 722 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
723#endif 723#endif
724 exit(1); 724 exit(1);
725#endif 725#endif
726} 726}
727 727
728void Desktop::startTransferServer() 728void Desktop::startTransferServer()
729{ 729{
730 // start qcop bridge server 730 // start qcop bridge server
731 qcopBridge = new QCopBridge( 4243 ); 731 qcopBridge = new QCopBridge( 4243 );
732 if ( !qcopBridge->ok() ) { 732 if ( !qcopBridge->ok() ) {
733 delete qcopBridge; 733 delete qcopBridge;
734 qcopBridge = 0; 734 qcopBridge = 0;
735 } 735 }
736 // start transfer server 736 // start transfer server
737 transferServer = new TransferServer( 4242 ); 737 transferServer = new TransferServer( 4242 );
738 if ( !transferServer->ok() ) { 738 if ( !transferServer->ok() ) {
739 delete transferServer; 739 delete transferServer;
740 transferServer = 0; 740 transferServer = 0;
741 } 741 }
742 if ( !transferServer || !qcopBridge ) 742 if ( !transferServer || !qcopBridge )
743 startTimer( 2000 ); 743 startTimer( 2000 );
744} 744}
745 745
746void Desktop::timerEvent( QTimerEvent *e ) 746void Desktop::timerEvent( QTimerEvent *e )
747{ 747{
748 killTimer( e->timerId() ); 748 killTimer( e->timerId() );
749 startTransferServer(); 749 startTransferServer();
750} 750}
751 751
752void Desktop::terminateServers() 752void Desktop::terminateServers()
753{ 753{
754 delete transferServer; 754 delete transferServer;
755 delete qcopBridge; 755 delete qcopBridge;
756 transferServer = 0; 756 transferServer = 0;
757 qcopBridge = 0; 757 qcopBridge = 0;
758} 758}
759 759
760void Desktop::rereadVolumes() 760void Desktop::rereadVolumes()
761{ 761{
762 Config cfg("qpe"); 762 Config cfg("qpe");
763 cfg.setGroup("Volume"); 763 cfg.setGroup("Volume");
764 touchclick = cfg.readBoolEntry("TouchSound"); 764 touchclick = cfg.readBoolEntry("TouchSound");
765 keyclick = cfg.readBoolEntry("KeySound"); 765 keyclick = cfg.readBoolEntry("KeySound");
766 alarmsound = cfg.readBoolEntry("AlarmSound"); 766 alarmsound = cfg.readBoolEntry("AlarmSound");
767} 767}
768 768
769void Desktop::keyClick() 769void Desktop::keyClick()
770{ 770{
771 if ( keyclick ) 771 if ( keyclick )
772 ODevice::inst ( )-> keySound ( ); 772 ODevice::inst ( )-> keySound ( );
773} 773}
774 774
775void Desktop::screenClick() 775void Desktop::screenClick()
776{ 776{
777 if ( touchclick ) 777 if ( touchclick )
778 ODevice::inst ( )-> touchSound ( ); 778 ODevice::inst ( )-> touchSound ( );
779} 779}
780 780
781void Desktop::soundAlarm() 781void Desktop::soundAlarm()
782{ 782{
783 if ( qpedesktop-> alarmsound ) 783 if ( qpedesktop-> alarmsound )
784 ODevice::inst ( )-> alarmSound ( ); 784 ODevice::inst ( )-> alarmSound ( );
785} 785}
786 786
787bool Desktop::eventFilter( QObject *, QEvent *ev ) 787bool Desktop::eventFilter( QObject *, QEvent *ev )
788{ 788{
789 if ( ev-> type ( ) == QEvent::KeyPress ) { 789 if ( ev-> type ( ) == QEvent::KeyPress ) {
790 QKeyEvent *ke = (QKeyEvent *) ev; 790 QKeyEvent *ke = (QKeyEvent *) ev;
791 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key 791 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key
792 QWidget *active = qApp-> activeWindow ( ); 792 QWidget *active = qApp-> activeWindow ( );
793 793
794 if ( active && active-> isPopup ( )) 794 if ( active && active-> isPopup ( ))
795 active->close(); 795 active->close();
796 796
797 /* 797 /*
798 * On iPAQ 38xx that key is not the "menu key" but the mail key 798 * On iPAQ 38xx that key is not the "menu key" but the mail key
799 * To not confuse the users, make it launch the mail app on 38xx 799 * To not confuse the users, make it launch the mail app on 38xx
800 */ 800 */
801 if (ODevice::inst()->model() == OMODEL_iPAQ_H38xx ) { 801 if (ODevice::inst()->model() == OMODEL_iPAQ_H38xx ) {
802 QCopEnvelope e( "QPE/System", "execute(QString)" ); 802 QCopEnvelope e( "QPE/System", "execute(QString)" );
803 e << QString( "mail" ); 803 e << QString( "mail" );
804 return true; 804 return true;
805 } else { 805 } else {
806 raiseMenu ( ); 806 raiseMenu ( );
807 return true; 807 return true;
808 } 808 }
809 } 809 }
810 } 810 }
811 return false; 811 return false;
812} 812}