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.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index c0ebd63..7eb75e6 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -24,109 +24,114 @@
24#include "mediawidget.h" 24#include "mediawidget.h"
25#include "playlistwidget.h" 25#include "playlistwidget.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} 36}
37 37
38MediaWidget::~MediaWidget() 38MediaWidget::~MediaWidget()
39{ 39{
40} 40}
41 41
42void MediaWidget::closeEvent( QCloseEvent * ) 42void MediaWidget::closeEvent( QCloseEvent * )
43{ 43{
44 mediaPlayerState.setList(); 44 mediaPlayerState.setList();
45} 45}
46 46
47void MediaWidget::paintEvent( QPaintEvent *pe ) 47void MediaWidget::paintEvent( QPaintEvent *pe )
48{ 48{
49 QPainter p( this ); 49 QPainter p( this );
50 50
51 if ( mediaPlayerState.isFullscreen() ) { 51 if ( mediaPlayerState.isFullscreen() ) {
52 // Clear the background 52 // Clear the background
53 p.setBrush( QBrush( Qt::black ) ); 53 p.setBrush( QBrush( Qt::black ) );
54 return; 54 return;
55 } 55 }
56 56
57 if ( !pe->erased() ) { 57 if ( !pe->erased() ) {
58 // Combine with background and double buffer 58 // Combine with background and double buffer
59 QPixmap pix( pe->rect().size() ); 59 QPixmap pix( pe->rect().size() );
60 QPainter p( &pix ); 60 QPainter p( &pix );
61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
63 paintAllButtons( p ); 63 paintAllButtons( p );
64 QPainter p2( this ); 64 QPainter p2( this );
65 p2.drawPixmap( pe->rect().topLeft(), pix ); 65 p2.drawPixmap( pe->rect().topLeft(), pix );
66 } else { 66 } else {
67 QPainter p( this ); 67 QPainter p( this );
68 paintAllButtons( p ); 68 paintAllButtons( p );
69 } 69 }
70} 70}
71 71
72void MediaWidget::makeVisible()
73{
74}
75
72void MediaWidget::handleCommand( Command command, bool buttonDown ) 76void MediaWidget::handleCommand( Command command, bool buttonDown )
73{ 77{
74 switch ( command ) { 78 switch ( command ) {
75 case Play: mediaPlayerState.togglePaused(); 79 case Play: mediaPlayerState.togglePaused();
76 case Stop: mediaPlayerState.setPlaying(FALSE); return; 80 case Stop: mediaPlayerState.setPlaying(FALSE); return;
77 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 81 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
78 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 82 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
79 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 83 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
80 case VolumeUp: emit moreReleased(); return; 84 case VolumeUp: emit moreReleased(); return;
81 case VolumeDown: emit lessReleased(); return; 85 case VolumeDown: emit lessReleased(); return;
82 case PlayList: mediaPlayerState.setList(); return; 86 case PlayList: mediaPlayerState.setList(); return;
83 case Forward: emit forwardReleased(); return; 87 case Forward: emit forwardReleased(); return;
84 case Back: emit backReleased(); return; 88 case Back: emit backReleased(); return;
89 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
85 default: assert( false ); 90 default: assert( false );
86 } 91 }
87} 92}
88 93
89bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 94bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
90{ 95{
91 return ( position.x() > 0 && position.y() > 0 && 96 return ( position.x() > 0 && position.y() > 0 &&
92 position.x() < buttonMask.width() && 97 position.x() < buttonMask.width() &&
93 position.y() < buttonMask.height() && 98 position.y() < buttonMask.height() &&
94 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 99 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
95} 100}
96 101
97void MediaWidget::paintAllButtons( QPainter &p ) 102void MediaWidget::paintAllButtons( QPainter &p )
98{ 103{
99 for ( ButtonVector::const_iterator it = buttons.begin(); 104 for ( ButtonVector::const_iterator it = buttons.begin();
100 it != buttons.end(); ++it ) 105 it != buttons.end(); ++it )
101 paintButton( p, *it ); 106 paintButton( p, *it );
102} 107}
103 108
104void MediaWidget::paintButton( const Button &button ) 109void MediaWidget::paintButton( const Button &button )
105{ 110{
106 QPainter p( this ); 111 QPainter p( this );
107 paintButton( p, button ); 112 paintButton( p, button );
108} 113}
109 114
110void MediaWidget::paintButton( QPainter &p, const Button &button ) 115void MediaWidget::paintButton( QPainter &p, const Button &button )
111{ 116{
112 if ( button.isDown ) 117 if ( button.isDown )
113 p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); 118 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
114 else 119 else
115 p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); 120 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
116} 121}
117 122
118void MediaWidget::setToggleButton( Command command, bool down ) 123void MediaWidget::setToggleButton( Command command, bool down )
119{ 124{
120 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 125 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
121 if ( it->command == command ) { 126 if ( it->command == command ) {
122 setToggleButton( *it, down ); 127 setToggleButton( *it, down );
123 return; 128 return;
124 } 129 }
125} 130}
126 131
127void MediaWidget::setToggleButton( Button &button, bool down ) 132void MediaWidget::setToggleButton( Button &button, bool down )
128{ 133{
129 if ( down != button.isDown ) 134 if ( down != button.isDown )
130 toggleButton( button ); 135 toggleButton( button );
131} 136}
132 137