summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-15 20:51:11 (UTC)
committer harlekin <harlekin>2002-08-15 20:51:11 (UTC)
commitbe99f951c39d19a6e9923103434afdb293741d35 (patch) (unidiff)
tree4fe4d6cc51eee0bbdd53c9b353624d104929f08b
parent157b5b1209b656960fc0b27fc077eb36a77b2c3f (diff)
downloadopie-be99f951c39d19a6e9923103434afdb293741d35.zip
opie-be99f951c39d19a6e9923103434afdb293741d35.tar.gz
opie-be99f951c39d19a6e9923103434afdb293741d35.tar.bz2
click in fullscreen leeds to going back to the normal videowidget now
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp37
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp68
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.h15
5 files changed, 67 insertions, 56 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 93819f2..22afe19 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,283 +1,283 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6#include <qmainwindow.h> 6#include <qmainwindow.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qwidgetstack.h> 8#include <qwidgetstack.h>
9#include <qfile.h> 9#include <qfile.h>
10 10
11#include "mediaplayer.h" 11#include "mediaplayer.h"
12#include "playlistwidget.h" 12#include "playlistwidget.h"
13#include "audiowidget.h" 13#include "audiowidget.h"
14#include "videowidget.h" 14#include "videowidget.h"
15#include "volumecontrol.h" 15#include "volumecontrol.h"
16 16
17#include "mediaplayerstate.h" 17#include "mediaplayerstate.h"
18 18
19 19
20 20
21extern AudioWidget *audioUI; 21extern AudioWidget *audioUI;
22extern VideoWidget *videoUI; 22extern VideoWidget *videoUI;
23extern PlayListWidget *playList; 23extern PlayListWidget *playList;
24extern MediaPlayerState *mediaPlayerState; 24extern MediaPlayerState *mediaPlayerState;
25 25
26 26
27MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 27MediaPlayer::MediaPlayer( QObject *parent, const char *name )
28 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 28 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
29 29
30 30
31 xineControl = new XineControl(); 31 xineControl = new XineControl();
32// QPEApplication::grabKeyboard(); // EVIL 32// QPEApplication::grabKeyboard(); // EVIL
33 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 33 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
34 34
35 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 35 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
36 36
37 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 37 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
38 38
39 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 39 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
40 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 40 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
41 41
42 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 42 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
43 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 43 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
44 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 44 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
45 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 45 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
46 46
47 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 47 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
48 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 48 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
49 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 49 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
50 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 50 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
51 51
52 volControl = new VolumeControl; 52 volControl = new VolumeControl;
53 53
54} 54}
55 55
56MediaPlayer::~MediaPlayer() { 56MediaPlayer::~MediaPlayer() {
57 delete xineControl; 57 delete xineControl;
58 delete volControl; 58 delete volControl;
59} 59}
60 60
61void MediaPlayer::pauseCheck( bool b ) { 61void MediaPlayer::pauseCheck( bool b ) {
62 if ( b && !mediaPlayerState->playing() ) { 62 if ( b && !mediaPlayerState->playing() ) {
63 mediaPlayerState->setPaused( FALSE ); 63 mediaPlayerState->setPaused( FALSE );
64 } 64 }
65} 65}
66 66
67void MediaPlayer::play() { 67void MediaPlayer::play() {
68 mediaPlayerState->setPlaying( FALSE ); 68 mediaPlayerState->setPlaying( FALSE );
69 mediaPlayerState->setPlaying( TRUE ); 69 mediaPlayerState->setPlaying( TRUE );
70} 70}
71 71
72void MediaPlayer::setPlaying( bool play ) { 72void MediaPlayer::setPlaying( bool play ) {
73 if ( !play ) { 73 if ( !play ) {
74 //mediaPlayerState->setPaused( TRUE ); 74 // mediaPlayerState->setPaused( FALSE );
75 return; 75 return;
76 } 76 }
77 77
78 if ( mediaPlayerState->paused() ) { 78 if ( mediaPlayerState->paused() ) {
79 mediaPlayerState->setPaused( FALSE ); 79 mediaPlayerState->setPaused( FALSE );
80 return; 80 return;
81 } 81 }
82 82
83 const DocLnk *playListCurrent = playList->current(); 83 const DocLnk *playListCurrent = playList->current();
84 if ( playListCurrent != NULL ) { 84 if ( playListCurrent != NULL ) {
85 currentFile = playListCurrent; 85 currentFile = playListCurrent;
86 } 86 }
87 87
88 xineControl->play( currentFile->file() ); 88 xineControl->play( currentFile->file() );
89 89
90 xineControl->length(); 90 xineControl->length();
91 long seconds = mediaPlayerState->length();// 91 long seconds = mediaPlayerState->length();//
92 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 92 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
93 qDebug(time); 93 qDebug(time);
94 94
95 QString tickerText; 95 QString tickerText;
96 if( currentFile->file().left(4) == "http" ) 96 if( currentFile->file().left(4) == "http" )
97 tickerText= tr( " File: " ) + currentFile->name(); 97 tickerText= tr( " File: " ) + currentFile->name();
98 else 98 else
99 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 99 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
100 100
101// QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); 101// QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
102 102
103// if ( !fileInfo.isEmpty() ) 103// if ( !fileInfo.isEmpty() )
104// tickerText += ", " + fileInfo; 104// tickerText += ", " + fileInfo;
105// audioUI->setTickerText( tickerText + "." ); 105// audioUI->setTickerText( tickerText + "." );
106 106
107 audioUI->setTickerText( currentFile->file( ) ); 107 audioUI->setTickerText( currentFile->file( ) );
108 108
109} 109}
110 110
111 111
112void MediaPlayer::prev() { 112void MediaPlayer::prev() {
113 if ( playList->prev() ) { 113 if ( playList->prev() ) {
114 play(); 114 play();
115 } else if ( mediaPlayerState->looping() ) { 115 } else if ( mediaPlayerState->looping() ) {
116 if ( playList->last() ) { 116 if ( playList->last() ) {
117 play(); 117 play();
118 } 118 }
119 } else { 119 } else {
120 mediaPlayerState->setList(); 120 mediaPlayerState->setList();
121 } 121 }
122} 122}
123 123
124 124
125void MediaPlayer::next() { 125void MediaPlayer::next() {
126 if ( playList->next() ) { 126 if ( playList->next() ) {
127 play(); 127 play();
128 } else if ( mediaPlayerState->looping() ) { 128 } else if ( mediaPlayerState->looping() ) {
129 if ( playList->first() ) { 129 if ( playList->first() ) {
130 play(); 130 play();
131 } 131 }
132 } else { 132 } else {
133 mediaPlayerState->setList(); 133 mediaPlayerState->setList();
134 } 134 }
135} 135}
136 136
137 137
138void MediaPlayer::startDecreasingVolume() { 138void MediaPlayer::startDecreasingVolume() {
139 volumeDirection = -1; 139 volumeDirection = -1;
140 startTimer( 100 ); 140 startTimer( 100 );
141 volControl->decVol(2); 141 volControl->decVol(2);
142} 142}
143 143
144 144
145void MediaPlayer::startIncreasingVolume() { 145void MediaPlayer::startIncreasingVolume() {
146 volumeDirection = +1; 146 volumeDirection = +1;
147 startTimer( 100 ); 147 startTimer( 100 );
148 volControl->incVol(2); 148 volControl->incVol(2);
149} 149}
150 150
151 151
152bool drawnOnScreenDisplay = FALSE; 152bool drawnOnScreenDisplay = FALSE;
153unsigned int onScreenDisplayVolume = 0; 153unsigned int onScreenDisplayVolume = 0;
154const int yoff = 110; 154const int yoff = 110;
155 155
156void MediaPlayer::stopChangingVolume() { 156void MediaPlayer::stopChangingVolume() {
157 killTimers(); 157 killTimers();
158 // Get rid of the on-screen display stuff 158 // Get rid of the on-screen display stuff
159 drawnOnScreenDisplay = FALSE; 159 drawnOnScreenDisplay = FALSE;
160 onScreenDisplayVolume = 0; 160 onScreenDisplayVolume = 0;
161 int w=0; 161 int w=0;
162 int h=0; 162 int h=0;
163 if( !xineControl->hasVideo()) { 163 if( !xineControl->hasVideo()) {
164 w = audioUI->width(); 164 w = audioUI->width();
165 h = audioUI->height(); 165 h = audioUI->height();
166 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 166 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
167 } else { 167 } else {
168 w = videoUI->width(); 168 w = videoUI->width();
169 h = videoUI->height(); 169 h = videoUI->height();
170 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 170 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
171 } 171 }
172} 172}
173 173
174 174
175void MediaPlayer::timerEvent( QTimerEvent * ) { 175void MediaPlayer::timerEvent( QTimerEvent * ) {
176 if ( volumeDirection == +1 ) { 176 if ( volumeDirection == +1 ) {
177 volControl->incVol(2); 177 volControl->incVol(2);
178 } else if ( volumeDirection == -1 ) { 178 } else if ( volumeDirection == -1 ) {
179 volControl->decVol(2); 179 volControl->decVol(2);
180 } 180 }
181 181
182 182
183 // TODO FIXME 183 // TODO FIXME
184 int v; 184 int v;
185 v = volControl->getVolume(); 185 v = volControl->getVolume();
186 v = v / 10; 186 v = v / 10;
187 187
188 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 188 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
189 return; 189 return;
190 } 190 }
191 191
192 int w=0; int h=0; 192 int w=0; int h=0;
193 if( !xineControl->hasVideo()) { 193 if( !xineControl->hasVideo()) {
194 w = audioUI->width(); 194 w = audioUI->width();
195 h = audioUI->height(); 195 h = audioUI->height();
196 196
197 if ( drawnOnScreenDisplay ) { 197 if ( drawnOnScreenDisplay ) {
198 if ( onScreenDisplayVolume > v ) { 198 if ( onScreenDisplayVolume > v ) {
199 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 199 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
200 } 200 }
201 } 201 }
202 drawnOnScreenDisplay = TRUE; 202 drawnOnScreenDisplay = TRUE;
203 onScreenDisplayVolume = v; 203 onScreenDisplayVolume = v;
204 QPainter p( audioUI ); 204 QPainter p( audioUI );
205 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 205 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
206 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 206 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
207 207
208 QFont f; 208 QFont f;
209 f.setPixelSize( 20 ); 209 f.setPixelSize( 20 );
210 f.setBold( TRUE ); 210 f.setBold( TRUE );
211 p.setFont( f ); 211 p.setFont( f );
212 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 212 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
213 213
214 for ( unsigned int i = 0; i < 10; i++ ) { 214 for ( unsigned int i = 0; i < 10; i++ ) {
215 if ( v > i ) { 215 if ( v > i ) {
216 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 216 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
217 } else { 217 } else {
218 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 218 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
219 } 219 }
220 } 220 }
221 } else { 221 } else {
222 w = videoUI->width(); 222 w = videoUI->width();
223 h = videoUI->height(); 223 h = videoUI->height();
224 224
225 if ( drawnOnScreenDisplay ) { 225 if ( drawnOnScreenDisplay ) {
226 if ( onScreenDisplayVolume > v ) { 226 if ( onScreenDisplayVolume > v ) {
227 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 227 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
228 } 228 }
229 } 229 }
230 drawnOnScreenDisplay = TRUE; 230 drawnOnScreenDisplay = TRUE;
231 onScreenDisplayVolume = v; 231 onScreenDisplayVolume = v;
232 QPainter p( videoUI ); 232 QPainter p( videoUI );
233 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 233 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
234 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 234 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
235 235
236 QFont f; 236 QFont f;
237 f.setPixelSize( 20 ); 237 f.setPixelSize( 20 );
238 f.setBold( TRUE ); 238 f.setBold( TRUE );
239 p.setFont( f ); 239 p.setFont( f );
240 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 240 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
241 241
242 for ( unsigned int i = 0; i < 10; i++ ) { 242 for ( unsigned int i = 0; i < 10; i++ ) {
243 if ( v > i ) { 243 if ( v > i ) {
244 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 244 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
245 } else { 245 } else {
246 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 246 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
247 } 247 }
248 } 248 }
249 } 249 }
250} 250}
251 251
252void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 252void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
253 switch ( e->key() ) { 253 switch ( e->key() ) {
254////////////////////////////// Zaurus keys 254////////////////////////////// Zaurus keys
255 case Key_Home: 255 case Key_Home:
256 break; 256 break;
257 case Key_F9: //activity 257 case Key_F9: //activity
258 break; 258 break;
259 case Key_F10: //contacts 259 case Key_F10: //contacts
260 break; 260 break;
261 case Key_F11: //menu 261 case Key_F11: //menu
262 break; 262 break;
263 case Key_F12: //home 263 case Key_F12: //home
264 qDebug("Blank here"); 264 qDebug("Blank here");
265 break; 265 break;
266 case Key_F13: //mail 266 case Key_F13: //mail
267 break; 267 break;
268 } 268 }
269} 269}
270 270
271void MediaPlayer::doBlank() { 271void MediaPlayer::doBlank() {
272 272
273} 273}
274 274
275void MediaPlayer::doUnblank() { 275void MediaPlayer::doUnblank() {
276 276
277} 277}
278 278
279void MediaPlayer::cleanUp() { 279void MediaPlayer::cleanUp() {
280// QPEApplication::grabKeyboard(); 280// QPEApplication::grabKeyboard();
281// QPEApplication::ungrabKeyboard(); 281// QPEApplication::ungrabKeyboard();
282 282
283} 283}
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 238770b..c2080e6 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,493 +1,500 @@
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#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/mediaplayerplugininterface.h> 35#include <qpe/mediaplayerplugininterface.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qpainter.h> 39#include <qpainter.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qslider.h> 41#include <qslider.h>
42#include <qdrawutil.h> 42#include <qdrawutil.h>
43#include "videowidget.h" 43#include "videowidget.h"
44#include "mediaplayerstate.h" 44#include "mediaplayerstate.h"
45 45
46 46
47#ifdef Q_WS_QWS 47#ifdef Q_WS_QWS
48# define USE_DIRECT_PAINTER 48# define USE_DIRECT_PAINTER
49# include <qdirectpainter_qws.h> 49# include <qdirectpainter_qws.h>
50# include <qgfxraster_qws.h> 50# include <qgfxraster_qws.h>
51#endif 51#endif
52 52
53 53
54extern MediaPlayerState *mediaPlayerState; 54extern MediaPlayerState *mediaPlayerState;
55 55
56 56
57static const int xo = 2; // movable x offset 57static const int xo = 2; // movable x offset
58static const int yo = 0; // movable y offset 58static const int yo = 0; // movable y offset
59 59
60 60
61struct MediaButton { 61struct MediaButton {
62 bool isToggle, isHeld, isDown; 62 bool isToggle, isHeld, isDown;
63}; 63};
64 64
65MediaButton videoButtons[] = { 65MediaButton videoButtons[] = {
66 { FALSE, FALSE, FALSE }, // stop 66 { FALSE, FALSE, FALSE }, // stop
67 { TRUE, FALSE, FALSE }, // play 67 { TRUE, FALSE, FALSE }, // play
68 { FALSE, FALSE, FALSE }, // previous 68 { FALSE, FALSE, FALSE }, // previous
69 { FALSE, FALSE, FALSE }, // next 69 { FALSE, FALSE, FALSE }, // next
70 { FALSE, FALSE, FALSE }, // volUp 70 { FALSE, FALSE, FALSE }, // volUp
71 { FALSE, FALSE, FALSE }, // volDown 71 { FALSE, FALSE, FALSE }, // volDown
72 { TRUE, FALSE, FALSE } // fullscreen 72 { TRUE, FALSE, FALSE } // fullscreen
73}; 73};
74 74
75const char *skinV_mask_file_names[7] = { 75const char *skinV_mask_file_names[7] = {
76"stop","play","back","fwd","up","down","full" 76"stop","play","back","fwd","up","down","full"
77}; 77};
78 78
79static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 79static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
80 80
81 81
82VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 82VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
83QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 83QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
84 setCaption( tr("OpiePlayer - Video") ); 84 setCaption( tr("OpiePlayer - Video") );
85 85
86 videoFrame = new XineVideoWidget ( this, "Video frame" ); 86 videoFrame = new XineVideoWidget ( this, "Video frame" );
87
87 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 88 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
89 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
88 90
89 Config cfg("OpiePlayer"); 91 Config cfg("OpiePlayer");
90 cfg.setGroup("Options"); 92 cfg.setGroup("Options");
91 skin = cfg.readEntry("Skin","default"); 93 skin = cfg.readEntry("Skin","default");
92 94
93 QString skinPath = "opieplayer2/skins/" + skin; 95 QString skinPath = "opieplayer2/skins/" + skin;
94 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 96 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
95 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 97 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
96 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 98 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
97 99
98 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 100 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
99 imgButtonMask->fill( 0 ); 101 imgButtonMask->fill( 0 );
100 102
101 for ( int i = 0; i < 7; i++ ) { 103 for ( int i = 0; i < 7; i++ ) {
102 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; 104 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png";
103 masks[i] = new QBitmap( filename ); 105 masks[i] = new QBitmap( filename );
104 106
105 if ( !masks[i]->isNull() ) { 107 if ( !masks[i]->isNull() ) {
106 QImage imgMask = masks[i]->convertToImage(); 108 QImage imgMask = masks[i]->convertToImage();
107 uchar **dest = imgButtonMask->jumpTable(); 109 uchar **dest = imgButtonMask->jumpTable();
108 for ( int y = 0; y < imgUp->height(); y++ ) { 110 for ( int y = 0; y < imgUp->height(); y++ ) {
109 uchar *line = dest[y]; 111 uchar *line = dest[y];
110 for ( int x = 0; x < imgUp->width(); x++ ) { 112 for ( int x = 0; x < imgUp->width(); x++ ) {
111 if ( !qRed( imgMask.pixel( x, y ) ) ) 113 if ( !qRed( imgMask.pixel( x, y ) ) )
112 line[x] = i + 1; 114 line[x] = i + 1;
113 } 115 }
114 } 116 }
115 } 117 }
116 } 118 }
117 119
118 for ( int i = 0; i < 7; i++ ) { 120 for ( int i = 0; i < 7; i++ ) {
119 buttonPixUp[i] = NULL; 121 buttonPixUp[i] = NULL;
120 buttonPixDown[i] = NULL; 122 buttonPixDown[i] = NULL;
121 } 123 }
122 124
123 setBackgroundPixmap( *pixBg ); 125 setBackgroundPixmap( *pixBg );
124 126
125 slider = new QSlider( Qt::Horizontal, this ); 127 slider = new QSlider( Qt::Horizontal, this );
126 slider->setMinValue( 0 ); 128 slider->setMinValue( 0 );
127 slider->setMaxValue( 1 ); 129 slider->setMaxValue( 1 );
128 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 130 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
129 slider->setFocusPolicy( QWidget::NoFocus ); 131 slider->setFocusPolicy( QWidget::NoFocus );
130 132
131 resizeEvent( NULL ); 133 resizeEvent( NULL );
132 134
133 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 135 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
134 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 136 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
135 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 137 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
136 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 138 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
137 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 139 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
138 140
139 setLength( mediaPlayerState->length() ); 141 setLength( mediaPlayerState->length() );
140 setPosition( mediaPlayerState->position() ); 142 setPosition( mediaPlayerState->position() );
141 setFullscreen( mediaPlayerState->fullscreen() ); 143 setFullscreen( mediaPlayerState->fullscreen() );
142// setPaused( mediaPlayerState->paused() ); 144// setPaused( mediaPlayerState->paused() );
143 setPlaying( mediaPlayerState->playing() ); 145 setPlaying( mediaPlayerState->playing() );
144} 146}
145 147
146 148
147VideoWidget::~VideoWidget() { 149VideoWidget::~VideoWidget() {
148 150
149 for ( int i = 0; i < 7; i++ ) { 151 for ( int i = 0; i < 7; i++ ) {
150 delete buttonPixUp[i]; 152 delete buttonPixUp[i];
151 delete buttonPixDown[i]; 153 delete buttonPixDown[i];
152 } 154 }
153 155
154 delete pixBg; 156 delete pixBg;
155 delete imgUp; 157 delete imgUp;
156 delete imgDn; 158 delete imgDn;
157 delete imgButtonMask; 159 delete imgButtonMask;
158 for ( int i = 0; i < 7; i++ ) { 160 for ( int i = 0; i < 7; i++ ) {
159 delete masks[i]; 161 delete masks[i];
160 } 162 }
161 163
162} 164}
163 165
164QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 166QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
165 QPixmap pix( img.width(), img.height() ); 167 QPixmap pix( img.width(), img.height() );
166 QPainter p( &pix ); 168 QPainter p( &pix );
167 p.drawTiledPixmap( pix.rect(), bg, offset ); 169 p.drawTiledPixmap( pix.rect(), bg, offset );
168 p.drawImage( 0, 0, img ); 170 p.drawImage( 0, 0, img );
169 return new QPixmap( pix ); 171 return new QPixmap( pix );
170} 172}
171 173
172QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 174QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
173 QPixmap *pixmap = new QPixmap( pix ); 175 QPixmap *pixmap = new QPixmap( pix );
174 pixmap->setMask( mask ); 176 pixmap->setMask( mask );
175 return pixmap; 177 return pixmap;
176} 178}
177 179
178void VideoWidget::resizeEvent( QResizeEvent * ) { 180void VideoWidget::resizeEvent( QResizeEvent * ) {
179 int h = height(); 181 int h = height();
180 int w = width(); 182 int w = width();
181 int Vh = 160; 183 int Vh = 160;
182 int Vw = 220; 184 int Vw = 220;
183 185
184 slider->setFixedWidth( w - 20 ); 186 slider->setFixedWidth( w - 20 );
185 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 187 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
186 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 188 slider->setBackgroundOrigin( QWidget::ParentOrigin );
187 slider->setFocusPolicy( QWidget::NoFocus ); 189 slider->setFocusPolicy( QWidget::NoFocus );
188 slider->setBackgroundPixmap( *pixBg ); 190 slider->setBackgroundPixmap( *pixBg );
189 191
190 xoff = 0;// ( imgUp->width() ) / 2; 192 xoff = 0;// ( imgUp->width() ) / 2;
191 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 193 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
192 QPoint p( xoff, yoff ); 194 QPoint p( xoff, yoff );
193 195
194 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 196 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
195 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 197 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
196 198
197 for ( int i = 0; i < 7; i++ ) { 199 for ( int i = 0; i < 7; i++ ) {
198 if ( !masks[i]->isNull() ) { 200 if ( !masks[i]->isNull() ) {
199 delete buttonPixUp[i]; 201 delete buttonPixUp[i];
200 delete buttonPixDown[i]; 202 delete buttonPixDown[i];
201 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 203 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
202 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 204 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
203 } 205 }
204 } 206 }
205 207
206 delete pixUp; 208 delete pixUp;
207 delete pixDn; 209 delete pixDn;
208} 210}
209 211
210static bool videoSliderBeingMoved = FALSE; 212static bool videoSliderBeingMoved = FALSE;
211 213
212void VideoWidget::sliderPressed() { 214void VideoWidget::sliderPressed() {
213 videoSliderBeingMoved = TRUE; 215 videoSliderBeingMoved = TRUE;
214} 216}
215 217
216void VideoWidget::sliderReleased() { 218void VideoWidget::sliderReleased() {
217 videoSliderBeingMoved = FALSE; 219 videoSliderBeingMoved = FALSE;
218 if ( slider->width() == 0 ) { 220 if ( slider->width() == 0 ) {
219 return; 221 return;
220 } 222 }
221 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 223 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
222 mediaPlayerState->setPosition( val ); 224 mediaPlayerState->setPosition( val );
223} 225}
224 226
225void VideoWidget::setPosition( long i ) { 227void VideoWidget::setPosition( long i ) {
226 updateSlider( i, mediaPlayerState->length() ); 228 updateSlider( i, mediaPlayerState->length() );
227} 229}
228 230
229 231
230void VideoWidget::setLength( long max ) { 232void VideoWidget::setLength( long max ) {
231 updateSlider( mediaPlayerState->position(), max ); 233 updateSlider( mediaPlayerState->position(), max );
232} 234}
233 235
234void VideoWidget::setView( char view ) { 236void VideoWidget::setView( char view ) {
235 237
236 if ( mediaPlayerState->streaming() ) { 238 if ( mediaPlayerState->streaming() ) {
237 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 239 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
238 if( !slider->isHidden()) { 240 if( !slider->isHidden()) {
239 slider->hide(); 241 slider->hide();
240 } 242 }
241 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 243 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
242 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 244 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
243 } else { 245 } else {
244 // this stops the slider from being moved, thus 246 // this stops the slider from being moved, thus
245 // does not stop stream when it reaches the end 247 // does not stop stream when it reaches the end
246 slider->show(); 248 slider->show();
247 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 249 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
248 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 250 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
249 } 251 }
250 252
251 if ( view == 'v' ) { 253 if ( view == 'v' ) {
252 makeVisible(); 254 makeVisible();
253 } else { 255 } else {
254 // Effectively blank the view next time we show it so it looks nicer 256 // Effectively blank the view next time we show it so it looks nicer
255 scaledWidth = 0; 257 scaledWidth = 0;
256 scaledHeight = 0; 258 scaledHeight = 0;
257 hide(); 259 hide();
258 } 260 }
259} 261}
260 262
261void VideoWidget::updateSlider( long i, long max ) { 263void VideoWidget::updateSlider( long i, long max ) {
262 // Will flicker too much if we don't do this 264 // Will flicker too much if we don't do this
263 if ( max == 0 ) { 265 if ( max == 0 ) {
264 return; 266 return;
265 } 267 }
266 int width = slider->width(); 268 int width = slider->width();
267 int val = int((double)i * width / max); 269 int val = int((double)i * width / max);
268 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 270 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
269 if ( slider->value() != val ) { 271 if ( slider->value() != val ) {
270 slider->setValue( val ); 272 slider->setValue( val );
271 } 273 }
272 if ( slider->maxValue() != width ) { 274 if ( slider->maxValue() != width ) {
273 slider->setMaxValue( width ); 275 slider->setMaxValue( width );
274 } 276 }
275 } 277 }
276} 278}
277 279
278void VideoWidget::setToggleButton( int i, bool down ) { 280void VideoWidget::setToggleButton( int i, bool down ) {
279 if ( down != videoButtons[i].isDown ) { 281 if ( down != videoButtons[i].isDown ) {
280 toggleButton( i ); 282 toggleButton( i );
281 } 283 }
282} 284}
283 285
284void VideoWidget::toggleButton( int i ) { 286void VideoWidget::toggleButton( int i ) {
285 videoButtons[i].isDown = !videoButtons[i].isDown; 287 videoButtons[i].isDown = !videoButtons[i].isDown;
286 QPainter p(this); 288 QPainter p(this);
287 paintButton ( &p, i ); 289 paintButton ( &p, i );
288} 290}
289 291
290void VideoWidget::paintButton( QPainter *p, int i ) { 292void VideoWidget::paintButton( QPainter *p, int i ) {
291 293
292 if ( videoButtons[i].isDown ) { 294 if ( videoButtons[i].isDown ) {
293 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 295 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
294 } else { 296 } else {
295 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 297 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
296 } 298 }
297} 299}
298 300
299void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 301void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
300 for ( int i = 0; i < numVButtons; i++ ) { 302 for ( int i = 0; i < numVButtons; i++ ) {
301 if ( event->state() == QMouseEvent::LeftButton ) { 303 if ( event->state() == QMouseEvent::LeftButton ) {
302 // The test to see if the mouse click is inside the button or not 304 // The test to see if the mouse click is inside the button or not
303 int x = event->pos().x() - xoff; 305 int x = event->pos().x() - xoff;
304 int y = event->pos().y() - yoff; 306 int y = event->pos().y() - yoff;
305 307
306 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 308 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
307 && y < imgButtonMask->height() 309 && y < imgButtonMask->height()
308 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 310 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
309 311
310 if ( isOnButton && !videoButtons[i].isHeld ) { 312 if ( isOnButton && !videoButtons[i].isHeld ) {
311 videoButtons[i].isHeld = TRUE; 313 videoButtons[i].isHeld = TRUE;
312 toggleButton(i); 314 toggleButton(i);
313 315
314 switch (i) { 316 switch (i) {
315 case VideoVolUp: 317 case VideoVolUp:
316 emit moreClicked(); 318 emit moreClicked();
317 return; 319 return;
318 case VideoVolDown: 320 case VideoVolDown:
319 emit lessClicked(); 321 emit lessClicked();
320 return; 322 return;
321 } 323 }
322 } else if ( !isOnButton && videoButtons[i].isHeld ) { 324 } else if ( !isOnButton && videoButtons[i].isHeld ) {
323 videoButtons[i].isHeld = FALSE; 325 videoButtons[i].isHeld = FALSE;
324 toggleButton(i); 326 toggleButton(i);
325 } 327 }
326 } else { 328 } else {
327 329
328 if ( videoButtons[i].isHeld ) { 330 if ( videoButtons[i].isHeld ) {
329 videoButtons[i].isHeld = FALSE; 331 videoButtons[i].isHeld = FALSE;
330 if ( !videoButtons[i].isToggle ) { 332 if ( !videoButtons[i].isToggle ) {
331 setToggleButton( i, FALSE ); 333 setToggleButton( i, FALSE );
332 } 334 }
333 335
334 switch(i) { 336 switch(i) {
335 337
336 case VideoPlay: { 338 case VideoPlay: {
337 if( mediaPlayerState->isPaused ) { 339 if( mediaPlayerState->isPaused ) {
338 setToggleButton( i, FALSE ); 340 setToggleButton( i, FALSE );
339 mediaPlayerState->setPaused( FALSE ); 341 mediaPlayerState->setPaused( FALSE );
340 return; 342 return;
341 } else if( !mediaPlayerState->isPaused ) { 343 } else if( !mediaPlayerState->isPaused ) {
342 setToggleButton( i, TRUE ); 344 setToggleButton( i, TRUE );
343 mediaPlayerState->setPaused( TRUE ); 345 mediaPlayerState->setPaused( TRUE );
344 return; 346 return;
345 } else { 347 } else {
346 // setToggleButton( i, TRUE ); 348 return;
347 // mediaPlayerState->setPlaying( videoButtons[i].isDown );
348 } 349 }
349 } 350 }
350 351
351 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 352 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
352 case VideoNext: mediaPlayerState->setNext(); return; 353 case VideoNext: mediaPlayerState->setNext(); return;
353 case VideoPrevious: mediaPlayerState->setPrev(); return; 354 case VideoPrevious: mediaPlayerState->setPrev(); return;
354 case VideoVolUp: emit moreReleased(); return; 355 case VideoVolUp: emit moreReleased(); return;
355 case VideoVolDown: emit lessReleased(); return; 356 case VideoVolDown: emit lessReleased(); return;
356 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 357 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
357 } 358 }
358 } 359 }
359 } 360 }
360 } 361 }
361} 362}
362 363
363void VideoWidget::mousePressEvent( QMouseEvent *event ) { 364void VideoWidget::mousePressEvent( QMouseEvent *event ) {
364 mouseMoveEvent( event ); 365 mouseMoveEvent( event );
365} 366}
366 367
367void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 368void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
368 if ( mediaPlayerState->fullscreen() ) { 369 if ( mediaPlayerState->fullscreen() ) {
369 mediaPlayerState->setFullscreen( FALSE ); 370 mediaPlayerState->setFullscreen( FALSE );
370 makeVisible(); 371 makeVisible();
371 } 372 }
372 mouseMoveEvent( event ); 373 mouseMoveEvent( event );
373} 374}
374 375
375void VideoWidget::showEvent( QShowEvent* ) { 376void VideoWidget::showEvent( QShowEvent* ) {
376 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 377 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
377 mouseMoveEvent( &event ); 378 mouseMoveEvent( &event );
378} 379}
379 380
380 381
382 void VideoWidget::backToNormal() {
383 mediaPlayerState->setFullscreen( FALSE );
384 makeVisible();
385 }
386
381void VideoWidget::makeVisible() { 387void VideoWidget::makeVisible() {
382 if ( mediaPlayerState->fullscreen() ) { 388 if ( mediaPlayerState->fullscreen() ) {
383 setBackgroundMode( QWidget::NoBackground ); 389 setBackgroundMode( QWidget::NoBackground );
384 showFullScreen(); 390 showFullScreen();
385 resize( qApp->desktop()->size() ); 391 resize( qApp->desktop()->size() );
386 slider->hide(); 392 slider->hide();
387 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 393 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
388 } else { 394
389 showNormal(); 395 } else {
390 showMaximized(); 396 showNormal();
391 slider->show(); 397 showMaximized();
392 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); 398 slider->show();
393 qApp->processEvents(); 399 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
394 } 400 qApp->processEvents();
401 }
395} 402}
396 403
397 404
398void VideoWidget::paintEvent( QPaintEvent * pe) { 405void VideoWidget::paintEvent( QPaintEvent * pe) {
399 QPainter p( this ); 406 QPainter p( this );
400 407
401 if ( mediaPlayerState->fullscreen() ) { 408 if ( mediaPlayerState->fullscreen() ) {
402 // Clear the background 409 // Clear the background
403 p.setBrush( QBrush( Qt::black ) ); 410 p.setBrush( QBrush( Qt::black ) );
404 } else { 411 } else {
405 if ( !pe->erased() ) { 412 if ( !pe->erased() ) {
406 // Combine with background and double buffer 413 // Combine with background and double buffer
407 QPixmap pix( pe->rect().size() ); 414 QPixmap pix( pe->rect().size() );
408 QPainter p( &pix ); 415 QPainter p( &pix );
409 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 416 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
410 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 417 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
411 for ( int i = 0; i < numVButtons; i++ ) { 418 for ( int i = 0; i < numVButtons; i++ ) {
412 paintButton( &p, i ); 419 paintButton( &p, i );
413 } 420 }
414 QPainter p2( this ); 421 QPainter p2( this );
415 p2.drawPixmap( pe->rect().topLeft(), pix ); 422 p2.drawPixmap( pe->rect().topLeft(), pix );
416 } else { 423 } else {
417 QPainter p( this ); 424 QPainter p( this );
418 for ( int i = 0; i < numVButtons; i++ ) 425 for ( int i = 0; i < numVButtons; i++ )
419 paintButton( &p, i ); 426 paintButton( &p, i );
420 } 427 }
421 slider->repaint( TRUE ); 428 slider->repaint( TRUE );
422 } 429 }
423} 430}
424 431
425 432
426void VideoWidget::closeEvent( QCloseEvent* ) { 433void VideoWidget::closeEvent( QCloseEvent* ) {
427 mediaPlayerState->setList(); 434 mediaPlayerState->setList();
428} 435}
429 436
430 437
431 438
432void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 439void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
433 switch ( e->key() ) { 440 switch ( e->key() ) {
434////////////////////////////// Zaurus keys 441////////////////////////////// Zaurus keys
435 case Key_Home: 442 case Key_Home:
436 break; 443 break;
437 case Key_F9: //activity 444 case Key_F9: //activity
438 break; 445 break;
439 case Key_F10: //contacts 446 case Key_F10: //contacts
440// hide(); 447// hide();
441 break; 448 break;
442 case Key_F11: //menu 449 case Key_F11: //menu
443 break; 450 break;
444 case Key_F12: //home 451 case Key_F12: //home
445 break; 452 break;
446 case Key_F13: //mail 453 case Key_F13: //mail
447 break; 454 break;
448 case Key_Space: { 455 case Key_Space: {
449 if(mediaPlayerState->playing()) { 456 if(mediaPlayerState->playing()) {
450 mediaPlayerState->setPlaying(FALSE); 457 mediaPlayerState->setPlaying(FALSE);
451 } else { 458 } else {
452 mediaPlayerState->setPlaying(TRUE); 459 mediaPlayerState->setPlaying(TRUE);
453 } 460 }
454 } 461 }
455 break; 462 break;
456 case Key_Down: 463 case Key_Down:
457// toggleButton(6); 464// toggleButton(6);
458 emit lessClicked(); 465 emit lessClicked();
459 emit lessReleased(); 466 emit lessReleased();
460// toggleButton(6); 467// toggleButton(6);
461 break; 468 break;
462 case Key_Up: 469 case Key_Up:
463// toggleButton(5); 470// toggleButton(5);
464 emit moreClicked(); 471 emit moreClicked();
465 emit moreReleased(); 472 emit moreReleased();
466// toggleButton(5); 473// toggleButton(5);
467 break; 474 break;
468 case Key_Right: 475 case Key_Right:
469 mediaPlayerState->setNext(); 476 mediaPlayerState->setNext();
470 break; 477 break;
471 case Key_Left: 478 case Key_Left:
472 mediaPlayerState->setPrev(); 479 mediaPlayerState->setPrev();
473 break; 480 break;
474 case Key_Escape: 481 case Key_Escape:
475 break; 482 break;
476 483
477 }; 484 };
478} 485}
479 486
480XineVideoWidget* VideoWidget::vidWidget() { 487XineVideoWidget* VideoWidget::vidWidget() {
481 return videoFrame; 488 return videoFrame;
482} 489}
483 490
484 491
485void VideoWidget::setFullscreen ( bool b ) { 492void VideoWidget::setFullscreen ( bool b ) {
486 setToggleButton( VideoFullscreen, b ); 493 setToggleButton( VideoFullscreen, b );
487} 494}
488 495
489 496
490void VideoWidget::setPlaying( bool b) { 497void VideoWidget::setPlaying( bool b) {
491 setToggleButton( VideoPlay, b ); 498 setToggleButton( VideoPlay, b );
492} 499}
493 500
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index b35558b..990fa5f 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,122 +1,123 @@
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 "xinevideowidget.h" 38#include "xinevideowidget.h"
39 39
40class QPixmap; 40class QPixmap;
41class QSlider; 41class QSlider;
42 42
43enum VideoButtons { 43enum VideoButtons {
44 VideoStop = 0, 44 VideoStop = 0,
45 VideoPlay, 45 VideoPlay,
46// VideoPause, 46// VideoPause,
47 VideoPrevious, 47 VideoPrevious,
48 VideoNext, 48 VideoNext,
49 VideoVolUp, 49 VideoVolUp,
50 VideoVolDown, 50 VideoVolDown,
51 VideoFullscreen 51 VideoFullscreen
52}; 52};
53 53
54class VideoWidget : public QWidget { 54class VideoWidget : public QWidget {
55 Q_OBJECT 55 Q_OBJECT
56public: 56public:
57 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 57 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
58 ~VideoWidget(); 58 ~VideoWidget();
59 59
60 60
61 XineVideoWidget* vidWidget(); 61 XineVideoWidget* vidWidget();
62public slots: 62public slots:
63 void updateSlider( long, long ); 63 void updateSlider( long, long );
64 void sliderPressed( ); 64 void sliderPressed( );
65 void sliderReleased( ); 65 void sliderReleased( );
66 void setPlaying( bool b); 66 void setPlaying( bool b);
67 void setFullscreen( bool b ); 67 void setFullscreen( bool b );
68 void makeVisible(); 68 void makeVisible();
69 void backToNormal();
69 void setPosition( long ); 70 void setPosition( long );
70 void setLength( long ); 71 void setLength( long );
71 void setView( char ); 72 void setView( char );
72 73
73signals: 74signals:
74 void moreClicked(); 75 void moreClicked();
75 void lessClicked(); 76 void lessClicked();
76 void moreReleased(); 77 void moreReleased();
77 void lessReleased(); 78 void lessReleased();
78 void sliderMoved( long ); 79 void sliderMoved( long );
79 void videoResized ( const QSize &s ); 80 void videoResized ( const QSize &s );
80 81
81protected: 82protected:
82 83
83 void resizeEvent( QResizeEvent * ); 84 void resizeEvent( QResizeEvent * );
84 void paintEvent( QPaintEvent *pe ); 85 void paintEvent( QPaintEvent *pe );
85 void showEvent( QShowEvent *se ); 86 void showEvent( QShowEvent *se );
86 void mouseMoveEvent( QMouseEvent *event ); 87 void mouseMoveEvent( QMouseEvent *event );
87 void mousePressEvent( QMouseEvent *event ); 88 void mousePressEvent( QMouseEvent *event );
88 void mouseReleaseEvent( QMouseEvent *event ); 89 void mouseReleaseEvent( QMouseEvent *event );
89 void closeEvent( QCloseEvent *event ); 90 void closeEvent( QCloseEvent *event );
90 void keyReleaseEvent( QKeyEvent *e); 91 void keyReleaseEvent( QKeyEvent *e);
91 92
92private: 93private:
93// Ticker songInfo; 94// Ticker songInfo;
94 QPixmap *pixBg; 95 QPixmap *pixBg;
95 QImage *imgUp; 96 QImage *imgUp;
96 QImage *imgDn; 97 QImage *imgDn;
97 QImage *imgButtonMask; 98 QImage *imgButtonMask;
98 QBitmap *masks[7]; 99 QBitmap *masks[7];
99 QPixmap *buttonPixUp[7]; 100 QPixmap *buttonPixUp[7];
100 QPixmap *buttonPixDown[7]; 101 QPixmap *buttonPixDown[7];
101 QString skin; 102 QString skin;
102// QPixmap *pixmaps[4]; 103// QPixmap *pixmaps[4];
103 int xoff, yoff; 104 int xoff, yoff;
104 105
105 106
106 void paintButton( QPainter *p, int i ); 107 void paintButton( QPainter *p, int i );
107 void toggleButton( int ); 108 void toggleButton( int );
108 void setToggleButton( int, bool ); 109 void setToggleButton( int, bool );
109 110
110 QString backgroundPix; 111 QString backgroundPix;
111 QSlider *slider; 112 QSlider *slider;
112 QPixmap *pixmaps[3]; 113 QPixmap *pixmaps[3];
113 QImage *currentFrame; 114 QImage *currentFrame;
114 int scaledWidth; 115 int scaledWidth;
115 int scaledHeight; 116 int scaledHeight;
116 XineVideoWidget* videoFrame; 117 XineVideoWidget* videoFrame;
117}; 118};
118 119
119#endif // VIDEO_WIDGET_H 120#endif // VIDEO_WIDGET_H
120 121
121 122
122 123
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index d65006b..3e28e54 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -1,268 +1,270 @@
1 1
2/* 2/*
3                This file is part of the Opie Project 3                This file is part of the Opie Project
4 4
5              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 5              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
6 Copyright (c) 2002 LJP <> 6 Copyright (c) 2002 LJP <>
7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
8 =. 8 =.
9 .=l. 9 .=l.
10           .>+-= 10           .>+-=
11 _;:,     .>    :=|. This program is free software; you can 11 _;:,     .>    :=|. This program is free software; you can
12.> <`_,   >  .   <= redistribute it and/or modify it under 12.> <`_,   >  .   <= redistribute it and/or modify it under
13:`=1 )Y*s>-.--   : the terms of the GNU General Public 13:`=1 )Y*s>-.--   : the terms of the GNU General Public
14.="- .-=="i,     .._ License as published by the Free Software 14.="- .-=="i,     .._ License as published by the Free Software
15 - .   .-<_>     .<> Foundation; either version 2 of the License, 15 - .   .-<_>     .<> Foundation; either version 2 of the License,
16     ._= =}       : or (at your option) any later version. 16     ._= =}       : or (at your option) any later version.
17    .%`+i>       _;_. 17    .%`+i>       _;_.
18    .i_,=:_.      -<s. This program is distributed in the hope that 18    .i_,=:_.      -<s. This program is distributed in the hope that
19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
20    : ..    .:,     . . . without even the implied warranty of 20    : ..    .:,     . . . without even the implied warranty of
21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
23..}^=.=       =       ; Library General Public License for more 23..}^=.=       =       ; Library General Public License for more
24++=   -.     .`     .: details. 24++=   -.     .`     .: details.
25 :     =  ...= . :.=- 25 :     =  ...= . :.=-
26 -.   .:....=;==+<; You should have received a copy of the GNU 26 -.   .:....=;==+<; You should have received a copy of the GNU
27  -_. . .   )=.  = Library General Public License along with 27  -_. . .   )=.  = Library General Public License along with
28    --        :-=` this library; see the file COPYING.LIB. 28    --        :-=` this library; see the file COPYING.LIB.
29 If not, write to the Free Software Foundation, 29 If not, write to the Free Software Foundation,
30 Inc., 59 Temple Place - Suite 330, 30 Inc., 59 Temple Place - Suite 330,
31 Boston, MA 02111-1307, USA. 31 Boston, MA 02111-1307, USA.
32 32
33*/ 33*/
34 34
35#include <qimage.h> 35#include <qimage.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qgfx_qws.h> 37#include <qgfx_qws.h>
38#include <qdirectpainter_qws.h> 38#include <qdirectpainter_qws.h>
39#include <qgfx_qws.h> 39#include <qgfx_qws.h>
40#include <qsize.h> 40#include <qsize.h>
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qpainter.h> 42#include <qpainter.h>
43 43
44#include <qpe/resource.h> 44#include <qpe/resource.h>
45 45
46#include "xinevideowidget.h" 46#include "xinevideowidget.h"
47 47
48 48
49static inline void memcpy_rev ( void *dst, void *src, size_t len ) 49static inline void memcpy_rev ( void *dst, void *src, size_t len )
50{ 50{
51 ((char *) src ) += len; 51 ((char *) src ) += len;
52 52
53 len >>= 1; 53 len >>= 1;
54 while ( len-- ) 54 while ( len-- )
55 *((short int *) dst )++ = *--((short int *) src ); 55 *((short int *) dst )++ = *--((short int *) src );
56} 56}
57 57
58static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) 58static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
59{ 59{
60 len >>= 1; 60 len >>= 1;
61 while ( len-- ) { 61 while ( len-- ) {
62 *((short int *) dst )++ = *((short int *) src ); 62 *((short int *) dst )++ = *((short int *) src );
63 ((char *) src ) += step; 63 ((char *) src ) += step;
64 } 64 }
65} 65}
66 66
67static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) 67static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step )
68{ 68{
69 len >>= 1; 69 len >>= 1;
70 70
71 ((char *) src ) += ( len * step ); 71 ((char *) src ) += ( len * step );
72 72
73 while ( len-- ) { 73 while ( len-- ) {
74 ((char *) src ) -= step; 74 ((char *) src ) -= step;
75 *((short int *) dst )++ = *((short int *) src ); 75 *((short int *) dst )++ = *((short int *) src );
76 } 76 }
77} 77}
78 78
79 79
80XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) 80XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name )
81 : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) 81 : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase )
82{ 82{
83 setBackgroundMode ( NoBackground ); 83 setBackgroundMode ( NoBackground );
84 84
85 m_image = 0; 85 m_image = 0;
86 m_buff = 0; 86 m_buff = 0;
87 m_bytes_per_line_fb = qt_screen-> linestep ( ); 87 m_bytes_per_line_fb = qt_screen-> linestep ( );
88 m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; 88 m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8;
89 m_rotation = 0; 89 m_rotation = 0;
90} 90}
91 91
92 92
93XineVideoWidget::~XineVideoWidget ( ) 93XineVideoWidget::~XineVideoWidget ( )
94{ 94{
95 delete m_image; 95 delete m_image;
96} 96}
97 97
98void XineVideoWidget::clear ( ) 98void XineVideoWidget::clear ( )
99{ 99{
100 m_buff = 0; 100 m_buff = 0;
101 repaint ( false ); 101 repaint ( false );
102} 102}
103 103
104void XineVideoWidget::paintEvent ( QPaintEvent * ) 104void XineVideoWidget::paintEvent ( QPaintEvent * )
105{ 105{
106 //qWarning( "painting <<<" ); 106 //qWarning( "painting <<<" );
107 if ( m_buff == 0 ) { 107 if ( m_buff == 0 ) {
108 QPainter p ( this ); 108 QPainter p ( this );
109 p. fillRect ( rect ( ), black ); 109 p. fillRect ( rect ( ), black );
110 if ( m_image ) 110 if ( m_image )
111 p. drawImage ( 0, 0, *m_image ); 111 p. drawImage ( 0, 0, *m_image );
112 //qWarning ( "logo\n" ); 112 //qWarning ( "logo\n" );
113 } 113 }
114 else { 114 else {
115// qWarning ( "paintevent\n" ); 115// qWarning ( "paintevent\n" );
116 116
117 QArray <QRect> qt_bug_workaround_clip_rects; 117 QArray <QRect> qt_bug_workaround_clip_rects;
118 118
119 { 119 {
120 QDirectPainter dp ( this ); 120 QDirectPainter dp ( this );
121 121
122 int rot = dp. transformOrientation ( ) + m_rotation; 122 int rot = dp. transformOrientation ( ) + m_rotation;
123 123
124 uchar *fb = dp. frameBuffer ( ); 124 uchar *fb = dp. frameBuffer ( );
125 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; 125 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame;
126 126
127 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 127 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
128 128
129 qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); 129 qt_bug_workaround_clip_rects. resize ( dp. numRects ( ));
130 130
131 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { 131 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) {
132 const QRect &clip = dp. rect ( i ); 132 const QRect &clip = dp. rect ( i );
133 133
134 qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 134 qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
135 135
136 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); 136 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb );
137 uchar *src = frame; 137 uchar *src = frame;
138 138
139 switch ( rot ) { 139 switch ( rot ) {
140 case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; 140 case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break;
141 case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; 141 case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break;
142 case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; 142 case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break;
143 case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; 143 case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break;
144 } 144 }
145 145
146 uint leftfill = 0; 146 uint leftfill = 0;
147 uint framefill = 0; 147 uint framefill = 0;
148 uint rightfill = 0; 148 uint rightfill = 0;
149 uint clipwidth = clip. width ( ) * m_bytes_per_pixel; 149 uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
150 150
151 if ( clip. left ( ) < framerect. left ( )) 151 if ( clip. left ( ) < framerect. left ( ))
152 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; 152 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
153 if ( clip. right ( ) > framerect. right ( )) 153 if ( clip. right ( ) > framerect. right ( ))
154 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; 154 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
155 155
156 framefill = clipwidth - ( leftfill + rightfill ); 156 framefill = clipwidth - ( leftfill + rightfill );
157 157
158 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { 158 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
159 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { 159 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
160 memset ( dst, 0, clipwidth ); 160 memset ( dst, 0, clipwidth );
161 } 161 }
162 else { 162 else {
163 if ( leftfill ) 163 if ( leftfill )
164 memset ( dst, 0, leftfill ); 164 memset ( dst, 0, leftfill );
165 165
166 if ( framefill ) { 166 if ( framefill ) {
167 switch ( rot ) { 167 switch ( rot ) {
168 case 0: memcpy ( dst + leftfill, src, framefill ); break; 168 case 0: memcpy ( dst + leftfill, src, framefill ); break;
169 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; 169 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
170 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; 170 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break;
171 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; 171 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
172 } 172 }
173 } 173 }
174 if ( rightfill ) 174 if ( rightfill )
175 memset ( dst + leftfill + framefill, 0, rightfill ); 175 memset ( dst + leftfill + framefill, 0, rightfill );
176 } 176 }
177 177
178 dst += m_bytes_per_line_fb; 178 dst += m_bytes_per_line_fb;
179 179
180 switch ( rot ) { 180 switch ( rot ) {
181 case 0: src += m_bytes_per_line_frame; break; 181 case 0: src += m_bytes_per_line_frame; break;
182 case 1: src -= m_bytes_per_pixel; break; 182 case 1: src -= m_bytes_per_pixel; break;
183 case 2: src -= m_bytes_per_line_frame; break; 183 case 2: src -= m_bytes_per_line_frame; break;
184 case 3: src += m_bytes_per_pixel; break; 184 case 3: src += m_bytes_per_pixel; break;
185 } 185 }
186 } 186 }
187 } 187 }
188 } 188 }
189 //qWarning ( " ||| painting |||" ); 189 //qWarning ( " ||| painting |||" );
190 { 190 {
191 // QVFB hack by MArtin Jones 191 // QVFB hack by MArtin Jones
192 QPainter p ( this ); 192 QPainter p ( this );
193 193
194 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { 194 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) {
195 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); 195 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) );
196 } 196 }
197 } 197 }
198 } 198 }
199 //qWarning( "painting >>>" ); 199 //qWarning( "painting >>>" );
200} 200}
201 201
202 202
203void XineVideoWidget::setImage ( QImage* image ) 203void XineVideoWidget::setImage ( QImage* image )
204{ 204{
205 delete m_image; 205 delete m_image;
206 m_image = image; 206 m_image = image;
207} 207}
208 208
209void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) 209void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl )
210{ 210{
211 bool rot90 = (( -m_rotation ) & 1 ); 211 bool rot90 = (( -m_rotation ) & 1 );
212 212
213 if ( rot90 ) { 213 if ( rot90 ) {
214 int d = w; 214 int d = w;
215 w = h; 215 w = h;
216 h = d; 216 h = d;
217 } 217 }
218 218
219 m_lastframe = m_thisframe; 219 m_lastframe = m_thisframe;
220 m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); 220 m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h );
221 221
222// qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); 222// qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h );
223 223
224 m_buff = img; 224 m_buff = img;
225 m_bytes_per_line_frame = bpl; 225 m_bytes_per_line_frame = bpl;
226 226
227 repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); 227 repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false );
228} 228}
229 229
230void XineVideoWidget::resizeEvent ( QResizeEvent * ) 230void XineVideoWidget::resizeEvent ( QResizeEvent * )
231{ 231{
232 QSize s = size ( ); 232 QSize s = size ( );
233 bool fs = ( s == qApp-> desktop ( )-> size ( )); 233 bool fs = ( s == qApp-> desktop ( )-> size ( ));
234 234
235 m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; 235 m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0;
236 236
237 if ( fs && qt_screen-> isTransformed ( )) { 237 if ( fs && qt_screen-> isTransformed ( )) {
238 s = qt_screen-> mapToDevice ( s ); 238 s = qt_screen-> mapToDevice ( s );
239 } 239 }
240 240
241// qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); 241// qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation );
242 242
243 emit videoResized ( s ); 243 emit videoResized ( s );
244} 244}
245 245
246 246
247void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) 247void XineVideoWidget::mousePressEvent ( QMouseEvent *me )
248{ 248{
249 QWidget *p = parentWidget ( ); 249 QWidget *p = parentWidget ( );
250 250
251 if ( p ) { 251 if ( p ) {
252 QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); 252 // QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( ));
253 253
254 QApplication::sendEvent ( p, &pme ); 254 // QApplication::sendEvent ( p, &pme );
255 // emit clicked();
255 } 256 }
256} 257}
257 258
258void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) 259void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me )
259{ 260{
260 QWidget *p = parentWidget ( ); 261 QWidget *p = parentWidget ( );
261 262
262 if ( p ) { 263 if ( p ) {
263 QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); 264 // QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( ));
264 265
265 QApplication::sendEvent ( p, &pme ); 266 // QApplication::sendEvent ( p, &pme );
267 emit clicked();
266 } 268 }
267} 269}
268 270
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h
index 2fc627d..c5101da 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.h
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.h
@@ -1,72 +1,73 @@
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 LJP <> 5 Copyright (c) 2002 LJP <>
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 34
35 35
36#include <qwidget.h> 36#include <qwidget.h>
37 37
38#include "lib.h" 38#include "lib.h"
39 39
40class QImage; 40class QImage;
41class XineVideoWidget : public QWidget { 41class XineVideoWidget : public QWidget {
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 XineVideoWidget( QWidget* parent, const char* name ); 44 XineVideoWidget( QWidget* parent, const char* name );
45 ~XineVideoWidget(); 45 ~XineVideoWidget();
46 QImage *image() { return m_image; }; 46 QImage *image() { return m_image; };
47 void setImage( QImage* image ); 47 void setImage( QImage* image );
48 void setImage( uchar* image, int width, int height, int linestep); 48 void setImage( uchar* image, int width, int height, int linestep);
49 void clear() ; 49 void clear() ;
50 50
51protected: 51protected:
52 void paintEvent( QPaintEvent* p ); 52 void paintEvent( QPaintEvent* p );
53 void resizeEvent ( QResizeEvent *r ); 53 void resizeEvent ( QResizeEvent *r );
54 54
55 void mousePressEvent ( QMouseEvent *e ); 55 void mousePressEvent ( QMouseEvent *e );
56 void mouseReleaseEvent ( QMouseEvent *e ); 56 void mouseReleaseEvent ( QMouseEvent *e );
57 57
58signals: 58signals:
59 void videoResized ( const QSize &s ); 59 void clicked();
60 60 void videoResized ( const QSize &s );
61
61private: 62private:
62 QRect m_lastframe; 63 QRect m_lastframe;
63 QRect m_thisframe; 64 QRect m_thisframe;
64 65
65 uchar* m_buff; 66 uchar* m_buff;
66 int m_bytes_per_line_fb; 67 int m_bytes_per_line_fb;
67 int m_bytes_per_line_frame; 68 int m_bytes_per_line_frame;
68 int m_bytes_per_pixel; 69 int m_bytes_per_pixel;
69 QImage* m_image; 70 QImage* m_image;
70 int m_rotation; 71 int m_rotation;
71}; 72};
72 73