summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp28
-rw-r--r--core/launcher/launcherview.h22
2 files changed, 33 insertions, 17 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 506c11e..42704ba 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -178,522 +178,549 @@ void LauncherItem::paintAnimatedIcon( QPainter *p )
178 QPixmap dblBuf( w, h + 4 ); 178 QPixmap dblBuf( w, h + 4 );
179 QPainter p2( &dblBuf ); 179 QPainter p2( &dblBuf );
180 int x1, y1; 180 int x1, y1;
181 if ( liv->itemTextPos() == QIconView::Bottom ) { 181 if ( liv->itemTextPos() == QIconView::Bottom ) {
182 x1 = x() + (width() - w) / 2 - liv->contentsX(); 182 x1 = x() + (width() - w) / 2 - liv->contentsX();
183 y1 = y() - liv->contentsY(); 183 y1 = y() - liv->contentsY();
184 } else { 184 } else {
185 x1 = x() - liv->contentsX(); 185 x1 = x() - liv->contentsX();
186 y1 = y() + (height() - h) / 2 - liv->contentsY(); 186 y1 = y() + (height() - h) / 2 - liv->contentsY();
187 } 187 }
188 y1 -= 2; 188 y1 -= 2;
189 p2.translate(-x1,-y1); 189 p2.translate(-x1,-y1);
190 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); 190 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
191 int bounceY = 2; 191 int bounceY = 2;
192#ifdef BOUNCE_BUSY_ICON 192#ifdef BOUNCE_BUSY_ICON
193 if ( busyType == BIT_Animated ) { 193 if ( busyType == BIT_Animated ) {
194 bounceY = 4 - ((iteration+2)%8); 194 bounceY = 4 - ((iteration+2)%8);
195 bounceY = bounceY < 0 ? -bounceY : bounceY; 195 bounceY = bounceY < 0 ? -bounceY : bounceY;
196 } 196 }
197#endif 197#endif
198 p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); 198 p2.drawPixmap( x1, y1 + bounceY, *pixmap() );
199#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 199#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
200 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); 200 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h );
201#else 201#else
202 Q_UNUSED( pic ) 202 Q_UNUSED( pic )
203#endif 203#endif
204 p->drawPixmap( x1, y1, dblBuf ); 204 p->drawPixmap( x1, y1, dblBuf );
205} 205}
206 206
207void LauncherItem::animateIcon() 207void LauncherItem::animateIcon()
208{ 208{
209 LauncherIconView* liv = (LauncherIconView*)iconView(); 209 LauncherIconView* liv = (LauncherIconView*)iconView();
210 210
211 if ( liv->busyItem() != this || !app ) 211 if ( liv->busyItem() != this || !app )
212 return; 212 return;
213 213
214 // Highlight the icon 214 // Highlight the icon
215 if ( iteration == 0 ) { 215 if ( iteration == 0 ) {
216 QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); 216 QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()));
217 QImage img = src.convertToImage(); 217 QImage img = src.convertToImage();
218 QRgb *rgb; 218 QRgb *rgb;
219 int count; 219 int count;
220 if ( img.depth() == 32 ) { 220 if ( img.depth() == 32 ) {
221 rgb = (QRgb*)img.bits(); 221 rgb = (QRgb*)img.bits();
222 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 222 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
223 } else { 223 } else {
224 rgb = img.colorTable(); 224 rgb = img.colorTable();
225 count = img.numColors(); 225 count = img.numColors();
226 } 226 }
227 for ( int r = 0; r < count; r++, rgb++ ) { 227 for ( int r = 0; r < count; r++, rgb++ ) {
228#if defined(BRIGHTEN_BUSY_ICON) 228#if defined(BRIGHTEN_BUSY_ICON)
229 QColor c(*rgb); 229 QColor c(*rgb);
230 int h, s, v; 230 int h, s, v;
231 c.hsv(&h,&s,&v); 231 c.hsv(&h,&s,&v);
232 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 232 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
233 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 233 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
234#elif defined(ALPHA_FADE_BUSY_ICON) 234#elif defined(ALPHA_FADE_BUSY_ICON)
235 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 235 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
236#endif 236#endif
237 } 237 }
238 src.convertFromImage( img ); 238 src.convertFromImage( img );
239 setPixmap( src ); 239 setPixmap( src );
240 } 240 }
241 241
242 iteration++; 242 iteration++;
243 243
244 // Paint animation overlay 244 // Paint animation overlay
245 QPainter p( liv->viewport() ); 245 QPainter p( liv->viewport() );
246 paintAnimatedIcon( &p ); 246 paintAnimatedIcon( &p );
247} 247}
248 248
249void LauncherItem::resetIcon() 249void LauncherItem::resetIcon()
250{ 250{
251 iteration = 0; 251 iteration = 0;
252 setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); 252 setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())));
253} 253}
254 254
255void LauncherItem::setEyePixmap(const QPixmap&aIcon) 255void LauncherItem::setEyePixmap(const QPixmap&aIcon)
256{ 256{
257 if (!isEyeImage()) return; 257 if (!isEyeImage()) return;
258 m_iPixmap = aIcon; 258 m_iPixmap = aIcon;
259 setPixmap(aIcon); 259 setPixmap(aIcon);
260 m_EyeImageSet = EYE_ICON; 260 m_EyeImageSet = EYE_ICON;
261} 261}
262 262
263//=========================================================================== 263//===========================================================================
264// Implemantation of LauncherIconview start 264// Implemantation of LauncherIconview start
265//=========================================================================== 265//===========================================================================
266LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 266LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
267 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) 267 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white)
268{ 268{
269 m_EyeCallBack = 0; 269 m_EyeCallBack = 0;
270 sortmeth = Name; 270 sortmeth = Name;
271 hidden.setAutoDelete(TRUE); 271 hidden.setAutoDelete(TRUE);
272 ike = FALSE; 272 ike = FALSE;
273 calculateGrid( Bottom ); 273 calculateGrid( Bottom );
274 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
274} 275}
275 276
276LauncherIconView::~LauncherIconView() 277LauncherIconView::~LauncherIconView()
277{ 278{
278#if 0 // debuggery 279#if 0 // debuggery
279 QListIterator<AppLnk> it(hidden); 280 QListIterator<AppLnk> it(hidden);
280 AppLnk* l; 281 AppLnk* l;
281 while ((l=it.current())) { 282 while ((l=it.current())) {
282 ++it; 283 ++it;
283 //odebug << "" << l << ": hidden (should remove)" << oendl; 284 //odebug << "" << l << ": hidden (should remove)" << oendl;
284 } 285 }
285#endif 286#endif
286} 287}
287 288
288int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 289int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
289{ 290{
290 switch (sortmeth) { 291 switch (sortmeth) {
291 case Name: 292 case Name:
292 return a->name().lower().compare(b->name().lower()); 293 return a->name().lower().compare(b->name().lower());
293 case Date: { 294 case Date: {
294 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 295 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
295 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 296 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
296 return fa.lastModified().secsTo(fb.lastModified()); 297 return fa.lastModified().secsTo(fb.lastModified());
297 } 298 }
298 case Type: 299 case Type:
299 return a->type().compare(b->type()); 300 return a->type().compare(b->type());
300 } 301 }
301 return 0; 302 return 0;
302} 303}
303 304
304void LauncherIconView::setSortMethod( SortMethod m ) 305void LauncherIconView::setSortMethod( SortMethod m )
305{ 306{
306 if ( sortmeth != m ) { 307 if ( sortmeth != m ) {
307 sortmeth = m; 308 sortmeth = m;
308 sort(); 309 sort();
309 } 310 }
310} 311}
311 312
312void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 313void LauncherIconView::setCategoryFilter( int catfilter, bool resort )
313{ 314{
314 Categories cat; 315 Categories cat;
315 cat.load( categoryFileName() ); 316 cat.load( categoryFileName() );
316 QString str; 317 QString str;
317 if ( catfilter == -2 ) 318 if ( catfilter == -2 )
318 cf = 0; 319 cf = 0;
319 else 320 else
320 cf = catfilter; 321 cf = catfilter;
321 hideOrShowItems(resort); 322 hideOrShowItems(resort);
322} 323}
323 324
324void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 325void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
325{ 326{
326 tf = QRegExp(typefilter,FALSE,TRUE); 327 tf = QRegExp(typefilter,FALSE,TRUE);
327 hideOrShowItems(resort); 328 hideOrShowItems(resort);
328} 329}
329 330
330void LauncherIconView::setItemTextPos( ItemTextPos pos ) 331void LauncherIconView::setItemTextPos( ItemTextPos pos )
331{ 332{
332 calculateGrid( pos ); 333 calculateGrid( pos );
333 QIconView::setItemTextPos( pos ); 334 QIconView::setItemTextPos( pos );
334} 335}
335 336
336void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) 337void LauncherIconView::drawBackground( QPainter *p, const QRect &r )
337{ 338{
338 if ( !bgPixmap.isNull() ) { 339 if ( !bgPixmap.isNull() ) {
339 p->drawTiledPixmap( r, bgPixmap, 340 p->drawTiledPixmap( r, bgPixmap,
340 QPoint( (r.x() + contentsX()) % bgPixmap.width(), 341 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
341 (r.y() + contentsY()) % bgPixmap.height() ) ); 342 (r.y() + contentsY()) % bgPixmap.height() ) );
342 } else { 343 } else {
343 p->fillRect( r, bgColor ); 344 p->fillRect( r, bgColor );
344 } 345 }
345} 346}
346 347
347void LauncherIconView::addCatsAndMimes(AppLnk* app) 348void LauncherIconView::addCatsAndMimes(AppLnk* app)
348 { 349 {
349 // QStringList c = app->categories(); 350 // QStringList c = app->categories();
350 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 351 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
351 // cats.replace(*cit,(void*)1); 352 // cats.replace(*cit,(void*)1);
352 // } 353 // }
353 QString maj=app->type(); 354 QString maj=app->type();
354 int sl=maj.find('/'); 355 int sl=maj.find('/');
355 if (sl>=0) { 356 if (sl>=0) {
356 QString k; 357 QString k;
357 k = maj.left(12) == "application/" ? maj : maj.left(sl); 358 k = maj.left(12) == "application/" ? maj : maj.left(sl);
358 mimes.replace(k,(void*)1); 359 mimes.replace(k,(void*)1);
359 } 360 }
360} 361}
361 362
362void LauncherIconView::setBusy(bool on) 363void LauncherIconView::setBusy(bool on)
363{ 364{
364#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 365#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
365 if ( busyPix.isNull() ) { 366 if ( busyPix.isNull() ) {
366 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 367 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
367 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); 368 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
368 } 369 }
369#endif 370#endif
370 371
371 if ( on ) { 372 if ( on ) {
372 busyTimer = startTimer( 100 ); 373 busyTimer = startTimer( 100 );
373 } else { 374 } else {
374 if ( busyTimer ) { 375 if ( busyTimer ) {
375 killTimer( busyTimer ); 376 killTimer( busyTimer );
376 busyTimer = 0; 377 busyTimer = 0;
377 } 378 }
378 } 379 }
379 380
380 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; 381 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
381 382
382 if ( bsy != c ) { 383 if ( bsy != c ) {
383 LauncherItem *oldBusy = bsy; 384 LauncherItem *oldBusy = bsy;
384 bsy = c; 385 bsy = c;
385 if ( oldBusy ) { 386 if ( oldBusy ) {
386 oldBusy->resetIcon(); 387 oldBusy->resetIcon();
387 } 388 }
388 if ( bsy ) { 389 if ( bsy ) {
389 bsy->setBusyIndicatorType( busyType ) ; 390 bsy->setBusyIndicatorType( busyType ) ;
390 bsy->animateIcon(); 391 bsy->animateIcon();
391 } 392 }
392 } 393 }
393} 394}
394 395
395void LauncherIconView::clear() 396void LauncherIconView::clear()
396{ 397{
397 mimes.clear(); 398 mimes.clear();
398 cats.clear(); 399 cats.clear();
399 QIconView::clear(); 400 QIconView::clear();
400 hidden.clear(); 401 hidden.clear();
401} 402}
402 403
403QStringList LauncherIconView::mimeTypes() const 404QStringList LauncherIconView::mimeTypes() const
404{ 405{
405 QStringList r; 406 QStringList r;
406 QDictIterator<void> it(mimes); 407 QDictIterator<void> it(mimes);
407 while (it.current()) { 408 while (it.current()) {
408 r.append(it.currentKey()); 409 r.append(it.currentKey());
409 ++it; 410 ++it;
410 } 411 }
411 r.sort(); 412 r.sort();
412 return r; 413 return r;
413} 414}
414 415
415LauncherItem*LauncherIconView::findDocItem(const QString&fname) 416LauncherItem*LauncherIconView::findDocItem(const QString&fname)
416{ 417{
417 LauncherItem* item = (LauncherItem*)firstItem(); 418 LauncherItem* item = (LauncherItem*)firstItem();
418 while (item) { 419 while (item) {
419 if (item->appLnk()->file()==fname) { 420 if (item->appLnk()->file()==fname) {
420 break; 421 break;
421 } 422 }
422 item = (LauncherItem*)item->nextItem(); 423 item = (LauncherItem*)item->nextItem();
423 } 424 }
424 return item; 425 return item;
425} 426}
426 427
427void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) 428void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
428{ 429{
429 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 430 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
430 if (s!=width) return; 431 if (s!=width) return;
431 LauncherItem*item = findDocItem(aFile); 432 LauncherItem*item = findDocItem(aFile);
432 if (!item||!item->isEyeImage()) return; 433 if (!item||!item->isEyeImage()) return;
433 item->setEyePixmap(aPixmap); 434 item->setEyePixmap(aPixmap);
434} 435}
435 436
436void LauncherIconView::checkCallback() 437void LauncherIconView::checkCallback()
437{ 438{
438 if (m_EyeCallBack) { 439 if (m_EyeCallBack) {
439 return; 440 return;
440 } 441 }
441 m_EyeCallBack = new LauncherThumbReceiver(); 442 m_EyeCallBack = new LauncherThumbReceiver();
442 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 443 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
443 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 444 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
444} 445}
445 446
446void LauncherIconView::addCheckItem(AppLnk* app) 447void LauncherIconView::addCheckItem(AppLnk* app)
447{ 448{
448 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 449 LauncherItem*item = new LauncherItem( this, app, bigIcns );
449 if (item->isEyeImage()) { 450 if (item->isEyeImage()) {
450 checkCallback(); 451 checkCallback();
451 } 452 }
452} 453}
453 454
454void LauncherIconView::requestEyePix(const LauncherItem*item) 455void LauncherIconView::requestEyePix(const LauncherItem*item)
455{ 456{
456 if (!item) return; 457 if (!item) return;
457 if (item->isEyeImage()) { 458 if (item->isEyeImage()) {
459 m_eyeTimer.changeInterval(600000);
458 checkCallback(); 460 checkCallback();
459 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 461 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
460 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); 462 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
461 } 463 }
462} 464}
463 465
466void LauncherIconView::stopEyeTimer()
467{
468 odebug << "Launcherview: delete opie-eye handle" << oendl;
469 if (m_EyeCallBack) {
470 delete m_EyeCallBack;
471 m_EyeCallBack=0;
472 }
473 m_eyeTimer.stop();
474}
475
464void LauncherIconView::addItem(AppLnk* app, bool resort) 476void LauncherIconView::addItem(AppLnk* app, bool resort)
465{ 477{
466 addCatsAndMimes(app); 478 addCatsAndMimes(app);
467 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 479 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
468 && (cf == 0 || app->categories().contains(cf) 480 && (cf == 0 || app->categories().contains(cf)
469 || cf == -1 && app->categories().count() == 0 ) ) { 481 || cf == -1 && app->categories().count() == 0 ) ) {
470 addCheckItem(app); 482 addCheckItem(app);
471 } else { 483 } else {
472 hidden.append(app); 484 hidden.append(app);
473 } 485 }
474 if ( resort ){ 486 if ( resort ){
475 sort(); 487 sort();
476 } 488 }
477} 489}
478 490
479void LauncherIconView::updateCategoriesAndMimeTypes() 491void LauncherIconView::updateCategoriesAndMimeTypes()
480{ 492{
481 mimes.clear(); 493 mimes.clear();
482 cats.clear(); 494 cats.clear();
483 LauncherItem* item = (LauncherItem*)firstItem(); 495 LauncherItem* item = (LauncherItem*)firstItem();
484 while (item) { 496 while (item) {
485 addCatsAndMimes(item->appLnk()); 497 addCatsAndMimes(item->appLnk());
486 item = (LauncherItem*)item->nextItem(); 498 item = (LauncherItem*)item->nextItem();
487 } 499 }
488 QListIterator<AppLnk> it(hidden); 500 QListIterator<AppLnk> it(hidden);
489 AppLnk* l; 501 AppLnk* l;
490 while ((l=it.current())) { 502 while ((l=it.current())) {
491 addCatsAndMimes(l); 503 addCatsAndMimes(l);
492 ++it; 504 ++it;
493 } 505 }
494} 506}
495 507
496void LauncherIconView::hideOrShowItems(bool resort) 508void LauncherIconView::hideOrShowItems(bool resort)
497{ 509{
498 viewport()->setUpdatesEnabled( FALSE ); 510 viewport()->setUpdatesEnabled( FALSE );
499 hidden.setAutoDelete(FALSE); 511 hidden.setAutoDelete(FALSE);
500 QList<AppLnk> links=hidden; 512 QList<AppLnk> links=hidden;
501 hidden.clear(); 513 hidden.clear();
502 hidden.setAutoDelete(TRUE); 514 hidden.setAutoDelete(TRUE);
503 LauncherItem* item = (LauncherItem*)firstItem(); 515 LauncherItem* item = (LauncherItem*)firstItem();
504 while (item) { 516 while (item) {
505 links.append(item->takeAppLnk()); 517 links.append(item->takeAppLnk());
506 item = (LauncherItem*)item->nextItem(); 518 item = (LauncherItem*)item->nextItem();
507 } 519 }
508 clear(); 520 clear();
509 QListIterator<AppLnk> it(links); 521 QListIterator<AppLnk> it(links);
510 AppLnk* l; 522 AppLnk* l;
511 while ((l=it.current())) { 523 while ((l=it.current())) {
512 addItem(l,FALSE); 524 addItem(l,FALSE);
513 ++it; 525 ++it;
514 } 526 }
515 if ( resort && !autoArrange() ) 527 if ( resort && !autoArrange() )
516 sort(); 528 sort();
517 viewport()->setUpdatesEnabled( TRUE ); 529 viewport()->setUpdatesEnabled( TRUE );
518} 530}
519 531
520bool LauncherIconView::removeLink(const QString& linkfile) 532bool LauncherIconView::removeLink(const QString& linkfile)
521{ 533{
522 LauncherItem* item = (LauncherItem*)firstItem(); 534 LauncherItem* item = (LauncherItem*)firstItem();
523 AppLnk* l; 535 AppLnk* l;
524 bool did = FALSE; 536 bool did = FALSE;
525 DocLnk dl(linkfile); 537 DocLnk dl(linkfile);
526 while (item) { 538 while (item) {
527 l = item->appLnk(); 539 l = item->appLnk();
528 LauncherItem *nextItem = (LauncherItem *)item->nextItem(); 540 LauncherItem *nextItem = (LauncherItem *)item->nextItem();
529 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && 541 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() &&
530 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { 542 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) {
531 delete item; 543 delete item;
532 did = TRUE; 544 did = TRUE;
533 } 545 }
534 item = nextItem; 546 item = nextItem;
535 } 547 }
536 QListIterator<AppLnk> it(hidden); 548 QListIterator<AppLnk> it(hidden);
537 while ((l=it.current())) { 549 while ((l=it.current())) {
538 ++it; 550 ++it;
539 if ( l->linkFileKnown() && l->linkFile() == linkfile 551 if ( l->linkFileKnown() && l->linkFile() == linkfile
540 || l->file() == linkfile 552 || l->file() == linkfile
541 || dl.isValid() && dl.file() == l->file() ) { 553 || dl.isValid() && dl.file() == l->file() ) {
542 hidden.removeRef(l); 554 hidden.removeRef(l);
543 did = TRUE; 555 did = TRUE;
544 } 556 }
545 } 557 }
546 return did; 558 return did;
547} 559}
548 560
549void LauncherIconView::timerEvent( QTimerEvent *te ) 561void LauncherIconView::timerEvent( QTimerEvent *te )
550{ 562{
551 if ( te->timerId() == busyTimer ) { 563 if ( te->timerId() == busyTimer ) {
552 if ( bsy ) 564 if ( bsy )
553 bsy->animateIcon(); 565 bsy->animateIcon();
554 } else { 566 } else {
555 QIconView::timerEvent( te ); 567 QIconView::timerEvent( te );
556 } 568 }
557} 569}
558 570
559void LauncherIconView::setBigIcons( bool bi ) 571void LauncherIconView::setBigIcons( bool bi )
560{ 572{
561 bigIcns = bi; 573 bigIcns = bi;
562#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 574#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
563 busyPix.resize(0,0); 575 busyPix.resize(0,0);
564#endif 576#endif
565} 577}
566 578
567QIconViewItem* LauncherIconView::busyItem() const 579QIconViewItem* LauncherIconView::busyItem() const
568{ 580{
569 return bsy; 581 return bsy;
570} 582}
571 583
572void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 584void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
573 585
574void LauncherIconView::calculateGrid( ItemTextPos pos ) 586void LauncherIconView::calculateGrid( ItemTextPos pos )
575{ 587{
576 int dw = QApplication::desktop()->width(); 588 int dw = QApplication::desktop()->width();
577 int viewerWidth = dw-style().scrollBarExtent().width(); 589 int viewerWidth = dw-style().scrollBarExtent().width();
578 if ( pos == Bottom ) { 590 if ( pos == Bottom ) {
579 int cols = 3; 591 int cols = 3;
580 if ( viewerWidth <= 200 ) 592 if ( viewerWidth <= 200 )
581 cols = 2; 593 cols = 2;
582 else if ( viewerWidth >= 400 ) 594 else if ( viewerWidth >= 400 )
583 cols = viewerWidth/96; 595 cols = viewerWidth/96;
584 setSpacing( 4 ); 596 setSpacing( 4 );
585 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 597 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
586 setGridY( fontMetrics().height()*2+24 ); 598 setGridY( fontMetrics().height()*2+24 );
587 } else { 599 } else {
588 int cols = 2; 600 int cols = 2;
589 if ( viewerWidth < 150 ) 601 if ( viewerWidth < 150 )
590 cols = 1; 602 cols = 1;
591 else if ( viewerWidth >= 400 ) 603 else if ( viewerWidth >= 400 )
592 cols = viewerWidth/150; 604 cols = viewerWidth/150;
593 setSpacing( 2 ); 605 setSpacing( 2 );
594 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 606 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
595 setGridY( fontMetrics().height()+2 ); 607 setGridY( fontMetrics().height()+2 );
596 } 608 }
597} 609}
598 610
599void LauncherIconView::styleChange( QStyle &old ) 611void LauncherIconView::styleChange( QStyle &old )
600{ 612{
601 QIconView::styleChange( old ); 613 QIconView::styleChange( old );
602 calculateGrid( itemTextPos() ); 614 calculateGrid( itemTextPos() );
603} 615}
616
617void LauncherIconView::keyPressEvent(QKeyEvent* e)
618{
619 ike = TRUE;
620 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) {
621 if ( (e->state() & ShiftButton) )
622 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() );
623 else
624 returnPressed(currentItem());
625 }
626
627 QIconView::keyPressEvent(e);
628 ike = FALSE;
629}
630
604//=========================================================================== 631//===========================================================================
605// Implemantation of LauncherIconview end 632// Implemantation of LauncherIconview end
606//=========================================================================== 633//===========================================================================
607 634
608 635
609//=========================================================================== 636//===========================================================================
610LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 637LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
611 : QVBox( parent, name, fl ) 638 : QVBox( parent, name, fl )
612{ 639{
613 catmb = 0; 640 catmb = 0;
614 icons = new LauncherIconView( this ); 641 icons = new LauncherIconView( this );
615 setFocusProxy(icons); 642 setFocusProxy(icons);
616 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 643 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
617 644
618 icons->setItemsMovable( FALSE ); 645 icons->setItemsMovable( FALSE );
619 icons->setAutoArrange( TRUE ); 646 icons->setAutoArrange( TRUE );
620 icons->setSorting( TRUE ); 647 icons->setSorting( TRUE );
621 icons->setFrameStyle( QFrame::NoFrame ); 648 icons->setFrameStyle( QFrame::NoFrame );
622 icons->setMargin( 0 ); 649 icons->setMargin( 0 );
623 icons->setSelectionMode( QIconView::NoSelection ); 650 icons->setSelectionMode( QIconView::NoSelection );
624 icons->setBackgroundMode( PaletteBase ); 651 icons->setBackgroundMode( PaletteBase );
625 icons->setResizeMode( QIconView::Fixed ); 652 icons->setResizeMode( QIconView::Fixed );
626 vmode = (ViewMode)-1; 653 vmode = (ViewMode)-1;
627 setViewMode( Icon ); 654 setViewMode( Icon );
628 655
629 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 656 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
630 SLOT(itemClicked(int,QIconViewItem*)) ); 657 SLOT(itemClicked(int,QIconViewItem*)) );
631 connect( icons, SIGNAL(selectionChanged()), 658 connect( icons, SIGNAL(selectionChanged()),
632 SLOT(selectionChanged()) ); 659 SLOT(selectionChanged()) );
633 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 660 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
634 SLOT(returnPressed(QIconViewItem*)) ); 661 SLOT(returnPressed(QIconViewItem*)) );
635 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 662 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
636 SLOT(itemPressed(int,QIconViewItem*)) ); 663 SLOT(itemPressed(int,QIconViewItem*)) );
637 664
638 tools = 0; 665 tools = 0;
639 setBackgroundType( Ruled, QString::null ); 666 setBackgroundType( Ruled, QString::null );
640} 667}
641 668
642LauncherView::~LauncherView() 669LauncherView::~LauncherView()
643{ 670{
644 if ( bgCache && bgCache->contains( bgName ) ) 671 if ( bgCache && bgCache->contains( bgName ) )
645 (*bgCache)[bgName]->ref--; 672 (*bgCache)[bgName]->ref--;
646} 673}
647 674
648 675
649bool LauncherView::bsy=FALSE; 676bool LauncherView::bsy=FALSE;
650 677
651void LauncherView::setBusy(bool on) 678void LauncherView::setBusy(bool on)
652{ 679{
653 icons->setBusy(on); 680 icons->setBusy(on);
654} 681}
655 682
656void LauncherView::setBusyIndicatorType( const QString& type ) { 683void LauncherView::setBusyIndicatorType( const QString& type ) {
657 if ( type. lower ( ) == "animated" ) 684 if ( type. lower ( ) == "animated" )
658 icons->setBusyIndicatorType( BIT_Animated ) ; 685 icons->setBusyIndicatorType( BIT_Animated ) ;
659 else 686 else
660 icons->setBusyIndicatorType( BIT_Normal ) ; 687 icons->setBusyIndicatorType( BIT_Normal ) ;
661} 688}
662 689
663void LauncherView::hideIcons() 690void LauncherView::hideIcons()
664{ 691{
665 icons->hide(); 692 icons->hide();
666} 693}
667 694
668void LauncherView::setToolsEnabled(bool y) 695void LauncherView::setToolsEnabled(bool y)
669{ 696{
670 if ( !y != !tools ) { 697 if ( !y != !tools ) {
671 if ( y ) { 698 if ( y ) {
672 tools = new QHBox(this); 699 tools = new QHBox(this);
673 700
674 // Type filter 701 // Type filter
675 typemb = new QComboBox(tools); 702 typemb = new QComboBox(tools);
676 QSizePolicy p = typemb->sizePolicy(); 703 QSizePolicy p = typemb->sizePolicy();
677 p.setHorData(QSizePolicy::Expanding); 704 p.setHorData(QSizePolicy::Expanding);
678 typemb->setSizePolicy(p); 705 typemb->setSizePolicy(p);
679 706
680 // Category filter 707 // Category filter
681 updateTools(); 708 updateTools();
682 tools->show(); 709 tools->show();
683 710
684 } else { 711 } else {
685 delete tools; 712 delete tools;
686 tools = 0; 713 tools = 0;
687 } 714 }
688 } 715 }
689} 716}
690 717
691void LauncherView::updateTools() 718void LauncherView::updateTools()
692{ 719{
693 disconnect( typemb, SIGNAL(activated(int)), 720 disconnect( typemb, SIGNAL(activated(int)),
694 this, SLOT(showType(int)) ); 721 this, SLOT(showType(int)) );
695 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), 722 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)),
696 this, SLOT(showCategory(int)) ); 723 this, SLOT(showCategory(int)) );
697 724
698 // ### I want to remove this 725 // ### I want to remove this
699 icons->updateCategoriesAndMimeTypes(); 726 icons->updateCategoriesAndMimeTypes();
@@ -1030,119 +1057,118 @@ void LauncherView::setSortEnabled( bool v )
1030void LauncherView::setUpdatesEnabled( bool u ) 1057void LauncherView::setUpdatesEnabled( bool u )
1031{ 1058{
1032 icons->setUpdatesEnabled( u ); 1059 icons->setUpdatesEnabled( u );
1033} 1060}
1034 1061
1035void LauncherView::sort() 1062void LauncherView::sort()
1036{ 1063{
1037 icons->sort(); 1064 icons->sort();
1038} 1065}
1039 1066
1040void LauncherView::addItem(AppLnk* app, bool resort) 1067void LauncherView::addItem(AppLnk* app, bool resort)
1041{ 1068{
1042 icons->addItem(app,resort); 1069 icons->addItem(app,resort);
1043} 1070}
1044 1071
1045void LauncherView::paletteChange( const QPalette &p ) 1072void LauncherView::paletteChange( const QPalette &p )
1046{ 1073{
1047 icons->unsetPalette(); 1074 icons->unsetPalette();
1048 QVBox::paletteChange( p ); 1075 QVBox::paletteChange( p );
1049 if ( bgType == Ruled ) 1076 if ( bgType == Ruled )
1050 setBackgroundType( Ruled, QString::null ); 1077 setBackgroundType( Ruled, QString::null );
1051 QColorGroup cg = icons->colorGroup(); 1078 QColorGroup cg = icons->colorGroup();
1052 cg.setColor( QColorGroup::Text, textCol ); 1079 cg.setColor( QColorGroup::Text, textCol );
1053 icons->setPalette( QPalette(cg,cg,cg) ); 1080 icons->setPalette( QPalette(cg,cg,cg) );
1054} 1081}
1055 1082
1056void LauncherView::fontChanged(const QFont&) 1083void LauncherView::fontChanged(const QFont&)
1057{ 1084{
1058 odebug << "LauncherView::fontChanged()" << oendl; 1085 odebug << "LauncherView::fontChanged()" << oendl;
1059 icons->hideOrShowItems( FALSE ); 1086 icons->hideOrShowItems( FALSE );
1060} 1087}
1061 1088
1062void LauncherView::relayout(void) 1089void LauncherView::relayout(void)
1063{ 1090{
1064 icons->hideOrShowItems(FALSE); 1091 icons->hideOrShowItems(FALSE);
1065} 1092}
1066 1093
1067void LauncherView::flushBgCache() 1094void LauncherView::flushBgCache()
1068{ 1095{
1069 if ( !bgCache ) 1096 if ( !bgCache )
1070 return; 1097 return;
1071 // remove unreferenced backgrounds. 1098 // remove unreferenced backgrounds.
1072 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1099 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1073 while ( it != bgCache->end() ) { 1100 while ( it != bgCache->end() ) {
1074 QMap<QString,BgPixmap*>::Iterator curr = it; 1101 QMap<QString,BgPixmap*>::Iterator curr = it;
1075 ++it; 1102 ++it;
1076 if ( (*curr)->ref == 0 ) { 1103 if ( (*curr)->ref == 0 ) {
1077 delete (*curr); 1104 delete (*curr);
1078 bgCache->remove( curr ); 1105 bgCache->remove( curr );
1079 } 1106 }
1080 } 1107 }
1081} 1108}
1082 1109
1083/* 1110/*
1084 * Launcherthumbnail handling for image files 1111 * Launcherthumbnail handling for image files
1085 */ 1112 */
1086 1113
1087/* special image handling - based on opie eye */ 1114/* special image handling - based on opie eye */
1088QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 1115QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1089 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 1116 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1090 return s; 1117 return s;
1091} 1118}
1092 1119
1093QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 1120QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1094 return s << inf.file << inf.width << inf.height; 1121 return s << inf.file << inf.width << inf.height;
1095} 1122}
1096 1123
1097LauncherThumbReceiver::LauncherThumbReceiver() 1124LauncherThumbReceiver::LauncherThumbReceiver()
1098 :QObject() 1125 :QObject()
1099{ 1126{
1100 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); 1127 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1101 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 1128 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1102 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 1129 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1103 1130
1104 { 1131 {
1105 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 1132 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1106 } 1133 }
1107} 1134}
1108 1135
1109LauncherThumbReceiver::~LauncherThumbReceiver() 1136LauncherThumbReceiver::~LauncherThumbReceiver()
1110{ 1137{
1111 { 1138 {
1112 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 1139 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1113 } 1140 }
1114} 1141}
1115 1142
1116void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) 1143void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1117{ 1144{
1118 PixmapInfos pixinfos; 1145 PixmapInfos pixinfos;
1119 QDataStream stream( at, IO_ReadOnly ); 1146 QDataStream stream( at, IO_ReadOnly );
1120 1147
1121 /* we are just interested in thumbmails */ 1148 /* we are just interested in thumbmails */
1122 if ( str == "pixmapsHandled(PixmapList)" ) 1149 if ( str == "pixmapsHandled(PixmapList)" )
1123 stream >> pixinfos; 1150 stream >> pixinfos;
1124 1151
1125 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { 1152 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1126 odebug << "Pixinfos: " << (*it).file << " - " << (*it).width << oendl;
1127 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); 1153 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
1128 } 1154 }
1129} 1155}
1130 1156
1131void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) 1157void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1132{ 1158{
1133 PixmapInfo rItem; 1159 PixmapInfo rItem;
1134 rItem.file = file; 1160 rItem.file = file;
1135 rItem.width = width; 1161 rItem.width = width;
1136 rItem.height = height; 1162 rItem.height = height;
1137 m_inThumbNail.append(rItem); 1163 m_inThumbNail.append(rItem);
1138 QTimer::singleShot(0, this, SLOT(sendRequest())); 1164 QTimer::singleShot(0, this, SLOT(sendRequest()));
1139} 1165}
1140 1166
1141void LauncherThumbReceiver::sendRequest() 1167void LauncherThumbReceiver::sendRequest()
1142{ 1168{
1143 if (m_inThumbNail.count()>0) { 1169 if (m_inThumbNail.count()>0) {
1144 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); 1170 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1145 env << m_inThumbNail; 1171 env << m_inThumbNail;
1146 m_inThumbNail.clear(); 1172 m_inThumbNail.clear();
1147 } 1173 }
1148} 1174}
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 0be9a1f..ebb1362 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -1,254 +1,244 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LAUNCHERVIEW_H 20#ifndef LAUNCHERVIEW_H
21#define LAUNCHERVIEW_H 21#define LAUNCHERVIEW_H
22 22
23#include <qtopia/storage.h> 23#include <qtopia/storage.h>
24#include <qtopia/applnk.h> 24#include <qtopia/applnk.h>
25 25
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qiconview.h> 27#include <qiconview.h>
28#include <qtimer.h>
28 29
29class CategorySelect; 30class CategorySelect;
30class LauncherIconView; 31class LauncherIconView;
31class LauncherItem; 32class LauncherItem;
32class QIconViewItem; 33class QIconViewItem;
33class QLabel; 34class QLabel;
34class QWidgetStack; 35class QWidgetStack;
35class MenuButton; 36class MenuButton;
36class QComboBox; 37class QComboBox;
37 38
38 39
39 40
40enum BusyIndicatorType { 41enum BusyIndicatorType {
41 BIT_Normal = 0, 42 BIT_Normal = 0,
42 BIT_Animated 43 BIT_Animated
43}; 44};
44 45
45class LauncherView : public QVBox 46class LauncherView : public QVBox
46{ 47{
47 Q_OBJECT 48 Q_OBJECT
48 49
49public: 50public:
50 LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 51 LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
51 ~LauncherView(); 52 ~LauncherView();
52 53
53 void hideIcons(); 54 void hideIcons();
54 55
55 bool removeLink(const QString& linkfile); 56 bool removeLink(const QString& linkfile);
56 void addItem(AppLnk* app, bool resort=TRUE); 57 void addItem(AppLnk* app, bool resort=TRUE);
57 void removeAllItems(); 58 void removeAllItems();
58 void setSortEnabled(bool); 59 void setSortEnabled(bool);
59 void setUpdatesEnabled(bool); 60 void setUpdatesEnabled(bool);
60 void sort(); 61 void sort();
61 62
62 void setToolsEnabled(bool); 63 void setToolsEnabled(bool);
63 void updateTools(); 64 void updateTools();
64 65
65 void setBusy(bool); 66 void setBusy(bool);
66 void setBusyIndicatorType( const QString& ); 67 void setBusyIndicatorType( const QString& );
67 68
68 enum ViewMode { Icon, List }; 69 enum ViewMode { Icon, List };
69 void setViewMode( ViewMode m ); 70 void setViewMode( ViewMode m );
70 ViewMode viewMode() const { return vmode; } 71 ViewMode viewMode() const { return vmode; }
71 72
72 enum BackgroundType { Ruled, SolidColor, Image }; 73 enum BackgroundType { Ruled, SolidColor, Image };
73 void setBackgroundType( BackgroundType t, const QString & ); 74 void setBackgroundType( BackgroundType t, const QString & );
74 BackgroundType backgroundType() const { return bgType; } 75 BackgroundType backgroundType() const { return bgType; }
75 76
76 void setTextColor( const QColor & ); 77 void setTextColor( const QColor & );
77 QColor textColor() const { return textCol; } 78 QColor textColor() const { return textCol; }
78 79
79 void setViewFont( const QFont & ); 80 void setViewFont( const QFont & );
80 void clearViewFont(); 81 void clearViewFont();
81 82
82 void relayout(void); 83 void relayout(void);
83 84
84signals: 85signals:
85 void clicked( const AppLnk * ); 86 void clicked( const AppLnk * );
86 void rightPressed( AppLnk * ); 87 void rightPressed( AppLnk * );
87 88
88protected slots: 89protected slots:
89 void selectionChanged(); 90 void selectionChanged();
90 void returnPressed( QIconViewItem *item ); 91 void returnPressed( QIconViewItem *item );
91 void itemClicked( int, QIconViewItem * ); 92 void itemClicked( int, QIconViewItem * );
92 void itemPressed( int, QIconViewItem * ); 93 void itemPressed( int, QIconViewItem * );
93 void sortBy(int); 94 void sortBy(int);
94 void showType(int); 95 void showType(int);
95 void showCategory( int ); 96 void showCategory( int );
96 void resizeEvent(QResizeEvent *); 97 void resizeEvent(QResizeEvent *);
97 void flushBgCache(); 98 void flushBgCache();
98 99
99protected: 100protected:
100 void paletteChange( const QPalette & ); 101 void paletteChange( const QPalette & );
101 102
102 void fontChanged(const QFont &); 103 void fontChanged(const QFont &);
103 104
104private: 105private:
105 static bool bsy; 106 static bool bsy;
106 QWidget* tools; 107 QWidget* tools;
107 LauncherIconView* icons; 108 LauncherIconView* icons;
108 QComboBox *typemb; 109 QComboBox *typemb;
109 QStringList typelist; 110 QStringList typelist;
110 CategorySelect *catmb; 111 CategorySelect *catmb;
111 ViewMode vmode; 112 ViewMode vmode;
112 BackgroundType bgType; 113 BackgroundType bgType;
113 QString bgName; 114 QString bgName;
114 QColor textCol; 115 QColor textCol;
115 116
116 QImage loadBackgroundImage(QString &fname); 117 QImage loadBackgroundImage(QString &fname);
117 118
118}; 119};
119 120
120/* from opie-eye */ 121/* from opie-eye */
121struct PixmapInfo { 122struct PixmapInfo {
122 PixmapInfo() : width( -1 ), height( -1 ) {} 123 PixmapInfo() : width( -1 ), height( -1 ) {}
123 bool operator==( const PixmapInfo& r ) { 124 bool operator==( const PixmapInfo& r ) {
124 if ( width != r.width ) return false; 125 if ( width != r.width ) return false;
125 if ( height != r.height ) return false; 126 if ( height != r.height ) return false;
126 if ( file != r.file ) return false; 127 if ( file != r.file ) return false;
127 return true; 128 return true;
128 } 129 }
129 int width, height; 130 int width, height;
130 QString file; 131 QString file;
131 QPixmap pixmap; 132 QPixmap pixmap;
132}; 133};
133 134
134class LauncherThumbReceiver:public QObject 135class LauncherThumbReceiver:public QObject
135{ 136{
136 Q_OBJECT 137 Q_OBJECT
137 typedef QValueList<PixmapInfo> PixmapInfos; 138 typedef QValueList<PixmapInfo> PixmapInfos;
138public: 139public:
139 LauncherThumbReceiver(); 140 LauncherThumbReceiver();
140 ~LauncherThumbReceiver(); 141 ~LauncherThumbReceiver();
141 void requestThumb(const QString&file,int width,int height); 142 void requestThumb(const QString&file,int width,int height);
142 143
143public slots: 144public slots:
144 void recieve( const QCString&, const QByteArray& ); 145 void recieve( const QCString&, const QByteArray& );
145protected slots: 146protected slots:
146 virtual void sendRequest(); 147 virtual void sendRequest();
147 148
148signals: 149signals:
149 void sig_Thumbnail(const QPixmap&,const QString&,int); 150 void sig_Thumbnail(const QPixmap&,const QString&,int);
150 151
151protected: 152protected:
152 PixmapInfos m_inThumbNail; 153 PixmapInfos m_inThumbNail;
153}; 154};
154 155
155class LauncherIconView : public QIconView { 156class LauncherIconView : public QIconView {
156 Q_OBJECT 157 Q_OBJECT
157public: 158public:
158 LauncherIconView( QWidget* parent, const char* name=0 ); 159 LauncherIconView( QWidget* parent, const char* name=0 );
159 ~LauncherIconView(); 160 ~LauncherIconView();
160 QIconViewItem* busyItem() const; 161 QIconViewItem* busyItem() const;
161 162
162#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 163#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
163 QPixmap busyPixmap() const { return busyPix; } 164 QPixmap busyPixmap() const { return busyPix; }
164#endif 165#endif
165 void setBigIcons( bool bi ); 166 void setBigIcons( bool bi );
166 void updateCategoriesAndMimeTypes(); 167 void updateCategoriesAndMimeTypes();
167 void setBusyIndicatorType ( BusyIndicatorType t ); 168 void setBusyIndicatorType ( BusyIndicatorType t );
168 void doAutoScroll() 169 void doAutoScroll()
169 { 170 {
170 // We don't want rubberbanding (yet) 171 // We don't want rubberbanding (yet)
171 } 172 }
172 173
173 void setBusy(bool on); 174 void setBusy(bool on);
174 bool inKeyEvent() const { return ike; } 175 bool inKeyEvent() const { return ike; }
175 176
176 void keyPressEvent(QKeyEvent* e)
177 {
178 ike = TRUE;
179 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) {
180 if ( (e->state() & ShiftButton) )
181 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() );
182 else
183 returnPressed(currentItem());
184 }
185
186 QIconView::keyPressEvent(e);
187 ike = FALSE;
188 }
189
190 void addItem(AppLnk* app, bool resort=TRUE); 177 void addItem(AppLnk* app, bool resort=TRUE);
191 bool removeLink(const QString& linkfile); 178 bool removeLink(const QString& linkfile);
192 179
193 QStringList mimeTypes() const; 180 QStringList mimeTypes() const;
194 QStringList categories() const; 181 QStringList categories() const;
195 void clear(); 182 void clear();
196 void addCatsAndMimes(AppLnk* app); 183 void addCatsAndMimes(AppLnk* app);
197 184
198 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} 185 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {}
199 186
200 void setBackgroundPixmap( const QPixmap &pm ) { 187 void setBackgroundPixmap( const QPixmap &pm ) {
201 bgPixmap = pm; 188 bgPixmap = pm;
202 } 189 }
203 190
204 void setBackgroundColor( const QColor &c ) { 191 void setBackgroundColor( const QColor &c ) {
205 bgColor = c; 192 bgColor = c;
206 } 193 }
207 194
208 void drawBackground( QPainter *p, const QRect &r ); 195 void drawBackground( QPainter *p, const QRect &r );
209 void setItemTextPos( ItemTextPos pos ); 196 void setItemTextPos( ItemTextPos pos );
210 void hideOrShowItems(bool resort); 197 void hideOrShowItems(bool resort);
211 198
212 void setTypeFilter(const QString& typefilter, bool resort); 199 void setTypeFilter(const QString& typefilter, bool resort);
213 void setCategoryFilter( int catfilter, bool resort ); 200 void setCategoryFilter( int catfilter, bool resort );
214 201
215 enum SortMethod { Name, Date, Type }; 202 enum SortMethod { Name, Date, Type };
216 203
217 void setSortMethod( SortMethod m ); 204 void setSortMethod( SortMethod m );
218 int compare(const AppLnk* a, const AppLnk* b); 205 int compare(const AppLnk* a, const AppLnk* b);
219 void requestEyePix(const LauncherItem*which); 206 void requestEyePix(const LauncherItem*which);
220 207
221protected: 208protected:
222 void timerEvent( QTimerEvent *te ); 209 virtual void timerEvent( QTimerEvent *te );
223 void styleChange( QStyle &old ); 210 void styleChange( QStyle &old );
224 void calculateGrid( ItemTextPos pos ); 211 void calculateGrid( ItemTextPos pos );
225 void focusInEvent( QFocusEvent * ) {} 212 void focusInEvent( QFocusEvent * ) {}
226 void focusOutEvent( QFocusEvent * ) {} 213 void focusOutEvent( QFocusEvent * ) {}
227 LauncherItem*findDocItem(const QString&); 214 LauncherItem*findDocItem(const QString&);
228 void addCheckItem(AppLnk* app); 215 void addCheckItem(AppLnk* app);
229 void checkCallback(); 216 void checkCallback();
217 virtual void keyPressEvent(QKeyEvent* e);
230 218
231protected slots: 219protected slots:
232 void setEyePixmap(const QPixmap&,const QString&,int width); 220 void setEyePixmap(const QPixmap&,const QString&,int width);
221 void stopEyeTimer();
233 222
234private: 223private:
235 QList<AppLnk> hidden; 224 QList<AppLnk> hidden;
236 QDict<void> mimes; 225 QDict<void> mimes;
237 QDict<void> cats; 226 QDict<void> cats;
238 SortMethod sortmeth; 227 SortMethod sortmeth;
239 QRegExp tf; 228 QRegExp tf;
240 int cf; 229 int cf;
241 LauncherItem* bsy; 230 LauncherItem* bsy;
242 int busyTimer; 231 int busyTimer;
243 bool ike; 232 bool ike;
244 bool bigIcns; 233 bool bigIcns;
245 QPixmap bgPixmap; 234 QPixmap bgPixmap;
246 QColor bgColor; 235 QColor bgColor;
247 LauncherThumbReceiver*m_EyeCallBack; 236 LauncherThumbReceiver*m_EyeCallBack;
248#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 237#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
249 QPixmap busyPix; 238 QPixmap busyPix;
250#endif 239#endif
251 BusyIndicatorType busyType; 240 BusyIndicatorType busyType;
241 QTimer m_eyeTimer;
252}; 242};
253 243
254#endif // LAUNCHERVIEW_H 244#endif // LAUNCHERVIEW_H