summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 16:39:32 (UTC)
committer simon <simon>2002-12-09 16:39:32 (UTC)
commit1bb6aa52f2db85f65f75278310c328218caeae65 (patch) (unidiff)
tree1983547bac0da80bde93554038a57713feb715c1
parent1ae041fba55e218a2523de441bec6ec3a1eecf02 (diff)
downloadopie-1bb6aa52f2db85f65f75278310c328218caeae65.zip
opie-1bb6aa52f2db85f65f75278310c328218caeae65.tar.gz
opie-1bb6aa52f2db85f65f75278310c328218caeae65.tar.bz2
- removing duplicated code in VideoWidget
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h4
4 files changed, 9 insertions, 27 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
@@ -1,141 +1,146 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
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
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
133void MediaWidget::toggleButton( Button &button ) 138void MediaWidget::toggleButton( Button &button )
134{ 139{
135 button.isDown = !button.isDown; 140 button.isDown = !button.isDown;
136 141
137 paintButton( button ); 142 paintButton( button );
138} 143}
139 144
140/* vim: et sw=4 ts=4 145/* vim: et sw=4 ts=4
141 */ 146 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index caae0a7..3f4c45d 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,112 +1,114 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
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#ifndef MEDIAWIDGET_H 23#ifndef MEDIAWIDGET_H
24#define MEDIAWIDGET_H 24#define MEDIAWIDGET_H
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qmap.h> 27#include <qmap.h>
28 28
29#include "mediaplayerstate.h" 29#include "mediaplayerstate.h"
30#include "playlistwidget.h" 30#include "playlistwidget.h"
31 31
32#include <vector> 32#include <vector>
33 33
34class MediaWidget : public QWidget 34class MediaWidget : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37public: 37public:
38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; 38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
39 enum ButtonType { NormalButton, ToggleButton }; 39 enum ButtonType { NormalButton, ToggleButton };
40 40
41 struct Button 41 struct Button
42 { 42 {
43 Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {} 43 Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {}
44 44
45 Command command; 45 Command command;
46 46
47 ButtonType type : 1; 47 ButtonType type : 1;
48 bool isHeld : 1; 48 bool isHeld : 1;
49 bool isDown : 1; 49 bool isDown : 1;
50 50
51 QBitmap mask; 51 QBitmap mask;
52 QPixmap pixUp; 52 QPixmap pixUp;
53 QPixmap pixDown; 53 QPixmap pixDown;
54 }; 54 };
55 typedef std::vector<Button> ButtonVector; 55 typedef std::vector<Button> ButtonVector;
56 56
57 struct SkinButtonInfo 57 struct SkinButtonInfo
58 { 58 {
59 Command command; 59 Command command;
60 const char *fileName; 60 const char *fileName;
61 ButtonType type; 61 ButtonType type;
62 }; 62 };
63 63
64 typedef std::vector<QBitmap> MaskVector; 64 typedef std::vector<QBitmap> MaskVector;
65 typedef std::vector<QPixmap> PixmapVector; 65 typedef std::vector<QPixmap> PixmapVector;
66 66
67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
68 virtual ~MediaWidget(); 68 virtual ~MediaWidget();
69 69
70public slots: 70public slots:
71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
72 virtual void setLength( long length ) = 0; 72 virtual void setLength( long length ) = 0;
73 virtual void setPlaying( bool playing ) = 0; 73 virtual void setPlaying( bool playing ) = 0;
74 74
75signals: 75signals:
76 void moreReleased(); 76 void moreReleased();
77 void lessReleased(); 77 void lessReleased();
78 void forwardReleased(); 78 void forwardReleased();
79 void backReleased(); 79 void backReleased();
80 80
81protected: 81protected:
82 virtual void closeEvent( QCloseEvent * ); 82 virtual void closeEvent( QCloseEvent * );
83 83
84 virtual void paintEvent( QPaintEvent *pe ); 84 virtual void paintEvent( QPaintEvent *pe );
85 85
86 virtual void makeVisible();
87
86 void handleCommand( Command command, bool buttonDown ); 88 void handleCommand( Command command, bool buttonDown );
87 89
88 bool isOverButton( const QPoint &position, int buttonId ) const; 90 bool isOverButton( const QPoint &position, int buttonId ) const;
89 91
90 void paintAllButtons( QPainter &p ); 92 void paintAllButtons( QPainter &p );
91 void paintButton( const Button &button ); 93 void paintButton( const Button &button );
92 void paintButton( QPainter &p, const Button &button ); 94 void paintButton( QPainter &p, const Button &button );
93 95
94 void setToggleButton( Button &button, bool down ); 96 void setToggleButton( Button &button, bool down );
95 void setToggleButton( Command command, bool down ); 97 void setToggleButton( Command command, bool down );
96 void toggleButton( Button &button ); 98 void toggleButton( Button &button );
97 99
98 MediaPlayerState &mediaPlayerState; 100 MediaPlayerState &mediaPlayerState;
99 PlayListWidget &playList; 101 PlayListWidget &playList;
100 102
101 ButtonVector buttons; 103 ButtonVector buttons;
102 104
103 QImage buttonMask; 105 QImage buttonMask;
104 106
105 QPoint upperLeftOfButtonMask; 107 QPoint upperLeftOfButtonMask;
106 108
107 QPixmap backgroundPixmap; 109 QPixmap backgroundPixmap;
108}; 110};
109 111
110#endif // MEDIAWIDGET_H 112#endif // MEDIAWIDGET_H
111/* vim: et sw=4 ts=4 113/* vim: et sw=4 ts=4
112 */ 114 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 12316f8..cc586cc 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -152,280 +152,257 @@ QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
152 QPixmap pixmap( pix ); 152 QPixmap pixmap( pix );
153 pixmap.setMask( mask ); 153 pixmap.setMask( mask );
154 return pixmap; 154 return pixmap;
155} 155}
156 156
157void VideoWidget::resizeEvent( QResizeEvent * ) { 157void VideoWidget::resizeEvent( QResizeEvent * ) {
158 int h = height(); 158 int h = height();
159 int w = width(); 159 int w = width();
160 //int Vh = 160; 160 //int Vh = 160;
161 //int Vw = 220; 161 //int Vw = 220;
162 162
163 slider->setFixedWidth( w - 20 ); 163 slider->setFixedWidth( w - 20 );
164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
165 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 165 slider->setBackgroundOrigin( QWidget::ParentOrigin );
166 slider->setFocusPolicy( QWidget::NoFocus ); 166 slider->setFocusPolicy( QWidget::NoFocus );
167 slider->setBackgroundPixmap( backgroundPixmap ); 167 slider->setBackgroundPixmap( backgroundPixmap );
168 168
169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
170 if(w>h) 170 if(w>h)
171 upperLeftOfButtonMask.ry() = 0; 171 upperLeftOfButtonMask.ry() = 0;
172 else 172 else
173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
174 QPoint p = upperLeftOfButtonMask; 174 QPoint p = upperLeftOfButtonMask;
175 175
176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); 176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p );
177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); 177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
178 178
179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
180 Button &button = *it; 180 Button &button = *it;
181 181
182 if ( !button.mask.isNull() ) { 182 if ( !button.mask.isNull() ) {
183 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 183 button.pixUp = maskVPixToMask( *pixUp, button.mask );
184 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 184 button.pixDown = maskVPixToMask( *pixDn, button.mask );
185 } 185 }
186 } 186 }
187 187
188 delete pixUp; 188 delete pixUp;
189 delete pixDn; 189 delete pixDn;
190} 190}
191 191
192static bool videoSliderBeingMoved = FALSE; 192static bool videoSliderBeingMoved = FALSE;
193 193
194void VideoWidget::sliderPressed() { 194void VideoWidget::sliderPressed() {
195 videoSliderBeingMoved = TRUE; 195 videoSliderBeingMoved = TRUE;
196} 196}
197 197
198void VideoWidget::sliderReleased() { 198void VideoWidget::sliderReleased() {
199 videoSliderBeingMoved = FALSE; 199 videoSliderBeingMoved = FALSE;
200 if ( slider->width() == 0 ) { 200 if ( slider->width() == 0 ) {
201 return; 201 return;
202 } 202 }
203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
204 mediaPlayerState.setPosition( val ); 204 mediaPlayerState.setPosition( val );
205} 205}
206 206
207void VideoWidget::setPosition( long i ) { 207void VideoWidget::setPosition( long i ) {
208 updateSlider( i, mediaPlayerState.length() ); 208 updateSlider( i, mediaPlayerState.length() );
209} 209}
210 210
211 211
212void VideoWidget::setLength( long max ) { 212void VideoWidget::setLength( long max ) {
213 updateSlider( mediaPlayerState.position(), max ); 213 updateSlider( mediaPlayerState.position(), max );
214} 214}
215 215
216void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 216void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
217{ 217{
218 if ( displayType == MediaPlayerState::Video ) { 218 if ( displayType == MediaPlayerState::Video ) {
219 makeVisible(); 219 makeVisible();
220 return; 220 return;
221 } 221 }
222 222
223 // Effectively blank the view next time we show it so it looks nicer 223 // Effectively blank the view next time we show it so it looks nicer
224 scaledWidth = 0; 224 scaledWidth = 0;
225 scaledHeight = 0; 225 scaledHeight = 0;
226 hide(); 226 hide();
227} 227}
228 228
229void VideoWidget::updateSlider( long i, long max ) { 229void VideoWidget::updateSlider( long i, long max ) {
230 // Will flicker too much if we don't do this 230 // Will flicker too much if we don't do this
231 if ( max == 0 ) { 231 if ( max == 0 ) {
232 return; 232 return;
233 } 233 }
234 int width = slider->width(); 234 int width = slider->width();
235 int val = int((double)i * width / max); 235 int val = int((double)i * width / max);
236 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 236 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
237 if ( slider->value() != val ) { 237 if ( slider->value() != val ) {
238 slider->setValue( val ); 238 slider->setValue( val );
239 } 239 }
240 if ( slider->maxValue() != width ) { 240 if ( slider->maxValue() != width ) {
241 slider->setMaxValue( width ); 241 slider->setMaxValue( width );
242 } 242 }
243 } 243 }
244} 244}
245 245
246void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 246void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
247 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 247 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
248 Button &button = *it; 248 Button &button = *it;
249 Command command = button.command; 249 Command command = button.command;
250 250
251 if ( event->state() == QMouseEvent::LeftButton ) { 251 if ( event->state() == QMouseEvent::LeftButton ) {
252 // The test to see if the mouse click is inside the button or not 252 // The test to see if the mouse click is inside the button or not
253 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); 253 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command );
254 254
255 if ( isOnButton && !button.isHeld ) { 255 if ( isOnButton && !button.isHeld ) {
256 button.isHeld = TRUE; 256 button.isHeld = TRUE;
257 toggleButton( button ); 257 toggleButton( button );
258 258
259 switch ( command ) { 259 switch ( command ) {
260 case VolumeUp: 260 case VolumeUp:
261 emit moreClicked(); 261 emit moreClicked();
262 return; 262 return;
263 case VolumeDown: 263 case VolumeDown:
264 emit lessClicked(); 264 emit lessClicked();
265 return; 265 return;
266 default: break; 266 default: break;
267 } 267 }
268 } else if ( !isOnButton && button.isHeld ) { 268 } else if ( !isOnButton && button.isHeld ) {
269 button.isHeld = FALSE; 269 button.isHeld = FALSE;
270 toggleButton( button ); 270 toggleButton( button );
271 } 271 }
272 } else { 272 } else {
273 273
274 if ( button.isHeld ) { 274 if ( button.isHeld ) {
275 button.isHeld = FALSE; 275 button.isHeld = FALSE;
276 if ( button.type != ToggleButton ) { 276 if ( button.type != ToggleButton ) {
277 setToggleButton( button, FALSE ); 277 setToggleButton( button, FALSE );
278 } 278 }
279 279
280 switch( command ) { 280 handleCommand( command, button.isDown );
281
282 case Play: {
283 if( mediaPlayerState.isPaused() ) {
284 setToggleButton( button, FALSE );
285 mediaPlayerState.setPaused( FALSE );
286 return;
287 } else if( !mediaPlayerState.isPaused() ) {
288 setToggleButton( button, TRUE );
289 mediaPlayerState.setPaused( TRUE );
290 return;
291 } else {
292 return;
293 }
294 }
295
296 case Stop: mediaPlayerState.setPlaying( FALSE ); return;
297 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
298 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
299 case VolumeUp: emit moreReleased(); return;
300 case VolumeDown: emit lessReleased(); return;
301 case FullScreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
302 default: break;
303 }
304 } 281 }
305 } 282 }
306 } 283 }
307} 284}
308 285
309void VideoWidget::mousePressEvent( QMouseEvent *event ) { 286void VideoWidget::mousePressEvent( QMouseEvent *event ) {
310 mouseMoveEvent( event ); 287 mouseMoveEvent( event );
311} 288}
312 289
313void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 290void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
314 if ( mediaPlayerState.isFullscreen() ) { 291 if ( mediaPlayerState.isFullscreen() ) {
315 mediaPlayerState.setFullscreen( FALSE ); 292 mediaPlayerState.setFullscreen( FALSE );
316 makeVisible(); 293 makeVisible();
317 } 294 }
318 mouseMoveEvent( event ); 295 mouseMoveEvent( event );
319} 296}
320 297
321void VideoWidget::showEvent( QShowEvent* ) { 298void VideoWidget::showEvent( QShowEvent* ) {
322 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 299 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
323 mouseMoveEvent( &event ); 300 mouseMoveEvent( &event );
324} 301}
325 302
326 303
327 void VideoWidget::backToNormal() { 304 void VideoWidget::backToNormal() {
328 mediaPlayerState.setFullscreen( FALSE ); 305 mediaPlayerState.setFullscreen( FALSE );
329 makeVisible(); 306 makeVisible();
330 } 307 }
331 308
332void VideoWidget::makeVisible() { 309void VideoWidget::makeVisible() {
333 if ( mediaPlayerState.isFullscreen() ) { 310 if ( mediaPlayerState.isFullscreen() ) {
334 setBackgroundMode( QWidget::NoBackground ); 311 setBackgroundMode( QWidget::NoBackground );
335 showFullScreen(); 312 showFullScreen();
336 resize( qApp->desktop()->size() ); 313 resize( qApp->desktop()->size() );
337 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 314 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
338 315
339 slider->hide(); 316 slider->hide();
340 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 317 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
341 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 318 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
342 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 319 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
343 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 320 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
344 321
345 } else { 322 } else {
346 showNormal(); 323 showNormal();
347 showMaximized(); 324 showMaximized();
348 setBackgroundPixmap( backgroundPixmap ); 325 setBackgroundPixmap( backgroundPixmap );
349 QWidget *d = QApplication::desktop(); 326 QWidget *d = QApplication::desktop();
350 int w = d->width(); 327 int w = d->width();
351 int h = d->height(); 328 int h = d->height();
352 329
353 if(w>h) { 330 if(w>h) {
354 int newW=(w/2)-(246/2); //this will only work with 320x240 331 int newW=(w/2)-(246/2); //this will only work with 320x240
355 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 332 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
356 } else { 333 } else {
357 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 334 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
358 } 335 }
359 336
360 if ( !mediaPlayerState.isSeekable() ) { 337 if ( !mediaPlayerState.isSeekable() ) {
361 if( !slider->isHidden()) { 338 if( !slider->isHidden()) {
362 slider->hide(); 339 slider->hide();
363 } 340 }
364 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 341 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
365 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 342 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
366 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 343 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
367 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 344 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
368 } else { 345 } else {
369 slider->show(); 346 slider->show();
370 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 347 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
371 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 348 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
372 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 349 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
373 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 350 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
374 } 351 }
375 } 352 }
376} 353}
377 354
378void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 355void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
379 switch ( e->key() ) { 356 switch ( e->key() ) {
380////////////////////////////// Zaurus keys 357////////////////////////////// Zaurus keys
381 case Key_Home: 358 case Key_Home:
382 break; 359 break;
383 case Key_F9: //activity 360 case Key_F9: //activity
384 break; 361 break;
385 case Key_F10: //contacts 362 case Key_F10: //contacts
386// hide(); 363// hide();
387 break; 364 break;
388 case Key_F11: //menu 365 case Key_F11: //menu
389 break; 366 break;
390 case Key_F12: //home 367 case Key_F12: //home
391 break; 368 break;
392 case Key_F13: //mail 369 case Key_F13: //mail
393 break; 370 break;
394 case Key_Space: { 371 case Key_Space: {
395 if(mediaPlayerState.isPlaying()) { 372 if(mediaPlayerState.isPlaying()) {
396 mediaPlayerState.setPlaying(FALSE); 373 mediaPlayerState.setPlaying(FALSE);
397 } else { 374 } else {
398 mediaPlayerState.setPlaying(TRUE); 375 mediaPlayerState.setPlaying(TRUE);
399 } 376 }
400 } 377 }
401 break; 378 break;
402 case Key_Down: 379 case Key_Down:
403// toggleButton(6); 380// toggleButton(6);
404 emit lessClicked(); 381 emit lessClicked();
405 emit lessReleased(); 382 emit lessReleased();
406// toggleButton(6); 383// toggleButton(6);
407 break; 384 break;
408 case Key_Up: 385 case Key_Up:
409// toggleButton(5); 386// toggleButton(5);
410 emit moreClicked(); 387 emit moreClicked();
411 emit moreReleased(); 388 emit moreReleased();
412// toggleButton(5); 389// toggleButton(5);
413 break; 390 break;
414 case Key_Right: 391 case Key_Right:
415 mediaPlayerState.setNext(); 392 mediaPlayerState.setNext();
416 break; 393 break;
417 case Key_Left: 394 case Key_Left:
418 mediaPlayerState.setPrev(); 395 mediaPlayerState.setPrev();
419 break; 396 break;
420 case Key_Escape: 397 case Key_Escape:
421 break; 398 break;
422 399
423 }; 400 };
424} 401}
425 402
426XineVideoWidget* VideoWidget::vidWidget() { 403XineVideoWidget* VideoWidget::vidWidget() {
427 return videoFrame; 404 return videoFrame;
428} 405}
429 406
430 407
431void VideoWidget::setFullscreen ( bool b ) { 408void VideoWidget::setFullscreen ( bool b ) {
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index c3bc131..ef88186 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,105 +1,103 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef VIDEO_WIDGET_H 34#ifndef VIDEO_WIDGET_H
35#define VIDEO_WIDGET_H 35#define VIDEO_WIDGET_H
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qimage.h> 38#include <qimage.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include "xinevideowidget.h" 40#include "xinevideowidget.h"
41 41
42#include "mediawidget.h" 42#include "mediawidget.h"
43 43
44class QPixmap; 44class QPixmap;
45class QSlider; 45class QSlider;
46 46
47class VideoWidget : public MediaWidget { 47class VideoWidget : public MediaWidget {
48 Q_OBJECT 48 Q_OBJECT
49public: 49public:
50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
51 ~VideoWidget(); 51 ~VideoWidget();
52 52
53 53
54 XineVideoWidget* vidWidget(); 54 XineVideoWidget* vidWidget();
55public slots: 55public slots:
56 void updateSlider( long, long ); 56 void updateSlider( long, long );
57 void sliderPressed( ); 57 void sliderPressed( );
58 void sliderReleased( ); 58 void sliderReleased( );
59 void setFullscreen( bool b ); 59 void setFullscreen( bool b );
60 void makeVisible(); 60 virtual void makeVisible();
61 void backToNormal(); 61 void backToNormal();
62 void setPosition( long ); 62 void setPosition( long );
63 63
64public: 64public:
65 virtual void setPlaying( bool b); 65 virtual void setPlaying( bool b);
66 virtual void setLength( long ); 66 virtual void setLength( long );
67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
68 68
69signals: 69signals:
70 void moreClicked(); 70 void moreClicked();
71 void lessClicked(); 71 void lessClicked();
72 void moreReleased();
73 void lessReleased();
74 void sliderMoved( long ); 72 void sliderMoved( long );
75 void videoResized ( const QSize &s ); 73 void videoResized ( const QSize &s );
76 74
77protected: 75protected:
78 76
79 void resizeEvent( QResizeEvent * ); 77 void resizeEvent( QResizeEvent * );
80 void showEvent( QShowEvent *se ); 78 void showEvent( QShowEvent *se );
81 void mouseMoveEvent( QMouseEvent *event ); 79 void mouseMoveEvent( QMouseEvent *event );
82 void mousePressEvent( QMouseEvent *event ); 80 void mousePressEvent( QMouseEvent *event );
83 void mouseReleaseEvent( QMouseEvent *event ); 81 void mouseReleaseEvent( QMouseEvent *event );
84 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
85 83
86private: 84private:
87// Ticker songInfo; 85// Ticker songInfo;
88 QImage imgUp; 86 QImage imgUp;
89 QImage imgDn; 87 QImage imgDn;
90 QString skin; 88 QString skin;
91 89
92 90
93 91
94 QString backgroundPix; 92 QString backgroundPix;
95 QSlider *slider; 93 QSlider *slider;
96 QImage *currentFrame; 94 QImage *currentFrame;
97 int scaledWidth; 95 int scaledWidth;
98 int scaledHeight; 96 int scaledHeight;
99 XineVideoWidget* videoFrame; 97 XineVideoWidget* videoFrame;
100}; 98};
101 99
102#endif // VIDEO_WIDGET_H 100#endif // VIDEO_WIDGET_H
103 101
104 102
105 103