author | zecke <zecke> | 2005-02-22 22:18:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-22 22:18:11 (UTC) |
commit | a2eea1c6273acd16fed2406493923c52fba19ebc (patch) (unidiff) | |
tree | c0ab063876da2129b74956fa50092384a39449cb /library/resource.cpp | |
parent | e5d8117ff25ff91b4ba8029a63b6ffed4ea56d38 (diff) | |
download | opie-a2eea1c6273acd16fed2406493923c52fba19ebc.zip opie-a2eea1c6273acd16fed2406493923c52fba19ebc.tar.gz opie-a2eea1c6273acd16fed2406493923c52fba19ebc.tar.bz2 |
Remove overriding of inline pictures. We now can easily disable compilation
of compiled in icons
-rw-r--r-- | library/resource.cpp | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/library/resource.cpp b/library/resource.cpp index 92d4b60..f6b548d 100644 --- a/library/resource.cpp +++ b/library/resource.cpp | |||
@@ -22,34 +22,32 @@ | |||
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #include "resource.h" | 23 | #include "resource.h" |
24 | #include "mimetype.h" | 24 | #include "mimetype.h" |
25 | #include <qdir.h> | 25 | #include <qdir.h> |
26 | #include <qpixmapcache.h> | 26 | #include <qpixmapcache.h> |
27 | 27 | ||
28 | // this namespace is just a workaround for a gcc bug | 28 | // this namespace is just a workaround for a gcc bug |
29 | // gcc exports inline functions in the generated file | 29 | // gcc exports inline functions in the generated file |
30 | // inlinepics_p.h | 30 | // inlinepics_p.h |
31 | 31 | ||
32 | #ifndef LIBQPE_NO_INLINE_IMAGES | 32 | #ifndef LIBQPE_NO_INLINE_IMAGES |
33 | namespace { | 33 | namespace { |
34 | #include "inlinepics_p.h" | 34 | #include "inlinepics_p.h" |
35 | } | 35 | } |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | static bool g_notUseSet = ::getenv("OVERWRITE_ICON_SET"); | ||
39 | |||
40 | /*! | 38 | /*! |
41 | \class Resource resource.h | 39 | \class Resource resource.h |
42 | \brief The Resource class provides access to named resources. | 40 | \brief The Resource class provides access to named resources. |
43 | 41 | ||
44 | The resources may be provided from files or other sources. | 42 | The resources may be provided from files or other sources. |
45 | 43 | ||
46 | The allSounds() function returns a list of all the sounds available. | 44 | The allSounds() function returns a list of all the sounds available. |
47 | A particular sound can be searched for using findSound(). | 45 | A particular sound can be searched for using findSound(). |
48 | 46 | ||
49 | Images can be loaded with loadImage(), loadPixmap(), loadBitmap() | 47 | Images can be loaded with loadImage(), loadPixmap(), loadBitmap() |
50 | and loadIconSet(). | 48 | and loadIconSet(). |
51 | 49 | ||
52 | \ingroup qtopiaemb | 50 | \ingroup qtopiaemb |
53 | */ | 51 | */ |
54 | 52 | ||
55 | /*! | 53 | /*! |
@@ -153,63 +151,50 @@ QString Resource::findSound( const QString &name ) | |||
153 | Returns a list of all sound names. | 151 | Returns a list of all sound names. |
154 | */ | 152 | */ |
155 | QStringList Resource::allSounds() | 153 | QStringList Resource::allSounds() |
156 | { | 154 | { |
157 | QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" ); | 155 | QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" ); |
158 | QStringList entries = resourcedir.entryList(); | 156 | QStringList entries = resourcedir.entryList(); |
159 | QStringList result; | 157 | QStringList result; |
160 | for (QStringList::Iterator i=entries.begin(); i != entries.end(); ++i) | 158 | for (QStringList::Iterator i=entries.begin(); i != entries.end(); ++i) |
161 | result.append((*i).replace(QRegExp("\\.wav"),"")); | 159 | result.append((*i).replace(QRegExp("\\.wav"),"")); |
162 | return result; | 160 | return result; |
163 | } | 161 | } |
164 | 162 | ||
165 | static QImage load_image(const QString &name) | 163 | static QImage load_image(const QString &name) |
166 | { | 164 | { |
167 | QImage img; | 165 | QImage img; |
168 | 166 | ||
169 | if (g_notUseSet ) { | ||
170 | // try file | ||
171 | QString f = Resource::findPixmap(name); | ||
172 | if ( !f.isEmpty() ) | ||
173 | img.load(f); | ||
174 | #ifndef LIBQPE_NO_INLINE_IMAGES | 167 | #ifndef LIBQPE_NO_INLINE_IMAGES |
175 | if (img.isNull() ) | 168 | img = qembed_findImage(name.latin1()); |
176 | img = qembed_findImage(name.latin1() ); | 169 | #else |
177 | #endif | 170 | QString f = Resource::findPixmap( "/inline/" + name ); |
171 | if ( !f.isEmpty() ) | ||
172 | { | ||
173 | img.load(f); | ||
178 | return img; | 174 | return img; |
179 | } | 175 | } |
180 | else{ | 176 | #endif |
181 | #ifndef LIBQPE_NO_INLINE_IMAGES | 177 | if ( img.isNull() ) |
182 | img = qembed_findImage(name.latin1()); | 178 | { |
183 | #else | 179 | // No inlined image, try file |
184 | QString f = Resource::findPixmap( "/inline/" + name ); | 180 | QString f = Resource::findPixmap(name); |
185 | if ( !f.isEmpty() ) | 181 | if ( !f.isEmpty() ) |
186 | { | ||
187 | img.load(f); | 182 | img.load(f); |
188 | return img; | ||
189 | } | ||
190 | #endif | ||
191 | if ( img.isNull() ) | ||
192 | { | ||
193 | // No inlined image, try file | ||
194 | QString f = Resource::findPixmap(name); | ||
195 | if ( !f.isEmpty() ) | ||
196 | img.load(f); | ||
197 | } | ||
198 | return img; | ||
199 | } | 183 | } |
184 | return img; | ||
200 | } | 185 | } |
201 | 186 | ||
202 | /*! | 187 | /*! |
203 | Returns the QImage called \a name. You should avoid including | 188 | Returns the QImage called \a name. You should avoid including |
204 | any filename type extension (e.g. .png, .xpm). | 189 | any filename type extension (e.g. .png, .xpm). |
205 | */ | 190 | */ |
206 | QImage Resource::loadImage( const QString &name) | 191 | QImage Resource::loadImage( const QString &name) |
207 | { | 192 | { |
208 | #ifndef QT_NO_DEPTH_32// have alpha-blended pixmaps | 193 | #ifndef QT_NO_DEPTH_32// have alpha-blended pixmaps |
209 | static QImage last_enabled; | 194 | static QImage last_enabled; |
210 | static QString last_enabled_name; | 195 | static QString last_enabled_name; |
211 | if ( name == last_enabled_name ) | 196 | if ( name == last_enabled_name ) |
212 | return last_enabled; | 197 | return last_enabled; |
213 | #endif | 198 | #endif |
214 | QImage img = load_image(name); | 199 | QImage img = load_image(name); |
215 | #ifndef QT_NO_DEPTH_32// have alpha-blended pixmaps | 200 | #ifndef QT_NO_DEPTH_32// have alpha-blended pixmaps |