summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.cpp84
1 files changed, 43 insertions, 41 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp
index 80f2c62..c82d3b9 100644
--- a/library/applnk.cpp
+++ b/library/applnk.cpp
@@ -451,46 +451,48 @@ AppLnk& AppLnk::operator=(const AppLnk &copy)
451 d->mCatList = copy.d->mCatList; 451 d->mCatList = copy.d->mCatList;
452 d->mPixmaps = copy.d->mPixmaps; 452 d->mPixmaps = copy.d->mPixmaps;
453 453
454 return *this; 454 return *this;
455} 455}
456/*! 456/*!
457 protected internally to share code 457 protected internally to share code
458 should I document that at all? 458 should I document that at all?
459 I don't know the TT style for that 459 I don't know the TT style for that
460*/ 460*/
461const QPixmap& AppLnk::pixmap( int pos, int size ) const { 461const QPixmap& AppLnk::pixmap( int pos, int size ) const {
462 if ( d->mPixmaps[pos].isNull() ) { 462 if ( d->mPixmaps[pos].isNull() ) {
463 AppLnk* that = (AppLnk*)this; 463 AppLnk* that = (AppLnk*)this;
464 if ( mIconFile.isEmpty() ) { 464 if ( mIconFile.isEmpty() ) {
465 MimeType mt(type()); 465 MimeType mt(type());
466 that->d->mPixmaps[pos] = pos ? mt.bigPixmap() : mt.pixmap(); 466 that->d->mPixmaps[pos] = pos ? mt.bigPixmap() : mt.pixmap();
467 if ( that->d->mPixmaps[pos].isNull() ) 467 if ( that->d->mPixmaps[pos].isNull() )
468 that->d->mPixmaps[pos].convertFromImage( 468 that->d->mPixmaps[pos].convertFromImage(
469 Resource::loadImage("UnknownDocument") 469 Resource::loadImage("UnknownDocument")
470 .smoothScale( size, size ) ); 470 .smoothScale( size, size ) );
471 return that->d->mPixmaps[pos]; 471 return that->d->mPixmaps[pos];
472 } 472 }
473 QImage unscaledIcon = Resource::loadImage( that->mIconFile ); 473
474 if ( unscaledIcon.isNull() ) { 474 QImage unscaledIcon = Resource::loadImage( that->mIconFile );
475 // qDebug( "Cannot find icon: %s", that->mIconFile.latin1() ); 475 if ( unscaledIcon.isNull() ) {
476 that->d->mPixmaps[pos].convertFromImage( 476 // qDebug( "Cannot find icon: %s", that->mIconFile.latin1() );
477 Resource::loadImage("UnknownDocument") 477 that->d->mPixmaps[pos].convertFromImage(
478 .smoothScale( size, size ) ); 478 Resource::loadImage("UnknownDocument")
479 } else { 479 .smoothScale( size, size ) );
480 that->d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); 480 } else {
481 that->d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); 481 that->d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) );
482 } 482 that->d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) );
483 return that->d->mPixmaps[pos]; 483 }
484 return that->d->mPixmaps[pos];
484 } 485 }
486
485 return d->mPixmaps[pos]; 487 return d->mPixmaps[pos];
486} 488}
487 489
488/*! 490/*!
489 Returns a small pixmap associated with the application. 491 Returns a small pixmap associated with the application.
490 492
491 \sa bigPixmap() setIcon() 493 \sa bigPixmap() setIcon()
492*/ 494*/
493const QPixmap& AppLnk::pixmap() const 495const QPixmap& AppLnk::pixmap() const
494{ 496{
495 if ( d->mPixmaps[0].isNull() ) { 497 if ( d->mPixmaps[0].isNull() ) {
496 return pixmap(AppLnkPrivate::Normal, smallSize ); 498 return pixmap(AppLnkPrivate::Normal, smallSize );
@@ -975,51 +977,51 @@ void AppLnk::removeLinkFile()
975{ 977{
976 if ( isValid() && linkFileKnown() && QFile::remove(linkFile()) ) { 978 if ( isValid() && linkFileKnown() && QFile::remove(linkFile()) ) {
977#ifndef QT_NO_COP 979#ifndef QT_NO_COP
978 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 980 QCopEnvelope e("QPE/System", "linkChanged(QString)");
979 e << linkFile(); 981 e << linkFile();
980#endif 982#endif
981 } 983 }
982} 984}
983 985
984class AppLnkImagePrivate { 986class AppLnkImagePrivate {
985public : 987public :
986 AppLnkImagePrivate( const QString & ImageName ) { 988 AppLnkImagePrivate( const QString & ImageName ) {
987 IconName = ImageName; 989 IconName = ImageName;
988 Small = 0; 990 Small = 0;
989 Big = 0; 991 Big = 0;
990 } 992 }
991 ~AppLnkImagePrivate( ) { 993 ~AppLnkImagePrivate( ) {
992 if ( Small ) delete Small; 994 if ( Small ) delete Small;
993 if ( Big ) delete Big; 995 if ( Big ) delete Big;
994 } 996 }
995 997
996 inline QPixmap * small( void ) { 998 inline QPixmap * small( void ) {
997 if( ! Small ) { 999 if( ! Small ) {
998 QImage unscaledIcon = Resource::loadImage( IconName ); 1000 QImage unscaledIcon = Resource::loadImage( IconName );
999 // works as long as smallSize remains static 1001 // works as long as smallSize remains static
1000 Small = new QPixmap(); 1002 Small = new QPixmap();
1001 Small->convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); 1003 Small->convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) );
1002 } 1004 }
1003 return Small; 1005 return Small;
1004 } 1006 }
1005 1007
1006 inline QPixmap * big( void ) { 1008 inline QPixmap * big( void ) {
1007 if( ! Big ) { 1009 if( ! Big ) {
1008 QImage unscaledIcon = Resource::loadImage( IconName ); 1010 QImage unscaledIcon = Resource::loadImage( IconName );
1009 // works as long as bigSize remains static 1011 // works as long as bigSize remains static
1010 Big = new QPixmap(); 1012 Big = new QPixmap();
1011 Big->convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); 1013 Big->convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) );
1012 } 1014 }
1013 return Big; 1015 return Big;
1014 } 1016 }
1015 1017
1016 QString IconName; 1018 QString IconName;
1017 QPixmap * Small; 1019 QPixmap * Small;
1018 QPixmap * Big; 1020 QPixmap * Big;
1019}; 1021};
1020 1022
1021class AppLnkSetPrivate { 1023class AppLnkSetPrivate {
1022public: 1024public:
1023 AppLnkSetPrivate() 1025 AppLnkSetPrivate()
1024 { 1026 {
1025 typPix.setAutoDelete(TRUE); 1027 typPix.setAutoDelete(TRUE);
@@ -1116,25 +1118,25 @@ void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QStrin
1116 depth++; 1118 depth++;
1117 if ( depth > 10 ) 1119 if ( depth > 10 )
1118 return; 1120 return;
1119 1121
1120 QDir dir( dr ); 1122 QDir dir( dr );
1121 QString typNameLocal = typName; 1123 QString typNameLocal = typName;
1122 1124
1123 if ( dir.exists( ".directory" ) ) { 1125 if ( dir.exists( ".directory" ) ) {
1124 Config config( dr + "/.directory", Config::File ); 1126 Config config( dr + "/.directory", Config::File );
1125 config.setGroup( "Desktop Entry" ); 1127 config.setGroup( "Desktop Entry" );
1126 typNameLocal = config.readEntry( "Name", typNameLocal ); 1128 typNameLocal = config.readEntry( "Name", typNameLocal );
1127 if ( !typ.isEmpty() ) { 1129 if ( !typ.isEmpty() ) {
1128 d->typPix.insert( typ, 1130 d->typPix.insert( typ,
1129 new AppLnkImagePrivate( config.readEntry( "Icon", "AppsIcon" ) ) 1131 new AppLnkImagePrivate( config.readEntry( "Icon", "AppsIcon" ) )
1130 ); 1132 );
1131 d->typName.insert(typ, new QString(typNameLocal)); 1133 d->typName.insert(typ, new QString(typNameLocal));
1132 1134
1133 } 1135 }
1134 } 1136 }
1135 1137
1136 const QFileInfoList *list = dir.entryInfoList(); 1138 const QFileInfoList *list = dir.entryInfoList();
1137 if ( list ) { 1139 if ( list ) {
1138 QFileInfo* fi; 1140 QFileInfo* fi;
1139 bool cadded=FALSE; 1141 bool cadded=FALSE;
1140 for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) { 1142 for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) {