-rw-r--r-- | core/launcher/launcherview.cpp | 91 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 5 |
2 files changed, 64 insertions, 32 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 673e53c..506c11e 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -52,143 +52,145 @@ public: | |||
52 | QPixmap pm; | 52 | QPixmap pm; |
53 | int ref; | 53 | int ref; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | 56 | ||
57 | static QMap<QString,BgPixmap*> *bgCache = 0; | 57 | static QMap<QString,BgPixmap*> *bgCache = 0; |
58 | 58 | ||
59 | static void cleanup_cache() | 59 | static void cleanup_cache() |
60 | { | 60 | { |
61 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 61 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
62 | while ( it != bgCache->end() ) { | 62 | while ( it != bgCache->end() ) { |
63 | QMap<QString,BgPixmap*>::Iterator curr = it; | 63 | QMap<QString,BgPixmap*>::Iterator curr = it; |
64 | ++it; | 64 | ++it; |
65 | delete (*curr); | 65 | delete (*curr); |
66 | bgCache->remove( curr ); | 66 | bgCache->remove( curr ); |
67 | } | 67 | } |
68 | delete bgCache; | 68 | delete bgCache; |
69 | bgCache = 0; | 69 | bgCache = 0; |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | class LauncherItem : public QIconViewItem | 73 | class LauncherItem : public QIconViewItem |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | enum iconstate_t { | ||
77 | BASE_ICON, | ||
78 | WAITING_ICON, | ||
79 | EYE_ICON | ||
80 | }; | ||
81 | |||
76 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); | 82 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); |
77 | ~LauncherItem(); | 83 | ~LauncherItem(); |
78 | 84 | ||
79 | AppLnk *appLnk() const { return app; } | 85 | AppLnk *appLnk() const { return app; } |
80 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } | 86 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } |
81 | 87 | ||
82 | void animateIcon(); | 88 | void animateIcon(); |
83 | void resetIcon(); | 89 | void resetIcon(); |
84 | bool isEyeImage()const{return m_EyeImage;} | 90 | bool isEyeImage()const{return m_EyeImage;} |
85 | 91 | ||
86 | virtual int compare ( QIconViewItem * i ) const; | 92 | virtual int compare ( QIconViewItem * i ) const; |
87 | void paintItem( QPainter *p, const QColorGroup &cg ); | 93 | void paintItem( QPainter *p, const QColorGroup &cg ); |
88 | 94 | ||
89 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 95 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
90 | void setEyePixmap(const QPixmap&aIcon); | 96 | void setEyePixmap(const QPixmap&aIcon); |
97 | virtual QPixmap*pixmap()const; | ||
98 | |||
91 | protected: | 99 | protected: |
92 | bool isBigIcon; | 100 | bool isBigIcon; |
93 | int iteration; | 101 | int iteration; |
94 | AppLnk* app; | 102 | AppLnk* app; |
95 | 103 | ||
96 | private: | 104 | private: |
97 | void paintAnimatedIcon( QPainter *p ); | 105 | void paintAnimatedIcon( QPainter *p ); |
98 | BusyIndicatorType busyType; | 106 | BusyIndicatorType busyType; |
99 | int psize; | 107 | int psize; |
100 | QPixmap m_iPixmap; | 108 | QPixmap m_iPixmap; |
101 | bool m_EyeImage; | 109 | bool m_EyeImage; |
110 | iconstate_t m_EyeImageSet; | ||
102 | }; | 111 | }; |
103 | 112 | ||
104 | |||
105 | bool LauncherView::bsy=FALSE; | ||
106 | |||
107 | void LauncherView::setBusy(bool on) | ||
108 | { | ||
109 | icons->setBusy(on); | ||
110 | } | ||
111 | |||
112 | void LauncherView::setBusyIndicatorType( const QString& type ) { | ||
113 | if ( type. lower ( ) == "animated" ) | ||
114 | icons->setBusyIndicatorType( BIT_Animated ) ; | ||
115 | else | ||
116 | icons->setBusyIndicatorType( BIT_Normal ) ; | ||
117 | } | ||
118 | |||
119 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | 113 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) |
120 | : QIconViewItem( parent, applnk->name(), | 114 | : QIconViewItem( parent, applnk->name(), |
121 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), | 115 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), |
122 | isBigIcon( bigIcon ), | 116 | isBigIcon( bigIcon ), |
123 | iteration(0), | 117 | iteration(0), |
124 | app(applnk), // Takes ownership | 118 | app(applnk), // Takes ownership |
125 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), | 119 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), |
126 | m_iPixmap(), | 120 | m_iPixmap(), |
127 | m_EyeImage(false) | 121 | m_EyeImage(false), |
122 | m_EyeImageSet(BASE_ICON) | ||
128 | { | 123 | { |
129 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { | 124 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { |
130 | m_EyeImage = true; | 125 | m_EyeImage = true; |
131 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); | 126 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); |
132 | } | 127 | } |
133 | } | 128 | } |
134 | 129 | ||
135 | LauncherItem::~LauncherItem() | 130 | LauncherItem::~LauncherItem() |
136 | { | 131 | { |
137 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 132 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
138 | if ( liv->busyItem() == this ) | 133 | if ( liv->busyItem() == this ) |
139 | liv->setBusy(FALSE); | 134 | liv->setBusy(FALSE); |
140 | delete app; | 135 | delete app; |
141 | } | 136 | } |
142 | 137 | ||
138 | QPixmap*LauncherItem::pixmap()const | ||
139 | { | ||
140 | if (m_EyeImage && m_EyeImageSet == BASE_ICON) { | ||
141 | LauncherIconView* liv = (LauncherIconView*)iconView(); | ||
142 | liv->requestEyePix(this); | ||
143 | } | ||
144 | return QIconViewItem::pixmap(); | ||
145 | } | ||
146 | |||
143 | int LauncherItem::compare ( QIconViewItem * i ) const | 147 | int LauncherItem::compare ( QIconViewItem * i ) const |
144 | { | 148 | { |
145 | LauncherIconView* view = (LauncherIconView*)iconView(); | 149 | LauncherIconView* view = (LauncherIconView*)iconView(); |
146 | return view->compare(app,((LauncherItem *)i)->appLnk()); | 150 | return view->compare(app,((LauncherItem *)i)->appLnk()); |
147 | } | 151 | } |
148 | 152 | ||
149 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) | 153 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) |
150 | { | 154 | { |
151 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 155 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
152 | QBrush oldBrush( liv->itemTextBackground() ); | 156 | QBrush oldBrush( liv->itemTextBackground() ); |
153 | QColorGroup mycg( cg ); | 157 | QColorGroup mycg( cg ); |
154 | if ( liv->currentItem() == this ) { | 158 | if ( liv->currentItem() == this ) { |
155 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); | 159 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); |
156 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); | 160 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); |
157 | } | 161 | } |
158 | 162 | ||
159 | QIconViewItem::paintItem(p,mycg); | 163 | QIconViewItem::paintItem(p,mycg); |
160 | 164 | ||
161 | // Paint animation overlay | 165 | // Paint animation overlay |
162 | if ( liv->busyItem() == this ) | 166 | if ( liv->busyItem() == this ) |
163 | paintAnimatedIcon(p); | 167 | paintAnimatedIcon(p); |
164 | 168 | ||
165 | if ( liv->currentItem() == this ) | 169 | if ( liv->currentItem() == this ) |
166 | liv->setItemTextBackground( oldBrush ); | 170 | liv->setItemTextBackground( oldBrush ); |
167 | } | 171 | } |
168 | 172 | ||
169 | |||
170 | |||
171 | void LauncherItem::paintAnimatedIcon( QPainter *p ) | 173 | void LauncherItem::paintAnimatedIcon( QPainter *p ) |
172 | { | 174 | { |
173 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 175 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
174 | int pic = iteration % 16; | 176 | int pic = iteration % 16; |
175 | int w = pixmap()->width(), h = pixmap()->height(); | 177 | int w = pixmap()->width(), h = pixmap()->height(); |
176 | QPixmap dblBuf( w, h + 4 ); | 178 | QPixmap dblBuf( w, h + 4 ); |
177 | QPainter p2( &dblBuf ); | 179 | QPainter p2( &dblBuf ); |
178 | int x1, y1; | 180 | int x1, y1; |
179 | if ( liv->itemTextPos() == QIconView::Bottom ) { | 181 | if ( liv->itemTextPos() == QIconView::Bottom ) { |
180 | x1 = x() + (width() - w) / 2 - liv->contentsX(); | 182 | x1 = x() + (width() - w) / 2 - liv->contentsX(); |
181 | y1 = y() - liv->contentsY(); | 183 | y1 = y() - liv->contentsY(); |
182 | } else { | 184 | } else { |
183 | x1 = x() - liv->contentsX(); | 185 | x1 = x() - liv->contentsX(); |
184 | y1 = y() + (height() - h) / 2 - liv->contentsY(); | 186 | y1 = y() + (height() - h) / 2 - liv->contentsY(); |
185 | } | 187 | } |
186 | y1 -= 2; | 188 | y1 -= 2; |
187 | p2.translate(-x1,-y1); | 189 | p2.translate(-x1,-y1); |
188 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); | 190 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); |
189 | int bounceY = 2; | 191 | int bounceY = 2; |
190 | #ifdef BOUNCE_BUSY_ICON | 192 | #ifdef BOUNCE_BUSY_ICON |
191 | if ( busyType == BIT_Animated ) { | 193 | if ( busyType == BIT_Animated ) { |
192 | bounceY = 4 - ((iteration+2)%8); | 194 | bounceY = 4 - ((iteration+2)%8); |
193 | bounceY = bounceY < 0 ? -bounceY : bounceY; | 195 | bounceY = bounceY < 0 ? -bounceY : bounceY; |
194 | } | 196 | } |
@@ -234,48 +236,49 @@ void LauncherItem::animateIcon() | |||
234 | #endif | 236 | #endif |
235 | } | 237 | } |
236 | src.convertFromImage( img ); | 238 | src.convertFromImage( img ); |
237 | setPixmap( src ); | 239 | setPixmap( src ); |
238 | } | 240 | } |
239 | 241 | ||
240 | iteration++; | 242 | iteration++; |
241 | 243 | ||
242 | // Paint animation overlay | 244 | // Paint animation overlay |
243 | QPainter p( liv->viewport() ); | 245 | QPainter p( liv->viewport() ); |
244 | paintAnimatedIcon( &p ); | 246 | paintAnimatedIcon( &p ); |
245 | } | 247 | } |
246 | 248 | ||
247 | void LauncherItem::resetIcon() | 249 | void LauncherItem::resetIcon() |
248 | { | 250 | { |
249 | iteration = 0; | 251 | iteration = 0; |
250 | setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); | 252 | setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); |
251 | } | 253 | } |
252 | 254 | ||
253 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) | 255 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) |
254 | { | 256 | { |
255 | if (!isEyeImage()) return; | 257 | if (!isEyeImage()) return; |
256 | m_iPixmap = aIcon; | 258 | m_iPixmap = aIcon; |
257 | setPixmap(aIcon); | 259 | setPixmap(aIcon); |
260 | m_EyeImageSet = EYE_ICON; | ||
258 | } | 261 | } |
259 | 262 | ||
260 | //=========================================================================== | 263 | //=========================================================================== |
261 | // Implemantation of LauncherIconview start | 264 | // Implemantation of LauncherIconview start |
262 | //=========================================================================== | 265 | //=========================================================================== |
263 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) | 266 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) |
264 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) | 267 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) |
265 | { | 268 | { |
266 | m_EyeCallBack = 0; | 269 | m_EyeCallBack = 0; |
267 | sortmeth = Name; | 270 | sortmeth = Name; |
268 | hidden.setAutoDelete(TRUE); | 271 | hidden.setAutoDelete(TRUE); |
269 | ike = FALSE; | 272 | ike = FALSE; |
270 | calculateGrid( Bottom ); | 273 | calculateGrid( Bottom ); |
271 | } | 274 | } |
272 | 275 | ||
273 | LauncherIconView::~LauncherIconView() | 276 | LauncherIconView::~LauncherIconView() |
274 | { | 277 | { |
275 | #if 0 // debuggery | 278 | #if 0 // debuggery |
276 | QListIterator<AppLnk> it(hidden); | 279 | QListIterator<AppLnk> it(hidden); |
277 | AppLnk* l; | 280 | AppLnk* l; |
278 | while ((l=it.current())) { | 281 | while ((l=it.current())) { |
279 | ++it; | 282 | ++it; |
280 | //odebug << "" << l << ": hidden (should remove)" << oendl; | 283 | //odebug << "" << l << ": hidden (should remove)" << oendl; |
281 | } | 284 | } |
@@ -400,73 +403,82 @@ void LauncherIconView::clear() | |||
400 | QStringList LauncherIconView::mimeTypes() const | 403 | QStringList LauncherIconView::mimeTypes() const |
401 | { | 404 | { |
402 | QStringList r; | 405 | QStringList r; |
403 | QDictIterator<void> it(mimes); | 406 | QDictIterator<void> it(mimes); |
404 | while (it.current()) { | 407 | while (it.current()) { |
405 | r.append(it.currentKey()); | 408 | r.append(it.currentKey()); |
406 | ++it; | 409 | ++it; |
407 | } | 410 | } |
408 | r.sort(); | 411 | r.sort(); |
409 | return r; | 412 | return r; |
410 | } | 413 | } |
411 | 414 | ||
412 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) | 415 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) |
413 | { | 416 | { |
414 | LauncherItem* item = (LauncherItem*)firstItem(); | 417 | LauncherItem* item = (LauncherItem*)firstItem(); |
415 | while (item) { | 418 | while (item) { |
416 | if (item->appLnk()->file()==fname) { | 419 | if (item->appLnk()->file()==fname) { |
417 | break; | 420 | break; |
418 | } | 421 | } |
419 | item = (LauncherItem*)item->nextItem(); | 422 | item = (LauncherItem*)item->nextItem(); |
420 | } | 423 | } |
421 | return item; | 424 | return item; |
422 | } | 425 | } |
423 | 426 | ||
424 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile) | 427 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) |
425 | { | 428 | { |
429 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | ||
430 | if (s!=width) return; | ||
426 | LauncherItem*item = findDocItem(aFile); | 431 | LauncherItem*item = findDocItem(aFile); |
427 | if (!item||!item->isEyeImage()) return; | 432 | if (!item||!item->isEyeImage()) return; |
428 | |||
429 | item->setEyePixmap(aPixmap); | 433 | item->setEyePixmap(aPixmap); |
430 | } | 434 | } |
431 | 435 | ||
432 | void LauncherIconView::checkCallback() | 436 | void LauncherIconView::checkCallback() |
433 | { | 437 | { |
434 | if (m_EyeCallBack) { | 438 | if (m_EyeCallBack) { |
435 | return; | 439 | return; |
436 | } | 440 | } |
437 | m_EyeCallBack = new LauncherThumbReceiver(); | 441 | m_EyeCallBack = new LauncherThumbReceiver(); |
438 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&)), | 442 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), |
439 | this,SLOT(setEyePixmap(const QPixmap&,const QString&))); | 443 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); |
440 | } | 444 | } |
441 | 445 | ||
442 | void LauncherIconView::addCheckItem(AppLnk* app) | 446 | void LauncherIconView::addCheckItem(AppLnk* app) |
443 | { | 447 | { |
444 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); | 448 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); |
445 | if (item->isEyeImage()) { | 449 | if (item->isEyeImage()) { |
446 | checkCallback(); | 450 | checkCallback(); |
451 | } | ||
452 | } | ||
453 | |||
454 | void LauncherIconView::requestEyePix(const LauncherItem*item) | ||
455 | { | ||
456 | if (!item) return; | ||
457 | if (item->isEyeImage()) { | ||
458 | checkCallback(); | ||
447 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 459 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
448 | m_EyeCallBack->requestThumb(app->file(),s,s); | 460 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); |
449 | } | 461 | } |
450 | } | 462 | } |
451 | 463 | ||
452 | void LauncherIconView::addItem(AppLnk* app, bool resort) | 464 | void LauncherIconView::addItem(AppLnk* app, bool resort) |
453 | { | 465 | { |
454 | addCatsAndMimes(app); | 466 | addCatsAndMimes(app); |
455 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 467 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
456 | && (cf == 0 || app->categories().contains(cf) | 468 | && (cf == 0 || app->categories().contains(cf) |
457 | || cf == -1 && app->categories().count() == 0 ) ) { | 469 | || cf == -1 && app->categories().count() == 0 ) ) { |
458 | addCheckItem(app); | 470 | addCheckItem(app); |
459 | } else { | 471 | } else { |
460 | hidden.append(app); | 472 | hidden.append(app); |
461 | } | 473 | } |
462 | if ( resort ){ | 474 | if ( resort ){ |
463 | sort(); | 475 | sort(); |
464 | } | 476 | } |
465 | } | 477 | } |
466 | 478 | ||
467 | void LauncherIconView::updateCategoriesAndMimeTypes() | 479 | void LauncherIconView::updateCategoriesAndMimeTypes() |
468 | { | 480 | { |
469 | mimes.clear(); | 481 | mimes.clear(); |
470 | cats.clear(); | 482 | cats.clear(); |
471 | LauncherItem* item = (LauncherItem*)firstItem(); | 483 | LauncherItem* item = (LauncherItem*)firstItem(); |
472 | while (item) { | 484 | while (item) { |
@@ -612,48 +624,63 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | |||
612 | icons->setBackgroundMode( PaletteBase ); | 624 | icons->setBackgroundMode( PaletteBase ); |
613 | icons->setResizeMode( QIconView::Fixed ); | 625 | icons->setResizeMode( QIconView::Fixed ); |
614 | vmode = (ViewMode)-1; | 626 | vmode = (ViewMode)-1; |
615 | setViewMode( Icon ); | 627 | setViewMode( Icon ); |
616 | 628 | ||
617 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), | 629 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), |
618 | SLOT(itemClicked(int,QIconViewItem*)) ); | 630 | SLOT(itemClicked(int,QIconViewItem*)) ); |
619 | connect( icons, SIGNAL(selectionChanged()), | 631 | connect( icons, SIGNAL(selectionChanged()), |
620 | SLOT(selectionChanged()) ); | 632 | SLOT(selectionChanged()) ); |
621 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), | 633 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), |
622 | SLOT(returnPressed(QIconViewItem*)) ); | 634 | SLOT(returnPressed(QIconViewItem*)) ); |
623 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), | 635 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), |
624 | SLOT(itemPressed(int,QIconViewItem*)) ); | 636 | SLOT(itemPressed(int,QIconViewItem*)) ); |
625 | 637 | ||
626 | tools = 0; | 638 | tools = 0; |
627 | setBackgroundType( Ruled, QString::null ); | 639 | setBackgroundType( Ruled, QString::null ); |
628 | } | 640 | } |
629 | 641 | ||
630 | LauncherView::~LauncherView() | 642 | LauncherView::~LauncherView() |
631 | { | 643 | { |
632 | if ( bgCache && bgCache->contains( bgName ) ) | 644 | if ( bgCache && bgCache->contains( bgName ) ) |
633 | (*bgCache)[bgName]->ref--; | 645 | (*bgCache)[bgName]->ref--; |
634 | } | 646 | } |
635 | 647 | ||
648 | |||
649 | bool LauncherView::bsy=FALSE; | ||
650 | |||
651 | void LauncherView::setBusy(bool on) | ||
652 | { | ||
653 | icons->setBusy(on); | ||
654 | } | ||
655 | |||
656 | void LauncherView::setBusyIndicatorType( const QString& type ) { | ||
657 | if ( type. lower ( ) == "animated" ) | ||
658 | icons->setBusyIndicatorType( BIT_Animated ) ; | ||
659 | else | ||
660 | icons->setBusyIndicatorType( BIT_Normal ) ; | ||
661 | } | ||
662 | |||
636 | void LauncherView::hideIcons() | 663 | void LauncherView::hideIcons() |
637 | { | 664 | { |
638 | icons->hide(); | 665 | icons->hide(); |
639 | } | 666 | } |
640 | 667 | ||
641 | void LauncherView::setToolsEnabled(bool y) | 668 | void LauncherView::setToolsEnabled(bool y) |
642 | { | 669 | { |
643 | if ( !y != !tools ) { | 670 | if ( !y != !tools ) { |
644 | if ( y ) { | 671 | if ( y ) { |
645 | tools = new QHBox(this); | 672 | tools = new QHBox(this); |
646 | 673 | ||
647 | // Type filter | 674 | // Type filter |
648 | typemb = new QComboBox(tools); | 675 | typemb = new QComboBox(tools); |
649 | QSizePolicy p = typemb->sizePolicy(); | 676 | QSizePolicy p = typemb->sizePolicy(); |
650 | p.setHorData(QSizePolicy::Expanding); | 677 | p.setHorData(QSizePolicy::Expanding); |
651 | typemb->setSizePolicy(p); | 678 | typemb->setSizePolicy(p); |
652 | 679 | ||
653 | // Category filter | 680 | // Category filter |
654 | updateTools(); | 681 | updateTools(); |
655 | tools->show(); | 682 | tools->show(); |
656 | 683 | ||
657 | } else { | 684 | } else { |
658 | delete tools; | 685 | delete tools; |
659 | tools = 0; | 686 | tools = 0; |
@@ -1032,86 +1059,90 @@ void LauncherView::fontChanged(const QFont&) | |||
1032 | icons->hideOrShowItems( FALSE ); | 1059 | icons->hideOrShowItems( FALSE ); |
1033 | } | 1060 | } |
1034 | 1061 | ||
1035 | void LauncherView::relayout(void) | 1062 | void LauncherView::relayout(void) |
1036 | { | 1063 | { |
1037 | icons->hideOrShowItems(FALSE); | 1064 | icons->hideOrShowItems(FALSE); |
1038 | } | 1065 | } |
1039 | 1066 | ||
1040 | void LauncherView::flushBgCache() | 1067 | void LauncherView::flushBgCache() |
1041 | { | 1068 | { |
1042 | if ( !bgCache ) | 1069 | if ( !bgCache ) |
1043 | return; | 1070 | return; |
1044 | // remove unreferenced backgrounds. | 1071 | // remove unreferenced backgrounds. |
1045 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 1072 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
1046 | while ( it != bgCache->end() ) { | 1073 | while ( it != bgCache->end() ) { |
1047 | QMap<QString,BgPixmap*>::Iterator curr = it; | 1074 | QMap<QString,BgPixmap*>::Iterator curr = it; |
1048 | ++it; | 1075 | ++it; |
1049 | if ( (*curr)->ref == 0 ) { | 1076 | if ( (*curr)->ref == 0 ) { |
1050 | delete (*curr); | 1077 | delete (*curr); |
1051 | bgCache->remove( curr ); | 1078 | bgCache->remove( curr ); |
1052 | } | 1079 | } |
1053 | } | 1080 | } |
1054 | } | 1081 | } |
1055 | 1082 | ||
1083 | /* | ||
1084 | * Launcherthumbnail handling for image files | ||
1085 | */ | ||
1086 | |||
1056 | /* special image handling - based on opie eye */ | 1087 | /* special image handling - based on opie eye */ |
1057 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 1088 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { |
1058 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; | 1089 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; |
1059 | return s; | 1090 | return s; |
1060 | } | 1091 | } |
1061 | 1092 | ||
1062 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 1093 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { |
1063 | return s << inf.file << inf.width << inf.height; | 1094 | return s << inf.file << inf.width << inf.height; |
1064 | } | 1095 | } |
1065 | 1096 | ||
1066 | LauncherThumbReceiver::LauncherThumbReceiver() | 1097 | LauncherThumbReceiver::LauncherThumbReceiver() |
1067 | :QObject() | 1098 | :QObject() |
1068 | { | 1099 | { |
1069 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); | 1100 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); |
1070 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), | 1101 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), |
1071 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); | 1102 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); |
1072 | 1103 | ||
1073 | { | 1104 | { |
1074 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 1105 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
1075 | } | 1106 | } |
1076 | } | 1107 | } |
1077 | 1108 | ||
1078 | LauncherThumbReceiver::~LauncherThumbReceiver() | 1109 | LauncherThumbReceiver::~LauncherThumbReceiver() |
1079 | { | 1110 | { |
1080 | { | 1111 | { |
1081 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 1112 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
1082 | } | 1113 | } |
1083 | } | 1114 | } |
1084 | 1115 | ||
1085 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | 1116 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) |
1086 | { | 1117 | { |
1087 | PixmapInfos pixinfos; | 1118 | PixmapInfos pixinfos; |
1088 | QDataStream stream( at, IO_ReadOnly ); | 1119 | QDataStream stream( at, IO_ReadOnly ); |
1089 | 1120 | ||
1090 | /* we are just interested in thumbmails */ | 1121 | /* we are just interested in thumbmails */ |
1091 | if ( str == "pixmapsHandled(PixmapList)" ) | 1122 | if ( str == "pixmapsHandled(PixmapList)" ) |
1092 | stream >> pixinfos; | 1123 | stream >> pixinfos; |
1093 | 1124 | ||
1094 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { | 1125 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { |
1095 | odebug << "Pixinfos: " << (*it).file << " - " << (*it).width << oendl; | 1126 | odebug << "Pixinfos: " << (*it).file << " - " << (*it).width << oendl; |
1096 | emit sig_Thumbnail((*it).pixmap,(*it).file); | 1127 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); |
1097 | } | 1128 | } |
1098 | } | 1129 | } |
1099 | 1130 | ||
1100 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) | 1131 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) |
1101 | { | 1132 | { |
1102 | PixmapInfo rItem; | 1133 | PixmapInfo rItem; |
1103 | rItem.file = file; | 1134 | rItem.file = file; |
1104 | rItem.width = width; | 1135 | rItem.width = width; |
1105 | rItem.height = height; | 1136 | rItem.height = height; |
1106 | m_inThumbNail.append(rItem); | 1137 | m_inThumbNail.append(rItem); |
1107 | QTimer::singleShot(2, this, SLOT(sendRequest())); | 1138 | QTimer::singleShot(0, this, SLOT(sendRequest())); |
1108 | } | 1139 | } |
1109 | 1140 | ||
1110 | void LauncherThumbReceiver::sendRequest() | 1141 | void LauncherThumbReceiver::sendRequest() |
1111 | { | 1142 | { |
1112 | if (m_inThumbNail.count()>0) { | 1143 | if (m_inThumbNail.count()>0) { |
1113 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); | 1144 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); |
1114 | env << m_inThumbNail; | 1145 | env << m_inThumbNail; |
1146 | m_inThumbNail.clear(); | ||
1115 | } | 1147 | } |
1116 | m_inThumbNail.clear(); | ||
1117 | } | 1148 | } |
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 3cca7f7..0be9a1f 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h | |||
@@ -125,49 +125,49 @@ struct PixmapInfo { | |||
125 | if ( height != r.height ) return false; | 125 | if ( height != r.height ) return false; |
126 | if ( file != r.file ) return false; | 126 | if ( file != r.file ) return false; |
127 | return true; | 127 | return true; |
128 | } | 128 | } |
129 | int width, height; | 129 | int width, height; |
130 | QString file; | 130 | QString file; |
131 | QPixmap pixmap; | 131 | QPixmap pixmap; |
132 | }; | 132 | }; |
133 | 133 | ||
134 | class LauncherThumbReceiver:public QObject | 134 | class LauncherThumbReceiver:public QObject |
135 | { | 135 | { |
136 | Q_OBJECT | 136 | Q_OBJECT |
137 | typedef QValueList<PixmapInfo> PixmapInfos; | 137 | typedef QValueList<PixmapInfo> PixmapInfos; |
138 | public: | 138 | public: |
139 | LauncherThumbReceiver(); | 139 | LauncherThumbReceiver(); |
140 | ~LauncherThumbReceiver(); | 140 | ~LauncherThumbReceiver(); |
141 | void requestThumb(const QString&file,int width,int height); | 141 | void requestThumb(const QString&file,int width,int height); |
142 | 142 | ||
143 | public slots: | 143 | public slots: |
144 | void recieve( const QCString&, const QByteArray& ); | 144 | void recieve( const QCString&, const QByteArray& ); |
145 | protected slots: | 145 | protected slots: |
146 | virtual void sendRequest(); | 146 | virtual void sendRequest(); |
147 | 147 | ||
148 | signals: | 148 | signals: |
149 | void sig_Thumbnail(const QPixmap&,const QString&); | 149 | void sig_Thumbnail(const QPixmap&,const QString&,int); |
150 | 150 | ||
151 | protected: | 151 | protected: |
152 | PixmapInfos m_inThumbNail; | 152 | PixmapInfos m_inThumbNail; |
153 | }; | 153 | }; |
154 | 154 | ||
155 | class LauncherIconView : public QIconView { | 155 | class LauncherIconView : public QIconView { |
156 | Q_OBJECT | 156 | Q_OBJECT |
157 | public: | 157 | public: |
158 | LauncherIconView( QWidget* parent, const char* name=0 ); | 158 | LauncherIconView( QWidget* parent, const char* name=0 ); |
159 | ~LauncherIconView(); | 159 | ~LauncherIconView(); |
160 | QIconViewItem* busyItem() const; | 160 | QIconViewItem* busyItem() const; |
161 | 161 | ||
162 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 162 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
163 | QPixmap busyPixmap() const { return busyPix; } | 163 | QPixmap busyPixmap() const { return busyPix; } |
164 | #endif | 164 | #endif |
165 | void setBigIcons( bool bi ); | 165 | void setBigIcons( bool bi ); |
166 | void updateCategoriesAndMimeTypes(); | 166 | void updateCategoriesAndMimeTypes(); |
167 | void setBusyIndicatorType ( BusyIndicatorType t ); | 167 | void setBusyIndicatorType ( BusyIndicatorType t ); |
168 | void doAutoScroll() | 168 | void doAutoScroll() |
169 | { | 169 | { |
170 | // We don't want rubberbanding (yet) | 170 | // We don't want rubberbanding (yet) |
171 | } | 171 | } |
172 | 172 | ||
173 | void setBusy(bool on); | 173 | void setBusy(bool on); |
@@ -195,59 +195,60 @@ public: | |||
195 | void clear(); | 195 | void clear(); |
196 | void addCatsAndMimes(AppLnk* app); | 196 | void addCatsAndMimes(AppLnk* app); |
197 | 197 | ||
198 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} | 198 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} |
199 | 199 | ||
200 | void setBackgroundPixmap( const QPixmap &pm ) { | 200 | void setBackgroundPixmap( const QPixmap &pm ) { |
201 | bgPixmap = pm; | 201 | bgPixmap = pm; |
202 | } | 202 | } |
203 | 203 | ||
204 | void setBackgroundColor( const QColor &c ) { | 204 | void setBackgroundColor( const QColor &c ) { |
205 | bgColor = c; | 205 | bgColor = c; |
206 | } | 206 | } |
207 | 207 | ||
208 | void drawBackground( QPainter *p, const QRect &r ); | 208 | void drawBackground( QPainter *p, const QRect &r ); |
209 | void setItemTextPos( ItemTextPos pos ); | 209 | void setItemTextPos( ItemTextPos pos ); |
210 | void hideOrShowItems(bool resort); | 210 | void hideOrShowItems(bool resort); |
211 | 211 | ||
212 | void setTypeFilter(const QString& typefilter, bool resort); | 212 | void setTypeFilter(const QString& typefilter, bool resort); |
213 | void setCategoryFilter( int catfilter, bool resort ); | 213 | void setCategoryFilter( int catfilter, bool resort ); |
214 | 214 | ||
215 | enum SortMethod { Name, Date, Type }; | 215 | enum SortMethod { Name, Date, Type }; |
216 | 216 | ||
217 | void setSortMethod( SortMethod m ); | 217 | void setSortMethod( SortMethod m ); |
218 | int compare(const AppLnk* a, const AppLnk* b); | 218 | int compare(const AppLnk* a, const AppLnk* b); |
219 | void requestEyePix(const LauncherItem*which); | ||
219 | 220 | ||
220 | protected: | 221 | protected: |
221 | void timerEvent( QTimerEvent *te ); | 222 | void timerEvent( QTimerEvent *te ); |
222 | void styleChange( QStyle &old ); | 223 | void styleChange( QStyle &old ); |
223 | void calculateGrid( ItemTextPos pos ); | 224 | void calculateGrid( ItemTextPos pos ); |
224 | void focusInEvent( QFocusEvent * ) {} | 225 | void focusInEvent( QFocusEvent * ) {} |
225 | void focusOutEvent( QFocusEvent * ) {} | 226 | void focusOutEvent( QFocusEvent * ) {} |
226 | LauncherItem*findDocItem(const QString&); | 227 | LauncherItem*findDocItem(const QString&); |
227 | void addCheckItem(AppLnk* app); | 228 | void addCheckItem(AppLnk* app); |
228 | void checkCallback(); | 229 | void checkCallback(); |
229 | 230 | ||
230 | protected slots: | 231 | protected slots: |
231 | void setEyePixmap(const QPixmap&,const QString&); | 232 | void setEyePixmap(const QPixmap&,const QString&,int width); |
232 | 233 | ||
233 | private: | 234 | private: |
234 | QList<AppLnk> hidden; | 235 | QList<AppLnk> hidden; |
235 | QDict<void> mimes; | 236 | QDict<void> mimes; |
236 | QDict<void> cats; | 237 | QDict<void> cats; |
237 | SortMethod sortmeth; | 238 | SortMethod sortmeth; |
238 | QRegExp tf; | 239 | QRegExp tf; |
239 | int cf; | 240 | int cf; |
240 | LauncherItem* bsy; | 241 | LauncherItem* bsy; |
241 | int busyTimer; | 242 | int busyTimer; |
242 | bool ike; | 243 | bool ike; |
243 | bool bigIcns; | 244 | bool bigIcns; |
244 | QPixmap bgPixmap; | 245 | QPixmap bgPixmap; |
245 | QColor bgColor; | 246 | QColor bgColor; |
246 | LauncherThumbReceiver*m_EyeCallBack; | 247 | LauncherThumbReceiver*m_EyeCallBack; |
247 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 248 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
248 | QPixmap busyPix; | 249 | QPixmap busyPix; |
249 | #endif | 250 | #endif |
250 | BusyIndicatorType busyType; | 251 | BusyIndicatorType busyType; |
251 | }; | 252 | }; |
252 | 253 | ||
253 | #endif // LAUNCHERVIEW_H | 254 | #endif // LAUNCHERVIEW_H |