author | alwin <alwin> | 2005-03-12 02:13:52 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-12 02:13:52 (UTC) |
commit | cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42 (patch) (unidiff) | |
tree | d4ed9b082abe2aa645fbd58b86d65f5ce9c48348 | |
parent | 84af289057291a49a52a60b390bc5320c02b5a55 (diff) | |
download | opie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.zip opie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.tar.gz opie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.tar.bz2 |
And I'm wondering why opie sometimes is that slow. Hopefully reduced
the calls to opie-eye for images in documenttab when changing layout
and so on.
-rw-r--r-- | core/launcher/launcherview.cpp | 34 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 4 |
2 files changed, 31 insertions, 7 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index a4c7561..d960908 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -50,159 +50,161 @@ typedef QMap<QString,QPixmap>::Iterator pixiter; | |||
50 | class BgPixmap | 50 | class BgPixmap |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} | 53 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} |
54 | QPixmap pm; | 54 | QPixmap pm; |
55 | int ref; | 55 | int ref; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | 58 | ||
59 | static QMap<QString,BgPixmap*> *bgCache = 0; | 59 | static QMap<QString,BgPixmap*> *bgCache = 0; |
60 | 60 | ||
61 | static void cleanup_cache() | 61 | static void cleanup_cache() |
62 | { | 62 | { |
63 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 63 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
64 | while ( it != bgCache->end() ) { | 64 | while ( it != bgCache->end() ) { |
65 | QMap<QString,BgPixmap*>::Iterator curr = it; | 65 | QMap<QString,BgPixmap*>::Iterator curr = it; |
66 | ++it; | 66 | ++it; |
67 | delete (*curr); | 67 | delete (*curr); |
68 | bgCache->remove( curr ); | 68 | bgCache->remove( curr ); |
69 | } | 69 | } |
70 | delete bgCache; | 70 | delete bgCache; |
71 | bgCache = 0; | 71 | bgCache = 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | class LauncherItem : public QIconViewItem | 75 | class LauncherItem : public QIconViewItem |
76 | { | 76 | { |
77 | public: | 77 | public: |
78 | enum iconstate_t { | 78 | enum iconstate_t { |
79 | BASE_ICON, | 79 | BASE_ICON, |
80 | WAITING_ICON, | 80 | WAITING_ICON, |
81 | EYE_ICON | 81 | EYE_ICON |
82 | }; | 82 | }; |
83 | 83 | ||
84 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); | 84 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); |
85 | ~LauncherItem(); | 85 | ~LauncherItem(); |
86 | 86 | ||
87 | AppLnk *appLnk() const { return app; } | 87 | AppLnk *appLnk() const { return app; } |
88 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } | 88 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } |
89 | 89 | ||
90 | void animateIcon(); | 90 | void animateIcon(); |
91 | void resetIcon(); | 91 | void resetIcon(); |
92 | bool isEyeImage()const{return m_EyeImage;} | 92 | bool isEyeImage()const{return m_EyeImage;} |
93 | 93 | ||
94 | virtual int compare ( QIconViewItem * i ) const; | 94 | virtual int compare ( QIconViewItem * i ) const; |
95 | void paintItem( QPainter *p, const QColorGroup &cg ); | 95 | void paintItem( QPainter *p, const QColorGroup &cg ); |
96 | 96 | ||
97 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 97 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
98 | void setEyePixmap(const QPixmap&aIcon); | 98 | void setEyePixmap(const QPixmap&aIcon); |
99 | virtual QPixmap*pixmap()const; | 99 | virtual QPixmap*pixmap()const; |
100 | 100 | ||
101 | protected: | 101 | protected: |
102 | bool isBigIcon; | 102 | bool isBigIcon; |
103 | int iteration; | 103 | int iteration; |
104 | AppLnk* app; | 104 | AppLnk* app; |
105 | 105 | ||
106 | private: | 106 | private: |
107 | void paintAnimatedIcon( QPainter *p ); | 107 | void paintAnimatedIcon( QPainter *p ); |
108 | BusyIndicatorType busyType; | 108 | BusyIndicatorType busyType; |
109 | int psize; | 109 | int psize; |
110 | bool m_EyeImage; | 110 | bool m_EyeImage; |
111 | iconstate_t m_EyeImageSet; | 111 | iconstate_t m_EyeImageSet; |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static bool s_IgnoreNextPix = false; | ||
115 | |||
114 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | 116 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) |
115 | : QIconViewItem( parent, applnk->name(), | 117 | : QIconViewItem( parent, applnk->name(), |
116 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), | 118 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), |
117 | isBigIcon( bigIcon ), | 119 | isBigIcon( bigIcon ), |
118 | iteration(0), | 120 | iteration(0), |
119 | app(applnk), // Takes ownership | 121 | app(applnk), // Takes ownership |
120 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), | 122 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), |
121 | m_EyeImage(false), | 123 | m_EyeImage(false), |
122 | m_EyeImageSet(BASE_ICON) | 124 | m_EyeImageSet(BASE_ICON) |
123 | { | 125 | { |
124 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { | 126 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { |
125 | m_EyeImage = true; | 127 | m_EyeImage = true; |
126 | QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); | 128 | QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); |
127 | if (it != LauncherIconView::sm_EyeCache->end()) { | 129 | if (it != LauncherIconView::sm_EyeCache->end()) { |
128 | m_EyeImageSet = EYE_ICON; | 130 | m_EyeImageSet = EYE_ICON; |
129 | setPixmap(*it); | 131 | setPixmap(*it); |
130 | } | 132 | } |
131 | } | 133 | } |
132 | } | 134 | } |
133 | 135 | ||
134 | LauncherItem::~LauncherItem() | 136 | LauncherItem::~LauncherItem() |
135 | { | 137 | { |
136 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 138 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
137 | if ( liv->busyItem() == this ) | 139 | if ( liv->busyItem() == this ) |
138 | liv->setBusy(FALSE); | 140 | liv->setBusy(FALSE); |
139 | delete app; | 141 | delete app; |
140 | } | 142 | } |
141 | 143 | ||
142 | QPixmap*LauncherItem::pixmap()const | 144 | QPixmap*LauncherItem::pixmap()const |
143 | { | 145 | { |
144 | if (m_EyeImage && m_EyeImageSet == BASE_ICON) { | 146 | if (m_EyeImage && m_EyeImageSet == BASE_ICON && s_IgnoreNextPix==false) { |
145 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 147 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
146 | liv->requestEyePix(this); | 148 | liv->requestEyePix(this); |
147 | } | 149 | } |
148 | return QIconViewItem::pixmap(); | 150 | return QIconViewItem::pixmap(); |
149 | } | 151 | } |
150 | 152 | ||
151 | int LauncherItem::compare ( QIconViewItem * i ) const | 153 | int LauncherItem::compare ( QIconViewItem * i ) const |
152 | { | 154 | { |
153 | LauncherIconView* view = (LauncherIconView*)iconView(); | 155 | LauncherIconView* view = (LauncherIconView*)iconView(); |
154 | return view->compare(app,((LauncherItem *)i)->appLnk()); | 156 | return view->compare(app,((LauncherItem *)i)->appLnk()); |
155 | } | 157 | } |
156 | 158 | ||
157 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) | 159 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) |
158 | { | 160 | { |
159 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 161 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
160 | QBrush oldBrush( liv->itemTextBackground() ); | 162 | QBrush oldBrush( liv->itemTextBackground() ); |
161 | QColorGroup mycg( cg ); | 163 | QColorGroup mycg( cg ); |
162 | if ( liv->currentItem() == this ) { | 164 | if ( liv->currentItem() == this ) { |
163 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); | 165 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); |
164 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); | 166 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); |
165 | } | 167 | } |
166 | 168 | ||
167 | QIconViewItem::paintItem(p,mycg); | 169 | QIconViewItem::paintItem(p,mycg); |
168 | 170 | ||
169 | // Paint animation overlay | 171 | // Paint animation overlay |
170 | if ( liv->busyItem() == this ) | 172 | if ( liv->busyItem() == this ) |
171 | paintAnimatedIcon(p); | 173 | paintAnimatedIcon(p); |
172 | 174 | ||
173 | if ( liv->currentItem() == this ) | 175 | if ( liv->currentItem() == this ) |
174 | liv->setItemTextBackground( oldBrush ); | 176 | liv->setItemTextBackground( oldBrush ); |
175 | } | 177 | } |
176 | 178 | ||
177 | void LauncherItem::paintAnimatedIcon( QPainter *p ) | 179 | void LauncherItem::paintAnimatedIcon( QPainter *p ) |
178 | { | 180 | { |
179 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 181 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
180 | int pic = iteration % 16; | 182 | int pic = iteration % 16; |
181 | int w = pixmap()->width(), h = pixmap()->height(); | 183 | int w = pixmap()->width(), h = pixmap()->height(); |
182 | QPixmap dblBuf( w, h + 4 ); | 184 | QPixmap dblBuf( w, h + 4 ); |
183 | QPainter p2( &dblBuf ); | 185 | QPainter p2( &dblBuf ); |
184 | int x1, y1; | 186 | int x1, y1; |
185 | if ( liv->itemTextPos() == QIconView::Bottom ) { | 187 | if ( liv->itemTextPos() == QIconView::Bottom ) { |
186 | x1 = x() + (width() - w) / 2 - liv->contentsX(); | 188 | x1 = x() + (width() - w) / 2 - liv->contentsX(); |
187 | y1 = y() - liv->contentsY(); | 189 | y1 = y() - liv->contentsY(); |
188 | } else { | 190 | } else { |
189 | x1 = x() - liv->contentsX(); | 191 | x1 = x() - liv->contentsX(); |
190 | y1 = y() + (height() - h) / 2 - liv->contentsY(); | 192 | y1 = y() + (height() - h) / 2 - liv->contentsY(); |
191 | } | 193 | } |
192 | y1 -= 2; | 194 | y1 -= 2; |
193 | p2.translate(-x1,-y1); | 195 | p2.translate(-x1,-y1); |
194 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); | 196 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); |
195 | int bounceY = 2; | 197 | int bounceY = 2; |
196 | #ifdef BOUNCE_BUSY_ICON | 198 | #ifdef BOUNCE_BUSY_ICON |
197 | if ( busyType == BIT_Animated ) { | 199 | if ( busyType == BIT_Animated ) { |
198 | bounceY = 4 - ((iteration+2)%8); | 200 | bounceY = 4 - ((iteration+2)%8); |
199 | bounceY = bounceY < 0 ? -bounceY : bounceY; | 201 | bounceY = bounceY < 0 ? -bounceY : bounceY; |
200 | } | 202 | } |
201 | #endif | 203 | #endif |
202 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); | 204 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); |
203 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 205 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
204 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); | 206 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); |
205 | #else | 207 | #else |
206 | Q_UNUSED( pic ) | 208 | Q_UNUSED( pic ) |
207 | #endif | 209 | #endif |
208 | p->drawPixmap( x1, y1, dblBuf ); | 210 | p->drawPixmap( x1, y1, dblBuf ); |
@@ -233,158 +235,172 @@ void LauncherItem::animateIcon() | |||
233 | } else { | 235 | } else { |
234 | rgb = img.colorTable(); | 236 | rgb = img.colorTable(); |
235 | count = img.numColors(); | 237 | count = img.numColors(); |
236 | } | 238 | } |
237 | for ( int r = 0; r < count; r++, rgb++ ) { | 239 | for ( int r = 0; r < count; r++, rgb++ ) { |
238 | #if defined(BRIGHTEN_BUSY_ICON) | 240 | #if defined(BRIGHTEN_BUSY_ICON) |
239 | QColor c(*rgb); | 241 | QColor c(*rgb); |
240 | int h, s, v; | 242 | int h, s, v; |
241 | c.hsv(&h,&s,&v); | 243 | c.hsv(&h,&s,&v); |
242 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); | 244 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); |
243 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); | 245 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); |
244 | #elif defined(ALPHA_FADE_BUSY_ICON) | 246 | #elif defined(ALPHA_FADE_BUSY_ICON) |
245 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); | 247 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); |
246 | #endif | 248 | #endif |
247 | } | 249 | } |
248 | src.convertFromImage( img ); | 250 | src.convertFromImage( img ); |
249 | setPixmap( src ); | 251 | setPixmap( src ); |
250 | } | 252 | } |
251 | 253 | ||
252 | iteration++; | 254 | iteration++; |
253 | 255 | ||
254 | // Paint animation overlay | 256 | // Paint animation overlay |
255 | QPainter p( liv->viewport() ); | 257 | QPainter p( liv->viewport() ); |
256 | paintAnimatedIcon( &p ); | 258 | paintAnimatedIcon( &p ); |
257 | } | 259 | } |
258 | 260 | ||
259 | void LauncherItem::resetIcon() | 261 | void LauncherItem::resetIcon() |
260 | { | 262 | { |
261 | iteration = 0; | 263 | iteration = 0; |
262 | if (isEyeImage()) { | 264 | if (isEyeImage()) { |
263 | QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); | 265 | QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); |
264 | if (it != LauncherIconView::sm_EyeCache->end()) { | 266 | if (it != LauncherIconView::sm_EyeCache->end()) { |
265 | setPixmap(*it); | 267 | setPixmap(*it); |
266 | return; | 268 | return; |
267 | } | 269 | } |
268 | } | 270 | } |
269 | setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); | 271 | setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); |
270 | } | 272 | } |
271 | 273 | ||
272 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) | 274 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) |
273 | { | 275 | { |
274 | if (!isEyeImage()) return; | 276 | if (!isEyeImage()) return; |
275 | setPixmap(aIcon); | 277 | setPixmap(aIcon); |
276 | m_EyeImageSet = EYE_ICON; | 278 | m_EyeImageSet = EYE_ICON; |
277 | } | 279 | } |
278 | 280 | ||
279 | //=========================================================================== | 281 | //=========================================================================== |
280 | // Implemantation of LauncherIconview start | 282 | // Implemantation of LauncherIconview start |
281 | //=========================================================================== | 283 | //=========================================================================== |
282 | 284 | ||
283 | QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; | 285 | QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; |
284 | 286 | ||
285 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) | 287 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) |
286 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0) | 288 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0) |
287 | { | 289 | { |
288 | m_EyeCallBack = 0; | 290 | m_EyeCallBack = 0; |
289 | if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); | 291 | if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); |
290 | sortmeth = Name; | 292 | sortmeth = Name; |
291 | hidden.setAutoDelete(TRUE); | 293 | hidden.setAutoDelete(TRUE); |
292 | ike = FALSE; | 294 | ike = FALSE; |
293 | calculateGrid( Bottom ); | 295 | calculateGrid( Bottom ); |
294 | connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); | 296 | connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); |
295 | Config config( "Launcher" ); | 297 | Config config( "Launcher" ); |
296 | config.setGroup( "GUI" ); | 298 | config.setGroup( "GUI" ); |
297 | setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) ); | 299 | setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) ); |
298 | } | 300 | } |
299 | 301 | ||
300 | LauncherIconView::~LauncherIconView() | 302 | LauncherIconView::~LauncherIconView() |
301 | { | 303 | { |
302 | odebug << "LauncherIconView::~LauncherIconView()" << oendl; | 304 | odebug << "LauncherIconView::~LauncherIconView()" << oendl; |
303 | #if 0 // debuggery | 305 | #if 0 // debuggery |
304 | QListIterator<AppLnk> it(hidden); | 306 | QListIterator<AppLnk> it(hidden); |
305 | AppLnk* l; | 307 | AppLnk* l; |
306 | while ((l=it.current())) { | 308 | while ((l=it.current())) { |
307 | ++it; | 309 | ++it; |
308 | //odebug << "" << l << ": hidden (should remove)" << oendl; | 310 | //odebug << "" << l << ": hidden (should remove)" << oendl; |
309 | } | 311 | } |
310 | #endif | 312 | #endif |
311 | } | 313 | } |
312 | 314 | ||
315 | void LauncherIconView::unsetPalette() | ||
316 | { | ||
317 | s_IgnoreNextPix = true; | ||
318 | QIconView::unsetPalette(); | ||
319 | s_IgnoreNextPix = false; | ||
320 | } | ||
321 | |||
322 | void LauncherIconView::setPalette(const QPalette & palette) | ||
323 | { | ||
324 | s_IgnoreNextPix = true; | ||
325 | QIconView::setPalette(palette); | ||
326 | s_IgnoreNextPix = false; | ||
327 | } | ||
328 | |||
313 | void LauncherIconView::setStaticBackgroundPicture( bool enable ) | 329 | void LauncherIconView::setStaticBackgroundPicture( bool enable ) |
314 | { | 330 | { |
315 | staticBackground = enable; | 331 | staticBackground = enable; |
316 | if ( staticBackground ) | 332 | if ( staticBackground ) |
317 | { | 333 | { |
318 | setStaticBackground( true ); | 334 | setStaticBackground( true ); |
319 | verticalScrollBar()->setTracking( false ); | 335 | verticalScrollBar()->setTracking( false ); |
320 | } | 336 | } |
321 | else | 337 | else |
322 | { | 338 | { |
323 | setStaticBackground( false ); | 339 | setStaticBackground( false ); |
324 | verticalScrollBar()->setTracking( true ); | 340 | verticalScrollBar()->setTracking( true ); |
325 | } | 341 | } |
326 | } | 342 | } |
327 | 343 | ||
328 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) | 344 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) |
329 | { | 345 | { |
330 | switch (sortmeth) { | 346 | switch (sortmeth) { |
331 | case Name: | 347 | case Name: |
332 | return a->name().lower().compare(b->name().lower()); | 348 | return a->name().lower().compare(b->name().lower()); |
333 | case Date: { | 349 | case Date: { |
334 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | 350 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); |
335 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | 351 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); |
336 | return fa.lastModified().secsTo(fb.lastModified()); | 352 | return fa.lastModified().secsTo(fb.lastModified()); |
337 | } | 353 | } |
338 | case Type: | 354 | case Type: |
339 | return a->type().compare(b->type()); | 355 | return a->type().compare(b->type()); |
340 | } | 356 | } |
341 | return 0; | 357 | return 0; |
342 | } | 358 | } |
343 | 359 | ||
344 | void LauncherIconView::setSortMethod( SortMethod m ) | 360 | void LauncherIconView::setSortMethod( SortMethod m ) |
345 | { | 361 | { |
346 | if ( sortmeth != m ) { | 362 | if ( sortmeth != m ) { |
347 | sortmeth = m; | 363 | sortmeth = m; |
348 | sort(); | 364 | sort(); |
349 | } | 365 | } |
350 | } | 366 | } |
351 | 367 | ||
352 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) | 368 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) |
353 | { | 369 | { |
354 | if ( catfilter == -2 ) | 370 | if ( catfilter == -2 ) |
355 | cf = 0; | 371 | cf = 0; |
356 | else | 372 | else |
357 | cf = catfilter; | 373 | cf = catfilter; |
358 | hideOrShowItems(resort); | 374 | hideOrShowItems(resort); |
359 | } | 375 | } |
360 | 376 | ||
361 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) | 377 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) |
362 | { | 378 | { |
363 | tf = QRegExp(typefilter,FALSE,TRUE); | 379 | tf = QRegExp(typefilter,FALSE,TRUE); |
364 | hideOrShowItems(resort); | 380 | hideOrShowItems(resort); |
365 | } | 381 | } |
366 | 382 | ||
367 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) | 383 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) |
368 | { | 384 | { |
369 | calculateGrid( pos ); | 385 | calculateGrid( pos ); |
370 | QIconView::setItemTextPos( pos ); | 386 | QIconView::setItemTextPos( pos ); |
371 | } | 387 | } |
372 | 388 | ||
373 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) | 389 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) |
374 | { | 390 | { |
375 | if ( bgPixmap.isNull() ) | 391 | if ( bgPixmap.isNull() ) |
376 | { | 392 | { |
377 | p->fillRect( r, bgColor ); | 393 | p->fillRect( r, bgColor ); |
378 | } | 394 | } |
379 | else | 395 | else |
380 | { | 396 | { |
381 | if ( staticBackground ) | 397 | if ( staticBackground ) |
382 | { | 398 | { |
383 | p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) ); | 399 | p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) ); |
384 | } | 400 | } |
385 | else | 401 | else |
386 | { | 402 | { |
387 | p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(), | 403 | p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(), |
388 | (r.y() + contentsY()) % bgPixmap.height() ) ); | 404 | (r.y() + contentsY()) % bgPixmap.height() ) ); |
389 | } | 405 | } |
390 | } | 406 | } |
@@ -425,130 +441,130 @@ void LauncherIconView::setBusy(bool on) | |||
425 | 441 | ||
426 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; | 442 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; |
427 | 443 | ||
428 | if ( bsy != c ) { | 444 | if ( bsy != c ) { |
429 | LauncherItem *oldBusy = bsy; | 445 | LauncherItem *oldBusy = bsy; |
430 | bsy = c; | 446 | bsy = c; |
431 | if ( oldBusy ) { | 447 | if ( oldBusy ) { |
432 | oldBusy->resetIcon(); | 448 | oldBusy->resetIcon(); |
433 | } | 449 | } |
434 | if ( bsy ) { | 450 | if ( bsy ) { |
435 | bsy->setBusyIndicatorType( busyType ) ; | 451 | bsy->setBusyIndicatorType( busyType ) ; |
436 | bsy->animateIcon(); | 452 | bsy->animateIcon(); |
437 | } | 453 | } |
438 | } | 454 | } |
439 | } | 455 | } |
440 | 456 | ||
441 | void LauncherIconView::clear() | 457 | void LauncherIconView::clear() |
442 | { | 458 | { |
443 | mimes.clear(); | 459 | mimes.clear(); |
444 | cats.clear(); | 460 | cats.clear(); |
445 | QIconView::clear(); | 461 | QIconView::clear(); |
446 | hidden.clear(); | 462 | hidden.clear(); |
447 | } | 463 | } |
448 | 464 | ||
449 | QStringList LauncherIconView::mimeTypes() const | 465 | QStringList LauncherIconView::mimeTypes() const |
450 | { | 466 | { |
451 | QStringList r; | 467 | QStringList r; |
452 | QDictIterator<void> it(mimes); | 468 | QDictIterator<void> it(mimes); |
453 | while (it.current()) { | 469 | while (it.current()) { |
454 | r.append(it.currentKey()); | 470 | r.append(it.currentKey()); |
455 | ++it; | 471 | ++it; |
456 | } | 472 | } |
457 | r.sort(); | 473 | r.sort(); |
458 | return r; | 474 | return r; |
459 | } | 475 | } |
460 | 476 | ||
461 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) | 477 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) |
462 | { | 478 | { |
463 | LauncherItem* item = (LauncherItem*)firstItem(); | 479 | LauncherItem* item = (LauncherItem*)firstItem(); |
464 | while (item) { | 480 | while (item) { |
465 | if (item->appLnk()->file()==fname) { | 481 | if (item->appLnk()->file()==fname) { |
466 | break; | 482 | break; |
467 | } | 483 | } |
468 | item = (LauncherItem*)item->nextItem(); | 484 | item = (LauncherItem*)item->nextItem(); |
469 | } | 485 | } |
470 | return item; | 486 | return item; |
471 | } | 487 | } |
472 | 488 | ||
473 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) | 489 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) |
474 | { | 490 | { |
475 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 491 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
476 | if (s!=width) return; | 492 | if (s!=width) return; |
477 | LauncherItem*item = findDocItem(aFile); | 493 | LauncherItem*item = findDocItem(aFile); |
478 | if (!item||!item->isEyeImage()) return; | 494 | if (!item||!item->isEyeImage()) return; |
479 | (*sm_EyeCache)[aFile]=aPixmap; | 495 | (*sm_EyeCache)[aFile]=aPixmap; |
480 | item->setEyePixmap(aPixmap); | 496 | item->setEyePixmap(aPixmap); |
481 | } | 497 | } |
482 | 498 | ||
483 | void LauncherIconView::checkCallback() | 499 | void LauncherIconView::checkCallback() |
484 | { | 500 | { |
485 | if (!m_EyeCallBack) { | 501 | if (!m_EyeCallBack) { |
486 | m_EyeCallBack = new LauncherThumbReceiver(); | 502 | m_EyeCallBack = new LauncherThumbReceiver(); |
487 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | 503 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), |
488 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | 504 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); |
505 | m_eyeTimer.changeInterval(600000); | ||
489 | } | 506 | } |
490 | m_eyeTimer.changeInterval(600000); | ||
491 | } | 507 | } |
492 | 508 | ||
493 | void LauncherIconView::addCheckItem(AppLnk* app) | 509 | void LauncherIconView::addCheckItem(AppLnk* app) |
494 | { | 510 | { |
495 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); | 511 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); |
496 | if (item->isEyeImage()) { | 512 | if (item->isEyeImage()) { |
497 | checkCallback(); | 513 | checkCallback(); |
498 | } | 514 | } |
499 | } | 515 | } |
500 | 516 | ||
501 | void LauncherIconView::requestEyePix(const LauncherItem*item) | 517 | void LauncherIconView::requestEyePix(const LauncherItem*item) |
502 | { | 518 | { |
503 | if (!item) return; | 519 | if (!item) return; |
504 | if (item->isEyeImage()) { | 520 | if (item->isEyeImage()) { |
505 | checkCallback(); | 521 | checkCallback(); |
506 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 522 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
507 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); | 523 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); |
508 | } | 524 | } |
509 | } | 525 | } |
510 | 526 | ||
511 | void LauncherIconView::stopEyeTimer() | 527 | void LauncherIconView::stopEyeTimer() |
512 | { | 528 | { |
513 | if (m_EyeCallBack) { | 529 | if (m_EyeCallBack) { |
514 | disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | 530 | disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), |
515 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | 531 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); |
516 | delete m_EyeCallBack; | 532 | delete m_EyeCallBack; |
517 | m_EyeCallBack=0; | 533 | m_EyeCallBack=0; |
518 | } | 534 | } |
519 | m_eyeTimer.stop(); | 535 | m_eyeTimer.stop(); |
520 | } | 536 | } |
521 | 537 | ||
522 | void LauncherIconView::updateCategoriesAndMimeTypes() | 538 | void LauncherIconView::updateCategoriesAndMimeTypes() |
523 | { | 539 | { |
524 | mimes.clear(); | 540 | mimes.clear(); |
525 | cats.clear(); | 541 | cats.clear(); |
526 | LauncherItem* item = (LauncherItem*)firstItem(); | 542 | LauncherItem* item = (LauncherItem*)firstItem(); |
527 | while (item) { | 543 | while (item) { |
528 | addCatsAndMimes(item->appLnk()); | 544 | addCatsAndMimes(item->appLnk()); |
529 | item = (LauncherItem*)item->nextItem(); | 545 | item = (LauncherItem*)item->nextItem(); |
530 | } | 546 | } |
531 | QListIterator<AppLnk> it(hidden); | 547 | QListIterator<AppLnk> it(hidden); |
532 | AppLnk* l; | 548 | AppLnk* l; |
533 | while ((l=it.current())) { | 549 | while ((l=it.current())) { |
534 | addCatsAndMimes(l); | 550 | addCatsAndMimes(l); |
535 | ++it; | 551 | ++it; |
536 | } | 552 | } |
537 | } | 553 | } |
538 | 554 | ||
539 | void LauncherIconView::hideOrShowItems(bool resort) | 555 | void LauncherIconView::hideOrShowItems(bool resort) |
540 | { | 556 | { |
541 | viewport()->setUpdatesEnabled( FALSE ); | 557 | viewport()->setUpdatesEnabled( FALSE ); |
542 | hidden.setAutoDelete(FALSE); | 558 | hidden.setAutoDelete(FALSE); |
543 | QList<AppLnk> links=hidden; | 559 | QList<AppLnk> links=hidden; |
544 | hidden.clear(); | 560 | hidden.clear(); |
545 | hidden.setAutoDelete(TRUE); | 561 | hidden.setAutoDelete(TRUE); |
546 | LauncherItem* item = (LauncherItem*)firstItem(); | 562 | LauncherItem* item = (LauncherItem*)firstItem(); |
547 | while (item) { | 563 | while (item) { |
548 | links.append(item->takeAppLnk()); | 564 | links.append(item->takeAppLnk()); |
549 | item = (LauncherItem*)item->nextItem(); | 565 | item = (LauncherItem*)item->nextItem(); |
550 | } | 566 | } |
551 | clear(); | 567 | clear(); |
552 | QListIterator<AppLnk> it(links); | 568 | QListIterator<AppLnk> it(links); |
553 | AppLnk* l; | 569 | AppLnk* l; |
554 | while ((l=it.current())) { | 570 | while ((l=it.current())) { |
@@ -1147,114 +1163,118 @@ void LauncherView::setSortEnabled( bool v ) | |||
1147 | 1163 | ||
1148 | void LauncherView::setUpdatesEnabled( bool u ) | 1164 | void LauncherView::setUpdatesEnabled( bool u ) |
1149 | { | 1165 | { |
1150 | icons->setUpdatesEnabled( u ); | 1166 | icons->setUpdatesEnabled( u ); |
1151 | } | 1167 | } |
1152 | 1168 | ||
1153 | void LauncherView::sort() | 1169 | void LauncherView::sort() |
1154 | { | 1170 | { |
1155 | icons->sort(); | 1171 | icons->sort(); |
1156 | } | 1172 | } |
1157 | 1173 | ||
1158 | void LauncherView::paletteChange( const QPalette &p ) | 1174 | void LauncherView::paletteChange( const QPalette &p ) |
1159 | { | 1175 | { |
1160 | icons->unsetPalette(); | 1176 | icons->unsetPalette(); |
1161 | QVBox::paletteChange( p ); | 1177 | QVBox::paletteChange( p ); |
1162 | if ( bgType == Ruled ) | 1178 | if ( bgType == Ruled ) |
1163 | setBackgroundType( Ruled, QString::null ); | 1179 | setBackgroundType( Ruled, QString::null ); |
1164 | QColorGroup cg = icons->colorGroup(); | 1180 | QColorGroup cg = icons->colorGroup(); |
1165 | cg.setColor( QColorGroup::Text, textCol ); | 1181 | cg.setColor( QColorGroup::Text, textCol ); |
1166 | icons->setPalette( QPalette(cg,cg,cg) ); | 1182 | icons->setPalette( QPalette(cg,cg,cg) ); |
1167 | } | 1183 | } |
1168 | 1184 | ||
1169 | void LauncherView::fontChanged(const QFont&) | 1185 | void LauncherView::fontChanged(const QFont&) |
1170 | { | 1186 | { |
1171 | odebug << "LauncherView::fontChanged()" << oendl; | 1187 | odebug << "LauncherView::fontChanged()" << oendl; |
1172 | icons->hideOrShowItems( FALSE ); | 1188 | icons->hideOrShowItems( FALSE ); |
1173 | } | 1189 | } |
1174 | 1190 | ||
1175 | void LauncherView::relayout(void) | 1191 | void LauncherView::relayout(void) |
1176 | { | 1192 | { |
1177 | icons->hideOrShowItems(FALSE); | 1193 | icons->hideOrShowItems(FALSE); |
1178 | } | 1194 | } |
1179 | 1195 | ||
1180 | void LauncherView::flushBgCache() | 1196 | void LauncherView::flushBgCache() |
1181 | { | 1197 | { |
1182 | if ( !bgCache ) | 1198 | if ( !bgCache ) |
1183 | return; | 1199 | return; |
1184 | // remove unreferenced backgrounds. | 1200 | // remove unreferenced backgrounds. |
1185 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 1201 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
1186 | while ( it != bgCache->end() ) { | 1202 | while ( it != bgCache->end() ) { |
1187 | QMap<QString,BgPixmap*>::Iterator curr = it; | 1203 | QMap<QString,BgPixmap*>::Iterator curr = it; |
1188 | ++it; | 1204 | ++it; |
1189 | if ( (*curr)->ref == 0 ) { | 1205 | if ( (*curr)->ref == 0 ) { |
1190 | delete (*curr); | 1206 | delete (*curr); |
1191 | bgCache->remove( curr ); | 1207 | bgCache->remove( curr ); |
1192 | } | 1208 | } |
1193 | } | 1209 | } |
1194 | } | 1210 | } |
1195 | 1211 | ||
1196 | /* | 1212 | /* |
1197 | * Launcherthumbnail handling for image files | 1213 | * Launcherthumbnail handling for image files |
1198 | */ | 1214 | */ |
1199 | 1215 | ||
1200 | /* special image handling - based on opie eye */ | 1216 | /* special image handling - based on opie eye */ |
1201 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 1217 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { |
1202 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; | 1218 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; |
1203 | return s; | 1219 | return s; |
1204 | } | 1220 | } |
1205 | 1221 | ||
1206 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 1222 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { |
1207 | return s << inf.file << inf.width << inf.height; | 1223 | return s << inf.file << inf.width << inf.height; |
1208 | } | 1224 | } |
1209 | 1225 | ||
1210 | LauncherThumbReceiver::LauncherThumbReceiver() | 1226 | LauncherThumbReceiver::LauncherThumbReceiver() |
1211 | :QObject() | 1227 | :QObject(),requestTimer(this) |
1212 | { | 1228 | { |
1229 | |||
1230 | connect(&requestTimer,SIGNAL(timeout()),SLOT(sendRequest())); | ||
1213 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); | 1231 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); |
1214 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), | 1232 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), |
1215 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); | 1233 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); |
1216 | 1234 | ||
1217 | { | 1235 | { |
1218 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 1236 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
1219 | } | 1237 | } |
1220 | } | 1238 | } |
1221 | 1239 | ||
1222 | LauncherThumbReceiver::~LauncherThumbReceiver() | 1240 | LauncherThumbReceiver::~LauncherThumbReceiver() |
1223 | { | 1241 | { |
1224 | { | 1242 | { |
1225 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 1243 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
1226 | } | 1244 | } |
1227 | } | 1245 | } |
1228 | 1246 | ||
1229 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | 1247 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) |
1230 | { | 1248 | { |
1231 | PixmapInfos pixinfos; | 1249 | PixmapInfos pixinfos; |
1232 | QDataStream stream( at, IO_ReadOnly ); | 1250 | QDataStream stream( at, IO_ReadOnly ); |
1233 | 1251 | ||
1234 | /* we are just interested in thumbmails */ | 1252 | /* we are just interested in thumbmails */ |
1235 | if ( str == "pixmapsHandled(PixmapList)" ) | 1253 | if ( str == "pixmapsHandled(PixmapList)" ) |
1236 | stream >> pixinfos; | 1254 | stream >> pixinfos; |
1237 | 1255 | ||
1238 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { | 1256 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { |
1239 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); | 1257 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); |
1240 | } | 1258 | } |
1241 | } | 1259 | } |
1242 | 1260 | ||
1243 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) | 1261 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) |
1244 | { | 1262 | { |
1245 | PixmapInfo rItem; | 1263 | PixmapInfo rItem; |
1246 | rItem.file = file; | 1264 | rItem.file = file; |
1247 | rItem.width = width; | 1265 | rItem.width = width; |
1248 | rItem.height = height; | 1266 | rItem.height = height; |
1249 | m_inThumbNail.append(rItem); | 1267 | m_inThumbNail.append(rItem); |
1250 | QTimer::singleShot(2, this, SLOT(sendRequest())); | 1268 | if (!requestTimer.isActive()) { |
1269 | requestTimer.start(100,true); | ||
1270 | } | ||
1251 | } | 1271 | } |
1252 | 1272 | ||
1253 | void LauncherThumbReceiver::sendRequest() | 1273 | void LauncherThumbReceiver::sendRequest() |
1254 | { | 1274 | { |
1255 | if (m_inThumbNail.count()>0) { | 1275 | if (m_inThumbNail.count()>0) { |
1256 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); | 1276 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); |
1257 | env << m_inThumbNail; | 1277 | env << m_inThumbNail; |
1258 | m_inThumbNail.clear(); | 1278 | m_inThumbNail.clear(); |
1259 | } | 1279 | } |
1260 | } | 1280 | } |
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 6a2d197..792c6d1 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h | |||
@@ -92,164 +92,168 @@ signals: | |||
92 | protected slots: | 92 | protected slots: |
93 | void selectionChanged(); | 93 | void selectionChanged(); |
94 | void returnPressed( QIconViewItem *item ); | 94 | void returnPressed( QIconViewItem *item ); |
95 | void itemClicked( int, QIconViewItem * ); | 95 | void itemClicked( int, QIconViewItem * ); |
96 | void itemPressed( int, QIconViewItem * ); | 96 | void itemPressed( int, QIconViewItem * ); |
97 | void sortBy(int); | 97 | void sortBy(int); |
98 | void showType(int); | 98 | void showType(int); |
99 | void showCategory( int ); | 99 | void showCategory( int ); |
100 | void resizeEvent(QResizeEvent *); | 100 | void resizeEvent(QResizeEvent *); |
101 | void flushBgCache(); | 101 | void flushBgCache(); |
102 | 102 | ||
103 | protected: | 103 | protected: |
104 | void paletteChange( const QPalette & ); | 104 | void paletteChange( const QPalette & ); |
105 | 105 | ||
106 | void fontChanged(const QFont &); | 106 | void fontChanged(const QFont &); |
107 | 107 | ||
108 | private: | 108 | private: |
109 | static bool bsy; | 109 | static bool bsy; |
110 | QWidget* tools; | 110 | QWidget* tools; |
111 | LauncherIconView* icons; | 111 | LauncherIconView* icons; |
112 | QComboBox *typemb; | 112 | QComboBox *typemb; |
113 | QStringList typelist; | 113 | QStringList typelist; |
114 | CategorySelect *catmb; | 114 | CategorySelect *catmb; |
115 | ViewMode vmode; | 115 | ViewMode vmode; |
116 | BackgroundType bgType; | 116 | BackgroundType bgType; |
117 | QString bgName; | 117 | QString bgName; |
118 | QColor textCol; | 118 | QColor textCol; |
119 | 119 | ||
120 | QImage loadBackgroundImage(QString &fname); | 120 | QImage loadBackgroundImage(QString &fname); |
121 | 121 | ||
122 | }; | 122 | }; |
123 | 123 | ||
124 | /* from opie-eye */ | 124 | /* from opie-eye */ |
125 | struct PixmapInfo { | 125 | struct PixmapInfo { |
126 | PixmapInfo() : width( -1 ), height( -1 ) {} | 126 | PixmapInfo() : width( -1 ), height( -1 ) {} |
127 | bool operator==( const PixmapInfo& r ) { | 127 | bool operator==( const PixmapInfo& r ) { |
128 | if ( width != r.width ) return false; | 128 | if ( width != r.width ) return false; |
129 | if ( height != r.height ) return false; | 129 | if ( height != r.height ) return false; |
130 | if ( file != r.file ) return false; | 130 | if ( file != r.file ) return false; |
131 | return true; | 131 | return true; |
132 | } | 132 | } |
133 | int width, height; | 133 | int width, height; |
134 | QString file; | 134 | QString file; |
135 | QPixmap pixmap; | 135 | QPixmap pixmap; |
136 | }; | 136 | }; |
137 | 137 | ||
138 | class LauncherThumbReceiver:public QObject | 138 | class LauncherThumbReceiver:public QObject |
139 | { | 139 | { |
140 | Q_OBJECT | 140 | Q_OBJECT |
141 | typedef QValueList<PixmapInfo> PixmapInfos; | 141 | typedef QValueList<PixmapInfo> PixmapInfos; |
142 | public: | 142 | public: |
143 | LauncherThumbReceiver(); | 143 | LauncherThumbReceiver(); |
144 | ~LauncherThumbReceiver(); | 144 | ~LauncherThumbReceiver(); |
145 | void requestThumb(const QString&file,int width,int height); | 145 | void requestThumb(const QString&file,int width,int height); |
146 | 146 | ||
147 | public slots: | 147 | public slots: |
148 | void recieve( const QCString&, const QByteArray& ); | 148 | void recieve( const QCString&, const QByteArray& ); |
149 | protected slots: | 149 | protected slots: |
150 | virtual void sendRequest(); | 150 | virtual void sendRequest(); |
151 | 151 | ||
152 | signals: | 152 | signals: |
153 | void sig_Thumbnail(const QPixmap&,const QString&,int); | 153 | void sig_Thumbnail(const QPixmap&,const QString&,int); |
154 | 154 | ||
155 | protected: | 155 | protected: |
156 | QTimer requestTimer; | ||
156 | PixmapInfos m_inThumbNail; | 157 | PixmapInfos m_inThumbNail; |
157 | }; | 158 | }; |
158 | 159 | ||
159 | class LauncherIconView : public QIconView { | 160 | class LauncherIconView : public QIconView { |
160 | Q_OBJECT | 161 | Q_OBJECT |
161 | public: | 162 | public: |
162 | LauncherIconView( QWidget* parent, const char* name=0 ); | 163 | LauncherIconView( QWidget* parent, const char* name=0 ); |
163 | ~LauncherIconView(); | 164 | ~LauncherIconView(); |
164 | QIconViewItem* busyItem() const; | 165 | QIconViewItem* busyItem() const; |
165 | 166 | ||
166 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 167 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
167 | QPixmap busyPixmap() const { return busyPix; } | 168 | QPixmap busyPixmap() const { return busyPix; } |
168 | #endif | 169 | #endif |
169 | void setBigIcons( bool bi ); | 170 | void setBigIcons( bool bi ); |
170 | void updateCategoriesAndMimeTypes(); | 171 | void updateCategoriesAndMimeTypes(); |
171 | void setBusyIndicatorType ( BusyIndicatorType t ); | 172 | void setBusyIndicatorType ( BusyIndicatorType t ); |
172 | void setStaticBackgroundPicture( bool enable ); | 173 | void setStaticBackgroundPicture( bool enable ); |
173 | void doAutoScroll() | 174 | void doAutoScroll() |
174 | { | 175 | { |
175 | // We don't want rubberbanding (yet) | 176 | // We don't want rubberbanding (yet) |
176 | } | 177 | } |
177 | 178 | ||
178 | void setBusy(bool on); | 179 | void setBusy(bool on); |
179 | bool inKeyEvent() const { return ike; } | 180 | bool inKeyEvent() const { return ike; } |
180 | 181 | ||
181 | void addItem(AppLnk* app, bool resort=TRUE); | 182 | void addItem(AppLnk* app, bool resort=TRUE); |
182 | bool removeLink(const QString& linkfile,bool removeCache = true); | 183 | bool removeLink(const QString& linkfile,bool removeCache = true); |
183 | void changeItem(const AppLnk&old,AppLnk*nlink); | 184 | void changeItem(const AppLnk&old,AppLnk*nlink); |
184 | 185 | ||
185 | QStringList mimeTypes() const; | 186 | QStringList mimeTypes() const; |
186 | QStringList categories() const; | 187 | QStringList categories() const; |
187 | void clear(); | 188 | void clear(); |
188 | void addCatsAndMimes(AppLnk* app); | 189 | void addCatsAndMimes(AppLnk* app); |
189 | 190 | ||
190 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} | 191 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} |
191 | 192 | ||
192 | void setBackgroundPixmap( const QPixmap &pm ) { | 193 | void setBackgroundPixmap( const QPixmap &pm ) { |
193 | bgPixmap = pm; | 194 | bgPixmap = pm; |
194 | } | 195 | } |
195 | 196 | ||
196 | void setBackgroundColor( const QColor &c ) { | 197 | void setBackgroundColor( const QColor &c ) { |
197 | bgColor = c; | 198 | bgColor = c; |
198 | } | 199 | } |
199 | 200 | ||
200 | void setColNumber( int ); | 201 | void setColNumber( int ); |
201 | 202 | ||
202 | void drawBackground( QPainter *p, const QRect &r ); | 203 | void drawBackground( QPainter *p, const QRect &r ); |
203 | void setItemTextPos( ItemTextPos pos ); | 204 | void setItemTextPos( ItemTextPos pos ); |
204 | void hideOrShowItems(bool resort); | 205 | void hideOrShowItems(bool resort); |
205 | 206 | ||
206 | void setTypeFilter(const QString& typefilter, bool resort); | 207 | void setTypeFilter(const QString& typefilter, bool resort); |
207 | void setCategoryFilter( int catfilter, bool resort ); | 208 | void setCategoryFilter( int catfilter, bool resort ); |
208 | 209 | ||
209 | enum SortMethod { Name, Date, Type }; | 210 | enum SortMethod { Name, Date, Type }; |
210 | 211 | ||
211 | void setSortMethod( SortMethod m ); | 212 | void setSortMethod( SortMethod m ); |
212 | int compare(const AppLnk* a, const AppLnk* b); | 213 | int compare(const AppLnk* a, const AppLnk* b); |
213 | void requestEyePix(const LauncherItem*which); | 214 | void requestEyePix(const LauncherItem*which); |
214 | 215 | ||
215 | static QMap<QString,QPixmap>* sm_EyeCache; | 216 | static QMap<QString,QPixmap>* sm_EyeCache; |
216 | 217 | ||
218 | virtual void setPalette(const QPalette & palette); | ||
219 | virtual void unsetPalette(); | ||
220 | |||
217 | protected: | 221 | protected: |
218 | virtual void timerEvent( QTimerEvent *te ); | 222 | virtual void timerEvent( QTimerEvent *te ); |
219 | void styleChange( QStyle &old ); | 223 | void styleChange( QStyle &old ); |
220 | void calculateGrid( ItemTextPos pos ); | 224 | void calculateGrid( ItemTextPos pos ); |
221 | void focusInEvent( QFocusEvent * ) {} | 225 | void focusInEvent( QFocusEvent * ) {} |
222 | void focusOutEvent( QFocusEvent * ) {} | 226 | void focusOutEvent( QFocusEvent * ) {} |
223 | LauncherItem*findDocItem(const QString&); | 227 | LauncherItem*findDocItem(const QString&); |
224 | void addCheckItem(AppLnk* app); | 228 | void addCheckItem(AppLnk* app); |
225 | void checkCallback(); | 229 | void checkCallback(); |
226 | virtual void keyPressEvent(QKeyEvent* e); | 230 | virtual void keyPressEvent(QKeyEvent* e); |
227 | 231 | ||
228 | protected slots: | 232 | protected slots: |
229 | void setEyePixmap(const QPixmap&,const QString&,int width); | 233 | void setEyePixmap(const QPixmap&,const QString&,int width); |
230 | void stopEyeTimer(); | 234 | void stopEyeTimer(); |
231 | 235 | ||
232 | private: | 236 | private: |
233 | QList<AppLnk> hidden; | 237 | QList<AppLnk> hidden; |
234 | QDict<void> mimes; | 238 | QDict<void> mimes; |
235 | QDict<void> cats; | 239 | QDict<void> cats; |
236 | SortMethod sortmeth; | 240 | SortMethod sortmeth; |
237 | QRegExp tf; | 241 | QRegExp tf; |
238 | int cf; | 242 | int cf; |
239 | LauncherItem* bsy; | 243 | LauncherItem* bsy; |
240 | int busyTimer; | 244 | int busyTimer; |
241 | bool ike; | 245 | bool ike; |
242 | bool bigIcns; | 246 | bool bigIcns; |
243 | QPixmap bgPixmap; | 247 | QPixmap bgPixmap; |
244 | QColor bgColor; | 248 | QColor bgColor; |
245 | LauncherThumbReceiver*m_EyeCallBack; | 249 | LauncherThumbReceiver*m_EyeCallBack; |
246 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 250 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
247 | QPixmap busyPix; | 251 | QPixmap busyPix; |
248 | #endif | 252 | #endif |
249 | BusyIndicatorType busyType; | 253 | BusyIndicatorType busyType; |
250 | QTimer m_eyeTimer; | 254 | QTimer m_eyeTimer; |
251 | int numColumns; | 255 | int numColumns; |
252 | bool staticBackground; | 256 | bool staticBackground; |
253 | }; | 257 | }; |
254 | 258 | ||
255 | #endif // LAUNCHERVIEW_H | 259 | #endif // LAUNCHERVIEW_H |