summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-14 18:18:20 (UTC)
committer simon <simon>2002-12-14 18:18:20 (UTC)
commit7c854ad1b909f37c7314ef4ac2061500d02af16d (patch) (unidiff)
tree24528d72c0f2d36d6777090d7d93e2536ffb120d
parentae7a270c56fa0fff6d3f530c80532c54c51be596 (diff)
downloadopie-7c854ad1b909f37c7314ef4ac2061500d02af16d.zip
opie-7c854ad1b909f37c7314ef4ac2061500d02af16d.tar.gz
opie-7c854ad1b909f37c7314ef4ac2061500d02af16d.tar.bz2
- reduce memory usage a little bit by not storing the images after they
got converted to pixmaps
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/skin.h4
3 files changed, 10 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index edef2a7..46e7b6e 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -7,128 +7,129 @@
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 "mediawidget.h" 23#include "mediawidget.h"
24#include "playlistwidget.h" 24#include "playlistwidget.h"
25#include "skin.h" 25#include "skin.h"
26 26
27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
29{ 29{
30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
33 this, SLOT( setLength( long ) ) ); 33 this, SLOT( setLength( long ) ) );
34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
35 this, SLOT( setPlaying( bool ) ) ); 35 this, SLOT( setPlaying( bool ) ) );
36 36
37 setBackgroundMode( NoBackground ); 37 setBackgroundMode( NoBackground );
38} 38}
39 39
40MediaWidget::~MediaWidget() 40MediaWidget::~MediaWidget()
41{ 41{
42} 42}
43 43
44void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 44void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
45 const Skin &skin ) 45 const Skin &skin )
46{ 46{
47 buttonMask = skin.buttonMask( skinInfo, buttonCount ); 47 buttonMask = skin.buttonMask( skinInfo, buttonCount );
48 48
49 buttons.clear(); 49 buttons.clear();
50 buttons.reserve( buttonCount ); 50 buttons.reserve( buttonCount );
51 51
52 for ( uint i = 0; i < buttonCount; ++i ) { 52 for ( uint i = 0; i < buttonCount; ++i ) {
53 Button button = setupButton( skinInfo[ i ], skin ); 53 Button button = setupButton( skinInfo[ i ], skin );
54 buttons.push_back( button ); 54 buttons.push_back( button );
55 } 55 }
56} 56}
57 57
58MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) 58MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
59{ 59{
60 Button button; 60 Button button;
61 button.command = buttonInfo.command; 61 button.command = buttonInfo.command;
62 button.type = buttonInfo.type; 62 button.type = buttonInfo.type;
63 button.mask = skin.buttonMaskImage( buttonInfo.fileName ); 63 button.mask = skin.buttonMaskImage( buttonInfo.fileName );
64 64
65 return button; 65 return button;
66} 66}
67 67
68void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) 68void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo )
69{ 69{
70 Skin skin( guiInfo.fileNameInfix ); 70 Skin skin( guiInfo.fileNameInfix );
71 skin.setCachable( false );
71 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); 72 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin );
72} 73}
73 74
74void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) 75void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin )
75{ 76{
76 backgroundPixmap = skin.backgroundPixmap(); 77 backgroundPixmap = skin.backgroundPixmap();
77 buttonUpImage = skin.buttonUpImage(); 78 buttonUpImage = skin.buttonUpImage();
78 buttonDownImage = skin.buttonDownImage(); 79 buttonDownImage = skin.buttonDownImage();
79 80
80 setupButtons( skinInfo, buttonCount, skin ); 81 setupButtons( skinInfo, buttonCount, skin );
81} 82}
82 83
83void MediaWidget::closeEvent( QCloseEvent * ) 84void MediaWidget::closeEvent( QCloseEvent * )
84{ 85{
85 mediaPlayerState.setList(); 86 mediaPlayerState.setList();
86} 87}
87 88
88void MediaWidget::paintEvent( QPaintEvent *pe ) 89void MediaWidget::paintEvent( QPaintEvent *pe )
89{ 90{
90 QPainter p( this ); 91 QPainter p( this );
91 92
92 if ( mediaPlayerState.isFullscreen() ) { 93 if ( mediaPlayerState.isFullscreen() ) {
93 // Clear the background 94 // Clear the background
94 p.setBrush( QBrush( Qt::black ) ); 95 p.setBrush( QBrush( Qt::black ) );
95 return; 96 return;
96 } 97 }
97 98
98 QPixmap buffer( size() ); 99 QPixmap buffer( size() );
99 QPainter bufferedPainter( &buffer ); 100 QPainter bufferedPainter( &buffer );
100 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); 101 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) );
101 paintAllButtons( bufferedPainter ); 102 paintAllButtons( bufferedPainter );
102 p.drawPixmap( 0, 0, buffer ); 103 p.drawPixmap( 0, 0, buffer );
103} 104}
104 105
105void MediaWidget::resizeEvent( QResizeEvent *e ) 106void MediaWidget::resizeEvent( QResizeEvent *e )
106{ 107{
107 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); 108 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
108 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); 109 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
109 110
110 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 111 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
111 Button &button = *it; 112 Button &button = *it;
112 113
113 if ( button.mask.isNull() ) 114 if ( button.mask.isNull() )
114 continue; 115 continue;
115 button.pixUp = addMaskToPixmap( pixUp, button.mask ); 116 button.pixUp = addMaskToPixmap( pixUp, button.mask );
116 button.pixDown = addMaskToPixmap( pixDn, button.mask ); 117 button.pixDown = addMaskToPixmap( pixDn, button.mask );
117 } 118 }
118 119
119 QWidget::resizeEvent( e ); 120 QWidget::resizeEvent( e );
120} 121}
121 122
122MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 123MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
123{ 124{
124 if ( position.x() <= 0 || position.y() <= 0 || 125 if ( position.x() <= 0 || position.y() <= 0 ||
125 position.x() >= buttonMask.width() || 126 position.x() >= buttonMask.width() ||
126 position.y() >= buttonMask.height() ) 127 position.y() >= buttonMask.height() )
127 return 0; 128 return 0;
128 129
129 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 130 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
130 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 131 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
131 if ( it->command + 1 == pixelIdx ) 132 if ( it->command + 1 == pixelIdx )
132 return &( *it ); 133 return &( *it );
133 134
134 return 0; 135 return 0;
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp
index a8f4ae9..44f5ca2 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -16,133 +16,137 @@
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 25
26#include <qcache.h> 26#include <qcache.h>
27#include <qmap.h> 27#include <qmap.h>
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/config.h> 31#include <qpe/config.h>
32 32
33#include <assert.h> 33#include <assert.h>
34 34
35struct SkinData 35struct SkinData
36{ 36{
37 typedef QMap<QString, QImage> ButtonMaskImageMap; 37 typedef QMap<QString, QImage> ButtonMaskImageMap;
38 38
39 QPixmap backgroundPixmap; 39 QPixmap backgroundPixmap;
40 QImage buttonUpImage; 40 QImage buttonUpImage;
41 QImage buttonDownImage; 41 QImage buttonDownImage;
42 QImage buttonMask; 42 QImage buttonMask;
43 ButtonMaskImageMap buttonMasks; 43 ButtonMaskImageMap buttonMasks;
44}; 44};
45 45
46class SkinCache : public Singleton<SkinCache> 46class SkinCache : public Singleton<SkinCache>
47{ 47{
48public: 48public:
49 SkinCache(); 49 SkinCache();
50 50
51 SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix ); 51 SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix );
52 52
53 void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ); 53 void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data );
54 54
55private: 55private:
56 typedef QCache<SkinData> DataCache; 56 typedef QCache<SkinData> DataCache;
57 typedef QCache<QPixmap> BackgroundPixmapCache; 57 typedef QCache<QPixmap> BackgroundPixmapCache;
58 58
59 template <class CacheType> 59 template <class CacheType>
60 void store( const QCache<CacheType> &cache, const QString &key, CacheType *data ); 60 void store( const QCache<CacheType> &cache, const QString &key, CacheType *data );
61 61
62 DataCache m_cache; 62 DataCache m_cache;
63 BackgroundPixmapCache m_backgroundPixmapCache; 63 BackgroundPixmapCache m_backgroundPixmapCache;
64}; 64};
65 65
66Skin::Skin( const QString &name, const QString &fileNameInfix ) 66Skin::Skin( const QString &name, const QString &fileNameInfix )
67 : m_fileNameInfix( fileNameInfix ) 67 : m_fileNameInfix( fileNameInfix )
68{ 68{
69 init( name ); 69 init( name );
70} 70}
71 71
72Skin::Skin( const QString &fileNameInfix ) 72Skin::Skin( const QString &fileNameInfix )
73 : m_fileNameInfix( fileNameInfix ) 73 : m_fileNameInfix( fileNameInfix )
74{ 74{
75 init( defaultSkinName() ); 75 init( defaultSkinName() );
76} 76}
77 77
78Skin::~Skin() 78Skin::~Skin()
79{ 79{
80 SkinCache::self().store( m_skinPath, m_fileNameInfix, d ); 80 if ( m_isCachable )
81 SkinCache::self().store( m_skinPath, m_fileNameInfix, d );
82 else
83 delete d;
81} 84}
82 85
83void Skin::init( const QString &name ) 86void Skin::init( const QString &name )
84{ 87{
88 m_isCachable = true;
85 m_skinPath = "opieplayer2/skins/" + name; 89 m_skinPath = "opieplayer2/skins/" + name;
86 d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix ); 90 d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix );
87} 91}
88 92
89QPixmap Skin::backgroundPixmap() const 93QPixmap Skin::backgroundPixmap() const
90{ 94{
91 if ( d->backgroundPixmap.isNull() ) 95 if ( d->backgroundPixmap.isNull() )
92 d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) ); 96 d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) );
93 return d->backgroundPixmap; 97 return d->backgroundPixmap;
94} 98}
95 99
96QImage Skin::buttonUpImage() const 100QImage Skin::buttonUpImage() const
97{ 101{
98 if ( d->buttonUpImage.isNull() ) 102 if ( d->buttonUpImage.isNull() )
99 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 ) );
100 return d->buttonUpImage; 104 return d->buttonUpImage;
101} 105}
102 106
103QImage Skin::buttonDownImage() const 107QImage Skin::buttonDownImage() const
104{ 108{
105 if ( d->buttonDownImage.isNull() ) 109 if ( d->buttonDownImage.isNull() )
106 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 ) );
107 return d->buttonDownImage; 111 return d->buttonDownImage;
108} 112}
109 113
110QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const 114QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const
111{ 115{
112 if ( !d->buttonMask.isNull() ) 116 if ( !d->buttonMask.isNull() )
113 return d->buttonMask; 117 return d->buttonMask;
114 118
115 QSize buttonAreaSize = buttonUpImage().size(); 119 QSize buttonAreaSize = buttonUpImage().size();
116 120
117 d->buttonMask = QImage( buttonAreaSize, 8, 255 ); 121 d->buttonMask = QImage( buttonAreaSize, 8, 255 );
118 d->buttonMask.fill( 0 ); 122 d->buttonMask.fill( 0 );
119 123
120 for ( uint i = 0; i < buttonCount; ++i ) 124 for ( uint i = 0; i < buttonCount; ++i )
121 addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); 125 addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) );
122 126
123 return d->buttonMask; 127 return d->buttonMask;
124} 128}
125 129
126void Skin::addButtonToMask( int tag, const QImage &maskImage ) const 130void Skin::addButtonToMask( int tag, const QImage &maskImage ) const
127{ 131{
128 if ( maskImage.isNull() ) 132 if ( maskImage.isNull() )
129 return; 133 return;
130 134
131 uchar **dest = d->buttonMask.jumpTable(); 135 uchar **dest = d->buttonMask.jumpTable();
132 for ( int y = 0; y < d->buttonMask.height(); y++ ) { 136 for ( int y = 0; y < d->buttonMask.height(); y++ ) {
133 uchar *line = dest[y]; 137 uchar *line = dest[y];
134 for ( int x = 0; x < d->buttonMask.width(); x++ ) 138 for ( int x = 0; x < d->buttonMask.width(); x++ )
135 if ( !qRed( maskImage.pixel( x, y ) ) ) 139 if ( !qRed( maskImage.pixel( x, y ) ) )
136 line[x] = tag; 140 line[x] = tag;
137 } 141 }
138} 142}
139 143
140QImage Skin::buttonMaskImage( const QString &fileName ) const 144QImage Skin::buttonMaskImage( const QString &fileName ) const
141{ 145{
142 SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); 146 SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName );
143 if ( it == d->buttonMasks.end() ) { 147 if ( it == d->buttonMasks.end() ) {
144 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 );
145 QString path = prefix + fileName + ".png"; 149 QString path = prefix + fileName + ".png";
146 it = d->buttonMasks.insert( fileName, loadImage( path ) ); 150 it = d->buttonMasks.insert( fileName, loadImage( path ) );
147 } 151 }
148 return *it; 152 return *it;
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h
index bafebd3..067b6c4 100644
--- a/noncore/multimedia/opieplayer2/skin.h
+++ b/noncore/multimedia/opieplayer2/skin.h
@@ -1,122 +1,126 @@
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#ifndef SKIN_H 23#ifndef SKIN_H
24#define SKIN_H 24#define SKIN_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27#include <qimage.h> 27#include <qimage.h>
28#include <qobject.h> 28#include <qobject.h>
29 29
30#include "mediawidget.h" 30#include "mediawidget.h"
31 31
32struct SkinData; 32struct SkinData;
33 33
34class Skin 34class Skin
35{ 35{
36public: 36public:
37 Skin( const QString &name, const QString &fileNameInfix ); 37 Skin( const QString &name, const QString &fileNameInfix );
38 Skin( const QString &fileNameInfix ); 38 Skin( const QString &fileNameInfix );
39 ~Skin(); 39 ~Skin();
40 40
41 bool isCachable() const { return m_isCachable; }
42 void setCachable( bool cachable ) { m_isCachable = cachable; }
43
41 QPixmap backgroundPixmap() const; 44 QPixmap backgroundPixmap() const;
42 QImage buttonUpImage() const; 45 QImage buttonUpImage() const;
43 QImage buttonDownImage() const; 46 QImage buttonDownImage() const;
44 47
45 QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; 48 QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const;
46 49
47 QImage buttonMaskImage( const QString &fileName ) const; 50 QImage buttonMaskImage( const QString &fileName ) const;
48 51
49 static QString defaultSkinName(); 52 static QString defaultSkinName();
50 53
51private: 54private:
52 void init( const QString &name ); 55 void init( const QString &name );
53 56
54 void addButtonToMask( int tag, const QImage &maskImage ) const; 57 void addButtonToMask( int tag, const QImage &maskImage ) const;
55 58
56 static QImage loadImage( const QString &fileName ); 59 static QImage loadImage( const QString &fileName );
57 60
58 QString m_fileNameInfix; 61 QString m_fileNameInfix;
59 QString m_skinPath; 62 QString m_skinPath;
63 bool m_isCachable : 1;
60 64
61 SkinData *d; 65 SkinData *d;
62 66
63 Skin( const Skin & ); 67 Skin( const Skin & );
64 Skin &operator=( const Skin & ); 68 Skin &operator=( const Skin & );
65}; 69};
66 70
67class SkinLoader : public QObject 71class SkinLoader : public QObject
68{ 72{
69 Q_OBJECT 73 Q_OBJECT
70public: 74public:
71 SkinLoader(); 75 SkinLoader();
72 virtual ~SkinLoader(); 76 virtual ~SkinLoader();
73 77
74 void schedule( const MediaWidget::GUIInfo &guiInfo ); 78 void schedule( const MediaWidget::GUIInfo &guiInfo );
75 void schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo ); 79 void schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo );
76 80
77 void start(); 81 void start();
78 82
79protected: 83protected:
80 virtual void timerEvent( QTimerEvent *ev ); 84 virtual void timerEvent( QTimerEvent *ev );
81 85
82private slots: 86private slots:
83 void deleteMe(); 87 void deleteMe();
84 88
85private: 89private:
86 struct Info : public MediaWidget::GUIInfo 90 struct Info : public MediaWidget::GUIInfo
87 { 91 {
88 Info() {} 92 Info() {}
89 Info( const QString &_skinName, const MediaWidget::GUIInfo &guiInfo ) 93 Info( const QString &_skinName, const MediaWidget::GUIInfo &guiInfo )
90 : MediaWidget::GUIInfo( guiInfo ), skinName( _skinName ) 94 : MediaWidget::GUIInfo( guiInfo ), skinName( _skinName )
91 {} 95 {}
92 96
93 QString skinName; 97 QString skinName;
94 }; 98 };
95 typedef QValueList<Info> InfoList; 99 typedef QValueList<Info> InfoList;
96 100
97 class IncrementalLoader 101 class IncrementalLoader
98 { 102 {
99 public: 103 public:
100 enum LoaderResult { LoadingCompleted, MoreToCome }; 104 enum LoaderResult { LoadingCompleted, MoreToCome };
101 105
102 IncrementalLoader( const Info &info ); 106 IncrementalLoader( const Info &info );
103 107
104 LoaderResult loadStep(); 108 LoaderResult loadStep();
105 109
106 private: 110 private:
107 enum State { LoadBackgroundPixmap, LoadButtonUpImage, LoadButtonDownImage, LoadButtonMasks, LoadButtonMask }; 111 enum State { LoadBackgroundPixmap, LoadButtonUpImage, LoadButtonDownImage, LoadButtonMasks, LoadButtonMask };
108 112
109 Skin m_skin; 113 Skin m_skin;
110 Info m_info; 114 Info m_info;
111 State m_currentState; 115 State m_currentState;
112 uint m_currentButton; 116 uint m_currentButton;
113 }; 117 };
114 118
115 InfoList pendingSkins; 119 InfoList pendingSkins;
116 IncrementalLoader *m_currentLoader; 120 IncrementalLoader *m_currentLoader;
117 int m_timerId; 121 int m_timerId;
118}; 122};
119 123
120#endif // SKIN_H 124#endif // SKIN_H
121/* vim: et sw=4 ts=4 125/* vim: et sw=4 ts=4
122 */ 126 */