summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediawidget.cpp
authorsimon <simon>2002-12-11 01:09:30 (UTC)
committer simon <simon>2002-12-11 01:09:30 (UTC)
commit7e71955ef58a502d6a6dd2384c3f55bd852d649a (patch) (unidiff)
tree99096f2de6d579ddfa461495cddd07f40859e4d4 /noncore/multimedia/opieplayer2/mediawidget.cpp
parent212b7605f9e86d2161e11f65498c37acd1863300 (diff)
downloadopie-7e71955ef58a502d6a6dd2384c3f55bd852d649a.zip
opie-7e71955ef58a502d6a6dd2384c3f55bd852d649a.tar.gz
opie-7e71955ef58a502d6a6dd2384c3f55bd852d649a.tar.bz2
- centralize more of the skin loading code, so it can be factored out later
more easily
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediawidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index d60dc0d..c9d7db8 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -15,24 +15,27 @@
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 26
27#include <qpe/config.h>
28#include <qpe/qpeapplication.h>
29
27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 30MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 31 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
29{ 32{
30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 33 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 34 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 35 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
33 this, SLOT( setLength( long ) ) ); 36 this, SLOT( setLength( long ) ) );
34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 37 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
35 this, SLOT( setPlaying( bool ) ) ); 38 this, SLOT( setPlaying( bool ) ) );
36} 39}
37 40
38MediaWidget::~MediaWidget() 41MediaWidget::~MediaWidget()
@@ -76,24 +79,44 @@ QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fil
76 QImage imgMask = mask.convertToImage(); 79 QImage imgMask = mask.convertToImage();
77 uchar **dest = buttonMask.jumpTable(); 80 uchar **dest = buttonMask.jumpTable();
78 for ( int y = 0; y < buttonMask.height(); y++ ) { 81 for ( int y = 0; y < buttonMask.height(); y++ ) {
79 uchar *line = dest[y]; 82 uchar *line = dest[y];
80 for ( int x = 0; x < buttonMask.width(); x++ ) 83 for ( int x = 0; x < buttonMask.width(); x++ )
81 if ( !qRed( imgMask.pixel( x, y ) ) ) 84 if ( !qRed( imgMask.pixel( x, y ) ) )
82 line[x] = command + 1; 85 line[x] = command + 1;
83 } 86 }
84 87
85 return mask; 88 return mask;
86} 89}
87 90
91void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix )
92{
93 Config cfg( "OpiePlayer" );
94 cfg.setGroup( "Options" );
95 QString skin = cfg.readEntry( "Skin","default" );
96
97 loadSkin( skinInfo, buttonCount, skin, fileNameInfix );
98}
99
100void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix )
101{
102 QString skinPath = "opieplayer2/skins/" + name;
103 backgroundPixmap = QPixmap( Resource::loadPixmap( QString( "%1/background" ).arg( skinPath ) ) );
104 buttonUpImage = QImage( Resource::loadImage( QString( "%1/skin%2_up" ).arg( skinPath ).arg( fileNameInfix ) ) );
105 buttonDownImage = QImage( Resource::loadImage( QString( "%1/skin%2_down" ).arg( skinPath ).arg( fileNameInfix ) ) );
106
107 setupButtons( skinInfo, buttonCount,
108 QPEApplication::qpeDir() + "/pics/" + skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() );
109}
110
88void MediaWidget::closeEvent( QCloseEvent * ) 111void MediaWidget::closeEvent( QCloseEvent * )
89{ 112{
90 mediaPlayerState.setList(); 113 mediaPlayerState.setList();
91} 114}
92 115
93void MediaWidget::paintEvent( QPaintEvent *pe ) 116void MediaWidget::paintEvent( QPaintEvent *pe )
94{ 117{
95 QPainter p( this ); 118 QPainter p( this );
96 119
97 if ( mediaPlayerState.isFullscreen() ) { 120 if ( mediaPlayerState.isFullscreen() ) {
98 // Clear the background 121 // Clear the background
99 p.setBrush( QBrush( Qt::black ) ); 122 p.setBrush( QBrush( Qt::black ) );