summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp18
-rw-r--r--core/launcher/desktop.h2
-rw-r--r--core/launcher/startmenu.cpp304
-rw-r--r--core/launcher/startmenu.h31
-rw-r--r--core/launcher/systray.cpp2
-rw-r--r--core/launcher/taskbar.cpp19
6 files changed, 318 insertions, 58 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 68949e6..1a33b36 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -287,192 +287,195 @@ public:
287 m_backlight_forcedoff = false; 287 m_backlight_forcedoff = false;
288 bright = -1; 288 bright = -1;
289 } 289 }
290 if ( m_backlight_forcedoff && bright != -2 ) 290 if ( m_backlight_forcedoff && bright != -2 )
291 return ; 291 return ;
292 if ( bright == -2 ) { 292 if ( bright == -2 ) {
293 // Toggle between off and on 293 // Toggle between off and on
294 bright = m_backlight_bright ? 0 : -1; 294 bright = m_backlight_bright ? 0 : -1;
295 m_backlight_forcedoff = !bright; 295 m_backlight_forcedoff = !bright;
296 } 296 }
297 297
298 m_backlight_bright = bright; 298 m_backlight_bright = bright;
299 299
300 bright = backlight ( ); 300 bright = backlight ( );
301 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 301 ODevice::inst ( ) -> setDisplayBrightness ( bright );
302 302
303 m_backlight_bright = bright; 303 m_backlight_bright = bright;
304 } 304 }
305 305
306private: 306private:
307 int m_disable_suspend; 307 int m_disable_suspend;
308 bool m_enable_dim; 308 bool m_enable_dim;
309 bool m_enable_lightoff; 309 bool m_enable_lightoff;
310 bool m_enable_onlylcdoff; 310 bool m_enable_onlylcdoff;
311 311
312 bool m_lcd_status; 312 bool m_lcd_status;
313 313
314 int m_backlight_bright; 314 int m_backlight_bright;
315 bool m_backlight_forcedoff; 315 bool m_backlight_forcedoff;
316}; 316};
317 317
318 318
319void DesktopApplication::switchLCD ( bool on ) 319void DesktopApplication::switchLCD ( bool on )
320{ 320{
321 if ( qApp ) { 321 if ( qApp ) {
322 DesktopApplication *dapp = (DesktopApplication *) qApp; 322 DesktopApplication *dapp = (DesktopApplication *) qApp;
323 323
324 if ( dapp-> m_screensaver ) { 324 if ( dapp-> m_screensaver ) {
325 if ( on ) 325 if ( on )
326 dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); 326 dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 );
327 else 327 else
328 dapp-> m_screensaver-> save ( 1 ); 328 dapp-> m_screensaver-> save ( 1 );
329 329
330 } 330 }
331 } 331 }
332} 332}
333 333
334 334
335DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 335DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
336 : QPEApplication( argc, argv, appType ) 336 : QPEApplication( argc, argv, appType )
337{ 337{
338 338
339 QTimer * t = new QTimer( this ); 339 QTimer * t = new QTimer( this );
340 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); 340 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) );
341 t->start( 10000 ); 341 t->start( 10000 );
342 ps = new PowerStatus; 342 ps = new PowerStatus;
343 pa = new DesktopPowerAlerter( 0 ); 343 pa = new DesktopPowerAlerter( 0 );
344 344
345 channel = new QCopChannel( "QPE/Desktop", this ); 345 channel = new QCopChannel( "QPE/Desktop", this );
346 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 346 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
347 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 347 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
348 348
349 channel = new QCopChannel( "QPE/System", this ); 349 channel = new QCopChannel( "QPE/System", this );
350 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 350 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
351 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 351 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
352 352
353 m_screensaver = new QPEScreenSaver; 353 m_screensaver = new QPEScreenSaver;
354 354
355 m_screensaver-> setInterval ( -1 ); 355 m_screensaver-> setInterval ( -1 );
356 QWSServer::setScreenSaver( m_screensaver ); 356 QWSServer::setScreenSaver( m_screensaver );
357} 357}
358 358
359 359
360DesktopApplication::~DesktopApplication() 360DesktopApplication::~DesktopApplication()
361{ 361{
362 delete ps; 362 delete ps;
363 delete pa; 363 delete pa;
364} 364}
365 365
366void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) 366void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
367{ 367{
368#ifdef Q_WS_QWS 368#ifdef Q_WS_QWS
369 QDataStream stream( data, IO_ReadOnly ); 369 QDataStream stream( data, IO_ReadOnly );
370 if ( msg == "keyRegister(int key, QString channel, QString message)" ) { 370 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
371 int k; 371 int k;
372 QString c, m; 372 QString c, m;
373 stream >> k; 373 stream >> k;
374 stream >> c; 374 stream >> c;
375 stream >> m; 375 stream >> m;
376 376
377 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); 377 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
378 keyRegisterList.append( QCopKeyRegister( k, c, m ) ); 378 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
379 } 379 }
380 else if ( msg == "suspend()" ) { 380 else if ( msg == "suspend()" ) {
381 emit power(); 381 emit power();
382 } 382 }
383 else if ( msg == "home()" ) {
384 qpedesktop-> home ( );
385 }
383#endif 386#endif
384} 387}
385 388
386 389
387void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 390void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
388{ 391{
389#ifdef Q_WS_QWS 392#ifdef Q_WS_QWS
390 QDataStream stream ( data, IO_ReadOnly ); 393 QDataStream stream ( data, IO_ReadOnly );
391 394
392 if ( msg == "setScreenSaverInterval(int)" ) { 395 if ( msg == "setScreenSaverInterval(int)" ) {
393 int time; 396 int time;
394 stream >> time; 397 stream >> time;
395 m_screensaver-> setInterval( time ); 398 m_screensaver-> setInterval( time );
396 } 399 }
397 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 400 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
398 int t1, t2, t3; 401 int t1, t2, t3;
399 stream >> t1 >> t2 >> t3; 402 stream >> t1 >> t2 >> t3;
400 m_screensaver-> setIntervals( t1, t2, t3 ); 403 m_screensaver-> setIntervals( t1, t2, t3 );
401 } 404 }
402 else if ( msg == "setBacklight(int)" ) { 405 else if ( msg == "setBacklight(int)" ) {
403 int bright; 406 int bright;
404 stream >> bright; 407 stream >> bright;
405 m_screensaver-> setBacklight( bright ); 408 m_screensaver-> setBacklight( bright );
406 } 409 }
407 else if ( msg == "setScreenSaverMode(int)" ) { 410 else if ( msg == "setScreenSaverMode(int)" ) {
408 int mode; 411 int mode;
409 stream >> mode; 412 stream >> mode;
410 m_screensaver-> setMode ( mode ); 413 m_screensaver-> setMode ( mode );
411 } 414 }
412#endif 415#endif
413} 416}
414 417
415enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 418enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
416 419
417#ifdef Q_WS_QWS 420#ifdef Q_WS_QWS
418bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 421bool DesktopApplication::qwsEventFilter( QWSEvent *e )
419{ 422{
420 qpedesktop->checkMemory(); 423 qpedesktop->checkMemory();
421 424
422 if ( e->type == QWSEvent::Key ) { 425 if ( e->type == QWSEvent::Key ) {
423 QWSKeyEvent * ke = ( QWSKeyEvent * ) e; 426 QWSKeyEvent * ke = ( QWSKeyEvent * ) e;
424 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 427 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
425 return TRUE; 428 return TRUE;
426 bool press = ke->simpleData.is_press; 429 bool press = ke->simpleData.is_press;
427 bool autoRepeat = ke->simpleData.is_auto_repeat; 430 bool autoRepeat = ke->simpleData.is_auto_repeat;
428 431
429 /* 432 /*
430 app that registers key/message to be sent back to the app, when it doesn't have focus, 433 app that registers key/message to be sent back to the app, when it doesn't have focus,
431 when user presses key, unless keyboard has been requested from app. 434 when user presses key, unless keyboard has been requested from app.
432 will not send multiple repeats if user holds key 435 will not send multiple repeats if user holds key
433 i.e. one shot 436 i.e. one shot
434 */ 437 */
435 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { 438 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) {
436// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); 439// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode);
437 KeyRegisterList::Iterator it; 440 KeyRegisterList::Iterator it;
438 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 441 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
439 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { 442 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) {
440 if ( press ) 443 if ( press )
441 qDebug( "press" ); 444 qDebug( "press" );
442 else 445 else
443 qDebug( "release" ); 446 qDebug( "release" );
444 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); 447 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() );
445 } 448 }
446 } 449 }
447 } 450 }
448 451
449 if ( !keyboardGrabbed() ) { 452 if ( !keyboardGrabbed() ) {
450 if ( ke->simpleData.keycode == Key_F9 ) { 453 if ( ke->simpleData.keycode == Key_F9 ) {
451 if ( press ) 454 if ( press )
452 emit datebook(); 455 emit datebook();
453 return TRUE; 456 return TRUE;
454 } 457 }
455 if ( ke->simpleData.keycode == Key_F10 ) { 458 if ( ke->simpleData.keycode == Key_F10 ) {
456 if ( !press && cardSendTimer ) { 459 if ( !press && cardSendTimer ) {
457 emit contacts(); 460 emit contacts();
458 delete cardSendTimer; 461 delete cardSendTimer;
459 } 462 }
460 else if ( press ) { 463 else if ( press ) {
461 cardSendTimer = new QTimer(); 464 cardSendTimer = new QTimer();
462 cardSendTimer->start( 2000, TRUE ); 465 cardSendTimer->start( 2000, TRUE );
463 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 466 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
464 } 467 }
465 return TRUE; 468 return TRUE;
466 } 469 }
467 /* menu key now opens application menu/toolbar 470 /* menu key now opens application menu/toolbar
468 if ( ke->simpleData.keycode == Key_F11 ) { 471 if ( ke->simpleData.keycode == Key_F11 ) {
469 if ( press ) emit menu(); 472 if ( press ) emit menu();
470 return TRUE; 473 return TRUE;
471 } 474 }
472 */ 475 */
473 if ( ke->simpleData.keycode == Key_F12 ) { 476 if ( ke->simpleData.keycode == Key_F12 ) {
474 while ( activePopupWidget() ) 477 while ( activePopupWidget() )
475 activePopupWidget() ->close(); 478 activePopupWidget() ->close();
476 if ( press ) 479 if ( press )
477 emit launch(); 480 emit launch();
478 return TRUE; 481 return TRUE;
@@ -624,312 +627,319 @@ Desktop::Desktop() :
624 packageSlave = new PackageSlave( this ); 627 packageSlave = new PackageSlave( this );
625 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); 628 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
626 629
627 qApp->installEventFilter( this ); 630 qApp->installEventFilter( this );
628} 631}
629 632
630void Desktop::show() 633void Desktop::show()
631{ 634{
632 login( TRUE ); 635 login( TRUE );
633 QWidget::show(); 636 QWidget::show();
634} 637}
635 638
636Desktop::~Desktop() 639Desktop::~Desktop()
637{ 640{
638 delete launcher; 641 delete launcher;
639 delete tb; 642 delete tb;
640 delete qcopBridge; 643 delete qcopBridge;
641 delete transferServer; 644 delete transferServer;
642} 645}
643 646
644bool Desktop::recoverMemory() 647bool Desktop::recoverMemory()
645{ 648{
646 return tb->recoverMemory(); 649 return tb->recoverMemory();
647} 650}
648 651
649void Desktop::checkMemory() 652void Desktop::checkMemory()
650{ 653{
651#if defined(QPE_HAVE_MEMALERTER) 654#if defined(QPE_HAVE_MEMALERTER)
652 static bool ignoreNormal = FALSE; 655 static bool ignoreNormal = FALSE;
653 static bool existingMessage = FALSE; 656 static bool existingMessage = FALSE;
654 657
655 if ( existingMessage ) 658 if ( existingMessage )
656 return ; // don't show a second message while still on first 659 return ; // don't show a second message while still on first
657 660
658 existingMessage = TRUE; 661 existingMessage = TRUE;
659 switch ( memstate ) { 662 switch ( memstate ) {
660 case Unknown: 663 case Unknown:
661 break; 664 break;
662 case Low: 665 case Low:
663 memstate = Unknown; 666 memstate = Unknown;
664 if ( recoverMemory() ) 667 if ( recoverMemory() )
665 ignoreNormal = TRUE; 668 ignoreNormal = TRUE;
666 else 669 else
667 QMessageBox::warning( 0 , "Memory Status", 670 QMessageBox::warning( 0 , "Memory Status",
668 "The memory smacks of shortage. \n" 671 "The memory smacks of shortage. \n"
669 "Please save data. " ); 672 "Please save data. " );
670 break; 673 break;
671 case Normal: 674 case Normal:
672 memstate = Unknown; 675 memstate = Unknown;
673 if ( ignoreNormal ) 676 if ( ignoreNormal )
674 ignoreNormal = FALSE; 677 ignoreNormal = FALSE;
675 else 678 else
676 QMessageBox::information ( 0 , "Memory Status", 679 QMessageBox::information ( 0 , "Memory Status",
677 "There is enough memory again." ); 680 "There is enough memory again." );
678 break; 681 break;
679 case VeryLow: 682 case VeryLow:
680 memstate = Unknown; 683 memstate = Unknown;
681 QMessageBox::critical( 0 , "Memory Status", 684 QMessageBox::critical( 0 , "Memory Status",
682 "The memory is very low. \n" 685 "The memory is very low. \n"
683 "Please end this application \n" 686 "Please end this application \n"
684 "immediately." ); 687 "immediately." );
685 recoverMemory(); 688 recoverMemory();
686 } 689 }
687 existingMessage = FALSE; 690 existingMessage = FALSE;
688#endif 691#endif
689} 692}
690 693
691static bool isVisibleWindow( int wid ) 694static bool isVisibleWindow( int wid )
692{ 695{
693 const QList<QWSWindow> &list = qwsServer->clientWindows(); 696 const QList<QWSWindow> &list = qwsServer->clientWindows();
694 QWSWindow* w; 697 QWSWindow* w;
695 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 698 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
696 if ( w->winId() == wid ) 699 if ( w->winId() == wid )
697 return !w->isFullyObscured(); 700 return !w->isFullyObscured();
698 } 701 }
699 return FALSE; 702 return FALSE;
700} 703}
701 704
702static bool hasVisibleWindow( const QString& clientname ) 705static bool hasVisibleWindow( const QString& clientname )
703{ 706{
704 const QList<QWSWindow> &list = qwsServer->clientWindows(); 707 const QList<QWSWindow> &list = qwsServer->clientWindows();
705 QWSWindow* w; 708 QWSWindow* w;
706 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 709 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
707 if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) 710 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
708 return TRUE; 711 return TRUE;
709 } 712 }
710 return FALSE; 713 return FALSE;
711} 714}
712 715
713void Desktop::raiseLauncher() 716void Desktop::raiseLauncher()
714{ 717{
715 Config cfg( "qpe" ); //F12 'Home' 718 Config cfg( "qpe" ); //F12 'Home'
716 cfg.setGroup( "AppsKey" ); 719 cfg.setGroup( "AppsKey" );
717 QString tempItem; 720 QString tempItem;
718 tempItem = cfg.readEntry( "Middle", "Home" ); 721 tempItem = cfg.readEntry( "Middle", "Home" );
719 if ( tempItem == "Home" || tempItem.isEmpty() ) { 722 if ( tempItem == "Home" || tempItem.isEmpty() ) {
720 if ( isVisibleWindow( launcher->winId() ) ) 723 home ( );
721 launcher->nextView();
722 else
723 launcher->raise();
724 } 724 }
725 else { 725 else {
726 QCopEnvelope e( "QPE/System", "execute(QString)" ); 726 QCopEnvelope e( "QPE/System", "execute(QString)" );
727 e << tempItem; 727 e << tempItem;
728 } 728 }
729} 729}
730 730
731void Desktop::home ( )
732 {
733 if ( isVisibleWindow( launcher->winId() ) )
734 launcher->nextView();
735 else
736 launcher->raise();
737}
738
731void Desktop::executeOrModify( const QString& appLnkFile ) 739void Desktop::executeOrModify( const QString& appLnkFile )
732{ 740{
733 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); 741 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
734 if ( lnk.isValid() ) { 742 if ( lnk.isValid() ) {
735 QCString app = lnk.exec().utf8(); 743 QCString app = lnk.exec().utf8();
736 Global::terminateBuiltin( "calibrate" ); 744 Global::terminateBuiltin( "calibrate" );
737 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { 745 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
738 // MRUList::addTask( &lnk ); 746 // MRUList::addTask( &lnk );
739 if ( hasVisibleWindow( app ) ) 747 if ( hasVisibleWindow( app ) )
740 QCopChannel::send( "QPE/Application/" + app, "nextView()" ); 748 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
741 else 749 else
742 QCopChannel::send( "QPE/Application/" + app, "raise()" ); 750 QCopChannel::send( "QPE/Application/" + app, "raise()" );
743 } 751 }
744 else { 752 else {
745 lnk.execute(); 753 lnk.execute();
746 } 754 }
747 } 755 }
748} 756}
749 757
750void Desktop::raiseDatebook() 758void Desktop::raiseDatebook()
751{ 759{
752 Config cfg( "qpe" ); //F9 'Activity' 760 Config cfg( "qpe" ); //F9 'Activity'
753 cfg.setGroup( "AppsKey" ); 761 cfg.setGroup( "AppsKey" );
754 QString tempItem; 762 QString tempItem;
755 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); 763 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" );
756 if ( tempItem == "Calendar" || tempItem.isEmpty() ) { 764 if ( tempItem == "Calendar" || tempItem.isEmpty() ) {
757 tempItem = "datebook"; 765 tempItem = "datebook";
758 } 766 }
759 QCopEnvelope e( "QPE/System", "execute(QString)" ); 767 QCopEnvelope e( "QPE/System", "execute(QString)" );
760 e << tempItem; 768 e << tempItem;
761} 769}
762 770
763void Desktop::raiseContacts() 771void Desktop::raiseContacts()
764{ 772{
765 Config cfg( "qpe" ); //F10, 'Contacts' 773 Config cfg( "qpe" ); //F10, 'Contacts'
766 cfg.setGroup( "AppsKey" ); 774 cfg.setGroup( "AppsKey" );
767 QString tempItem; 775 QString tempItem;
768 tempItem = cfg.readEntry( "Left2nd", "Address Book" ); 776 tempItem = cfg.readEntry( "Left2nd", "Address Book" );
769 if ( tempItem == "Address Book" || tempItem.isEmpty() ) { 777 if ( tempItem == "Address Book" || tempItem.isEmpty() ) {
770 tempItem = "addressbook"; 778 tempItem = "addressbook";
771 } 779 }
772 QCopEnvelope e( "QPE/System", "execute(QString)" ); 780 QCopEnvelope e( "QPE/System", "execute(QString)" );
773 e << tempItem; 781 e << tempItem;
774} 782}
775 783
776void Desktop::raiseMenu() 784void Desktop::raiseMenu()
777{ 785{
778 Config cfg( "qpe" ); //F11, 'Menu 786 Config cfg( "qpe" ); //F11, 'Menu
779 cfg.setGroup( "AppsKey" ); 787 cfg.setGroup( "AppsKey" );
780 QString tempItem; 788 QString tempItem;
781 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); 789 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" );
782 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { 790 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) {
783 Global::terminateBuiltin( "calibrate" ); 791 Global::terminateBuiltin( "calibrate" );
784 tb->startMenu() ->launch(); 792 tb->startMenu() ->launch();
785 } 793 }
786 else { 794 else {
787 QCopEnvelope e( "QPE/System", "execute(QString)" ); 795 QCopEnvelope e( "QPE/System", "execute(QString)" );
788 e << tempItem; 796 e << tempItem;
789 } 797 }
790} 798}
791 799
792void Desktop::raiseEmail() 800void Desktop::raiseEmail()
793{ 801{
794 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 802 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11
795 cfg.setGroup( "AppsKey" ); 803 cfg.setGroup( "AppsKey" );
796 QString tempItem; 804 QString tempItem;
797 tempItem = cfg.readEntry( "RightEnd", "Mail" ); 805 tempItem = cfg.readEntry( "RightEnd", "Mail" );
798 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { 806 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) {
799 tempItem = "mail"; 807 tempItem = "mail";
800 } 808 }
801 QCopEnvelope e( "QPE/System", "execute(QString)" ); 809 QCopEnvelope e( "QPE/System", "execute(QString)" );
802 e << tempItem; 810 e << tempItem;
803} 811}
804 812
805// autoStarts apps on resume and start 813// autoStarts apps on resume and start
806void Desktop::execAutoStart() 814void Desktop::execAutoStart()
807{ 815{
808 QString appName; 816 QString appName;
809 int delay; 817 int delay;
810 QDateTime now = QDateTime::currentDateTime(); 818 QDateTime now = QDateTime::currentDateTime();
811 Config cfg( "autostart" ); 819 Config cfg( "autostart" );
812 cfg.setGroup( "AutoStart" ); 820 cfg.setGroup( "AutoStart" );
813 appName = cfg.readEntry( "Apps", "" ); 821 appName = cfg.readEntry( "Apps", "" );
814 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 822 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
815 // If the time between suspend and resume was longer then the 823 // If the time between suspend and resume was longer then the
816 // value saved as delay, start the app 824 // value saved as delay, start the app
817 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 825 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
818 QCopEnvelope e( "QPE/System", "execute(QString)" ); 826 QCopEnvelope e( "QPE/System", "execute(QString)" );
819 e << QString( appName ); 827 e << QString( appName );
820 } 828 }
821} 829}
822 830
823#if defined(QPE_HAVE_TOGGLELIGHT) 831#if defined(QPE_HAVE_TOGGLELIGHT)
824#include <qpe/config.h> 832#include <qpe/config.h>
825 833
826#include <sys/ioctl.h> 834#include <sys/ioctl.h>
827#include <sys/types.h> 835#include <sys/types.h>
828#include <fcntl.h> 836#include <fcntl.h>
829#include <unistd.h> 837#include <unistd.h>
830#include <errno.h> 838#include <errno.h>
831#include <linux/ioctl.h> 839#include <linux/ioctl.h>
832#include <time.h> 840#include <time.h>
833#endif 841#endif
834 842
835 843
836void Desktop::togglePower() 844void Desktop::togglePower()
837{ 845{
838 static bool excllock = false; 846 static bool excllock = false;
839 847
848 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 );
849
840 if ( excllock ) 850 if ( excllock )
841 return ; 851 return ;
842 852
843 excllock = true; 853 excllock = true;
844 854
845 bool wasloggedin = loggedin; 855 bool wasloggedin = loggedin;
846 loggedin = 0; 856 loggedin = 0;
847 suspendTime = QDateTime::currentDateTime(); 857 suspendTime = QDateTime::currentDateTime();
848 858
849 ODevice::inst ( ) -> suspend ( ); 859 ODevice::inst ( ) -> suspend ( );
850 860
851 QWSServer::screenSaverActivate ( false ); 861 QWSServer::screenSaverActivate ( false );
852 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 862 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
853 863
854 { 864 {
855 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 865 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
856 } 866 }
857 867
858 if ( wasloggedin ) 868 if ( wasloggedin )
859 login( TRUE ); 869 login( TRUE );
860 870
861 execAutoStart(); 871 execAutoStart();
862 //qcopBridge->closeOpenConnections(); 872 //qcopBridge->closeOpenConnections();
863 873
864 excllock = false; 874 excllock = false;
865} 875}
866 876
867void Desktop::toggleLight() 877void Desktop::toggleLight()
868{ 878{
869 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 879 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
870 e << -2; // toggle 880 e << -2; // toggle
871} 881}
872 882
873void Desktop::toggleSymbolInput() 883void Desktop::toggleSymbolInput()
874{ 884{
875 tb->toggleSymbolInput(); 885 tb->toggleSymbolInput();
876} 886}
877 887
878void Desktop::toggleNumLockState() 888void Desktop::toggleNumLockState()
879{ 889{
880 tb->toggleNumLockState(); 890 tb->toggleNumLockState();
881} 891}
882 892
883void Desktop::toggleCapsLockState() 893void Desktop::toggleCapsLockState()
884{ 894{
885 tb->toggleCapsLockState(); 895 tb->toggleCapsLockState();
886} 896}
887 897
888void Desktop::styleChange( QStyle &s ) 898void Desktop::styleChange( QStyle &s )
889{ 899{
890 QWidget::styleChange( s ); 900 QWidget::styleChange( s );
891 int displayw = qApp->desktop() ->width(); 901 int displayw = qApp->desktop() ->width();
892 int displayh = qApp->desktop() ->height(); 902 int displayh = qApp->desktop() ->height();
893 903
894 QSize sz = tb->sizeHint(); 904 QSize sz = tb->sizeHint();
895 905
896 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 906 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
897} 907}
898 908
899void DesktopApplication::shutdown() 909void DesktopApplication::shutdown()
900{ 910{
901 if ( type() != GuiServer ) 911 if ( type() != GuiServer )
902 return ; 912 return ;
903 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 913 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
904 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 914 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
905 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 915 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
906 sd->showMaximized(); 916 sd->showMaximized();
907} 917}
908 918
909void DesktopApplication::shutdown( ShutdownImpl::Type t ) 919void DesktopApplication::shutdown( ShutdownImpl::Type t )
910{ 920{
911 switch ( t ) { 921 switch ( t ) {
912 case ShutdownImpl::ShutdownSystem: 922 case ShutdownImpl::ShutdownSystem:
913 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); 923 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 );
914 break; 924 break;
915 case ShutdownImpl::RebootSystem: 925 case ShutdownImpl::RebootSystem:
916 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); 926 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 );
917 break; 927 break;
918 case ShutdownImpl::RestartDesktop: 928 case ShutdownImpl::RestartDesktop:
919 restart(); 929 restart();
920 break; 930 break;
921 case ShutdownImpl::TerminateDesktop: 931 case ShutdownImpl::TerminateDesktop:
922 prepareForTermination( FALSE ); 932 prepareForTermination( FALSE );
923 933
924 // This is a workaround for a Qt bug 934 // This is a workaround for a Qt bug
925 // clipboard applet has to stop its poll timer, or Qt/E 935 // clipboard applet has to stop its poll timer, or Qt/E
926 // will hang on quit() right before it emits aboutToQuit() 936 // will hang on quit() right before it emits aboutToQuit()
927 emit aboutToQuit ( ); 937 emit aboutToQuit ( );
928 938
929 quit(); 939 quit();
930 break; 940 break;
931 } 941 }
932} 942}
933 943
934void DesktopApplication::restart() 944void DesktopApplication::restart()
935{ 945{
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index f7c3e3f..09ffe1c 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -25,120 +25,122 @@
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 home(); 52 void home();
53 void datebook(); 53 void datebook();
54 void contacts(); 54 void contacts();
55 void launch(); 55 void launch();
56 void email(); 56 void email();
57 void backlight(); 57 void backlight();
58 void power(); 58 void power();
59 void symbol(); 59 void symbol();
60 void numLockStateToggle(); 60 void numLockStateToggle();
61 void capsLockStateToggle(); 61 void capsLockStateToggle();
62 void prepareForRestart(); 62 void prepareForRestart();
63 63
64protected: 64protected:
65#ifdef Q_WS_QWS 65#ifdef Q_WS_QWS
66 66
67 bool qwsEventFilter( QWSEvent * ); 67 bool qwsEventFilter( QWSEvent * );
68#endif 68#endif
69 69
70 void shutdown(); 70 void shutdown();
71 void restart(); 71 void restart();
72 72
73public slots: 73public slots:
74 virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); 74 virtual void desktopMessage ( const QCString &msg, const QByteArray &data );
75 virtual void systemMessage ( const QCString &msg, const QByteArray &data ); 75 virtual void systemMessage ( const QCString &msg, const QByteArray &data );
76 76
77protected slots: 77protected slots:
78 void shutdown( ShutdownImpl::Type ); 78 void shutdown( ShutdownImpl::Type );
79 void psTimeout(); 79 void psTimeout();
80 void sendCard(); 80 void sendCard();
81private: 81private:
82 DesktopPowerAlerter *pa; 82 DesktopPowerAlerter *pa;
83 PowerStatus *ps; 83 PowerStatus *ps;
84 QTimer *cardSendTimer; 84 QTimer *cardSendTimer;
85 QCopChannel *channel; 85 QCopChannel *channel;
86 QPEScreenSaver *m_screensaver; 86 QPEScreenSaver *m_screensaver;
87}; 87};
88 88
89 89
90class Desktop : public QWidget 90class Desktop : public QWidget
91{ 91{
92 Q_OBJECT 92 Q_OBJECT
93public: 93public:
94 Desktop(); 94 Desktop();
95 ~Desktop(); 95 ~Desktop();
96 96
97 static bool screenLocked(); 97 static bool screenLocked();
98 98
99 void show(); 99 void show();
100 void checkMemory(); 100 void checkMemory();
101 101
102 void keyClick(); 102 void keyClick();
103 void screenClick(); 103 void screenClick();
104 static void soundAlarm(); 104 static void soundAlarm();
105 105
106public slots: 106public slots:
107 void raiseDatebook(); 107 void raiseDatebook();
108 void raiseContacts(); 108 void raiseContacts();
109 void raiseMenu(); 109 void raiseMenu();
110 void raiseLauncher(); 110 void raiseLauncher();
111 void raiseEmail(); 111 void raiseEmail();
112 void execAutoStart(); 112 void execAutoStart();
113 void togglePower(); 113 void togglePower();
114 void toggleLight(); 114 void toggleLight();
115 void toggleNumLockState(); 115 void toggleNumLockState();
116 void toggleCapsLockState(); 116 void toggleCapsLockState();
117 void toggleSymbolInput(); 117 void toggleSymbolInput();
118 void terminateServers(); 118 void terminateServers();
119 void rereadVolumes(); 119 void rereadVolumes();
120 120
121 void home ( );
122
121protected: 123protected:
122 void executeOrModify( const QString& appLnkFile ); 124 void executeOrModify( const QString& appLnkFile );
123 void styleChange( QStyle & ); 125 void styleChange( QStyle & );
124 void timerEvent( QTimerEvent *e ); 126 void timerEvent( QTimerEvent *e );
125 127
126 QWidget *bg; 128 QWidget *bg;
127 Launcher *launcher; 129 Launcher *launcher;
128 TaskBar *tb; 130 TaskBar *tb;
129 131
130private: 132private:
131 void startTransferServer(); 133 void startTransferServer();
132 bool recoverMemory(); 134 bool recoverMemory();
133 135
134 QCopBridge *qcopBridge; 136 QCopBridge *qcopBridge;
135 TransferServer *transferServer; 137 TransferServer *transferServer;
136 PackageSlave *packageSlave; 138 PackageSlave *packageSlave;
137 139
138 QDateTime suspendTime; 140 QDateTime suspendTime;
139 bool keyclick, touchclick, alarmsound; 141 bool keyclick, touchclick, alarmsound;
140}; 142};
141 143
142 144
143#endif // __DESKTOP_H__ 145#endif // __DESKTOP_H__
144 146
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index b008a30..647d0f2 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -1,171 +1,385 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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#define INCLUDE_MENUITEM_DEF
22
21#include "startmenu.h" 23#include "startmenu.h"
22#include "sidething.h" 24#include "sidething.h"
23//#include "mrulist.h" 25//#include "mrulist.h"
24#include "info.h" 26#include "info.h"
25 27
26#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
27#include <qpe/config.h> 29#include <qpe/config.h>
28#include <qpe/applnk.h> 30#include <qpe/applnk.h>
29#include <qpe/global.h> 31#include <qpe/global.h>
30#include <qpe/resource.h> 32#include <qpe/resource.h>
33#include <qpe/qlibrary.h>
31 34
32#include <qdict.h> 35#include <qintdict.h>
36#include <qdir.h>
33 37
34#include <stdlib.h> 38#include <stdlib.h>
35 39
36 40
37// #define USE_CONFIG_FILE 41// #define USE_CONFIG_FILE
38 42
39 43
40StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) 44StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
41{ 45{
42 loadOptions(); 46 loadOptions();
43 47
44 setPixmap( Resource::loadPixmap( startButtonPixmap ) ); 48 int sz = AppLnk::smallIconSize()+3;
49 QPixmap pm;
50 pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz));
51 setPixmap(pm);
45 setFocusPolicy( NoFocus ); 52 setFocusPolicy( NoFocus );
46 //setFlat( startButtonIsFlat ); 53 //setFlat( startButtonIsFlat );
47 54
48 apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); 55 apps = 0;
49 56 launchMenu = 0;
50 createMenu(); 57 applets. setAutoDelete ( true );
58 sepId = 0;
59
60 reloadApps ( );
61 reloadApplets ( );
51} 62}
52 63
53 64
54void StartMenu::mousePressEvent( QMouseEvent * ) 65void StartMenu::mousePressEvent( QMouseEvent * )
55{ 66{
56 launch(); 67 launch();
57 if (desktopInfo) 68 if (desktopInfo)
58 desktopInfo->menuClicked(); 69 desktopInfo->menuClicked();
59} 70}
60 71
61 72
62StartMenu::~StartMenu() 73StartMenu::~StartMenu()
63{ 74{
64 delete apps; 75 delete apps;
65} 76}
66 77
67 78
68void StartMenu::loadOptions() 79void StartMenu::loadOptions()
69{ 80{
70#ifdef USE_CONFIG_FILE 81#ifdef USE_CONFIG_FILE
71 // Read configuration file 82 // Read configuration file
72 Config config("StartMenu"); 83 Config config("StartMenu");
73 config.setGroup( "StartMenu" ); 84 config.setGroup( "StartMenu" );
74 QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" ); 85 QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" );
75 useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE; 86 useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE;
76 QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" ); 87 QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" );
77 startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE; 88 startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE;
78// QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" ); 89 QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" );
79 popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" ); 90 popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" );
80 startButtonPixmap = config.readEntry( "StartButtonPixmap", "go" ); 91 startButtonPixmap = config.readEntry( "StartButtonPixmap", "launcher/start_button" );
81#else 92#else
82 // Basically just #include the .qpe_menu.conf file settings 93 // Basically just #include the .qpe_menu.conf file settings
83 useWidePopupMenu = FALSE; 94 useWidePopupMenu = FALSE;
84 popupMenuSidePixmap = "launcher/sidebar"; 95 popupMenuSidePixmap = "launcher/sidebar";
85 startButtonIsFlat = TRUE; 96 startButtonIsFlat = TRUE;
86 startButtonPixmap = "launcher/start_button"; 97 startButtonPixmap = "launcher/start_button"; // No tr
87#endif 98#endif
88} 99}
89 100
90 101
91void StartMenu::createMenu() 102void StartMenu::createMenu()
92{ 103{
104 delete launchMenu;
93 if ( useWidePopupMenu ) 105 if ( useWidePopupMenu )
94 launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); 106 launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap );
95 else 107 else
96 launchMenu = new StartPopupMenu( this ); 108 launchMenu = new StartPopupMenu( this );
97 109
98 loadMenu( apps, launchMenu ); 110 loadMenu ( apps, launchMenu );
111 loadApplets ( );
112
113 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
114}
99 115
116void StartMenu::reloadApps()
117{
118 Config cfg("StartMenu");
119 cfg.setGroup("Menu");
120 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE);
121 bool lot = cfg.readBoolEntry("LauncherOther",TRUE);
122 bool lt = ltabs || lot;
123 if ( launchMenu && apps && !lt )
124 return; // nothing to do
125
126 if ( lt ) {
127 delete apps;
128 apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" );
129 }
130 if ( launchMenu ) {
131 launchMenu-> hide ( );
132
133 for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) {
134 launchMenu-> removeItem ( it. currentKey ( ));
135 delete it.current ( );
136 }
137 tabdict. clear ( );
138 loadMenu(apps,launchMenu);
139 } else {
140 createMenu();
141 }
142}
143
144void StartMenu::reloadApplets()
145{
146 if ( launchMenu ) {
147 clearApplets ( );
148 loadApplets ( );
149 }
150 else
151 createMenu ( );
100} 152}
101 153
102void StartMenu::itemSelected( int id ) 154void StartMenu::itemSelected( int id )
103{ 155{
104 const AppLnk *app = apps->find( id ); 156 const AppLnk *app = apps->find( id );
105 if ( app ) 157 if ( app )
106 app->execute(); 158 app->execute();
159 else {
160 MenuApplet *applet = applets. find ( id );
161
162 if ( applet )
163 applet-> iface-> activated ( );
164 }
107} 165}
108 166
109bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) 167bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu )
110{ 168{
111 bool result = FALSE; 169 bool result = FALSE;
112 170
113 QStringList typs = folder->types(); 171 Config cfg("StartMenu");
114 QDict<QPopupMenu> typpop; 172 cfg.setGroup("Menu");
115 for (QStringList::Iterator tit=typs.begin(); tit!=typs.end(); ++tit) { 173
116 if ( !(*tit).isEmpty() ) { 174 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE);
117 QPopupMenu *new_menu = new StartPopupMenu( menu ); 175 bool lot = cfg.readBoolEntry("LauncherOther",TRUE);
118 typpop.insert(*tit, new_menu); 176
119 connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 177 tabdict. clear ( );
120 menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu ); 178
121 } 179 if ( sepId )
122 } 180 menu-> removeItem ( sepId );
123 181 sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0;
124 QListIterator<AppLnk> it( folder->children() ); 182
125 for ( ; it.current(); ++it ) { 183 if ( ltabs || lot ) {
126 AppLnk *app = it.current(); 184 QDict<QPopupMenu> typpop;
127 if ( app->type() == "Separator" ) { 185 QStringList typs = folder->types();
128 menu->insertSeparator(); 186 for (QStringList::Iterator tit=typs.fromLast(); ; --tit) {
129 } else { 187 if ( !(*tit).isEmpty() ) {
130 QString t = app->type(); 188 QPopupMenu *new_menu;
131 QPopupMenu* pmenu = typpop.find(t); 189 if ( ltabs ) {
132 if ( !pmenu ) 190 new_menu = new StartPopupMenu( menu );
133 pmenu = menu; 191 connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
134 pmenu->insertItem( app->pixmap(), app->name(), app->id() ); 192 int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 );
135 result=TRUE; 193 tabdict. insert ( id, new_menu );
136 } 194 } else {
195 new_menu = (QPopupMenu*)1;
196 }
197 typpop.insert(*tit, new_menu);
198 }
199 if ( tit == typs. begin ( ))
200 break;
201 }
202 QListIterator<AppLnk> it( folder->children() );
203 bool f=TRUE;
204 for ( ; it.current(); ++it ) {
205 AppLnk *app = it.current();
206 if ( app->type() == "Separator" ) { // No tr
207 if ( lot ) {
208 menu->insertSeparator();
209 }
210 } else {
211 f = FALSE;
212 QString t = app->type();
213 QPopupMenu* pmenu = typpop.find(t);
214 if ( ltabs ) {
215 if ( !pmenu && lot )
216 pmenu = menu;
217 } else {
218 if ( !pmenu )
219 pmenu = menu;
220 else
221 pmenu = 0;
222 }
223 if ( pmenu ) {
224 QString t = app->name();
225 t.replace(QRegExp("&"),"&&"); // escape shortcut character
226 pmenu->insertItem( app->pixmap(), t, app->id() );
227 }
228 result=TRUE;
229 }
230 }
137 } 231 }
138 232
139 if ( result ) 233 if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries
140 connect( menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 234 menu-> removeItem ( sepId );
141 235 sepId = 0;
236 }
237 if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later
238 sepId = menu-> insertSeparator ( );
239
142 return result; 240 return result;
143} 241}
144 242
145 243
146void StartMenu::launch() 244void StartMenu::launch()
147{ 245{
148 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); 246 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height();
149 247
150 if ( launchMenu->isVisible() ) 248 if ( launchMenu->isVisible() )
151 launchMenu->hide(); 249 launchMenu->hide();
152 else 250 else
153 launchMenu->popup( QPoint( 1, y ) ); 251 launchMenu->popup( QPoint( 1, y ) );
154} 252}
155 253
156const AppLnk* StartMenu::execToLink(const QString& appname) 254const AppLnk* StartMenu::execToLink(const QString& appname)
157{ 255{
158 const AppLnk* a = apps->findExec( appname ); 256 const AppLnk* a = apps->findExec( appname );
159 return a; 257 return a;
160} 258}
161 259
162void StartPopupMenu::keyPressEvent( QKeyEvent *e ) 260void StartPopupMenu::keyPressEvent( QKeyEvent *e )
163{ 261{
164 if ( e->key() == Key_F33 || e->key() == Key_Space ) { 262 if ( e->key() == Key_F33 || e->key() == Key_Space ) {
165 // "OK" button, little hacky 263 // "OK" button, little hacky
166 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); 264 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
167 QPopupMenu::keyPressEvent( &ke ); 265 QPopupMenu::keyPressEvent( &ke );
168 } else { 266 } else {
169 QPopupMenu::keyPressEvent( e ); 267 QPopupMenu::keyPressEvent( e );
170 } 268 }
171} 269}
270
271static int compareAppletPositions(const void *a, const void *b)
272{
273 const MenuApplet* aa = *(const MenuApplet**)a;
274 const MenuApplet* ab = *(const MenuApplet**)b;
275 int d = ab->iface->position() - aa->iface->position();
276 if ( d ) return d;
277 return QString::compare(ab->library->library(),aa->library->library());
278}
279
280void StartMenu::clearApplets()
281{
282 launchMenu-> hide();
283
284 for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) {
285 MenuApplet *applet = it. current ( );
286 if ( launchMenu ) {
287 launchMenu-> removeItem ( applet-> id );
288 delete applet-> popup;
289 }
290
291 applet-> iface-> release();
292 applet-> library-> unload();
293 delete applet-> library;
294 }
295 applets.clear();
296}
297
298
299
300void StartMenu::loadApplets()
301{
302 Config cfg( "StartMenu" );
303 cfg.setGroup( "Applets" );
304
305 // SafeMode causes too much problems, so we disable it for now --
306 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02
307
308 bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE);
309 if ( safe && !safety_tid )
310 return;
311 cfg.writeEntry("SafeMode",TRUE);
312 cfg.write();
313 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
314
315 QString path = QPEApplication::qpeDir() + "/plugins/applets";
316 QDir dir( path, "lib*.so" );
317 QStringList list = dir.entryList();
318 QStringList::Iterator it;
319 int napplets=0;
320 MenuApplet* *xapplets = new MenuApplet*[list.count()];
321 for ( it = list.begin(); it != list.end(); ++it ) {
322 if ( exclude.find( *it ) != exclude.end() )
323 continue;
324 MenuAppletInterface *iface = 0;
325 QLibrary *lib = new QLibrary( path + "/" + *it );
326 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
327 MenuApplet *applet = new MenuApplet;
328 xapplets[napplets++] = applet;
329 applet->library = lib;
330 applet->iface = iface;
331 } else {
332 exclude += *it;
333 delete lib;
334 }
335 }
336 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
337 qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions);
338
339 if ( sepId )
340 launchMenu-> removeItem ( sepId );
341 sepId = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0;
342
343 while (napplets--) {
344 MenuApplet *applet = xapplets[napplets];
345 QString lang = getenv( "LANG" );
346 QTranslator * trans = new QTranslator(qApp);
347 QString type = (*it).left( (*it).find(".") );
348 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
349 if ( trans->load( tfn ))
350 qApp->installTranslator( trans );
351 else
352 delete trans;
353
354 applet-> popup = applet-> iface-> popup ( this );
355
356 if ( applet-> popup )
357 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup );
358 else
359 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) );
360 applets.insert ( applet-> id, new MenuApplet(*applet));
361 }
362 delete xapplets;
363
364 if ( sepId && ( launchMenu-> idAt ( launchMenu-> count ( ) - 1 ) == sepId )) { // no applets
365 launchMenu-> removeItem ( sepId );
366 sepId = 0;
367 }
368 if ( !launchMenu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later
369 sepId = launchMenu-> insertSeparator ( );
370
371 if ( !safety_tid )
372 safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman)
373}
374
375void StartMenu::timerEvent(QTimerEvent* e)
376{
377 if ( e->timerId() == safety_tid ) {
378 Config cfg( "StartMenu" );
379 cfg.setGroup( "Applets" );
380 cfg.writeEntry( "SafeMode", FALSE );
381 killTimer(safety_tid);
382 safety_tid = 0;
383 }
384}
385
diff --git a/core/launcher/startmenu.h b/core/launcher/startmenu.h
index a02f39e..0a91bb8 100644
--- a/core/launcher/startmenu.h
+++ b/core/launcher/startmenu.h
@@ -1,76 +1,103 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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 __START_MENU_H__ 21#ifndef __START_MENU_H__
22#define __START_MENU_H__ 22#define __START_MENU_H__
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qlist.h> 25#include <qlist.h>
26#include <qintdict.h>
26#include <qlabel.h> 27#include <qlabel.h>
27#include <qpopupmenu.h> 28#include <qpopupmenu.h>
28 29
30#include <qpe/menuappletinterface.h>
29 31
30class AppLnkSet; 32class AppLnkSet;
31class AppLnk; 33class AppLnk;
32 34
33class StartPopupMenu : public QPopupMenu 35class StartPopupMenu : public QPopupMenu
34{ 36{
35public: 37public:
36 StartPopupMenu( QWidget *parent ) : QPopupMenu( parent ) {} 38 StartPopupMenu( QWidget *parent ) : QPopupMenu( parent ) {}
37protected: 39protected:
38 void keyPressEvent( QKeyEvent *e ); 40 void keyPressEvent( QKeyEvent *e );
39}; 41};
40 42
43class QLibrary;
44
45struct MenuApplet
46{
47#ifndef QT_NO_COMPONENT
48 QLibrary *library;
49#endif
50 MenuAppletInterface *iface;
51 int id;
52 QPopupMenu *popup;
53};
54
55
41class StartMenu : public QLabel { 56class StartMenu : public QLabel {
42 Q_OBJECT 57 Q_OBJECT
43public: 58public:
44 StartMenu( QWidget * ); 59 StartMenu( QWidget * );
45 ~StartMenu(); 60 ~StartMenu();
46 61
47 const AppLnk* execToLink(const QString& appname); 62 const AppLnk* execToLink(const QString& appname);
48 63
49public: 64public:
50 StartPopupMenu *launchMenu; 65 StartPopupMenu *launchMenu;
51 66
52public slots: 67public slots:
53 void launch( ); 68 void launch( );
54 void loadOptions( ); 69 void loadOptions( );
55 void createMenu( ); 70 void createMenu( );
71 void reloadApps( );
72 void reloadApplets( );
56 73
57protected slots: 74protected slots:
58 void itemSelected( int id ); 75 void itemSelected( int id );
59 76
60protected: 77protected:
61 virtual void mousePressEvent( QMouseEvent * ); 78 virtual void mousePressEvent( QMouseEvent * );
79 virtual void timerEvent ( QTimerEvent * );
62 80
63private: 81private:
64 bool loadMenu( AppLnkSet *folder, QPopupMenu *menu ); 82 bool loadMenu( AppLnkSet *folder, QPopupMenu *menu );
83 void loadApplets( );
84 void clearApplets( );
65 85
66private: 86private:
67 bool useWidePopupMenu; 87 bool useWidePopupMenu;
68 QString popupMenuSidePixmap; 88 QString popupMenuSidePixmap;
69 89
70 bool startButtonIsFlat; 90 bool startButtonIsFlat;
71 QString startButtonPixmap; 91 QString startButtonPixmap;
72 92
73 AppLnkSet *apps; 93 AppLnkSet *apps;
94
95 QIntDict<MenuApplet> applets;
96 QIntDict<QPopupMenu> tabdict;
97
98// QValueList<MenuApplet> appletList;
99 int safety_tid;
100 int sepId;
74}; 101};
75 102
76#endif // __START_MENU_H__ 103#endif // __START_MENU_H__
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp
index 697971d..406c662 100644
--- a/core/launcher/systray.cpp
+++ b/core/launcher/systray.cpp
@@ -9,144 +9,144 @@
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#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/qlibrary.h> 22#include <qpe/qlibrary.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24 24
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qdir.h> 26#include <qdir.h>
27#include <qtranslator.h> 27#include <qtranslator.h>
28 28
29#include "quicklauncher.h" 29#include "quicklauncher.h"
30#include "systray.h" 30#include "systray.h"
31 31
32#include <stdlib.h> 32#include <stdlib.h>
33 33
34#ifdef SINGLE_APP 34#ifdef SINGLE_APP
35#include "clockappletimpl.h" 35#include "clockappletimpl.h"
36#endif 36#endif
37 37
38SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) 38SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0)
39{ 39{
40 safety_tid = 0; 40 safety_tid = 0;
41 //setFrameStyle( QFrame::Panel | QFrame::Sunken ); 41 //setFrameStyle( QFrame::Panel | QFrame::Sunken );
42 loadApplets(); 42 loadApplets();
43} 43}
44 44
45static int compareAppletPositions(const void *a, const void *b) 45static int compareAppletPositions(const void *a, const void *b)
46{ 46{
47 const TaskbarApplet* aa = *(const TaskbarApplet**)a; 47 const TaskbarApplet* aa = *(const TaskbarApplet**)a;
48 const TaskbarApplet* ab = *(const TaskbarApplet**)b; 48 const TaskbarApplet* ab = *(const TaskbarApplet**)b;
49 int d = ab->iface->position() - aa->iface->position(); 49 int d = ab->iface->position() - aa->iface->position();
50 if ( d ) return d; 50 if ( d ) return d;
51 return QString::compare(ab->library->library(),aa->library->library()); 51 return QString::compare(ab->library->library(),aa->library->library());
52} 52}
53 53
54void SysTray::loadApplets() 54void SysTray::loadApplets()
55{ 55{
56 clearApplets(); 56 clearApplets();
57 addApplets(); 57 addApplets();
58} 58}
59 59
60void SysTray::clearApplets() 60void SysTray::clearApplets()
61{ 61{
62 hide(); 62 hide();
63#ifndef SINGLE_APP 63#ifndef SINGLE_APP
64 QValueList<TaskbarApplet>::Iterator mit; 64 QValueList<TaskbarApplet>::Iterator mit;
65 for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { 65 for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) {
66 (*mit).iface->release(); 66 (*mit).iface->release();
67 (*mit).library->unload(); 67 (*mit).library->unload();
68 delete (*mit).library; 68 delete (*mit).library;
69 } 69 }
70#endif 70#endif
71 appletList.clear(); 71 appletList.clear();
72 if ( layout ) 72 if ( layout )
73 delete layout; 73 delete layout;
74 layout = new QHBoxLayout( this, 0, 1 ); 74 layout = new QHBoxLayout( this, 0, 1 );
75 layout->setAutoAdd(TRUE); 75 layout->setAutoAdd(TRUE);
76} 76}
77 77
78void SysTray::addApplets() 78void SysTray::addApplets()
79{ 79{
80#ifndef SINGLE_APP 80#ifndef SINGLE_APP
81 Config cfg( "Taskbar" ); 81 Config cfg( "Taskbar" );
82 cfg.setGroup( "Applets" ); 82 cfg.setGroup( "Applets" );
83 83
84 // SafeMode causes too much problems, so we disable it for now -- 84 // SafeMode causes too much problems, so we disable it for now --
85 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 85 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02
86 86
87 bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); 87 bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE);
88 if ( safe && !safety_tid ) 88 if ( safe && !safety_tid )
89 return; 89 return;
90 cfg.writeEntry("SafeMode",TRUE); 90 cfg.writeEntry("SafeMode",TRUE);
91 cfg.write(); 91 cfg.write();
92 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); 92 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
93 93
94 QString path = QPEApplication::qpeDir() + "/plugins/applets"; 94 QString path = QPEApplication::qpeDir() + "/plugins/applets";
95 QDir dir( path, "lib*.so" ); 95 QDir dir( path, "lib*.so" );
96 QStringList list = dir.entryList(); 96 QStringList list = dir.entryList();
97 QStringList::Iterator it; 97 QStringList::Iterator it;
98 int napplets=0; 98 int napplets=0;
99 TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; 99 TaskbarApplet* *applets = new TaskbarApplet*[list.count()];
100 for ( it = list.begin(); it != list.end(); ++it ) { 100 for ( it = list.begin(); it != list.end(); ++it ) {
101 if ( exclude.find( *it ) != exclude.end() ) 101 if ( exclude.find( *it ) != exclude.end() )
102 continue; 102 continue;
103 TaskbarAppletInterface *iface = 0; 103 TaskbarAppletInterface *iface = 0;
104 QLibrary *lib = new QLibrary( path + "/" + *it ); 104 QLibrary *lib = new QLibrary( path + "/" + *it );
105 if ( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) { 105 if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
106 TaskbarApplet *applet = new TaskbarApplet; 106 TaskbarApplet *applet = new TaskbarApplet;
107 applets[napplets++] = applet; 107 applets[napplets++] = applet;
108 applet->library = lib; 108 applet->library = lib;
109 applet->iface = iface; 109 applet->iface = iface;
110 } else { 110 } else {
111 exclude += *it; 111 exclude += *it;
112 delete lib; 112 delete lib;
113 } 113 }
114 } 114 }
115 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 115 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
116 qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); 116 qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions);
117 while (napplets--) { 117 while (napplets--) {
118 TaskbarApplet *applet = applets[napplets]; 118 TaskbarApplet *applet = applets[napplets];
119 applet->applet = applet->iface->applet( this ); 119 applet->applet = applet->iface->applet( this );
120 appletList.append(*applet); 120 appletList.append(*applet);
121 QString lang = getenv( "LANG" ); 121 QString lang = getenv( "LANG" );
122 QTranslator * trans = new QTranslator(qApp); 122 QTranslator * trans = new QTranslator(qApp);
123 QString type = (*it).left( (*it).find(".") ); 123 QString type = (*it).left( (*it).find(".") );
124 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 124 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
125 if ( trans->load( tfn )) 125 if ( trans->load( tfn ))
126 qApp->installTranslator( trans ); 126 qApp->installTranslator( trans );
127 else 127 else
128 delete trans; 128 delete trans;
129 } 129 }
130 delete applets; 130 delete applets;
131#else 131#else
132 TaskbarApplet applet; 132 TaskbarApplet applet;
133 applet.iface = new ClockAppletImpl(); 133 applet.iface = new ClockAppletImpl();
134 applet.applet = applet.iface->applet( this ); 134 applet.applet = applet.iface->applet( this );
135 appletList.append( a ); 135 appletList.append( a );
136#endif 136#endif
137 show(); 137 show();
138 138
139 if ( !safety_tid ) 139 if ( !safety_tid )
140 safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman) 140 safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman)
141} 141}
142 142
143void SysTray::timerEvent(QTimerEvent* e) 143void SysTray::timerEvent(QTimerEvent* e)
144{ 144{
145 if ( e->timerId() == safety_tid ) { 145 if ( e->timerId() == safety_tid ) {
146 Config cfg( "Taskbar" ); 146 Config cfg( "Taskbar" );
147 cfg.setGroup( "Applets" ); 147 cfg.setGroup( "Applets" );
148 cfg.writeEntry( "SafeMode", FALSE ); 148 cfg.writeEntry( "SafeMode", FALSE );
149 killTimer(safety_tid); 149 killTimer(safety_tid);
150 safety_tid = 0; 150 safety_tid = 0;
151 } 151 }
152} 152}
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 46bcdb3..7d1aaf1 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -98,234 +98,241 @@ static bool initNumLock()
98#ifdef QPE_INITIAL_NUMLOCK_STATE 98#ifdef QPE_INITIAL_NUMLOCK_STATE
99 QPE_INITIAL_NUMLOCK_STATE 99 QPE_INITIAL_NUMLOCK_STATE
100#endif 100#endif
101 return FALSE; 101 return FALSE;
102} 102}
103 103
104class LockKeyState : public QWidget 104class LockKeyState : public QWidget
105{ 105{
106public: 106public:
107 LockKeyState( QWidget *parent ) : 107 LockKeyState( QWidget *parent ) :
108 QWidget(parent), 108 QWidget(parent),
109 nl(initNumLock()), cl(FALSE) 109 nl(initNumLock()), cl(FALSE)
110 { 110 {
111 nl_pm = Resource::loadPixmap("numlock"); 111 nl_pm = Resource::loadPixmap("numlock");
112 cl_pm = Resource::loadPixmap("capslock"); 112 cl_pm = Resource::loadPixmap("capslock");
113 } 113 }
114 QSize sizeHint() const 114 QSize sizeHint() const
115 { 115 {
116 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); 116 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
117 } 117 }
118 void toggleNumLockState() 118 void toggleNumLockState()
119 { 119 {
120 nl = !nl; repaint(); 120 nl = !nl; repaint();
121 } 121 }
122 void toggleCapsLockState() 122 void toggleCapsLockState()
123 { 123 {
124 cl = !cl; repaint(); 124 cl = !cl; repaint();
125 } 125 }
126 void paintEvent( QPaintEvent * ) 126 void paintEvent( QPaintEvent * )
127 { 127 {
128 int y = (height()-sizeHint().height())/2; 128 int y = (height()-sizeHint().height())/2;
129 QPainter p(this); 129 QPainter p(this);
130 if ( nl ) 130 if ( nl )
131 p.drawPixmap(1,y,nl_pm); 131 p.drawPixmap(1,y,nl_pm);
132 if ( cl ) 132 if ( cl )
133 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); 133 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
134 } 134 }
135private: 135private:
136 QPixmap nl_pm, cl_pm; 136 QPixmap nl_pm, cl_pm;
137 bool nl, cl; 137 bool nl, cl;
138}; 138};
139 139
140TaskBar::~TaskBar() 140TaskBar::~TaskBar()
141{ 141{
142} 142}
143 143
144 144
145TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) 145TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
146{ 146{
147 Global::setBuiltinCommands(builtins); 147 Global::setBuiltinCommands(builtins);
148 148
149 sm = new StartMenu( this ); 149 sm = new StartMenu( this );
150 150
151 inputMethods = new InputMethods( this ); 151 inputMethods = new InputMethods( this );
152 connect( inputMethods, SIGNAL(inputToggled(bool)), 152 connect( inputMethods, SIGNAL(inputToggled(bool)),
153 this, SLOT(calcMaxWindowRect()) ); 153 this, SLOT(calcMaxWindowRect()) );
154 //new QuickLauncher( this ); 154 //new QuickLauncher( this );
155 155
156 stack = new QWidgetStack( this ); 156 stack = new QWidgetStack( this );
157 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 157 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
158 label = new QLabel(stack); 158 label = new QLabel(stack);
159 159
160 //mru = new MRUList( stack ); 160 //mru = new MRUList( stack );
161 //stack->raiseWidget( mru ); 161 //stack->raiseWidget( mru );
162 162
163 runningAppBar = new RunningAppBar(stack); 163 runningAppBar = new RunningAppBar(stack);
164 stack->raiseWidget(runningAppBar); 164 stack->raiseWidget(runningAppBar);
165 165
166 waitIcon = new Wait( this ); 166 waitIcon = new Wait( this );
167 (void) new AppIcons( this ); 167 (void) new AppIcons( this );
168 168
169 sysTray = new SysTray( this ); 169 sysTray = new SysTray( this );
170 170
171 // ## make customizable in some way? 171 // ## make customizable in some way?
172#ifdef QT_QWS_CUSTOM 172#ifdef QT_QWS_CUSTOM
173 lockState = new LockKeyState( this ); 173 lockState = new LockKeyState( this );
174#else 174#else
175 lockState = 0; 175 lockState = 0;
176#endif 176#endif
177 177
178#if defined(Q_WS_QWS) 178#if defined(Q_WS_QWS)
179#if !defined(QT_NO_COP) 179#if !defined(QT_NO_COP)
180 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); 180 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
181 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 181 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
182 this, SLOT(receive(const QCString&, const QByteArray&)) ); 182 this, SLOT(receive(const QCString&, const QByteArray&)) );
183#endif 183#endif
184#endif 184#endif
185 waitTimer = new QTimer( this ); 185 waitTimer = new QTimer( this );
186 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); 186 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
187 clearer = new QTimer( this ); 187 clearer = new QTimer( this );
188 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); 188 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
189 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); 189 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show()));
190} 190}
191 191
192void TaskBar::setStatusMessage( const QString &text ) 192void TaskBar::setStatusMessage( const QString &text )
193{ 193{
194 label->setText( text ); 194 if ( !text.isEmpty() ) {
195 stack->raiseWidget( label ); 195 label->setText( text );
196 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) 196 stack->raiseWidget( label );
197 sysTray->hide(); 197 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
198 clearer->start( 3000 ); 198 sysTray->hide();
199 clearer->start( 3000, TRUE );
200 } else {
201 clearStatusBar();
202 }
199} 203}
200 204
201void TaskBar::clearStatusBar() 205void TaskBar::clearStatusBar()
202{ 206{
203 label->clear(); 207 label->clear();
204 stack->raiseWidget(runningAppBar); 208 stack->raiseWidget(runningAppBar);
205 // stack->raiseWidget( mru ); 209 // stack->raiseWidget( mru );
206} 210}
207 211
208void TaskBar::startWait() 212void TaskBar::startWait()
209{ 213{
210 waitIcon->setWaiting( true ); 214 waitIcon->setWaiting( true );
211 // a catchall stop after 10 seconds... 215 // a catchall stop after 10 seconds...
212 waitTimer->start( 10 * 1000, true ); 216 waitTimer->start( 10 * 1000, true );
213} 217}
214 218
215void TaskBar::stopWait(const QString& app) 219void TaskBar::stopWait(const QString& /*app*/)
216{ 220{
217 waitTimer->stop(); 221 waitTimer->stop();
218 //mru->addTask(sm->execToLink(app)); 222 //mru->addTask(sm->execToLink(app));
219 waitIcon->setWaiting( false ); 223 waitIcon->setWaiting( false );
220} 224}
221 225
222void TaskBar::stopWait() 226void TaskBar::stopWait()
223{ 227{
224 waitTimer->stop(); 228 waitTimer->stop();
225 229
226 waitIcon->setWaiting( false ); 230 waitIcon->setWaiting( false );
227} 231}
228 232
229void TaskBar::resizeEvent( QResizeEvent *e ) 233void TaskBar::resizeEvent( QResizeEvent *e )
230{ 234{
231 QHBox::resizeEvent( e ); 235 QHBox::resizeEvent( e );
232 calcMaxWindowRect(); 236 calcMaxWindowRect();
233} 237}
234 238
235void TaskBar::styleChange( QStyle &s ) 239void TaskBar::styleChange( QStyle &s )
236{ 240{
237 QHBox::styleChange( s ); 241 QHBox::styleChange( s );
238 calcMaxWindowRect(); 242 calcMaxWindowRect();
239} 243}
240 244
241void TaskBar::calcMaxWindowRect() 245void TaskBar::calcMaxWindowRect()
242{ 246{
243#ifdef Q_WS_QWS 247#ifdef Q_WS_QWS
244 QRect wr; 248 QRect wr;
245 int displayWidth = qApp->desktop()->width(); 249 int displayWidth = qApp->desktop()->width();
246 QRect ir = inputMethods->inputRect(); 250 QRect ir = inputMethods->inputRect();
247 if ( ir.isValid() ) { 251 if ( ir.isValid() ) {
248 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 252 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
249 } else { 253 } else {
250 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 254 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
251 } 255 }
252 256
253#if QT_VERSION < 300 257#if QT_VERSION < 300
254 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 258 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
255 QSize(qt_screen->width(),qt_screen->height())) 259 QSize(qt_screen->width(),qt_screen->height()))
256 ); 260 );
257#else 261#else
258 QWSServer::setMaxWindowRect( wr ); 262 QWSServer::setMaxWindowRect( wr );
259#endif 263#endif
260#endif 264#endif
261} 265}
262 266
263void TaskBar::receive( const QCString &msg, const QByteArray &data ) 267void TaskBar::receive( const QCString &msg, const QByteArray &data )
264{ 268{
265 QDataStream stream( data, IO_ReadOnly ); 269 QDataStream stream( data, IO_ReadOnly );
266 if ( msg == "message(QString)" ) { 270 if ( msg == "message(QString)" ) {
267 QString text; 271 QString text;
268 stream >> text; 272 stream >> text;
269 setStatusMessage( text ); 273 setStatusMessage( text );
270 } else if ( msg == "hideInputMethod()" ) { 274 } else if ( msg == "hideInputMethod()" ) {
271 inputMethods->hideInputMethod(); 275 inputMethods->hideInputMethod();
272 } else if ( msg == "showInputMethod()" ) { 276 } else if ( msg == "showInputMethod()" ) {
273 inputMethods->showInputMethod(); 277 inputMethods->showInputMethod();
274 } else if ( msg == "reloadInputMethods()" ) { 278 } else if ( msg == "reloadInputMethods()" ) {
275 inputMethods->loadInputMethods(); 279 inputMethods->loadInputMethods();
280 } else if ( msg == "reloadApps()" ) {
281 sm->reloadApps();
276 } else if ( msg == "reloadApplets()" ) { 282 } else if ( msg == "reloadApplets()" ) {
277 sysTray->clearApplets(); 283 sysTray->clearApplets();
278 sysTray->addApplets(); 284 sysTray->addApplets();
285 sm->reloadApplets();
279 } else if ( msg == "soundAlarm()" ) { 286 } else if ( msg == "soundAlarm()" ) {
280 Desktop::soundAlarm(); 287 Desktop::soundAlarm();
281 } 288 }
282 else if ( msg == "setLed(int,bool)" ) { 289 else if ( msg == "setLed(int,bool)" ) {
283 int led, status; 290 int led, status;
284 stream >> led >> status; 291 stream >> led >> status;
285 292
286 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); 293 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( );
287 if ( ll. count ( )){ 294 if ( ll. count ( )){
288 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; 295 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0];
289 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); 296 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow );
290 297
291 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); 298 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off );
292 } 299 }
293 } 300 }
294} 301}
295 302
296QWidget *TaskBar::calibrate(bool) 303QWidget *TaskBar::calibrate(bool)
297{ 304{
298#ifdef Q_WS_QWS 305#ifdef Q_WS_QWS
299 Calibrate *c = new Calibrate; 306 Calibrate *c = new Calibrate;
300 c->show(); 307 c->show();
301 return c; 308 return c;
302#else 309#else
303 return 0; 310 return 0;
304#endif 311#endif
305} 312}
306 313
307void TaskBar::toggleNumLockState() 314void TaskBar::toggleNumLockState()
308{ 315{
309 if ( lockState ) lockState->toggleNumLockState(); 316 if ( lockState ) lockState->toggleNumLockState();
310} 317}
311 318
312void TaskBar::toggleCapsLockState() 319void TaskBar::toggleCapsLockState()
313{ 320{
314 if ( lockState ) lockState->toggleCapsLockState(); 321 if ( lockState ) lockState->toggleCapsLockState();
315} 322}
316 323
317void TaskBar::toggleSymbolInput() 324void TaskBar::toggleSymbolInput()
318{ 325{
319 if ( inputMethods->currentShown() == "Unicode" ) { 326 if ( inputMethods->currentShown() == "Unicode" ) {
320 inputMethods->hideInputMethod(); 327 inputMethods->hideInputMethod();
321 } else { 328 } else {
322 inputMethods->showInputMethod("Unicode"); 329 inputMethods->showInputMethod("Unicode");
323 } 330 }
324} 331}
325 332
326bool TaskBar::recoverMemory() 333bool TaskBar::recoverMemory()
327{ 334{
328 //eturn mru->quitOldApps(); 335 //eturn mru->quitOldApps();
329 return true; 336 return true;
330} 337}
331 338