summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp
index b95c544..bd176e3 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -105,129 +105,129 @@ QPixmap Skin::backgroundPixmap() const
105QImage Skin::buttonUpImage() const 105QImage Skin::buttonUpImage() const
106{ 106{
107 if ( d->buttonUpImage.isNull() ) 107 if ( d->buttonUpImage.isNull() )
108 d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); 108 d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) );
109 return d->buttonUpImage; 109 return d->buttonUpImage;
110} 110}
111 111
112QImage Skin::buttonDownImage() const 112QImage Skin::buttonDownImage() const
113{ 113{
114 if ( d->buttonDownImage.isNull() ) 114 if ( d->buttonDownImage.isNull() )
115 d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); 115 d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) );
116 return d->buttonDownImage; 116 return d->buttonDownImage;
117} 117}
118 118
119QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const 119QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const
120{ 120{
121 if ( !d->buttonMask.isNull() ) 121 if ( !d->buttonMask.isNull() )
122 return d->buttonMask; 122 return d->buttonMask;
123 123
124 QSize buttonAreaSize = buttonUpImage().size(); 124 QSize buttonAreaSize = buttonUpImage().size();
125 125
126 d->buttonMask = QImage( buttonAreaSize, 8, 255 ); 126 d->buttonMask = QImage( buttonAreaSize, 8, 255 );
127 d->buttonMask.fill( 0 ); 127 d->buttonMask.fill( 0 );
128 128
129 for ( uint i = 0; i < buttonCount; ++i ) 129 for ( uint i = 0; i < buttonCount; ++i )
130 addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); 130 addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) );
131 131
132 return d->buttonMask; 132 return d->buttonMask;
133} 133}
134 134
135void Skin::addButtonToMask( int tag, const QImage &maskImage ) const 135void Skin::addButtonToMask( int tag, const QImage &maskImage ) const
136{ 136{
137 if ( maskImage.isNull() ) 137 if ( maskImage.isNull() )
138 return; 138 return;
139 139
140 uchar **dest = d->buttonMask.jumpTable(); 140 uchar **dest = d->buttonMask.jumpTable();
141 for ( int y = 0; y < d->buttonMask.height(); y++ ) { 141 for ( int y = 0; y < d->buttonMask.height(); y++ ) {
142 uchar *line = dest[y]; 142 uchar *line = dest[y];
143 for ( int x = 0; x < d->buttonMask.width(); x++ ) 143 for ( int x = 0; x < d->buttonMask.width(); x++ )
144 if ( !qRed( maskImage.pixel( x, y ) ) ) 144 if ( !qRed( maskImage.pixel( x, y ) ) )
145 line[x] = tag; 145 line[x] = tag;
146 } 146 }
147} 147}
148 148
149QImage Skin::buttonMaskImage( const QString &fileName ) const 149QImage Skin::buttonMaskImage( const QString &fileName ) const
150{ 150{
151 SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); 151 SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName );
152 if ( it == d->buttonMasks.end() ) { 152 if ( it == d->buttonMasks.end() ) {
153 QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); 153 QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix );
154 QString path = prefix + fileName; 154 QString path = prefix + fileName;
155 it = d->buttonMasks.insert( fileName, loadImage( path ) ); 155 it = d->buttonMasks.insert( fileName, loadImage( path ) );
156 } 156 }
157 return *it; 157 return *it;
158} 158}
159 159
160QString Skin::defaultSkinName() 160QString Skin::defaultSkinName()
161{ 161{
162 Config cfg( "OpiePlayer" ); 162 Config cfg( "OpiePlayer" );
163 cfg.setGroup( "Options" ); 163 cfg.setGroup( "Options" );
164 return cfg.readEntry( "Skin", "default" ); 164 return cfg.readEntry( "Skin", "default" );
165} 165}
166 166
167QImage Skin::loadImage( const QString &fileName ) 167QImage Skin::loadImage( const QString &fileName )
168{ 168{
169 return QImage( OResource::findPixmap( fileName ) ); 169 return QImage( Opie::Core::OResource::findPixmap( fileName ) );
170} 170}
171 171
172SkinCache::SkinCache() 172SkinCache::SkinCache()
173{ 173{
174 // let's say we cache two skins (audio+video) at maximum 174 // let's say we cache two skins (audio+video) at maximum
175 m_cache.setMaxCost( 2 ); 175 m_cache.setMaxCost( 2 );
176 // ... and one background pixmap 176 // ... and one background pixmap
177 m_backgroundPixmapCache.setMaxCost( 1 ); 177 m_backgroundPixmapCache.setMaxCost( 1 );
178} 178}
179 179
180SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) 180SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix )
181{ 181{
182 QString key = skinPath + fileNameInfix; 182 QString key = skinPath + fileNameInfix;
183 183
184 SkinData *data = m_cache.take( key ); 184 SkinData *data = m_cache.take( key );
185 if ( !data ) 185 if ( !data )
186 data = new SkinData; 186 data = new SkinData;
187 else 187 else
188 odebug << "SkinCache: hit" << oendl; 188 odebug << "SkinCache: hit" << oendl;
189 189
190 QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); 190 QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath );
191 if ( bgPixmap ) { 191 if ( bgPixmap ) {
192 odebug << "SkinCache: hit on bgpixmap" << oendl; 192 odebug << "SkinCache: hit on bgpixmap" << oendl;
193 data->backgroundPixmap = *bgPixmap; 193 data->backgroundPixmap = *bgPixmap;
194 } 194 }
195 else 195 else
196 data->backgroundPixmap = QPixmap(); 196 data->backgroundPixmap = QPixmap();
197 197
198 return data; 198 return data;
199} 199}
200 200
201void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) 201void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data )
202{ 202{
203 QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap ); 203 QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap );
204 204
205 data->backgroundPixmap = QPixmap(); 205 data->backgroundPixmap = QPixmap();
206 206
207 QString key = skinPath + fileNameInfix; 207 QString key = skinPath + fileNameInfix;
208 208
209 if ( m_cache.find( key, false /*ref*/ ) != 0 || 209 if ( m_cache.find( key, false /*ref*/ ) != 0 ||
210 !m_cache.insert( key, data ) ) 210 !m_cache.insert( key, data ) )
211 delete data; 211 delete data;
212 212
213 if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 || 213 if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 ||
214 !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) ) 214 !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) )
215 delete backgroundPixmap; 215 delete backgroundPixmap;
216} 216}
217 217
218SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info ) 218SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info )
219 : m_skin( info.skinName, info.fileNameInfix ), m_info( info ) 219 : m_skin( info.skinName, info.fileNameInfix ), m_info( info )
220{ 220{
221 m_currentState = LoadBackgroundPixmap; 221 m_currentState = LoadBackgroundPixmap;
222} 222}
223 223
224SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep() 224SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep()
225{ 225{
226 switch ( m_currentState ) { 226 switch ( m_currentState ) {
227 case LoadBackgroundPixmap: 227 case LoadBackgroundPixmap:
228 odebug << "load bgpixmap" << oendl; 228 odebug << "load bgpixmap" << oendl;
229 m_skin.backgroundPixmap(); 229 m_skin.backgroundPixmap();
230 m_currentState = LoadButtonUpImage; 230 m_currentState = LoadButtonUpImage;
231 break; 231 break;
232 case LoadButtonUpImage: 232 case LoadButtonUpImage:
233 odebug << "load upimage" << oendl; 233 odebug << "load upimage" << oendl;