summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp32
-rw-r--r--core/launcher/launcherview.h9
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
@@ -53,28 +53,24 @@
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
57class BgPixmap 57class BgPixmap
58{ 58{
59public: 59public:
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
65enum BusyIndicatorType {
66 BIT_Normal = 0,
67 BIT_Blinking
68};
69 65
70static QMap<QString,BgPixmap*> *bgCache = 0; 66static QMap<QString,BgPixmap*> *bgCache = 0;
71 67
72static void cleanup_cache() 68static 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 }
@@ -88,30 +84,33 @@ class LauncherItem : public QIconViewItem
88public: 84public:
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; }
100protected: 98protected:
101 bool isBigIcon; 99 bool isBigIcon;
102 int iteration; 100 int iteration;
103 AppLnk* app; 101 AppLnk* app;
104private: 102private:
105 void paintAnimatedIcon( QPainter *p ); 103 void paintAnimatedIcon( QPainter *p );
104 BusyIndicatorType busyType;
106}; 105};
107 106
108 107
109class LauncherIconView : public QIconView { 108class LauncherIconView : public QIconView {
110public: 109public:
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),
@@ -138,26 +137,26 @@ public:
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
@@ -167,28 +166,31 @@ public:
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());
@@ -354,36 +356,40 @@ private:
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
369bool LauncherView::bsy=FALSE; 372bool LauncherView::bsy=FALSE;
370 373
371void LauncherView::setBusy(bool on) 374void LauncherView::setBusy(bool on)
372{ 375{
373 icons->setBusy(on); 376 icons->setBusy(on);
374} 377}
375 378
376void LauncherView::setBusyIndicatorType( const QString& type ) { 379void 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
380LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 386LauncherItem::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
389LauncherItem::~LauncherItem() 395LauncherItem::~LauncherItem()
@@ -411,46 +417,50 @@ void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
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
423void LauncherItem::paintAnimatedIcon( QPainter *p ) 431void 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
453void LauncherItem::animateIcon() 463void LauncherItem::animateIcon()
454{ 464{
455 LauncherIconView* liv = (LauncherIconView*)iconView(); 465 LauncherIconView* liv = (LauncherIconView*)iconView();
456 466
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
@@ -25,24 +25,31 @@
25 25
26#include <qvbox.h> 26#include <qvbox.h>
27 27
28class CategorySelect; 28class CategorySelect;
29class LauncherIconView; 29class LauncherIconView;
30class QIconView; 30class QIconView;
31class QIconViewItem; 31class QIconViewItem;
32class QLabel; 32class QLabel;
33class QWidgetStack; 33class QWidgetStack;
34class MenuButton; 34class MenuButton;
35class QComboBox; 35class QComboBox;
36 36
37
38
39enum BusyIndicatorType {
40 BIT_Normal = 0,
41 BIT_Animated
42};
43
37class LauncherView : public QVBox 44class LauncherView : public QVBox
38{ 45{
39 Q_OBJECT 46 Q_OBJECT
40 47
41public: 48public:
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);
@@ -97,16 +104,16 @@ 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