summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-04-03 08:12:17 (UTC)
committer harlekin <harlekin>2002-04-03 08:12:17 (UTC)
commit48f7cbcb23cfd4daff6218d8902e0049af674b9f (patch) (unidiff)
tree49cbc6aa015290a143ff3c0652de906ad3c8fc71
parent14acfe3608e8c57e5cacb08daed8944946e03d42 (diff)
downloadopie-48f7cbcb23cfd4daff6218d8902e0049af674b9f.zip
opie-48f7cbcb23cfd4daff6218d8902e0049af674b9f.tar.gz
opie-48f7cbcb23cfd4daff6218d8902e0049af674b9f.tar.bz2
changed MRUlist to a taskbar, only running apps are shown
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp11
-rw-r--r--core/launcher/mrulist.cpp46
-rw-r--r--core/launcher/mrulist.h1
3 files changed, 28 insertions, 30 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 17a30e6..1449269 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -427,512 +427,517 @@ void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
427 return; 427 return;
428 428
429 if ( t->isEnabled() && isEnabled() ) { 429 if ( t->isEnabled() && isEnabled() ) {
430#if defined(_WS_WIN32_) 430#if defined(_WS_WIN32_)
431 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 431 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
432 p->setPen( colorGroup().buttonText() ); 432 p->setPen( colorGroup().buttonText() );
433 else 433 else
434 p->setPen( colorGroup().foreground() ); 434 p->setPen( colorGroup().foreground() );
435#else 435#else
436 p->setPen( colorGroup().foreground() ); 436 p->setPen( colorGroup().foreground() );
437#endif 437#endif
438 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 438 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
439 } else { 439 } else {
440 p->setPen( palette().disabled().foreground() ); 440 p->setPen( palette().disabled().foreground() );
441 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 441 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
442 } 442 }
443} 443}
444 444
445//--------------------------------------------------------------------------- 445//---------------------------------------------------------------------------
446 446
447Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 447Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
448 : QMainWindow( parent, name, fl ) 448 : QMainWindow( parent, name, fl )
449{ 449{
450 setCaption( tr("Launcher") ); 450 setCaption( tr("Launcher") );
451 451
452 syncDialog = 0; 452 syncDialog = 0;
453 453
454 // we have a pretty good idea how big we'll be 454 // we have a pretty good idea how big we'll be
455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
456 456
457 tabs = 0; 457 tabs = 0;
458 rootFolder = 0; 458 rootFolder = 0;
459 docsFolder = 0; 459 docsFolder = 0;
460 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know 460 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
461 //uidgen.store( stamp ); 461 //uidgen.store( stamp );
462 m_timeStamp = QString::number( stamp ); 462 m_timeStamp = QString::number( stamp );
463 463
464 tabs = new CategoryTabWidget( this ); 464 tabs = new CategoryTabWidget( this );
465 tabs->setMaximumWidth( qApp->desktop()->width() ); 465 tabs->setMaximumWidth( qApp->desktop()->width() );
466 setCentralWidget( tabs ); 466 setCentralWidget( tabs );
467 467
468 connect( tabs, SIGNAL(selected(const QString&)), 468 connect( tabs, SIGNAL(selected(const QString&)),
469 this, SLOT(viewSelected(const QString&)) ); 469 this, SLOT(viewSelected(const QString&)) );
470 connect( tabs, SIGNAL(clicked(const AppLnk*)), 470 connect( tabs, SIGNAL(clicked(const AppLnk*)),
471 this, SLOT(select(const AppLnk*))); 471 this, SLOT(select(const AppLnk*)));
472 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 472 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
473 this, SLOT(properties(AppLnk*))); 473 this, SLOT(properties(AppLnk*)));
474 474
475#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 475#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
479#endif 479#endif
480 480
481 storage = new StorageInfo( this ); 481 storage = new StorageInfo( this );
482 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 482 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
483 483
484 updateTabs(); 484 updateTabs();
485 485
486 preloadApps(); 486 preloadApps();
487 487
488 in_lnk_props = FALSE; 488 in_lnk_props = FALSE;
489 got_lnk_change = FALSE; 489 got_lnk_change = FALSE;
490} 490}
491 491
492Launcher::~Launcher() 492Launcher::~Launcher()
493{ 493{
494} 494}
495 495
496static bool isVisibleWindow(int wid) 496static bool isVisibleWindow(int wid)
497{ 497{
498 const QList<QWSWindow> &list = qwsServer->clientWindows(); 498 const QList<QWSWindow> &list = qwsServer->clientWindows();
499 QWSWindow* w; 499 QWSWindow* w;
500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
501 if ( w->winId() == wid ) 501 if ( w->winId() == wid )
502 return !w->isFullyObscured(); 502 return !w->isFullyObscured();
503 } 503 }
504 return FALSE; 504 return FALSE;
505} 505}
506 506
507void Launcher::showMaximized() 507void Launcher::showMaximized()
508{ 508{
509 if ( isVisibleWindow( winId() ) ) 509 if ( isVisibleWindow( winId() ) )
510 doMaximize(); 510 doMaximize();
511 else 511 else
512 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 512 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
513} 513}
514 514
515void Launcher::doMaximize() 515void Launcher::doMaximize()
516{ 516{
517 QMainWindow::showMaximized(); 517 QMainWindow::showMaximized();
518} 518}
519 519
520void Launcher::updateMimeTypes() 520void Launcher::updateMimeTypes()
521{ 521{
522 MimeType::clear(); 522 MimeType::clear();
523 updateMimeTypes(rootFolder); 523 updateMimeTypes(rootFolder);
524} 524}
525 525
526void Launcher::updateMimeTypes(AppLnkSet* folder) 526void Launcher::updateMimeTypes(AppLnkSet* folder)
527{ 527{
528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
529 AppLnk *app = it.current(); 529 AppLnk *app = it.current();
530 if ( app->type() == "Folder" ) 530 if ( app->type() == "Folder" )
531 updateMimeTypes((AppLnkSet *)app); 531 updateMimeTypes((AppLnkSet *)app);
532 else { 532 else {
533 MimeType::registerApp(*app); 533 MimeType::registerApp(*app);
534 } 534 }
535 } 535 }
536} 536}
537 537
538void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 538void Launcher::loadDocs() // ok here comes a hack belonging to Global::
539{ 539{
540 qWarning("loading Documents" ); 540 qWarning("loading Documents" );
541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); 541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() );
542 delete docsFolder; 542 delete docsFolder;
543 docsFolder = new DocLnkSet; 543 docsFolder = new DocLnkSet;
544 qWarning("new DocLnkSet" ); 544 qWarning("new DocLnkSet" );
545 DocLnkSet *tmp = 0; 545 DocLnkSet *tmp = 0;
546 QString home = QString(getenv("HOME")) + "/Documents"; 546 QString home = QString(getenv("HOME")) + "/Documents";
547 tmp = new DocLnkSet( home , QString::null); 547 tmp = new DocLnkSet( home , QString::null);
548 docsFolder->appendFrom( *tmp ); 548 docsFolder->appendFrom( *tmp );
549 delete tmp; 549 delete tmp;
550 // find out wich filesystems are new in this round 550 // find out wich filesystems are new in this round
551 // We will do this by having a timestamp inside each mountpoint 551 // We will do this by having a timestamp inside each mountpoint
552 // if the current timestamp doesn't match this is a new file system and 552 // if the current timestamp doesn't match this is a new file system and
553 // come up with our MediumMountGui :) let the hacking begin 553 // come up with our MediumMountGui :) let the hacking begin
554 int stamp = uidgen.generate(); 554 int stamp = uidgen.generate();
555 555
556 QString newStamp = QString::number( stamp ); // generates newtime Stamp 556 QString newStamp = QString::number( stamp ); // generates newtime Stamp
557 StorageInfo storage; 557 StorageInfo storage;
558 const QList<FileSystem> &fileSystems = storage.fileSystems(); 558 const QList<FileSystem> &fileSystems = storage.fileSystems();
559 QListIterator<FileSystem> it ( fileSystems ); 559 QListIterator<FileSystem> it ( fileSystems );
560 for ( ; it.current(); ++it ) { 560 for ( ; it.current(); ++it ) {
561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
562 qWarning("%s is removeable", (*it)->path().latin1() ); 562 qWarning("%s is removeable", (*it)->path().latin1() );
563 OConfig cfg( (*it)->path() + "/.opiestorage.cf"); 563 OConfig cfg( (*it)->path() + "/.opiestorage.cf");
564 cfg.setGroup("main"); 564 cfg.setGroup("main");
565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
566 if( stamp == m_timeStamp ){ // ok we know this card 566 if( stamp == m_timeStamp ){ // ok we know this card
567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
568 // we need to scan the list now. Hopefully the cache will be there 568 // we need to scan the list now. Hopefully the cache will be there
569 // read the mimetypes from the config and search for documents 569 // read the mimetypes from the config and search for documents
570 QStringList mimetypes = configToMime( &cfg); 570 QStringList mimetypes = configToMime( &cfg);
571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
572 docsFolder->appendFrom( *tmp ); 572 docsFolder->appendFrom( *tmp );
573 delete tmp; 573 delete tmp;
574 574
575 }else{ // come up with the gui cause this a new card 575 }else{ // come up with the gui cause this a new card
576 MediumMountGui medium((*it)->path() ); 576 MediumMountGui medium((*it)->path() );
577 if( medium.check() ){ // we did not ask before or ask again is off 577 if( medium.check() ){ // we did not ask before or ask again is off
578 if( medium.exec() ){ // he clicked yes so search it 578 if( medium.exec() ){ // he clicked yes so search it
579 // speicher 579 // speicher
580 cfg.read(); // cause of a race we need to reread 580 cfg.read(); // cause of a race we need to reread
581 cfg.writeEntry("timestamp", newStamp ); 581 cfg.writeEntry("timestamp", newStamp );
582 }// no else 582 }// no else
583 }else{ // we checked 583 }else{ // we checked
584 // do something different see what we need to do 584 // do something different see what we need to do
585 // let's see if we should check the device 585 // let's see if we should check the device
586 cfg.setGroup("main" ); 586 cfg.setGroup("main" );
587 bool check = cfg.readBoolEntry("autocheck", true ); 587 bool check = cfg.readBoolEntry("autocheck", true );
588 if( check ){ // find the documents 588 if( check ){ // find the documents
589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); 589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
590 docsFolder->appendFrom( *tmp ); 590 docsFolder->appendFrom( *tmp );
591 delete tmp; 591 delete tmp;
592 } 592 }
593 } 593 }
594 } 594 }
595 } 595 }
596 } 596 }
597 m_timeStamp = newStamp; 597 m_timeStamp = newStamp;
598} 598}
599 599
600void Launcher::updateTabs() 600void Launcher::updateTabs()
601{ 601{
602 MimeType::updateApplications(); // ### reads all applnks twice 602 MimeType::updateApplications(); // ### reads all applnks twice
603 603
604 delete rootFolder; 604 delete rootFolder;
605 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 605 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
606 606
607 loadDocs(); 607 loadDocs();
608 608
609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
610} 610}
611 611
612void Launcher::updateDocs() 612void Launcher::updateDocs()
613{ 613{
614 loadDocs(); 614 loadDocs();
615 tabs->updateDocs(docsFolder,storage->fileSystems()); 615 tabs->updateDocs(docsFolder,storage->fileSystems());
616} 616}
617 617
618void Launcher::viewSelected(const QString& s) 618void Launcher::viewSelected(const QString& s)
619{ 619{
620 setCaption( s + tr(" - Launcher") ); 620 setCaption( s + tr(" - Launcher") );
621} 621}
622 622
623void Launcher::nextView() 623void Launcher::nextView()
624{ 624{
625 tabs->nextTab(); 625 tabs->nextTab();
626} 626}
627 627
628 628
629void Launcher::select( const AppLnk *appLnk ) 629void Launcher::select( const AppLnk *appLnk )
630{ 630{
631 if ( appLnk->type() == "Folder" ) { 631 if ( appLnk->type() == "Folder" ) {
632 // Not supported: flat is simpler for the user 632 // Not supported: flat is simpler for the user
633 } else { 633 } else {
634 if ( appLnk->exec().isNull() ) { 634 if ( appLnk->exec().isNull() ) {
635 QMessageBox::information(this,tr("No application"), 635 QMessageBox::information(this,tr("No application"),
636 tr("<p>No application is defined for this document." 636 tr("<p>No application is defined for this document."
637 "<p>Type is %1.").arg(appLnk->type())); 637 "<p>Type is %1.").arg(appLnk->type()));
638 return; 638 return;
639 } 639 }
640 tabs->setBusy(TRUE); 640 tabs->setBusy(TRUE);
641 emit executing( appLnk ); 641 emit executing( appLnk );
642 appLnk->execute(); 642 appLnk->execute();
643 } 643 }
644} 644}
645 645
646void Launcher::externalSelected(const AppLnk *appLnk) 646void Launcher::externalSelected(const AppLnk *appLnk)
647{ 647{
648 tabs->setBusy(TRUE); 648 tabs->setBusy(TRUE);
649 emit executing( appLnk ); 649 emit executing( appLnk );
650} 650}
651 651
652void Launcher::properties( AppLnk *appLnk ) 652void Launcher::properties( AppLnk *appLnk )
653{ 653{
654 if ( appLnk->type() == "Folder" ) { 654 if ( appLnk->type() == "Folder" ) {
655 // Not supported: flat is simpler for the user 655 // Not supported: flat is simpler for the user
656 } else { 656 } else {
657 in_lnk_props = TRUE; 657 in_lnk_props = TRUE;
658 got_lnk_change = FALSE; 658 got_lnk_change = FALSE;
659 LnkProperties prop(appLnk); 659 LnkProperties prop(appLnk);
660 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 660 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
661 prop.showMaximized(); 661 prop.showMaximized();
662 prop.exec(); 662 prop.exec();
663 in_lnk_props = FALSE; 663 in_lnk_props = FALSE;
664 if ( got_lnk_change ) { 664 if ( got_lnk_change ) {
665 updateLink(lnk_change); 665 updateLink(lnk_change);
666 } 666 }
667 } 667 }
668} 668}
669 669
670void Launcher::updateLink(const QString& link) 670void Launcher::updateLink(const QString& link)
671{ 671{
672 if (link.isNull()) 672 if (link.isNull())
673 updateTabs(); 673 updateTabs();
674 else if (link.isEmpty()) 674 else if (link.isEmpty())
675 updateDocs(); 675 updateDocs();
676 else 676 else
677 tabs->updateLink(link); 677 tabs->updateLink(link);
678} 678}
679 679
680void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 680void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
681{ 681{
682 QDataStream stream( data, IO_ReadOnly ); 682 QDataStream stream( data, IO_ReadOnly );
683 if ( msg == "linkChanged(QString)" ) { 683 if ( msg == "closing(QString)" ){
684 QString link; 684 QString app;
685 stream >> link; 685 stream >> app;
686 qWarning("app closed %s", app.latin1() );
687 MRUList::removeTask( app );
688 }else if ( msg == "linkChanged(QString)" ) {
689 QString link;
690 stream >> link;
686 if ( in_lnk_props ) { 691 if ( in_lnk_props ) {
687 got_lnk_change = TRUE; 692 got_lnk_change = TRUE;
688 lnk_change = link; 693 lnk_change = link;
689 } else { 694 } else {
690 updateLink(link); 695 updateLink(link);
691 } 696 }
692 } else if ( msg == "busy()" ) { 697 } else if ( msg == "busy()" ) {
693 emit busy(); 698 emit busy();
694 } else if ( msg == "notBusy(QString)" ) { 699 } else if ( msg == "notBusy(QString)" ) {
695 QString app; 700 QString app;
696 stream >> app; 701 stream >> app;
697 tabs->setBusy(FALSE); 702 tabs->setBusy(FALSE);
698 emit notBusy(app); 703 emit notBusy(app);
699 } else if ( msg == "mkdir(QString)" ) { 704 } else if ( msg == "mkdir(QString)" ) {
700 QString dir; 705 QString dir;
701 stream >> dir; 706 stream >> dir;
702 if ( !dir.isEmpty() ) 707 if ( !dir.isEmpty() )
703 mkdir( dir ); 708 mkdir( dir );
704 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 709 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
705 QString baseFile, sigFile; 710 QString baseFile, sigFile;
706 stream >> baseFile >> sigFile; 711 stream >> baseFile >> sigFile;
707 QRsync::generateSignature( baseFile, sigFile ); 712 QRsync::generateSignature( baseFile, sigFile );
708 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 713 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
709 QString baseFile, sigFile, deltaFile; 714 QString baseFile, sigFile, deltaFile;
710 stream >> baseFile >> sigFile >> deltaFile; 715 stream >> baseFile >> sigFile >> deltaFile;
711 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 716 QRsync::generateDiff( baseFile, sigFile, deltaFile );
712 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 717 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
713 QString baseFile, deltaFile; 718 QString baseFile, deltaFile;
714 stream >> baseFile >> deltaFile; 719 stream >> baseFile >> deltaFile;
715 if ( !QFile::exists( baseFile ) ) { 720 if ( !QFile::exists( baseFile ) ) {
716 QFile f( baseFile ); 721 QFile f( baseFile );
717 f.open( IO_WriteOnly ); 722 f.open( IO_WriteOnly );
718 f.close(); 723 f.close();
719 } 724 }
720 QRsync::applyDiff( baseFile, deltaFile ); 725 QRsync::applyDiff( baseFile, deltaFile );
721 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 726 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
722 e << baseFile; 727 e << baseFile;
723 } else if ( msg == "rdiffCleanup()" ) { 728 } else if ( msg == "rdiffCleanup()" ) {
724 mkdir( "/tmp/rdiff" ); 729 mkdir( "/tmp/rdiff" );
725 QDir dir; 730 QDir dir;
726 dir.setPath( "/tmp/rdiff" ); 731 dir.setPath( "/tmp/rdiff" );
727 QStringList entries = dir.entryList(); 732 QStringList entries = dir.entryList();
728 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 733 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
729 dir.remove( *it ); 734 dir.remove( *it );
730 } else if ( msg == "sendHandshakeInfo()" ) { 735 } else if ( msg == "sendHandshakeInfo()" ) {
731 QString home = getenv( "HOME" ); 736 QString home = getenv( "HOME" );
732 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 737 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
733 e << home; 738 e << home;
734 int locked = (int) Desktop::screenLocked(); 739 int locked = (int) Desktop::screenLocked();
735 e << locked; 740 e << locked;
736 // register an app for autostart 741 // register an app for autostart
737 // if clear is send the list is cleared. 742 // if clear is send the list is cleared.
738 } else if ( msg == "autoStart(QString)" ) { 743 } else if ( msg == "autoStart(QString)" ) {
739 QString appName; 744 QString appName;
740 stream >> appName; 745 stream >> appName;
741 Config cfg( "autostart" ); 746 Config cfg( "autostart" );
742 cfg.setGroup( "AutoStart" ); 747 cfg.setGroup( "AutoStart" );
743 if ( appName.compare("clear") == 0){ 748 if ( appName.compare("clear") == 0){
744 cfg.writeEntry("Apps", ""); 749 cfg.writeEntry("Apps", "");
745 } 750 }
746 } else if ( msg == "autoStart(QString,QString)" ) { 751 } else if ( msg == "autoStart(QString,QString)" ) {
747 QString modifier, appName; 752 QString modifier, appName;
748 stream >> modifier >> appName; 753 stream >> modifier >> appName;
749 Config cfg( "autostart" ); 754 Config cfg( "autostart" );
750 cfg.setGroup( "AutoStart" ); 755 cfg.setGroup( "AutoStart" );
751 if ( modifier.compare("add") == 0 ){ 756 if ( modifier.compare("add") == 0 ){
752 // only add it appname is entered 757 // only add it appname is entered
753 if (!appName.isEmpty()) { 758 if (!appName.isEmpty()) {
754 cfg.writeEntry("Apps", appName); 759 cfg.writeEntry("Apps", appName);
755 } 760 }
756 } else if (modifier.compare("remove") == 0 ) { 761 } else if (modifier.compare("remove") == 0 ) {
757 // need to change for multiple entries 762 // need to change for multiple entries
758 // actually remove is right now simular to clear, but in future there 763 // actually remove is right now simular to clear, but in future there
759 // should be multiple apps in autostart possible. 764 // should be multiple apps in autostart possible.
760 QString checkName; 765 QString checkName;
761 checkName = cfg.readEntry("Apps", ""); 766 checkName = cfg.readEntry("Apps", "");
762 if (checkName == appName) { 767 if (checkName == appName) {
763 cfg.writeEntry("Apps", ""); 768 cfg.writeEntry("Apps", "");
764 } 769 }
765 } 770 }
766 } else if ( msg == "sendCardInfo()" ) { 771 } else if ( msg == "sendCardInfo()" ) {
767 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 772 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
768 const QList<FileSystem> &fs = storage->fileSystems(); 773 const QList<FileSystem> &fs = storage->fileSystems();
769 QListIterator<FileSystem> it ( fs ); 774 QListIterator<FileSystem> it ( fs );
770 QString s; 775 QString s;
771 QString homeDir = getenv("HOME"); 776 QString homeDir = getenv("HOME");
772 QString hardDiskHome; 777 QString hardDiskHome;
773 for ( ; it.current(); ++it ) { 778 for ( ; it.current(); ++it ) {
774 if ( (*it)->isRemovable() ) 779 if ( (*it)->isRemovable() )
775 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 780 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
776 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 781 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
777 + " " + (*it)->options() + ";"; 782 + " " + (*it)->options() + ";";
778 else if ( (*it)->disk() == "/dev/mtdblock1" || 783 else if ( (*it)->disk() == "/dev/mtdblock1" ||
779 (*it)->disk() == "/dev/mtdblock/1" ) 784 (*it)->disk() == "/dev/mtdblock/1" )
780 s += (*it)->name() + "=" + homeDir + "/Documents " 785 s += (*it)->name() + "=" + homeDir + "/Documents "
781 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 786 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
782 + " " + (*it)->options() + ";"; 787 + " " + (*it)->options() + ";";
783 else if ( (*it)->name().contains( "Hard Disk") && 788 else if ( (*it)->name().contains( "Hard Disk") &&
784 homeDir.contains( (*it)->path() ) && 789 homeDir.contains( (*it)->path() ) &&
785 (*it)->path().length() > hardDiskHome.length() ) 790 (*it)->path().length() > hardDiskHome.length() )
786 hardDiskHome = 791 hardDiskHome =
787 (*it)->name() + "=" + homeDir + "/Documents " 792 (*it)->name() + "=" + homeDir + "/Documents "
788 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 793 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
789 + " " + (*it)->options() + ";"; 794 + " " + (*it)->options() + ";";
790 } 795 }
791 if ( !hardDiskHome.isEmpty() ) 796 if ( !hardDiskHome.isEmpty() )
792 s += hardDiskHome; 797 s += hardDiskHome;
793 798
794 e << s; 799 e << s;
795 } else if ( msg == "sendSyncDate(QString)" ) { 800 } else if ( msg == "sendSyncDate(QString)" ) {
796 QString app; 801 QString app;
797 stream >> app; 802 stream >> app;
798 Config cfg( "qpe" ); 803 Config cfg( "qpe" );
799 cfg.setGroup("SyncDate"); 804 cfg.setGroup("SyncDate");
800 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 805 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
801 e << app << cfg.readEntry( app ); 806 e << app << cfg.readEntry( app );
802 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 807 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
803 //cfg.readEntry( app ).latin1() ); 808 //cfg.readEntry( app ).latin1() );
804 } else if ( msg == "setSyncDate(QString,QString)" ) { 809 } else if ( msg == "setSyncDate(QString,QString)" ) {
805 QString app, date; 810 QString app, date;
806 stream >> app >> date; 811 stream >> app >> date;
807 Config cfg( "qpe" ); 812 Config cfg( "qpe" );
808 cfg.setGroup("SyncDate"); 813 cfg.setGroup("SyncDate");
809 cfg.writeEntry( app, date ); 814 cfg.writeEntry( app, date );
810 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 815 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
811 } else if ( msg == "startSync(QString)" ) { 816 } else if ( msg == "startSync(QString)" ) {
812 QString what; 817 QString what;
813 stream >> what; 818 stream >> what;
814 delete syncDialog; syncDialog = 0; 819 delete syncDialog; syncDialog = 0;
815 syncDialog = new SyncDialog( this, "syncProgress", FALSE, 820 syncDialog = new SyncDialog( this, "syncProgress", FALSE,
816 WStyle_Tool | WStyle_Customize | 821 WStyle_Tool | WStyle_Customize |
817 Qt::WStyle_StaysOnTop ); 822 Qt::WStyle_StaysOnTop );
818 syncDialog->showMaximized(); 823 syncDialog->showMaximized();
819 syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); 824 syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
820 connect( syncDialog->buttonCancel, SIGNAL( clicked() ), 825 connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
821 SLOT( cancelSync() ) ); 826 SLOT( cancelSync() ) );
822 } 827 }
823 else if ( msg == "stopSync()") { 828 else if ( msg == "stopSync()") {
824 delete syncDialog; syncDialog = 0; 829 delete syncDialog; syncDialog = 0;
825 } else if ( msg == "getAllDocLinks()" ) { 830 } else if ( msg == "getAllDocLinks()" ) {
826 loadDocs(); 831 loadDocs();
827 832
828 QString contents; 833 QString contents;
829 834
830 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { 835 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
831 DocLnk *doc = it.current(); 836 DocLnk *doc = it.current();
832 QFileInfo fi( doc->file() ); 837 QFileInfo fi( doc->file() );
833 if ( !fi.exists() ) 838 if ( !fi.exists() )
834 continue; 839 continue;
835 840
836 bool fake = !doc->linkFileKnown(); 841 bool fake = !doc->linkFileKnown();
837 if ( !fake ) { 842 if ( !fake ) {
838 QFile f( doc->linkFile() ); 843 QFile f( doc->linkFile() );
839 if ( f.open( IO_ReadOnly ) ) { 844 if ( f.open( IO_ReadOnly ) ) {
840 QTextStream ts( &f ); 845 QTextStream ts( &f );
841 ts.setEncoding( QTextStream::UnicodeUTF8 ); 846 ts.setEncoding( QTextStream::UnicodeUTF8 );
842 contents += ts.read(); 847 contents += ts.read();
843 f.close(); 848 f.close();
844 } else 849 } else
845 fake = TRUE; 850 fake = TRUE;
846 } 851 }
847 if (fake) { 852 if (fake) {
848 contents += "[Desktop Entry]\n"; 853 contents += "[Desktop Entry]\n";
849 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; 854 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n";
850 contents += "File = "+doc->file()+"\n"; 855 contents += "File = "+doc->file()+"\n";
851 contents += "Name = "+doc->name()+"\n"; 856 contents += "Name = "+doc->name()+"\n";
852 contents += "Type = "+doc->type()+"\n"; 857 contents += "Type = "+doc->type()+"\n";
853 } 858 }
854 contents += QString("Size = %1\n").arg( fi.size() ); 859 contents += QString("Size = %1\n").arg( fi.size() );
855 } 860 }
856 861
857 //qDebug( "sending length %d", contents.length() ); 862 //qDebug( "sending length %d", contents.length() );
858 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 863 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
859 e << contents; 864 e << contents;
860 865
861 qDebug( "================ \n\n%s\n\n===============", 866 qDebug( "================ \n\n%s\n\n===============",
862 contents.latin1() ); 867 contents.latin1() );
863 868
864 delete docsFolder; 869 delete docsFolder;
865 docsFolder = 0; 870 docsFolder = 0;
866 } 871 }
867} 872}
868 873
869void Launcher::cancelSync() 874void Launcher::cancelSync()
870{ 875{
871 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 876 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
872} 877}
873 878
874void Launcher::storageChanged() 879void Launcher::storageChanged()
875{ 880{
876 if ( in_lnk_props ) { 881 if ( in_lnk_props ) {
877 got_lnk_change = TRUE; 882 got_lnk_change = TRUE;
878 lnk_change = ""; 883 lnk_change = "";
879 } else { 884 } else {
880 updateDocs(); 885 updateDocs();
881 } 886 }
882} 887}
883 888
884 889
885bool Launcher::mkdir(const QString &localPath) 890bool Launcher::mkdir(const QString &localPath)
886{ 891{
887 QDir fullDir(localPath); 892 QDir fullDir(localPath);
888 if (fullDir.exists()) 893 if (fullDir.exists())
889 return true; 894 return true;
890 895
891 // at this point the directory doesn't exist 896 // at this point the directory doesn't exist
892 // go through the directory tree and start creating the direcotories 897 // go through the directory tree and start creating the direcotories
893 // that don't exist; if we can't create the directories, return false 898 // that don't exist; if we can't create the directories, return false
894 899
895 QString dirSeps = "/"; 900 QString dirSeps = "/";
896 int dirIndex = localPath.find(dirSeps); 901 int dirIndex = localPath.find(dirSeps);
897 QString checkedPath; 902 QString checkedPath;
898 903
899 // didn't find any seps; weird, use the cur dir instead 904 // didn't find any seps; weird, use the cur dir instead
900 if (dirIndex == -1) { 905 if (dirIndex == -1) {
901 //qDebug("No seperators found in path %s", localPath.latin1()); 906 //qDebug("No seperators found in path %s", localPath.latin1());
902 checkedPath = QDir::currentDirPath(); 907 checkedPath = QDir::currentDirPath();
903 } 908 }
904 909
905 while (checkedPath != localPath) { 910 while (checkedPath != localPath) {
906 // no more seperators found, use the local path 911 // no more seperators found, use the local path
907 if (dirIndex == -1) 912 if (dirIndex == -1)
908 checkedPath = localPath; 913 checkedPath = localPath;
909 else { 914 else {
910 // the next directory to check 915 // the next directory to check
911 checkedPath = localPath.left(dirIndex) + "/"; 916 checkedPath = localPath.left(dirIndex) + "/";
912 // advance the iterator; the next dir seperator 917 // advance the iterator; the next dir seperator
913 dirIndex = localPath.find(dirSeps, dirIndex+1); 918 dirIndex = localPath.find(dirSeps, dirIndex+1);
914 } 919 }
915 920
916 QDir checkDir(checkedPath); 921 QDir checkDir(checkedPath);
917 if (!checkDir.exists()) { 922 if (!checkDir.exists()) {
918 //qDebug("mkdir making dir %s", checkedPath.latin1()); 923 //qDebug("mkdir making dir %s", checkedPath.latin1());
919 924
920 if (!checkDir.mkdir(checkedPath)) { 925 if (!checkDir.mkdir(checkedPath)) {
921 qDebug("Unable to make directory %s", checkedPath.latin1()); 926 qDebug("Unable to make directory %s", checkedPath.latin1());
922 return FALSE; 927 return FALSE;
923 } 928 }
924 } 929 }
925 930
926 } 931 }
927 return TRUE; 932 return TRUE;
928} 933}
929 934
930void Launcher::preloadApps() 935void Launcher::preloadApps()
931{ 936{
932 Config cfg("Launcher"); 937 Config cfg("Launcher");
933 cfg.setGroup("Preload"); 938 cfg.setGroup("Preload");
934 QStringList apps = cfg.readListEntry("Apps",','); 939 QStringList apps = cfg.readListEntry("Apps",',');
935 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 940 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
936 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 941 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
937 } 942 }
938} 943}
diff --git a/core/launcher/mrulist.cpp b/core/launcher/mrulist.cpp
index 6066dac..5590d38 100644
--- a/core/launcher/mrulist.cpp
+++ b/core/launcher/mrulist.cpp
@@ -1,231 +1,223 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Holger 'zecke' Freyther 2** Copyright (C) 2002 Holger 'zecke' Freyther
3** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 4**
5** This file is part of Qtopia Environment. 5** This file is part of Qtopia Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include "mrulist.h" 22#include "mrulist.h"
23 23
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27 27
28#include <qframe.h> 28#include <qframe.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qtoolbutton.h> 30#include <qtoolbutton.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qwindowsystem_qws.h> 33#include <qwindowsystem_qws.h>
34 34
35 35
36 QList<MRUList>*MRUList::MRUListWidgets = NULL; 36 QList<MRUList>*MRUList::MRUListWidgets = NULL;
37 QList<AppLnk>*MRUList::task = NULL; 37 QList<AppLnk>*MRUList::task = NULL;
38 38
39 39
40MRUList::MRUList( QWidget *parent ) 40MRUList::MRUList( QWidget *parent )
41 : QFrame( parent ), selected(-1), oldsel(-1) 41 : QFrame( parent ), selected(-1), oldsel(-1)
42{ 42{
43 setBackgroundMode( PaletteButton ); 43 setBackgroundMode( PaletteButton );
44 if (!MRUListWidgets) 44 if (!MRUListWidgets)
45 MRUListWidgets = new QList<MRUList>; 45 MRUListWidgets = new QList<MRUList>;
46 if (!task) 46 if (!task)
47 task = new QList<AppLnk>; 47 task = new QList<AppLnk>;
48 MRUListWidgets->append( this ); 48 MRUListWidgets->append( this );
49} 49}
50 50
51 51
52MRUList::~MRUList() 52MRUList::~MRUList()
53{ 53{
54 if (MRUListWidgets) 54 if (MRUListWidgets)
55 MRUListWidgets->remove( this ); 55 MRUListWidgets->remove( this );
56 if (task) 56 if (task)
57 task->setAutoDelete( TRUE ); 57 task->setAutoDelete( TRUE );
58} 58}
59 59
60 60
61QSize MRUList::sizeHint() const 61QSize MRUList::sizeHint() const
62{ 62{
63 return QSize( frameWidth(), 16 ); 63 return QSize( frameWidth(), 16 );
64} 64}
65 65
66// thanks to John from Trolltech
67void MRUList::removeTask(const QString &appName )
68{
69 qWarning("MRULList::removeTask( %s)", appName.latin1() );
70 if(appName.isEmpty() )
71 return;
72
73 if(!task ) // at least it should be called once before
74 return;
75 unsigned int i= 0;
76 for ( ; i < task->count(); i++ ) {
77 AppLnk *t = task->at(i);
78 if ( t->exec() == appName )
79 task->remove();
80 }
81 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
82 MRUListWidgets->at(i)->update();
83}
66 84
67void MRUList::addTask( const AppLnk *appLnk ) 85void MRUList::addTask( const AppLnk *appLnk )
68{ 86{
87 qWarning("Add Task" );
69 if ( !appLnk ) 88 if ( !appLnk )
70 return; 89 return;
71 unsigned int i = 0; 90 unsigned int i = 0;
72 91
73 if ( !task ) 92 if ( !task )
74 return; 93 return;
75 // ok we wan't to delete old icons from the taskbar
76 // get the window list and see which windows aren't there any more
77 QList<AppLnk> cleanUp;
78 cleanUp.setAutoDelete( TRUE );
79 const QList<QWSWindow> &list = qwsServer->clientWindows();
80 QWSWindow* w;
81 bool running = false; // to see what we should do
82 for ( ; i < task->count(); i++ ) {
83 AppLnk *t = task->at(i);
84 running = false;
85 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
86 QString app = w->client()->identity();
87 if( app == t->exec( ) ){
88 running = true;
89 break;
90 }
91 }
92 if(!running ) { // gues what we do now
93 cleanUp.append( t);
94 }
95 }
96 // no do a clean up of these old icons
97 AppLnk *lnk;
98 for( lnk = cleanUp.first(); lnk != 0; lnk = cleanUp.next() ){
99 task->remove( lnk );
100 }
101 cleanUp.clear(); // should be deleted too
102 94
103 i = 0; 95 i = 0;
104 for ( ; i < task->count(); i++ ) { 96 for ( ; i < task->count(); i++ ) {
105 AppLnk *t = task->at(i); 97 AppLnk *t = task->at(i);
106 if ( t->exec() == appLnk->exec() ) { 98 if ( t->exec() == appLnk->exec() ) {
107 if (i != 0) { 99 if (i != 0) {
108 task->remove(); 100 task->remove();
109 task->prepend( t ); 101 task->prepend( t );
110 } 102 }
111 for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) 103 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
112 MRUListWidgets->at(i)->update(); 104 MRUListWidgets->at(i)->update();
113 return; 105 return;
114 } 106 }
115 } 107 }
116 // check which tasks are running and delete them from the list 108 // check which tasks are running and delete them from the list
117 AppLnk *t = new AppLnk( *appLnk ); 109 AppLnk *t = new AppLnk( *appLnk );
118 // DocLnks have an overloaded virtual function exec() 110 // DocLnks have an overloaded virtual function exec()
119 t->setExec( appLnk->exec() ); 111 t->setExec( appLnk->exec() );
120 task->prepend( t ); 112 task->prepend( t );
121 113
122 if ( task->count() > 6 ) { 114 if ( task->count() > 6 ) {
123 t = task->last(); 115 t = task->last();
124 task->remove(); 116 task->remove();
125 Global::terminate(t); 117 Global::terminate(t);
126 delete t; 118 delete t;
127 } 119 }
128 120
129 for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) 121 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
130 MRUListWidgets->at(i)->update(); 122 MRUListWidgets->at(i)->update();
131} 123}
132 124
133bool MRUList::quitOldApps() 125bool MRUList::quitOldApps()
134{ 126{
135 QStringList appsstarted; 127 QStringList appsstarted;
136 QStringList appsrunning; 128 QStringList appsrunning;
137 for ( int i=task->count()-1; i>=0; --i ) { 129 for ( int i=task->count()-1; i>=0; --i ) {
138 AppLnk *t = task->at(i); 130 AppLnk *t = task->at(i);
139 appsstarted.append(t->exec()); 131 appsstarted.append(t->exec());
140 } 132 }
141 133
142 const QList<QWSWindow> &list = qwsServer->clientWindows(); 134 const QList<QWSWindow> &list = qwsServer->clientWindows();
143 QWSWindow* w; 135 QWSWindow* w;
144 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 136 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
145 QString app = w->client()->identity(); 137 QString app = w->client()->identity();
146 if ( appsstarted.contains(app) && !appsrunning.contains(app) ) 138 if ( appsstarted.contains(app) && !appsrunning.contains(app) )
147 appsrunning.append(app); 139 appsrunning.append(app);
148 } 140 }
149 141
150 if ( appsrunning.count() > 1 ) { 142 if ( appsrunning.count() > 1 ) {
151 QStringList::ConstIterator it = appsrunning.begin(); 143 QStringList::ConstIterator it = appsrunning.begin();
152 ++it; // top stays running! 144 ++it; // top stays running!
153 for (; it != appsrunning.end(); it++) { 145 for (; it != appsrunning.end(); it++) {
154 for ( int i=task->count()-1; i>=0; --i ) { 146 for ( int i=task->count()-1; i>=0; --i ) {
155 AppLnk *t = task->at(i); 147 AppLnk *t = task->at(i);
156 if ( t->exec() == *it ){ 148 if ( t->exec() == *it ){
157 task->remove(i ); 149 task->remove(i );
158 delete t; 150 delete t;
159 Global::terminate(t); 151 Global::terminate(t);
160 } 152 }
161 } 153 }
162 } 154 }
163 return TRUE; 155 return TRUE;
164 } else { 156 } else {
165 return FALSE; 157 return FALSE;
166 } 158 }
167} 159}
168 160
169 161
170void MRUList::mousePressEvent(QMouseEvent *e) 162void MRUList::mousePressEvent(QMouseEvent *e)
171{ 163{
172 selected = 0; 164 selected = 0;
173 int x=0; 165 int x=0;
174 QListIterator<AppLnk> it( *task ); 166 QListIterator<AppLnk> it( *task );
175 for ( ; it.current(); ++it,++selected,x+=15 ) { 167 for ( ; it.current(); ++it,++selected,x+=15 ) {
176 if ( x + 15 <= width() ) { 168 if ( x + 15 <= width() ) {
177 if ( e->x() >= x && e->x() < x+15 ) { 169 if ( e->x() >= x && e->x() < x+15 ) {
178 if ( selected < (int)task->count() ) { 170 if ( selected < (int)task->count() ) {
179 repaint(FALSE); 171 repaint(FALSE);
180 return; 172 return;
181 } 173 }
182 } 174 }
183 } else { 175 } else {
184 break; 176 break;
185 } 177 }
186 } 178 }
187 selected = -1; 179 selected = -1;
188 repaint( FALSE ); 180 repaint( FALSE );
189} 181}
190 182
191 183
192void MRUList::mouseReleaseEvent(QMouseEvent *) 184void MRUList::mouseReleaseEvent(QMouseEvent *)
193{ 185{
194 if ( selected >= 0 ) { 186 if ( selected >= 0 ) {
195 if ( parentWidget() ) 187 if ( parentWidget() )
196 if ( parentWidget()->isA( "QPopupMenu" ) ) 188 if ( parentWidget()->isA( "QPopupMenu" ) )
197 parentWidget()->hide(); 189 parentWidget()->hide();
198 Global::execute( task->at(selected)->exec() ); 190 Global::execute( task->at(selected)->exec() );
199 selected = -1; 191 selected = -1;
200 oldsel = -1; 192 oldsel = -1;
201 update(); 193 update();
202 } 194 }
203} 195}
204 196
205 197
206void MRUList::paintEvent( QPaintEvent * ) 198void MRUList::paintEvent( QPaintEvent * )
207{ 199{
208 QPainter p( this ); 200 QPainter p( this );
209 AppLnk *t; 201 AppLnk *t;
210 int x = 0; 202 int x = 0;
211 int y = (height() - 14) / 2; 203 int y = (height() - 14) / 2;
212 int i = 0; 204 int i = 0;
213 205
214 p.fillRect( 0, 0, width(), height(), colorGroup().background() ); 206 p.fillRect( 0, 0, width(), height(), colorGroup().background() );
215 207
216 if ( task ) { 208 if ( task ) {
217 QListIterator<AppLnk> it( *task ); 209 QListIterator<AppLnk> it( *task );
218 for ( ; it.current(); i++, ++it ) { 210 for ( ; it.current(); i++, ++it ) {
219 if ( x + 15 <= width() ) { 211 if ( x + 15 <= width() ) {
220 t = it.current(); 212 t = it.current();
221 if ( (int)i == selected ) 213 if ( (int)i == selected )
222 p.fillRect( x, y, 15, t->pixmap().height()+1, colorGroup().highlight() ); 214 p.fillRect( x, y, 15, t->pixmap().height()+1, colorGroup().highlight() );
223 else if ( (int)i == oldsel ) 215 else if ( (int)i == oldsel )
224 p.eraseRect( x, y, 15, t->pixmap().height()+1 ); 216 p.eraseRect( x, y, 15, t->pixmap().height()+1 );
225 p.drawPixmap( x, y, t->pixmap() ); 217 p.drawPixmap( x, y, t->pixmap() );
226 x += 15; 218 x += 15;
227 } 219 }
228 } 220 }
229 } 221 }
230} 222}
231 223
diff --git a/core/launcher/mrulist.h b/core/launcher/mrulist.h
index 141a09b..ff111ce 100644
--- a/core/launcher/mrulist.h
+++ b/core/launcher/mrulist.h
@@ -1,55 +1,56 @@
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 __MRU_LIST_H__ 21#ifndef __MRU_LIST_H__
22#define __MRU_LIST_H__ 22#define __MRU_LIST_H__
23 23
24 24
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlist.h> 28#include <qlist.h>
29#include <qpixmap.h> 29#include <qpixmap.h>
30 30
31 31
32class MRUList : public QFrame 32class MRUList : public QFrame
33{ 33{
34public: 34public:
35 MRUList( QWidget *parent ); 35 MRUList( QWidget *parent );
36 ~MRUList(); 36 ~MRUList();
37 virtual QSize sizeHint() const; 37 virtual QSize sizeHint() const;
38 static void addTask( const AppLnk *appLnk ); 38 static void addTask( const AppLnk *appLnk );
39 static void removeTask(const QString &appName );
39 bool quitOldApps(); 40 bool quitOldApps();
40 41
41protected: 42protected:
42 void mousePressEvent(QMouseEvent *e); 43 void mousePressEvent(QMouseEvent *e);
43 void mouseReleaseEvent(QMouseEvent *e); 44 void mouseReleaseEvent(QMouseEvent *e);
44 void paintEvent( QPaintEvent *event ); 45 void paintEvent( QPaintEvent *event );
45 46
46private: 47private:
47 static QList<MRUList> *MRUListWidgets; 48 static QList<MRUList> *MRUListWidgets;
48 static QList<AppLnk> *task; 49 static QList<AppLnk> *task;
49 int selected; 50 int selected;
50 int oldsel; 51 int oldsel;
51}; 52};
52 53
53 54
54#endif // __MRU_LIST_H__ 55#endif // __MRU_LIST_H__
55 56