author | harlekin <harlekin> | 2002-09-11 11:06:50 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-09-11 11:06:50 (UTC) |
commit | 7ab82ad13aaf708ffba4bf4294d29b789007ddde (patch) (unidiff) | |
tree | 7621e986cbac9004c90b38c50f4df6d0536cab04 | |
parent | 8699473dd4e21242b1c98192c2dd38655177762b (diff) | |
download | opie-7ab82ad13aaf708ffba4bf4294d29b789007ddde.zip opie-7ab82ad13aaf708ffba4bf4294d29b789007ddde.tar.gz opie-7ab82ad13aaf708ffba4bf4294d29b789007ddde.tar.bz2 |
bye bye
-rw-r--r-- | core/launcher/mrulist.cpp | 224 | ||||
-rw-r--r-- | core/launcher/mrulist.h | 56 |
2 files changed, 0 insertions, 280 deletions
diff --git a/core/launcher/mrulist.cpp b/core/launcher/mrulist.cpp deleted file mode 100644 index 0530fd6..0000000 --- a/core/launcher/mrulist.cpp +++ b/dev/null | |||
@@ -1,224 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Holger 'zecke' Freyther | ||
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
4 | ** | ||
5 | ** This file is part of Qtopia Environment. | ||
6 | ** | ||
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 | ||
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
10 | ** packaging of this file. | ||
11 | ** | ||
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. | ||
14 | ** | ||
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
16 | ** | ||
17 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
18 | ** not clear to you. | ||
19 | ** | ||
20 | **********************************************************************/ | ||
21 | |||
22 | #include "mrulist.h" | ||
23 | |||
24 | #include <qpe/global.h> | ||
25 | #include <qpe/applnk.h> | ||
26 | #include <qpe/resource.h> | ||
27 | |||
28 | #include <qframe.h> | ||
29 | #include <qpushbutton.h> | ||
30 | #include <qtoolbutton.h> | ||
31 | #include <qpopupmenu.h> | ||
32 | #include <qpainter.h> | ||
33 | #include <qwindowsystem_qws.h> | ||
34 | |||
35 | |||
36 | QList<MRUList>*MRUList::MRUListWidgets = NULL; | ||
37 | QList<AppLnk>*MRUList::task = NULL; | ||
38 | |||
39 | |||
40 | MRUList::MRUList( QWidget *parent ) | ||
41 | : QFrame( parent ), selected(-1), oldsel(-1) | ||
42 | { | ||
43 | setBackgroundMode( PaletteBackground ); | ||
44 | if (!MRUListWidgets) | ||
45 | MRUListWidgets = new QList<MRUList>; | ||
46 | if (!task) | ||
47 | task = new QList<AppLnk>; | ||
48 | MRUListWidgets->append( this ); | ||
49 | } | ||
50 | |||
51 | |||
52 | MRUList::~MRUList() | ||
53 | { | ||
54 | if (MRUListWidgets) | ||
55 | MRUListWidgets->remove( this ); | ||
56 | if (task) | ||
57 | task->setAutoDelete( TRUE ); | ||
58 | } | ||
59 | |||
60 | |||
61 | QSize MRUList::sizeHint() const | ||
62 | { | ||
63 | return QSize( frameWidth(), 16 ); | ||
64 | } | ||
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 | } | ||
84 | |||
85 | void MRUList::addTask( const AppLnk *appLnk ) | ||
86 | { | ||
87 | qWarning("Add Task" ); | ||
88 | if ( !appLnk ) | ||
89 | return; | ||
90 | unsigned int i = 0; | ||
91 | |||
92 | if ( !task ) | ||
93 | return; | ||
94 | |||
95 | i = 0; | ||
96 | for ( ; i < task->count(); i++ ) { | ||
97 | AppLnk *t = task->at(i); | ||
98 | if ( t->exec() == appLnk->exec() ) { | ||
99 | if (i != 0) { | ||
100 | task->remove(); | ||
101 | task->prepend( t ); | ||
102 | } | ||
103 | for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) | ||
104 | MRUListWidgets->at(i)->update(); | ||
105 | return; | ||
106 | } | ||
107 | } | ||
108 | // check which tasks are running and delete them from the list | ||
109 | AppLnk *t = new AppLnk( *appLnk ); | ||
110 | // DocLnks have an overloaded virtual function exec() | ||
111 | t->setExec( appLnk->exec() ); | ||
112 | task->prepend( t ); | ||
113 | |||
114 | if ( task->count() > 6 ) { | ||
115 | t = task->last(); | ||
116 | task->remove(); | ||
117 | Global::terminate(t); | ||
118 | delete t; | ||
119 | } | ||
120 | |||
121 | for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) | ||
122 | MRUListWidgets->at(i)->update(); | ||
123 | } | ||
124 | |||
125 | bool MRUList::quitOldApps() | ||
126 | { | ||
127 | QStringList appsstarted; | ||
128 | QStringList appsrunning; | ||
129 | for ( int i=task->count()-1; i>=0; --i ) { | ||
130 | AppLnk *t = task->at(i); | ||
131 | appsstarted.append(t->exec()); | ||
132 | } | ||
133 | |||
134 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | ||
135 | QWSWindow* w; | ||
136 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | ||
137 | QString app = w->client()->identity(); | ||
138 | if ( appsstarted.contains(app) && !appsrunning.contains(app) ) | ||
139 | appsrunning.append(app); | ||
140 | } | ||
141 | |||
142 | if ( appsrunning.count() > 1 ) { | ||
143 | QStringList::ConstIterator it = appsrunning.begin(); | ||
144 | ++it; // top stays running! | ||
145 | for (; it != appsrunning.end(); it++) { | ||
146 | for ( int i=task->count()-1; i>=0; --i ) { | ||
147 | AppLnk *t = task->at(i); | ||
148 | if ( t->exec() == *it ){ | ||
149 | task->remove(i ); | ||
150 | delete t; | ||
151 | Global::terminate(t); | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | return TRUE; | ||
156 | } else { | ||
157 | return FALSE; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | |||
162 | void MRUList::mousePressEvent(QMouseEvent *e) | ||
163 | { | ||
164 | selected = 0; | ||
165 | int x=0; | ||
166 | QListIterator<AppLnk> it( *task ); | ||
167 | for ( ; it.current(); ++it,++selected,x+=15 ) { | ||
168 | if ( x + 15 <= width() ) { | ||
169 | if ( e->x() >= x && e->x() < x+15 ) { | ||
170 | if ( selected < (int)task->count() ) { | ||
171 | repaint(FALSE); | ||
172 | return; | ||
173 | } | ||
174 | } | ||
175 | } else { | ||
176 | break; | ||
177 | } | ||
178 | } | ||
179 | selected = -1; | ||
180 | repaint( FALSE ); | ||
181 | } | ||
182 | |||
183 | |||
184 | void MRUList::mouseReleaseEvent(QMouseEvent *) | ||
185 | { | ||
186 | if ( selected >= 0 ) { | ||
187 | if ( parentWidget() ) | ||
188 | if ( parentWidget()->isA( "QPopupMenu" ) ) | ||
189 | parentWidget()->hide(); | ||
190 | Global::execute( task->at(selected)->exec() ); | ||
191 | selected = -1; | ||
192 | oldsel = -1; | ||
193 | update(); | ||
194 | } | ||
195 | } | ||
196 | |||
197 | |||
198 | void MRUList::paintEvent( QPaintEvent * ) | ||
199 | { | ||
200 | QPainter p( this ); | ||
201 | AppLnk *t; | ||
202 | int x = 0; | ||
203 | int y = (height() - 14) / 2; | ||
204 | int i = 0; | ||
205 | |||
206 | // p.fillRect( 0, 0, width(), height(), colorGroup().background() ); | ||
207 | erase ( ); | ||
208 | |||
209 | if ( task ) { | ||
210 | QListIterator<AppLnk> it( *task ); | ||
211 | for ( ; it.current(); i++, ++it ) { | ||
212 | if ( x + 15 <= width() ) { | ||
213 | t = it.current(); | ||
214 | if ( (int)i == selected ) | ||
215 | p.fillRect( x, y, 15, t->pixmap().height()+1, colorGroup().highlight() ); | ||
216 | else if ( (int)i == oldsel ) | ||
217 | p.eraseRect( x, y, 15, t->pixmap().height()+1 ); | ||
218 | p.drawPixmap( x, y, t->pixmap() ); | ||
219 | x += 15; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
diff --git a/core/launcher/mrulist.h b/core/launcher/mrulist.h deleted file mode 100644 index ff111ce..0000000 --- a/core/launcher/mrulist.h +++ b/dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef __MRU_LIST_H__ | ||
22 | #define __MRU_LIST_H__ | ||
23 | |||
24 | |||
25 | #include <qpe/applnk.h> | ||
26 | |||
27 | #include <qframe.h> | ||
28 | #include <qlist.h> | ||
29 | #include <qpixmap.h> | ||
30 | |||
31 | |||
32 | class MRUList : public QFrame | ||
33 | { | ||
34 | public: | ||
35 | MRUList( QWidget *parent ); | ||
36 | ~MRUList(); | ||
37 | virtual QSize sizeHint() const; | ||
38 | static void addTask( const AppLnk *appLnk ); | ||
39 | static void removeTask(const QString &appName ); | ||
40 | bool quitOldApps(); | ||
41 | |||
42 | protected: | ||
43 | void mousePressEvent(QMouseEvent *e); | ||
44 | void mouseReleaseEvent(QMouseEvent *e); | ||
45 | void paintEvent( QPaintEvent *event ); | ||
46 | |||
47 | private: | ||
48 | static QList<MRUList> *MRUListWidgets; | ||
49 | static QList<AppLnk> *task; | ||
50 | int selected; | ||
51 | int oldsel; | ||
52 | }; | ||
53 | |||
54 | |||
55 | #endif // __MRU_LIST_H__ | ||
56 | |||