-rw-r--r-- | library/resource.cpp | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/library/resource.cpp b/library/resource.cpp index 3b5e9ec..92d4b60 100644 --- a/library/resource.cpp +++ b/library/resource.cpp | |||
@@ -63,107 +63,96 @@ static bool g_notUseSet = ::getenv("OVERWRITE_ICON_SET"); | |||
63 | */ | 63 | */ |
64 | #include <stdio.h> | 64 | #include <stdio.h> |
65 | QPixmap Resource::loadPixmap( const QString &pix ) | 65 | QPixmap Resource::loadPixmap( const QString &pix ) |
66 | { | 66 | { |
67 | QPixmap pm; // null pixmap | 67 | QPixmap pm; // null pixmap |
68 | QString key="QPE_"+pix; | 68 | QString key="QPE_"+pix; |
69 | if ( !QPixmapCache::find(key,pm) ) { | 69 | if ( !QPixmapCache::find(key,pm) ) { |
70 | QImage I = loadImage(pix); | 70 | QImage I = loadImage(pix); |
71 | if( I.isNull() ) { | 71 | if( I.isNull() ) { |
72 | qWarning( "Could not load %s", pix.latin1() ); | 72 | qWarning( "Could not load %s", pix.latin1() ); |
73 | } else { | 73 | } else { |
74 | pm.convertFromImage(I); | 74 | pm.convertFromImage(I); |
75 | QPixmapCache::insert(key,pm); | 75 | QPixmapCache::insert(key,pm); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | return pm; | 78 | return pm; |
79 | } | 79 | } |
80 | 80 | ||
81 | /*! | 81 | /*! |
82 | Returns the QBitmap called \a pix. You should avoid including | 82 | Returns the QBitmap called \a pix. You should avoid including |
83 | any filename type extension (e.g. .png, .xpm). | 83 | any filename type extension (e.g. .png, .xpm). |
84 | */ | 84 | */ |
85 | QBitmap Resource::loadBitmap( const QString &pix ) | 85 | QBitmap Resource::loadBitmap( const QString &pix ) |
86 | { | 86 | { |
87 | QBitmap bm; | 87 | QBitmap bm; |
88 | bm = loadPixmap(pix); | 88 | bm = loadPixmap(pix); |
89 | return bm; | 89 | return bm; |
90 | } | 90 | } |
91 | 91 | ||
92 | /*! | 92 | /*! |
93 | Returns the filename of a pixmap called \a pix. You should avoid including | 93 | Returns the filename of a pixmap called \a pix. You should avoid including |
94 | any filename type extension (e.g. .png, .xpm). | 94 | any filename type extension (e.g. .png, .xpm). |
95 | 95 | ||
96 | Normally you will use loadPixmap() rather than this function. | 96 | Normally you will use loadPixmap() rather than this function. |
97 | */ | 97 | */ |
98 | QString Resource::findPixmap( const QString &pix ) | 98 | QString Resource::findPixmap( const QString &pix ) |
99 | { | 99 | { |
100 | QString picsPath = QPEApplication::qpeDir() + "pics/"; | 100 | QString picsPath = QPEApplication::qpeDir() + "pics/"; |
101 | QString f; | 101 | QString f; |
102 | 102 | ||
103 | // Common case optimizations... | 103 | // Common case optimizations... |
104 | f = picsPath + pix + ".png"; | 104 | f = picsPath + pix + ".png"; |
105 | if ( QFile( f ).exists() ) | 105 | if ( QFile( f ).exists() ) |
106 | return f; | 106 | return f; |
107 | f = picsPath + pix + ".xpm"; | 107 | f = picsPath + pix + ".xpm"; |
108 | if ( QFile( f ).exists() ) | 108 | if ( QFile( f ).exists() ) |
109 | return f; | 109 | return f; |
110 | 110 | ||
111 | #ifdef LIBQPE_NO_INLINE_IMAGES | ||
112 | QString picsPathInline = picsPath + "inline/"; | ||
113 | // Common case optimizations... | ||
114 | f = picsPathInline + pix + ".png"; | ||
115 | if ( QFile( f ).exists() ) | ||
116 | return f; | ||
117 | f = picsPathInline + pix + ".xpm"; | ||
118 | if ( QFile( f ).exists() ) | ||
119 | return f; | ||
120 | #endif | ||
121 | |||
122 | // All formats... | 111 | // All formats... |
123 | QStrList fileFormats = QImageIO::inputFormats(); | 112 | QStrList fileFormats = QImageIO::inputFormats(); |
124 | QString ff = fileFormats.first(); | 113 | QString ff = fileFormats.first(); |
125 | while ( fileFormats.current() ) { | 114 | while ( fileFormats.current() ) { |
126 | QStringList exts = MimeType("image/"+ff.lower()).extensions(); | 115 | QStringList exts = MimeType("image/"+ff.lower()).extensions(); |
127 | for ( QStringList::ConstIterator it = exts.begin(); it!=exts.end(); ++it ) { | 116 | for ( QStringList::ConstIterator it = exts.begin(); it!=exts.end(); ++it ) { |
128 | QString f = picsPath + pix + "." + *it; | 117 | QString f = picsPath + pix + "." + *it; |
129 | if ( QFile(f).exists() ) | 118 | if ( QFile(f).exists() ) |
130 | return f; | 119 | return f; |
131 | } | 120 | } |
132 | ff = fileFormats.next(); | 121 | ff = fileFormats.next(); |
133 | } | 122 | } |
134 | 123 | ||
135 | // Finally, no (or existing) extension... | 124 | // Finally, no (or existing) extension... |
136 | if ( QFile( picsPath + pix ).exists() ) | 125 | if ( QFile( picsPath + pix ).exists() ) |
137 | return picsPath + pix; | 126 | return picsPath + pix; |
138 | 127 | ||
139 | //qDebug("Cannot find pixmap: %s", pix.latin1()); | 128 | //qDebug("Cannot find pixmap: %s", pix.latin1()); |
140 | return QString(); | 129 | return QString(); |
141 | } | 130 | } |
142 | 131 | ||
143 | /*! | 132 | /*! |
144 | Returns a sound file for a sound called \a name. | 133 | Returns a sound file for a sound called \a name. |
145 | 134 | ||
146 | You should avoid including any filename type extension (e.g. .wav), | 135 | You should avoid including any filename type extension (e.g. .wav), |
147 | as the system will search for only those fileformats which are supported | 136 | as the system will search for only those fileformats which are supported |
148 | by the library. | 137 | by the library. |
149 | 138 | ||
150 | Currently, only WAV files are supported. | 139 | Currently, only WAV files are supported. |
151 | */ | 140 | */ |
152 | QString Resource::findSound( const QString &name ) | 141 | QString Resource::findSound( const QString &name ) |
153 | { | 142 | { |
154 | QString picsPath = QPEApplication::qpeDir() + "sounds/"; | 143 | QString picsPath = QPEApplication::qpeDir() + "sounds/"; |
155 | 144 | ||
156 | QString result; | 145 | QString result; |
157 | if ( QFile( (result = picsPath + name + ".wav") ).exists() ) | 146 | if ( QFile( (result = picsPath + name + ".wav") ).exists() ) |
158 | return result; | 147 | return result; |
159 | 148 | ||
160 | return QString(); | 149 | return QString(); |
161 | } | 150 | } |
162 | 151 | ||
163 | /*! | 152 | /*! |
164 | Returns a list of all sound names. | 153 | Returns a list of all sound names. |
165 | */ | 154 | */ |
166 | QStringList Resource::allSounds() | 155 | QStringList Resource::allSounds() |
167 | { | 156 | { |
168 | QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" ); | 157 | QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" ); |
169 | QStringList entries = resourcedir.entryList(); | 158 | QStringList entries = resourcedir.entryList(); |