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 44f5ca2..742e495 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -101,97 +101,97 @@ QImage Skin::buttonUpImage() const
101{ 101{
102 if ( d->buttonUpImage.isNull() ) 102 if ( d->buttonUpImage.isNull() )
103 d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); 103 d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) );
104 return d->buttonUpImage; 104 return d->buttonUpImage;
105} 105}
106 106
107QImage Skin::buttonDownImage() const 107QImage Skin::buttonDownImage() const
108{ 108{
109 if ( d->buttonDownImage.isNull() ) 109 if ( d->buttonDownImage.isNull() )
110 d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); 110 d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) );
111 return d->buttonDownImage; 111 return d->buttonDownImage;
112} 112}
113 113
114QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const 114QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const
115{ 115{
116 if ( !d->buttonMask.isNull() ) 116 if ( !d->buttonMask.isNull() )
117 return d->buttonMask; 117 return d->buttonMask;
118 118
119 QSize buttonAreaSize = buttonUpImage().size(); 119 QSize buttonAreaSize = buttonUpImage().size();
120 120
121 d->buttonMask = QImage( buttonAreaSize, 8, 255 ); 121 d->buttonMask = QImage( buttonAreaSize, 8, 255 );
122 d->buttonMask.fill( 0 ); 122 d->buttonMask.fill( 0 );
123 123
124 for ( uint i = 0; i < buttonCount; ++i ) 124 for ( uint i = 0; i < buttonCount; ++i )
125 addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); 125 addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) );
126 126
127 return d->buttonMask; 127 return d->buttonMask;
128} 128}
129 129
130void Skin::addButtonToMask( int tag, const QImage &maskImage ) const 130void Skin::addButtonToMask( int tag, const QImage &maskImage ) const
131{ 131{
132 if ( maskImage.isNull() ) 132 if ( maskImage.isNull() )
133 return; 133 return;
134 134
135 uchar **dest = d->buttonMask.jumpTable(); 135 uchar **dest = d->buttonMask.jumpTable();
136 for ( int y = 0; y < d->buttonMask.height(); y++ ) { 136 for ( int y = 0; y < d->buttonMask.height(); y++ ) {
137 uchar *line = dest[y]; 137 uchar *line = dest[y];
138 for ( int x = 0; x < d->buttonMask.width(); x++ ) 138 for ( int x = 0; x < d->buttonMask.width(); x++ )
139 if ( !qRed( maskImage.pixel( x, y ) ) ) 139 if ( !qRed( maskImage.pixel( x, y ) ) )
140 line[x] = tag; 140 line[x] = tag;
141 } 141 }
142} 142}
143 143
144QImage Skin::buttonMaskImage( const QString &fileName ) const 144QImage Skin::buttonMaskImage( const QString &fileName ) const
145{ 145{
146 SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); 146 SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName );
147 if ( it == d->buttonMasks.end() ) { 147 if ( it == d->buttonMasks.end() ) {
148 QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); 148 QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix );
149 QString path = prefix + fileName + ".png"; 149 QString path = prefix + fileName;
150 it = d->buttonMasks.insert( fileName, loadImage( path ) ); 150 it = d->buttonMasks.insert( fileName, loadImage( path ) );
151 } 151 }
152 return *it; 152 return *it;
153} 153}
154 154
155QString Skin::defaultSkinName() 155QString Skin::defaultSkinName()
156{ 156{
157 Config cfg( "OpiePlayer" ); 157 Config cfg( "OpiePlayer" );
158 cfg.setGroup( "Options" ); 158 cfg.setGroup( "Options" );
159 return cfg.readEntry( "Skin", "default" ); 159 return cfg.readEntry( "Skin", "default" );
160} 160}
161 161
162QImage Skin::loadImage( const QString &fileName ) 162QImage Skin::loadImage( const QString &fileName )
163{ 163{
164 return QImage( Resource::findPixmap( fileName ) ); 164 return QImage( Resource::findPixmap( fileName ) );
165} 165}
166 166
167SkinCache::SkinCache() 167SkinCache::SkinCache()
168{ 168{
169 // let's say we cache two skins (audio+video) at maximum 169 // let's say we cache two skins (audio+video) at maximum
170 m_cache.setMaxCost( 2 ); 170 m_cache.setMaxCost( 2 );
171 // ... and one background pixmap 171 // ... and one background pixmap
172 m_backgroundPixmapCache.setMaxCost( 1 ); 172 m_backgroundPixmapCache.setMaxCost( 1 );
173} 173}
174 174
175SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) 175SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix )
176{ 176{
177 QString key = skinPath + fileNameInfix; 177 QString key = skinPath + fileNameInfix;
178 178
179 SkinData *data = m_cache.take( key ); 179 SkinData *data = m_cache.take( key );
180 if ( !data ) 180 if ( !data )
181 data = new SkinData; 181 data = new SkinData;
182 else 182 else
183 qDebug( "SkinCache: hit" ); 183 qDebug( "SkinCache: hit" );
184 184
185 QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); 185 QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath );
186 if ( bgPixmap ) { 186 if ( bgPixmap ) {
187 qDebug( "SkinCache: hit on bgpixmap" ); 187 qDebug( "SkinCache: hit on bgpixmap" );
188 data->backgroundPixmap = *bgPixmap; 188 data->backgroundPixmap = *bgPixmap;
189 } 189 }
190 else 190 else
191 data->backgroundPixmap = QPixmap(); 191 data->backgroundPixmap = QPixmap();
192 192
193 return data; 193 return data;
194} 194}
195 195
196void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) 196void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data )
197{ 197{