summaryrefslogtreecommitdiff
authorsandman <sandman>2002-09-27 00:59:52 (UTC)
committer sandman <sandman>2002-09-27 00:59:52 (UTC)
commitac99721b91f3c61d37236932a5d0f6bc09caaa54 (patch) (unidiff)
treee8397c2fd2636452485c5192bbe8166052d08df9
parent6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d (diff)
downloadopie-ac99721b91f3c61d37236932a5d0f6bc09caaa54.zip
opie-ac99721b91f3c61d37236932a5d0f6bc09caaa54.tar.gz
opie-ac99721b91f3c61d37236932a5d0f6bc09caaa54.tar.bz2
- fixed bg image location
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 047fe45..c2bde53 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -322,544 +322,544 @@ public:
322 if ( liv->currentItem() == this ) { 322 if ( liv->currentItem() == this ) {
323 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 323 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
324 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 324 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
325 } 325 }
326 QIconViewItem::paintItem(p,mycg); 326 QIconViewItem::paintItem(p,mycg);
327 if ( liv->currentItem() == this ) 327 if ( liv->currentItem() == this )
328 liv->setItemTextBackground( oldBrush ); 328 liv->setItemTextBackground( oldBrush );
329 } 329 }
330 330
331 virtual QPixmap* pixmap () const 331 virtual QPixmap* pixmap () const
332 { 332 {
333 const LauncherIconView* liv = (LauncherIconView*)iconView(); 333 const LauncherIconView* liv = (LauncherIconView*)iconView();
334 if ( (const LauncherItem *)liv->busyItem() == this ) 334 if ( (const LauncherItem *)liv->busyItem() == this )
335 return liv->busyPixmap(); 335 return liv->busyPixmap();
336 return QIconViewItem::pixmap(); 336 return QIconViewItem::pixmap();
337 } 337 }
338 338
339protected: 339protected:
340 AppLnk* app; 340 AppLnk* app;
341}; 341};
342 342
343 343
344LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 344LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
345 : QIconViewItem( parent, applnk->name(), 345 : QIconViewItem( parent, applnk->name(),
346 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 346 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
347 app(applnk) // Takes ownership 347 app(applnk) // Takes ownership
348{ 348{
349} 349}
350 350
351int LauncherItem::compare ( QIconViewItem * i ) const 351int LauncherItem::compare ( QIconViewItem * i ) const
352{ 352{
353 LauncherIconView* view = (LauncherIconView*)iconView(); 353 LauncherIconView* view = (LauncherIconView*)iconView();
354 return view->compare(app,((LauncherItem *)i)->appLnk()); 354 return view->compare(app,((LauncherItem *)i)->appLnk());
355} 355}
356 356
357QStringList LauncherIconView::mimeTypes() const 357QStringList LauncherIconView::mimeTypes() const
358{ 358{
359 QStringList r; 359 QStringList r;
360 QDictIterator<void> it(mimes); 360 QDictIterator<void> it(mimes);
361 while (it.current()) { 361 while (it.current()) {
362 r.append(it.currentKey()); 362 r.append(it.currentKey());
363 ++it; 363 ++it;
364 } 364 }
365 r.sort(); 365 r.sort();
366 return r; 366 return r;
367} 367}
368 368
369void LauncherIconView::addItem(AppLnk* app, bool resort) 369void LauncherIconView::addItem(AppLnk* app, bool resort)
370{ 370{
371 addCatsAndMimes(app); 371 addCatsAndMimes(app);
372 372
373 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 373 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
374 && (cf == 0 || app->categories().contains(cf) 374 && (cf == 0 || app->categories().contains(cf)
375 || cf == -1 && app->categories().count() == 0 ) ) 375 || cf == -1 && app->categories().count() == 0 ) )
376 (void) new LauncherItem( this, app, bigIcns ); 376 (void) new LauncherItem( this, app, bigIcns );
377 else 377 else
378 hidden.append(app); 378 hidden.append(app);
379 if ( resort ) 379 if ( resort )
380 sort(); 380 sort();
381} 381}
382 382
383void LauncherIconView::updateCategoriesAndMimeTypes() 383void LauncherIconView::updateCategoriesAndMimeTypes()
384{ 384{
385 mimes.clear(); 385 mimes.clear();
386 cats.clear(); 386 cats.clear();
387 LauncherItem* item = (LauncherItem*)firstItem(); 387 LauncherItem* item = (LauncherItem*)firstItem();
388 while (item) { 388 while (item) {
389 addCatsAndMimes(item->appLnk()); 389 addCatsAndMimes(item->appLnk());
390 item = (LauncherItem*)item->nextItem(); 390 item = (LauncherItem*)item->nextItem();
391 } 391 }
392 QListIterator<AppLnk> it(hidden); 392 QListIterator<AppLnk> it(hidden);
393 AppLnk* l; 393 AppLnk* l;
394 while ((l=it.current())) { 394 while ((l=it.current())) {
395 addCatsAndMimes(l); 395 addCatsAndMimes(l);
396 ++it; 396 ++it;
397 } 397 }
398} 398}
399 399
400void LauncherIconView::hideOrShowItems(bool resort) 400void LauncherIconView::hideOrShowItems(bool resort)
401{ 401{
402 hidden.setAutoDelete(FALSE); 402 hidden.setAutoDelete(FALSE);
403 QList<AppLnk> links=hidden; 403 QList<AppLnk> links=hidden;
404 hidden.clear(); 404 hidden.clear();
405 hidden.setAutoDelete(TRUE); 405 hidden.setAutoDelete(TRUE);
406 LauncherItem* item = (LauncherItem*)firstItem(); 406 LauncherItem* item = (LauncherItem*)firstItem();
407 while (item) { 407 while (item) {
408 links.append(item->takeAppLnk()); 408 links.append(item->takeAppLnk());
409 item = (LauncherItem*)item->nextItem(); 409 item = (LauncherItem*)item->nextItem();
410 } 410 }
411 viewport()->setUpdatesEnabled( FALSE ); 411 viewport()->setUpdatesEnabled( FALSE );
412 clear(); 412 clear();
413 QListIterator<AppLnk> it(links); 413 QListIterator<AppLnk> it(links);
414 AppLnk* l; 414 AppLnk* l;
415 while ((l=it.current())) { 415 while ((l=it.current())) {
416 addItem(l,FALSE); 416 addItem(l,FALSE);
417 ++it; 417 ++it;
418 } 418 }
419 viewport()->setUpdatesEnabled( TRUE ); 419 viewport()->setUpdatesEnabled( TRUE );
420 if ( resort && !autoArrange() ) 420 if ( resort && !autoArrange() )
421 sort(); 421 sort();
422} 422}
423 423
424bool LauncherIconView::removeLink(const QString& linkfile) 424bool LauncherIconView::removeLink(const QString& linkfile)
425{ 425{
426 LauncherItem* item = (LauncherItem*)firstItem(); 426 LauncherItem* item = (LauncherItem*)firstItem();
427 AppLnk* l; 427 AppLnk* l;
428 bool did = FALSE; 428 bool did = FALSE;
429 DocLnk dl(linkfile); 429 DocLnk dl(linkfile);
430 while (item) { 430 while (item) {
431 l = item->appLnk(); 431 l = item->appLnk();
432 if ( l->linkFileKnown() && l->linkFile() == linkfile 432 if ( l->linkFileKnown() && l->linkFile() == linkfile
433 || l->fileKnown() && ( 433 || l->fileKnown() && (
434 l->file() == linkfile 434 l->file() == linkfile
435 || dl.isValid() && dl.file() == l->file() ) ) { 435 || dl.isValid() && dl.file() == l->file() ) ) {
436 delete item; 436 delete item;
437 did = TRUE; 437 did = TRUE;
438 } 438 }
439 item = (LauncherItem*)item->nextItem(); 439 item = (LauncherItem*)item->nextItem();
440 } 440 }
441 QListIterator<AppLnk> it(hidden); 441 QListIterator<AppLnk> it(hidden);
442 while ((l=it.current())) { 442 while ((l=it.current())) {
443 ++it; 443 ++it;
444 if ( l->linkFileKnown() && l->linkFile() == linkfile 444 if ( l->linkFileKnown() && l->linkFile() == linkfile
445 || l->file() == linkfile 445 || l->file() == linkfile
446 || dl.isValid() && dl.file() == l->file() ) { 446 || dl.isValid() && dl.file() == l->file() ) {
447 hidden.removeRef(l); 447 hidden.removeRef(l);
448 did = TRUE; 448 did = TRUE;
449 } 449 }
450 } 450 }
451 return did; 451 return did;
452} 452}
453 453
454static QString docLinkInfo(const Categories& cats, DocLnk* doc) 454static QString docLinkInfo(const Categories& cats, DocLnk* doc)
455{ 455{
456 QString contents; 456 QString contents;
457 457
458 QFileInfo fi( doc->file() ); 458 QFileInfo fi( doc->file() );
459 if ( !fi.exists() ) 459 if ( !fi.exists() )
460 return contents; 460 return contents;
461 461
462 if ( doc->linkFileKnown() ) { 462 if ( doc->linkFileKnown() ) {
463 QString lfn = doc->linkFile(); 463 QString lfn = doc->linkFile();
464 QFile f( lfn ); 464 QFile f( lfn );
465 if ( f.open( IO_ReadOnly ) ) { 465 if ( f.open( IO_ReadOnly ) ) {
466 QTextStream ts( &f ); 466 QTextStream ts( &f );
467 ts.setEncoding( QTextStream::UnicodeUTF8 ); 467 ts.setEncoding( QTextStream::UnicodeUTF8 );
468 contents += ts.read(); 468 contents += ts.read();
469 f.close(); 469 f.close();
470 goto calcsize; 470 goto calcsize;
471 } 471 }
472 } 472 }
473 473
474 contents += "[Desktop Entry]\n"; 474 contents += "[Desktop Entry]\n";
475 contents += "Categories = " // No tr 475 contents += "Categories = " // No tr
476 + cats.labels("Document View", doc->categories()).join(";") + "\n"; // No tr 476 + cats.labels("Document View", doc->categories()).join(";") + "\n"; // No tr
477 contents += "File = "+doc->file()+"\n"; // No tr 477 contents += "File = "+doc->file()+"\n"; // No tr
478 contents += "Name = "+doc->name()+"\n"; // No tr 478 contents += "Name = "+doc->name()+"\n"; // No tr
479 contents += "Type = "+doc->type()+"\n"; // No tr 479 contents += "Type = "+doc->type()+"\n"; // No tr
480 480
481calcsize: 481calcsize:
482 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 482 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
483 return contents; 483 return contents;
484} 484}
485 485
486QString LauncherIconView::getAllDocLinkInfo() const 486QString LauncherIconView::getAllDocLinkInfo() const
487{ 487{
488 QString contents; 488 QString contents;
489 LauncherItem* item = (LauncherItem*)firstItem(); 489 LauncherItem* item = (LauncherItem*)firstItem();
490 Categories cats; 490 Categories cats;
491 while (item) { 491 while (item) {
492 DocLnk* doc = (DocLnk*)item->appLnk(); 492 DocLnk* doc = (DocLnk*)item->appLnk();
493 contents += docLinkInfo(cats,doc); 493 contents += docLinkInfo(cats,doc);
494 item = (LauncherItem*)item->nextItem(); 494 item = (LauncherItem*)item->nextItem();
495 } 495 }
496 QListIterator<AppLnk> it(hidden); 496 QListIterator<AppLnk> it(hidden);
497 DocLnk* doc; 497 DocLnk* doc;
498 while ((doc=(DocLnk*)it.current())) { 498 while ((doc=(DocLnk*)it.current())) {
499 contents += docLinkInfo(cats,doc); 499 contents += docLinkInfo(cats,doc);
500 ++it; 500 ++it;
501 } 501 }
502 return contents; 502 return contents;
503} 503}
504 504
505//=========================================================================== 505//===========================================================================
506 506
507LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 507LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
508 : QVBox( parent, name, fl ) 508 : QVBox( parent, name, fl )
509{ 509{
510 icons = new LauncherIconView( this ); 510 icons = new LauncherIconView( this );
511 setFocusProxy(icons); 511 setFocusProxy(icons);
512 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 512 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
513 513
514 icons->setItemsMovable( FALSE ); 514 icons->setItemsMovable( FALSE );
515 icons->setAutoArrange( TRUE ); 515 icons->setAutoArrange( TRUE );
516 icons->setSorting( TRUE ); 516 icons->setSorting( TRUE );
517 icons->setFrameStyle( QFrame::NoFrame ); 517 icons->setFrameStyle( QFrame::NoFrame );
518 icons->setMargin( 0 ); 518 icons->setMargin( 0 );
519 icons->setSelectionMode( QIconView::NoSelection ); 519 icons->setSelectionMode( QIconView::NoSelection );
520 icons->setBackgroundMode( PaletteBase ); 520 icons->setBackgroundMode( PaletteBase );
521 icons->setResizeMode( QIconView::Fixed ); 521 icons->setResizeMode( QIconView::Fixed );
522 vmode = (ViewMode)-1; 522 vmode = (ViewMode)-1;
523 setViewMode( Icon ); 523 setViewMode( Icon );
524 524
525 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 525 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
526 SLOT(itemClicked(int, QIconViewItem *)) ); 526 SLOT(itemClicked(int, QIconViewItem *)) );
527 connect( icons, SIGNAL(selectionChanged()), 527 connect( icons, SIGNAL(selectionChanged()),
528 SLOT(selectionChanged()) ); 528 SLOT(selectionChanged()) );
529 connect( icons, SIGNAL(returnPressed(QIconViewItem *)), 529 connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
530 SLOT(returnPressed(QIconViewItem *)) ); 530 SLOT(returnPressed(QIconViewItem *)) );
531 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), 531 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
532 SLOT(itemPressed(int, QIconViewItem *)) ); 532 SLOT(itemPressed(int, QIconViewItem *)) );
533 533
534 tools = 0; 534 tools = 0;
535 setBackgroundType( Ruled, QString::null ); 535 setBackgroundType( Ruled, QString::null );
536} 536}
537 537
538LauncherView::~LauncherView() 538LauncherView::~LauncherView()
539{ 539{
540} 540}
541 541
542void LauncherView::setToolsEnabled(bool y) 542void LauncherView::setToolsEnabled(bool y)
543{ 543{
544 if ( !y != !tools ) { 544 if ( !y != !tools ) {
545 if ( y ) { 545 if ( y ) {
546 tools = new QHBox(this); 546 tools = new QHBox(this);
547 547
548 // Type filter 548 // Type filter
549 typemb = new QComboBox(tools); 549 typemb = new QComboBox(tools);
550 550
551 // Category filter 551 // Category filter
552 catmb = new CategorySelect(tools); 552 catmb = new CategorySelect(tools);
553 553
554 updateTools(); 554 updateTools();
555 tools->show(); 555 tools->show();
556 } else { 556 } else {
557 delete tools; 557 delete tools;
558 tools = 0; 558 tools = 0;
559 } 559 }
560 } 560 }
561} 561}
562 562
563void LauncherView::updateTools() 563void LauncherView::updateTools()
564{ 564{
565 disconnect( typemb, SIGNAL(activated(int)), 565 disconnect( typemb, SIGNAL(activated(int)),
566 this, SLOT(showType(int)) ); 566 this, SLOT(showType(int)) );
567 disconnect( catmb, SIGNAL(signalSelected(int)), 567 disconnect( catmb, SIGNAL(signalSelected(int)),
568 this, SLOT(showCategory(int)) ); 568 this, SLOT(showCategory(int)) );
569 569
570 icons->updateCategoriesAndMimeTypes(); 570 icons->updateCategoriesAndMimeTypes();
571 571
572 QString prev; 572 QString prev;
573 573
574 // Type filter 574 // Type filter
575 QStringList types; 575 QStringList types;
576 typelist = icons->mimeTypes(); 576 typelist = icons->mimeTypes();
577 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 577 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
578 QString t = *it; 578 QString t = *it;
579 if ( t.left(12) == "application/" ) { 579 if ( t.left(12) == "application/" ) {
580 MimeType mt(t); 580 MimeType mt(t);
581 const AppLnk* app = mt.application(); 581 const AppLnk* app = mt.application();
582 if ( app ) 582 if ( app )
583 t = app->name(); 583 t = app->name();
584 else 584 else
585 t = t.mid(12); 585 t = t.mid(12);
586 } else { 586 } else {
587 t[0] = t[0].upper(); 587 t[0] = t[0].upper();
588 } 588 }
589 types += tr("%1 files").arg(t); 589 types += tr("%1 files").arg(t);
590 } 590 }
591 types << tr("All types of file"); 591 types << tr("All types of file");
592 prev = typemb->currentText(); 592 prev = typemb->currentText();
593 typemb->clear(); 593 typemb->clear();
594 typemb->insertStringList(types); 594 typemb->insertStringList(types);
595 for (int i=0; i<typemb->count(); i++) { 595 for (int i=0; i<typemb->count(); i++) {
596 if ( typemb->text(i) == prev ) { 596 if ( typemb->text(i) == prev ) {
597 typemb->setCurrentItem(i); 597 typemb->setCurrentItem(i);
598 break; 598 break;
599 } 599 }
600 } 600 }
601 if ( prev.isNull() ) 601 if ( prev.isNull() )
602 typemb->setCurrentItem(typemb->count()-1); 602 typemb->setCurrentItem(typemb->count()-1);
603 603
604 Categories cats( 0 ); 604 Categories cats( 0 );
605 cats.load( categoryFileName() ); 605 cats.load( categoryFileName() );
606 QArray<int> vl( 0 ); 606 QArray<int> vl( 0 );
607 catmb->setCategories( vl, "Document View", // No tr 607 catmb->setCategories( vl, "Document View", // No tr
608 tr("Document View") ); 608 tr("Document View") );
609 catmb->setRemoveCategoryEdit( TRUE ); 609 catmb->setRemoveCategoryEdit( TRUE );
610 catmb->setAllCategories( TRUE ); 610 catmb->setAllCategories( TRUE );
611 611
612 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 612 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
613 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 613 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
614} 614}
615 615
616void LauncherView::sortBy(int s) 616void LauncherView::sortBy(int s)
617{ 617{
618 icons->setSortMethod((LauncherIconView::SortMethod)s); 618 icons->setSortMethod((LauncherIconView::SortMethod)s);
619} 619}
620 620
621void LauncherView::showType(int t) 621void LauncherView::showType(int t)
622{ 622{
623 if ( t >= (int)typelist.count() ) { 623 if ( t >= (int)typelist.count() ) {
624 icons->setTypeFilter("",TRUE); 624 icons->setTypeFilter("",TRUE);
625 } else { 625 } else {
626 QString ty = typelist[t]; 626 QString ty = typelist[t];
627 if ( !ty.contains('/') ) 627 if ( !ty.contains('/') )
628 ty += "/*"; 628 ty += "/*";
629 icons->setTypeFilter(ty,TRUE); 629 icons->setTypeFilter(ty,TRUE);
630 } 630 }
631} 631}
632 632
633void LauncherView::showCategory( int c ) 633void LauncherView::showCategory( int c )
634{ 634{
635 icons->setCategoryFilter( c, TRUE ); 635 icons->setCategoryFilter( c, TRUE );
636} 636}
637 637
638void LauncherView::setViewMode( ViewMode m ) 638void LauncherView::setViewMode( ViewMode m )
639{ 639{
640 if ( vmode != m ) { 640 if ( vmode != m ) {
641 bool bigIcons = m == Icon; 641 bool bigIcons = m == Icon;
642 icons->viewport()->setUpdatesEnabled( FALSE ); 642 icons->viewport()->setUpdatesEnabled( FALSE );
643 icons->setBigIcons( bigIcons ); 643 icons->setBigIcons( bigIcons );
644 switch ( m ) { 644 switch ( m ) {
645 case List: 645 case List:
646 icons->setItemTextPos( QIconView::Right ); 646 icons->setItemTextPos( QIconView::Right );
647 break; 647 break;
648 case Icon: 648 case Icon:
649 icons->setItemTextPos( QIconView::Bottom ); 649 icons->setItemTextPos( QIconView::Bottom );
650 break; 650 break;
651 } 651 }
652 icons->hideOrShowItems( FALSE ); 652 icons->hideOrShowItems( FALSE );
653 icons->viewport()->setUpdatesEnabled( TRUE ); 653 icons->viewport()->setUpdatesEnabled( TRUE );
654 vmode = m; 654 vmode = m;
655 } 655 }
656} 656}
657 657
658void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 658void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
659{ 659{
660 if ( !bgCache ) 660 if ( !bgCache )
661 bgCache = new QMap<QString,BgPixmap*>; 661 bgCache = new QMap<QString,BgPixmap*>;
662 if ( bgCache->contains( bgName ) ) 662 if ( bgCache->contains( bgName ) )
663 (*bgCache)[bgName]->ref--; 663 (*bgCache)[bgName]->ref--;
664 664
665 switch ( t ) { 665 switch ( t ) {
666 case Ruled: { 666 case Ruled: {
667 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 667 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
668 QPixmap bg; 668 QPixmap bg;
669 if ( bgCache->contains( bgName ) ) { 669 if ( bgCache->contains( bgName ) ) {
670 (*bgCache)[bgName]->ref++; 670 (*bgCache)[bgName]->ref++;
671 bg = (*bgCache)[bgName]->pm; 671 bg = (*bgCache)[bgName]->pm;
672 } else { 672 } else {
673 bg.resize( width(), 9 ); 673 bg.resize( width(), 9 );
674 QPainter painter( &bg ); 674 QPainter painter( &bg );
675 for ( int i = 0; i < 3; i++ ) { 675 for ( int i = 0; i < 3; i++ ) {
676 painter.setPen( white ); 676 painter.setPen( white );
677 painter.drawLine( 0, i*3, width()-1, i*3 ); 677 painter.drawLine( 0, i*3, width()-1, i*3 );
678 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 678 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
679 painter.setPen( colorGroup().background().light(105) ); 679 painter.setPen( colorGroup().background().light(105) );
680 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 680 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
681 } 681 }
682 painter.end(); 682 painter.end();
683 bgCache->insert( bgName, new BgPixmap(bg) ); 683 bgCache->insert( bgName, new BgPixmap(bg) );
684 } 684 }
685 icons->setBackgroundPixmap( bg ); 685 icons->setBackgroundPixmap( bg );
686 break; 686 break;
687 } 687 }
688 688
689 case SolidColor: 689 case SolidColor:
690 icons->setBackgroundPixmap( QPixmap() ); 690 icons->setBackgroundPixmap( QPixmap() );
691 if ( val.isEmpty() ) { 691 if ( val.isEmpty() ) {
692 icons->setBackgroundColor( colorGroup().base() ); 692 icons->setBackgroundColor( colorGroup().base() );
693 } else { 693 } else {
694 icons->setBackgroundColor( val ); 694 icons->setBackgroundColor( val );
695 } 695 }
696 bgName = ""; 696 bgName = "";
697 break; 697 break;
698 698
699 case Image: 699 case Image:
700 bgName = val; 700 bgName = val;
701 if ( bgCache->contains( bgName ) ) { 701 if ( bgCache->contains( bgName ) ) {
702 (*bgCache)[bgName]->ref++; 702 (*bgCache)[bgName]->ref++;
703 icons->setBackgroundPixmap( (*bgCache)[bgName]->pm ); 703 icons->setBackgroundPixmap( (*bgCache)[bgName]->pm );
704 } else { 704 } else {
705 qDebug( "Loading image: %s", val.latin1() ); 705 qDebug( "Loading image: %s", val.latin1() );
706 QPixmap bg( Resource::loadPixmap( "wallpaper/" + val ) ); 706 QPixmap bg( Resource::loadPixmap( val ) );
707 if ( bg.isNull() ) { 707 if ( bg.isNull() ) {
708 QImageIO imgio; 708 QImageIO imgio;
709 imgio.setFileName( bgName ); 709 imgio.setFileName( bgName );
710 QSize ds = qApp->desktop()->size(); 710 QSize ds = qApp->desktop()->size();
711 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 711 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
712 imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() ); 712 imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() );
713 imgio.read(); 713 imgio.read();
714 bg = imgio.image(); 714 bg = imgio.image();
715 } 715 }
716 bgCache->insert( bgName, new BgPixmap(bg) ); 716 bgCache->insert( bgName, new BgPixmap(bg) );
717 icons->setBackgroundPixmap( bg ); 717 icons->setBackgroundPixmap( bg );
718 } 718 }
719 break; 719 break;
720 } 720 }
721 721
722 // remove unreferenced backgrounds. 722 // remove unreferenced backgrounds.
723 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 723 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
724 while ( it != bgCache->end() ) { 724 while ( it != bgCache->end() ) {
725 QMap<QString,BgPixmap*>::Iterator curr = it; 725 QMap<QString,BgPixmap*>::Iterator curr = it;
726 ++it; 726 ++it;
727 if ( (*curr)->ref == 0 ) { 727 if ( (*curr)->ref == 0 ) {
728 delete (*curr); 728 delete (*curr);
729 bgCache->remove( curr ); 729 bgCache->remove( curr );
730 } 730 }
731 } 731 }
732 732
733 bgType = t; 733 bgType = t;
734 icons->viewport()->update(); 734 icons->viewport()->update();
735} 735}
736 736
737void LauncherView::setTextColor( const QColor &tc ) 737void LauncherView::setTextColor( const QColor &tc )
738{ 738{
739 textCol = tc; 739 textCol = tc;
740 QColorGroup cg = icons->colorGroup(); 740 QColorGroup cg = icons->colorGroup();
741 cg.setColor( QColorGroup::Text, tc ); 741 cg.setColor( QColorGroup::Text, tc );
742 icons->setPalette( QPalette(cg,cg,cg) ); 742 icons->setPalette( QPalette(cg,cg,cg) );
743 icons->viewport()->update(); 743 icons->viewport()->update();
744} 744}
745 745
746void LauncherView::setViewFont( const QFont &f ) 746void LauncherView::setViewFont( const QFont &f )
747{ 747{
748 icons->setFont( f ); 748 icons->setFont( f );
749} 749}
750 750
751void LauncherView::resizeEvent(QResizeEvent *e) 751void LauncherView::resizeEvent(QResizeEvent *e)
752{ 752{
753 QVBox::resizeEvent( e ); 753 QVBox::resizeEvent( e );
754 if ( e->size().width() != e->oldSize().width() ) 754 if ( e->size().width() != e->oldSize().width() )
755 sort(); 755 sort();
756} 756}
757 757
758void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) 758void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
759{ 759{
760 icons->clear(); 760 icons->clear();
761 internalPopulate( folder, typefilter ); 761 internalPopulate( folder, typefilter );
762} 762}
763 763
764QString LauncherView::getAllDocLinkInfo() const 764QString LauncherView::getAllDocLinkInfo() const
765{ 765{
766 return icons->getAllDocLinkInfo(); 766 return icons->getAllDocLinkInfo();
767} 767}
768 768
769void LauncherView::selectionChanged() 769void LauncherView::selectionChanged()
770{ 770{
771 QIconViewItem* item = icons->currentItem(); 771 QIconViewItem* item = icons->currentItem();
772 if ( item && item->isSelected() ) { 772 if ( item && item->isSelected() ) {
773 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 773 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
774 if ( icons->inKeyEvent() ) // not for mouse press 774 if ( icons->inKeyEvent() ) // not for mouse press
775 emit clicked( appLnk ); 775 emit clicked( appLnk );
776 item->setSelected(FALSE); 776 item->setSelected(FALSE);
777 } 777 }
778} 778}
779 779
780void LauncherView::returnPressed( QIconViewItem *item ) 780void LauncherView::returnPressed( QIconViewItem *item )
781{ 781{
782 if ( item ) { 782 if ( item ) {
783 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 783 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
784 emit clicked( appLnk ); 784 emit clicked( appLnk );
785 } 785 }
786} 786}
787 787
788void LauncherView::itemClicked( int btn, QIconViewItem *item ) 788void LauncherView::itemClicked( int btn, QIconViewItem *item )
789{ 789{
790 if ( item ) { 790 if ( item ) {
791 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 791 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
792 if ( btn == LeftButton ) { 792 if ( btn == LeftButton ) {
793 // Make sure it's the item we execute that gets highlighted 793 // Make sure it's the item we execute that gets highlighted
794 icons->setCurrentItem( item ); 794 icons->setCurrentItem( item );
795 emit clicked( appLnk ); 795 emit clicked( appLnk );
796 } 796 }
797 item->setSelected(FALSE); 797 item->setSelected(FALSE);
798 } 798 }
799} 799}
800 800
801void LauncherView::itemPressed( int btn, QIconViewItem *item ) 801void LauncherView::itemPressed( int btn, QIconViewItem *item )
802{ 802{
803 if ( item ) { 803 if ( item ) {
804 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 804 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
805 if ( btn == RightButton ) 805 if ( btn == RightButton )
806 emit rightPressed( appLnk ); 806 emit rightPressed( appLnk );
807/* 807/*
808 else if ( btn == LeftButton ) 808 else if ( btn == LeftButton )
809 emit clicked( appLnk ); 809 emit clicked( appLnk );
810*/ 810*/
811 item->setSelected(FALSE); 811 item->setSelected(FALSE);
812 } 812 }
813} 813}
814 814
815void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) 815void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter )
816{ 816{
817 QListIterator<AppLnk> it( folder->children() ); 817 QListIterator<AppLnk> it( folder->children() );
818 icons->setTypeFilter(typefilter,FALSE); 818 icons->setTypeFilter(typefilter,FALSE);
819 819
820 while ( it.current() ) { 820 while ( it.current() ) {
821 // show only the icons for existing files 821 // show only the icons for existing files
822 if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) { 822 if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) {
823 icons->addItem(*it,FALSE); 823 icons->addItem(*it,FALSE);
824 } 824 }
825 else { 825 else {
826 //maybe insert some .desktop file deletion code later 826 //maybe insert some .desktop file deletion code later
827 //maybe dir specific 827 //maybe dir specific
828 } 828 }
829 ++it; 829 ++it;
830 } 830 }
831 831
832 icons->sort(); 832 icons->sort();
833} 833}
834 834
835bool LauncherView::removeLink(const QString& linkfile) 835bool LauncherView::removeLink(const QString& linkfile)
836{ 836{
837 return icons->removeLink(linkfile); 837 return icons->removeLink(linkfile);
838} 838}
839 839
840void LauncherView::sort() 840void LauncherView::sort()
841{ 841{
842 icons->sort(); 842 icons->sort();
843} 843}
844 844
845void LauncherView::addItem(AppLnk* app, bool resort) 845void LauncherView::addItem(AppLnk* app, bool resort)
846{ 846{
847 icons->addItem(app,resort); 847 icons->addItem(app,resort);
848} 848}
849 849
850void LauncherView::setFileSystems(const QList<FileSystem> &) 850void LauncherView::setFileSystems(const QList<FileSystem> &)
851{ 851{
852 // ### does nothing now... 852 // ### does nothing now...
853} 853}
854 854
855void LauncherView::paletteChange( const QPalette &p ) 855void LauncherView::paletteChange( const QPalette &p )
856{ 856{
857 icons->unsetPalette(); 857 icons->unsetPalette();
858 QVBox::paletteChange( p ); 858 QVBox::paletteChange( p );
859 if ( bgType == Ruled ) 859 if ( bgType == Ruled )
860 setBackgroundType( Ruled, QString::null ); 860 setBackgroundType( Ruled, QString::null );
861 QColorGroup cg = icons->colorGroup(); 861 QColorGroup cg = icons->colorGroup();
862 cg.setColor( QColorGroup::Text, textCol ); 862 cg.setColor( QColorGroup::Text, textCol );
863 icons->setPalette( QPalette(cg,cg,cg) ); 863 icons->setPalette( QPalette(cg,cg,cg) );
864} 864}
865 865