summaryrefslogtreecommitdiff
path: root/library/resource.cpp
authorzecke <zecke>2004-12-26 13:40:21 (UTC)
committer zecke <zecke>2004-12-26 13:40:21 (UTC)
commit99b055b572f64f180751b3a43440796d1bf9fc4f (patch) (unidiff)
tree2caf1b3d3e9ecec68d616880d4a354033574b8c0 /library/resource.cpp
parentd8f38f36ad533f93d46c8ff883c6b42f15c96c28 (diff)
downloadopie-99b055b572f64f180751b3a43440796d1bf9fc4f.zip
opie-99b055b572f64f180751b3a43440796d1bf9fc4f.tar.gz
opie-99b055b572f64f180751b3a43440796d1bf9fc4f.tar.bz2
Merge the way we insert Images into the PixmapCache
Diffstat (limited to 'library/resource.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/resource.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/library/resource.cpp b/library/resource.cpp
index cfa0d26..43fdc60 100644
--- a/library/resource.cpp
+++ b/library/resource.cpp
@@ -57,20 +57,45 @@ static bool g_notUseSet = ::getenv("OVERWRITE_ICON_SET");
57 57
58/*! 58/*!
59 Returns the QPixmap called \a pix. You should avoid including 59 Returns the QPixmap called \a pix. You should avoid including
60 any filename type extension (e.g. .png, .xpm). 60 any filename type extension (e.g. .png, .xpm).
61*/ 61*/
62QPixmap Resource::loadPixmap( const QString &pix ) 62QPixmap Resource::loadPixmap( const QString &pix )
63{ 63{
64 QPixmap pm; 64 QPixmap pm;
65 QString key="QPE_"+pix; 65
66 if ( !QPixmapCache::find(key,pm) ) { 66 // Give the pixmaps some kind of namespace in the pixmapcache
67 pm.convertFromImage(loadImage(pix)); 67 int index = pix.find('/');
68 QPixmapCache::insert(key,pm); 68 QString appName1 = qApp->argv()[0];
69 appName1 = appName1.replace(QRegExp(".*/"),"");
70 QString appName2 = pix.left(index);
71
72 if ( appName2 == "" || appName2 == pix || appName2 == "icons" )
73 appName2 = "Global";
74
75 QString appKey1 = "_QPE_" + appName1 + "_" + pix;
76 QString appKey2 = "_QPE_" + appName2 + "_" + pix.mid(index+1);
77
78 if ( !QPixmapCache::find(appKey1, pm) ) {
79 if ( !QPixmapCache::find(appKey2, pm) ) {
80 QImage img;
81 QString f = findPixmap( pix );
82 if ( !f.isEmpty() ) {
83 img.load(f);
84 if ( !img.isNull() ) {
85 pm.convertFromImage(img);
86 if ( f.contains(appName1) ) {
87 QPixmapCache::insert( appKey1, pm);
88 } else {
89 QPixmapCache::insert( appKey2, pm);
90 }
91 }
92 }
93 }
69 } 94 }
70 return pm; 95 return pm;
71} 96}
72 97
73/*! 98/*!
74 Returns the QBitmap called \a pix. You should avoid including 99 Returns the QBitmap called \a pix. You should avoid including
75 any filename type extension (e.g. .png, .xpm). 100 any filename type extension (e.g. .png, .xpm).
76*/ 101*/