Diffstat (limited to 'core/launcher/launcherview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/launcherview.cpp | 109 |
1 files changed, 79 insertions, 30 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index ff26133..c9efacb 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -43,8 +43,9 @@ using namespace Opie::Core; | |||
43 | //#define ALPHA_FADE_BUSY_ICON | 43 | //#define ALPHA_FADE_BUSY_ICON |
44 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY | 44 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY |
45 | #define BOUNCE_BUSY_ICON | 45 | #define BOUNCE_BUSY_ICON |
46 | 46 | ||
47 | typedef QMap<QString,QPixmap>::Iterator pixiter; | ||
47 | 48 | ||
48 | class BgPixmap | 49 | class BgPixmap |
49 | { | 50 | { |
50 | public: | 51 | public: |
@@ -104,9 +105,8 @@ protected: | |||
104 | private: | 105 | private: |
105 | void paintAnimatedIcon( QPainter *p ); | 106 | void paintAnimatedIcon( QPainter *p ); |
106 | BusyIndicatorType busyType; | 107 | BusyIndicatorType busyType; |
107 | int psize; | 108 | int psize; |
108 | QPixmap m_iPixmap; | ||
109 | bool m_EyeImage; | 109 | bool m_EyeImage; |
110 | iconstate_t m_EyeImageSet; | 110 | iconstate_t m_EyeImageSet; |
111 | }; | 111 | }; |
112 | 112 | ||
@@ -116,15 +116,18 @@ LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | |||
116 | isBigIcon( bigIcon ), | 116 | isBigIcon( bigIcon ), |
117 | iteration(0), | 117 | iteration(0), |
118 | app(applnk), // Takes ownership | 118 | app(applnk), // Takes ownership |
119 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), | 119 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), |
120 | m_iPixmap(), | ||
121 | m_EyeImage(false), | 120 | m_EyeImage(false), |
122 | m_EyeImageSet(BASE_ICON) | 121 | m_EyeImageSet(BASE_ICON) |
123 | { | 122 | { |
124 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { | 123 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { |
125 | m_EyeImage = true; | 124 | m_EyeImage = true; |
126 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); | 125 | QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); |
126 | if (it != LauncherIconView::sm_EyeCache->end()) { | ||
127 | m_EyeImageSet = EYE_ICON; | ||
128 | setPixmap(*it); | ||
129 | } | ||
127 | } | 130 | } |
128 | } | 131 | } |
129 | 132 | ||
130 | LauncherItem::~LauncherItem() | 133 | LauncherItem::~LauncherItem() |
@@ -212,9 +215,15 @@ void LauncherItem::animateIcon() | |||
212 | return; | 215 | return; |
213 | 216 | ||
214 | // Highlight the icon | 217 | // Highlight the icon |
215 | if ( iteration == 0 ) { | 218 | if ( iteration == 0 ) { |
216 | QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); | 219 | QPixmap src; |
220 | pixiter it; | ||
221 | if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) { | ||
222 | src = (*it); | ||
223 | } else { | ||
224 | src = ((isBigIcon ? app->bigPixmap() : app->pixmap())); | ||
225 | } | ||
217 | QImage img = src.convertToImage(); | 226 | QImage img = src.convertToImage(); |
218 | QRgb *rgb; | 227 | QRgb *rgb; |
219 | int count; | 228 | int count; |
220 | if ( img.depth() == 32 ) { | 229 | if ( img.depth() == 32 ) { |
@@ -248,26 +257,36 @@ void LauncherItem::animateIcon() | |||
248 | 257 | ||
249 | void LauncherItem::resetIcon() | 258 | void LauncherItem::resetIcon() |
250 | { | 259 | { |
251 | iteration = 0; | 260 | iteration = 0; |
252 | setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); | 261 | if (isEyeImage()) { |
262 | QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); | ||
263 | if (it != LauncherIconView::sm_EyeCache->end()) { | ||
264 | setPixmap(*it); | ||
265 | return; | ||
266 | } | ||
267 | } | ||
268 | setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); | ||
253 | } | 269 | } |
254 | 270 | ||
255 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) | 271 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) |
256 | { | 272 | { |
257 | if (!isEyeImage()) return; | 273 | if (!isEyeImage()) return; |
258 | m_iPixmap = aIcon; | ||
259 | setPixmap(aIcon); | 274 | setPixmap(aIcon); |
260 | m_EyeImageSet = EYE_ICON; | 275 | m_EyeImageSet = EYE_ICON; |
261 | } | 276 | } |
262 | 277 | ||
263 | //=========================================================================== | 278 | //=========================================================================== |
264 | // Implemantation of LauncherIconview start | 279 | // Implemantation of LauncherIconview start |
265 | //=========================================================================== | 280 | //=========================================================================== |
281 | |||
282 | QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; | ||
283 | |||
266 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) | 284 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) |
267 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) | 285 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) |
268 | { | 286 | { |
269 | m_EyeCallBack = 0; | 287 | m_EyeCallBack = 0; |
288 | if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); | ||
270 | sortmeth = Name; | 289 | sortmeth = Name; |
271 | hidden.setAutoDelete(TRUE); | 290 | hidden.setAutoDelete(TRUE); |
272 | ike = FALSE; | 291 | ike = FALSE; |
273 | calculateGrid( Bottom ); | 292 | calculateGrid( Bottom ); |
@@ -431,8 +450,9 @@ void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,in | |||
431 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 450 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
432 | if (s!=width) return; | 451 | if (s!=width) return; |
433 | LauncherItem*item = findDocItem(aFile); | 452 | LauncherItem*item = findDocItem(aFile); |
434 | if (!item||!item->isEyeImage()) return; | 453 | if (!item||!item->isEyeImage()) return; |
454 | (*sm_EyeCache)[aFile]=aPixmap; | ||
435 | item->setEyePixmap(aPixmap); | 455 | item->setEyePixmap(aPixmap); |
436 | } | 456 | } |
437 | 457 | ||
438 | void LauncherIconView::checkCallback() | 458 | void LauncherIconView::checkCallback() |
@@ -440,10 +460,10 @@ void LauncherIconView::checkCallback() | |||
440 | if (!m_EyeCallBack) { | 460 | if (!m_EyeCallBack) { |
441 | m_EyeCallBack = new LauncherThumbReceiver(); | 461 | m_EyeCallBack = new LauncherThumbReceiver(); |
442 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | 462 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), |
443 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | 463 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); |
444 | m_eyeTimer.changeInterval(600000); | ||
445 | } | 464 | } |
465 | m_eyeTimer.changeInterval(600000); | ||
446 | } | 466 | } |
447 | 467 | ||
448 | void LauncherIconView::addCheckItem(AppLnk* app) | 468 | void LauncherIconView::addCheckItem(AppLnk* app) |
449 | { | 469 | { |
@@ -465,29 +485,16 @@ void LauncherIconView::requestEyePix(const LauncherItem*item) | |||
465 | 485 | ||
466 | void LauncherIconView::stopEyeTimer() | 486 | void LauncherIconView::stopEyeTimer() |
467 | { | 487 | { |
468 | if (m_EyeCallBack) { | 488 | if (m_EyeCallBack) { |
489 | disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | ||
490 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | ||
469 | delete m_EyeCallBack; | 491 | delete m_EyeCallBack; |
470 | m_EyeCallBack=0; | 492 | m_EyeCallBack=0; |
471 | } | 493 | } |
472 | m_eyeTimer.stop(); | 494 | m_eyeTimer.stop(); |
473 | } | 495 | } |
474 | 496 | ||
475 | void LauncherIconView::addItem(AppLnk* app, bool resort) | ||
476 | { | ||
477 | addCatsAndMimes(app); | ||
478 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | ||
479 | && (cf == 0 || app->categories().contains(cf) | ||
480 | || cf == -1 && app->categories().count() == 0 ) ) { | ||
481 | addCheckItem(app); | ||
482 | } else { | ||
483 | hidden.append(app); | ||
484 | } | ||
485 | if ( resort ){ | ||
486 | sort(); | ||
487 | } | ||
488 | } | ||
489 | |||
490 | void LauncherIconView::updateCategoriesAndMimeTypes() | 497 | void LauncherIconView::updateCategoriesAndMimeTypes() |
491 | { | 498 | { |
492 | mimes.clear(); | 499 | mimes.clear(); |
493 | cats.clear(); | 500 | cats.clear(); |
@@ -527,9 +534,9 @@ void LauncherIconView::hideOrShowItems(bool resort) | |||
527 | sort(); | 534 | sort(); |
528 | viewport()->setUpdatesEnabled( TRUE ); | 535 | viewport()->setUpdatesEnabled( TRUE ); |
529 | } | 536 | } |
530 | 537 | ||
531 | bool LauncherIconView::removeLink(const QString& linkfile) | 538 | bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache) |
532 | { | 539 | { |
533 | LauncherItem* item = (LauncherItem*)firstItem(); | 540 | LauncherItem* item = (LauncherItem*)firstItem(); |
534 | AppLnk* l; | 541 | AppLnk* l; |
535 | bool did = FALSE; | 542 | bool did = FALSE; |
@@ -538,8 +545,9 @@ bool LauncherIconView::removeLink(const QString& linkfile) | |||
538 | l = item->appLnk(); | 545 | l = item->appLnk(); |
539 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); | 546 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); |
540 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && | 547 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && |
541 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { | 548 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { |
549 | if (removeCache) sm_EyeCache->remove(l->file()); | ||
542 | delete item; | 550 | delete item; |
543 | did = TRUE; | 551 | did = TRUE; |
544 | } | 552 | } |
545 | item = nextItem; | 553 | item = nextItem; |
@@ -556,8 +564,40 @@ bool LauncherIconView::removeLink(const QString& linkfile) | |||
556 | } | 564 | } |
557 | return did; | 565 | return did; |
558 | } | 566 | } |
559 | 567 | ||
568 | void LauncherIconView::addItem(AppLnk* app, bool resort) | ||
569 | { | ||
570 | addCatsAndMimes(app); | ||
571 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | ||
572 | && (cf == 0 || app->categories().contains(cf) | ||
573 | || cf == -1 && app->categories().count() == 0 ) ) { | ||
574 | addCheckItem(app); | ||
575 | } else { | ||
576 | hidden.append(app); | ||
577 | } | ||
578 | if ( resort ){ | ||
579 | sort(); | ||
580 | } | ||
581 | } | ||
582 | |||
583 | void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink) | ||
584 | { | ||
585 | QString oldfile = old.file(); | ||
586 | QString newfile = nlink->file(); | ||
587 | |||
588 | if (newfile != oldfile) { | ||
589 | QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile); | ||
590 | if (it != sm_EyeCache->end()) { | ||
591 | (*sm_EyeCache)[newfile]=(*it); | ||
592 | } | ||
593 | removeLink(old.linkFile()); | ||
594 | } else { | ||
595 | removeLink(old.linkFile(),false); | ||
596 | } | ||
597 | addItem(nlink,false); | ||
598 | } | ||
599 | |||
560 | void LauncherIconView::timerEvent( QTimerEvent *te ) | 600 | void LauncherIconView::timerEvent( QTimerEvent *te ) |
561 | { | 601 | { |
562 | if ( te->timerId() == busyTimer ) { | 602 | if ( te->timerId() == busyTimer ) { |
563 | if ( bsy ) | 603 | if ( bsy ) |
@@ -568,8 +608,9 @@ void LauncherIconView::timerEvent( QTimerEvent *te ) | |||
568 | } | 608 | } |
569 | 609 | ||
570 | void LauncherIconView::setBigIcons( bool bi ) | 610 | void LauncherIconView::setBigIcons( bool bi ) |
571 | { | 611 | { |
612 | sm_EyeCache->clear(); | ||
572 | bigIcns = bi; | 613 | bigIcns = bi; |
573 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 614 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
574 | busyPix.resize(0,0); | 615 | busyPix.resize(0,0); |
575 | #endif | 616 | #endif |
@@ -755,10 +796,13 @@ void LauncherView::updateTools() | |||
755 | typemb->setCurrentItem(typemb->count()-1); | 796 | typemb->setCurrentItem(typemb->count()-1); |
756 | } | 797 | } |
757 | 798 | ||
758 | int pcat = catmb ? catmb->currentCategory() : -2; | 799 | int pcat = catmb ? catmb->currentCategory() : -2; |
759 | if ( !catmb ) | 800 | if ( !catmb ) { |
760 | catmb = new CategorySelect(tools); | 801 | catmb = new CategorySelect(tools); |
802 | } else if (pcat!=-2) { | ||
803 | |||
804 | } | ||
761 | Categories cats( 0 ); | 805 | Categories cats( 0 ); |
762 | cats.load( categoryFileName() ); | 806 | cats.load( categoryFileName() ); |
763 | QArray<int> vl( 0 ); | 807 | QArray<int> vl( 0 ); |
764 | catmb->setCategories( vl, "Document View", // No tr | 808 | catmb->setCategories( vl, "Document View", // No tr |
@@ -1019,9 +1063,9 @@ void LauncherView::itemClicked( int btn, QIconViewItem *item ) | |||
1019 | // Make sure it's the item we execute that gets highlighted | 1063 | // Make sure it's the item we execute that gets highlighted |
1020 | icons->setCurrentItem( item ); | 1064 | icons->setCurrentItem( item ); |
1021 | emit clicked( appLnk ); | 1065 | emit clicked( appLnk ); |
1022 | } | 1066 | } |
1023 | item->setSelected(FALSE); | 1067 | item->setSelected(FALSE); |
1024 | } | 1068 | } |
1025 | } | 1069 | } |
1026 | 1070 | ||
1027 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) | 1071 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) |
@@ -1046,8 +1090,18 @@ bool LauncherView::removeLink(const QString& linkfile) | |||
1046 | { | 1090 | { |
1047 | return icons->removeLink(linkfile); | 1091 | return icons->removeLink(linkfile); |
1048 | } | 1092 | } |
1049 | 1093 | ||
1094 | void LauncherView::addItem(AppLnk* app, bool resort) | ||
1095 | { | ||
1096 | icons->addItem(app,resort); | ||
1097 | } | ||
1098 | |||
1099 | void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) | ||
1100 | { | ||
1101 | icons->changeItem(old,nlink); | ||
1102 | } | ||
1103 | |||
1050 | void LauncherView::setSortEnabled( bool v ) | 1104 | void LauncherView::setSortEnabled( bool v ) |
1051 | { | 1105 | { |
1052 | icons->setSorting( v ); | 1106 | icons->setSorting( v ); |
1053 | if ( v ) | 1107 | if ( v ) |
@@ -1063,13 +1117,8 @@ void LauncherView::sort() | |||
1063 | { | 1117 | { |
1064 | icons->sort(); | 1118 | icons->sort(); |
1065 | } | 1119 | } |
1066 | 1120 | ||
1067 | void LauncherView::addItem(AppLnk* app, bool resort) | ||
1068 | { | ||
1069 | icons->addItem(app,resort); | ||
1070 | } | ||
1071 | |||
1072 | void LauncherView::paletteChange( const QPalette &p ) | 1121 | void LauncherView::paletteChange( const QPalette &p ) |
1073 | { | 1122 | { |
1074 | icons->unsetPalette(); | 1123 | icons->unsetPalette(); |
1075 | QVBox::paletteChange( p ); | 1124 | QVBox::paletteChange( p ); |