summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/resource.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/library/resource.cpp b/library/resource.cpp
index 80ce7a2..4108883 100644
--- a/library/resource.cpp
+++ b/library/resource.cpp
@@ -57,98 +57,96 @@ namespace {
57*/ 57*/
58 58
59/*! 59/*!
60 Returns the QPixmap called \a pix. You should avoid including 60 Returns the QPixmap called \a pix. You should avoid including
61 any filename type extension (e.g. .png, .xpm). 61 any filename type extension (e.g. .png, .xpm).
62*/ 62*/
63QPixmap Resource::loadPixmap( const QString &pix ) 63QPixmap Resource::loadPixmap( const QString &pix )
64{ 64{
65 QPixmap pm; 65 QPixmap pm;
66 QString key="QPE_"+pix; 66 QString key="QPE_"+pix;
67 if ( !QPixmapCache::find(key,pm) ) { 67 if ( !QPixmapCache::find(key,pm) ) {
68 pm.convertFromImage(loadImage(pix)); 68 pm.convertFromImage(loadImage(pix));
69 QPixmapCache::insert(key,pm); 69 QPixmapCache::insert(key,pm);
70 } 70 }
71 return pm; 71 return pm;
72} 72}
73 73
74/*! 74/*!
75 Returns the QBitmap called \a pix. You should avoid including 75 Returns the QBitmap called \a pix. You should avoid including
76 any filename type extension (e.g. .png, .xpm). 76 any filename type extension (e.g. .png, .xpm).
77*/ 77*/
78QBitmap Resource::loadBitmap( const QString &pix ) 78QBitmap Resource::loadBitmap( const QString &pix )
79{ 79{
80 QBitmap bm; 80 QBitmap bm;
81 bm = loadPixmap(pix); 81 bm = loadPixmap(pix);
82 return bm; 82 return bm;
83} 83}
84 84
85/*! 85/*!
86 Returns the filename of a pixmap called \a pix. You should avoid including 86 Returns the filename of a pixmap called \a pix. You should avoid including
87 any filename type extension (e.g. .png, .xpm). 87 any filename type extension (e.g. .png, .xpm).
88 88
89 Normally you will use loadPixmap() rather than this function. 89 Normally you will use loadPixmap() rather than this function.
90*/ 90*/
91QString Resource::findPixmap( const QString &pix ) 91QString Resource::findPixmap( const QString &pix )
92{ 92{
93 QString picsPath = QPEApplication::qpeDir() + "pics/"; 93 QString picsPath = QPEApplication::qpeDir() + "pics/";
94 94
95 QString f; 95 QString f;
96 96
97 // Common case optimizations... 97 // Common case optimizations...
98 f = picsPath + pix + ".png"; 98 f = picsPath + pix + ".png";
99 if ( QFile( f ).exists() ) 99 if ( QFile( f ).exists() )
100 return f; 100 return f;
101 f = picsPath + pix + ".xpm"; 101 f = picsPath + pix + ".xpm";
102 if ( QFile( f ).exists() ) 102 if ( QFile( f ).exists() )
103 return f; 103 return f;
104 104
105 //qDebug ( "\nLoading of image '%s' is not ideal (either it doesn't exist or an extension was specified)\n", pix.latin1());
106//is this really necessary??
107 105
108 // All formats... 106 // All formats...
109 QStrList fileFormats = QImageIO::inputFormats(); 107 QStrList fileFormats = QImageIO::inputFormats();
110 QString ff = fileFormats.first(); 108 QString ff = fileFormats.first();
111 while ( fileFormats.current() ) { 109 while ( fileFormats.current() ) {
112 QStringList exts = MimeType("image/"+ff.lower()).extensions(); 110 QStringList exts = MimeType("image/"+ff.lower()).extensions();
113 for ( QStringList::ConstIterator it = exts.begin(); it!=exts.end(); ++it ) { 111 for ( QStringList::ConstIterator it = exts.begin(); it!=exts.end(); ++it ) {
114 QString f = picsPath + pix + "." + *it; 112 QString f = picsPath + pix + "." + *it;
115 if ( QFile(f).exists() ) 113 if ( QFile(f).exists() )
116 return f; 114 return f;
117 } 115 }
118 ff = fileFormats.next(); 116 ff = fileFormats.next();
119 } 117 }
120 118
121 // Finally, no (or existing) extension... 119 // Finally, no (or existing) extension...
122 if ( QFile( picsPath + pix ).exists() ) 120 if ( QFile( picsPath + pix ).exists() )
123 return picsPath + pix; 121 return picsPath + pix;
124 122
125 //qDebug("Cannot find pixmap: %s", pix.latin1()); 123 //qDebug("Cannot find pixmap: %s", pix.latin1());
126 return QString(); 124 return QString();
127} 125}
128 126
129/*! 127/*!
130 Returns a sound file for a sound called \a name. 128 Returns a sound file for a sound called \a name.
131 129
132 You should avoid including any filename type extension (e.g. .wav), 130 You should avoid including any filename type extension (e.g. .wav),
133 as the system will search for only those fileformats which are supported 131 as the system will search for only those fileformats which are supported
134 by the library. 132 by the library.
135 133
136 Currently, only WAV files are supported. 134 Currently, only WAV files are supported.
137*/ 135*/
138QString Resource::findSound( const QString &name ) 136QString Resource::findSound( const QString &name )
139{ 137{
140 QString picsPath = QPEApplication::qpeDir() + "sounds/"; 138 QString picsPath = QPEApplication::qpeDir() + "sounds/";
141 139
142 QString result; 140 QString result;
143 if ( QFile( (result = picsPath + name + ".wav") ).exists() ) 141 if ( QFile( (result = picsPath + name + ".wav") ).exists() )
144 return result; 142 return result;
145 143
146 return QString(); 144 return QString();
147} 145}
148 146
149/*! 147/*!
150 Returns a list of all sound names. 148 Returns a list of all sound names.
151*/ 149*/
152QStringList Resource::allSounds() 150QStringList Resource::allSounds()
153{ 151{
154 QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" ); 152 QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" );