summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 71e8753..e86f389 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -557,503 +557,505 @@ void LauncherIconView::hideOrShowItems(bool resort)
557 clear(); 557 clear();
558 QListIterator<AppLnk> it(links); 558 QListIterator<AppLnk> it(links);
559 AppLnk* l; 559 AppLnk* l;
560 while ((l=it.current())) { 560 while ((l=it.current())) {
561 addItem(l,FALSE); 561 addItem(l,FALSE);
562 ++it; 562 ++it;
563 } 563 }
564 if ( resort && !autoArrange() ) 564 if ( resort && !autoArrange() )
565 sort(); 565 sort();
566 viewport()->setUpdatesEnabled( TRUE ); 566 viewport()->setUpdatesEnabled( TRUE );
567} 567}
568 568
569bool LauncherIconView::removeLink(const QString& linkfile) 569bool LauncherIconView::removeLink(const QString& linkfile)
570{ 570{
571 LauncherItem* item = (LauncherItem*)firstItem(); 571 LauncherItem* item = (LauncherItem*)firstItem();
572 AppLnk* l; 572 AppLnk* l;
573 bool did = FALSE; 573 bool did = FALSE;
574 DocLnk dl(linkfile); 574 DocLnk dl(linkfile);
575 while (item) { 575 while (item) {
576 l = item->appLnk(); 576 l = item->appLnk();
577 LauncherItem *nextItem = (LauncherItem *)item->nextItem(); 577 LauncherItem *nextItem = (LauncherItem *)item->nextItem();
578 if ( l->linkFileKnown() && l->linkFile() == linkfile 578 if ( l->linkFileKnown() && l->linkFile() == linkfile
579 || l->fileKnown() && ( 579 || l->fileKnown() && (
580 l->file() == linkfile 580 l->file() == linkfile
581 || dl.isValid() && dl.file() == l->file() ) ) { 581 || dl.isValid() && dl.file() == l->file() ) ) {
582 delete item; 582 delete item;
583 did = TRUE; 583 did = TRUE;
584 } 584 }
585 item = nextItem; 585 item = nextItem;
586 } 586 }
587 QListIterator<AppLnk> it(hidden); 587 QListIterator<AppLnk> it(hidden);
588 while ((l=it.current())) { 588 while ((l=it.current())) {
589 ++it; 589 ++it;
590 if ( l->linkFileKnown() && l->linkFile() == linkfile 590 if ( l->linkFileKnown() && l->linkFile() == linkfile
591 || l->file() == linkfile 591 || l->file() == linkfile
592 || dl.isValid() && dl.file() == l->file() ) { 592 || dl.isValid() && dl.file() == l->file() ) {
593 hidden.removeRef(l); 593 hidden.removeRef(l);
594 did = TRUE; 594 did = TRUE;
595 } 595 }
596 } 596 }
597 return did; 597 return did;
598} 598}
599 599
600//=========================================================================== 600//===========================================================================
601 601
602LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 602LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
603 : QVBox( parent, name, fl ) 603 : QVBox( parent, name, fl )
604{ 604{
605 catmb = 0; 605 catmb = 0;
606 icons = new LauncherIconView( this ); 606 icons = new LauncherIconView( this );
607 setFocusProxy(icons); 607 setFocusProxy(icons);
608 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 608 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
609 609
610 icons->setItemsMovable( FALSE ); 610 icons->setItemsMovable( FALSE );
611 icons->setAutoArrange( TRUE ); 611 icons->setAutoArrange( TRUE );
612 icons->setSorting( TRUE ); 612 icons->setSorting( TRUE );
613 icons->setFrameStyle( QFrame::NoFrame ); 613 icons->setFrameStyle( QFrame::NoFrame );
614 icons->setMargin( 0 ); 614 icons->setMargin( 0 );
615 icons->setSelectionMode( QIconView::NoSelection ); 615 icons->setSelectionMode( QIconView::NoSelection );
616 icons->setBackgroundMode( PaletteBase ); 616 icons->setBackgroundMode( PaletteBase );
617 icons->setResizeMode( QIconView::Fixed ); 617 icons->setResizeMode( QIconView::Fixed );
618 vmode = (ViewMode)-1; 618 vmode = (ViewMode)-1;
619 setViewMode( Icon ); 619 setViewMode( Icon );
620 620
621 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 621 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
622 SLOT(itemClicked(int,QIconViewItem*)) ); 622 SLOT(itemClicked(int,QIconViewItem*)) );
623 connect( icons, SIGNAL(selectionChanged()), 623 connect( icons, SIGNAL(selectionChanged()),
624 SLOT(selectionChanged()) ); 624 SLOT(selectionChanged()) );
625 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 625 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
626 SLOT(returnPressed(QIconViewItem*)) ); 626 SLOT(returnPressed(QIconViewItem*)) );
627 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 627 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
628 SLOT(itemPressed(int,QIconViewItem*)) ); 628 SLOT(itemPressed(int,QIconViewItem*)) );
629 629
630 tools = 0; 630 tools = 0;
631 setBackgroundType( Ruled, QString::null ); 631 setBackgroundType( Ruled, QString::null );
632} 632}
633 633
634LauncherView::~LauncherView() 634LauncherView::~LauncherView()
635{ 635{
636 if ( bgCache && bgCache->contains( bgName ) ) 636 if ( bgCache && bgCache->contains( bgName ) )
637 (*bgCache)[bgName]->ref--; 637 (*bgCache)[bgName]->ref--;
638} 638}
639 639
640void LauncherView::hideIcons() 640void LauncherView::hideIcons()
641{ 641{
642 icons->hide(); 642 icons->hide();
643} 643}
644 644
645void LauncherView::setToolsEnabled(bool y) 645void LauncherView::setToolsEnabled(bool y)
646{ 646{
647 if ( !y != !tools ) { 647 if ( !y != !tools ) {
648 if ( y ) { 648 if ( y ) {
649 tools = new QHBox(this); 649 tools = new QHBox(this);
650 650
651 // Type filter 651 // Type filter
652 typemb = new QComboBox(tools); 652 typemb = new QComboBox(tools);
653 QSizePolicy p = typemb->sizePolicy(); 653 QSizePolicy p = typemb->sizePolicy();
654 p.setHorData(QSizePolicy::Expanding); 654 p.setHorData(QSizePolicy::Expanding);
655 typemb->setSizePolicy(p); 655 typemb->setSizePolicy(p);
656 656
657 // Category filter 657 // Category filter
658 updateTools(); 658 updateTools();
659 tools->show(); 659 tools->show();
660 660
661 // Always show vscrollbar 661 // Always show vscrollbar
662 icons->setVScrollBarMode( QScrollView::AlwaysOn ); 662 icons->setVScrollBarMode( QScrollView::AlwaysOn );
663 } else { 663 } else {
664 delete tools; 664 delete tools;
665 tools = 0; 665 tools = 0;
666 } 666 }
667 } 667 }
668} 668}
669 669
670void LauncherView::updateTools() 670void LauncherView::updateTools()
671{ 671{
672 disconnect( typemb, SIGNAL(activated(int)), 672 disconnect( typemb, SIGNAL(activated(int)),
673 this, SLOT(showType(int)) ); 673 this, SLOT(showType(int)) );
674 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), 674 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)),
675 this, SLOT(showCategory(int)) ); 675 this, SLOT(showCategory(int)) );
676 676
677 // ### I want to remove this 677 // ### I want to remove this
678 icons->updateCategoriesAndMimeTypes(); 678 icons->updateCategoriesAndMimeTypes();
679 679
680 QString prev; 680 QString prev;
681 681
682 // Type filter 682 // Type filter
683 QStringList types; 683 QStringList types;
684 typelist = icons->mimeTypes(); 684 typelist = icons->mimeTypes();
685 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 685 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
686 QString t = *it; 686 QString t = *it;
687 if ( t.left(12) == "application/" ) { 687 if ( t.left(12) == "application/" ) {
688 MimeType mt(t); 688 MimeType mt(t);
689 const AppLnk* app = mt.application(); 689 const AppLnk* app = mt.application();
690 if ( app ) 690 if ( app )
691 t = app->name(); 691 t = app->name();
692 else 692 else
693 t = t.mid(12); 693 t = t.mid(12);
694 } else { 694 } else {
695 t[0] = t[0].upper(); 695 t[0] = t[0].upper();
696 } 696 }
697 types += t; 697 types += t;
698 } 698 }
699 types << tr("All types"); 699 types << tr("All types");
700 prev = typemb->currentText(); 700 prev = typemb->currentText();
701 typemb->clear(); 701 typemb->clear();
702 typemb->insertStringList(types); 702 typemb->insertStringList(types);
703 for (int i=0; i<typemb->count(); i++) { 703 for (int i=0; i<typemb->count(); i++) {
704 if ( typemb->text(i) == prev ) { 704 if ( typemb->text(i) == prev ) {
705 typemb->setCurrentItem(i); 705 typemb->setCurrentItem(i);
706 break; 706 break;
707 } 707 }
708 } 708 }
709 if ( prev.isNull() ) 709 if ( prev.isNull() )
710 typemb->setCurrentItem(typemb->count()-1); 710 typemb->setCurrentItem(typemb->count()-1);
711 711
712 int pcat = catmb ? catmb->currentCategory() : -2; 712 int pcat = catmb ? catmb->currentCategory() : -2;
713 if ( !catmb ) 713 if ( !catmb )
714 catmb = new CategorySelect(tools); 714 catmb = new CategorySelect(tools);
715 Categories cats( 0 ); 715 Categories cats( 0 );
716 cats.load( categoryFileName() ); 716 cats.load( categoryFileName() );
717 QArray<int> vl( 0 ); 717 QArray<int> vl( 0 );
718 catmb->setCategories( vl, "Document View", // No tr 718 catmb->setCategories( vl, "Document View", // No tr
719 tr("Document View") ); 719 tr("Document View") );
720 catmb->setRemoveCategoryEdit( TRUE ); 720 catmb->setRemoveCategoryEdit( TRUE );
721 catmb->setAllCategories( TRUE ); 721 catmb->setAllCategories( TRUE );
722 catmb->setCurrentCategory(pcat); 722 catmb->setCurrentCategory(pcat);
723 723
724 // if type has changed we need to redisplay 724 // if type has changed we need to redisplay
725 if ( typemb->currentText() != prev ) 725 if ( typemb->currentText() != prev )
726 showType( typemb->currentItem() ); 726 showType( typemb->currentItem() );
727 727
728 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 728 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
729 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 729 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
730} 730}
731 731
732void LauncherView::sortBy(int s) 732void LauncherView::sortBy(int s)
733{ 733{
734 icons->setSortMethod((LauncherIconView::SortMethod)s); 734 icons->setSortMethod((LauncherIconView::SortMethod)s);
735} 735}
736 736
737void LauncherView::showType(int t) 737void LauncherView::showType(int t)
738{ 738{
739 if ( t >= (int)typelist.count() ) { 739 if ( t >= (int)typelist.count() ) {
740 icons->setTypeFilter("",TRUE); 740 icons->setTypeFilter("",TRUE);
741 } else { 741 } else {
742 QString ty = typelist[t]; 742 QString ty = typelist[t];
743 if ( !ty.contains('/') ) 743 if ( !ty.contains('/') )
744 ty += "/*"; 744 ty += "/*";
745 icons->setTypeFilter(ty,TRUE); 745 icons->setTypeFilter(ty,TRUE);
746 } 746 }
747} 747}
748 748
749void LauncherView::showCategory( int c ) 749void LauncherView::showCategory( int c )
750{ 750{
751 icons->setCategoryFilter( c, TRUE ); 751 icons->setCategoryFilter( c, TRUE );
752} 752}
753 753
754void LauncherView::setViewMode( ViewMode m ) 754void LauncherView::setViewMode( ViewMode m )
755{ 755{
756 if ( vmode != m ) { 756 if ( vmode != m ) {
757 bool bigIcons = m == Icon; 757 bool bigIcons = m == Icon;
758 icons->viewport()->setUpdatesEnabled( FALSE ); 758 icons->viewport()->setUpdatesEnabled( FALSE );
759 icons->setBigIcons( bigIcons ); 759 icons->setBigIcons( bigIcons );
760 switch ( m ) { 760 switch ( m ) {
761 case List: 761 case List:
762 icons->setItemTextPos( QIconView::Right ); 762 icons->setItemTextPos( QIconView::Right );
763 break; 763 break;
764 case Icon: 764 case Icon:
765 icons->setItemTextPos( QIconView::Bottom ); 765 icons->setItemTextPos( QIconView::Bottom );
766 break; 766 break;
767 } 767 }
768 icons->hideOrShowItems( FALSE ); 768 icons->hideOrShowItems( FALSE );
769 icons->viewport()->setUpdatesEnabled( TRUE ); 769 icons->viewport()->setUpdatesEnabled( TRUE );
770 vmode = m; 770 vmode = m;
771 } 771 }
772} 772}
773 773
774// 774//
775// User images may require scaling. 775// User images may require scaling.
776// 776//
777QImage LauncherView::loadBackgroundImage(QString &bgName) 777QImage LauncherView::loadBackgroundImage(QString &bgName)
778{ 778{
779 QImageIO imgio; 779 QImageIO imgio;
780 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop 780 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop
781 bool further_scaling = TRUE; 781 bool further_scaling = TRUE;
782 782
783 imgio.setFileName( bgName ); 783 imgio.setFileName( bgName );
784 imgio.setParameters("GetHeaderInformation"); 784 imgio.setParameters("GetHeaderInformation");
785 785
786 if (imgio.read() == FALSE) { 786 if (imgio.read() == FALSE) {
787 return imgio.image(); 787 return imgio.image();
788 } 788 }
789 789
790 if (imgio.image().width() < ds.width() && 790 if (imgio.image().width() < ds.width() &&
791 imgio.image().height() < ds.height()) { 791 imgio.image().height() < ds.height()) {
792 further_scaling = FALSE; 792 further_scaling = FALSE;
793 } 793 }
794 794
795 if (!imgio.image().bits()) { 795 if (!imgio.image().bits()) {
796 // 796 //
797 // Scale and load. Note we don't scale up. 797 // Scale and load. Note we don't scale up.
798 // 798 //
799 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 799 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
800 imgio.setParameters(further_scaling ? 800 imgio.setParameters(further_scaling ?
801 param.arg(ds.width()).arg(ds.height()).latin1() : 801 param.arg(ds.width()).arg(ds.height()).latin1() :
802 ""); 802 "");
803 imgio.read(); 803 imgio.read();
804 } else { 804 } else {
805 if (further_scaling) { 805 if (further_scaling) {
806 intt1 = imgio.image().width() * ds.height(); 806 intt1 = imgio.image().width() * ds.height();
807 int t2 = imgio.image().height() * ds.width(); 807 int t2 = imgio.image().height() * ds.width();
808 int dsth = ds.height(); 808 int dsth = ds.height();
809 int dstw = ds.width(); 809 int dstw = ds.width();
810 810
811 if (t1 > t2) { 811 if (t1 > t2) {
812 dsth = t2 / imgio.image().width(); 812 dsth = t2 / imgio.image().width();
813 } else { 813 } else {
814 dstw = t1 / imgio.image().height(); 814 dstw = t1 / imgio.image().height();
815 } 815 }
816 816
817 // 817 //
818 // Loader didn't scale for us. Do it manually. 818 // Loader didn't scale for us. Do it manually.
819 // 819 //
820 return imgio.image().smoothScale(dstw, dsth); 820 return imgio.image().smoothScale(dstw, dsth);
821 } 821 }
822 } 822 }
823 823
824 return imgio.image(); 824 return imgio.image();
825} 825}
826 826
827void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 827void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
828{ 828{
829 if ( !bgCache ) { 829 if ( !bgCache ) {
830 bgCache = new QMap<QString,BgPixmap*>; 830 bgCache = new QMap<QString,BgPixmap*>;
831 qAddPostRoutine( cleanup_cache ); 831 qAddPostRoutine( cleanup_cache );
832 } 832 }
833 833
834 if ( bgCache->contains( bgName ) ) 834 if ( bgCache->contains( bgName ) )
835 (*bgCache)[bgName]->ref--; 835 (*bgCache)[bgName]->ref--;
836 bgName = ""; 836 bgName = "";
837 837
838 QPixmap bg; 838 QPixmap bg;
839 839
840 switch ( t ) { 840 switch ( t ) {
841 case Ruled: { 841 case Ruled: {
842 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 842 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
843 if ( bgCache->contains( bgName ) ) { 843 if ( bgCache->contains( bgName ) ) {
844 (*bgCache)[bgName]->ref++; 844 (*bgCache)[bgName]->ref++;
845 bg = (*bgCache)[bgName]->pm; 845 bg = (*bgCache)[bgName]->pm;
846 } else { 846 } else {
847 bg.resize( width(), 9 ); 847 bg.resize( width(), 9 );
848 QPainter painter( &bg ); 848 QPainter painter( &bg );
849 for ( int i = 0; i < 3; i++ ) { 849 for ( int i = 0; i < 3; i++ ) {
850 painter.setPen( white ); 850 painter.setPen( white );
851 painter.drawLine( 0, i*3, width()-1, i*3 ); 851 painter.drawLine( 0, i*3, width()-1, i*3 );
852 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 852 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
853 painter.setPen( colorGroup().background().light(105) ); 853 painter.setPen( colorGroup().background().light(105) );
854 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 854 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
855 } 855 }
856 painter.end(); 856 painter.end();
857 bgCache->insert( bgName, new BgPixmap(bg) ); 857 bgCache->insert( bgName, new BgPixmap(bg) );
858 } 858 }
859 break; 859 break;
860 } 860 }
861 861
862 case Image: 862 case Image:
863 if (!val.isEmpty()) { 863 if (!val.isEmpty()) {
864 bgName = val; 864 bgName = val;
865 if ( bgCache->contains( bgName ) ) { 865 if ( bgCache->contains( bgName ) ) {
866 (*bgCache)[bgName]->ref++; 866 (*bgCache)[bgName]->ref++;
867 bg = (*bgCache)[bgName]->pm; 867 bg = (*bgCache)[bgName]->pm;
868 } else { 868 } else {
869 QString imgFile = bgName; 869 QString imgFile = bgName;
870 bool tile = FALSE; 870 bool tile = FALSE;
871 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { 871 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) {
872 imgFile = Resource::findPixmap( imgFile ); 872 imgFile = Resource::findPixmap( imgFile );
873 tile = TRUE; 873 tile = TRUE;
874 } 874 }
875 QImage img = loadBackgroundImage(imgFile); 875 QImage img = loadBackgroundImage(imgFile);
876 876
877 877
878 if ( img.depth() == 1 ) 878 if ( img.depth() == 1 )
879 img = img.convertDepth(8); 879 img = img.convertDepth(8);
880 img.setAlphaBuffer(FALSE); 880 img.setAlphaBuffer(FALSE);
881 bg.convertFromImage(img); 881 bg.convertFromImage(img);
882 bgCache->insert( bgName, new BgPixmap(bg) ); 882 bgCache->insert( bgName, new BgPixmap(bg) );
883 } 883 }
884 } 884 }
885 break; 885 break;
886 886
887 case SolidColor: 887 case SolidColor:
888 default: 888 default:
889 break; 889 break;
890 } 890 }
891 891
892 const QObjectList *list = queryList( "QWidget", 0, FALSE ); 892 const QObjectList *list = queryList( "QWidget", 0, FALSE );
893 QObject *obj; 893 QObject *obj;
894 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { 894 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) {
895 if ( obj->isWidgetType() ) { 895 if ( obj->isWidgetType() ) {
896 QWidget *w = (QWidget*)obj; 896 QWidget *w = (QWidget*)obj;
897 w->setBackgroundPixmap( bg ); 897 w->setBackgroundPixmap( bg );
898 if ( bgName.isEmpty() ) { 898 if ( bgName.isEmpty() ) {
899 // Solid Color 899 // Solid Color
900 if ( val.isEmpty() ) 900 if ( val.isEmpty() )
901 w->setBackgroundColor( colorGroup().base() ); 901 w->setBackgroundColor( colorGroup().base() );
902 else 902 else
903 w->setBackgroundColor( val ); 903 w->setBackgroundColor( val );
904 } else { 904 } else {
905 // Ruled or Image pixmap 905 // Ruled or Image pixmap
906 w->setBackgroundOrigin( ParentOrigin ); 906 w->setBackgroundOrigin( ParentOrigin );
907 } 907 }
908 } 908 }
909 } 909 }
910 delete list; 910 delete list;
911 911
912 bgType = t; 912 bgType = t;
913 icons->viewport()->update(); 913 icons->viewport()->update();
914 914
915 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); 915 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) );
916} 916}
917 917
918void LauncherView::setTextColor( const QColor &tc ) 918void LauncherView::setTextColor( const QColor &tc )
919{ 919{
920 textCol = tc; 920 textCol = tc;
921 QColorGroup cg = icons->colorGroup(); 921 QColorGroup cg = icons->colorGroup();
922 cg.setColor( QColorGroup::Text, tc ); 922 cg.setColor( QColorGroup::Text, tc );
923 icons->setPalette( QPalette(cg,cg,cg) ); 923 icons->setPalette( QPalette(cg,cg,cg) );
924 icons->viewport()->update(); 924 icons->viewport()->update();
925} 925}
926 926
927void LauncherView::setViewFont( const QFont &f ) 927void LauncherView::setViewFont( const QFont &f )
928{ 928{
929 icons->setFont( f ); 929 icons->setFont( f );
930 icons->hideOrShowItems( FALSE ); 930 icons->hideOrShowItems( FALSE );
931} 931}
932 932
933void LauncherView::clearViewFont() 933void LauncherView::clearViewFont()
934{ 934{
935 icons->unsetFont(); 935 icons->unsetFont();
936 icons->hideOrShowItems( FALSE ); 936 icons->hideOrShowItems( FALSE );
937} 937}
938 938
939void LauncherView::resizeEvent(QResizeEvent *e) 939void LauncherView::resizeEvent(QResizeEvent *e)
940{ 940{
941 //qDebug("LauncherView resize event");
941 QVBox::resizeEvent( e ); 942 QVBox::resizeEvent( e );
942 if ( e->size().width() != e->oldSize().width() ) 943// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere...
944// if ( e->size().width() != e->oldSize().width() )
943 sort(); 945 sort();
944} 946}
945 947
946void LauncherView::selectionChanged() 948void LauncherView::selectionChanged()
947{ 949{
948 QIconViewItem* item = icons->currentItem(); 950 QIconViewItem* item = icons->currentItem();
949 if ( item && item->isSelected() ) { 951 if ( item && item->isSelected() ) {
950 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 952 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
951 if ( icons->inKeyEvent() ) // not for mouse press 953 if ( icons->inKeyEvent() ) // not for mouse press
952 emit clicked( appLnk ); 954 emit clicked( appLnk );
953 item->setSelected(FALSE); 955 item->setSelected(FALSE);
954 } 956 }
955} 957}
956 958
957void LauncherView::returnPressed( QIconViewItem *item ) 959void LauncherView::returnPressed( QIconViewItem *item )
958{ 960{
959 if ( item ) { 961 if ( item ) {
960 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 962 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
961 emit clicked( appLnk ); 963 emit clicked( appLnk );
962 } 964 }
963} 965}
964 966
965void LauncherView::itemClicked( int btn, QIconViewItem *item ) 967void LauncherView::itemClicked( int btn, QIconViewItem *item )
966{ 968{
967 if ( item ) { 969 if ( item ) {
968 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 970 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
969 if ( btn == LeftButton ) { 971 if ( btn == LeftButton ) {
970 // Make sure it's the item we execute that gets highlighted 972 // Make sure it's the item we execute that gets highlighted
971 icons->setCurrentItem( item ); 973 icons->setCurrentItem( item );
972 emit clicked( appLnk ); 974 emit clicked( appLnk );
973 } 975 }
974 item->setSelected(FALSE); 976 item->setSelected(FALSE);
975 } 977 }
976} 978}
977 979
978void LauncherView::itemPressed( int btn, QIconViewItem *item ) 980void LauncherView::itemPressed( int btn, QIconViewItem *item )
979{ 981{
980 if ( item ) { 982 if ( item ) {
981 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 983 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
982 if ( btn == RightButton ) 984 if ( btn == RightButton )
983 emit rightPressed( appLnk ); 985 emit rightPressed( appLnk );
984 else if ( btn == ShiftButton ) 986 else if ( btn == ShiftButton )
985 emit rightPressed( appLnk ); 987 emit rightPressed( appLnk );
986 item->setSelected(FALSE); 988 item->setSelected(FALSE);
987 } 989 }
988} 990}
989 991
990void LauncherView::removeAllItems() 992void LauncherView::removeAllItems()
991{ 993{
992 icons->clear(); 994 icons->clear();
993} 995}
994 996
995bool LauncherView::removeLink(const QString& linkfile) 997bool LauncherView::removeLink(const QString& linkfile)
996{ 998{
997 return icons->removeLink(linkfile); 999 return icons->removeLink(linkfile);
998} 1000}
999 1001
1000void LauncherView::setSortEnabled( bool v ) 1002void LauncherView::setSortEnabled( bool v )
1001{ 1003{
1002 icons->setSorting( v ); 1004 icons->setSorting( v );
1003 if ( v ) 1005 if ( v )
1004 sort(); 1006 sort();
1005} 1007}
1006 1008
1007void LauncherView::setUpdatesEnabled( bool u ) 1009void LauncherView::setUpdatesEnabled( bool u )
1008{ 1010{
1009 icons->setUpdatesEnabled( u ); 1011 icons->setUpdatesEnabled( u );
1010} 1012}
1011 1013
1012void LauncherView::sort() 1014void LauncherView::sort()
1013{ 1015{
1014 icons->sort(); 1016 icons->sort();
1015} 1017}
1016 1018
1017void LauncherView::addItem(AppLnk* app, bool resort) 1019void LauncherView::addItem(AppLnk* app, bool resort)
1018{ 1020{
1019 icons->addItem(app,resort); 1021 icons->addItem(app,resort);
1020} 1022}
1021 1023
1022void LauncherView::paletteChange( const QPalette &p ) 1024void LauncherView::paletteChange( const QPalette &p )
1023{ 1025{
1024 icons->unsetPalette(); 1026 icons->unsetPalette();
1025 QVBox::paletteChange( p ); 1027 QVBox::paletteChange( p );
1026 if ( bgType == Ruled ) 1028 if ( bgType == Ruled )
1027 setBackgroundType( Ruled, QString::null ); 1029 setBackgroundType( Ruled, QString::null );
1028 QColorGroup cg = icons->colorGroup(); 1030 QColorGroup cg = icons->colorGroup();
1029 cg.setColor( QColorGroup::Text, textCol ); 1031 cg.setColor( QColorGroup::Text, textCol );
1030 icons->setPalette( QPalette(cg,cg,cg) ); 1032 icons->setPalette( QPalette(cg,cg,cg) );
1031} 1033}
1032 1034
1033void LauncherView::fontChanged(const QFont&) 1035void LauncherView::fontChanged(const QFont&)
1034{ 1036{
1035 odebug << "LauncherView::fontChanged()" << oendl; 1037 odebug << "LauncherView::fontChanged()" << oendl;
1036 icons->hideOrShowItems( FALSE ); 1038 icons->hideOrShowItems( FALSE );
1037} 1039}
1038 1040
1039void LauncherView::relayout(void) 1041void LauncherView::relayout(void)
1040{ 1042{
1041 icons->hideOrShowItems(FALSE); 1043 icons->hideOrShowItems(FALSE);
1042} 1044}
1043 1045
1044void LauncherView::flushBgCache() 1046void LauncherView::flushBgCache()
1045{ 1047{
1046 if ( !bgCache ) 1048 if ( !bgCache )
1047 return; 1049 return;
1048 // remove unreferenced backgrounds. 1050 // remove unreferenced backgrounds.
1049 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1051 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1050 while ( it != bgCache->end() ) { 1052 while ( it != bgCache->end() ) {
1051 QMap<QString,BgPixmap*>::Iterator curr = it; 1053 QMap<QString,BgPixmap*>::Iterator curr = it;
1052 ++it; 1054 ++it;
1053 if ( (*curr)->ref == 0 ) { 1055 if ( (*curr)->ref == 0 ) {
1054 delete (*curr); 1056 delete (*curr);
1055 bgCache->remove( curr ); 1057 bgCache->remove( curr );
1056 } 1058 }
1057 } 1059 }
1058} 1060}
1059 1061