summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-20 23:00:49 (UTC)
committer llornkcor <llornkcor>2002-10-20 23:00:49 (UTC)
commit8bbd3bca858939b15b8775b4811149b8d83bb6cc (patch) (unidiff)
tree3ec2f82cf31c49debdf46f21746c71c0d69ec1db
parent706b3e155ad713f388606b4ae15c70a2be4c2294 (diff)
downloadopie-8bbd3bca858939b15b8775b4811149b8d83bb6cc.zip
opie-8bbd3bca858939b15b8775b4811149b8d83bb6cc.tar.gz
opie-8bbd3bca858939b15b8775b4811149b8d83bb6cc.tar.bz2
better implementation of F11 menu handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp23
-rw-r--r--core/launcher/desktop.h1
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
@@ -287,388 +287,388 @@ public:
287 // Forced on 287 // Forced on
288 m_backlight_forcedoff = false; 288 m_backlight_forcedoff = false;
289 bright = -1; 289 bright = -1;
290 } 290 }
291 if ( m_backlight_forcedoff && bright != -2 ) 291 if ( m_backlight_forcedoff && bright != -2 )
292 return ; 292 return ;
293 if ( bright == -2 ) { 293 if ( bright == -2 ) {
294 // Toggle between off and on 294 // Toggle between off and on
295 bright = m_backlight_bright ? 0 : -1; 295 bright = m_backlight_bright ? 0 : -1;
296 m_backlight_forcedoff = !bright; 296 m_backlight_forcedoff = !bright;
297 } 297 }
298 298
299 m_backlight_bright = bright; 299 m_backlight_bright = bright;
300 300
301 bright = backlight ( ); 301 bright = backlight ( );
302 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 302 ODevice::inst ( ) -> setDisplayBrightness ( bright );
303 303
304 m_backlight_bright = bright; 304 m_backlight_bright = bright;
305 } 305 }
306 306
307 void setDisplayState ( bool on ) 307 void setDisplayState ( bool on )
308 { 308 {
309 if ( m_lcd_status != on ) { 309 if ( m_lcd_status != on ) {
310 ODevice::inst ( ) -> setDisplayStatus ( on ); 310 ODevice::inst ( ) -> setDisplayStatus ( on );
311 m_lcd_status = on; 311 m_lcd_status = on;
312 } 312 }
313 } 313 }
314 314
315private: 315private:
316 int m_disable_suspend; 316 int m_disable_suspend;
317 bool m_enable_dim; 317 bool m_enable_dim;
318 bool m_enable_lightoff; 318 bool m_enable_lightoff;
319 bool m_enable_onlylcdoff; 319 bool m_enable_onlylcdoff;
320 320
321 bool m_lcd_status; 321 bool m_lcd_status;
322 322
323 int m_backlight_bright; 323 int m_backlight_bright;
324 bool m_backlight_forcedoff; 324 bool m_backlight_forcedoff;
325}; 325};
326 326
327void DesktopApplication::switchLCD ( bool on ) 327void DesktopApplication::switchLCD ( bool on )
328{ 328{
329 if ( qApp ) { 329 if ( qApp ) {
330 DesktopApplication *dapp = (DesktopApplication *) qApp; 330 DesktopApplication *dapp = (DesktopApplication *) qApp;
331 331
332 if ( dapp-> m_screensaver ) { 332 if ( dapp-> m_screensaver ) {
333 if ( on ) { 333 if ( on ) {
334 dapp-> m_screensaver-> setDisplayState ( true ); 334 dapp-> m_screensaver-> setDisplayState ( true );
335 dapp-> m_screensaver-> setBacklight ( -3 ); 335 dapp-> m_screensaver-> setBacklight ( -3 );
336 } 336 }
337 else { 337 else {
338 dapp-> m_screensaver-> setDisplayState ( false ); 338 dapp-> m_screensaver-> setDisplayState ( false );
339 } 339 }
340 } 340 }
341 } 341 }
342} 342}
343 343
344 344
345DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 345DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
346 : QPEApplication( argc, argv, appType ) 346 : QPEApplication( argc, argv, appType )
347{ 347{
348 348
349 QTimer * t = new QTimer( this ); 349 QTimer * t = new QTimer( this );
350 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); 350 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) );
351 t->start( 10000 ); 351 t->start( 10000 );
352 ps = new PowerStatus; 352 ps = new PowerStatus;
353 pa = new DesktopPowerAlerter( 0 ); 353 pa = new DesktopPowerAlerter( 0 );
354 354
355 channel = new QCopChannel( "QPE/Desktop", this ); 355 channel = new QCopChannel( "QPE/Desktop", this );
356 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 356 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
357 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 357 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
358 358
359 channel = new QCopChannel( "QPE/System", this ); 359 channel = new QCopChannel( "QPE/System", this );
360 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 360 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
361 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 361 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
362 362
363 m_screensaver = new QPEScreenSaver; 363 m_screensaver = new QPEScreenSaver;
364 364
365 m_screensaver-> setInterval ( -1 ); 365 m_screensaver-> setInterval ( -1 );
366 QWSServer::setScreenSaver( m_screensaver ); 366 QWSServer::setScreenSaver( m_screensaver );
367} 367}
368 368
369 369
370DesktopApplication::~DesktopApplication() 370DesktopApplication::~DesktopApplication()
371{ 371{
372 delete ps; 372 delete ps;
373 delete pa; 373 delete pa;
374} 374}
375 375
376void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) 376void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
377{ 377{
378 QDataStream stream( data, IO_ReadOnly ); 378 QDataStream stream( data, IO_ReadOnly );
379 if ( msg == "keyRegister(int key, QString channel, QString message)" ) { 379 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
380 int k; 380 int k;
381 QString c, m; 381 QString c, m;
382 stream >> k; 382 stream >> k;
383 stream >> c; 383 stream >> c;
384 stream >> m; 384 stream >> m;
385 385
386 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); 386 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
387 keyRegisterList.append( QCopKeyRegister( k, c, m ) ); 387 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
388 } 388 }
389} 389}
390 390
391 391
392void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 392void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
393{ 393{
394 QDataStream stream ( data, IO_ReadOnly ); 394 QDataStream stream ( data, IO_ReadOnly );
395 395
396 if ( msg == "setScreenSaverInterval(int)" ) { 396 if ( msg == "setScreenSaverInterval(int)" ) {
397 int time; 397 int time;
398 stream >> time; 398 stream >> time;
399 m_screensaver-> setInterval( time ); 399 m_screensaver-> setInterval( time );
400 } 400 }
401 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 401 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
402 int t1, t2, t3; 402 int t1, t2, t3;
403 stream >> t1 >> t2 >> t3; 403 stream >> t1 >> t2 >> t3;
404 m_screensaver-> setIntervals( t1, t2, t3 ); 404 m_screensaver-> setIntervals( t1, t2, t3 );
405 } 405 }
406 else if ( msg == "setBacklight(int)" ) { 406 else if ( msg == "setBacklight(int)" ) {
407 int bright; 407 int bright;
408 stream >> bright; 408 stream >> bright;
409 m_screensaver-> setBacklight( bright ); 409 m_screensaver-> setBacklight( bright );
410 } 410 }
411 else if ( msg == "setScreenSaverMode(int)" ) { 411 else if ( msg == "setScreenSaverMode(int)" ) {
412 int mode; 412 int mode;
413 stream >> mode; 413 stream >> mode;
414 m_screensaver-> setMode ( mode ); 414 m_screensaver-> setMode ( mode );
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
426enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 426enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
427 427
428#ifdef Q_WS_QWS 428#ifdef Q_WS_QWS
429bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 429bool 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 {
547 up = TRUE; 547 up = TRUE;
548 } 548 }
549 } 549 }
550 } 550 }
551 551
552 return QPEApplication::qwsEventFilter( e ); 552 return QPEApplication::qwsEventFilter( e );
553} 553}
554#endif 554#endif
555 555
556void DesktopApplication::psTimeout() 556void DesktopApplication::psTimeout()
557{ 557{
558 qpedesktop->checkMemory(); // in case no events are being generated 558 qpedesktop->checkMemory(); // in case no events are being generated
559 559
560 *ps = PowerStatusManager::readStatus(); 560 *ps = PowerStatusManager::readStatus();
561 561
562 if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { 562 if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) {
563 pa->alert( tr( "Battery is running very low." ), 6 ); 563 pa->alert( tr( "Battery is running very low." ), 6 );
564 } 564 }
565 565
566 if ( ps->batteryStatus() == PowerStatus::Critical ) { 566 if ( ps->batteryStatus() == PowerStatus::Critical ) {
567 pa->alert( tr( "Battery level is critical!\n" 567 pa->alert( tr( "Battery level is critical!\n"
568 "Keep power off until power restored!" ), 1 ); 568 "Keep power off until power restored!" ), 1 );
569 } 569 }
570 570
571 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 571 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
572 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 572 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
573 } 573 }
574} 574}
575 575
576 576
577void DesktopApplication::sendCard() 577void DesktopApplication::sendCard()
578{ 578{
579 delete cardSendTimer; 579 delete cardSendTimer;
580 cardSendTimer = 0; 580 cardSendTimer = 0;
581 QString card = getenv( "HOME" ); 581 QString card = getenv( "HOME" );
582 card += "/Applications/addressbook/businesscard.vcf"; 582 card += "/Applications/addressbook/businesscard.vcf";
583 583
584 if ( QFile::exists( card ) ) { 584 if ( QFile::exists( card ) ) {
585 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); 585 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" );
586 QString mimetype = "text/x-vCard"; 586 QString mimetype = "text/x-vCard";
587 e << tr( "business card" ) << card << mimetype; 587 e << tr( "business card" ) << card << mimetype;
588 } 588 }
589} 589}
590 590
591#if defined(QPE_HAVE_MEMALERTER) 591#if defined(QPE_HAVE_MEMALERTER)
592QPE_MEMALERTER_IMPL 592QPE_MEMALERTER_IMPL
593#endif 593#endif
594 594
595//=========================================================================== 595//===========================================================================
596 596
597Desktop::Desktop() : 597Desktop::Desktop() :
598 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 598 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
599 qcopBridge( 0 ), 599 qcopBridge( 0 ),
600 transferServer( 0 ), 600 transferServer( 0 ),
601 packageSlave( 0 ) 601 packageSlave( 0 )
602{ 602{
603 qpedesktop = this; 603 qpedesktop = this;
604 604
605 // bg = new Info( this ); 605 // bg = new Info( this );
606 tb = new TaskBar; 606 tb = new TaskBar;
607 607
608 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 608 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
609 609
610 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); 610 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
611 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); 611 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
612 612
613 int displayw = qApp->desktop() ->width(); 613 int displayw = qApp->desktop() ->width();
614 int displayh = qApp->desktop() ->height(); 614 int displayh = qApp->desktop() ->height();
615 615
616 616
617 QSize sz = tb->sizeHint(); 617 QSize sz = tb->sizeHint();
618 618
619 setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 619 setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
620 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 620 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
621 621
622 tb->show(); 622 tb->show();
623 launcher->showMaximized(); 623 launcher->showMaximized();
624 launcher->show(); 624 launcher->show();
625 launcher->raise(); 625 launcher->raise();
626#if defined(QPE_HAVE_MEMALERTER) 626#if defined(QPE_HAVE_MEMALERTER)
627 627
628 initMemalerter(); 628 initMemalerter();
629#endif 629#endif
630 // start services 630 // start services
631 startTransferServer(); 631 startTransferServer();
632 ( void ) new IrServer( this ); 632 ( void ) new IrServer( this );
633 rereadVolumes(); 633 rereadVolumes();
634 634
635 packageSlave = new PackageSlave( this ); 635 packageSlave = new PackageSlave( this );
636 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); 636 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
637 637
638 qApp->installEventFilter( this ); 638 qApp->installEventFilter( this );
639 639
640 qApp-> setMainWidget ( launcher ); 640 qApp-> setMainWidget ( launcher );
641} 641}
642 642
643void Desktop::show() 643void Desktop::show()
644{ 644{
645 login( TRUE ); 645 login( TRUE );
646 QWidget::show(); 646 QWidget::show();
647} 647}
648 648
649Desktop::~Desktop() 649Desktop::~Desktop()
650{ 650{
651 delete launcher; 651 delete launcher;
652 delete tb; 652 delete tb;
653 delete qcopBridge; 653 delete qcopBridge;
654 delete transferServer; 654 delete transferServer;
655} 655}
656 656
657bool Desktop::recoverMemory() 657bool Desktop::recoverMemory()
658{ 658{
659 return tb->recoverMemory(); 659 return tb->recoverMemory();
660} 660}
661 661
662void Desktop::checkMemory() 662void Desktop::checkMemory()
663{ 663{
664#if defined(QPE_HAVE_MEMALERTER) 664#if defined(QPE_HAVE_MEMALERTER)
665 static bool ignoreNormal = FALSE; 665 static bool ignoreNormal = FALSE;
666 static bool existingMessage = FALSE; 666 static bool existingMessage = FALSE;
667 667
668 if ( existingMessage ) 668 if ( existingMessage )
669 return ; // don't show a second message while still on first 669 return ; // don't show a second message while still on first
670 670
671 existingMessage = TRUE; 671 existingMessage = TRUE;
672 switch ( memstate ) { 672 switch ( memstate ) {
673 case Unknown: 673 case Unknown:
674 break; 674 break;
@@ -858,192 +858,207 @@ void Desktop::execAutoStart()
858void Desktop::togglePower() 858void Desktop::togglePower()
859{ 859{
860 static bool excllock = false; 860 static bool excllock = false;
861 861
862 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); 862 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 );
863 863
864 if ( excllock ) 864 if ( excllock )
865 return; 865 return;
866 866
867 excllock = true; 867 excllock = true;
868 868
869 bool wasloggedin = loggedin; 869 bool wasloggedin = loggedin;
870 loggedin = 0; 870 loggedin = 0;
871 suspendTime = QDateTime::currentDateTime(); 871 suspendTime = QDateTime::currentDateTime();
872 872
873#ifdef QWS 873#ifdef QWS
874 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 874 if ( Password::needToAuthenticate ( true ) && qt_screen ) {
875 // Should use a big black window instead. 875 // Should use a big black window instead.
876 // But this would not show up fast enough 876 // But this would not show up fast enough
877 QGfx *g = qt_screen-> screenGfx ( ); 877 QGfx *g = qt_screen-> screenGfx ( );
878 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 878 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
879 delete g; 879 delete g;
880 } 880 }
881#endif 881#endif
882 882
883 ODevice::inst ( )-> suspend ( ); 883 ODevice::inst ( )-> suspend ( );
884 884
885 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 885 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
886 QWSServer::screenSaverActivate ( false ); 886 QWSServer::screenSaverActivate ( false );
887 887
888 { 888 {
889 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 889 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
890 } 890 }
891 891
892 if ( wasloggedin ) 892 if ( wasloggedin )
893 login ( true ); 893 login ( true );
894 894
895 execAutoStart(); 895 execAutoStart();
896 //qcopBridge->closeOpenConnections(); 896 //qcopBridge->closeOpenConnections();
897 897
898 excllock = false; 898 excllock = false;
899} 899}
900 900
901void Desktop::toggleLight() 901void Desktop::toggleLight()
902{ 902{
903 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 903 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
904 e << -2; // toggle 904 e << -2; // toggle
905} 905}
906 906
907void Desktop::toggleSymbolInput() 907void Desktop::toggleSymbolInput()
908{ 908{
909 tb->toggleSymbolInput(); 909 tb->toggleSymbolInput();
910} 910}
911 911
912void Desktop::toggleNumLockState() 912void Desktop::toggleNumLockState()
913{ 913{
914 tb->toggleNumLockState(); 914 tb->toggleNumLockState();
915} 915}
916 916
917void Desktop::toggleCapsLockState() 917void Desktop::toggleCapsLockState()
918{ 918{
919 tb->toggleCapsLockState(); 919 tb->toggleCapsLockState();
920} 920}
921 921
922void Desktop::styleChange( QStyle &s ) 922void Desktop::styleChange( QStyle &s )
923{ 923{
924 QWidget::styleChange( s ); 924 QWidget::styleChange( s );
925 int displayw = qApp->desktop() ->width(); 925 int displayw = qApp->desktop() ->width();
926 int displayh = qApp->desktop() ->height(); 926 int displayh = qApp->desktop() ->height();
927 927
928 QSize sz = tb->sizeHint(); 928 QSize sz = tb->sizeHint();
929 929
930 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 930 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
931} 931}
932 932
933void DesktopApplication::shutdown() 933void DesktopApplication::shutdown()
934{ 934{
935 if ( type() != GuiServer ) 935 if ( type() != GuiServer )
936 return ; 936 return ;
937 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 937 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
938 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 938 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
939 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 939 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
940 sd->showMaximized(); 940 sd->showMaximized();
941} 941}
942 942
943void DesktopApplication::shutdown( ShutdownImpl::Type t ) 943void DesktopApplication::shutdown( ShutdownImpl::Type t )
944{ 944{
945 switch ( t ) { 945 switch ( t ) {
946 case ShutdownImpl::ShutdownSystem: 946 case ShutdownImpl::ShutdownSystem:
947 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); 947 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 );
948 break; 948 break;
949 case ShutdownImpl::RebootSystem: 949 case ShutdownImpl::RebootSystem:
950 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); 950 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 );
951 break; 951 break;
952 case ShutdownImpl::RestartDesktop: 952 case ShutdownImpl::RestartDesktop:
953 restart(); 953 restart();
954 break; 954 break;
955 case ShutdownImpl::TerminateDesktop: 955 case ShutdownImpl::TerminateDesktop:
956 prepareForTermination( FALSE ); 956 prepareForTermination( FALSE );
957 957
958 // This is a workaround for a Qt bug 958 // This is a workaround for a Qt bug
959 // clipboard applet has to stop its poll timer, or Qt/E 959 // clipboard applet has to stop its poll timer, or Qt/E
960 // will hang on quit() right before it emits aboutToQuit() 960 // will hang on quit() right before it emits aboutToQuit()
961 emit aboutToQuit ( ); 961 emit aboutToQuit ( );
962 962
963 quit(); 963 quit();
964 break; 964 break;
965 } 965 }
966} 966}
967 967
968void DesktopApplication::restart() 968void DesktopApplication::restart()
969{ 969{
970 prepareForTermination( TRUE ); 970 prepareForTermination( TRUE );
971 971
972#ifdef Q_WS_QWS 972#ifdef Q_WS_QWS
973 973
974 for ( int fd = 3; fd < 100; fd++ ) 974 for ( int fd = 3; fd < 100; fd++ )
975 close( fd ); 975 close( fd );
976#if defined(QT_DEMO_SINGLE_FLOPPY) 976#if defined(QT_DEMO_SINGLE_FLOPPY)
977 977
978 execl( "/sbin/init", "qpe", 0 ); 978 execl( "/sbin/init", "qpe", 0 );
979#elif defined(QT_QWS_CASSIOPEIA) 979#elif defined(QT_QWS_CASSIOPEIA)
980 980
981 execl( "/bin/sh", "sh", 0 ); 981 execl( "/bin/sh", "sh", 0 );
982#else 982#else
983 983
984 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 984 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
985#endif 985#endif
986 986
987 exit( 1 ); 987 exit( 1 );
988#endif 988#endif
989} 989}
990 990
991void Desktop::startTransferServer() 991void 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
1009void Desktop::timerEvent( QTimerEvent *e ) 1009void Desktop::timerEvent( QTimerEvent *e )
1010{ 1010{
1011 killTimer( e->timerId() ); 1011 killTimer( e->timerId() );
1012 startTransferServer(); 1012 startTransferServer();
1013} 1013}
1014 1014
1015void Desktop::terminateServers() 1015void 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
1023void Desktop::rereadVolumes() 1023void 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
1032void Desktop::keyClick() 1032void Desktop::keyClick()
1033{ 1033{
1034 if ( keyclick ) 1034 if ( keyclick )
1035 ODevice::inst ( ) -> keySound ( ); 1035 ODevice::inst ( ) -> keySound ( );
1036} 1036}
1037 1037
1038void Desktop::screenClick() 1038void Desktop::screenClick()
1039{ 1039{
1040 if ( touchclick ) 1040 if ( touchclick )
1041 ODevice::inst ( ) -> touchSound ( ); 1041 ODevice::inst ( ) -> touchSound ( );
1042} 1042}
1043 1043
1044void Desktop::soundAlarm() 1044void Desktop::soundAlarm()
1045{ 1045{
1046 if ( qpedesktop-> alarmsound ) 1046 if ( qpedesktop-> alarmsound )
1047 ODevice::inst ( ) -> alarmSound ( ); 1047 ODevice::inst ( ) -> alarmSound ( );
1048} 1048}
1049 1049
1050bool 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
@@ -1,147 +1,148 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __DESKTOP_H__ 21#ifndef __DESKTOP_H__
22#define __DESKTOP_H__ 22#define __DESKTOP_H__
23 23
24 24
25#include "shutdownimpl.h" 25#include "shutdownimpl.h"
26 26
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31 31
32class Background; 32class Background;
33class Launcher; 33class Launcher;
34class TaskBar; 34class TaskBar;
35class PowerStatus; 35class PowerStatus;
36class QCopBridge; 36class QCopBridge;
37class TransferServer; 37class TransferServer;
38class DesktopPowerAlerter; 38class DesktopPowerAlerter;
39class PackageSlave; 39class PackageSlave;
40class QPEScreenSaver; 40class QPEScreenSaver;
41 41
42class DesktopApplication : public QPEApplication 42class DesktopApplication : public QPEApplication
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45public: 45public:
46 DesktopApplication( int& argc, char **argv, Type t ); 46 DesktopApplication( int& argc, char **argv, Type t );
47 ~DesktopApplication(); 47 ~DesktopApplication();
48 48
49 static void switchLCD ( bool on ); // only for togglePower in Desktop 49 static void switchLCD ( bool on ); // only for togglePower in Desktop
50 50
51signals: 51signals:
52 void menu(); 52 void menu();
53 void home(); 53 void home();
54 void datebook(); 54 void datebook();
55 void contacts(); 55 void contacts();
56 void launch(); 56 void launch();
57 void email(); 57 void email();
58 void backlight(); 58 void backlight();
59 void power(); 59 void power();
60 void symbol(); 60 void symbol();
61 void numLockStateToggle(); 61 void numLockStateToggle();
62 void capsLockStateToggle(); 62 void capsLockStateToggle();
63 void prepareForRestart(); 63 void prepareForRestart();
64 64
65protected: 65protected:
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
74public slots: 74public 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
78protected slots: 78protected slots:
79 void shutdown( ShutdownImpl::Type ); 79 void shutdown( ShutdownImpl::Type );
80 void psTimeout(); 80 void psTimeout();
81 void sendCard(); 81 void sendCard();
82private: 82private:
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
91class Desktop : public QWidget 91class Desktop : public QWidget
92{ 92{
93 Q_OBJECT 93 Q_OBJECT
94public: 94public:
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
107public slots: 107public 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
124protected: 124protected:
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
133private: 134private:
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