summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediawidget.cpp
Unidiff
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
@@ -3,48 +3,51 @@
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 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()
39{ 42{
40} 43}
41 44
42void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 45void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
43 const QString &imagePrefix, const QSize &buttonAreaSize ) 46 const QString &imagePrefix, const QSize &buttonAreaSize )
44{ 47{
45 buttonMask = QImage( buttonAreaSize, 8, 255 ); 48 buttonMask = QImage( buttonAreaSize, 8, 255 );
46 buttonMask.fill( 0 ); 49 buttonMask.fill( 0 );
47 50
48 buttons.clear(); 51 buttons.clear();
49 buttons.reserve( buttonCount ); 52 buttons.reserve( buttonCount );
50 53
@@ -64,48 +67,68 @@ MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo,
64 67
65 button.mask = setupButtonMask( button.command, fileName ); 68 button.mask = setupButtonMask( button.command, fileName );
66 69
67 return button; 70 return button;
68} 71}
69 72
70QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName ) 73QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName )
71{ 74{
72 QBitmap mask( fileName ); 75 QBitmap mask( fileName );
73 if ( mask.isNull() ) 76 if ( mask.isNull() )
74 return mask; 77 return mask;
75 78
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 ) );
100 return; 123 return;
101 } 124 }
102 125
103 if ( !pe->erased() ) { 126 if ( !pe->erased() ) {
104 // Combine with background and double buffer 127 // Combine with background and double buffer
105 QPixmap pix( pe->rect().size() ); 128 QPixmap pix( pe->rect().size() );
106 QPainter p( &pix ); 129 QPainter p( &pix );
107 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 130 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
108 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 131 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
109 paintAllButtons( p ); 132 paintAllButtons( p );
110 QPainter p2( this ); 133 QPainter p2( this );
111 p2.drawPixmap( pe->rect().topLeft(), pix ); 134 p2.drawPixmap( pe->rect().topLeft(), pix );