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.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index f193001..08c62a2 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,133 +1,133 @@
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#include <assert.h> 23#include <assert.h>
24 24
25#include "mediawidget.h" 25#include "mediawidget.h"
26#include "playlistwidget.h" 26#include "playlistwidget.h"
27#include "skin.h" 27#include "skin.h"
28 28
29MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 29MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
30 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 30 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
31{ 31{
32 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 32 connect( &mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ),
33 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 33 this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) );
34 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 34 connect( &mediaPlayerState, SIGNAL( lengthChanged(long) ),
35 this, SLOT( setLength( long ) ) ); 35 this, SLOT( setLength(long) ) );
36 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 36 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ),
37 this, SLOT( setPlaying( bool ) ) ); 37 this, SLOT( setPlaying(bool) ) );
38 38
39 setBackgroundMode( NoBackground ); 39 setBackgroundMode( NoBackground );
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 Skin &skin ) 47 const Skin &skin )
48{ 48{
49 buttonMask = skin.buttonMask( skinInfo, buttonCount ); 49 buttonMask = skin.buttonMask( skinInfo, buttonCount );
50 50
51 buttons.clear(); 51 buttons.clear();
52 buttons.reserve( buttonCount ); 52 buttons.reserve( buttonCount );
53 53
54 for ( uint i = 0; i < buttonCount; ++i ) { 54 for ( uint i = 0; i < buttonCount; ++i ) {
55 Button button = setupButton( skinInfo[ i ], skin ); 55 Button button = setupButton( skinInfo[ i ], skin );
56 buttons.push_back( button ); 56 buttons.push_back( button );
57 } 57 }
58} 58}
59 59
60MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) 60MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
61{ 61{
62 Button button; 62 Button button;
63 button.command = buttonInfo.command; 63 button.command = buttonInfo.command;
64 button.type = buttonInfo.type; 64 button.type = buttonInfo.type;
65 button.mask = skin.buttonMaskImage( buttonInfo.fileName ); 65 button.mask = skin.buttonMaskImage( buttonInfo.fileName );
66 66
67 return button; 67 return button;
68} 68}
69 69
70void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) 70void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo )
71{ 71{
72 Skin skin( guiInfo.fileNameInfix ); 72 Skin skin( guiInfo.fileNameInfix );
73 skin.setCachable( false ); 73 skin.setCachable( false );
74 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); 74 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin );
75} 75}
76 76
77void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) 77void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin )
78{ 78{
79 backgroundPixmap = skin.backgroundPixmap(); 79 backgroundPixmap = skin.backgroundPixmap();
80 buttonUpImage = skin.buttonUpImage(); 80 buttonUpImage = skin.buttonUpImage();
81 buttonDownImage = skin.buttonDownImage(); 81 buttonDownImage = skin.buttonDownImage();
82 82
83 setupButtons( skinInfo, buttonCount, skin ); 83 setupButtons( skinInfo, buttonCount, skin );
84} 84}
85 85
86void MediaWidget::closeEvent( QCloseEvent * ) 86void MediaWidget::closeEvent( QCloseEvent * )
87{ 87{
88 mediaPlayerState.setList(); 88 mediaPlayerState.setList();
89} 89}
90 90
91void MediaWidget::paintEvent( QPaintEvent *pe ) 91void MediaWidget::paintEvent( QPaintEvent *pe )
92{ 92{
93 QPainter p( this ); 93 QPainter p( this );
94 94
95 if ( mediaPlayerState.isFullscreen() ) { 95 if ( mediaPlayerState.isFullscreen() ) {
96 // Clear the background 96 // Clear the background
97 p.setBrush( QBrush( Qt::black ) ); 97 p.setBrush( QBrush( Qt::black ) );
98 return; 98 return;
99 } 99 }
100 100
101 QPixmap buffer( size() ); 101 QPixmap buffer( size() );
102 QPainter bufferedPainter( &buffer ); 102 QPainter bufferedPainter( &buffer );
103 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); 103 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) );
104 paintAllButtons( bufferedPainter ); 104 paintAllButtons( bufferedPainter );
105 p.drawPixmap( 0, 0, buffer ); 105 p.drawPixmap( 0, 0, buffer );
106} 106}
107 107
108void MediaWidget::resizeEvent( QResizeEvent *e ) 108void MediaWidget::resizeEvent( QResizeEvent *e )
109{ 109{
110 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); 110 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
111 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); 111 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
112 112
113 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 113 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
114 Button &button = *it; 114 Button &button = *it;
115 115
116 if ( button.mask.isNull() ) 116 if ( button.mask.isNull() )
117 continue; 117 continue;
118 button.pixUp = addMaskToPixmap( pixUp, button.mask ); 118 button.pixUp = addMaskToPixmap( pixUp, button.mask );
119 button.pixDown = addMaskToPixmap( pixDn, button.mask ); 119 button.pixDown = addMaskToPixmap( pixDn, button.mask );
120 } 120 }
121 121
122 QWidget::resizeEvent( e ); 122 QWidget::resizeEvent( e );
123} 123}
124 124
125MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 125MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
126{ 126{
127 if ( position.x() <= 0 || position.y() <= 0 || 127 if ( position.x() <= 0 || position.y() <= 0 ||
128 position.x() >= buttonMask.width() || 128 position.x() >= buttonMask.width() ||
129 position.y() >= buttonMask.height() ) 129 position.y() >= buttonMask.height() )
130 return 0; 130 return 0;
131 131
132 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 132 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
133 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 133 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )