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