summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp
index b2c1649..b95c544 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -1,56 +1,61 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <simon@lst.de> 2 Copyright (C) 2002 Simon Hausmann <simon@lst.de>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This program is free software; you can redistribute it and/or 7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details. 15 General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to 18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include "skin.h" 23#include "skin.h"
24#include "singleton.h" 24#include "singleton.h"
25
26/* OPIE */
25#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28#include <opie2/oresource.h>
29using namespace Opie::Core;
30#include <qpe/config.h>
31#include <qpe/global.h>
26 32
33/* QT */
27#include <qcache.h> 34#include <qcache.h>
28#include <qtimer.h> 35#include <qtimer.h>
29 36
30#include <qpe/config.h> 37/* STD */
31#include <qpe/global.h>
32
33#include <assert.h> 38#include <assert.h>
34 39
35struct SkinData 40struct SkinData
36{ 41{
37 typedef QMap<QString, QImage> ButtonMaskImageMap; 42 typedef QMap<QString, QImage> ButtonMaskImageMap;
38 43
39 QPixmap backgroundPixmap; 44 QPixmap backgroundPixmap;
40 QImage buttonUpImage; 45 QImage buttonUpImage;
41 QImage buttonDownImage; 46 QImage buttonDownImage;
42 QImage buttonMask; 47 QImage buttonMask;
43 ButtonMaskImageMap buttonMasks; 48 ButtonMaskImageMap buttonMasks;
44}; 49};
45 50
46class SkinCache : public Singleton<SkinCache> 51class SkinCache : public Singleton<SkinCache>
47{ 52{
48public: 53public:
49 SkinCache(); 54 SkinCache();
50 55
51 SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix ); 56 SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix );
52 57
53 void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ); 58 void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data );
54 59
55private: 60private:
56 typedef QCache<SkinData> DataCache; 61 typedef QCache<SkinData> DataCache;
@@ -140,49 +145,49 @@ void Skin::addButtonToMask( int tag, const QImage &maskImage ) const
140 line[x] = tag; 145 line[x] = tag;
141 } 146 }
142} 147}
143 148
144QImage Skin::buttonMaskImage( const QString &fileName ) const 149QImage Skin::buttonMaskImage( const QString &fileName ) const
145{ 150{
146 SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); 151 SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName );
147 if ( it == d->buttonMasks.end() ) { 152 if ( it == d->buttonMasks.end() ) {
148 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 );
149 QString path = prefix + fileName; 154 QString path = prefix + fileName;
150 it = d->buttonMasks.insert( fileName, loadImage( path ) ); 155 it = d->buttonMasks.insert( fileName, loadImage( path ) );
151 } 156 }
152 return *it; 157 return *it;
153} 158}
154 159
155QString Skin::defaultSkinName() 160QString Skin::defaultSkinName()
156{ 161{
157 Config cfg( "OpiePlayer" ); 162 Config cfg( "OpiePlayer" );
158 cfg.setGroup( "Options" ); 163 cfg.setGroup( "Options" );
159 return cfg.readEntry( "Skin", "default" ); 164 return cfg.readEntry( "Skin", "default" );
160} 165}
161 166
162QImage Skin::loadImage( const QString &fileName ) 167QImage Skin::loadImage( const QString &fileName )
163{ 168{
164 return QImage( Resource::findPixmap( fileName ) ); 169 return QImage( OResource::findPixmap( fileName ) );
165} 170}
166 171
167SkinCache::SkinCache() 172SkinCache::SkinCache()
168{ 173{
169 // let's say we cache two skins (audio+video) at maximum 174 // let's say we cache two skins (audio+video) at maximum
170 m_cache.setMaxCost( 2 ); 175 m_cache.setMaxCost( 2 );
171 // ... and one background pixmap 176 // ... and one background pixmap
172 m_backgroundPixmapCache.setMaxCost( 1 ); 177 m_backgroundPixmapCache.setMaxCost( 1 );
173} 178}
174 179
175SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) 180SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix )
176{ 181{
177 QString key = skinPath + fileNameInfix; 182 QString key = skinPath + fileNameInfix;
178 183
179 SkinData *data = m_cache.take( key ); 184 SkinData *data = m_cache.take( key );
180 if ( !data ) 185 if ( !data )
181 data = new SkinData; 186 data = new SkinData;
182 else 187 else
183 odebug << "SkinCache: hit" << oendl; 188 odebug << "SkinCache: hit" << oendl;
184 189
185 QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); 190 QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath );
186 if ( bgPixmap ) { 191 if ( bgPixmap ) {
187 odebug << "SkinCache: hit on bgpixmap" << oendl; 192 odebug << "SkinCache: hit on bgpixmap" << oendl;
188 data->backgroundPixmap = *bgPixmap; 193 data->backgroundPixmap = *bgPixmap;