-rw-r--r-- | library/applnk.cpp | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 1c1a227..80f2c62 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -983,2 +983,39 @@ void AppLnk::removeLinkFile() | |||
983 | 983 | ||
984 | class AppLnkImagePrivate { | ||
985 | public : | ||
986 | AppLnkImagePrivate( const QString & ImageName ) { | ||
987 | IconName = ImageName; | ||
988 | Small = 0; | ||
989 | Big = 0; | ||
990 | } | ||
991 | ~AppLnkImagePrivate( ) { | ||
992 | if ( Small ) delete Small; | ||
993 | if ( Big ) delete Big; | ||
994 | } | ||
995 | |||
996 | inline QPixmap * small( void ) { | ||
997 | if( ! Small ) { | ||
998 | QImage unscaledIcon = Resource::loadImage( IconName ); | ||
999 | // works as long as smallSize remains static | ||
1000 | Small = new QPixmap(); | ||
1001 | Small->convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | ||
1002 | } | ||
1003 | return Small; | ||
1004 | } | ||
1005 | |||
1006 | inline QPixmap * big( void ) { | ||
1007 | if( ! Big ) { | ||
1008 | QImage unscaledIcon = Resource::loadImage( IconName ); | ||
1009 | // works as long as bigSize remains static | ||
1010 | Big = new QPixmap(); | ||
1011 | Big->convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | ||
1012 | } | ||
1013 | return Big; | ||
1014 | } | ||
1015 | |||
1016 | QString IconName; | ||
1017 | QPixmap * Small; | ||
1018 | QPixmap * Big; | ||
1019 | }; | ||
1020 | |||
984 | class AppLnkSetPrivate { | 1021 | class AppLnkSetPrivate { |
@@ -988,3 +1025,2 @@ public: | |||
988 | typPix.setAutoDelete(TRUE); | 1025 | typPix.setAutoDelete(TRUE); |
989 | typPixBig.setAutoDelete(TRUE); | ||
990 | typName.setAutoDelete(TRUE); | 1026 | typName.setAutoDelete(TRUE); |
@@ -992,4 +1028,3 @@ public: | |||
992 | 1028 | ||
993 | QDict<QPixmap> typPix; | 1029 | QDict<AppLnkImagePrivate> typPix; |
994 | QDict<QPixmap> typPixBig; | ||
995 | QDict<QString> typName; | 1030 | QDict<QString> typName; |
@@ -1092,10 +1127,7 @@ void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QStrin | |||
1092 | if ( !typ.isEmpty() ) { | 1127 | if ( !typ.isEmpty() ) { |
1093 | QString iconFile = config.readEntry( "Icon", "AppsIcon" ); | 1128 | d->typPix.insert( typ, |
1094 | QImage unscaledIcon = Resource::loadImage( iconFile ); | 1129 | new AppLnkImagePrivate( config.readEntry( "Icon", "AppsIcon" ) ) |
1095 | QPixmap pm, bpm; | 1130 | ); |
1096 | pm.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | ||
1097 | bpm.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | ||
1098 | d->typPix.insert(typ, new QPixmap(pm)); | ||
1099 | d->typPixBig.insert(typ, new QPixmap(bpm)); | ||
1100 | d->typName.insert(typ, new QString(typNameLocal)); | 1131 | d->typName.insert(typ, new QString(typNameLocal)); |
1132 | |||
1101 | } | 1133 | } |
@@ -1194,4 +1226,4 @@ QPixmap AppLnkSet::typePixmap( const QString& t ) const | |||
1194 | { | 1226 | { |
1195 | QPixmap *pm = d->typPix.find(t); | 1227 | AppLnkImagePrivate *alip = d->typPix.find(t); |
1196 | return pm ? *pm : QPixmap(); | 1228 | return alip ? *(alip->small()) : QPixmap(); |
1197 | } | 1229 | } |
@@ -1206,4 +1238,4 @@ QPixmap AppLnkSet::typeBigPixmap( const QString& t ) const | |||
1206 | { | 1238 | { |
1207 | QPixmap *pm = d->typPixBig.find(t); | 1239 | AppLnkImagePrivate *alip = d->typPix.find(t); |
1208 | return pm ? *pm : QPixmap(); | 1240 | return alip ? *(alip->big()) : QPixmap(); |
1209 | } | 1241 | } |