author | alwin <alwin> | 2004-11-08 15:22:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-08 15:22:07 (UTC) |
commit | cce0a7a0d315993645870e88591b4afd647480a7 (patch) (unidiff) | |
tree | beb8886020fe12a0f77bbb22bf0da76d4a73a3d5 | |
parent | 40bbaace5492ce6420a2d4a353b24df64c142287 (diff) | |
download | opie-cce0a7a0d315993645870e88591b4afd647480a7.zip opie-cce0a7a0d315993645870e88591b4afd647480a7.tar.gz opie-cce0a7a0d315993645870e88591b4afd647480a7.tar.bz2 |
image preview for documenttab again, I think, for first shot it is
working fine now.
-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 | |||
@@ -72,8 +72,14 @@ static void cleanup_cache() | |||
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; } |
@@ -87,8 +93,10 @@ public: | |||
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; |
@@ -98,34 +106,21 @@ private: | |||
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()); |
@@ -139,8 +134,17 @@ LauncherItem::~LauncherItem() | |||
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()); |
@@ -151,24 +155,22 @@ void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) | |||
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; |
@@ -254,8 +256,9 @@ 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 |
@@ -420,13 +423,14 @@ LauncherItem*LauncherIconView::findDocItem(const QString&fname) | |||
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() |
@@ -434,19 +438,27 @@ void LauncherIconView::checkCallback() | |||
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) |
@@ -632,8 +644,23 @@ LauncherView::~LauncherView() | |||
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 | } |
@@ -1052,8 +1079,12 @@ void LauncherView::flushBgCache() | |||
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; |
@@ -1092,9 +1123,9 @@ void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | |||
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) |
@@ -1103,15 +1134,15 @@ void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height | |||
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 | |||
@@ -145,9 +145,9 @@ public slots: | |||
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 | }; |
@@ -215,8 +215,9 @@ public: | |||
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 ); |
@@ -227,9 +228,9 @@ protected: | |||
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; |