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 | |||
@@ -17,214 +17,216 @@ | |||
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 ) { |
@@ -318,175 +320,183 @@ protected: | |||
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 ); |
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 |