summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/skin.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/skin.cpp') (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 @@
/*
Copyright (C) 2002 Simon Hausmann <simon@lst.de>
(C) 2002 Max Reiss <harlekin@handhelds.org>
(C) 2002 L. Potter <ljp@llornkcor.com>
(C) 2002 Holger Freyther <zecke@handhelds.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "skin.h"
#include "singleton.h"
+
+/* OPIE */
#include <opie2/odebug.h>
+#include <opie2/oresource.h>
+using namespace Opie::Core;
+#include <qpe/config.h>
+#include <qpe/global.h>
+/* QT */
#include <qcache.h>
#include <qtimer.h>
-#include <qpe/config.h>
-#include <qpe/global.h>
-
+/* STD */
#include <assert.h>
struct SkinData
{
typedef QMap<QString, QImage> ButtonMaskImageMap;
QPixmap backgroundPixmap;
QImage buttonUpImage;
QImage buttonDownImage;
QImage buttonMask;
ButtonMaskImageMap buttonMasks;
};
class SkinCache : public Singleton<SkinCache>
{
public:
SkinCache();
SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix );
void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data );
private:
typedef QCache<SkinData> DataCache;
@@ -140,49 +145,49 @@ void Skin::addButtonToMask( int tag, const QImage &maskImage ) const
line[x] = tag;
}
}
QImage Skin::buttonMaskImage( const QString &fileName ) const
{
SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName );
if ( it == d->buttonMasks.end() ) {
QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix );
QString path = prefix + fileName;
it = d->buttonMasks.insert( fileName, loadImage( path ) );
}
return *it;
}
QString Skin::defaultSkinName()
{
Config cfg( "OpiePlayer" );
cfg.setGroup( "Options" );
return cfg.readEntry( "Skin", "default" );
}
QImage Skin::loadImage( const QString &fileName )
{
- return QImage( Resource::findPixmap( fileName ) );
+ return QImage( OResource::findPixmap( fileName ) );
}
SkinCache::SkinCache()
{
// let's say we cache two skins (audio+video) at maximum
m_cache.setMaxCost( 2 );
// ... and one background pixmap
m_backgroundPixmapCache.setMaxCost( 1 );
}
SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix )
{
QString key = skinPath + fileNameInfix;
SkinData *data = m_cache.take( key );
if ( !data )
data = new SkinData;
else
odebug << "SkinCache: hit" << oendl;
QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath );
if ( bgPixmap ) {
odebug << "SkinCache: hit on bgpixmap" << oendl;
data->backgroundPixmap = *bgPixmap;