-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 | |||
@@ -635,99 +635,104 @@ void Launcher::select( const AppLnk *appLnk ) | |||
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; |
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 | |||
@@ -18,132 +18,124 @@ | |||
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 | ||
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 | ||