author | sandman <sandman> | 2002-10-06 03:26:59 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-06 03:26:59 (UTC) |
commit | a1ebad08d462e682554d39a9beabce125a374452 (patch) (unidiff) | |
tree | 254d7ddc5b257b278172af4952b2bec27b5df3b5 /library/applnk.cpp | |
parent | 2c16c8767fa5c16c0eeebc7008202a68a61a5308 (diff) | |
download | opie-a1ebad08d462e682554d39a9beabce125a374452.zip opie-a1ebad08d462e682554d39a9beabce125a374452.tar.gz opie-a1ebad08d462e682554d39a9beabce125a374452.tar.bz2 |
- support "Rotation" setting in .desktop applnk file
- changed properties dialog to make Rotation editable
- fixed a long-standing QPE bug:
launcher expects AppLnk::file() to return QString::null for *all real*
applnks (as opposed to doclnks) -- but AppLnk itself initializes this
field to the name of the dir, where the applnk is stored.
This is why qcop "QPE/System" "linkChanged(QString)" xyz.desktop cleared
a whole launcher tab
I hope I didn't break anything with this change ;)
-rw-r--r-- | library/applnk.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 44f3f58..a56da5d 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -363,25 +363,28 @@ AppLnk::AppLnk( const QString &file ) | |||
363 | mExec = config.readEntry( "Exec" ); | 363 | mExec = config.readEntry( "Exec" ); |
364 | mType = config.readEntry( "Type", QString::null ); | 364 | mType = config.readEntry( "Type", QString::null ); |
365 | mIconFile = config.readEntry( "Icon", QString::null ); | 365 | mIconFile = config.readEntry( "Icon", QString::null ); |
366 | mRotation = config.readEntry( "Rotation", "" ); | 366 | mRotation = config.readEntry( "Rotation", "" ); |
367 | mComment = config.readEntry( "Comment", QString::null ); | 367 | mComment = config.readEntry( "Comment", QString::null ); |
368 | // MIME types are case-insensitive. | 368 | // MIME types are case-insensitive. |
369 | mMimeTypes = config.readListEntry( "MimeType", ';' ); | 369 | mMimeTypes = config.readListEntry( "MimeType", ';' ); |
370 | for (QStringList::Iterator it=mMimeTypes.begin(); it!=mMimeTypes.end(); ++it) | 370 | for (QStringList::Iterator it=mMimeTypes.begin(); it!=mMimeTypes.end(); ++it) |
371 | *it = (*it).lower(); | 371 | *it = (*it).lower(); |
372 | mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); | 372 | mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); |
373 | mLinkFile = file; | 373 | mLinkFile = file; |
374 | mFile = config.readEntry("File", QString::null); | 374 | mFile = config.readEntry("File", QString::null); |
375 | if ( mFile[0] != '/' ) { | 375 | if ( !mExec. isEmpty ( )) { |
376 | mFile = QString::null; | ||
377 | } | ||
378 | else if ( mFile[0] != '/' ) { | ||
376 | int slash = file.findRev('/'); | 379 | int slash = file.findRev('/'); |
377 | if ( slash >= 0 ) { | 380 | if ( slash >= 0 ) { |
378 | mFile = file.left(slash) + '/' + mFile; | 381 | mFile = file.left(slash) + '/' + mFile; |
379 | } | 382 | } |
380 | } | 383 | } |
381 | d->mCatList = config.readListEntry("Categories", ';'); | 384 | d->mCatList = config.readListEntry("Categories", ';'); |
382 | if ( d->mCatList[0].toInt() < -1 ) { | 385 | if ( d->mCatList[0].toInt() < -1 ) { |
383 | // numeric cats in file! convert to text | 386 | // numeric cats in file! convert to text |
384 | Categories cat( 0 ); | 387 | Categories cat( 0 ); |
385 | cat.load( categoryFileName() ); | 388 | cat.load( categoryFileName() ); |
386 | d->mCat.resize( d->mCatList.count() ); | 389 | d->mCat.resize( d->mCatList.count() ); |
387 | int i; | 390 | int i; |
@@ -511,33 +514,34 @@ QString AppLnk::type() const | |||
511 | } | 514 | } |
512 | } | 515 | } |
513 | return mType; | 516 | return mType; |
514 | } | 517 | } |
515 | 518 | ||
516 | /*! | 519 | /*! |
517 | Returns the file associated with the AppLnk. | 520 | Returns the file associated with the AppLnk. |
518 | 521 | ||
519 | \sa exec() name() | 522 | \sa exec() name() |
520 | */ | 523 | */ |
521 | QString AppLnk::file() const | 524 | QString AppLnk::file() const |
522 | { | 525 | { |
523 | if ( mFile.isNull() ) { | 526 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { |
524 | AppLnk* that = (AppLnk*)this; | 527 | AppLnk* that = (AppLnk*)this; |
525 | QString ext = MimeType(mType).extension(); | 528 | QString ext = MimeType(mType).extension(); |
526 | if ( !ext.isEmpty() ) | 529 | if ( !ext.isEmpty() ) |
527 | ext = "." + ext; | 530 | ext = "." + ext; |
528 | if ( !mLinkFile.isEmpty() ) { | 531 | if ( !mLinkFile.isEmpty() ) { |
529 | that->mFile = | 532 | that->mFile = |
530 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 533 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
531 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 534 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
535 | qDebug("mFile now == %s", mFile.latin1()); | ||
532 | } else if ( mType.contains('/') ) { | 536 | } else if ( mType.contains('/') ) { |
533 | that->mFile = | 537 | that->mFile = |
534 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 538 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
535 | /* | 539 | /* |
536 | * A file with the same name or a .desktop file already exists | 540 | * A file with the same name or a .desktop file already exists |
537 | */ | 541 | */ |
538 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { | 542 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { |
539 | int n=1; | 543 | int n=1; |
540 | QString nn; | 544 | QString nn; |
541 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 545 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
542 | || QFile::exists(nn+".desktop")) | 546 | || QFile::exists(nn+".desktop")) |
543 | n++; | 547 | n++; |
@@ -688,24 +692,36 @@ void AppLnk::invoke(const QStringList& args) const | |||
688 | } | 692 | } |
689 | 693 | ||
690 | /*! | 694 | /*! |
691 | Sets the Exec property to \a exec. | 695 | Sets the Exec property to \a exec. |
692 | 696 | ||
693 | \sa exec() name() | 697 | \sa exec() name() |
694 | */ | 698 | */ |
695 | void AppLnk::setExec( const QString& exec ) | 699 | void AppLnk::setExec( const QString& exec ) |
696 | { | 700 | { |
697 | mExec = exec; | 701 | mExec = exec; |
698 | } | 702 | } |
699 | 703 | ||
704 | #if 0 // this was inlined for better BC | ||
705 | /*! | ||
706 | Sets the Rotation property to \a rot. | ||
707 | |||
708 | \sa rotation() | ||
709 | */ | ||
710 | void AppLnk::setRotation ( const QString &rot ) | ||
711 | { | ||
712 | mRotation = rot; | ||
713 | } | ||
714 | #endif | ||
715 | |||
700 | /*! | 716 | /*! |
701 | Sets the Name property to \a docname. | 717 | Sets the Name property to \a docname. |
702 | 718 | ||
703 | \sa name() | 719 | \sa name() |
704 | */ | 720 | */ |
705 | void AppLnk::setName( const QString& docname ) | 721 | void AppLnk::setName( const QString& docname ) |
706 | { | 722 | { |
707 | mName = docname; | 723 | mName = docname; |
708 | } | 724 | } |
709 | 725 | ||
710 | /*! | 726 | /*! |
711 | Sets the File property to \a filename. | 727 | Sets the File property to \a filename. |
@@ -826,24 +842,28 @@ bool AppLnk::writeLink() const | |||
826 | } | 842 | } |
827 | 843 | ||
828 | /*! | 844 | /*! |
829 | \internal | 845 | \internal |
830 | */ | 846 | */ |
831 | void AppLnk::storeLink() const | 847 | void AppLnk::storeLink() const |
832 | { | 848 | { |
833 | Config config( mLinkFile, Config::File ); | 849 | Config config( mLinkFile, Config::File ); |
834 | config.setGroup("Desktop Entry"); | 850 | config.setGroup("Desktop Entry"); |
835 | config.writeEntry("Name",mName); | 851 | config.writeEntry("Name",mName); |
836 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); | 852 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); |
837 | config.writeEntry("Type",type()); | 853 | config.writeEntry("Type",type()); |
854 | if(!rotation().isEmpty()) | ||
855 | config.writeEntry("Rotation",rotation()); | ||
856 | else | ||
857 | config.removeEntry("Rotation"); | ||
838 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); | 858 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); |
839 | QString f = file(); | 859 | QString f = file(); |
840 | int i = 0; | 860 | int i = 0; |
841 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) | 861 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) |
842 | i++; | 862 | i++; |
843 | while ( i && f[i] != '/' ) | 863 | while ( i && f[i] != '/' ) |
844 | i--; | 864 | i--; |
845 | // simple case where in the same directory | 865 | // simple case where in the same directory |
846 | if ( mLinkFile.find( '/', i + 1 ) < 0 ) | 866 | if ( mLinkFile.find( '/', i + 1 ) < 0 ) |
847 | f = f.mid(i+1); | 867 | f = f.mid(i+1); |
848 | // ### could do relative ie ../../otherDocs/file.doc | 868 | // ### could do relative ie ../../otherDocs/file.doc |
849 | config.writeEntry("File",f); | 869 | config.writeEntry("File",f); |