author | simon <simon> | 2002-12-11 13:12:29 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 13:12:29 (UTC) |
commit | cd5e96b40ceae9158e5cb01e71769e895ea7a3c1 (patch) (unidiff) | |
tree | 0a5e1961a31096f995e00215d851c3af8e8ae877 | |
parent | 57a776c8345422a0fc32b3fb9d604be1c050d201 (diff) | |
download | opie-cd5e96b40ceae9158e5cb01e71769e895ea7a3c1.zip opie-cd5e96b40ceae9158e5cb01e71769e895ea7a3c1.tar.gz opie-cd5e96b40ceae9158e5cb01e71769e895ea7a3c1.tar.bz2 |
- moved default skin name reading over to skin class
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 9 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 21 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.h | 6 |
3 files changed, 26 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 0d1c8b6..ab23aa8 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -1,172 +1,165 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
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 library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library 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 library is distributed in the hope that it will be useful, | 12 | This library 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 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. 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 | 23 | ||
24 | #include "mediawidget.h" | 24 | #include "mediawidget.h" |
25 | #include "playlistwidget.h" | 25 | #include "playlistwidget.h" |
26 | #include "skin.h" | 26 | #include "skin.h" |
27 | 27 | ||
28 | #include <qpe/config.h> | ||
29 | #include <qpe/qpeapplication.h> | ||
30 | |||
31 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) | 28 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) |
32 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) | 29 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) |
33 | { | 30 | { |
34 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), | 31 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), |
35 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 32 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
36 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 33 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), |
37 | this, SLOT( setLength( long ) ) ); | 34 | this, SLOT( setLength( long ) ) ); |
38 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 35 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
39 | this, SLOT( setPlaying( bool ) ) ); | 36 | this, SLOT( setPlaying( bool ) ) ); |
40 | } | 37 | } |
41 | 38 | ||
42 | MediaWidget::~MediaWidget() | 39 | MediaWidget::~MediaWidget() |
43 | { | 40 | { |
44 | } | 41 | } |
45 | 42 | ||
46 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, | 43 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, |
47 | const Skin &skin ) | 44 | const Skin &skin ) |
48 | { | 45 | { |
49 | buttonMask = skin.buttonMask( skinInfo, buttonCount ); | 46 | buttonMask = skin.buttonMask( skinInfo, buttonCount ); |
50 | 47 | ||
51 | buttons.clear(); | 48 | buttons.clear(); |
52 | buttons.reserve( buttonCount ); | 49 | buttons.reserve( buttonCount ); |
53 | 50 | ||
54 | for ( uint i = 0; i < buttonCount; ++i ) { | 51 | for ( uint i = 0; i < buttonCount; ++i ) { |
55 | Button button = setupButton( skinInfo[ i ], skin ); | 52 | Button button = setupButton( skinInfo[ i ], skin ); |
56 | buttons.push_back( button ); | 53 | buttons.push_back( button ); |
57 | } | 54 | } |
58 | } | 55 | } |
59 | 56 | ||
60 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) | 57 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) |
61 | { | 58 | { |
62 | Button button; | 59 | Button button; |
63 | button.command = buttonInfo.command; | 60 | button.command = buttonInfo.command; |
64 | button.type = buttonInfo.type; | 61 | button.type = buttonInfo.type; |
65 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); | 62 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); |
66 | 63 | ||
67 | return button; | 64 | return button; |
68 | } | 65 | } |
69 | 66 | ||
70 | void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) | 67 | void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) |
71 | { | 68 | { |
72 | Config cfg( "OpiePlayer" ); | 69 | Skin skin( fileNameInfix ); |
73 | cfg.setGroup( "Options" ); | ||
74 | QString name = cfg.readEntry( "Skin","default" ); | ||
75 | |||
76 | Skin skin( name, fileNameInfix ); | ||
77 | loadSkin( skinInfo, buttonCount, skin ); | 70 | loadSkin( skinInfo, buttonCount, skin ); |
78 | } | 71 | } |
79 | 72 | ||
80 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) | 73 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) |
81 | { | 74 | { |
82 | backgroundPixmap = skin.backgroundImage(); | 75 | backgroundPixmap = skin.backgroundImage(); |
83 | buttonUpImage = skin.buttonUpImage(); | 76 | buttonUpImage = skin.buttonUpImage(); |
84 | buttonDownImage = skin.buttonDownImage(); | 77 | buttonDownImage = skin.buttonDownImage(); |
85 | 78 | ||
86 | setupButtons( skinInfo, buttonCount, skin ); | 79 | setupButtons( skinInfo, buttonCount, skin ); |
87 | } | 80 | } |
88 | 81 | ||
89 | void MediaWidget::closeEvent( QCloseEvent * ) | 82 | void MediaWidget::closeEvent( QCloseEvent * ) |
90 | { | 83 | { |
91 | mediaPlayerState.setList(); | 84 | mediaPlayerState.setList(); |
92 | } | 85 | } |
93 | 86 | ||
94 | void MediaWidget::paintEvent( QPaintEvent *pe ) | 87 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
95 | { | 88 | { |
96 | QPainter p( this ); | 89 | QPainter p( this ); |
97 | 90 | ||
98 | if ( mediaPlayerState.isFullscreen() ) { | 91 | if ( mediaPlayerState.isFullscreen() ) { |
99 | // Clear the background | 92 | // Clear the background |
100 | p.setBrush( QBrush( Qt::black ) ); | 93 | p.setBrush( QBrush( Qt::black ) ); |
101 | return; | 94 | return; |
102 | } | 95 | } |
103 | 96 | ||
104 | if ( !pe->erased() ) { | 97 | if ( !pe->erased() ) { |
105 | // Combine with background and double buffer | 98 | // Combine with background and double buffer |
106 | QPixmap pix( pe->rect().size() ); | 99 | QPixmap pix( pe->rect().size() ); |
107 | QPainter p( &pix ); | 100 | QPainter p( &pix ); |
108 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 101 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
109 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | 102 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); |
110 | paintAllButtons( p ); | 103 | paintAllButtons( p ); |
111 | QPainter p2( this ); | 104 | QPainter p2( this ); |
112 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 105 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
113 | } else { | 106 | } else { |
114 | QPainter p( this ); | 107 | QPainter p( this ); |
115 | paintAllButtons( p ); | 108 | paintAllButtons( p ); |
116 | } | 109 | } |
117 | } | 110 | } |
118 | 111 | ||
119 | MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) | 112 | MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) |
120 | { | 113 | { |
121 | if ( position.x() <= 0 || position.y() <= 0 || | 114 | if ( position.x() <= 0 || position.y() <= 0 || |
122 | position.x() >= buttonMask.width() || | 115 | position.x() >= buttonMask.width() || |
123 | position.y() >= buttonMask.height() ) | 116 | position.y() >= buttonMask.height() ) |
124 | return 0; | 117 | return 0; |
125 | 118 | ||
126 | int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); | 119 | int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); |
127 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) | 120 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) |
128 | if ( it->command + 1 == pixelIdx ) | 121 | if ( it->command + 1 == pixelIdx ) |
129 | return &( *it ); | 122 | return &( *it ); |
130 | 123 | ||
131 | return 0; | 124 | return 0; |
132 | } | 125 | } |
133 | 126 | ||
134 | void MediaWidget::mousePressEvent( QMouseEvent *event ) | 127 | void MediaWidget::mousePressEvent( QMouseEvent *event ) |
135 | { | 128 | { |
136 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); | 129 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); |
137 | 130 | ||
138 | if ( !button ) { | 131 | if ( !button ) { |
139 | QWidget::mousePressEvent( event ); | 132 | QWidget::mousePressEvent( event ); |
140 | return; | 133 | return; |
141 | } | 134 | } |
142 | 135 | ||
143 | switch ( button->command ) { | 136 | switch ( button->command ) { |
144 | case VolumeUp: emit moreClicked(); return; | 137 | case VolumeUp: emit moreClicked(); return; |
145 | case VolumeDown: emit lessClicked(); return; | 138 | case VolumeDown: emit lessClicked(); return; |
146 | case Back: emit backClicked(); return; | 139 | case Back: emit backClicked(); return; |
147 | case Forward: emit forwardClicked(); return; | 140 | case Forward: emit forwardClicked(); return; |
148 | default: break; | 141 | default: break; |
149 | } | 142 | } |
150 | } | 143 | } |
151 | 144 | ||
152 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) | 145 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) |
153 | { | 146 | { |
154 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); | 147 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); |
155 | 148 | ||
156 | if ( !button ) { | 149 | if ( !button ) { |
157 | QWidget::mouseReleaseEvent( event ); | 150 | QWidget::mouseReleaseEvent( event ); |
158 | return; | 151 | return; |
159 | } | 152 | } |
160 | 153 | ||
161 | if ( button->type == ToggleButton ) | 154 | if ( button->type == ToggleButton ) |
162 | toggleButton( *button ); | 155 | toggleButton( *button ); |
163 | 156 | ||
164 | handleCommand( button->command, button->isDown ); | 157 | handleCommand( button->command, button->isDown ); |
165 | } | 158 | } |
166 | 159 | ||
167 | void MediaWidget::makeVisible() | 160 | void MediaWidget::makeVisible() |
168 | { | 161 | { |
169 | } | 162 | } |
170 | 163 | ||
171 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 164 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
172 | { | 165 | { |
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index d3918d1..8281b20 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp | |||
@@ -1,83 +1,102 @@ | |||
1 | 1 | ||
2 | #include "skin.h" | 2 | #include "skin.h" |
3 | 3 | ||
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | #include <qpe/config.h> | ||
5 | 6 | ||
6 | Skin::Skin( const QString &name, const QString &fileNameInfix ) | 7 | Skin::Skin( const QString &name, const QString &fileNameInfix ) |
7 | : m_name( name ), m_fileNameInfix( fileNameInfix ) | 8 | : m_fileNameInfix( fileNameInfix ) |
9 | { | ||
10 | init( name ); | ||
11 | } | ||
12 | |||
13 | Skin::Skin( const QString &fileNameInfix ) | ||
14 | : m_fileNameInfix( fileNameInfix ) | ||
15 | { | ||
16 | init( defaultSkinName() ); | ||
17 | } | ||
18 | |||
19 | void Skin::init( const QString &name ) | ||
8 | { | 20 | { |
9 | m_skinPath = "opieplayer2/skins/" + name; | 21 | m_skinPath = "opieplayer2/skins/" + name; |
10 | } | 22 | } |
11 | 23 | ||
12 | void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) | 24 | void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) |
13 | { | 25 | { |
14 | backgroundImage(); | 26 | backgroundImage(); |
15 | buttonUpImage(); | 27 | buttonUpImage(); |
16 | buttonDownImage(); | 28 | buttonDownImage(); |
17 | ( void )buttonMask( skinButtonInfo, buttonCount ); | 29 | ( void )buttonMask( skinButtonInfo, buttonCount ); |
18 | } | 30 | } |
19 | 31 | ||
20 | QImage Skin::backgroundImage() const | 32 | QImage Skin::backgroundImage() const |
21 | { | 33 | { |
22 | if ( m_backgroundImage.isNull() ) | 34 | if ( m_backgroundImage.isNull() ) |
23 | m_backgroundImage = QImage( Resource::findPixmap( QString( "%1/background" ).arg( m_skinPath ) ) ); | 35 | m_backgroundImage = QImage( Resource::findPixmap( QString( "%1/background" ).arg( m_skinPath ) ) ); |
24 | return m_backgroundImage; | 36 | return m_backgroundImage; |
25 | } | 37 | } |
26 | 38 | ||
27 | QImage Skin::buttonUpImage() const | 39 | QImage Skin::buttonUpImage() const |
28 | { | 40 | { |
29 | if ( m_buttonUpImage.isNull() ) | 41 | if ( m_buttonUpImage.isNull() ) |
30 | m_buttonUpImage = QImage( Resource::findPixmap( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); | 42 | m_buttonUpImage = QImage( Resource::findPixmap( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); |
31 | return m_buttonUpImage; | 43 | return m_buttonUpImage; |
32 | } | 44 | } |
33 | 45 | ||
34 | QImage Skin::buttonDownImage() const | 46 | QImage Skin::buttonDownImage() const |
35 | { | 47 | { |
36 | if ( m_buttonDownImage.isNull() ) | 48 | if ( m_buttonDownImage.isNull() ) |
37 | m_buttonDownImage = QImage( Resource::findPixmap( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); | 49 | m_buttonDownImage = QImage( Resource::findPixmap( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); |
38 | return m_buttonDownImage; | 50 | return m_buttonDownImage; |
39 | } | 51 | } |
40 | 52 | ||
41 | QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const | 53 | QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const |
42 | { | 54 | { |
43 | if ( !m_buttonMask.isNull() ) | 55 | if ( !m_buttonMask.isNull() ) |
44 | return m_buttonMask; | 56 | return m_buttonMask; |
45 | 57 | ||
46 | QSize buttonAreaSize = buttonUpImage().size(); | 58 | QSize buttonAreaSize = buttonUpImage().size(); |
47 | 59 | ||
48 | m_buttonMask = QImage( buttonAreaSize, 8, 255 ); | 60 | m_buttonMask = QImage( buttonAreaSize, 8, 255 ); |
49 | m_buttonMask.fill( 0 ); | 61 | m_buttonMask.fill( 0 ); |
50 | 62 | ||
51 | for ( uint i = 0; i < buttonCount; ++i ) | 63 | for ( uint i = 0; i < buttonCount; ++i ) |
52 | addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); | 64 | addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); |
53 | 65 | ||
54 | return m_buttonMask; | 66 | return m_buttonMask; |
55 | } | 67 | } |
56 | 68 | ||
57 | void Skin::addButtonToMask( int tag, const QImage &maskImage ) const | 69 | void Skin::addButtonToMask( int tag, const QImage &maskImage ) const |
58 | { | 70 | { |
59 | if ( maskImage.isNull() ) | 71 | if ( maskImage.isNull() ) |
60 | return; | 72 | return; |
61 | 73 | ||
62 | uchar **dest = m_buttonMask.jumpTable(); | 74 | uchar **dest = m_buttonMask.jumpTable(); |
63 | for ( int y = 0; y < m_buttonMask.height(); y++ ) { | 75 | for ( int y = 0; y < m_buttonMask.height(); y++ ) { |
64 | uchar *line = dest[y]; | 76 | uchar *line = dest[y]; |
65 | for ( int x = 0; x < m_buttonMask.width(); x++ ) | 77 | for ( int x = 0; x < m_buttonMask.width(); x++ ) |
66 | if ( !qRed( maskImage.pixel( x, y ) ) ) | 78 | if ( !qRed( maskImage.pixel( x, y ) ) ) |
67 | line[x] = tag; | 79 | line[x] = tag; |
68 | } | 80 | } |
69 | } | 81 | } |
70 | 82 | ||
71 | QImage Skin::buttonMaskImage( const QString &fileName ) const | 83 | QImage Skin::buttonMaskImage( const QString &fileName ) const |
72 | { | 84 | { |
73 | ButtonMaskImageMap::Iterator it = m_buttonMasks.find( fileName ); | 85 | ButtonMaskImageMap::Iterator it = m_buttonMasks.find( fileName ); |
74 | if ( it == m_buttonMasks.end() ) { | 86 | if ( it == m_buttonMasks.end() ) { |
75 | QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); | 87 | QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); |
76 | QString path = prefix + fileName + ".png"; | 88 | QString path = prefix + fileName + ".png"; |
77 | it = m_buttonMasks.insert( fileName, QImage( Resource::findPixmap( path ) ) ); | 89 | it = m_buttonMasks.insert( fileName, QImage( Resource::findPixmap( path ) ) ); |
78 | } | 90 | } |
79 | return *it; | 91 | return *it; |
80 | } | 92 | } |
81 | 93 | ||
94 | QString Skin::defaultSkinName() | ||
95 | { | ||
96 | Config cfg( "OpiePlayer" ); | ||
97 | cfg.setGroup( "Options" ); | ||
98 | return cfg.readEntry( "Skin", "default" ); | ||
99 | } | ||
100 | |||
82 | /* vim: et sw=4 ts=4 | 101 | /* vim: et sw=4 ts=4 |
83 | */ | 102 | */ |
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h index ee19f4b..58f1849 100644 --- a/noncore/multimedia/opieplayer2/skin.h +++ b/noncore/multimedia/opieplayer2/skin.h | |||
@@ -1,46 +1,50 @@ | |||
1 | #ifndef SKIN_H | 1 | #ifndef SKIN_H |
2 | #define SKIN_H | 2 | #define SKIN_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qimage.h> | 5 | #include <qimage.h> |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | 7 | ||
8 | #include "mediawidget.h" | 8 | #include "mediawidget.h" |
9 | 9 | ||
10 | class Skin | 10 | class Skin |
11 | { | 11 | { |
12 | public: | 12 | public: |
13 | Skin( const QString &name, const QString &fileNameInfix ); | 13 | Skin( const QString &name, const QString &fileNameInfix ); |
14 | Skin( const QString &fileNameInfix ); | ||
14 | 15 | ||
15 | void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ); | 16 | void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ); |
16 | 17 | ||
17 | QImage backgroundImage() const; | 18 | QImage backgroundImage() const; |
18 | QImage buttonUpImage() const; | 19 | QImage buttonUpImage() const; |
19 | QImage buttonDownImage() const; | 20 | QImage buttonDownImage() const; |
20 | 21 | ||
21 | QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; | 22 | QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; |
22 | 23 | ||
23 | QImage buttonMaskImage( const QString &fileName ) const; | 24 | QImage buttonMaskImage( const QString &fileName ) const; |
24 | 25 | ||
26 | static QString defaultSkinName(); | ||
27 | |||
25 | private: | 28 | private: |
29 | void init( const QString &name ); | ||
30 | |||
26 | void addButtonToMask( int tag, const QImage &maskImage ) const; | 31 | void addButtonToMask( int tag, const QImage &maskImage ) const; |
27 | 32 | ||
28 | QString m_name; | ||
29 | QString m_fileNameInfix; | 33 | QString m_fileNameInfix; |
30 | QString m_skinPath; | 34 | QString m_skinPath; |
31 | 35 | ||
32 | typedef QMap<QString, QImage> ButtonMaskImageMap; | 36 | typedef QMap<QString, QImage> ButtonMaskImageMap; |
33 | 37 | ||
34 | mutable QImage m_backgroundImage; | 38 | mutable QImage m_backgroundImage; |
35 | mutable QImage m_buttonUpImage; | 39 | mutable QImage m_buttonUpImage; |
36 | mutable QImage m_buttonDownImage; | 40 | mutable QImage m_buttonDownImage; |
37 | mutable QImage m_buttonMask; | 41 | mutable QImage m_buttonMask; |
38 | mutable ButtonMaskImageMap m_buttonMasks; | 42 | mutable ButtonMaskImageMap m_buttonMasks; |
39 | 43 | ||
40 | Skin( const Skin & ); | 44 | Skin( const Skin & ); |
41 | Skin &operator=( const Skin & ); | 45 | Skin &operator=( const Skin & ); |
42 | }; | 46 | }; |
43 | 47 | ||
44 | #endif // SKIN_H | 48 | #endif // SKIN_H |
45 | /* vim: et sw=4 ts=4 | 49 | /* vim: et sw=4 ts=4 |
46 | */ | 50 | */ |