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