summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 12:21:55 (UTC)
committer simon <simon>2002-12-11 12:21:55 (UTC)
commitd24ad11763335834718485f14e90d8dab2611fa2 (patch) (unidiff)
treec2ad64ecd8f2e217a3816f57c3dec20aaac4e421
parent381de1a3cfcc32dd7c0350329413f55dd9de9bb8 (diff)
downloadopie-d24ad11763335834718485f14e90d8dab2611fa2.zip
opie-d24ad11763335834718485f14e90d8dab2611fa2.tar.gz
opie-d24ad11763335834718485f14e90d8dab2611fa2.tar.bz2
- moved the remaining pieces of image/pixmap loading to the Skin class
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp22
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h8
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp7
-rw-r--r--noncore/multimedia/opieplayer2/skin.h2
4 files changed, 23 insertions, 16 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 2031b4d..4de7ea9 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,208 +1,204 @@
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> 28#include <qpe/config.h>
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30 30
31MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 31MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
32 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 32 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
33{ 33{
34 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 34 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
35 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 35 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
36 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 36 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
37 this, SLOT( setLength( long ) ) ); 37 this, SLOT( setLength( long ) ) );
38 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 38 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
39 this, SLOT( setPlaying( bool ) ) ); 39 this, SLOT( setPlaying( bool ) ) );
40} 40}
41 41
42MediaWidget::~MediaWidget() 42MediaWidget::~MediaWidget()
43{ 43{
44} 44}
45 45
46void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 46void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
47 const QString &imagePrefix, const QSize &buttonAreaSize ) 47 const Skin &skin, const QSize &buttonAreaSize )
48{ 48{
49 buttonMask = QImage( buttonAreaSize, 8, 255 ); 49 buttonMask = QImage( buttonAreaSize, 8, 255 );
50 buttonMask.fill( 0 ); 50 buttonMask.fill( 0 );
51 51
52 buttons.clear(); 52 buttons.clear();
53 buttons.reserve( buttonCount ); 53 buttons.reserve( buttonCount );
54 54
55 for ( uint i = 0; i < buttonCount; ++i ) { 55 for ( uint i = 0; i < buttonCount; ++i ) {
56 Button button = setupButton( skinInfo[ i ], imagePrefix ); 56 Button button = setupButton( skinInfo[ i ], skin );
57 buttons.push_back( button ); 57 buttons.push_back( button );
58 } 58 }
59} 59}
60 60
61MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ) 61MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
62{ 62{
63 Button button; 63 Button button;
64 button.command = buttonInfo.command; 64 button.command = buttonInfo.command;
65 button.type = buttonInfo.type; 65 button.type = buttonInfo.type;
66 66
67 QString fileName = imagePrefix + buttonInfo.fileName + ".png"; 67 button.mask = setupButtonMask( button.command, skin.buttonMaskImage( buttonInfo.fileName ) );
68
69 button.mask = setupButtonMask( button.command, fileName );
70 68
71 return button; 69 return button;
72} 70}
73 71
74QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName ) 72QBitmap MediaWidget::setupButtonMask( const Command &command, const QImage &maskImage )
75{ 73{
76 QImage imgMask( Resource::findPixmap( fileName ) ); 74 if ( maskImage.isNull() )
77 if ( imgMask.isNull() )
78 return QBitmap(); 75 return QBitmap();
79 76
80 uchar **dest = buttonMask.jumpTable(); 77 uchar **dest = buttonMask.jumpTable();
81 for ( int y = 0; y < buttonMask.height(); y++ ) { 78 for ( int y = 0; y < buttonMask.height(); y++ ) {
82 uchar *line = dest[y]; 79 uchar *line = dest[y];
83 for ( int x = 0; x < buttonMask.width(); x++ ) 80 for ( int x = 0; x < buttonMask.width(); x++ )
84 if ( !qRed( imgMask.pixel( x, y ) ) ) 81 if ( !qRed( maskImage.pixel( x, y ) ) )
85 line[x] = command + 1; 82 line[x] = command + 1;
86 } 83 }
87 84
88 // ### grmbl qt2. use constructor when switching to qt3. 85 // ### grmbl qt2. use constructor when switching to qt3.
89 QBitmap bm; bm = imgMask; 86 QBitmap bm; bm = maskImage;
90 return bm; 87 return bm;
91} 88}
92 89
93void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) 90void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix )
94{ 91{
95 Config cfg( "OpiePlayer" ); 92 Config cfg( "OpiePlayer" );
96 cfg.setGroup( "Options" ); 93 cfg.setGroup( "Options" );
97 QString skin = cfg.readEntry( "Skin","default" ); 94 QString skin = cfg.readEntry( "Skin","default" );
98 95
99 loadSkin( skinInfo, buttonCount, skin, fileNameInfix ); 96 loadSkin( skinInfo, buttonCount, skin, fileNameInfix );
100} 97}
101 98
102void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix ) 99void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix )
103{ 100{
104 Skin skin( name, fileNameInfix ); 101 Skin skin( name, fileNameInfix );
105 102
106 QString skinPath = "opieplayer2/skins/" + name; 103 QString skinPath = "opieplayer2/skins/" + name;
107 backgroundPixmap = skin.backgroundImage(); 104 backgroundPixmap = skin.backgroundImage();
108 buttonUpImage = skin.buttonUpImage(); 105 buttonUpImage = skin.buttonUpImage();
109 buttonDownImage = skin.buttonDownImage(); 106 buttonDownImage = skin.buttonDownImage();
110 107
111 setupButtons( skinInfo, buttonCount, 108 setupButtons( skinInfo, buttonCount, skin, buttonUpImage.size() );
112 skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() );
113} 109}
114 110
115void MediaWidget::closeEvent( QCloseEvent * ) 111void MediaWidget::closeEvent( QCloseEvent * )
116{ 112{
117 mediaPlayerState.setList(); 113 mediaPlayerState.setList();
118} 114}
119 115
120void MediaWidget::paintEvent( QPaintEvent *pe ) 116void MediaWidget::paintEvent( QPaintEvent *pe )
121{ 117{
122 QPainter p( this ); 118 QPainter p( this );
123 119
124 if ( mediaPlayerState.isFullscreen() ) { 120 if ( mediaPlayerState.isFullscreen() ) {
125 // Clear the background 121 // Clear the background
126 p.setBrush( QBrush( Qt::black ) ); 122 p.setBrush( QBrush( Qt::black ) );
127 return; 123 return;
128 } 124 }
129 125
130 if ( !pe->erased() ) { 126 if ( !pe->erased() ) {
131 // Combine with background and double buffer 127 // Combine with background and double buffer
132 QPixmap pix( pe->rect().size() ); 128 QPixmap pix( pe->rect().size() );
133 QPainter p( &pix ); 129 QPainter p( &pix );
134 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 130 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
135 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 131 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
136 paintAllButtons( p ); 132 paintAllButtons( p );
137 QPainter p2( this ); 133 QPainter p2( this );
138 p2.drawPixmap( pe->rect().topLeft(), pix ); 134 p2.drawPixmap( pe->rect().topLeft(), pix );
139 } else { 135 } else {
140 QPainter p( this ); 136 QPainter p( this );
141 paintAllButtons( p ); 137 paintAllButtons( p );
142 } 138 }
143} 139}
144 140
145MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 141MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
146{ 142{
147 if ( position.x() <= 0 || position.y() <= 0 || 143 if ( position.x() <= 0 || position.y() <= 0 ||
148 position.x() >= buttonMask.width() || 144 position.x() >= buttonMask.width() ||
149 position.y() >= buttonMask.height() ) 145 position.y() >= buttonMask.height() )
150 return 0; 146 return 0;
151 147
152 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 148 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
153 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 149 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
154 if ( it->command + 1 == pixelIdx ) 150 if ( it->command + 1 == pixelIdx )
155 return &( *it ); 151 return &( *it );
156 152
157 return 0; 153 return 0;
158} 154}
159 155
160void MediaWidget::mousePressEvent( QMouseEvent *event ) 156void MediaWidget::mousePressEvent( QMouseEvent *event )
161{ 157{
162 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 158 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
163 159
164 if ( !button ) { 160 if ( !button ) {
165 QWidget::mousePressEvent( event ); 161 QWidget::mousePressEvent( event );
166 return; 162 return;
167 } 163 }
168 164
169 switch ( button->command ) { 165 switch ( button->command ) {
170 case VolumeUp: emit moreClicked(); return; 166 case VolumeUp: emit moreClicked(); return;
171 case VolumeDown: emit lessClicked(); return; 167 case VolumeDown: emit lessClicked(); return;
172 case Back: emit backClicked(); return; 168 case Back: emit backClicked(); return;
173 case Forward: emit forwardClicked(); return; 169 case Forward: emit forwardClicked(); return;
174 default: break; 170 default: break;
175 } 171 }
176} 172}
177 173
178void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) 174void MediaWidget::mouseReleaseEvent( QMouseEvent *event )
179{ 175{
180 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 176 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
181 177
182 if ( !button ) { 178 if ( !button ) {
183 QWidget::mouseReleaseEvent( event ); 179 QWidget::mouseReleaseEvent( event );
184 return; 180 return;
185 } 181 }
186 182
187 if ( button->type == ToggleButton ) 183 if ( button->type == ToggleButton )
188 toggleButton( *button ); 184 toggleButton( *button );
189 185
190 handleCommand( button->command, button->isDown ); 186 handleCommand( button->command, button->isDown );
191} 187}
192 188
193void MediaWidget::makeVisible() 189void MediaWidget::makeVisible()
194{ 190{
195} 191}
196 192
197void MediaWidget::handleCommand( Command command, bool buttonDown ) 193void MediaWidget::handleCommand( Command command, bool buttonDown )
198{ 194{
199 switch ( command ) { 195 switch ( command ) {
200 case Play: mediaPlayerState.togglePaused(); return; 196 case Play: mediaPlayerState.togglePaused(); return;
201 case Stop: mediaPlayerState.setPlaying(FALSE); return; 197 case Stop: mediaPlayerState.setPlaying(FALSE); return;
202 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 198 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
203 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 199 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
204 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 200 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
205 case VolumeUp: emit moreReleased(); return; 201 case VolumeUp: emit moreReleased(); return;
206 case VolumeDown: emit lessReleased(); return; 202 case VolumeDown: emit lessReleased(); return;
207 case PlayList: mediaPlayerState.setList(); return; 203 case PlayList: mediaPlayerState.setList(); return;
208 case Forward: emit forwardReleased(); return; 204 case Forward: emit forwardReleased(); return;
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 52b9fcb..0d635aa 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,149 +1,151 @@
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#ifndef MEDIAWIDGET_H 23#ifndef MEDIAWIDGET_H
24#define MEDIAWIDGET_H 24#define MEDIAWIDGET_H
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qmap.h> 27#include <qmap.h>
28 28
29#include "mediaplayerstate.h" 29#include "mediaplayerstate.h"
30#include "playlistwidget.h" 30#include "playlistwidget.h"
31 31
32#include <vector> 32#include <vector>
33#include <memory> 33#include <memory>
34 34
35namespace 35namespace
36{ 36{
37 struct simpleAndStupidAllocator 37 struct simpleAndStupidAllocator
38 { 38 {
39 static void *allocate( size_t amount ) 39 static void *allocate( size_t amount )
40 { return ::operator new( amount ); } 40 { return ::operator new( amount ); }
41 static void deallocate( void *p, size_t ) 41 static void deallocate( void *p, size_t )
42 { ::operator delete( p ); } 42 { ::operator delete( p ); }
43 }; 43 };
44} 44}
45 45
46class Skin;
47
46class MediaWidget : public QWidget 48class MediaWidget : public QWidget
47{ 49{
48 Q_OBJECT 50 Q_OBJECT
49public: 51public:
50 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; 52 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
51 enum ButtonType { NormalButton, ToggleButton }; 53 enum ButtonType { NormalButton, ToggleButton };
52 54
53 struct Button 55 struct Button
54 { 56 {
55 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {} 57 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {}
56 58
57 Command command; 59 Command command;
58 60
59 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( 61 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
60 bool isDown : 1; 62 bool isDown : 1;
61 63
62 QBitmap mask; 64 QBitmap mask;
63 QPixmap pixUp; 65 QPixmap pixUp;
64 QPixmap pixDown; 66 QPixmap pixDown;
65 }; 67 };
66#if defined( _CC_GNU_ ) 68#if defined( _CC_GNU_ )
67 // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because 69 // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because
68 // in the BAD_ALLOC macro it uses std::cerr and friends :-( 70 // in the BAD_ALLOC macro it uses std::cerr and friends :-(
69 typedef std::vector<Button, std::__allocator<Button, simpleAndStupidAllocator> > ButtonVector; 71 typedef std::vector<Button, std::__allocator<Button, simpleAndStupidAllocator> > ButtonVector;
70#else 72#else
71 typedef std::vector<Button> ButtonVector; 73 typedef std::vector<Button> ButtonVector;
72#endif 74#endif
73 75
74 struct SkinButtonInfo 76 struct SkinButtonInfo
75 { 77 {
76 Command command; 78 Command command;
77 const char *fileName; 79 const char *fileName;
78 ButtonType type; 80 ButtonType type;
79 }; 81 };
80 82
81 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 83 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
82 virtual ~MediaWidget(); 84 virtual ~MediaWidget();
83 85
84public slots: 86public slots:
85 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 87 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
86 virtual void setLength( long length ) = 0; 88 virtual void setLength( long length ) = 0;
87 virtual void setPlaying( bool playing ) = 0; 89 virtual void setPlaying( bool playing ) = 0;
88 90
89 virtual void loadSkin() = 0; 91 virtual void loadSkin() = 0;
90 92
91signals: 93signals:
92 void moreReleased(); 94 void moreReleased();
93 void lessReleased(); 95 void lessReleased();
94 void forwardReleased(); 96 void forwardReleased();
95 void backReleased(); 97 void backReleased();
96 void forwardClicked(); 98 void forwardClicked();
97 void backClicked(); 99 void backClicked();
98 void moreClicked(); 100 void moreClicked();
99 void lessClicked(); 101 void lessClicked();
100 102
101protected: 103protected:
102 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 104 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
103 const QString &imagePrefix, const QSize &buttonAreaSize ); 105 const Skin &skin, const QSize &buttonAreaSize );
104 Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ); 106 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin );
105 QBitmap setupButtonMask( const Command &command, const QString &fileName ); 107 QBitmap setupButtonMask( const Command &command, const QImage &maskImage );
106 108
107 void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null ); 109 void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null );
108 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix ); 110 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix );
109 111
110 virtual void closeEvent( QCloseEvent * ); 112 virtual void closeEvent( QCloseEvent * );
111 113
112 virtual void paintEvent( QPaintEvent *pe ); 114 virtual void paintEvent( QPaintEvent *pe );
113 115
114 Button *buttonAt( const QPoint &position ); 116 Button *buttonAt( const QPoint &position );
115 117
116 virtual void mousePressEvent( QMouseEvent *event ); 118 virtual void mousePressEvent( QMouseEvent *event );
117 virtual void mouseReleaseEvent( QMouseEvent *event ); 119 virtual void mouseReleaseEvent( QMouseEvent *event );
118 120
119 virtual void makeVisible(); 121 virtual void makeVisible();
120 122
121 void handleCommand( Command command, bool buttonDown ); 123 void handleCommand( Command command, bool buttonDown );
122 124
123 bool isOverButton( const QPoint &position, int buttonId ) const; 125 bool isOverButton( const QPoint &position, int buttonId ) const;
124 126
125 void paintAllButtons( QPainter &p ); 127 void paintAllButtons( QPainter &p );
126 void paintButton( const Button &button ); 128 void paintButton( const Button &button );
127 void paintButton( QPainter &p, const Button &button ); 129 void paintButton( QPainter &p, const Button &button );
128 130
129 void setToggleButton( Button &button, bool down ); 131 void setToggleButton( Button &button, bool down );
130 void setToggleButton( Command command, bool down ); 132 void setToggleButton( Command command, bool down );
131 void toggleButton( Button &button ); 133 void toggleButton( Button &button );
132 134
133 MediaPlayerState &mediaPlayerState; 135 MediaPlayerState &mediaPlayerState;
134 PlayListWidget &playList; 136 PlayListWidget &playList;
135 137
136 ButtonVector buttons; 138 ButtonVector buttons;
137 139
138 QImage buttonMask; 140 QImage buttonMask;
139 141
140 QPoint upperLeftOfButtonMask; 142 QPoint upperLeftOfButtonMask;
141 143
142 QPixmap backgroundPixmap; 144 QPixmap backgroundPixmap;
143 QImage buttonUpImage; 145 QImage buttonUpImage;
144 QImage buttonDownImage; 146 QImage buttonDownImage;
145}; 147};
146 148
147#endif // MEDIAWIDGET_H 149#endif // MEDIAWIDGET_H
148/* vim: et sw=4 ts=4 150/* vim: et sw=4 ts=4
149 */ 151 */
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp
index 352368f..fb1c9c4 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -1,28 +1,35 @@
1 1
2#include "skin.h" 2#include "skin.h"
3 3
4#include <qpe/resource.h> 4#include <qpe/resource.h>
5 5
6Skin::Skin( const QString &name, const QString &fileNameInfix ) 6Skin::Skin( const QString &name, const QString &fileNameInfix )
7 : m_name( name ), m_fileNameInfix( fileNameInfix ) 7 : m_name( name ), m_fileNameInfix( fileNameInfix )
8{ 8{
9 m_skinPath = "opieplayer2/skins/" + name; 9 m_skinPath = "opieplayer2/skins/" + name;
10} 10}
11 11
12QImage Skin::backgroundImage() const 12QImage Skin::backgroundImage() const
13{ 13{
14 return QImage( Resource::findPixmap( QString( "%1/background" ).arg( m_skinPath ) ) ); 14 return QImage( Resource::findPixmap( QString( "%1/background" ).arg( m_skinPath ) ) );
15} 15}
16 16
17QImage Skin::buttonUpImage() const 17QImage Skin::buttonUpImage() const
18{ 18{
19 return QImage( Resource::findPixmap( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); 19 return QImage( Resource::findPixmap( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) );
20} 20}
21 21
22QImage Skin::buttonDownImage() const 22QImage Skin::buttonDownImage() const
23{ 23{
24 return QImage( Resource::findPixmap( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); 24 return QImage( Resource::findPixmap( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) );
25} 25}
26 26
27QImage Skin::buttonMaskImage( const QString &fileName ) const
28{
29 QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix );
30 QString path = prefix + fileName + ".png";
31 return QImage( Resource::findPixmap( path ) );
32}
33
27/* vim: et sw=4 ts=4 34/* vim: et sw=4 ts=4
28 */ 35 */
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h
index 85f9e57..f160b3c 100644
--- a/noncore/multimedia/opieplayer2/skin.h
+++ b/noncore/multimedia/opieplayer2/skin.h
@@ -1,27 +1,29 @@
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 6
7class Skin 7class Skin
8{ 8{
9public: 9public:
10 Skin( const QString &name, const QString &fileNameInfix ); 10 Skin( const QString &name, const QString &fileNameInfix );
11 11
12 QImage backgroundImage() const; 12 QImage backgroundImage() const;
13 QImage buttonUpImage() const; 13 QImage buttonUpImage() const;
14 QImage buttonDownImage() const; 14 QImage buttonDownImage() const;
15 15
16 QImage buttonMaskImage( const QString &fileName ) const;
17
16private: 18private:
17 QString m_name; 19 QString m_name;
18 QString m_fileNameInfix; 20 QString m_fileNameInfix;
19 QString m_skinPath; 21 QString m_skinPath;
20 22
21 Skin( const Skin & ); 23 Skin( const Skin & );
22 Skin &operator=( const Skin & ); 24 Skin &operator=( const Skin & );
23}; 25};
24 26
25#endif // SKIN_H 27#endif // SKIN_H
26/* vim: et sw=4 ts=4 28/* vim: et sw=4 ts=4
27 */ 29 */