-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 25 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 2 |
3 files changed, 29 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 0b9d826..9cb75ae 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,68 +1,73 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef MEDIAWIDGET_H | 20 | #ifndef MEDIAWIDGET_H |
21 | #define MEDIAWIDGET_H | 21 | #define MEDIAWIDGET_H |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | 24 | ||
25 | #include "mediaplayerstate.h" | 25 | #include "mediaplayerstate.h" |
26 | #include "playlistwidget.h" | 26 | #include "playlistwidget.h" |
27 | 27 | ||
28 | #include <vector> | ||
29 | |||
28 | class MediaWidget : public QWidget | 30 | class MediaWidget : public QWidget |
29 | { | 31 | { |
30 | Q_OBJECT | 32 | Q_OBJECT |
31 | public: | 33 | public: |
32 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; | 34 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; |
33 | 35 | ||
34 | struct Button | 36 | struct Button |
35 | { | 37 | { |
36 | // Button() : isToggle( false ), isHeld( false ), isDown( false ) {} | 38 | //Button() : isToggle( false ), isHeld( false ), isDown( false ) {} |
39 | // Button( bool toggle, bool held, bool down ) | ||
40 | // : isToggle( toggle ), isHeld( held ), isDown( down ) {} | ||
37 | 41 | ||
38 | bool isToggle : 1; | 42 | bool isToggle : 1; |
39 | bool isHeld : 1; | 43 | bool isHeld : 1; |
40 | bool isDown : 1; | 44 | bool isDown : 1; |
41 | }; | 45 | }; |
46 | typedef std::vector<Button> ButtonVector; | ||
42 | 47 | ||
43 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 48 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
44 | virtual ~MediaWidget(); | 49 | virtual ~MediaWidget(); |
45 | 50 | ||
46 | public slots: | 51 | public slots: |
47 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 52 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
48 | virtual void setLength( long length ) = 0; | 53 | virtual void setLength( long length ) = 0; |
49 | virtual void setPlaying( bool playing ) = 0; | 54 | virtual void setPlaying( bool playing ) = 0; |
50 | 55 | ||
51 | signals: | 56 | signals: |
52 | void moreReleased(); | 57 | void moreReleased(); |
53 | void lessReleased(); | 58 | void lessReleased(); |
54 | void forwardReleased(); | 59 | void forwardReleased(); |
55 | void backReleased(); | 60 | void backReleased(); |
56 | 61 | ||
57 | protected: | 62 | protected: |
58 | virtual void closeEvent( QCloseEvent * ); | 63 | virtual void closeEvent( QCloseEvent * ); |
59 | 64 | ||
60 | void handleCommand( Command command, bool buttonDown ); | 65 | void handleCommand( Command command, bool buttonDown ); |
61 | 66 | ||
62 | MediaPlayerState &mediaPlayerState; | 67 | MediaPlayerState &mediaPlayerState; |
63 | PlayListWidget &playList; | 68 | PlayListWidget &playList; |
64 | }; | 69 | }; |
65 | 70 | ||
66 | #endif // MEDIAWIDGET_H | 71 | #endif // MEDIAWIDGET_H |
67 | /* vim: et sw=4 ts=4 | 72 | /* vim: et sw=4 ts=4 |
68 | */ | 73 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 7c20c6d..efd756c 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -14,119 +14,136 @@ | |||
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 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | 38 | ||
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qpainter.h> | 40 | #include <qpainter.h> |
41 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
42 | #include <qslider.h> | 42 | #include <qslider.h> |
43 | #include <qdrawutil.h> | 43 | #include <qdrawutil.h> |
44 | #include "videowidget.h" | 44 | #include "videowidget.h" |
45 | #include "mediaplayerstate.h" | 45 | #include "mediaplayerstate.h" |
46 | #include "playlistwidget.h" | 46 | #include "playlistwidget.h" |
47 | 47 | ||
48 | 48 | ||
49 | #ifdef Q_WS_QWS | 49 | #ifdef Q_WS_QWS |
50 | # define USE_DIRECT_PAINTER | 50 | # define USE_DIRECT_PAINTER |
51 | # include <qdirectpainter_qws.h> | 51 | # include <qdirectpainter_qws.h> |
52 | # include <qgfxraster_qws.h> | 52 | # include <qgfxraster_qws.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | namespace | 56 | namespace |
57 | { | 57 | { |
58 | 58 | ||
59 | const int xo = 2; // movable x offset | 59 | const int xo = 2; // movable x offset |
60 | const int yo = 0; // movable y offset | 60 | const int yo = 0; // movable y offset |
61 | 61 | ||
62 | /* | ||
62 | MediaWidget::Button videoButtons[] = { | 63 | MediaWidget::Button videoButtons[] = { |
63 | { FALSE, FALSE, FALSE }, // stop | 64 | { FALSE, FALSE, FALSE }, // stop |
64 | { TRUE, FALSE, FALSE }, // play | 65 | { TRUE, FALSE, FALSE }, // play |
65 | { FALSE, FALSE, FALSE }, // previous | 66 | { FALSE, FALSE, FALSE }, // previous |
66 | { FALSE, FALSE, FALSE }, // next | 67 | { FALSE, FALSE, FALSE }, // next |
67 | { FALSE, FALSE, FALSE }, // volUp | 68 | { FALSE, FALSE, FALSE }, // volUp |
68 | { FALSE, FALSE, FALSE }, // volDown | 69 | { FALSE, FALSE, FALSE }, // volDown |
69 | { TRUE, FALSE, FALSE } // fullscreen | 70 | { TRUE, FALSE, FALSE } // fullscreen |
70 | }; | 71 | }; |
72 | */ | ||
71 | 73 | ||
72 | const char * const skinV_mask_file_names[7] = { | 74 | const char * const skinV_mask_file_names[7] = { |
73 | "stop","play","back","fwd","up","down","full" | 75 | "stop","play","back","fwd","up","down","full" |
74 | }; | 76 | }; |
75 | 77 | ||
76 | const int numVButtons = (sizeof(videoButtons)/sizeof(MediaWidget::Button)); | 78 | //const int numVButtons = (sizeof(videoButtons)/sizeof(MediaWidget::Button)); |
77 | 79 | ||
78 | } | 80 | } |
79 | 81 | ||
80 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 82 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
81 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) | 83 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) |
82 | { | 84 | { |
83 | setCaption( tr("OpiePlayer - Video") ); | 85 | setCaption( tr("OpiePlayer - Video") ); |
84 | 86 | ||
87 | Button defaultButton; | ||
88 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | ||
89 | Button toggleButton; | ||
90 | toggleButton.isToggle = true; | ||
91 | toggleButton.isHeld = toggleButton.isDown = false; | ||
92 | |||
93 | videoButtons.reserve( 7 ); | ||
94 | videoButtons.push_back( defaultButton ); // stop | ||
95 | videoButtons.push_back( toggleButton ); // play | ||
96 | videoButtons.push_back( defaultButton ); // previous | ||
97 | videoButtons.push_back( defaultButton ); // next | ||
98 | videoButtons.push_back( defaultButton ); // volUp | ||
99 | videoButtons.push_back( defaultButton ); // volDown | ||
100 | videoButtons.push_back( toggleButton ); //fullscreen | ||
101 | |||
85 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 102 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
86 | 103 | ||
87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 104 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
88 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 105 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
89 | 106 | ||
90 | Config cfg("OpiePlayer"); | 107 | Config cfg("OpiePlayer"); |
91 | cfg.setGroup("Options"); | 108 | cfg.setGroup("Options"); |
92 | skin = cfg.readEntry("Skin","default"); | 109 | skin = cfg.readEntry("Skin","default"); |
93 | 110 | ||
94 | QString skinPath = "opieplayer2/skins/" + skin; | 111 | QString skinPath = "opieplayer2/skins/" + skin; |
95 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 112 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
96 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 113 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
97 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 114 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
98 | 115 | ||
99 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 116 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
100 | imgButtonMask.fill( 0 ); | 117 | imgButtonMask.fill( 0 ); |
101 | 118 | ||
102 | for ( int i = 0; i < 7; i++ ) { | 119 | for ( int i = 0; i < 7; i++ ) { |
103 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 120 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
104 | masks[i] = new QBitmap( filename ); | 121 | masks[i] = new QBitmap( filename ); |
105 | 122 | ||
106 | if ( !masks[i]->isNull() ) { | 123 | if ( !masks[i]->isNull() ) { |
107 | QImage imgMask = masks[i]->convertToImage(); | 124 | QImage imgMask = masks[i]->convertToImage(); |
108 | uchar **dest = imgButtonMask.jumpTable(); | 125 | uchar **dest = imgButtonMask.jumpTable(); |
109 | for ( int y = 0; y < imgUp.height(); y++ ) { | 126 | for ( int y = 0; y < imgUp.height(); y++ ) { |
110 | uchar *line = dest[y]; | 127 | uchar *line = dest[y]; |
111 | for ( int x = 0; x < imgUp.width(); x++ ) { | 128 | for ( int x = 0; x < imgUp.width(); x++ ) { |
112 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 129 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
113 | line[x] = i + 1; | 130 | line[x] = i + 1; |
114 | } | 131 | } |
115 | } | 132 | } |
116 | } | 133 | } |
117 | } | 134 | } |
118 | 135 | ||
119 | for ( int i = 0; i < 7; i++ ) { | 136 | for ( int i = 0; i < 7; i++ ) { |
120 | buttonPixUp[i] = NULL; | 137 | buttonPixUp[i] = NULL; |
121 | buttonPixDown[i] = NULL; | 138 | buttonPixDown[i] = NULL; |
122 | } | 139 | } |
123 | 140 | ||
124 | setBackgroundPixmap( pixBg ); | 141 | setBackgroundPixmap( pixBg ); |
125 | 142 | ||
126 | slider = new QSlider( Qt::Horizontal, this ); | 143 | slider = new QSlider( Qt::Horizontal, this ); |
127 | slider->setMinValue( 0 ); | 144 | slider->setMinValue( 0 ); |
128 | slider->setMaxValue( 1 ); | 145 | slider->setMaxValue( 1 ); |
129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 146 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
130 | //slider->setFocusPolicy( QWidget::NoFocus ); | 147 | //slider->setFocusPolicy( QWidget::NoFocus ); |
131 | 148 | ||
132 | resizeEvent( NULL ); | 149 | resizeEvent( NULL ); |
@@ -231,97 +248,97 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | |||
231 | return; | 248 | return; |
232 | } | 249 | } |
233 | 250 | ||
234 | // Effectively blank the view next time we show it so it looks nicer | 251 | // Effectively blank the view next time we show it so it looks nicer |
235 | scaledWidth = 0; | 252 | scaledWidth = 0; |
236 | scaledHeight = 0; | 253 | scaledHeight = 0; |
237 | hide(); | 254 | hide(); |
238 | } | 255 | } |
239 | 256 | ||
240 | void VideoWidget::updateSlider( long i, long max ) { | 257 | void VideoWidget::updateSlider( long i, long max ) { |
241 | // Will flicker too much if we don't do this | 258 | // Will flicker too much if we don't do this |
242 | if ( max == 0 ) { | 259 | if ( max == 0 ) { |
243 | return; | 260 | return; |
244 | } | 261 | } |
245 | int width = slider->width(); | 262 | int width = slider->width(); |
246 | int val = int((double)i * width / max); | 263 | int val = int((double)i * width / max); |
247 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 264 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
248 | if ( slider->value() != val ) { | 265 | if ( slider->value() != val ) { |
249 | slider->setValue( val ); | 266 | slider->setValue( val ); |
250 | } | 267 | } |
251 | if ( slider->maxValue() != width ) { | 268 | if ( slider->maxValue() != width ) { |
252 | slider->setMaxValue( width ); | 269 | slider->setMaxValue( width ); |
253 | } | 270 | } |
254 | } | 271 | } |
255 | } | 272 | } |
256 | 273 | ||
257 | void VideoWidget::setToggleButton( int i, bool down ) { | 274 | void VideoWidget::setToggleButton( int i, bool down ) { |
258 | if ( down != videoButtons[i].isDown ) { | 275 | if ( down != videoButtons[i].isDown ) { |
259 | toggleButton( i ); | 276 | toggleButton( i ); |
260 | } | 277 | } |
261 | } | 278 | } |
262 | 279 | ||
263 | void VideoWidget::toggleButton( int i ) { | 280 | void VideoWidget::toggleButton( int i ) { |
264 | videoButtons[i].isDown = !videoButtons[i].isDown; | 281 | videoButtons[i].isDown = !videoButtons[i].isDown; |
265 | QPainter p(this); | 282 | QPainter p(this); |
266 | paintButton ( &p, i ); | 283 | paintButton ( &p, i ); |
267 | } | 284 | } |
268 | 285 | ||
269 | void VideoWidget::paintButton( QPainter *p, int i ) { | 286 | void VideoWidget::paintButton( QPainter *p, int i ) { |
270 | 287 | ||
271 | if ( videoButtons[i].isDown ) { | 288 | if ( videoButtons[i].isDown ) { |
272 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 289 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
273 | } else { | 290 | } else { |
274 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 291 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
275 | } | 292 | } |
276 | } | 293 | } |
277 | 294 | ||
278 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 295 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
279 | for ( int i = 0; i < numVButtons; i++ ) { | 296 | for ( unsigned int i = 0; i < videoButtons.size(); i++ ) { |
280 | if ( event->state() == QMouseEvent::LeftButton ) { | 297 | if ( event->state() == QMouseEvent::LeftButton ) { |
281 | // The test to see if the mouse click is inside the button or not | 298 | // The test to see if the mouse click is inside the button or not |
282 | int x = event->pos().x() - xoff; | 299 | int x = event->pos().x() - xoff; |
283 | int y = event->pos().y() - yoff; | 300 | int y = event->pos().y() - yoff; |
284 | 301 | ||
285 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 302 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
286 | && y < imgButtonMask.height() | 303 | && y < imgButtonMask.height() |
287 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 304 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
288 | 305 | ||
289 | if ( isOnButton && !videoButtons[i].isHeld ) { | 306 | if ( isOnButton && !videoButtons[i].isHeld ) { |
290 | videoButtons[i].isHeld = TRUE; | 307 | videoButtons[i].isHeld = TRUE; |
291 | toggleButton(i); | 308 | toggleButton(i); |
292 | 309 | ||
293 | switch (i) { | 310 | switch (i) { |
294 | case VideoVolUp: | 311 | case VideoVolUp: |
295 | emit moreClicked(); | 312 | emit moreClicked(); |
296 | return; | 313 | return; |
297 | case VideoVolDown: | 314 | case VideoVolDown: |
298 | emit lessClicked(); | 315 | emit lessClicked(); |
299 | return; | 316 | return; |
300 | } | 317 | } |
301 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 318 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
302 | videoButtons[i].isHeld = FALSE; | 319 | videoButtons[i].isHeld = FALSE; |
303 | toggleButton(i); | 320 | toggleButton(i); |
304 | } | 321 | } |
305 | } else { | 322 | } else { |
306 | 323 | ||
307 | if ( videoButtons[i].isHeld ) { | 324 | if ( videoButtons[i].isHeld ) { |
308 | videoButtons[i].isHeld = FALSE; | 325 | videoButtons[i].isHeld = FALSE; |
309 | if ( !videoButtons[i].isToggle ) { | 326 | if ( !videoButtons[i].isToggle ) { |
310 | setToggleButton( i, FALSE ); | 327 | setToggleButton( i, FALSE ); |
311 | } | 328 | } |
312 | 329 | ||
313 | switch(i) { | 330 | switch(i) { |
314 | 331 | ||
315 | case VideoPlay: { | 332 | case VideoPlay: { |
316 | if( mediaPlayerState.isPaused() ) { | 333 | if( mediaPlayerState.isPaused() ) { |
317 | setToggleButton( i, FALSE ); | 334 | setToggleButton( i, FALSE ); |
318 | mediaPlayerState.setPaused( FALSE ); | 335 | mediaPlayerState.setPaused( FALSE ); |
319 | return; | 336 | return; |
320 | } else if( !mediaPlayerState.isPaused() ) { | 337 | } else if( !mediaPlayerState.isPaused() ) { |
321 | setToggleButton( i, TRUE ); | 338 | setToggleButton( i, TRUE ); |
322 | mediaPlayerState.setPaused( TRUE ); | 339 | mediaPlayerState.setPaused( TRUE ); |
323 | return; | 340 | return; |
324 | } else { | 341 | } else { |
325 | return; | 342 | return; |
326 | } | 343 | } |
327 | } | 344 | } |
@@ -378,104 +395,104 @@ void VideoWidget::makeVisible() { | |||
378 | showNormal(); | 395 | showNormal(); |
379 | showMaximized(); | 396 | showMaximized(); |
380 | setBackgroundPixmap( pixBg ); | 397 | setBackgroundPixmap( pixBg ); |
381 | QWidget *d = QApplication::desktop(); | 398 | QWidget *d = QApplication::desktop(); |
382 | int w = d->width(); | 399 | int w = d->width(); |
383 | int h = d->height(); | 400 | int h = d->height(); |
384 | 401 | ||
385 | if(w>h) { | 402 | if(w>h) { |
386 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 403 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
387 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 404 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
388 | } else { | 405 | } else { |
389 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 406 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
390 | } | 407 | } |
391 | 408 | ||
392 | if ( !mediaPlayerState.isSeekable() ) { | 409 | if ( !mediaPlayerState.isSeekable() ) { |
393 | if( !slider->isHidden()) { | 410 | if( !slider->isHidden()) { |
394 | slider->hide(); | 411 | slider->hide(); |
395 | } | 412 | } |
396 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 413 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
397 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 414 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
398 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 415 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
399 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 416 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
400 | } else { | 417 | } else { |
401 | slider->show(); | 418 | slider->show(); |
402 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 419 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
403 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 420 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
404 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 421 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
405 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 422 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
406 | } | 423 | } |
407 | } | 424 | } |
408 | } | 425 | } |
409 | 426 | ||
410 | 427 | ||
411 | 428 | ||
412 | 429 | ||
413 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 430 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
414 | QPainter p( this ); | 431 | QPainter p( this ); |
415 | 432 | ||
416 | if ( mediaPlayerState.isFullscreen() ) { | 433 | if ( mediaPlayerState.isFullscreen() ) { |
417 | // Clear the background | 434 | // Clear the background |
418 | p.setBrush( QBrush( Qt::black ) ); | 435 | p.setBrush( QBrush( Qt::black ) ); |
419 | } else { | 436 | } else { |
420 | if ( !pe->erased() ) { | 437 | if ( !pe->erased() ) { |
421 | // Combine with background and double buffer | 438 | // Combine with background and double buffer |
422 | QPixmap pix( pe->rect().size() ); | 439 | QPixmap pix( pe->rect().size() ); |
423 | QPainter p( &pix ); | 440 | QPainter p( &pix ); |
424 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 441 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
425 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 442 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
426 | for ( int i = 0; i < numVButtons; i++ ) { | 443 | for ( unsigned int i = 0; i < videoButtons.size(); i++ ) { |
427 | paintButton( &p, i ); | 444 | paintButton( &p, i ); |
428 | } | 445 | } |
429 | QPainter p2( this ); | 446 | QPainter p2( this ); |
430 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 447 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
431 | } else { | 448 | } else { |
432 | QPainter p( this ); | 449 | QPainter p( this ); |
433 | for ( int i = 0; i < numVButtons; i++ ) | 450 | for ( unsigned int i = 0; i < videoButtons.size(); i++ ) |
434 | paintButton( &p, i ); | 451 | paintButton( &p, i ); |
435 | } | 452 | } |
436 | //slider->repaint( TRUE ); | 453 | //slider->repaint( TRUE ); |
437 | } | 454 | } |
438 | } | 455 | } |
439 | 456 | ||
440 | 457 | ||
441 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 458 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
442 | switch ( e->key() ) { | 459 | switch ( e->key() ) { |
443 | ////////////////////////////// Zaurus keys | 460 | ////////////////////////////// Zaurus keys |
444 | case Key_Home: | 461 | case Key_Home: |
445 | break; | 462 | break; |
446 | case Key_F9: //activity | 463 | case Key_F9: //activity |
447 | break; | 464 | break; |
448 | case Key_F10: //contacts | 465 | case Key_F10: //contacts |
449 | // hide(); | 466 | // hide(); |
450 | break; | 467 | break; |
451 | case Key_F11: //menu | 468 | case Key_F11: //menu |
452 | break; | 469 | break; |
453 | case Key_F12: //home | 470 | case Key_F12: //home |
454 | break; | 471 | break; |
455 | case Key_F13: //mail | 472 | case Key_F13: //mail |
456 | break; | 473 | break; |
457 | case Key_Space: { | 474 | case Key_Space: { |
458 | if(mediaPlayerState.isPlaying()) { | 475 | if(mediaPlayerState.isPlaying()) { |
459 | mediaPlayerState.setPlaying(FALSE); | 476 | mediaPlayerState.setPlaying(FALSE); |
460 | } else { | 477 | } else { |
461 | mediaPlayerState.setPlaying(TRUE); | 478 | mediaPlayerState.setPlaying(TRUE); |
462 | } | 479 | } |
463 | } | 480 | } |
464 | break; | 481 | break; |
465 | case Key_Down: | 482 | case Key_Down: |
466 | // toggleButton(6); | 483 | // toggleButton(6); |
467 | emit lessClicked(); | 484 | emit lessClicked(); |
468 | emit lessReleased(); | 485 | emit lessReleased(); |
469 | // toggleButton(6); | 486 | // toggleButton(6); |
470 | break; | 487 | break; |
471 | case Key_Up: | 488 | case Key_Up: |
472 | // toggleButton(5); | 489 | // toggleButton(5); |
473 | emit moreClicked(); | 490 | emit moreClicked(); |
474 | emit moreReleased(); | 491 | emit moreReleased(); |
475 | // toggleButton(5); | 492 | // toggleButton(5); |
476 | break; | 493 | break; |
477 | case Key_Right: | 494 | case Key_Right: |
478 | mediaPlayerState.setNext(); | 495 | mediaPlayerState.setNext(); |
479 | break; | 496 | break; |
480 | case Key_Left: | 497 | case Key_Left: |
481 | mediaPlayerState.setPrev(); | 498 | mediaPlayerState.setPrev(); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index f996803..34558f8 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -75,54 +75,56 @@ public slots: | |||
75 | public: | 75 | public: |
76 | virtual void setPlaying( bool b); | 76 | virtual void setPlaying( bool b); |
77 | virtual void setLength( long ); | 77 | virtual void setLength( long ); |
78 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 78 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void moreClicked(); | 81 | void moreClicked(); |
82 | void lessClicked(); | 82 | void lessClicked(); |
83 | void moreReleased(); | 83 | void moreReleased(); |
84 | void lessReleased(); | 84 | void lessReleased(); |
85 | void sliderMoved( long ); | 85 | void sliderMoved( long ); |
86 | void videoResized ( const QSize &s ); | 86 | void videoResized ( const QSize &s ); |
87 | 87 | ||
88 | protected: | 88 | protected: |
89 | 89 | ||
90 | void resizeEvent( QResizeEvent * ); | 90 | void resizeEvent( QResizeEvent * ); |
91 | void paintEvent( QPaintEvent *pe ); | 91 | void paintEvent( QPaintEvent *pe ); |
92 | void showEvent( QShowEvent *se ); | 92 | void showEvent( QShowEvent *se ); |
93 | void mouseMoveEvent( QMouseEvent *event ); | 93 | void mouseMoveEvent( QMouseEvent *event ); |
94 | void mousePressEvent( QMouseEvent *event ); | 94 | void mousePressEvent( QMouseEvent *event ); |
95 | void mouseReleaseEvent( QMouseEvent *event ); | 95 | void mouseReleaseEvent( QMouseEvent *event ); |
96 | void keyReleaseEvent( QKeyEvent *e); | 96 | void keyReleaseEvent( QKeyEvent *e); |
97 | 97 | ||
98 | private: | 98 | private: |
99 | // Ticker songInfo; | 99 | // Ticker songInfo; |
100 | QPixmap pixBg; | 100 | QPixmap pixBg; |
101 | QImage imgUp; | 101 | QImage imgUp; |
102 | QImage imgDn; | 102 | QImage imgDn; |
103 | QImage imgButtonMask; | 103 | QImage imgButtonMask; |
104 | QBitmap *masks[7]; | 104 | QBitmap *masks[7]; |
105 | QPixmap *buttonPixUp[7]; | 105 | QPixmap *buttonPixUp[7]; |
106 | QPixmap *buttonPixDown[7]; | 106 | QPixmap *buttonPixDown[7]; |
107 | QString skin; | 107 | QString skin; |
108 | // QPixmap *pixmaps[4]; | 108 | // QPixmap *pixmaps[4]; |
109 | int xoff, yoff; | 109 | int xoff, yoff; |
110 | 110 | ||
111 | 111 | ||
112 | void paintButton( QPainter *p, int i ); | 112 | void paintButton( QPainter *p, int i ); |
113 | void toggleButton( int ); | 113 | void toggleButton( int ); |
114 | void setToggleButton( int, bool ); | 114 | void setToggleButton( int, bool ); |
115 | 115 | ||
116 | QString backgroundPix; | 116 | QString backgroundPix; |
117 | QSlider *slider; | 117 | QSlider *slider; |
118 | QPixmap *pixmaps[3]; | 118 | QPixmap *pixmaps[3]; |
119 | QImage *currentFrame; | 119 | QImage *currentFrame; |
120 | int scaledWidth; | 120 | int scaledWidth; |
121 | int scaledHeight; | 121 | int scaledHeight; |
122 | XineVideoWidget* videoFrame; | 122 | XineVideoWidget* videoFrame; |
123 | |||
124 | ButtonVector videoButtons; | ||
123 | }; | 125 | }; |
124 | 126 | ||
125 | #endif // VIDEO_WIDGET_H | 127 | #endif // VIDEO_WIDGET_H |
126 | 128 | ||
127 | 129 | ||
128 | 130 | ||