-rw-r--r-- | core/launcher/launcher.cpp | 11 | ||||
-rw-r--r-- | core/launcher/mrulist.cpp | 46 | ||||
-rw-r--r-- | core/launcher/mrulist.h | 1 |
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 | |||
@@ -587,195 +587,200 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | |||
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 | ||
600 | void Launcher::updateTabs() | 600 | void 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 | ||
612 | void Launcher::updateDocs() | 612 | void Launcher::updateDocs() |
613 | { | 613 | { |
614 | loadDocs(); | 614 | loadDocs(); |
615 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 615 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
616 | } | 616 | } |
617 | 617 | ||
618 | void Launcher::viewSelected(const QString& s) | 618 | void Launcher::viewSelected(const QString& s) |
619 | { | 619 | { |
620 | setCaption( s + tr(" - Launcher") ); | 620 | setCaption( s + tr(" - Launcher") ); |
621 | } | 621 | } |
622 | 622 | ||
623 | void Launcher::nextView() | 623 | void Launcher::nextView() |
624 | { | 624 | { |
625 | tabs->nextTab(); | 625 | tabs->nextTab(); |
626 | } | 626 | } |
627 | 627 | ||
628 | 628 | ||
629 | void Launcher::select( const AppLnk *appLnk ) | 629 | void 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 | ||
646 | void Launcher::externalSelected(const AppLnk *appLnk) | 646 | void 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 | ||
652 | void Launcher::properties( AppLnk *appLnk ) | 652 | void 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 | ||
670 | void Launcher::updateLink(const QString& link) | 670 | void 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 | ||
680 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 680 | void 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() ) |
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,197 +1,189 @@ | |||
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 | ||
40 | MRUList::MRUList( QWidget *parent ) | 40 | MRUList::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 | ||
52 | MRUList::~MRUList() | 52 | MRUList::~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 | ||
61 | QSize MRUList::sizeHint() const | 61 | QSize 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 | ||
67 | void 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 | ||
67 | void MRUList::addTask( const AppLnk *appLnk ) | 85 | void 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 | ||
133 | bool MRUList::quitOldApps() | 125 | bool 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 | ||
170 | void MRUList::mousePressEvent(QMouseEvent *e) | 162 | void 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 | ||
192 | void MRUList::mouseReleaseEvent(QMouseEvent *) | 184 | void 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(); |
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 | ||
32 | class MRUList : public QFrame | 32 | class MRUList : public QFrame |
33 | { | 33 | { |
34 | public: | 34 | public: |
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 | ||
41 | protected: | 42 | protected: |
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 | ||
46 | private: | 47 | private: |
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 | ||