summaryrefslogtreecommitdiff
Unidiff
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
@@ -514,352 +514,352 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
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