author | harlekin <harlekin> | 2003-11-30 18:04:13 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-11-30 18:04:13 (UTC) |
commit | f40b049e2345a9b008ea2bdc241062302bd7ca04 (patch) (unidiff) | |
tree | 82ba2d954605de18ef063315b62f04f434ce43cb | |
parent | a7e786be4f9545a881015de8ba8a124a62f0f891 (diff) | |
download | opie-f40b049e2345a9b008ea2bdc241062302bd7ca04.zip opie-f40b049e2345a9b008ea2bdc241062302bd7ca04.tar.gz opie-f40b049e2345a9b008ea2bdc241062302bd7ca04.tar.bz2 |
make the busy indicator launcher settings also work in head
-rw-r--r-- | core/launcher/launcherview.cpp | 32 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 9 |
2 files changed, 29 insertions, 12 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 85163b6..62c678d 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -1,700 +1,710 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "launcherview.h" | 21 | #include "launcherview.h" |
22 | 22 | ||
23 | #include <qtopia/qpeapplication.h> | 23 | #include <qtopia/qpeapplication.h> |
24 | #include <qtopia/applnk.h> | 24 | #include <qtopia/applnk.h> |
25 | #include <qtopia/qpedebug.h> | 25 | #include <qtopia/qpedebug.h> |
26 | #include <qtopia/private/categories.h> | 26 | #include <qtopia/private/categories.h> |
27 | #include <qtopia/categoryselect.h> | 27 | #include <qtopia/categoryselect.h> |
28 | #include <qtopia/menubutton.h> | 28 | #include <qtopia/menubutton.h> |
29 | #include <qtopia/mimetype.h> | 29 | #include <qtopia/mimetype.h> |
30 | #include <qtopia/resource.h> | 30 | #include <qtopia/resource.h> |
31 | #include <qtopia/qpetoolbar.h> | 31 | #include <qtopia/qpetoolbar.h> |
32 | //#include <qtopia/private/palmtoprecord.h> | 32 | //#include <qtopia/private/palmtoprecord.h> |
33 | 33 | ||
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qdict.h> | 36 | #include <qdict.h> |
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | #include <qfileinfo.h> | 38 | #include <qfileinfo.h> |
39 | #include <qhbox.h> | 39 | #include <qhbox.h> |
40 | #include <qiconview.h> | 40 | #include <qiconview.h> |
41 | #include <qwidgetstack.h> | 41 | #include <qwidgetstack.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qtoolbutton.h> | 44 | #include <qtoolbutton.h> |
45 | #include <qimage.h> | 45 | #include <qimage.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qobjectlist.h> | 47 | #include <qobjectlist.h> |
48 | 48 | ||
49 | 49 | ||
50 | // These define how the busy icon is animated and highlighted | 50 | // These define how the busy icon is animated and highlighted |
51 | #define BRIGHTEN_BUSY_ICON | 51 | #define BRIGHTEN_BUSY_ICON |
52 | //#define ALPHA_FADE_BUSY_ICON | 52 | //#define ALPHA_FADE_BUSY_ICON |
53 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY | 53 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY |
54 | #define BOUNCE_BUSY_ICON | 54 | #define BOUNCE_BUSY_ICON |
55 | 55 | ||
56 | 56 | ||
57 | class BgPixmap | 57 | class BgPixmap |
58 | { | 58 | { |
59 | public: | 59 | public: |
60 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} | 60 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} |
61 | QPixmap pm; | 61 | QPixmap pm; |
62 | int ref; | 62 | int ref; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | enum BusyIndicatorType { | ||
66 | BIT_Normal = 0, | ||
67 | BIT_Blinking | ||
68 | }; | ||
69 | 65 | ||
70 | static QMap<QString,BgPixmap*> *bgCache = 0; | 66 | static QMap<QString,BgPixmap*> *bgCache = 0; |
71 | 67 | ||
72 | static void cleanup_cache() | 68 | static void cleanup_cache() |
73 | { | 69 | { |
74 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 70 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
75 | while ( it != bgCache->end() ) { | 71 | while ( it != bgCache->end() ) { |
76 | QMap<QString,BgPixmap*>::Iterator curr = it; | 72 | QMap<QString,BgPixmap*>::Iterator curr = it; |
77 | ++it; | 73 | ++it; |
78 | delete (*curr); | 74 | delete (*curr); |
79 | bgCache->remove( curr ); | 75 | bgCache->remove( curr ); |
80 | } | 76 | } |
81 | delete bgCache; | 77 | delete bgCache; |
82 | bgCache = 0; | 78 | bgCache = 0; |
83 | } | 79 | } |
84 | 80 | ||
85 | 81 | ||
86 | class LauncherItem : public QIconViewItem | 82 | class LauncherItem : public QIconViewItem |
87 | { | 83 | { |
88 | public: | 84 | public: |
89 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); | 85 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); |
90 | ~LauncherItem(); | 86 | ~LauncherItem(); |
91 | 87 | ||
92 | AppLnk *appLnk() const { return app; } | 88 | AppLnk *appLnk() const { return app; } |
93 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } | 89 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } |
94 | 90 | ||
95 | void animateIcon(); | 91 | void animateIcon(); |
96 | void resetIcon(); | 92 | void resetIcon(); |
97 | 93 | ||
98 | virtual int compare ( QIconViewItem * i ) const; | 94 | virtual int compare ( QIconViewItem * i ) const; |
99 | void paintItem( QPainter *p, const QColorGroup &cg ); | 95 | void paintItem( QPainter *p, const QColorGroup &cg ); |
96 | |||
97 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | ||
100 | protected: | 98 | protected: |
101 | bool isBigIcon; | 99 | bool isBigIcon; |
102 | int iteration; | 100 | int iteration; |
103 | AppLnk* app; | 101 | AppLnk* app; |
104 | private: | 102 | private: |
105 | void paintAnimatedIcon( QPainter *p ); | 103 | void paintAnimatedIcon( QPainter *p ); |
104 | BusyIndicatorType busyType; | ||
106 | }; | 105 | }; |
107 | 106 | ||
108 | 107 | ||
109 | class LauncherIconView : public QIconView { | 108 | class LauncherIconView : public QIconView { |
110 | public: | 109 | public: |
111 | LauncherIconView( QWidget* parent, const char* name=0 ) : | 110 | LauncherIconView( QWidget* parent, const char* name=0 ) : |
112 | QIconView(parent,name), | 111 | QIconView(parent,name), |
113 | tf(""), | 112 | tf(""), |
114 | cf(0), | 113 | cf(0), |
115 | bsy(0), | 114 | bsy(0), |
116 | busyTimer(0), | 115 | busyTimer(0), |
117 | bigIcns(TRUE), | 116 | bigIcns(TRUE), |
118 | bgColor(white) | 117 | bgColor(white) |
119 | { | 118 | { |
120 | sortmeth = Name; | 119 | sortmeth = Name; |
121 | hidden.setAutoDelete(TRUE); | 120 | hidden.setAutoDelete(TRUE); |
122 | ike = FALSE; | 121 | ike = FALSE; |
123 | calculateGrid( Bottom ); | 122 | calculateGrid( Bottom ); |
124 | } | 123 | } |
125 | 124 | ||
126 | ~LauncherIconView() | 125 | ~LauncherIconView() |
127 | { | 126 | { |
128 | #if 0 // debuggery | 127 | #if 0 // debuggery |
129 | QListIterator<AppLnk> it(hidden); | 128 | QListIterator<AppLnk> it(hidden); |
130 | AppLnk* l; | 129 | AppLnk* l; |
131 | while ((l=it.current())) { | 130 | while ((l=it.current())) { |
132 | ++it; | 131 | ++it; |
133 | //qDebug("%p: hidden (should remove)",l); | 132 | //qDebug("%p: hidden (should remove)",l); |
134 | } | 133 | } |
135 | #endif | 134 | #endif |
136 | } | 135 | } |
137 | 136 | ||
138 | QIconViewItem* busyItem() const { return bsy; } | 137 | QIconViewItem* busyItem() const { return bsy; } |
139 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 138 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
140 | QPixmap busyPixmap() const { return busyPix; } | 139 | QPixmap busyPixmap() const { return busyPix; } |
141 | #endif | 140 | #endif |
142 | void setBigIcons( bool bi ) { | 141 | void setBigIcons( bool bi ) { |
143 | bigIcns = bi; | 142 | bigIcns = bi; |
144 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 143 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
145 | busyPix.resize(0,0); | 144 | busyPix.resize(0,0); |
146 | #endif | 145 | #endif |
147 | } | 146 | } |
148 | 147 | ||
149 | void updateCategoriesAndMimeTypes(); | 148 | void updateCategoriesAndMimeTypes(); |
150 | 149 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | |
151 | void doAutoScroll() | 150 | void doAutoScroll() |
152 | { | 151 | { |
153 | // We don't want rubberbanding (yet) | 152 | // We don't want rubberbanding (yet) |
154 | } | 153 | } |
155 | 154 | ||
156 | void setBusy(bool on) | 155 | void setBusy(bool on) |
157 | { | 156 | { |
158 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 157 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
159 | if ( busyPix.isNull() ) { | 158 | if ( busyPix.isNull() ) { |
160 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 159 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
161 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); | 160 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); |
162 | } | 161 | } |
163 | #endif | 162 | #endif |
164 | 163 | ||
165 | if ( on ) { | 164 | if ( on ) { |
166 | busyTimer = startTimer( 100 ); | 165 | busyTimer = startTimer( 100 ); |
167 | } else { | 166 | } else { |
168 | if ( busyTimer ) { | 167 | if ( busyTimer ) { |
169 | killTimer( busyTimer ); | 168 | killTimer( busyTimer ); |
170 | busyTimer = 0; | 169 | busyTimer = 0; |
171 | } | 170 | } |
172 | } | 171 | } |
173 | 172 | ||
174 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; | 173 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; |
175 | 174 | ||
176 | if ( bsy != c ) { | 175 | if ( bsy != c ) { |
177 | LauncherItem *oldBusy = bsy; | 176 | LauncherItem *oldBusy = bsy; |
178 | bsy = c; | 177 | bsy = c; |
179 | if ( oldBusy ) | 178 | if ( oldBusy ) { |
180 | oldBusy->resetIcon(); | 179 | oldBusy->resetIcon(); |
181 | if ( bsy ) | 180 | } |
181 | if ( bsy ) { | ||
182 | bsy->setBusyIndicatorType( busyType ) ; | ||
182 | bsy->animateIcon(); | 183 | bsy->animateIcon(); |
184 | } | ||
183 | } | 185 | } |
184 | } | 186 | } |
185 | 187 | ||
186 | bool inKeyEvent() const { return ike; } | 188 | bool inKeyEvent() const { return ike; } |
187 | void keyPressEvent(QKeyEvent* e) | 189 | void keyPressEvent(QKeyEvent* e) |
188 | { | 190 | { |
189 | ike = TRUE; | 191 | ike = TRUE; |
190 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { | 192 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { |
191 | if ( (e->state() & ShiftButton) ) | 193 | if ( (e->state() & ShiftButton) ) |
192 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); | 194 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); |
193 | else | 195 | else |
194 | returnPressed(currentItem()); | 196 | returnPressed(currentItem()); |
195 | } | 197 | } |
196 | 198 | ||
197 | QIconView::keyPressEvent(e); | 199 | QIconView::keyPressEvent(e); |
198 | ike = FALSE; | 200 | ike = FALSE; |
199 | } | 201 | } |
200 | 202 | ||
201 | void addItem(AppLnk* app, bool resort=TRUE); | 203 | void addItem(AppLnk* app, bool resort=TRUE); |
202 | bool removeLink(const QString& linkfile); | 204 | bool removeLink(const QString& linkfile); |
203 | 205 | ||
204 | QStringList mimeTypes() const; | 206 | QStringList mimeTypes() const; |
205 | QStringList categories() const; | 207 | QStringList categories() const; |
206 | 208 | ||
207 | void clear() | 209 | void clear() |
208 | { | 210 | { |
209 | mimes.clear(); | 211 | mimes.clear(); |
210 | cats.clear(); | 212 | cats.clear(); |
211 | QIconView::clear(); | 213 | QIconView::clear(); |
212 | hidden.clear(); | 214 | hidden.clear(); |
213 | } | 215 | } |
214 | 216 | ||
215 | void addCatsAndMimes(AppLnk* app) | 217 | void addCatsAndMimes(AppLnk* app) |
216 | { | 218 | { |
217 | // QStringList c = app->categories(); | 219 | // QStringList c = app->categories(); |
218 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | 220 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { |
219 | // cats.replace(*cit,(void*)1); | 221 | // cats.replace(*cit,(void*)1); |
220 | // } | 222 | // } |
221 | QString maj=app->type(); | 223 | QString maj=app->type(); |
222 | int sl=maj.find('/'); | 224 | int sl=maj.find('/'); |
223 | if (sl>=0) { | 225 | if (sl>=0) { |
224 | QString k; | 226 | QString k; |
225 | k = maj.left(12) == "application/" ? maj : maj.left(sl); | 227 | k = maj.left(12) == "application/" ? maj : maj.left(sl); |
226 | mimes.replace(k,(void*)1); | 228 | mimes.replace(k,(void*)1); |
227 | } | 229 | } |
228 | } | 230 | } |
229 | 231 | ||
230 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) { | 232 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) { |
231 | } | 233 | } |
232 | 234 | ||
233 | void setBackgroundPixmap( const QPixmap &pm ) { | 235 | void setBackgroundPixmap( const QPixmap &pm ) { |
234 | bgPixmap = pm; | 236 | bgPixmap = pm; |
235 | } | 237 | } |
236 | 238 | ||
237 | void setBackgroundColor( const QColor &c ) { | 239 | void setBackgroundColor( const QColor &c ) { |
238 | bgColor = c; | 240 | bgColor = c; |
239 | } | 241 | } |
240 | 242 | ||
241 | void drawBackground( QPainter *p, const QRect &r ) | 243 | void drawBackground( QPainter *p, const QRect &r ) |
242 | { | 244 | { |
243 | if ( !bgPixmap.isNull() ) { | 245 | if ( !bgPixmap.isNull() ) { |
244 | p->drawTiledPixmap( r, bgPixmap, | 246 | p->drawTiledPixmap( r, bgPixmap, |
245 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), | 247 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), |
246 | (r.y() + contentsY()) % bgPixmap.height() ) ); | 248 | (r.y() + contentsY()) % bgPixmap.height() ) ); |
247 | } else { | 249 | } else { |
248 | p->fillRect( r, bgColor ); | 250 | p->fillRect( r, bgColor ); |
249 | } | 251 | } |
250 | } | 252 | } |
251 | 253 | ||
252 | void setItemTextPos( ItemTextPos pos ) | 254 | void setItemTextPos( ItemTextPos pos ) |
253 | { | 255 | { |
254 | calculateGrid( pos ); | 256 | calculateGrid( pos ); |
255 | QIconView::setItemTextPos( pos ); | 257 | QIconView::setItemTextPos( pos ); |
256 | } | 258 | } |
257 | 259 | ||
258 | void hideOrShowItems(bool resort); | 260 | void hideOrShowItems(bool resort); |
259 | 261 | ||
260 | void setTypeFilter(const QString& typefilter, bool resort) | 262 | void setTypeFilter(const QString& typefilter, bool resort) |
261 | { | 263 | { |
262 | tf = QRegExp(typefilter,FALSE,TRUE); | 264 | tf = QRegExp(typefilter,FALSE,TRUE); |
263 | hideOrShowItems(resort); | 265 | hideOrShowItems(resort); |
264 | } | 266 | } |
265 | 267 | ||
266 | void setCategoryFilter( int catfilter, bool resort ) | 268 | void setCategoryFilter( int catfilter, bool resort ) |
267 | { | 269 | { |
268 | Categories cat; | 270 | Categories cat; |
269 | cat.load( categoryFileName() ); | 271 | cat.load( categoryFileName() ); |
270 | QString str; | 272 | QString str; |
271 | if ( catfilter == -2 ) | 273 | if ( catfilter == -2 ) |
272 | cf = 0; | 274 | cf = 0; |
273 | else | 275 | else |
274 | cf = catfilter; | 276 | cf = catfilter; |
275 | hideOrShowItems(resort); | 277 | hideOrShowItems(resort); |
276 | } | 278 | } |
277 | 279 | ||
278 | enum SortMethod { Name, Date, Type }; | 280 | enum SortMethod { Name, Date, Type }; |
279 | 281 | ||
280 | void setSortMethod( SortMethod m ) | 282 | void setSortMethod( SortMethod m ) |
281 | { | 283 | { |
282 | if ( sortmeth != m ) { | 284 | if ( sortmeth != m ) { |
283 | sortmeth = m; | 285 | sortmeth = m; |
284 | sort(); | 286 | sort(); |
285 | } | 287 | } |
286 | } | 288 | } |
287 | 289 | ||
288 | int compare(const AppLnk* a, const AppLnk* b) | 290 | int compare(const AppLnk* a, const AppLnk* b) |
289 | { | 291 | { |
290 | switch (sortmeth) { | 292 | switch (sortmeth) { |
291 | case Name: | 293 | case Name: |
292 | return a->name().lower().compare(b->name().lower()); | 294 | return a->name().lower().compare(b->name().lower()); |
293 | case Date: { | 295 | case Date: { |
294 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | 296 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); |
295 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | 297 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); |
296 | return fa.lastModified().secsTo(fb.lastModified()); | 298 | return fa.lastModified().secsTo(fb.lastModified()); |
297 | } | 299 | } |
298 | case Type: | 300 | case Type: |
299 | return a->type().compare(b->type()); | 301 | return a->type().compare(b->type()); |
300 | } | 302 | } |
301 | return 0; | 303 | return 0; |
302 | } | 304 | } |
303 | 305 | ||
304 | protected: | 306 | protected: |
305 | 307 | ||
306 | void timerEvent( QTimerEvent *te ) | 308 | void timerEvent( QTimerEvent *te ) |
307 | { | 309 | { |
308 | if ( te->timerId() == busyTimer ) { | 310 | if ( te->timerId() == busyTimer ) { |
309 | if ( bsy ) | 311 | if ( bsy ) |
310 | bsy->animateIcon(); | 312 | bsy->animateIcon(); |
311 | } else { | 313 | } else { |
312 | QIconView::timerEvent( te ); | 314 | QIconView::timerEvent( te ); |
313 | } | 315 | } |
314 | } | 316 | } |
315 | 317 | ||
316 | void styleChange( QStyle &old ) | 318 | void styleChange( QStyle &old ) |
317 | { | 319 | { |
318 | QIconView::styleChange( old ); | 320 | QIconView::styleChange( old ); |
319 | calculateGrid( itemTextPos() ); | 321 | calculateGrid( itemTextPos() ); |
320 | } | 322 | } |
321 | 323 | ||
322 | void calculateGrid( ItemTextPos pos ) | 324 | void calculateGrid( ItemTextPos pos ) |
323 | { | 325 | { |
324 | int dw = QApplication::desktop()->width(); | 326 | int dw = QApplication::desktop()->width(); |
325 | int viewerWidth = dw-style().scrollBarExtent().width(); | 327 | int viewerWidth = dw-style().scrollBarExtent().width(); |
326 | if ( pos == Bottom ) { | 328 | if ( pos == Bottom ) { |
327 | int cols = 3; | 329 | int cols = 3; |
328 | if ( viewerWidth <= 200 ) | 330 | if ( viewerWidth <= 200 ) |
329 | cols = 2; | 331 | cols = 2; |
330 | else if ( viewerWidth >= 400 ) | 332 | else if ( viewerWidth >= 400 ) |
331 | cols = viewerWidth/96; | 333 | cols = viewerWidth/96; |
332 | setSpacing( 4 ); | 334 | setSpacing( 4 ); |
333 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 335 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
334 | setGridY( fontMetrics().height()*2+24 ); | 336 | setGridY( fontMetrics().height()*2+24 ); |
335 | } else { | 337 | } else { |
336 | int cols = 2; | 338 | int cols = 2; |
337 | if ( viewerWidth < 150 ) | 339 | if ( viewerWidth < 150 ) |
338 | cols = 1; | 340 | cols = 1; |
339 | else if ( viewerWidth >= 400 ) | 341 | else if ( viewerWidth >= 400 ) |
340 | cols = viewerWidth/150; | 342 | cols = viewerWidth/150; |
341 | setSpacing( 2 ); | 343 | setSpacing( 2 ); |
342 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 344 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
343 | setGridY( fontMetrics().height()+2 ); | 345 | setGridY( fontMetrics().height()+2 ); |
344 | } | 346 | } |
345 | } | 347 | } |
346 | 348 | ||
347 | void focusInEvent( QFocusEvent * ) {} | 349 | void focusInEvent( QFocusEvent * ) {} |
348 | void focusOutEvent( QFocusEvent * ) {} | 350 | void focusOutEvent( QFocusEvent * ) {} |
349 | 351 | ||
350 | private: | 352 | private: |
351 | QList<AppLnk> hidden; | 353 | QList<AppLnk> hidden; |
352 | QDict<void> mimes; | 354 | QDict<void> mimes; |
353 | QDict<void> cats; | 355 | QDict<void> cats; |
354 | SortMethod sortmeth; | 356 | SortMethod sortmeth; |
355 | QRegExp tf; | 357 | QRegExp tf; |
356 | int cf; | 358 | int cf; |
357 | LauncherItem* bsy; | 359 | LauncherItem* bsy; |
358 | int busyTimer; | 360 | int busyTimer; |
359 | bool ike; | 361 | bool ike; |
360 | bool bigIcns; | 362 | bool bigIcns; |
361 | QPixmap bgPixmap; | 363 | QPixmap bgPixmap; |
362 | QColor bgColor; | 364 | QColor bgColor; |
363 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 365 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
364 | QPixmap busyPix; | 366 | QPixmap busyPix; |
365 | #endif | 367 | #endif |
368 | BusyIndicatorType busyType; | ||
366 | }; | 369 | }; |
367 | 370 | ||
368 | 371 | ||
369 | bool LauncherView::bsy=FALSE; | 372 | bool LauncherView::bsy=FALSE; |
370 | 373 | ||
371 | void LauncherView::setBusy(bool on) | 374 | void LauncherView::setBusy(bool on) |
372 | { | 375 | { |
373 | icons->setBusy(on); | 376 | icons->setBusy(on); |
374 | } | 377 | } |
375 | 378 | ||
376 | void LauncherView::setBusyIndicatorType( const QString& type ) { | 379 | void LauncherView::setBusyIndicatorType( const QString& type ) { |
377 | /* ### FIXME */ | 380 | if ( type. lower ( ) == "animated" ) |
381 | icons->setBusyIndicatorType( BIT_Animated ) ; | ||
382 | else | ||
383 | icons->setBusyIndicatorType( BIT_Normal ) ; | ||
378 | } | 384 | } |
379 | 385 | ||
380 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | 386 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) |
381 | : QIconViewItem( parent, applnk->name(), | 387 | : QIconViewItem( parent, applnk->name(), |
382 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), | 388 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), |
383 | isBigIcon( bigIcon ), | 389 | isBigIcon( bigIcon ), |
384 | iteration(0), | 390 | iteration(0), |
385 | app(applnk) // Takes ownership | 391 | app(applnk) // Takes ownership |
386 | { | 392 | { |
387 | } | 393 | } |
388 | 394 | ||
389 | LauncherItem::~LauncherItem() | 395 | LauncherItem::~LauncherItem() |
390 | { | 396 | { |
391 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 397 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
392 | if ( liv->busyItem() == this ) | 398 | if ( liv->busyItem() == this ) |
393 | liv->setBusy(FALSE); | 399 | liv->setBusy(FALSE); |
394 | delete app; | 400 | delete app; |
395 | } | 401 | } |
396 | 402 | ||
397 | int LauncherItem::compare ( QIconViewItem * i ) const | 403 | int LauncherItem::compare ( QIconViewItem * i ) const |
398 | { | 404 | { |
399 | LauncherIconView* view = (LauncherIconView*)iconView(); | 405 | LauncherIconView* view = (LauncherIconView*)iconView(); |
400 | return view->compare(app,((LauncherItem *)i)->appLnk()); | 406 | return view->compare(app,((LauncherItem *)i)->appLnk()); |
401 | } | 407 | } |
402 | 408 | ||
403 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) | 409 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) |
404 | { | 410 | { |
405 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 411 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
406 | QBrush oldBrush( liv->itemTextBackground() ); | 412 | QBrush oldBrush( liv->itemTextBackground() ); |
407 | QColorGroup mycg( cg ); | 413 | QColorGroup mycg( cg ); |
408 | if ( liv->currentItem() == this ) { | 414 | if ( liv->currentItem() == this ) { |
409 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); | 415 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); |
410 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); | 416 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); |
411 | } | 417 | } |
412 | 418 | ||
413 | QIconViewItem::paintItem(p,mycg); | 419 | QIconViewItem::paintItem(p,mycg); |
414 | 420 | ||
415 | // Paint animation overlay | 421 | // Paint animation overlay |
416 | if ( liv->busyItem() == this ) | 422 | if ( liv->busyItem() == this ) |
417 | paintAnimatedIcon(p); | 423 | paintAnimatedIcon(p); |
418 | 424 | ||
419 | if ( liv->currentItem() == this ) | 425 | if ( liv->currentItem() == this ) |
420 | liv->setItemTextBackground( oldBrush ); | 426 | liv->setItemTextBackground( oldBrush ); |
421 | } | 427 | } |
422 | 428 | ||
429 | |||
430 | |||
423 | void LauncherItem::paintAnimatedIcon( QPainter *p ) | 431 | void LauncherItem::paintAnimatedIcon( QPainter *p ) |
424 | { | 432 | { |
425 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 433 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
426 | int pic = iteration % 16; | 434 | int pic = iteration % 16; |
427 | int w = pixmap()->width(), h = pixmap()->height(); | 435 | int w = pixmap()->width(), h = pixmap()->height(); |
428 | QPixmap dblBuf( w, h + 4 ); | 436 | QPixmap dblBuf( w, h + 4 ); |
429 | QPainter p2( &dblBuf ); | 437 | QPainter p2( &dblBuf ); |
430 | int x1, y1; | 438 | int x1, y1; |
431 | if ( liv->itemTextPos() == QIconView::Bottom ) { | 439 | if ( liv->itemTextPos() == QIconView::Bottom ) { |
432 | x1 = x() + (width() - w) / 2 - liv->contentsX(); | 440 | x1 = x() + (width() - w) / 2 - liv->contentsX(); |
433 | y1 = y() - liv->contentsY(); | 441 | y1 = y() - liv->contentsY(); |
434 | } else { | 442 | } else { |
435 | x1 = x() - liv->contentsX(); | 443 | x1 = x() - liv->contentsX(); |
436 | y1 = y() + (height() - h) / 2 - liv->contentsY(); | 444 | y1 = y() + (height() - h) / 2 - liv->contentsY(); |
437 | } | 445 | } |
438 | y1 -= 2; | 446 | y1 -= 2; |
439 | p2.translate(-x1,-y1); | 447 | p2.translate(-x1,-y1); |
440 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); | 448 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); |
441 | int bounceY = 2; | 449 | int bounceY = 2; |
442 | #ifdef BOUNCE_BUSY_ICON | 450 | #ifdef BOUNCE_BUSY_ICON |
443 | bounceY = 4 - ((iteration+2)%8); | 451 | if ( busyType == BIT_Animated ) { |
444 | bounceY = bounceY < 0 ? -bounceY : bounceY; | 452 | bounceY = 4 - ((iteration+2)%8); |
453 | bounceY = bounceY < 0 ? -bounceY : bounceY; | ||
454 | } | ||
445 | #endif | 455 | #endif |
446 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); | 456 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); |
447 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 457 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
448 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); | 458 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); |
449 | #endif | 459 | #endif |
450 | p->drawPixmap( x1, y1, dblBuf ); | 460 | p->drawPixmap( x1, y1, dblBuf ); |
451 | } | 461 | } |
452 | 462 | ||
453 | void LauncherItem::animateIcon() | 463 | void LauncherItem::animateIcon() |
454 | { | 464 | { |
455 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 465 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
456 | 466 | ||
457 | if ( liv->busyItem() != this || !app ) | 467 | if ( liv->busyItem() != this || !app ) |
458 | return; | 468 | return; |
459 | 469 | ||
460 | // Highlight the icon | 470 | // Highlight the icon |
461 | if ( iteration == 0 ) { | 471 | if ( iteration == 0 ) { |
462 | QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap(); | 472 | QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap(); |
463 | QImage img = src.convertToImage(); | 473 | QImage img = src.convertToImage(); |
464 | QRgb *rgb; | 474 | QRgb *rgb; |
465 | int count; | 475 | int count; |
466 | if ( img.depth() == 32 ) { | 476 | if ( img.depth() == 32 ) { |
467 | rgb = (QRgb*)img.bits(); | 477 | rgb = (QRgb*)img.bits(); |
468 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); | 478 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); |
469 | } else { | 479 | } else { |
470 | rgb = img.colorTable(); | 480 | rgb = img.colorTable(); |
471 | count = img.numColors(); | 481 | count = img.numColors(); |
472 | } | 482 | } |
473 | for ( int r = 0; r < count; r++, rgb++ ) { | 483 | for ( int r = 0; r < count; r++, rgb++ ) { |
474 | #if defined(BRIGHTEN_BUSY_ICON) | 484 | #if defined(BRIGHTEN_BUSY_ICON) |
475 | QColor c(*rgb); | 485 | QColor c(*rgb); |
476 | int h, s, v; | 486 | int h, s, v; |
477 | c.hsv(&h,&s,&v); | 487 | c.hsv(&h,&s,&v); |
478 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); | 488 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); |
479 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); | 489 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); |
480 | #elif defined(ALPHA_FADE_BUSY_ICON) | 490 | #elif defined(ALPHA_FADE_BUSY_ICON) |
481 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); | 491 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); |
482 | #endif | 492 | #endif |
483 | } | 493 | } |
484 | src.convertFromImage( img ); | 494 | src.convertFromImage( img ); |
485 | setPixmap( src ); | 495 | setPixmap( src ); |
486 | } | 496 | } |
487 | 497 | ||
488 | iteration++; | 498 | iteration++; |
489 | 499 | ||
490 | // Paint animation overlay | 500 | // Paint animation overlay |
491 | QPainter p( liv->viewport() ); | 501 | QPainter p( liv->viewport() ); |
492 | paintAnimatedIcon( &p ); | 502 | paintAnimatedIcon( &p ); |
493 | } | 503 | } |
494 | 504 | ||
495 | void LauncherItem::resetIcon() | 505 | void LauncherItem::resetIcon() |
496 | { | 506 | { |
497 | iteration = 0; | 507 | iteration = 0; |
498 | setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() ); | 508 | setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() ); |
499 | } | 509 | } |
500 | 510 | ||
501 | //=========================================================================== | 511 | //=========================================================================== |
502 | 512 | ||
503 | QStringList LauncherIconView::mimeTypes() const | 513 | QStringList LauncherIconView::mimeTypes() const |
504 | { | 514 | { |
505 | QStringList r; | 515 | QStringList r; |
506 | QDictIterator<void> it(mimes); | 516 | QDictIterator<void> it(mimes); |
507 | while (it.current()) { | 517 | while (it.current()) { |
508 | r.append(it.currentKey()); | 518 | r.append(it.currentKey()); |
509 | ++it; | 519 | ++it; |
510 | } | 520 | } |
511 | r.sort(); | 521 | r.sort(); |
512 | return r; | 522 | return r; |
513 | } | 523 | } |
514 | 524 | ||
515 | void LauncherIconView::addItem(AppLnk* app, bool resort) | 525 | void LauncherIconView::addItem(AppLnk* app, bool resort) |
516 | { | 526 | { |
517 | addCatsAndMimes(app); | 527 | addCatsAndMimes(app); |
518 | 528 | ||
519 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 529 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
520 | && (cf == 0 || app->categories().contains(cf) | 530 | && (cf == 0 || app->categories().contains(cf) |
521 | || cf == -1 && app->categories().count() == 0 ) ) | 531 | || cf == -1 && app->categories().count() == 0 ) ) |
522 | (void) new LauncherItem( this, app, bigIcns ); | 532 | (void) new LauncherItem( this, app, bigIcns ); |
523 | else | 533 | else |
524 | hidden.append(app); | 534 | hidden.append(app); |
525 | if ( resort ) | 535 | if ( resort ) |
526 | sort(); | 536 | sort(); |
527 | } | 537 | } |
528 | 538 | ||
529 | void LauncherIconView::updateCategoriesAndMimeTypes() | 539 | void LauncherIconView::updateCategoriesAndMimeTypes() |
530 | { | 540 | { |
531 | mimes.clear(); | 541 | mimes.clear(); |
532 | cats.clear(); | 542 | cats.clear(); |
533 | LauncherItem* item = (LauncherItem*)firstItem(); | 543 | LauncherItem* item = (LauncherItem*)firstItem(); |
534 | while (item) { | 544 | while (item) { |
535 | addCatsAndMimes(item->appLnk()); | 545 | addCatsAndMimes(item->appLnk()); |
536 | item = (LauncherItem*)item->nextItem(); | 546 | item = (LauncherItem*)item->nextItem(); |
537 | } | 547 | } |
538 | QListIterator<AppLnk> it(hidden); | 548 | QListIterator<AppLnk> it(hidden); |
539 | AppLnk* l; | 549 | AppLnk* l; |
540 | while ((l=it.current())) { | 550 | while ((l=it.current())) { |
541 | addCatsAndMimes(l); | 551 | addCatsAndMimes(l); |
542 | ++it; | 552 | ++it; |
543 | } | 553 | } |
544 | } | 554 | } |
545 | 555 | ||
546 | void LauncherIconView::hideOrShowItems(bool resort) | 556 | void LauncherIconView::hideOrShowItems(bool resort) |
547 | { | 557 | { |
548 | viewport()->setUpdatesEnabled( FALSE ); | 558 | viewport()->setUpdatesEnabled( FALSE ); |
549 | hidden.setAutoDelete(FALSE); | 559 | hidden.setAutoDelete(FALSE); |
550 | QList<AppLnk> links=hidden; | 560 | QList<AppLnk> links=hidden; |
551 | hidden.clear(); | 561 | hidden.clear(); |
552 | hidden.setAutoDelete(TRUE); | 562 | hidden.setAutoDelete(TRUE); |
553 | LauncherItem* item = (LauncherItem*)firstItem(); | 563 | LauncherItem* item = (LauncherItem*)firstItem(); |
554 | while (item) { | 564 | while (item) { |
555 | links.append(item->takeAppLnk()); | 565 | links.append(item->takeAppLnk()); |
556 | item = (LauncherItem*)item->nextItem(); | 566 | item = (LauncherItem*)item->nextItem(); |
557 | } | 567 | } |
558 | clear(); | 568 | clear(); |
559 | QListIterator<AppLnk> it(links); | 569 | QListIterator<AppLnk> it(links); |
560 | AppLnk* l; | 570 | AppLnk* l; |
561 | while ((l=it.current())) { | 571 | while ((l=it.current())) { |
562 | addItem(l,FALSE); | 572 | addItem(l,FALSE); |
563 | ++it; | 573 | ++it; |
564 | } | 574 | } |
565 | if ( resort && !autoArrange() ) | 575 | if ( resort && !autoArrange() ) |
566 | sort(); | 576 | sort(); |
567 | viewport()->setUpdatesEnabled( TRUE ); | 577 | viewport()->setUpdatesEnabled( TRUE ); |
568 | } | 578 | } |
569 | 579 | ||
570 | bool LauncherIconView::removeLink(const QString& linkfile) | 580 | bool LauncherIconView::removeLink(const QString& linkfile) |
571 | { | 581 | { |
572 | LauncherItem* item = (LauncherItem*)firstItem(); | 582 | LauncherItem* item = (LauncherItem*)firstItem(); |
573 | AppLnk* l; | 583 | AppLnk* l; |
574 | bool did = FALSE; | 584 | bool did = FALSE; |
575 | DocLnk dl(linkfile); | 585 | DocLnk dl(linkfile); |
576 | while (item) { | 586 | while (item) { |
577 | l = item->appLnk(); | 587 | l = item->appLnk(); |
578 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); | 588 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); |
579 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 589 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
580 | || l->fileKnown() && ( | 590 | || l->fileKnown() && ( |
581 | l->file() == linkfile | 591 | l->file() == linkfile |
582 | || dl.isValid() && dl.file() == l->file() ) ) { | 592 | || dl.isValid() && dl.file() == l->file() ) ) { |
583 | delete item; | 593 | delete item; |
584 | did = TRUE; | 594 | did = TRUE; |
585 | } | 595 | } |
586 | item = nextItem; | 596 | item = nextItem; |
587 | } | 597 | } |
588 | QListIterator<AppLnk> it(hidden); | 598 | QListIterator<AppLnk> it(hidden); |
589 | while ((l=it.current())) { | 599 | while ((l=it.current())) { |
590 | ++it; | 600 | ++it; |
591 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 601 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
592 | || l->file() == linkfile | 602 | || l->file() == linkfile |
593 | || dl.isValid() && dl.file() == l->file() ) { | 603 | || dl.isValid() && dl.file() == l->file() ) { |
594 | hidden.removeRef(l); | 604 | hidden.removeRef(l); |
595 | did = TRUE; | 605 | did = TRUE; |
596 | } | 606 | } |
597 | } | 607 | } |
598 | return did; | 608 | return did; |
599 | } | 609 | } |
600 | 610 | ||
601 | //=========================================================================== | 611 | //=========================================================================== |
602 | 612 | ||
603 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | 613 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) |
604 | : QVBox( parent, name, fl ) | 614 | : QVBox( parent, name, fl ) |
605 | { | 615 | { |
606 | catmb = 0; | 616 | catmb = 0; |
607 | icons = new LauncherIconView( this ); | 617 | icons = new LauncherIconView( this ); |
608 | setFocusProxy(icons); | 618 | setFocusProxy(icons); |
609 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); | 619 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); |
610 | 620 | ||
611 | icons->setItemsMovable( FALSE ); | 621 | icons->setItemsMovable( FALSE ); |
612 | icons->setAutoArrange( TRUE ); | 622 | icons->setAutoArrange( TRUE ); |
613 | icons->setSorting( TRUE ); | 623 | icons->setSorting( TRUE ); |
614 | icons->setFrameStyle( QFrame::NoFrame ); | 624 | icons->setFrameStyle( QFrame::NoFrame ); |
615 | icons->setMargin( 0 ); | 625 | icons->setMargin( 0 ); |
616 | icons->setSelectionMode( QIconView::NoSelection ); | 626 | icons->setSelectionMode( QIconView::NoSelection ); |
617 | icons->setBackgroundMode( PaletteBase ); | 627 | icons->setBackgroundMode( PaletteBase ); |
618 | icons->setResizeMode( QIconView::Fixed ); | 628 | icons->setResizeMode( QIconView::Fixed ); |
619 | vmode = (ViewMode)-1; | 629 | vmode = (ViewMode)-1; |
620 | setViewMode( Icon ); | 630 | setViewMode( Icon ); |
621 | 631 | ||
622 | connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), | 632 | connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), |
623 | SLOT(itemClicked(int, QIconViewItem *)) ); | 633 | SLOT(itemClicked(int, QIconViewItem *)) ); |
624 | connect( icons, SIGNAL(selectionChanged()), | 634 | connect( icons, SIGNAL(selectionChanged()), |
625 | SLOT(selectionChanged()) ); | 635 | SLOT(selectionChanged()) ); |
626 | connect( icons, SIGNAL(returnPressed(QIconViewItem *)), | 636 | connect( icons, SIGNAL(returnPressed(QIconViewItem *)), |
627 | SLOT(returnPressed(QIconViewItem *)) ); | 637 | SLOT(returnPressed(QIconViewItem *)) ); |
628 | connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), | 638 | connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), |
629 | SLOT(itemPressed(int, QIconViewItem *)) ); | 639 | SLOT(itemPressed(int, QIconViewItem *)) ); |
630 | 640 | ||
631 | tools = 0; | 641 | tools = 0; |
632 | setBackgroundType( Ruled, QString::null ); | 642 | setBackgroundType( Ruled, QString::null ); |
633 | } | 643 | } |
634 | 644 | ||
635 | LauncherView::~LauncherView() | 645 | LauncherView::~LauncherView() |
636 | { | 646 | { |
637 | if ( bgCache && bgCache->contains( bgName ) ) | 647 | if ( bgCache && bgCache->contains( bgName ) ) |
638 | (*bgCache)[bgName]->ref--; | 648 | (*bgCache)[bgName]->ref--; |
639 | } | 649 | } |
640 | 650 | ||
641 | void LauncherView::hideIcons() | 651 | void LauncherView::hideIcons() |
642 | { | 652 | { |
643 | icons->hide(); | 653 | icons->hide(); |
644 | } | 654 | } |
645 | 655 | ||
646 | void LauncherView::setToolsEnabled(bool y) | 656 | void LauncherView::setToolsEnabled(bool y) |
647 | { | 657 | { |
648 | if ( !y != !tools ) { | 658 | if ( !y != !tools ) { |
649 | if ( y ) { | 659 | if ( y ) { |
650 | tools = new QHBox(this); | 660 | tools = new QHBox(this); |
651 | 661 | ||
652 | // Type filter | 662 | // Type filter |
653 | typemb = new QComboBox(tools); | 663 | typemb = new QComboBox(tools); |
654 | QSizePolicy p = typemb->sizePolicy(); | 664 | QSizePolicy p = typemb->sizePolicy(); |
655 | p.setHorData(QSizePolicy::Expanding); | 665 | p.setHorData(QSizePolicy::Expanding); |
656 | typemb->setSizePolicy(p); | 666 | typemb->setSizePolicy(p); |
657 | 667 | ||
658 | // Category filter | 668 | // Category filter |
659 | updateTools(); | 669 | updateTools(); |
660 | tools->show(); | 670 | tools->show(); |
661 | 671 | ||
662 | // Always show vscrollbar | 672 | // Always show vscrollbar |
663 | icons->setVScrollBarMode( QScrollView::AlwaysOn ); | 673 | icons->setVScrollBarMode( QScrollView::AlwaysOn ); |
664 | } else { | 674 | } else { |
665 | delete tools; | 675 | delete tools; |
666 | tools = 0; | 676 | tools = 0; |
667 | } | 677 | } |
668 | } | 678 | } |
669 | } | 679 | } |
670 | 680 | ||
671 | void LauncherView::updateTools() | 681 | void LauncherView::updateTools() |
672 | { | 682 | { |
673 | disconnect( typemb, SIGNAL(activated(int)), | 683 | disconnect( typemb, SIGNAL(activated(int)), |
674 | this, SLOT(showType(int)) ); | 684 | this, SLOT(showType(int)) ); |
675 | if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), | 685 | if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), |
676 | this, SLOT(showCategory(int)) ); | 686 | this, SLOT(showCategory(int)) ); |
677 | 687 | ||
678 | // ### I want to remove this | 688 | // ### I want to remove this |
679 | icons->updateCategoriesAndMimeTypes(); | 689 | icons->updateCategoriesAndMimeTypes(); |
680 | 690 | ||
681 | QString prev; | 691 | QString prev; |
682 | 692 | ||
683 | // Type filter | 693 | // Type filter |
684 | QStringList types; | 694 | QStringList types; |
685 | typelist = icons->mimeTypes(); | 695 | typelist = icons->mimeTypes(); |
686 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { | 696 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { |
687 | QString t = *it; | 697 | QString t = *it; |
688 | if ( t.left(12) == "application/" ) { | 698 | if ( t.left(12) == "application/" ) { |
689 | MimeType mt(t); | 699 | MimeType mt(t); |
690 | const AppLnk* app = mt.application(); | 700 | const AppLnk* app = mt.application(); |
691 | if ( app ) | 701 | if ( app ) |
692 | t = app->name(); | 702 | t = app->name(); |
693 | else | 703 | else |
694 | t = t.mid(12); | 704 | t = t.mid(12); |
695 | } else { | 705 | } else { |
696 | t[0] = t[0].upper(); | 706 | t[0] = t[0].upper(); |
697 | } | 707 | } |
698 | types += t; | 708 | types += t; |
699 | } | 709 | } |
700 | types << tr("All types"); | 710 | types << tr("All types"); |
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 7863d6a..e40a006 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h | |||
@@ -1,112 +1,119 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LAUNCHERVIEW_H | 20 | #ifndef LAUNCHERVIEW_H |
21 | #define LAUNCHERVIEW_H | 21 | #define LAUNCHERVIEW_H |
22 | 22 | ||
23 | #include <qtopia/storage.h> | 23 | #include <qtopia/storage.h> |
24 | #include <qtopia/applnk.h> | 24 | #include <qtopia/applnk.h> |
25 | 25 | ||
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | 27 | ||
28 | class CategorySelect; | 28 | class CategorySelect; |
29 | class LauncherIconView; | 29 | class LauncherIconView; |
30 | class QIconView; | 30 | class QIconView; |
31 | class QIconViewItem; | 31 | class QIconViewItem; |
32 | class QLabel; | 32 | class QLabel; |
33 | class QWidgetStack; | 33 | class QWidgetStack; |
34 | class MenuButton; | 34 | class MenuButton; |
35 | class QComboBox; | 35 | class QComboBox; |
36 | 36 | ||
37 | |||
38 | |||
39 | enum BusyIndicatorType { | ||
40 | BIT_Normal = 0, | ||
41 | BIT_Animated | ||
42 | }; | ||
43 | |||
37 | class LauncherView : public QVBox | 44 | class LauncherView : public QVBox |
38 | { | 45 | { |
39 | Q_OBJECT | 46 | Q_OBJECT |
40 | 47 | ||
41 | public: | 48 | public: |
42 | LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 49 | LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
43 | ~LauncherView(); | 50 | ~LauncherView(); |
44 | 51 | ||
45 | void hideIcons(); | 52 | void hideIcons(); |
46 | 53 | ||
47 | bool removeLink(const QString& linkfile); | 54 | bool removeLink(const QString& linkfile); |
48 | void addItem(AppLnk* app, bool resort=TRUE); | 55 | void addItem(AppLnk* app, bool resort=TRUE); |
49 | void removeAllItems(); | 56 | void removeAllItems(); |
50 | void setSortEnabled(bool); | 57 | void setSortEnabled(bool); |
51 | void setUpdatesEnabled(bool); | 58 | void setUpdatesEnabled(bool); |
52 | void sort(); | 59 | void sort(); |
53 | 60 | ||
54 | void setToolsEnabled(bool); | 61 | void setToolsEnabled(bool); |
55 | void updateTools(); | 62 | void updateTools(); |
56 | 63 | ||
57 | void setBusy(bool); | 64 | void setBusy(bool); |
58 | void setBusyIndicatorType( const QString& ); | 65 | void setBusyIndicatorType( const QString& ); |
59 | 66 | ||
60 | enum ViewMode { Icon, List }; | 67 | enum ViewMode { Icon, List }; |
61 | void setViewMode( ViewMode m ); | 68 | void setViewMode( ViewMode m ); |
62 | ViewMode viewMode() const { return vmode; } | 69 | ViewMode viewMode() const { return vmode; } |
63 | 70 | ||
64 | enum BackgroundType { Ruled, SolidColor, Image }; | 71 | enum BackgroundType { Ruled, SolidColor, Image }; |
65 | void setBackgroundType( BackgroundType t, const QString & ); | 72 | void setBackgroundType( BackgroundType t, const QString & ); |
66 | BackgroundType backgroundType() const { return bgType; } | 73 | BackgroundType backgroundType() const { return bgType; } |
67 | 74 | ||
68 | void setTextColor( const QColor & ); | 75 | void setTextColor( const QColor & ); |
69 | QColor textColor() const { return textCol; } | 76 | QColor textColor() const { return textCol; } |
70 | 77 | ||
71 | void setViewFont( const QFont & ); | 78 | void setViewFont( const QFont & ); |
72 | void clearViewFont(); | 79 | void clearViewFont(); |
73 | 80 | ||
74 | void relayout(void); | 81 | void relayout(void); |
75 | 82 | ||
76 | signals: | 83 | signals: |
77 | void clicked( const AppLnk * ); | 84 | void clicked( const AppLnk * ); |
78 | void rightPressed( AppLnk * ); | 85 | void rightPressed( AppLnk * ); |
79 | 86 | ||
80 | protected slots: | 87 | protected slots: |
81 | void selectionChanged(); | 88 | void selectionChanged(); |
82 | void returnPressed( QIconViewItem *item ); | 89 | void returnPressed( QIconViewItem *item ); |
83 | void itemClicked( int, QIconViewItem * ); | 90 | void itemClicked( int, QIconViewItem * ); |
84 | void itemPressed( int, QIconViewItem * ); | 91 | void itemPressed( int, QIconViewItem * ); |
85 | void sortBy(int); | 92 | void sortBy(int); |
86 | void showType(int); | 93 | void showType(int); |
87 | void showCategory( int ); | 94 | void showCategory( int ); |
88 | void resizeEvent(QResizeEvent *); | 95 | void resizeEvent(QResizeEvent *); |
89 | void flushBgCache(); | 96 | void flushBgCache(); |
90 | 97 | ||
91 | protected: | 98 | protected: |
92 | void paletteChange( const QPalette & ); | 99 | void paletteChange( const QPalette & ); |
93 | 100 | ||
94 | void fontChanged(const QFont &); | 101 | void fontChanged(const QFont &); |
95 | 102 | ||
96 | private: | 103 | private: |
97 | static bool bsy; | 104 | static bool bsy; |
98 | QWidget* tools; | 105 | QWidget* tools; |
99 | LauncherIconView* icons; | 106 | LauncherIconView* icons; |
100 | QComboBox *typemb; | 107 | QComboBox *typemb; |
101 | QStringList typelist; | 108 | QStringList typelist; |
102 | CategorySelect *catmb; | 109 | CategorySelect *catmb; |
103 | ViewMode vmode; | 110 | ViewMode vmode; |
104 | BackgroundType bgType; | 111 | BackgroundType bgType; |
105 | QString bgName; | 112 | QString bgName; |
106 | QColor textCol; | 113 | QColor textCol; |
107 | 114 | ||
108 | QImage loadBackgroundImage(QString &fname); | 115 | QImage loadBackgroundImage(QString &fname); |
109 | int m_busyType; | 116 | |
110 | }; | 117 | }; |
111 | 118 | ||
112 | #endif // LAUNCHERVIEW_H | 119 | #endif // LAUNCHERVIEW_H |