summaryrefslogtreecommitdiff
authoralwin <alwin>2004-11-08 02:27:03 (UTC)
committer alwin <alwin>2004-11-08 02:27:03 (UTC)
commit18875a0d90d0425c066e6fa2cda81a6140fe8606 (patch) (unidiff)
tree778844c7dd2acb9f387a3228b3d3bd9df647c1a7
parent9218d2bf841e1f999475c86ba602dc1cd7e338f6 (diff)
downloadopie-18875a0d90d0425c066e6fa2cda81a6140fe8606.zip
opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.tar.gz
opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.tar.bz2
first try getting small imagethumbs in document-tab.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp866
-rw-r--r--core/launcher/launcherview.h40
2 files changed, 517 insertions, 389 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index cd9c14b..1317bda 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -26,12 +26,14 @@
26#include <qtopia/private/categories.h> 26#include <qtopia/private/categories.h>
27#include <qtopia/categoryselect.h> 27#include <qtopia/categoryselect.h>
28#include <qtopia/mimetype.h> 28#include <qtopia/mimetype.h>
29#include <qtopia/resource.h> 29#include <qtopia/resource.h>
30using namespace Opie::Core; 30using namespace Opie::Core;
31 31
32#include <qpe/qcopenvelope_qws.h>
33
32/* QT */ 34/* QT */
33#include <qtimer.h> 35#include <qtimer.h>
34#include <qfileinfo.h> 36#include <qfileinfo.h>
35#include <qiconview.h> 37#include <qiconview.h>
36#include <qobjectlist.h> 38#include <qobjectlist.h>
37 39
@@ -55,16 +57,16 @@ public:
55static QMap<QString,BgPixmap*> *bgCache = 0; 57static QMap<QString,BgPixmap*> *bgCache = 0;
56 58
57static void cleanup_cache() 59static void cleanup_cache()
58{ 60{
59 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 61 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
60 while ( it != bgCache->end() ) { 62 while ( it != bgCache->end() ) {
61 QMap<QString,BgPixmap*>::Iterator curr = it; 63 QMap<QString,BgPixmap*>::Iterator curr = it;
62 ++it; 64 ++it;
63 delete (*curr); 65 delete (*curr);
64 bgCache->remove( curr ); 66 bgCache->remove( curr );
65 } 67 }
66 delete bgCache; 68 delete bgCache;
67 bgCache = 0; 69 bgCache = 0;
68} 70}
69 71
70 72
@@ -76,266 +78,273 @@ public:
76 78
77 AppLnk *appLnk() const { return app; } 79 AppLnk *appLnk() const { return app; }
78 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } 80 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
79 81
80 void animateIcon(); 82 void animateIcon();
81 void resetIcon(); 83 void resetIcon();
84 bool isEyeImage()const{return m_EyeImage;}
82 85
83 virtual int compare ( QIconViewItem * i ) const; 86 virtual int compare ( QIconViewItem * i ) const;
84 void paintItem( QPainter *p, const QColorGroup &cg ); 87 void paintItem( QPainter *p, const QColorGroup &cg );
85 88
86 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 89 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
90 void setEyePixmap(const QPixmap&aIcon);
87protected: 91protected:
88 bool isBigIcon; 92 bool isBigIcon;
89 int iteration; 93 int iteration;
90 AppLnk* app; 94 AppLnk* app;
95
91private: 96private:
92 void paintAnimatedIcon( QPainter *p ); 97 void paintAnimatedIcon( QPainter *p );
93 BusyIndicatorType busyType; 98 BusyIndicatorType busyType;
99 int psize;
100 QPixmap m_iPixmap;
101 bool m_EyeImage;
102 LauncherThumbReceiver*m_EyeCallback;
94}; 103};
95 104
96 105
97class LauncherIconView : public QIconView { 106class LauncherIconView : public QIconView {
98public: 107public:
99 LauncherIconView( QWidget* parent, const char* name=0 ) : 108 LauncherIconView( QWidget* parent, const char* name=0 ) :
100 QIconView(parent,name), 109 QIconView(parent,name),
101 tf(""), 110 tf(""),
102 cf(0), 111 cf(0),
103 bsy(0), 112 bsy(0),
104 busyTimer(0), 113 busyTimer(0),
105 bigIcns(TRUE), 114 bigIcns(TRUE),
106 bgColor(white) 115 bgColor(white)
107 { 116 {
108 sortmeth = Name; 117 sortmeth = Name;
109 hidden.setAutoDelete(TRUE); 118 hidden.setAutoDelete(TRUE);
110 ike = FALSE; 119 ike = FALSE;
111 calculateGrid( Bottom ); 120 calculateGrid( Bottom );
112 } 121 }
113 122
114 ~LauncherIconView() 123 ~LauncherIconView()
115 { 124 {
116#if 0 // debuggery 125#if 0 // debuggery
117 QListIterator<AppLnk> it(hidden); 126 QListIterator<AppLnk> it(hidden);
118 AppLnk* l; 127 AppLnk* l;
119 while ((l=it.current())) { 128 while ((l=it.current())) {
120 ++it; 129 ++it;
121 //odebug << "" << l << ": hidden (should remove)" << oendl; 130 //odebug << "" << l << ": hidden (should remove)" << oendl;
122 } 131 }
123#endif 132#endif
124 } 133 }
125 134
126 QIconViewItem* busyItem() const { return bsy; } 135 QIconViewItem* busyItem() const { return bsy; }
127#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 136#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
128 QPixmap busyPixmap() const { return busyPix; } 137 QPixmap busyPixmap() const { return busyPix; }
129#endif 138#endif
130 void setBigIcons( bool bi ) { 139 void setBigIcons( bool bi ) {
131 bigIcns = bi; 140 bigIcns = bi;
132#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 141#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
133 busyPix.resize(0,0); 142 busyPix.resize(0,0);
134#endif 143#endif
135 } 144 }
136 145
137 void updateCategoriesAndMimeTypes(); 146 void updateCategoriesAndMimeTypes();
138 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 147 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
139 void doAutoScroll() 148 void doAutoScroll()
140 { 149 {
141 // We don't want rubberbanding (yet) 150 // We don't want rubberbanding (yet)
142 } 151 }
143 152
144 void setBusy(bool on) 153 void setBusy(bool on)
145 { 154 {
146#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 155#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
147 if ( busyPix.isNull() ) { 156 if ( busyPix.isNull() ) {
148 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 157 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
149 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); 158 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
150 } 159 }
151#endif 160#endif
152 161
153 if ( on ) { 162 if ( on ) {
154 busyTimer = startTimer( 100 ); 163 busyTimer = startTimer( 100 );
155 } else { 164 } else {
156 if ( busyTimer ) { 165 if ( busyTimer ) {
157 killTimer( busyTimer ); 166 killTimer( busyTimer );
158 busyTimer = 0; 167 busyTimer = 0;
159 } 168 }
160 } 169 }
161 170
162 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; 171 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
163 172
164 if ( bsy != c ) { 173 if ( bsy != c ) {
165 LauncherItem *oldBusy = bsy; 174 LauncherItem *oldBusy = bsy;
166 bsy = c; 175 bsy = c;
167 if ( oldBusy ) { 176 if ( oldBusy ) {
168 oldBusy->resetIcon(); 177 oldBusy->resetIcon();
169 } 178 }
170 if ( bsy ) { 179 if ( bsy ) {
171 bsy->setBusyIndicatorType( busyType ) ; 180 bsy->setBusyIndicatorType( busyType ) ;
172 bsy->animateIcon(); 181 bsy->animateIcon();
173 } 182 }
174 } 183 }
175 } 184 }
176 185
177 bool inKeyEvent() const { return ike; } 186 bool inKeyEvent() const { return ike; }
178 void keyPressEvent(QKeyEvent* e) 187 void keyPressEvent(QKeyEvent* e)
179 { 188 {
180 ike = TRUE; 189 ike = TRUE;
181 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { 190 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) {
182 if ( (e->state() & ShiftButton) ) 191 if ( (e->state() & ShiftButton) )
183 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); 192 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() );
184 else 193 else
185 returnPressed(currentItem()); 194 returnPressed(currentItem());
186 } 195 }
187 196
188 QIconView::keyPressEvent(e); 197 QIconView::keyPressEvent(e);
189 ike = FALSE; 198 ike = FALSE;
190 } 199 }
191 200
192 void addItem(AppLnk* app, bool resort=TRUE); 201 void addItem(AppLnk* app, bool resort=TRUE);
193 bool removeLink(const QString& linkfile); 202 bool removeLink(const QString& linkfile);
194 203
195 QStringList mimeTypes() const; 204 QStringList mimeTypes() const;
196 QStringList categories() const; 205 QStringList categories() const;
197 206
198 void clear() 207 void clear()
199 { 208 {
200 mimes.clear(); 209 mimes.clear();
201 cats.clear(); 210 cats.clear();
202 QIconView::clear(); 211 QIconView::clear();
203 hidden.clear(); 212 hidden.clear();
204 } 213 }
205 214
206 void addCatsAndMimes(AppLnk* app) 215 void addCatsAndMimes(AppLnk* app)
207 { 216 {
208 // QStringList c = app->categories(); 217 // QStringList c = app->categories();
209 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 218 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
210 // cats.replace(*cit,(void*)1); 219 // cats.replace(*cit,(void*)1);
211 // } 220 // }
212 QString maj=app->type(); 221 QString maj=app->type();
213 int sl=maj.find('/'); 222 int sl=maj.find('/');
214 if (sl>=0) { 223 if (sl>=0) {
215 QString k; 224 QString k;
216 k = maj.left(12) == "application/" ? maj : maj.left(sl); 225 k = maj.left(12) == "application/" ? maj : maj.left(sl);
217 mimes.replace(k,(void*)1); 226 mimes.replace(k,(void*)1);
218 } 227 }
219 } 228 }
220 229
221 void setBackgroundOrigin( QWidget::BackgroundOrigin ) { 230 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {
222 } 231 }
223 232
224 void setBackgroundPixmap( const QPixmap &pm ) { 233 void setBackgroundPixmap( const QPixmap &pm ) {
225 bgPixmap = pm; 234 bgPixmap = pm;
226 } 235 }
227 236
228 void setBackgroundColor( const QColor &c ) { 237 void setBackgroundColor( const QColor &c ) {
229 bgColor = c; 238 bgColor = c;
230 } 239 }
231 240
232 void drawBackground( QPainter *p, const QRect &r ) 241 void drawBackground( QPainter *p, const QRect &r )
233 { 242 {
234 if ( !bgPixmap.isNull() ) { 243 if ( !bgPixmap.isNull() ) {
235 p->drawTiledPixmap( r, bgPixmap, 244 p->drawTiledPixmap( r, bgPixmap,
236 QPoint( (r.x() + contentsX()) % bgPixmap.width(), 245 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
237 (r.y() + contentsY()) % bgPixmap.height() ) ); 246 (r.y() + contentsY()) % bgPixmap.height() ) );
238 } else { 247 } else {
239 p->fillRect( r, bgColor ); 248 p->fillRect( r, bgColor );
240 } 249 }
241 } 250 }
242 251
243 void setItemTextPos( ItemTextPos pos ) 252 void setItemTextPos( ItemTextPos pos )
244 { 253 {
245 calculateGrid( pos ); 254 calculateGrid( pos );
246 QIconView::setItemTextPos( pos ); 255 QIconView::setItemTextPos( pos );
247 } 256 }
248 257
249 void hideOrShowItems(bool resort); 258 void hideOrShowItems(bool resort);
250 259
251 void setTypeFilter(const QString& typefilter, bool resort) 260 void setTypeFilter(const QString& typefilter, bool resort)
252 { 261 {
253 tf = QRegExp(typefilter,FALSE,TRUE); 262 tf = QRegExp(typefilter,FALSE,TRUE);
254 hideOrShowItems(resort); 263 hideOrShowItems(resort);
255 } 264 }
256 265
257 void setCategoryFilter( int catfilter, bool resort ) 266 void setCategoryFilter( int catfilter, bool resort )
258 { 267 {
259 Categories cat; 268 Categories cat;
260 cat.load( categoryFileName() ); 269 cat.load( categoryFileName() );
261 QString str; 270 QString str;
262 if ( catfilter == -2 ) 271 if ( catfilter == -2 )
263 cf = 0; 272 cf = 0;
264 else 273 else
265 cf = catfilter; 274 cf = catfilter;
266 hideOrShowItems(resort); 275 hideOrShowItems(resort);
267 } 276 }
268 277
269 enum SortMethod { Name, Date, Type }; 278 enum SortMethod { Name, Date, Type };
270 279
271 void setSortMethod( SortMethod m ) 280 void setSortMethod( SortMethod m )
272 { 281 {
273 if ( sortmeth != m ) { 282 if ( sortmeth != m ) {
274 sortmeth = m; 283 sortmeth = m;
275 sort(); 284 sort();
276 } 285 }
277 } 286 }
278 287
279 int compare(const AppLnk* a, const AppLnk* b) 288 int compare(const AppLnk* a, const AppLnk* b)
280 { 289 {
281 switch (sortmeth) { 290 switch (sortmeth) {
282 case Name: 291 case Name:
283 return a->name().lower().compare(b->name().lower()); 292 return a->name().lower().compare(b->name().lower());
284 case Date: { 293 case Date: {
285 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 294 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
286 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 295 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
287 return fa.lastModified().secsTo(fb.lastModified()); 296 return fa.lastModified().secsTo(fb.lastModified());
288 } 297 }
289 case Type: 298 case Type:
290 return a->type().compare(b->type()); 299 return a->type().compare(b->type());
291 } 300 }
292 return 0; 301 return 0;
293 } 302 }
294 303
295protected: 304protected:
296 305
297 void timerEvent( QTimerEvent *te ) 306 void timerEvent( QTimerEvent *te )
298 { 307 {
299 if ( te->timerId() == busyTimer ) { 308 if ( te->timerId() == busyTimer ) {
300 if ( bsy ) 309 if ( bsy )
301 bsy->animateIcon(); 310 bsy->animateIcon();
302 } else { 311 } else {
303 QIconView::timerEvent( te ); 312 QIconView::timerEvent( te );
304 } 313 }
305 } 314 }
306 315
307 void styleChange( QStyle &old ) 316 void styleChange( QStyle &old )
308 { 317 {
309 QIconView::styleChange( old ); 318 QIconView::styleChange( old );
310 calculateGrid( itemTextPos() ); 319 calculateGrid( itemTextPos() );
311 } 320 }
312 321
313 void calculateGrid( ItemTextPos pos ) 322 void calculateGrid( ItemTextPos pos )
314 { 323 {
315 int dw = QApplication::desktop()->width(); 324 int dw = QApplication::desktop()->width();
316 int viewerWidth = dw-style().scrollBarExtent().width(); 325 int viewerWidth = dw-style().scrollBarExtent().width();
317 if ( pos == Bottom ) { 326 if ( pos == Bottom ) {
318 int cols = 3; 327 int cols = 3;
319 if ( viewerWidth <= 200 ) 328 if ( viewerWidth <= 200 )
320 cols = 2; 329 cols = 2;
321 else if ( viewerWidth >= 400 ) 330 else if ( viewerWidth >= 400 )
322 cols = viewerWidth/96; 331 cols = viewerWidth/96;
323 setSpacing( 4 ); 332 setSpacing( 4 );
324 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 333 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
325 setGridY( fontMetrics().height()*2+24 ); 334 setGridY( fontMetrics().height()*2+24 );
326 } else { 335 } else {
327 int cols = 2; 336 int cols = 2;
328 if ( viewerWidth < 150 ) 337 if ( viewerWidth < 150 )
329 cols = 1; 338 cols = 1;
330 else if ( viewerWidth >= 400 ) 339 else if ( viewerWidth >= 400 )
331 cols = viewerWidth/150; 340 cols = viewerWidth/150;
332 setSpacing( 2 ); 341 setSpacing( 2 );
333 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 342 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
334 setGridY( fontMetrics().height()+2 ); 343 setGridY( fontMetrics().height()+2 );
335 } 344 }
336 } 345 }
337 346
338 void focusInEvent( QFocusEvent * ) {} 347 void focusInEvent( QFocusEvent * ) {}
339 void focusOutEvent( QFocusEvent * ) {} 348 void focusOutEvent( QFocusEvent * ) {}
340 349
341private: 350private:
@@ -364,32 +373,42 @@ void LauncherView::setBusy(bool on)
364{ 373{
365 icons->setBusy(on); 374 icons->setBusy(on);
366} 375}
367 376
368void LauncherView::setBusyIndicatorType( const QString& type ) { 377void LauncherView::setBusyIndicatorType( const QString& type ) {
369 if ( type. lower ( ) == "animated" ) 378 if ( type. lower ( ) == "animated" )
370 icons->setBusyIndicatorType( BIT_Animated ) ; 379 icons->setBusyIndicatorType( BIT_Animated ) ;
371 else 380 else
372 icons->setBusyIndicatorType( BIT_Normal ) ; 381 icons->setBusyIndicatorType( BIT_Normal ) ;
373} 382}
374 383
375LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 384LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
376 : QIconViewItem( parent, applnk->name(), 385 : QIconViewItem( parent, applnk->name(),
377 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 386 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
378 isBigIcon( bigIcon ), 387 isBigIcon( bigIcon ),
379 iteration(0), 388 iteration(0),
380 app(applnk) // Takes ownership 389 app(applnk), // Takes ownership
390 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
391 m_iPixmap(),
392 m_EyeImage(false)
381{ 393{
394 m_EyeCallback = new LauncherThumbReceiver(this);
395 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
396 m_EyeImage = true;
397 m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap());
398 m_EyeCallback->requestThumb(applnk->file(),m_iPixmap.width(),m_iPixmap.height());
399 }
382} 400}
383 401
384LauncherItem::~LauncherItem() 402LauncherItem::~LauncherItem()
385{ 403{
386 LauncherIconView* liv = (LauncherIconView*)iconView(); 404 LauncherIconView* liv = (LauncherIconView*)iconView();
387 if ( liv->busyItem() == this ) 405 if ( liv->busyItem() == this )
388 liv->setBusy(FALSE); 406 liv->setBusy(FALSE);
389 delete app; 407 delete app;
408 if (m_EyeCallback) delete m_EyeCallback;
390} 409}
391 410
392int LauncherItem::compare ( QIconViewItem * i ) const 411int LauncherItem::compare ( QIconViewItem * i ) const
393{ 412{
394 LauncherIconView* view = (LauncherIconView*)iconView(); 413 LauncherIconView* view = (LauncherIconView*)iconView();
395 return view->compare(app,((LauncherItem *)i)->appLnk()); 414 return view->compare(app,((LauncherItem *)i)->appLnk());
@@ -398,24 +417,24 @@ int LauncherItem::compare ( QIconViewItem * i ) const
398void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 417void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
399{ 418{
400 LauncherIconView* liv = (LauncherIconView*)iconView(); 419 LauncherIconView* liv = (LauncherIconView*)iconView();
401 QBrush oldBrush( liv->itemTextBackground() ); 420 QBrush oldBrush( liv->itemTextBackground() );
402 QColorGroup mycg( cg ); 421 QColorGroup mycg( cg );
403 if ( liv->currentItem() == this ) { 422 if ( liv->currentItem() == this ) {
404 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 423 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
405 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 424 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
406 } 425 }
407 426
408 QIconViewItem::paintItem(p,mycg); 427 QIconViewItem::paintItem(p,mycg);
409 428
410 // Paint animation overlay 429 // Paint animation overlay
411 if ( liv->busyItem() == this ) 430 if ( liv->busyItem() == this )
412 paintAnimatedIcon(p); 431 paintAnimatedIcon(p);
413 432
414 if ( liv->currentItem() == this ) 433 if ( liv->currentItem() == this )
415 liv->setItemTextBackground( oldBrush ); 434 liv->setItemTextBackground( oldBrush );
416} 435}
417 436
418 437
419 438
420void LauncherItem::paintAnimatedIcon( QPainter *p ) 439void LauncherItem::paintAnimatedIcon( QPainter *p )
421{ 440{
@@ -423,17 +442,17 @@ void LauncherItem::paintAnimatedIcon( QPainter *p )
423 int pic = iteration % 16; 442 int pic = iteration % 16;
424 int w = pixmap()->width(), h = pixmap()->height(); 443 int w = pixmap()->width(), h = pixmap()->height();
425 QPixmap dblBuf( w, h + 4 ); 444 QPixmap dblBuf( w, h + 4 );
426 QPainter p2( &dblBuf ); 445 QPainter p2( &dblBuf );
427 int x1, y1; 446 int x1, y1;
428 if ( liv->itemTextPos() == QIconView::Bottom ) { 447 if ( liv->itemTextPos() == QIconView::Bottom ) {
429 x1 = x() + (width() - w) / 2 - liv->contentsX(); 448 x1 = x() + (width() - w) / 2 - liv->contentsX();
430 y1 = y() - liv->contentsY(); 449 y1 = y() - liv->contentsY();
431 } else { 450 } else {
432 x1 = x() - liv->contentsX(); 451 x1 = x() - liv->contentsX();
433 y1 = y() + (height() - h) / 2 - liv->contentsY(); 452 y1 = y() + (height() - h) / 2 - liv->contentsY();
434 } 453 }
435 y1 -= 2; 454 y1 -= 2;
436 p2.translate(-x1,-y1); 455 p2.translate(-x1,-y1);
437 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); 456 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
438 int bounceY = 2; 457 int bounceY = 2;
439#ifdef BOUNCE_BUSY_ICON 458#ifdef BOUNCE_BUSY_ICON
@@ -453,151 +472,158 @@ void LauncherItem::paintAnimatedIcon( QPainter *p )
453 472
454void LauncherItem::animateIcon() 473void LauncherItem::animateIcon()
455{ 474{
456 LauncherIconView* liv = (LauncherIconView*)iconView(); 475 LauncherIconView* liv = (LauncherIconView*)iconView();
457 476
458 if ( liv->busyItem() != this || !app ) 477 if ( liv->busyItem() != this || !app )
459 return; 478 return;
460 479
461 // Highlight the icon 480 // Highlight the icon
462 if ( iteration == 0 ) { 481 if ( iteration == 0 ) {
463 QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap(); 482 QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()));
464 QImage img = src.convertToImage(); 483 QImage img = src.convertToImage();
465 QRgb *rgb; 484 QRgb *rgb;
466 int count; 485 int count;
467 if ( img.depth() == 32 ) { 486 if ( img.depth() == 32 ) {
468 rgb = (QRgb*)img.bits(); 487 rgb = (QRgb*)img.bits();
469 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 488 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
470 } else { 489 } else {
471 rgb = img.colorTable(); 490 rgb = img.colorTable();
472 count = img.numColors(); 491 count = img.numColors();
473 } 492 }
474 for ( int r = 0; r < count; r++, rgb++ ) { 493 for ( int r = 0; r < count; r++, rgb++ ) {
475#if defined(BRIGHTEN_BUSY_ICON) 494#if defined(BRIGHTEN_BUSY_ICON)
476 QColor c(*rgb); 495 QColor c(*rgb);
477 int h, s, v; 496 int h, s, v;
478 c.hsv(&h,&s,&v); 497 c.hsv(&h,&s,&v);
479 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 498 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
480 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 499 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
481#elif defined(ALPHA_FADE_BUSY_ICON) 500#elif defined(ALPHA_FADE_BUSY_ICON)
482 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 501 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
483#endif 502#endif
484 } 503 }
485 src.convertFromImage( img ); 504 src.convertFromImage( img );
486 setPixmap( src ); 505 setPixmap( src );
487 } 506 }
488 507
489 iteration++; 508 iteration++;
490 509
491 // Paint animation overlay 510 // Paint animation overlay
492 QPainter p( liv->viewport() ); 511 QPainter p( liv->viewport() );
493 paintAnimatedIcon( &p ); 512 paintAnimatedIcon( &p );
494} 513}
495 514
496void LauncherItem::resetIcon() 515void LauncherItem::resetIcon()
497{ 516{
498 iteration = 0; 517 iteration = 0;
499 setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() ); 518 setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())));
519}
520
521void LauncherItem::setEyePixmap(const QPixmap&aIcon)
522{
523 if (!isEyeImage()) return;
524 m_iPixmap = aIcon;
525 setPixmap(aIcon);
500} 526}
501 527
502//=========================================================================== 528//===========================================================================
503 529
504QStringList LauncherIconView::mimeTypes() const 530QStringList LauncherIconView::mimeTypes() const
505{ 531{
506 QStringList r; 532 QStringList r;
507 QDictIterator<void> it(mimes); 533 QDictIterator<void> it(mimes);
508 while (it.current()) { 534 while (it.current()) {
509 r.append(it.currentKey()); 535 r.append(it.currentKey());
510 ++it; 536 ++it;
511 } 537 }
512 r.sort(); 538 r.sort();
513 return r; 539 return r;
514} 540}
515 541
516void LauncherIconView::addItem(AppLnk* app, bool resort) 542void LauncherIconView::addItem(AppLnk* app, bool resort)
517{ 543{
518 addCatsAndMimes(app); 544 addCatsAndMimes(app);
519 545
520 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 546 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
521 && (cf == 0 || app->categories().contains(cf) 547 && (cf == 0 || app->categories().contains(cf)
522 || cf == -1 && app->categories().count() == 0 ) ) 548 || cf == -1 && app->categories().count() == 0 ) )
523 (void) new LauncherItem( this, app, bigIcns ); 549 (void) new LauncherItem( this, app, bigIcns );
524 else 550 else
525 hidden.append(app); 551 hidden.append(app);
526 if ( resort ) 552 if ( resort )
527 sort(); 553 sort();
528} 554}
529 555
530void LauncherIconView::updateCategoriesAndMimeTypes() 556void LauncherIconView::updateCategoriesAndMimeTypes()
531{ 557{
532 mimes.clear(); 558 mimes.clear();
533 cats.clear(); 559 cats.clear();
534 LauncherItem* item = (LauncherItem*)firstItem(); 560 LauncherItem* item = (LauncherItem*)firstItem();
535 while (item) { 561 while (item) {
536 addCatsAndMimes(item->appLnk()); 562 addCatsAndMimes(item->appLnk());
537 item = (LauncherItem*)item->nextItem(); 563 item = (LauncherItem*)item->nextItem();
538 } 564 }
539 QListIterator<AppLnk> it(hidden); 565 QListIterator<AppLnk> it(hidden);
540 AppLnk* l; 566 AppLnk* l;
541 while ((l=it.current())) { 567 while ((l=it.current())) {
542 addCatsAndMimes(l); 568 addCatsAndMimes(l);
543 ++it; 569 ++it;
544 } 570 }
545} 571}
546 572
547void LauncherIconView::hideOrShowItems(bool resort) 573void LauncherIconView::hideOrShowItems(bool resort)
548{ 574{
549 viewport()->setUpdatesEnabled( FALSE ); 575 viewport()->setUpdatesEnabled( FALSE );
550 hidden.setAutoDelete(FALSE); 576 hidden.setAutoDelete(FALSE);
551 QList<AppLnk> links=hidden; 577 QList<AppLnk> links=hidden;
552 hidden.clear(); 578 hidden.clear();
553 hidden.setAutoDelete(TRUE); 579 hidden.setAutoDelete(TRUE);
554 LauncherItem* item = (LauncherItem*)firstItem(); 580 LauncherItem* item = (LauncherItem*)firstItem();
555 while (item) { 581 while (item) {
556 links.append(item->takeAppLnk()); 582 links.append(item->takeAppLnk());
557 item = (LauncherItem*)item->nextItem(); 583 item = (LauncherItem*)item->nextItem();
558 } 584 }
559 clear(); 585 clear();
560 QListIterator<AppLnk> it(links); 586 QListIterator<AppLnk> it(links);
561 AppLnk* l; 587 AppLnk* l;
562 while ((l=it.current())) { 588 while ((l=it.current())) {
563 addItem(l,FALSE); 589 addItem(l,FALSE);
564 ++it; 590 ++it;
565 } 591 }
566 if ( resort && !autoArrange() ) 592 if ( resort && !autoArrange() )
567 sort(); 593 sort();
568 viewport()->setUpdatesEnabled( TRUE ); 594 viewport()->setUpdatesEnabled( TRUE );
569} 595}
570 596
571bool LauncherIconView::removeLink(const QString& linkfile) 597bool LauncherIconView::removeLink(const QString& linkfile)
572{ 598{
573 LauncherItem* item = (LauncherItem*)firstItem(); 599 LauncherItem* item = (LauncherItem*)firstItem();
574 AppLnk* l; 600 AppLnk* l;
575 bool did = FALSE; 601 bool did = FALSE;
576 DocLnk dl(linkfile); 602 DocLnk dl(linkfile);
577 while (item) { 603 while (item) {
578 l = item->appLnk(); 604 l = item->appLnk();
579 LauncherItem *nextItem = (LauncherItem *)item->nextItem(); 605 LauncherItem *nextItem = (LauncherItem *)item->nextItem();
580 if ( l->linkFileKnown() && l->linkFile() == linkfile 606 if ( l->linkFileKnown() && l->linkFile() == linkfile
581 || l->fileKnown() && ( 607 || l->fileKnown() && (
582 l->file() == linkfile 608 l->file() == linkfile
583 || dl.isValid() && dl.file() == l->file() ) ) { 609 || dl.isValid() && dl.file() == l->file() ) ) {
584 delete item; 610 delete item;
585 did = TRUE; 611 did = TRUE;
586 } 612 }
587 item = nextItem; 613 item = nextItem;
588 } 614 }
589 QListIterator<AppLnk> it(hidden); 615 QListIterator<AppLnk> it(hidden);
590 while ((l=it.current())) { 616 while ((l=it.current())) {
591 ++it; 617 ++it;
592 if ( l->linkFileKnown() && l->linkFile() == linkfile 618 if ( l->linkFileKnown() && l->linkFile() == linkfile
593 || l->file() == linkfile 619 || l->file() == linkfile
594 || dl.isValid() && dl.file() == l->file() ) { 620 || dl.isValid() && dl.file() == l->file() ) {
595 hidden.removeRef(l); 621 hidden.removeRef(l);
596 did = TRUE; 622 did = TRUE;
597 } 623 }
598 } 624 }
599 return did; 625 return did;
600} 626}
601 627
602//=========================================================================== 628//===========================================================================
603 629
@@ -618,115 +644,115 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
618 icons->setBackgroundMode( PaletteBase ); 644 icons->setBackgroundMode( PaletteBase );
619 icons->setResizeMode( QIconView::Fixed ); 645 icons->setResizeMode( QIconView::Fixed );
620 vmode = (ViewMode)-1; 646 vmode = (ViewMode)-1;
621 setViewMode( Icon ); 647 setViewMode( Icon );
622 648
623 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 649 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
624 SLOT(itemClicked(int,QIconViewItem*)) ); 650 SLOT(itemClicked(int,QIconViewItem*)) );
625 connect( icons, SIGNAL(selectionChanged()), 651 connect( icons, SIGNAL(selectionChanged()),
626 SLOT(selectionChanged()) ); 652 SLOT(selectionChanged()) );
627 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 653 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
628 SLOT(returnPressed(QIconViewItem*)) ); 654 SLOT(returnPressed(QIconViewItem*)) );
629 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 655 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
630 SLOT(itemPressed(int,QIconViewItem*)) ); 656 SLOT(itemPressed(int,QIconViewItem*)) );
631 657
632 tools = 0; 658 tools = 0;
633 setBackgroundType( Ruled, QString::null ); 659 setBackgroundType( Ruled, QString::null );
634} 660}
635 661
636LauncherView::~LauncherView() 662LauncherView::~LauncherView()
637{ 663{
638 if ( bgCache && bgCache->contains( bgName ) ) 664 if ( bgCache && bgCache->contains( bgName ) )
639 (*bgCache)[bgName]->ref--; 665 (*bgCache)[bgName]->ref--;
640} 666}
641 667
642void LauncherView::hideIcons() 668void LauncherView::hideIcons()
643{ 669{
644 icons->hide(); 670 icons->hide();
645} 671}
646 672
647void LauncherView::setToolsEnabled(bool y) 673void LauncherView::setToolsEnabled(bool y)
648{ 674{
649 if ( !y != !tools ) { 675 if ( !y != !tools ) {
650 if ( y ) { 676 if ( y ) {
651 tools = new QHBox(this); 677 tools = new QHBox(this);
652 678
653 // Type filter 679 // Type filter
654 typemb = new QComboBox(tools); 680 typemb = new QComboBox(tools);
655 QSizePolicy p = typemb->sizePolicy(); 681 QSizePolicy p = typemb->sizePolicy();
656 p.setHorData(QSizePolicy::Expanding); 682 p.setHorData(QSizePolicy::Expanding);
657 typemb->setSizePolicy(p); 683 typemb->setSizePolicy(p);
658 684
659 // Category filter 685 // Category filter
660 updateTools(); 686 updateTools();
661 tools->show(); 687 tools->show();
662 688
663 } else { 689 } else {
664 delete tools; 690 delete tools;
665 tools = 0; 691 tools = 0;
666 } 692 }
667 } 693 }
668} 694}
669 695
670void LauncherView::updateTools() 696void LauncherView::updateTools()
671{ 697{
672 disconnect( typemb, SIGNAL(activated(int)), 698 disconnect( typemb, SIGNAL(activated(int)),
673 this, SLOT(showType(int)) ); 699 this, SLOT(showType(int)) );
674 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), 700 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)),
675 this, SLOT(showCategory(int)) ); 701 this, SLOT(showCategory(int)) );
676 702
677 // ### I want to remove this 703 // ### I want to remove this
678 icons->updateCategoriesAndMimeTypes(); 704 icons->updateCategoriesAndMimeTypes();
679 705
680 QString prev; 706 QString prev;
681 707
682 // Type filter 708 // Type filter
683 QStringList types; 709 QStringList types;
684 typelist = icons->mimeTypes(); 710 typelist = icons->mimeTypes();
685 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 711 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
686 QString t = *it; 712 QString t = *it;
687 if ( t.left(12) == "application/" ) { 713 if ( t.left(12) == "application/" ) {
688 MimeType mt(t); 714 MimeType mt(t);
689 const AppLnk* app = mt.application(); 715 const AppLnk* app = mt.application();
690 if ( app ) 716 if ( app )
691 t = app->name(); 717 t = app->name();
692 else 718 else
693 t = t.mid(12); 719 t = t.mid(12);
694 } else { 720 } else {
695 t[0] = t[0].upper(); 721 t[0] = t[0].upper();
696 } 722 }
697 types += t; 723 types += t;
698 } 724 }
699 types << tr("All types"); 725 types << tr("All types");
700 prev = typemb->currentText(); 726 prev = typemb->currentText();
701 typemb->clear(); 727 typemb->clear();
702 typemb->insertStringList(types); 728 typemb->insertStringList(types);
703 for (int i=0; i<typemb->count(); i++) { 729 for (int i=0; i<typemb->count(); i++) {
704 if ( typemb->text(i) == prev ) { 730 if ( typemb->text(i) == prev ) {
705 typemb->setCurrentItem(i); 731 typemb->setCurrentItem(i);
706 break; 732 break;
707 } 733 }
708 } 734 }
709 if ( prev.isNull() ) 735 if ( prev.isNull() )
710 typemb->setCurrentItem(typemb->count()-1); 736 typemb->setCurrentItem(typemb->count()-1);
711 737
712 int pcat = catmb ? catmb->currentCategory() : -2; 738 int pcat = catmb ? catmb->currentCategory() : -2;
713 if ( !catmb ) 739 if ( !catmb )
714 catmb = new CategorySelect(tools); 740 catmb = new CategorySelect(tools);
715 Categories cats( 0 ); 741 Categories cats( 0 );
716 cats.load( categoryFileName() ); 742 cats.load( categoryFileName() );
717 QArray<int> vl( 0 ); 743 QArray<int> vl( 0 );
718 catmb->setCategories( vl, "Document View", // No tr 744 catmb->setCategories( vl, "Document View", // No tr
719 tr("Document View") ); 745 tr("Document View") );
720 catmb->setRemoveCategoryEdit( TRUE ); 746 catmb->setRemoveCategoryEdit( TRUE );
721 catmb->setAllCategories( TRUE ); 747 catmb->setAllCategories( TRUE );
722 catmb->setCurrentCategory(pcat); 748 catmb->setCurrentCategory(pcat);
723 749
724 // if type has changed we need to redisplay 750 // if type has changed we need to redisplay
725 if ( typemb->currentText() != prev ) 751 if ( typemb->currentText() != prev )
726 showType( typemb->currentItem() ); 752 showType( typemb->currentItem() );
727 753
728 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 754 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
729 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 755 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
730} 756}
731 757
732void LauncherView::sortBy(int s) 758void LauncherView::sortBy(int s)
@@ -734,43 +760,43 @@ void LauncherView::sortBy(int s)
734 icons->setSortMethod((LauncherIconView::SortMethod)s); 760 icons->setSortMethod((LauncherIconView::SortMethod)s);
735} 761}
736 762
737void LauncherView::showType(int t) 763void LauncherView::showType(int t)
738{ 764{
739 if ( t >= (int)typelist.count() ) { 765 if ( t >= (int)typelist.count() ) {
740 icons->setTypeFilter("",TRUE); 766 icons->setTypeFilter("",TRUE);
741 } else { 767 } else {
742 QString ty = typelist[t]; 768 QString ty = typelist[t];
743 if ( !ty.contains('/') ) 769 if ( !ty.contains('/') )
744 ty += "/*"; 770 ty += "/*";
745 icons->setTypeFilter(ty,TRUE); 771 icons->setTypeFilter(ty,TRUE);
746 } 772 }
747} 773}
748 774
749void LauncherView::showCategory( int c ) 775void LauncherView::showCategory( int c )
750{ 776{
751 icons->setCategoryFilter( c, TRUE ); 777 icons->setCategoryFilter( c, TRUE );
752} 778}
753 779
754void LauncherView::setViewMode( ViewMode m ) 780void LauncherView::setViewMode( ViewMode m )
755{ 781{
756 if ( vmode != m ) { 782 if ( vmode != m ) {
757 bool bigIcons = m == Icon; 783 bool bigIcons = m == Icon;
758 icons->viewport()->setUpdatesEnabled( FALSE ); 784 icons->viewport()->setUpdatesEnabled( FALSE );
759 icons->setBigIcons( bigIcons ); 785 icons->setBigIcons( bigIcons );
760 switch ( m ) { 786 switch ( m ) {
761 case List: 787 case List:
762 icons->setItemTextPos( QIconView::Right ); 788 icons->setItemTextPos( QIconView::Right );
763 break; 789 break;
764 case Icon: 790 case Icon:
765 icons->setItemTextPos( QIconView::Bottom ); 791 icons->setItemTextPos( QIconView::Bottom );
766 break; 792 break;
767 } 793 }
768 icons->hideOrShowItems( FALSE ); 794 icons->hideOrShowItems( FALSE );
769 icons->viewport()->setUpdatesEnabled( TRUE ); 795 icons->viewport()->setUpdatesEnabled( TRUE );
770 vmode = m; 796 vmode = m;
771 } 797 }
772} 798}
773 799
774// 800//
775// User images may require scaling. 801// User images may require scaling.
776// 802//
@@ -781,134 +807,134 @@ QImage LauncherView::loadBackgroundImage(QString &bgName)
781 bool further_scaling = TRUE; 807 bool further_scaling = TRUE;
782 808
783 imgio.setFileName( bgName ); 809 imgio.setFileName( bgName );
784 imgio.setParameters("GetHeaderInformation"); 810 imgio.setParameters("GetHeaderInformation");
785 811
786 if (imgio.read() == FALSE) { 812 if (imgio.read() == FALSE) {
787 return imgio.image(); 813 return imgio.image();
788 } 814 }
789 815
790 if (imgio.image().width() < ds.width() && 816 if (imgio.image().width() < ds.width() &&
791 imgio.image().height() < ds.height()) { 817 imgio.image().height() < ds.height()) {
792 further_scaling = FALSE; 818 further_scaling = FALSE;
793 } 819 }
794 820
795 if (!imgio.image().bits()) { 821 if (!imgio.image().bits()) {
796 // 822 //
797 // Scale and load. Note we don't scale up. 823 // Scale and load. Note we don't scale up.
798 // 824 //
799 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 825 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
800 imgio.setParameters(further_scaling ? 826 imgio.setParameters(further_scaling ?
801 param.arg(ds.width()).arg(ds.height()).latin1() : 827 param.arg(ds.width()).arg(ds.height()).latin1() :
802 ""); 828 "");
803 imgio.read(); 829 imgio.read();
804 } else { 830 } else {
805 if (further_scaling) { 831 if (further_scaling) {
806 intt1 = imgio.image().width() * ds.height(); 832 int t1 = imgio.image().width() * ds.height();
807 int t2 = imgio.image().height() * ds.width(); 833 int t2 = imgio.image().height() * ds.width();
808 int dsth = ds.height(); 834 int dsth = ds.height();
809 int dstw = ds.width(); 835 int dstw = ds.width();
810 836
811 if (t1 > t2) { 837 if (t1 > t2) {
812 dsth = t2 / imgio.image().width(); 838 dsth = t2 / imgio.image().width();
813 } else { 839 } else {
814 dstw = t1 / imgio.image().height(); 840 dstw = t1 / imgio.image().height();
815 } 841 }
816 842
817 // 843 //
818 // Loader didn't scale for us. Do it manually. 844 // Loader didn't scale for us. Do it manually.
819 // 845 //
820 return imgio.image().smoothScale(dstw, dsth); 846 return imgio.image().smoothScale(dstw, dsth);
821 } 847 }
822 } 848 }
823 849
824 return imgio.image(); 850 return imgio.image();
825} 851}
826 852
827void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 853void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
828{ 854{
829 if ( !bgCache ) { 855 if ( !bgCache ) {
830 bgCache = new QMap<QString,BgPixmap*>; 856 bgCache = new QMap<QString,BgPixmap*>;
831 qAddPostRoutine( cleanup_cache ); 857 qAddPostRoutine( cleanup_cache );
832 } 858 }
833 859
834 if ( bgCache->contains( bgName ) ) 860 if ( bgCache->contains( bgName ) )
835 (*bgCache)[bgName]->ref--; 861 (*bgCache)[bgName]->ref--;
836 bgName = ""; 862 bgName = "";
837 863
838 QPixmap bg; 864 QPixmap bg;
839 865
840 switch ( t ) { 866 switch ( t ) {
841 case Ruled: { 867 case Ruled: {
842 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 868 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
843 if ( bgCache->contains( bgName ) ) { 869 if ( bgCache->contains( bgName ) ) {
844 (*bgCache)[bgName]->ref++; 870 (*bgCache)[bgName]->ref++;
845 bg = (*bgCache)[bgName]->pm; 871 bg = (*bgCache)[bgName]->pm;
846 } else { 872 } else {
847 bg.resize( width(), 9 ); 873 bg.resize( width(), 9 );
848 QPainter painter( &bg ); 874 QPainter painter( &bg );
849 for ( int i = 0; i < 3; i++ ) { 875 for ( int i = 0; i < 3; i++ ) {
850 painter.setPen( white ); 876 painter.setPen( white );
851 painter.drawLine( 0, i*3, width()-1, i*3 ); 877 painter.drawLine( 0, i*3, width()-1, i*3 );
852 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 878 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
853 painter.setPen( colorGroup().background().light(105) ); 879 painter.setPen( colorGroup().background().light(105) );
854 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 880 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
855 } 881 }
856 painter.end(); 882 painter.end();
857 bgCache->insert( bgName, new BgPixmap(bg) ); 883 bgCache->insert( bgName, new BgPixmap(bg) );
858 } 884 }
859 break; 885 break;
860 } 886 }
861 887
862 case Image: 888 case Image:
863 if (!val.isEmpty()) { 889 if (!val.isEmpty()) {
864 bgName = val; 890 bgName = val;
865 if ( bgCache->contains( bgName ) ) { 891 if ( bgCache->contains( bgName ) ) {
866 (*bgCache)[bgName]->ref++; 892 (*bgCache)[bgName]->ref++;
867 bg = (*bgCache)[bgName]->pm; 893 bg = (*bgCache)[bgName]->pm;
868 } else { 894 } else {
869 QString imgFile = bgName; 895 QString imgFile = bgName;
870 bool tile = FALSE; 896 bool tile = FALSE;
871 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { 897 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) {
872 imgFile = Resource::findPixmap( imgFile ); 898 imgFile = Resource::findPixmap( imgFile );
873 tile = TRUE; 899 tile = TRUE;
874 } 900 }
875 QImage img = loadBackgroundImage(imgFile); 901 QImage img = loadBackgroundImage(imgFile);
876 902
877 903
878 if ( img.depth() == 1 ) 904 if ( img.depth() == 1 )
879 img = img.convertDepth(8); 905 img = img.convertDepth(8);
880 img.setAlphaBuffer(FALSE); 906 img.setAlphaBuffer(FALSE);
881 bg.convertFromImage(img); 907 bg.convertFromImage(img);
882 bgCache->insert( bgName, new BgPixmap(bg) ); 908 bgCache->insert( bgName, new BgPixmap(bg) );
883 } 909 }
884 } 910 }
885 break; 911 break;
886 912
887 case SolidColor: 913 case SolidColor:
888 default: 914 default:
889 break; 915 break;
890 } 916 }
891 917
892 const QObjectList *list = queryList( "QWidget", 0, FALSE ); 918 const QObjectList *list = queryList( "QWidget", 0, FALSE );
893 QObject *obj; 919 QObject *obj;
894 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { 920 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) {
895 if ( obj->isWidgetType() ) { 921 if ( obj->isWidgetType() ) {
896 QWidget *w = (QWidget*)obj; 922 QWidget *w = (QWidget*)obj;
897 w->setBackgroundPixmap( bg ); 923 w->setBackgroundPixmap( bg );
898 if ( bgName.isEmpty() ) { 924 if ( bgName.isEmpty() ) {
899 // Solid Color 925 // Solid Color
900 if ( val.isEmpty() ) 926 if ( val.isEmpty() )
901 w->setBackgroundColor( colorGroup().base() ); 927 w->setBackgroundColor( colorGroup().base() );
902 else 928 else
903 w->setBackgroundColor( val ); 929 w->setBackgroundColor( val );
904 } else { 930 } else {
905 // Ruled or Image pixmap 931 // Ruled or Image pixmap
906 w->setBackgroundOrigin( ParentOrigin ); 932 w->setBackgroundOrigin( ParentOrigin );
907 } 933 }
908 } 934 }
909 } 935 }
910 delete list; 936 delete list;
911 937
912 bgType = t; 938 bgType = t;
913 icons->viewport()->update(); 939 icons->viewport()->update();
914 940
@@ -935,60 +961,60 @@ void LauncherView::clearViewFont()
935 icons->unsetFont(); 961 icons->unsetFont();
936 icons->hideOrShowItems( FALSE ); 962 icons->hideOrShowItems( FALSE );
937} 963}
938 964
939void LauncherView::resizeEvent(QResizeEvent *e) 965void LauncherView::resizeEvent(QResizeEvent *e)
940{ 966{
941 //qDebug("LauncherView resize event"); 967// qDebug("LauncherView resize event");
942 QVBox::resizeEvent( e ); 968 QVBox::resizeEvent( e );
943// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... 969// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere...
944// if ( e->size().width() != e->oldSize().width() ) 970// if ( e->size().width() != e->oldSize().width() )
945 sort(); 971 sort();
946} 972}
947 973
948void LauncherView::selectionChanged() 974void LauncherView::selectionChanged()
949{ 975{
950 QIconViewItem* item = icons->currentItem(); 976 QIconViewItem* item = icons->currentItem();
951 if ( item && item->isSelected() ) { 977 if ( item && item->isSelected() ) {
952 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 978 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
953 if ( icons->inKeyEvent() ) // not for mouse press 979 if ( icons->inKeyEvent() ) // not for mouse press
954 emit clicked( appLnk ); 980 emit clicked( appLnk );
955 item->setSelected(FALSE); 981 item->setSelected(FALSE);
956 } 982 }
957} 983}
958 984
959void LauncherView::returnPressed( QIconViewItem *item ) 985void LauncherView::returnPressed( QIconViewItem *item )
960{ 986{
961 if ( item ) { 987 if ( item ) {
962 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 988 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
963 emit clicked( appLnk ); 989 emit clicked( appLnk );
964 } 990 }
965} 991}
966 992
967void LauncherView::itemClicked( int btn, QIconViewItem *item ) 993void LauncherView::itemClicked( int btn, QIconViewItem *item )
968{ 994{
969 if ( item ) { 995 if ( item ) {
970 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 996 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
971 if ( btn == LeftButton ) { 997 if ( btn == LeftButton ) {
972 // Make sure it's the item we execute that gets highlighted 998 // Make sure it's the item we execute that gets highlighted
973 icons->setCurrentItem( item ); 999 icons->setCurrentItem( item );
974 emit clicked( appLnk ); 1000 emit clicked( appLnk );
975 } 1001 }
976 item->setSelected(FALSE); 1002 item->setSelected(FALSE);
977 } 1003 }
978} 1004}
979 1005
980void LauncherView::itemPressed( int btn, QIconViewItem *item ) 1006void LauncherView::itemPressed( int btn, QIconViewItem *item )
981{ 1007{
982 if ( item ) { 1008 if ( item ) {
983 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1009 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
984 if ( btn == RightButton ) 1010 if ( btn == RightButton )
985 emit rightPressed( appLnk ); 1011 emit rightPressed( appLnk );
986 else if ( btn == ShiftButton ) 1012 else if ( btn == ShiftButton )
987 emit rightPressed( appLnk ); 1013 emit rightPressed( appLnk );
988 item->setSelected(FALSE); 1014 item->setSelected(FALSE);
989 } 1015 }
990} 1016}
991 1017
992void LauncherView::removeAllItems() 1018void LauncherView::removeAllItems()
993{ 1019{
994 icons->clear(); 1020 icons->clear();
@@ -1000,13 +1026,13 @@ bool LauncherView::removeLink(const QString& linkfile)
1000} 1026}
1001 1027
1002void LauncherView::setSortEnabled( bool v ) 1028void LauncherView::setSortEnabled( bool v )
1003{ 1029{
1004 icons->setSorting( v ); 1030 icons->setSorting( v );
1005 if ( v ) 1031 if ( v )
1006 sort(); 1032 sort();
1007} 1033}
1008 1034
1009void LauncherView::setUpdatesEnabled( bool u ) 1035void LauncherView::setUpdatesEnabled( bool u )
1010{ 1036{
1011 icons->setUpdatesEnabled( u ); 1037 icons->setUpdatesEnabled( u );
1012} 1038}
@@ -1023,13 +1049,13 @@ void LauncherView::addItem(AppLnk* app, bool resort)
1023 1049
1024void LauncherView::paletteChange( const QPalette &p ) 1050void LauncherView::paletteChange( const QPalette &p )
1025{ 1051{
1026 icons->unsetPalette(); 1052 icons->unsetPalette();
1027 QVBox::paletteChange( p ); 1053 QVBox::paletteChange( p );
1028 if ( bgType == Ruled ) 1054 if ( bgType == Ruled )
1029 setBackgroundType( Ruled, QString::null ); 1055 setBackgroundType( Ruled, QString::null );
1030 QColorGroup cg = icons->colorGroup(); 1056 QColorGroup cg = icons->colorGroup();
1031 cg.setColor( QColorGroup::Text, textCol ); 1057 cg.setColor( QColorGroup::Text, textCol );
1032 icons->setPalette( QPalette(cg,cg,cg) ); 1058 icons->setPalette( QPalette(cg,cg,cg) );
1033} 1059}
1034 1060
1035void LauncherView::fontChanged(const QFont&) 1061void LauncherView::fontChanged(const QFont&)
@@ -1043,19 +1069,85 @@ void LauncherView::relayout(void)
1043 icons->hideOrShowItems(FALSE); 1069 icons->hideOrShowItems(FALSE);
1044} 1070}
1045 1071
1046void LauncherView::flushBgCache() 1072void LauncherView::flushBgCache()
1047{ 1073{
1048 if ( !bgCache ) 1074 if ( !bgCache )
1049 return; 1075 return;
1050 // remove unreferenced backgrounds. 1076 // remove unreferenced backgrounds.
1051 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1077 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1052 while ( it != bgCache->end() ) { 1078 while ( it != bgCache->end() ) {
1053 QMap<QString,BgPixmap*>::Iterator curr = it; 1079 QMap<QString,BgPixmap*>::Iterator curr = it;
1054 ++it; 1080 ++it;
1055 if ( (*curr)->ref == 0 ) { 1081 if ( (*curr)->ref == 0 ) {
1056 delete (*curr); 1082 delete (*curr);
1057 bgCache->remove( curr ); 1083 bgCache->remove( curr );
1058 } 1084 }
1059 } 1085 }
1060} 1086}
1061 1087
1088/* special image handling - based on opie eye */
1089QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1090 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1091 return s;
1092}
1093
1094QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1095 return s << inf.file << inf.width << inf.height;
1096}
1097
1098LauncherThumbReceiver::LauncherThumbReceiver(LauncherItem*parent)
1099 :QObject()
1100{
1101 m_parent = parent;
1102 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1103 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1104 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1105
1106 {
1107 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1108 }
1109 m_waiting = false;
1110}
1111
1112LauncherThumbReceiver::~LauncherThumbReceiver()
1113{
1114 {
1115 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1116 }
1117}
1118
1119void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1120{
1121 PixmapInfos pixinfos;
1122 QDataStream stream( at, IO_ReadOnly );
1123 if (!m_parent || !m_waiting) return;
1124 /* we are just interested in thumbmails */
1125 if ( str == "pixmapsHandled(PixmapList)" )
1126 stream >> pixinfos;
1127
1128 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1129 if ((*it).file==m_reqFile) {
1130 m_parent->setEyePixmap((*it).pixmap);
1131 m_waiting = false;
1132 break;
1133 }
1134 }
1135}
1136
1137void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1138{
1139 m_reqFile = file;
1140 rItem.file = file;
1141 rItem.width = width;
1142 rItem.height = height;
1143 QTimer::singleShot(1, this, SLOT(sendRequest()));
1144}
1145
1146void LauncherThumbReceiver::sendRequest()
1147{
1148 PixmapInfos m_inThumbNail;
1149 m_inThumbNail.append(rItem);
1150 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1151 env << m_inThumbNail;
1152 m_waiting = true;
1153}
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index e40a006..a9ff9eb 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -24,24 +24,25 @@
24#include <qtopia/applnk.h> 24#include <qtopia/applnk.h>
25 25
26#include <qvbox.h> 26#include <qvbox.h>
27 27
28class CategorySelect; 28class CategorySelect;
29class LauncherIconView; 29class LauncherIconView;
30class LauncherItem;
30class QIconView; 31class QIconView;
31class QIconViewItem; 32class QIconViewItem;
32class QLabel; 33class QLabel;
33class QWidgetStack; 34class QWidgetStack;
34class MenuButton; 35class MenuButton;
35class QComboBox; 36class QComboBox;
36 37
37 38
38 39
39enum BusyIndicatorType { 40enum BusyIndicatorType {
40 BIT_Normal = 0, 41 BIT_Normal = 0,
41 BIT_Animated 42 BIT_Animated
42}; 43};
43 44
44class LauncherView : public QVBox 45class LauncherView : public QVBox
45{ 46{
46 Q_OBJECT 47 Q_OBJECT
47 48
@@ -113,7 +114,42 @@ private:
113 QColor textCol; 114 QColor textCol;
114 115
115 QImage loadBackgroundImage(QString &fname); 116 QImage loadBackgroundImage(QString &fname);
116 117
117}; 118};
118 119
120/* taken from opie-eye */
121
122struct PixmapInfo {
123 PixmapInfo() : width( -1 ), height( -1 ) {}
124 bool operator==( const PixmapInfo& r ) {
125 if ( width != r.width ) return false;
126 if ( height != r.height ) return false;
127 if ( file != r.file ) return false;
128 return true;
129 }
130 int width, height;
131 QString file;
132 QPixmap pixmap;
133};
134
135class LauncherThumbReceiver:public QObject
136{
137 Q_OBJECT
138 typedef QValueList<PixmapInfo> PixmapInfos;
139public:
140 LauncherThumbReceiver(LauncherItem*parent);
141 ~LauncherThumbReceiver();
142 void requestThumb(const QString&file,int width,int height);
143
144public slots:
145 void recieve( const QCString&, const QByteArray& );
146protected slots:
147 virtual void sendRequest();
148protected:
149 LauncherItem*m_parent;
150 QString m_reqFile;
151 PixmapInfo rItem;
152 bool m_waiting:1;
153};
154
119#endif // LAUNCHERVIEW_H 155#endif // LAUNCHERVIEW_H