-rw-r--r-- | library/applnk.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index c82d3b9..874a1b6 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -496,387 +496,389 @@ const QPixmap& AppLnk::pixmap() const | |||
496 | { | 496 | { |
497 | if ( d->mPixmaps[0].isNull() ) { | 497 | if ( d->mPixmaps[0].isNull() ) { |
498 | return pixmap(AppLnkPrivate::Normal, smallSize ); | 498 | return pixmap(AppLnkPrivate::Normal, smallSize ); |
499 | } | 499 | } |
500 | return d->mPixmaps[0]; | 500 | return d->mPixmaps[0]; |
501 | } | 501 | } |
502 | 502 | ||
503 | /*! | 503 | /*! |
504 | Returns a large pixmap associated with the application. | 504 | Returns a large pixmap associated with the application. |
505 | 505 | ||
506 | \sa pixmap() setIcon() | 506 | \sa pixmap() setIcon() |
507 | */ | 507 | */ |
508 | const QPixmap& AppLnk::bigPixmap() const | 508 | const QPixmap& AppLnk::bigPixmap() const |
509 | { | 509 | { |
510 | if ( d->mPixmaps[1].isNull() ) { | 510 | if ( d->mPixmaps[1].isNull() ) { |
511 | return pixmap( AppLnkPrivate::Big, bigSize ); | 511 | return pixmap( AppLnkPrivate::Big, bigSize ); |
512 | } | 512 | } |
513 | return d->mPixmaps[1]; | 513 | return d->mPixmaps[1]; |
514 | } | 514 | } |
515 | 515 | ||
516 | /*! | 516 | /*! |
517 | Returns the type of the AppLnk. For applications, games and | 517 | Returns the type of the AppLnk. For applications, games and |
518 | settings the type is \c Application; for documents the type is the | 518 | settings the type is \c Application; for documents the type is the |
519 | document's MIME type. | 519 | document's MIME type. |
520 | */ | 520 | */ |
521 | QString AppLnk::type() const | 521 | QString AppLnk::type() const |
522 | { | 522 | { |
523 | if ( mType.isNull() ) { | 523 | if ( mType.isNull() ) { |
524 | AppLnk* that = (AppLnk*)this; | 524 | AppLnk* that = (AppLnk*)this; |
525 | QString f = file(); | 525 | QString f = file(); |
526 | if ( !f.isNull() ) { | 526 | if ( !f.isNull() ) { |
527 | MimeType mt(f); | 527 | MimeType mt(f); |
528 | that->mType = mt.id(); | 528 | that->mType = mt.id(); |
529 | return that->mType; | 529 | return that->mType; |
530 | } | 530 | } |
531 | } | 531 | } |
532 | return mType; | 532 | return mType; |
533 | } | 533 | } |
534 | 534 | ||
535 | /*! | 535 | /*! |
536 | Returns the file associated with the AppLnk. | 536 | Returns the file associated with the AppLnk. |
537 | 537 | ||
538 | \sa exec() name() | 538 | \sa exec() name() |
539 | */ | 539 | */ |
540 | QString AppLnk::file() const | 540 | QString AppLnk::file() const |
541 | { | 541 | { |
542 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { | 542 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { |
543 | AppLnk* that = (AppLnk*)this; | 543 | AppLnk* that = (AppLnk*)this; |
544 | QString ext = MimeType(mType).extension(); | 544 | QString ext = MimeType(mType).extension(); |
545 | if ( !ext.isEmpty() ) | 545 | if ( !ext.isEmpty() ) |
546 | ext = "." + ext; | 546 | ext = "." + ext; |
547 | if ( !mLinkFile.isEmpty() ) { | 547 | if ( !mLinkFile.isEmpty() ) { |
548 | that->mFile = | 548 | that->mFile = |
549 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 549 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
550 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 550 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
551 | qDebug("mFile now == %s", mFile.latin1()); | 551 | qDebug("mFile now == %s", mFile.latin1()); |
552 | } else if ( mType.contains('/') ) { | 552 | } else if ( mType.contains('/') ) { |
553 | that->mFile = | 553 | that->mFile = |
554 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 554 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
555 | /* | 555 | /* |
556 | * A file with the same name or a .desktop file already exists | 556 | * A file with the same name or a .desktop file already exists |
557 | */ | 557 | */ |
558 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { | 558 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { |
559 | int n=1; | 559 | int n=1; |
560 | QString nn; | 560 | QString nn; |
561 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 561 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
562 | || QFile::exists(nn+".desktop")) | 562 | || QFile::exists(nn+".desktop")) |
563 | n++; | 563 | n++; |
564 | that->mFile = nn; | 564 | that->mFile = nn; |
565 | } | 565 | } |
566 | that->mLinkFile = that->mFile+".desktop"; | 566 | that->mLinkFile = that->mFile+".desktop"; |
567 | that->mFile += ext; | 567 | that->mFile += ext; |
568 | } | 568 | } |
569 | prepareDirectories(that->mFile); | 569 | prepareDirectories(that->mFile); |
570 | if ( !that->mFile.isEmpty() ) { | 570 | if ( !that->mFile.isEmpty() ) { |
571 | QFile f(that->mFile); | 571 | QFile f(that->mFile); |
572 | if ( !f.open(IO_WriteOnly) ) | 572 | if ( !f.open(IO_WriteOnly) ) |
573 | that->mFile = QString::null; | 573 | that->mFile = QString::null; |
574 | return that->mFile; | 574 | return that->mFile; |
575 | } | 575 | } |
576 | } | 576 | } |
577 | return mFile; | 577 | return mFile; |
578 | } | 578 | } |
579 | 579 | ||
580 | /*! | 580 | /*! |
581 | Returns the desktop file corresponding to this AppLnk. | 581 | Returns the desktop file corresponding to this AppLnk. |
582 | 582 | ||
583 | \sa file() exec() name() | 583 | \sa file() exec() name() |
584 | */ | 584 | */ |
585 | QString AppLnk::linkFile() const | 585 | QString AppLnk::linkFile() const |
586 | { | 586 | { |
587 | if ( mLinkFile.isNull() ) { | 587 | if ( mLinkFile.isNull() ) { |
588 | AppLnk* that = (AppLnk*)this; | 588 | AppLnk* that = (AppLnk*)this; |
589 | if ( type().contains('/') ) { | 589 | if ( type().contains('/') ) { |
590 | StorageInfo storage; | 590 | StorageInfo storage; |
591 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); | 591 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); |
592 | /* tmpfs + and ramfs are available too but not removable | 592 | /* tmpfs + and ramfs are available too but not removable |
593 | * either we fix storage or add this | 593 | * either we fix storage or add this |
594 | */ | 594 | */ |
595 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs") ) { | 595 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs") ) { |
596 | that->mLinkFile = fs->path(); | 596 | that->mLinkFile = fs->path(); |
597 | } else | 597 | } else |
598 | that->mLinkFile = getenv( "HOME" ); | 598 | that->mLinkFile = getenv( "HOME" ); |
599 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); | 599 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); |
600 | 600 | ||
601 | /* the desktop file exists make sure we don't point to the same file */ | 601 | /* the desktop file exists make sure we don't point to the same file */ |
602 | if ( QFile::exists(that->mLinkFile+".desktop") ) { | 602 | if ( QFile::exists(that->mLinkFile+".desktop") ) { |
603 | AppLnk lnk( that->mLinkFile + ".desktop" ); | 603 | AppLnk lnk( that->mLinkFile + ".desktop" ); |
604 | 604 | ||
605 | /* the linked is different */ | 605 | /* the linked is different */ |
606 | if(that->file() != lnk.file() ) { | 606 | if(that->file() != lnk.file() ) { |
607 | int n = 1; | 607 | int n = 1; |
608 | QString nn; | 608 | QString nn; |
609 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")) { | 609 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")) { |
610 | n++; | 610 | n++; |
611 | /* just to be sure */ | 611 | /* just to be sure */ |
612 | AppLnk lnk(nn ); | 612 | AppLnk lnk(nn ); |
613 | if (lnk.file() == that->file() ) | 613 | if (lnk.file() == that->file() ) |
614 | break; | 614 | break; |
615 | } | 615 | } |
616 | that->mLinkFile = nn; | 616 | that->mLinkFile = nn; |
617 | } | 617 | } |
618 | } | 618 | } |
619 | that->mLinkFile += ".desktop"; | 619 | that->mLinkFile += ".desktop"; |
620 | storeLink(); | 620 | storeLink(); |
621 | } | 621 | } |
622 | return that->mLinkFile; | 622 | return that->mLinkFile; |
623 | } | 623 | } |
624 | return mLinkFile; | 624 | return mLinkFile; |
625 | } | 625 | } |
626 | 626 | ||
627 | /*! | 627 | /*! |
628 | Copies \a copy. | 628 | Copies \a copy. |
629 | */ | 629 | */ |
630 | AppLnk::AppLnk( const AppLnk © ) | 630 | AppLnk::AppLnk( const AppLnk © ) |
631 | { | 631 | { |
632 | mName = copy.mName; | 632 | mName = copy.mName; |
633 | mPixmap = copy.mPixmap; | 633 | mPixmap = copy.mPixmap; |
634 | mBigPixmap = copy.mBigPixmap; | 634 | mBigPixmap = copy.mBigPixmap; |
635 | mExec = copy.mExec; | 635 | mExec = copy.mExec; |
636 | mType = copy.mType; | 636 | mType = copy.mType; |
637 | mRotation = copy.mRotation; | 637 | mRotation = copy.mRotation; |
638 | mComment = copy.mComment; | 638 | mComment = copy.mComment; |
639 | mFile = copy.mFile; | 639 | mFile = copy.mFile; |
640 | mLinkFile = copy.mLinkFile; | 640 | mLinkFile = copy.mLinkFile; |
641 | mIconFile = copy.mIconFile; | 641 | mIconFile = copy.mIconFile; |
642 | mMimeTypes = copy.mMimeTypes; | 642 | mMimeTypes = copy.mMimeTypes; |
643 | mMimeTypeIcons = copy.mMimeTypeIcons; | 643 | mMimeTypeIcons = copy.mMimeTypeIcons; |
644 | mId = 0; | 644 | mId = 0; |
645 | d = new AppLnkPrivate(); | 645 | d = new AppLnkPrivate(); |
646 | d->mCat = copy.d->mCat; | 646 | d->mCat = copy.d->mCat; |
647 | d->mCatList = copy.d->mCatList; | 647 | d->mCatList = copy.d->mCatList; |
648 | d->mPixmaps = copy.d->mPixmaps; | 648 | d->mPixmaps = copy.d->mPixmaps; |
649 | } | 649 | } |
650 | 650 | ||
651 | /*! | 651 | /*! |
652 | Destroys the AppLnk. Note that if the AppLnk is currently a member | 652 | Destroys the AppLnk. Note that if the AppLnk is currently a member |
653 | of an AppLnkSet, this will produce a run-time warning. | 653 | of an AppLnkSet, this will produce a run-time warning. |
654 | 654 | ||
655 | \sa AppLnkSet::add() AppLnkSet::remove() | 655 | \sa AppLnkSet::add() AppLnkSet::remove() |
656 | */ | 656 | */ |
657 | AppLnk::~AppLnk() | 657 | AppLnk::~AppLnk() |
658 | { | 658 | { |
659 | if ( mId ) | 659 | if ( mId ) |
660 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 660 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
661 | if ( d ) | 661 | if ( d ) |
662 | delete d; | 662 | delete d; |
663 | } | 663 | } |
664 | 664 | ||
665 | /*! | 665 | /*! |
666 | \overload | 666 | \overload |
667 | Executes the application associated with this AppLnk. | 667 | Executes the application associated with this AppLnk. |
668 | 668 | ||
669 | \sa exec() | 669 | \sa exec() |
670 | */ | 670 | */ |
671 | void AppLnk::execute() const | 671 | void AppLnk::execute() const |
672 | { | 672 | { |
673 | execute( QStringList::split( ' ', property( "Arguments" ) ) ); | 673 | execute( QStringList::split( ' ', property( "Arguments" ) ) ); |
674 | } | 674 | } |
675 | 675 | ||
676 | /*! | 676 | /*! |
677 | Executes the application associated with this AppLnk, with | 677 | Executes the application associated with this AppLnk, with |
678 | \a args as arguments. | 678 | \a args as arguments. |
679 | 679 | ||
680 | \sa exec() | 680 | \sa exec() |
681 | */ | 681 | */ |
682 | void AppLnk::execute(const QStringList& args) const | 682 | void AppLnk::execute(const QStringList& args) const |
683 | { | 683 | { |
684 | #ifdef Q_WS_QWS | 684 | #ifdef Q_WS_QWS |
685 | if ( !mRotation.isEmpty() ) { | 685 | if ( !mRotation.isEmpty() ) { |
686 | // ######## this will only work in the server | 686 | // ######## this will only work in the server |
687 | int rot = QPEApplication::defaultRotation(); | 687 | int rot = QPEApplication::defaultRotation(); |
688 | int j = 0; | ||
688 | rot = (rot+mRotation.toInt())%360; | 689 | rot = (rot+mRotation.toInt())%360; |
689 | QCString old = getenv("QWS_DISPLAY"); | 690 | QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed"; |
690 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 691 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); |
692 | setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg( driver ).arg( rot ), 1 ); | ||
691 | invoke(args); | 693 | invoke(args); |
692 | setenv("QWS_DISPLAY", old.data(), 1); | 694 | setenv("QWS_DISPLAY", old.data(), 1); |
693 | } else | 695 | } else |
694 | #endif | 696 | #endif |
695 | invoke(args); | 697 | invoke(args); |
696 | } | 698 | } |
697 | 699 | ||
698 | /*! | 700 | /*! |
699 | Invokes the application associated with this AppLnk, with | 701 | Invokes the application associated with this AppLnk, with |
700 | \a args as arguments. Rotation is not taken into account by | 702 | \a args as arguments. Rotation is not taken into account by |
701 | this function, so you should not call it directly. | 703 | this function, so you should not call it directly. |
702 | 704 | ||
703 | \sa execute() | 705 | \sa execute() |
704 | */ | 706 | */ |
705 | void AppLnk::invoke(const QStringList& args) const | 707 | void AppLnk::invoke(const QStringList& args) const |
706 | { | 708 | { |
707 | if ( property( "Arguments" ).isEmpty() ) | 709 | if ( property( "Arguments" ).isEmpty() ) |
708 | Global::execute( exec(), args[0] ); | 710 | Global::execute( exec(), args[0] ); |
709 | else | 711 | else |
710 | Global::execute( exec(), args.join( " " ) ); | 712 | Global::execute( exec(), args.join( " " ) ); |
711 | } | 713 | } |
712 | 714 | ||
713 | /*! | 715 | /*! |
714 | Sets the Exec property to \a exec. | 716 | Sets the Exec property to \a exec. |
715 | 717 | ||
716 | \sa exec() name() | 718 | \sa exec() name() |
717 | */ | 719 | */ |
718 | void AppLnk::setExec( const QString& exec ) | 720 | void AppLnk::setExec( const QString& exec ) |
719 | { | 721 | { |
720 | mExec = exec; | 722 | mExec = exec; |
721 | } | 723 | } |
722 | 724 | ||
723 | #if 0 // this was inlined for better BC | 725 | #if 0 // this was inlined for better BC |
724 | /*! | 726 | /*! |
725 | Sets the Rotation property to \a rot. | 727 | Sets the Rotation property to \a rot. |
726 | 728 | ||
727 | \sa rotation() | 729 | \sa rotation() |
728 | */ | 730 | */ |
729 | void AppLnk::setRotation ( const QString &rot ) | 731 | void AppLnk::setRotation ( const QString &rot ) |
730 | { | 732 | { |
731 | mRotation = rot; | 733 | mRotation = rot; |
732 | } | 734 | } |
733 | #endif | 735 | #endif |
734 | 736 | ||
735 | /*! | 737 | /*! |
736 | Sets the Name property to \a docname. | 738 | Sets the Name property to \a docname. |
737 | 739 | ||
738 | \sa name() | 740 | \sa name() |
739 | */ | 741 | */ |
740 | void AppLnk::setName( const QString& docname ) | 742 | void AppLnk::setName( const QString& docname ) |
741 | { | 743 | { |
742 | mName = docname; | 744 | mName = docname; |
743 | } | 745 | } |
744 | 746 | ||
745 | /*! | 747 | /*! |
746 | Sets the File property to \a filename. | 748 | Sets the File property to \a filename. |
747 | 749 | ||
748 | \sa file() name() | 750 | \sa file() name() |
749 | */ | 751 | */ |
750 | void AppLnk::setFile( const QString& filename ) | 752 | void AppLnk::setFile( const QString& filename ) |
751 | { | 753 | { |
752 | mFile = filename; | 754 | mFile = filename; |
753 | } | 755 | } |
754 | 756 | ||
755 | /*! | 757 | /*! |
756 | Sets the LinkFile property to \a filename. | 758 | Sets the LinkFile property to \a filename. |
757 | 759 | ||
758 | \sa linkFile() | 760 | \sa linkFile() |
759 | */ | 761 | */ |
760 | void AppLnk::setLinkFile( const QString& filename ) | 762 | void AppLnk::setLinkFile( const QString& filename ) |
761 | { | 763 | { |
762 | mLinkFile = filename; | 764 | mLinkFile = filename; |
763 | } | 765 | } |
764 | 766 | ||
765 | /*! | 767 | /*! |
766 | Sets the Comment property to \a comment. | 768 | Sets the Comment property to \a comment. |
767 | 769 | ||
768 | This text is displayed in the 'Details Dialog', for example if the | 770 | This text is displayed in the 'Details Dialog', for example if the |
769 | user uses the 'press-and-hold' gesture. | 771 | user uses the 'press-and-hold' gesture. |
770 | 772 | ||
771 | \sa comment() | 773 | \sa comment() |
772 | */ | 774 | */ |
773 | void AppLnk::setComment( const QString& comment ) | 775 | void AppLnk::setComment( const QString& comment ) |
774 | { | 776 | { |
775 | mComment = comment; | 777 | mComment = comment; |
776 | } | 778 | } |
777 | 779 | ||
778 | /*! | 780 | /*! |
779 | Sets the Type property to \a type. | 781 | Sets the Type property to \a type. |
780 | 782 | ||
781 | For applications, games and settings the type should be \c | 783 | For applications, games and settings the type should be \c |
782 | Application; for documents the type should be the document's MIME | 784 | Application; for documents the type should be the document's MIME |
783 | type. | 785 | type. |
784 | 786 | ||
785 | \sa type() | 787 | \sa type() |
786 | */ | 788 | */ |
787 | void AppLnk::setType( const QString& type ) | 789 | void AppLnk::setType( const QString& type ) |
788 | { | 790 | { |
789 | mType = type; | 791 | mType = type; |
790 | } | 792 | } |
791 | 793 | ||
792 | /*! | 794 | /*! |
793 | \fn QString AppLnk::icon() const | 795 | \fn QString AppLnk::icon() const |
794 | 796 | ||
795 | Returns the Icon property. | 797 | Returns the Icon property. |
796 | 798 | ||
797 | \sa setIcon() | 799 | \sa setIcon() |
798 | */ | 800 | */ |
799 | 801 | ||
800 | /*! | 802 | /*! |
801 | Sets the Icon property to \a iconname. This is the filename from | 803 | Sets the Icon property to \a iconname. This is the filename from |
802 | which the pixmap() and bigPixmap() are obtained. | 804 | which the pixmap() and bigPixmap() are obtained. |
803 | 805 | ||
804 | \sa icon() setSmallIconSize() setBigIconSize() | 806 | \sa icon() setSmallIconSize() setBigIconSize() |
805 | */ | 807 | */ |
806 | void AppLnk::setIcon( const QString& iconname ) | 808 | void AppLnk::setIcon( const QString& iconname ) |
807 | { | 809 | { |
808 | mIconFile = iconname; | 810 | mIconFile = iconname; |
809 | QImage unscaledIcon = Resource::loadImage( mIconFile ); | 811 | QImage unscaledIcon = Resource::loadImage( mIconFile ); |
810 | d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 812 | d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
811 | d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 813 | d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
812 | } | 814 | } |
813 | 815 | ||
814 | /*! | 816 | /*! |
815 | Sets the Categories property to \a c. | 817 | Sets the Categories property to \a c. |
816 | 818 | ||
817 | See the CategoryWidget for more details. | 819 | See the CategoryWidget for more details. |
818 | 820 | ||
819 | \sa categories() | 821 | \sa categories() |
820 | */ | 822 | */ |
821 | void AppLnk::setCategories( const QArray<int>& c ) | 823 | void AppLnk::setCategories( const QArray<int>& c ) |
822 | { | 824 | { |
823 | d->mCat = c; | 825 | d->mCat = c; |
824 | d->updateCatListFromArray(); | 826 | d->updateCatListFromArray(); |
825 | } | 827 | } |
826 | 828 | ||
827 | /*! | 829 | /*! |
828 | \fn QStringList AppLnk::mimeTypeIcons() const | 830 | \fn QStringList AppLnk::mimeTypeIcons() const |
829 | 831 | ||
830 | Returns the MimeTypeIcons property of the AppLnk. | 832 | Returns the MimeTypeIcons property of the AppLnk. |
831 | */ | 833 | */ |
832 | 834 | ||
833 | /*! | 835 | /*! |
834 | Attempts to ensure that the link file for this AppLnk exists, | 836 | Attempts to ensure that the link file for this AppLnk exists, |
835 | including creating any required directories. Returns TRUE if | 837 | including creating any required directories. Returns TRUE if |
836 | successful; otherwise returns FALSE. | 838 | successful; otherwise returns FALSE. |
837 | 839 | ||
838 | You should not need to use this function. | 840 | You should not need to use this function. |
839 | */ | 841 | */ |
840 | bool AppLnk::ensureLinkExists() const | 842 | bool AppLnk::ensureLinkExists() const |
841 | { | 843 | { |
842 | QString lf = linkFile(); | 844 | QString lf = linkFile(); |
843 | return prepareDirectories(lf); | 845 | return prepareDirectories(lf); |
844 | } | 846 | } |
845 | 847 | ||
846 | /*! | 848 | /*! |
847 | Commits the AppLnk to disk. Returns TRUE if the operation succeeded; | 849 | Commits the AppLnk to disk. Returns TRUE if the operation succeeded; |
848 | otherwise returns FALSE. | 850 | otherwise returns FALSE. |
849 | 851 | ||
850 | In addition, the "linkChanged(QString)" message is sent to the | 852 | In addition, the "linkChanged(QString)" message is sent to the |
851 | "QPE/System" \link qcop.html QCop\endlink channel. | 853 | "QPE/System" \link qcop.html QCop\endlink channel. |
852 | */ | 854 | */ |
853 | bool AppLnk::writeLink() const | 855 | bool AppLnk::writeLink() const |
854 | { | 856 | { |
855 | // Only re-writes settable parts | 857 | // Only re-writes settable parts |
856 | QString lf = linkFile(); | 858 | QString lf = linkFile(); |
857 | if ( !ensureLinkExists() ) | 859 | if ( !ensureLinkExists() ) |
858 | return FALSE; | 860 | return FALSE; |
859 | storeLink(); | 861 | storeLink(); |
860 | return TRUE; | 862 | return TRUE; |
861 | } | 863 | } |
862 | 864 | ||
863 | /*! | 865 | /*! |
864 | \internal | 866 | \internal |
865 | */ | 867 | */ |
866 | void AppLnk::storeLink() const | 868 | void AppLnk::storeLink() const |
867 | { | 869 | { |
868 | Config config( mLinkFile, Config::File ); | 870 | Config config( mLinkFile, Config::File ); |
869 | config.setGroup("Desktop Entry"); | 871 | config.setGroup("Desktop Entry"); |
870 | config.writeEntry("Name",mName); | 872 | config.writeEntry("Name",mName); |
871 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); | 873 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); |
872 | config.writeEntry("Type",type()); | 874 | config.writeEntry("Type",type()); |
873 | if(!rotation().isEmpty()) | 875 | if(!rotation().isEmpty()) |
874 | config.writeEntry("Rotation",rotation()); | 876 | config.writeEntry("Rotation",rotation()); |
875 | else | 877 | else |
876 | config.removeEntry("Rotation"); | 878 | config.removeEntry("Rotation"); |
877 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); | 879 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); |
878 | QString f = file(); | 880 | QString f = file(); |
879 | int i = 0; | 881 | int i = 0; |
880 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) | 882 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) |
881 | i++; | 883 | i++; |
882 | while ( i && f[i] != '/' ) | 884 | while ( i && f[i] != '/' ) |