summaryrefslogtreecommitdiff
authorsandman <sandman>2002-09-29 02:08:31 (UTC)
committer sandman <sandman>2002-09-29 02:08:31 (UTC)
commitb7fcdc189dacc8e054a32090af4677bc86955491 (patch) (unidiff)
tree43b500b48fb7718a8c84b7aab91398c568b64b5d
parentd6ac648c6f0f504f2f9c3b21d62524d3167682ae (diff)
downloadopie-b7fcdc189dacc8e054a32090af4677bc86955491.zip
opie-b7fcdc189dacc8e054a32090af4677bc86955491.tar.gz
opie-b7fcdc189dacc8e054a32090af4677bc86955491.tar.bz2
compromise for the new busy indicator:
old explosion + new highlight = exploding highlight ;)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp50
1 files changed, 38 insertions, 12 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index c2bde53..9f86136 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -22,155 +22,179 @@
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/qpedebug.h> 25#include <qpe/qpedebug.h>
26#include <qpe/categories.h> 26#include <qpe/categories.h>
27#include <qpe/categoryselect.h> 27#include <qpe/categoryselect.h>
28#include <qpe/menubutton.h> 28#include <qpe/menubutton.h>
29#include <qpe/mimetype.h> 29#include <qpe/mimetype.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qpetoolbar.h> 31#include <qpe/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 <qpainter.h> 41#include <qpainter.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qtoolbutton.h> 43#include <qtoolbutton.h>
44#include <qimage.h> 44#include <qimage.h>
45 45
46 46
47class BgPixmap 47class BgPixmap
48{ 48{
49public: 49public:
50 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 50 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
51 QPixmap pm; 51 QPixmap pm;
52 int ref; 52 int ref;
53}; 53};
54 54
55static QMap<QString,BgPixmap*> *bgCache = 0; 55static QMap<QString,BgPixmap*> *bgCache = 0;
56 56
57class LauncherIconView : public QIconView { 57class LauncherIconView : public QIconView {
58public: 58public:
59 LauncherIconView( QWidget* parent, const char* name=0 ) : 59 LauncherIconView( QWidget* parent, const char* name=0 ) :
60 QIconView(parent,name), 60 QIconView(parent,name),
61 tf(""), 61 tf(""),
62 cf(0), 62 cf(0),
63 bsy(0), 63 bsy(0),
64 bigIcns(TRUE), 64 bigIcns(TRUE),
65 bgColor(white) 65 bgColor(white)
66 { 66 {
67 sortmeth = Name; 67 sortmeth = Name;
68 hidden.setAutoDelete(TRUE); 68 hidden.setAutoDelete(TRUE);
69 ike = FALSE; 69 ike = FALSE;
70 busytimer = 0;
70 calculateGrid( Bottom ); 71 calculateGrid( Bottom );
71 } 72 }
72 73
73 ~LauncherIconView() 74 ~LauncherIconView()
74 { 75 {
75#if 0 // debuggery 76#if 0 // debuggery
76 QListIterator<AppLnk> it(hidden); 77 QListIterator<AppLnk> it(hidden);
77 AppLnk* l; 78 AppLnk* l;
78 while ((l=it.current())) { 79 while ((l=it.current())) {
79 ++it; 80 ++it;
80 //qDebug("%p: hidden (should remove)",l); 81 //qDebug("%p: hidden (should remove)",l);
81 } 82 }
82#endif 83#endif
83 } 84 }
84 85
85 QPixmap* busyPixmap() const { return (QPixmap*)&bpm; } 86 QPixmap* busyPixmap() const { return (QPixmap*)&bpm; }
86 QIconViewItem* busyItem() const { return bsy; } 87 QIconViewItem* busyItem() const { return bsy; }
87 void setBigIcons( bool bi ) { bigIcns = bi; } 88 void setBigIcons( bool bi ) { bigIcns = bi; }
88 89
89 void updateCategoriesAndMimeTypes(); 90 void updateCategoriesAndMimeTypes();
90 91
91 void doAutoScroll() 92 void doAutoScroll()
92 { 93 {
93 // We don't want rubberbanding (yet) 94 // We don't want rubberbanding (yet)
94 } 95 }
95 96
96 void setBusy(bool on) 97 void setBusy(bool on)
97 { 98 {
98 QIconViewItem *c = on ? currentItem() : 0; 99 QIconViewItem *c = on ? currentItem() : 0;
99 if ( bsy != c ) { 100 if ( bsy != c ) {
100 if ( c ) { 101 if ( bsy )
101 QPixmap *src = c->pixmap(); 102 bsy-> repaint ( );
103 bsy = c;
104
105 if ( bsy ) {
106 busytimer = startTimer ( 150 );
107 busystate = 50;
108 startTimer ( 0 );
109 }
110 else
111 killTimer ( busytimer );
112 }
113 }
114
115 virtual void timerEvent ( QTimerEvent *te )
116 {
117 if ( !te || ( te-> timerId ( ) == busytimer )) {
118 if ( bsy ) {
119 QPixmap *src = bsy-> QIconViewItem::pixmap();
102 QImage img = src->convertToImage(); 120 QImage img = src->convertToImage();
103 QRgb* rgb; 121 QRgb* rgb;
104 int count; 122 int count;
105 if ( img.depth() == 32 ) { 123 if ( img.depth() == 32 ) {
106 rgb = (QRgb*)img.bits(); 124 rgb = (QRgb*)img.bits();
107 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 125 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
108 } else { 126 } else {
109 rgb = img.colorTable(); 127 rgb = img.colorTable();
110 count = img.numColors(); 128 count = img.numColors();
111 } 129 }
112 int rc, gc, bc; 130 int rc, gc, bc;
131 int bs = ::abs ( busystate ) + 25;
113 colorGroup().highlight().rgb( &rc, &gc, &bc ); 132 colorGroup().highlight().rgb( &rc, &gc, &bc );
114 int ri, gi, bi; 133 rc = rc * bs / 100;
134 gc = gc * bs / 100;
135 bc = bc * bs / 100;
136
115 for ( int r = 0; r < count; r++, rgb++ ) { 137 for ( int r = 0; r < count; r++, rgb++ ) {
116 int ri = (rc+qRed(*rgb))/2; 138 int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100;
117 int gi = (gc+qGreen(*rgb))/2; 139 int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100;
118 int bi = (bc+qBlue(*rgb))/2; 140 int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100;
119 int ai = qAlpha(*rgb); 141 int ai = qAlpha ( *rgb );
120 *rgb = qRgba(ri,gi,bi,ai); 142 *rgb = qRgba ( ri, gi, bi, ai );
121 } 143 }
122 144
123 bpm.convertFromImage( img ); 145 bpm.convertFromImage( img );
146
147 bsy-> repaint ( );
148
149 busystate += 10;
150 if ( busystate > 50 )
151 busystate = -40;
124 } 152 }
125 QIconViewItem* o = bsy;
126 bsy = c;
127 if ( o ) o->repaint();
128 if ( c ) c->repaint();
129 } 153 }
130 } 154 }
131 155
132 bool inKeyEvent() const { return ike; } 156 bool inKeyEvent() const { return ike; }
133 void keyPressEvent(QKeyEvent* e) 157 void keyPressEvent(QKeyEvent* e)
134 { 158 {
135 ike = TRUE; 159 ike = TRUE;
136 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) 160 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space )
137 returnPressed(currentItem()); 161 returnPressed(currentItem());
138 QIconView::keyPressEvent(e); 162 QIconView::keyPressEvent(e);
139 ike = FALSE; 163 ike = FALSE;
140 } 164 }
141 165
142 void addItem(AppLnk* app, bool resort=TRUE); 166 void addItem(AppLnk* app, bool resort=TRUE);
143 bool removeLink(const QString& linkfile); 167 bool removeLink(const QString& linkfile);
144 168
145 QStringList mimeTypes() const; 169 QStringList mimeTypes() const;
146 QStringList categories() const; 170 QStringList categories() const;
147 171
148 void clear() 172 void clear()
149 { 173 {
150 mimes.clear(); 174 mimes.clear();
151 cats.clear(); 175 cats.clear();
152 QIconView::clear(); 176 QIconView::clear();
153 hidden.clear(); 177 hidden.clear();
154 } 178 }
155 179
156 void addCatsAndMimes(AppLnk* app) 180 void addCatsAndMimes(AppLnk* app)
157 { 181 {
158 // QStringList c = app->categories(); 182 // QStringList c = app->categories();
159 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 183 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
160 // cats.replace(*cit,(void*)1); 184 // cats.replace(*cit,(void*)1);
161 // } 185 // }
162 QString maj=app->type(); 186 QString maj=app->type();
163 int sl=maj.find('/'); 187 int sl=maj.find('/');
164 if (sl>=0) { 188 if (sl>=0) {
165 QString k; 189 QString k;
166 k = maj.left(12) == "application/" ? maj : maj.left(sl); 190 k = maj.left(12) == "application/" ? maj : maj.left(sl);
167 mimes.replace(k,(void*)1); 191 mimes.replace(k,(void*)1);
168 } 192 }
169 } 193 }
170 194
171 void setBackgroundPixmap( const QPixmap &pm ) { 195 void setBackgroundPixmap( const QPixmap &pm ) {
172 bgPixmap = pm; 196 bgPixmap = pm;
173 } 197 }
174 198
175 void setBackgroundColor( const QColor &c ) { 199 void setBackgroundColor( const QColor &c ) {
176 bgColor = c; 200 bgColor = c;
@@ -242,96 +266,98 @@ public:
242 QString getAllDocLinkInfo() const; 266 QString getAllDocLinkInfo() const;
243 267
244protected: 268protected:
245 269
246 void styleChange( QStyle &old ) 270 void styleChange( QStyle &old )
247 { 271 {
248 QIconView::styleChange( old ); 272 QIconView::styleChange( old );
249 calculateGrid( itemTextPos() ); 273 calculateGrid( itemTextPos() );
250 } 274 }
251 275
252 void calculateGrid( ItemTextPos pos ) 276 void calculateGrid( ItemTextPos pos )
253 { 277 {
254 int dw = QApplication::desktop()->width(); 278 int dw = QApplication::desktop()->width();
255 int viewerWidth = dw-style().scrollBarExtent().width(); 279 int viewerWidth = dw-style().scrollBarExtent().width();
256 if ( pos == Bottom ) { 280 if ( pos == Bottom ) {
257 int cols = 3; 281 int cols = 3;
258 if ( viewerWidth <= 200 ) 282 if ( viewerWidth <= 200 )
259 cols = 2; 283 cols = 2;
260 else if ( viewerWidth >= 400 ) 284 else if ( viewerWidth >= 400 )
261 cols = viewerWidth/96; 285 cols = viewerWidth/96;
262 setSpacing( 4 ); 286 setSpacing( 4 );
263 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 287 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
264 setGridY( fontMetrics().height()*2+24 ); 288 setGridY( fontMetrics().height()*2+24 );
265 } else { 289 } else {
266 int cols = 2; 290 int cols = 2;
267 if ( viewerWidth < 150 ) 291 if ( viewerWidth < 150 )
268 cols = 1; 292 cols = 1;
269 else if ( viewerWidth >= 400 ) 293 else if ( viewerWidth >= 400 )
270 cols = viewerWidth/150; 294 cols = viewerWidth/150;
271 setSpacing( 2 ); 295 setSpacing( 2 );
272 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 296 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
273 setGridY( fontMetrics().height()+2 ); 297 setGridY( fontMetrics().height()+2 );
274 } 298 }
275 } 299 }
276 300
277private: 301private:
278 QList<AppLnk> hidden; 302 QList<AppLnk> hidden;
279 QDict<void> mimes; 303 QDict<void> mimes;
280 QDict<void> cats; 304 QDict<void> cats;
281 SortMethod sortmeth; 305 SortMethod sortmeth;
282 QRegExp tf; 306 QRegExp tf;
283 int cf; 307 int cf;
284 QIconViewItem* bsy; 308 QIconViewItem* bsy;
285 bool ike; 309 bool ike;
286 bool bigIcns; 310 bool bigIcns;
287 QPixmap bgPixmap; 311 QPixmap bgPixmap;
288 QPixmap bpm; 312 QPixmap bpm;
289 QColor bgColor; 313 QColor bgColor;
314 int busytimer;
315 int busystate;
290}; 316};
291 317
292 318
293bool LauncherView::bsy=FALSE; 319bool LauncherView::bsy=FALSE;
294 320
295void LauncherView::setBusy(bool on) 321void LauncherView::setBusy(bool on)
296{ 322{
297 icons->setBusy(on); 323 icons->setBusy(on);
298} 324}
299 325
300class LauncherItem : public QIconViewItem 326class LauncherItem : public QIconViewItem
301{ 327{
302public: 328public:
303 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 329 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
304 ~LauncherItem() 330 ~LauncherItem()
305 { 331 {
306 LauncherIconView* liv = (LauncherIconView*)iconView(); 332 LauncherIconView* liv = (LauncherIconView*)iconView();
307 if ( liv->busyItem() == this ) 333 if ( liv->busyItem() == this )
308 liv->setBusy(FALSE); 334 liv->setBusy(FALSE);
309 delete app; 335 delete app;
310 } 336 }
311 337
312 AppLnk* appLnk() const { return app; } 338 AppLnk* appLnk() const { return app; }
313 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } 339 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; }
314 340
315 virtual int compare ( QIconViewItem * i ) const; 341 virtual int compare ( QIconViewItem * i ) const;
316 342
317 void paintItem( QPainter *p, const QColorGroup &cg ) 343 void paintItem( QPainter *p, const QColorGroup &cg )
318 { 344 {
319 LauncherIconView* liv = (LauncherIconView*)iconView(); 345 LauncherIconView* liv = (LauncherIconView*)iconView();
320 QBrush oldBrush( liv->itemTextBackground() ); 346 QBrush oldBrush( liv->itemTextBackground() );
321 QColorGroup mycg( cg ); 347 QColorGroup mycg( cg );
322 if ( liv->currentItem() == this ) { 348 if ( liv->currentItem() == this ) {
323 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 349 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
324 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 350 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
325 } 351 }
326 QIconViewItem::paintItem(p,mycg); 352 QIconViewItem::paintItem(p,mycg);
327 if ( liv->currentItem() == this ) 353 if ( liv->currentItem() == this )
328 liv->setItemTextBackground( oldBrush ); 354 liv->setItemTextBackground( oldBrush );
329 } 355 }
330 356
331 virtual QPixmap* pixmap () const 357 virtual QPixmap* pixmap () const
332 { 358 {
333 const LauncherIconView* liv = (LauncherIconView*)iconView(); 359 const LauncherIconView* liv = (LauncherIconView*)iconView();
334 if ( (const LauncherItem *)liv->busyItem() == this ) 360 if ( (const LauncherItem *)liv->busyItem() == this )
335 return liv->busyPixmap(); 361 return liv->busyPixmap();
336 return QIconViewItem::pixmap(); 362 return QIconViewItem::pixmap();
337 } 363 }