summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 19:29:34 (UTC)
committer simon <simon>2002-12-02 19:29:34 (UTC)
commitaf73e44e57b1095f92b6f6bcd530c2e4b626a664 (patch) (unidiff)
treef4178ea80b26bec9955e4c529d3b0c92301b08a8
parent24081d2efe5860c9656716b04af00e5ab85d1cd3 (diff)
downloadopie-af73e44e57b1095f92b6f6bcd530c2e4b626a664.zip
opie-af73e44e57b1095f92b6f6bcd530c2e4b626a664.tar.gz
opie-af73e44e57b1095f92b6f6bcd530c2e4b626a664.tar.bz2
- completed MediaPlayer::DisplayType transition
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp27
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h2
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp10
5 files changed, 12 insertions, 35 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 74ab2e3..68bbae9 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,354 +1,354 @@
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#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6#include <qfileinfo.h> 6#include <qfileinfo.h>
7 7
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include <qwidgetstack.h> 10#include <qwidgetstack.h>
11#include <qfile.h> 11#include <qfile.h>
12 12
13#include "mediaplayer.h" 13#include "mediaplayer.h"
14#include "playlistwidget.h" 14#include "playlistwidget.h"
15#include "audiowidget.h" 15#include "audiowidget.h"
16#include "videowidget.h" 16#include "videowidget.h"
17#include "volumecontrol.h" 17#include "volumecontrol.h"
18 18
19#include "mediaplayerstate.h" 19#include "mediaplayerstate.h"
20 20
21// for setBacklight() 21// for setBacklight()
22#include <linux/fb.h> 22#include <linux/fb.h>
23#include <sys/file.h> 23#include <sys/file.h>
24#include <sys/ioctl.h> 24#include <sys/ioctl.h>
25 25
26 26
27extern AudioWidget *audioUI; 27extern AudioWidget *audioUI;
28extern VideoWidget *videoUI; 28extern VideoWidget *videoUI;
29extern PlayListWidget *playList; 29extern PlayListWidget *playList;
30extern MediaPlayerState *mediaPlayerState; 30extern MediaPlayerState *mediaPlayerState;
31 31
32 32
33#define FBIOBLANK 0x4611 33#define FBIOBLANK 0x4611
34 34
35MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 35MediaPlayer::MediaPlayer( QObject *parent, const char *name )
36 : QObject( parent, name ), volumeDirection( 0 ) { 36 : QObject( parent, name ), volumeDirection( 0 ) {
37 37
38 fd=-1;fl=-1; 38 fd=-1;fl=-1;
39 playList->setCaption( tr( "OpiePlayer: Initializating" ) ); 39 playList->setCaption( tr( "OpiePlayer: Initializating" ) );
40 40
41 qApp->processEvents(); 41 qApp->processEvents();
42 // QPEApplication::grabKeyboard(); // EVIL 42 // QPEApplication::grabKeyboard(); // EVIL
43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
44 44
45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
46 46
47 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 47 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
48 48
49 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 49 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
50 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 50 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
51 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
52 52
53 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 53 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
54 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 54 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
55 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 55 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
56 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 56 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
57 57
58 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 58 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
59 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 59 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
60 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 60 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
61 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 61 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
62 62
63 volControl = new VolumeControl; 63 volControl = new VolumeControl;
64 xineControl = new XineControl(); 64 xineControl = new XineControl();
65 Config cfg( "OpiePlayer" ); 65 Config cfg( "OpiePlayer" );
66 cfg.setGroup("PlayList"); 66 cfg.setGroup("PlayList");
67 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 67 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
68 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 68 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
69} 69}
70 70
71MediaPlayer::~MediaPlayer() { 71MediaPlayer::~MediaPlayer() {
72 delete xineControl; 72 delete xineControl;
73 delete volControl; 73 delete volControl;
74} 74}
75 75
76void MediaPlayer::pauseCheck( bool b ) { 76void MediaPlayer::pauseCheck( bool b ) {
77 if ( b && !mediaPlayerState->isPlaying() ) { 77 if ( b && !mediaPlayerState->isPlaying() ) {
78 mediaPlayerState->setPaused( FALSE ); 78 mediaPlayerState->setPaused( FALSE );
79 } 79 }
80} 80}
81 81
82void MediaPlayer::play() { 82void MediaPlayer::play() {
83 mediaPlayerState->setPlaying( FALSE ); 83 mediaPlayerState->setPlaying( FALSE );
84 mediaPlayerState->setPlaying( TRUE ); 84 mediaPlayerState->setPlaying( TRUE );
85} 85}
86 86
87void MediaPlayer::setPlaying( bool play ) { 87void MediaPlayer::setPlaying( bool play ) {
88 if ( !play ) { 88 if ( !play ) {
89 return; 89 return;
90 } 90 }
91 91
92 if ( mediaPlayerState->isPaused() ) { 92 if ( mediaPlayerState->isPaused() ) {
93 mediaPlayerState->setPaused( FALSE ); 93 mediaPlayerState->setPaused( FALSE );
94 return; 94 return;
95 } 95 }
96 96
97 QString tickerText, time, fileName; 97 QString tickerText, time, fileName;
98 if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { 98 if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) {
99 //if playing in file list.. play in a different way 99 //if playing in file list.. play in a different way
100 // random and looping settings enabled causes problems here, 100 // random and looping settings enabled causes problems here,
101 // since there is no selected file in the playlist, but a selected file in the file list, 101 // since there is no selected file in the playlist, but a selected file in the file list,
102 // so we remember and shutoff 102 // so we remember and shutoff
103 l = mediaPlayerState->isLooping(); 103 l = mediaPlayerState->isLooping();
104 if(l) { 104 if(l) {
105 mediaPlayerState->setLooping( false ); 105 mediaPlayerState->setLooping( false );
106 } 106 }
107 r = mediaPlayerState->isShuffled(); 107 r = mediaPlayerState->isShuffled();
108 mediaPlayerState->setShuffled( false ); 108 mediaPlayerState->setShuffled( false );
109 } 109 }
110 110
111 PlayListWidget::Entry playListEntry = playList->currentEntry(); 111 PlayListWidget::Entry playListEntry = playList->currentEntry();
112 fileName = playListEntry.name; 112 fileName = playListEntry.name;
113 xineControl->play( playListEntry.file ); 113 xineControl->play( playListEntry.file );
114 114
115 long seconds = mediaPlayerState->length(); 115 long seconds = mediaPlayerState->length();
116 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 116 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
117 117
118 if( fileName.left(4) == "http" ) { 118 if( fileName.left(4) == "http" ) {
119 fileName = QFileInfo( fileName ).baseName(); 119 fileName = QFileInfo( fileName ).baseName();
120 if ( xineControl->getMetaInfo().isEmpty() ) { 120 if ( xineControl->getMetaInfo().isEmpty() ) {
121 tickerText = tr( " File: " ) + fileName; 121 tickerText = tr( " File: " ) + fileName;
122 } else { 122 } else {
123 tickerText = xineControl->getMetaInfo(); 123 tickerText = xineControl->getMetaInfo();
124 } 124 }
125 } else { 125 } else {
126 if ( xineControl->getMetaInfo().isEmpty() ) { 126 if ( xineControl->getMetaInfo().isEmpty() ) {
127 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 127 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
128 } else { 128 } else {
129 tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; 129 tickerText = xineControl->getMetaInfo() + " Length: " + time + " ";
130 } 130 }
131 } 131 }
132 audioUI->setTickerText( tickerText ); 132 audioUI->setTickerText( tickerText );
133} 133}
134 134
135 135
136void MediaPlayer::prev() { 136void MediaPlayer::prev() {
137 if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 137 if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
138 if ( playList->prev() ) { 138 if ( playList->prev() ) {
139 play(); 139 play();
140 } else if ( mediaPlayerState->isLooping() ) { 140 } else if ( mediaPlayerState->isLooping() ) {
141 if ( playList->last() ) { 141 if ( playList->last() ) {
142 play(); 142 play();
143 } 143 }
144 } else { 144 } else {
145 mediaPlayerState->setList(); 145 mediaPlayerState->setList();
146 } 146 }
147 } 147 }
148} 148}
149 149
150 150
151void MediaPlayer::next() { 151void MediaPlayer::next() {
152 152
153 if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 153 if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
154 if ( playList->next() ) { 154 if ( playList->next() ) {
155 play(); 155 play();
156 } else if ( mediaPlayerState->isLooping() ) { 156 } else if ( mediaPlayerState->isLooping() ) {
157 if ( playList->first() ) { 157 if ( playList->first() ) {
158 play(); 158 play();
159 } 159 }
160 } else { 160 } else {
161 mediaPlayerState->setList(); 161 mediaPlayerState->setList();
162 } 162 }
163 } else { //if playing from file list, let's just stop 163 } else { //if playing from file list, let's just stop
164 qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); 164 qDebug("<<<<<<<<<<<<<<<<<stop for filelists");
165 mediaPlayerState->setPlaying(false); 165 mediaPlayerState->setPlaying(false);
166 mediaPlayerState->setView('l'); 166 mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection );
167 if(l) mediaPlayerState->setLooping(l); 167 if(l) mediaPlayerState->setLooping(l);
168 if(r) mediaPlayerState->setShuffled(r); 168 if(r) mediaPlayerState->setShuffled(r);
169 } 169 }
170 qApp->processEvents(); 170 qApp->processEvents();
171} 171}
172 172
173 173
174void MediaPlayer::startDecreasingVolume() { 174void MediaPlayer::startDecreasingVolume() {
175 volumeDirection = -1; 175 volumeDirection = -1;
176 startTimer( 100 ); 176 startTimer( 100 );
177 volControl->decVol(2); 177 volControl->decVol(2);
178} 178}
179 179
180 180
181void MediaPlayer::startIncreasingVolume() { 181void MediaPlayer::startIncreasingVolume() {
182 volumeDirection = +1; 182 volumeDirection = +1;
183 startTimer( 100 ); 183 startTimer( 100 );
184 volControl->incVol(2); 184 volControl->incVol(2);
185} 185}
186 186
187 187
188bool drawnOnScreenDisplay = FALSE; 188bool drawnOnScreenDisplay = FALSE;
189unsigned int onScreenDisplayVolume = 0; 189unsigned int onScreenDisplayVolume = 0;
190const int yoff = 110; 190const int yoff = 110;
191 191
192void MediaPlayer::stopChangingVolume() { 192void MediaPlayer::stopChangingVolume() {
193 killTimers(); 193 killTimers();
194 // Get rid of the on-screen display stuff 194 // Get rid of the on-screen display stuff
195 drawnOnScreenDisplay = FALSE; 195 drawnOnScreenDisplay = FALSE;
196 onScreenDisplayVolume = 0; 196 onScreenDisplayVolume = 0;
197 int w=0; 197 int w=0;
198 int h=0; 198 int h=0;
199 if( !xineControl->hasVideo() ) { 199 if( !xineControl->hasVideo() ) {
200 w = audioUI->width(); 200 w = audioUI->width();
201 h = audioUI->height(); 201 h = audioUI->height();
202 audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 202 audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
203 } else { 203 } else {
204 w = videoUI->width(); 204 w = videoUI->width();
205 h = videoUI->height(); 205 h = videoUI->height();
206 videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 206 videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
207 } 207 }
208} 208}
209 209
210 210
211void MediaPlayer::timerEvent( QTimerEvent * ) { 211void MediaPlayer::timerEvent( QTimerEvent * ) {
212 if ( volumeDirection == +1 ) { 212 if ( volumeDirection == +1 ) {
213 volControl->incVol( 2 ); 213 volControl->incVol( 2 );
214 } else if ( volumeDirection == -1 ) { 214 } else if ( volumeDirection == -1 ) {
215 volControl->decVol( 2 ); 215 volControl->decVol( 2 );
216 } 216 }
217 217
218 218
219 // TODO FIXME 219 // TODO FIXME
220 // huh?? 220 // huh??
221 unsigned int v= 0; 221 unsigned int v= 0;
222 v = volControl->volume(); 222 v = volControl->volume();
223 v = v / 10; 223 v = v / 10;
224 224
225 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 225 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
226 return; 226 return;
227 } 227 }
228 228
229 int w=0; int h=0; 229 int w=0; int h=0;
230 if( !xineControl->hasVideo() ) { 230 if( !xineControl->hasVideo() ) {
231 w = audioUI->width(); 231 w = audioUI->width();
232 h = audioUI->height(); 232 h = audioUI->height();
233 233
234 if ( drawnOnScreenDisplay ) { 234 if ( drawnOnScreenDisplay ) {
235 if ( onScreenDisplayVolume > v ) { 235 if ( onScreenDisplayVolume > v ) {
236 audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 236 audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
237 } 237 }
238 } 238 }
239 drawnOnScreenDisplay = TRUE; 239 drawnOnScreenDisplay = TRUE;
240 onScreenDisplayVolume = v; 240 onScreenDisplayVolume = v;
241 QPainter p( audioUI ); 241 QPainter p( audioUI );
242 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 242 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
243 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 243 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
244 244
245 QFont f; 245 QFont f;
246 f.setPixelSize( 20 ); 246 f.setPixelSize( 20 );
247 f.setBold( TRUE ); 247 f.setBold( TRUE );
248 p.setFont( f ); 248 p.setFont( f );
249 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 249 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
250 250
251 for ( unsigned int i = 0; i < 10; i++ ) { 251 for ( unsigned int i = 0; i < 10; i++ ) {
252 if ( v > i ) { 252 if ( v > i ) {
253 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 253 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
254 } else { 254 } else {
255 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 255 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
256 } 256 }
257 } 257 }
258 } else { 258 } else {
259 w = videoUI->width(); 259 w = videoUI->width();
260 h = videoUI->height(); 260 h = videoUI->height();
261 261
262 if ( drawnOnScreenDisplay ) { 262 if ( drawnOnScreenDisplay ) {
263 if ( onScreenDisplayVolume > v ) { 263 if ( onScreenDisplayVolume > v ) {
264 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 264 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
265 } 265 }
266 } 266 }
267 drawnOnScreenDisplay = TRUE; 267 drawnOnScreenDisplay = TRUE;
268 onScreenDisplayVolume = v; 268 onScreenDisplayVolume = v;
269 QPainter p( videoUI ); 269 QPainter p( videoUI );
270 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 270 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
271 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 271 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
272 272
273 QFont f; 273 QFont f;
274 f.setPixelSize( 20 ); 274 f.setPixelSize( 20 );
275 f.setBold( TRUE ); 275 f.setBold( TRUE );
276 p.setFont( f ); 276 p.setFont( f );
277 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 277 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
278 278
279 for ( unsigned int i = 0; i < 10; i++ ) { 279 for ( unsigned int i = 0; i < 10; i++ ) {
280 if ( v > i ) { 280 if ( v > i ) {
281 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 281 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
282 } else { 282 } else {
283 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 283 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
284 } 284 }
285 } 285 }
286 } 286 }
287} 287}
288 288
289 289
290void MediaPlayer::blank( bool b ) { 290void MediaPlayer::blank( bool b ) {
291 fd=open("/dev/fb0",O_RDWR); 291 fd=open("/dev/fb0",O_RDWR);
292#ifdef QT_QWS_EBX 292#ifdef QT_QWS_EBX
293 fl= open( "/dev/fl", O_RDWR ); 293 fl= open( "/dev/fl", O_RDWR );
294#endif 294#endif
295 if (fd != -1) { 295 if (fd != -1) {
296 if ( b ) { 296 if ( b ) {
297 qDebug("do blanking"); 297 qDebug("do blanking");
298#ifdef QT_QWS_EBX 298#ifdef QT_QWS_EBX
299 ioctl( fd, FBIOBLANK, 1 ); 299 ioctl( fd, FBIOBLANK, 1 );
300 if(fl !=-1) { 300 if(fl !=-1) {
301 ioctl( fl, 2 ); 301 ioctl( fl, 2 );
302 ::close(fl); 302 ::close(fl);
303 } 303 }
304#else 304#else
305 ioctl( fd, FBIOBLANK, 3 ); 305 ioctl( fd, FBIOBLANK, 3 );
306#endif 306#endif
307 isBlanked = TRUE; 307 isBlanked = TRUE;
308 } else { 308 } else {
309 qDebug("do unblanking"); 309 qDebug("do unblanking");
310 ioctl( fd, FBIOBLANK, 0); 310 ioctl( fd, FBIOBLANK, 0);
311#ifdef QT_QWS_EBX 311#ifdef QT_QWS_EBX
312 if(fl != -1) { 312 if(fl != -1) {
313 ioctl( fl, 1); 313 ioctl( fl, 1);
314 ::close(fl); 314 ::close(fl);
315 } 315 }
316#endif 316#endif
317 isBlanked = FALSE; 317 isBlanked = FALSE;
318 } 318 }
319 close( fd ); 319 close( fd );
320 } else { 320 } else {
321 qDebug("<< /dev/fb0 could not be opened >>"); 321 qDebug("<< /dev/fb0 could not be opened >>");
322 } 322 }
323} 323}
324 324
325void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 325void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
326 switch ( e->key() ) { 326 switch ( e->key() ) {
327////////////////////////////// Zaurus keys 327////////////////////////////// Zaurus keys
328 case Key_Home: 328 case Key_Home:
329 break; 329 break;
330 case Key_F9: //activity 330 case Key_F9: //activity
331 break; 331 break;
332 case Key_F10: //contacts 332 case Key_F10: //contacts
333 break; 333 break;
334 case Key_F11: //menu 334 case Key_F11: //menu
335 break; 335 break;
336 case Key_F12: //home 336 case Key_F12: //home
337 qDebug("Blank here"); 337 qDebug("Blank here");
338// mediaPlayerState->toggleBlank(); 338// mediaPlayerState->toggleBlank();
339 break; 339 break;
340 case Key_F13: //mail 340 case Key_F13: //mail
341 qDebug("Blank here"); 341 qDebug("Blank here");
342 // mediaPlayerState->toggleBlank(); 342 // mediaPlayerState->toggleBlank();
343 break; 343 break;
344 } 344 }
345} 345}
346 346
347void MediaPlayer::cleanUp() {// this happens on closing 347void MediaPlayer::cleanUp() {// this happens on closing
348 Config cfg( "OpiePlayer" ); 348 Config cfg( "OpiePlayer" );
349 mediaPlayerState->writeConfig( cfg ); 349 mediaPlayerState->writeConfig( cfg );
350 playList->writeDefaultPlaylist( ); 350 playList->writeDefaultPlaylist( );
351 351
352// QPEApplication::grabKeyboard(); 352// QPEApplication::grabKeyboard();
353// QPEApplication::ungrabKeyboard(); 353// QPEApplication::ungrabKeyboard();
354} 354}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 901b43f..40fa1a4 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,285 +1,264 @@
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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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// this file is based on work by trolltech 34// this file is based on work by trolltech
35 35
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37#include <qpe/qlibrary.h> 37#include <qpe/qlibrary.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <qvaluelist.h> 39#include <qvaluelist.h>
40#include <qobject.h> 40#include <qobject.h>
41#include <qdir.h> 41#include <qdir.h>
42#include "mediaplayerstate.h" 42#include "mediaplayerstate.h"
43 43
44#include <assert.h> 44#include <assert.h>
45 45
46//#define MediaPlayerDebug(x) qDebug x 46//#define MediaPlayerDebug(x) qDebug x
47#define MediaPlayerDebug(x) 47#define MediaPlayerDebug(x)
48 48
49 49
50MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 50MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
51 : QObject( parent, name ) { 51 : QObject( parent, name ) {
52 Config cfg( "OpiePlayer" ); 52 Config cfg( "OpiePlayer" );
53 readConfig( cfg ); 53 readConfig( cfg );
54 streaming = false; 54 streaming = false;
55 seekable = true; 55 seekable = true;
56} 56}
57 57
58 58
59MediaPlayerState::~MediaPlayerState() { 59MediaPlayerState::~MediaPlayerState() {
60} 60}
61 61
62 62
63void MediaPlayerState::readConfig( Config& cfg ) { 63void MediaPlayerState::readConfig( Config& cfg ) {
64 cfg.setGroup("Options"); 64 cfg.setGroup("Options");
65 fullscreen = cfg.readBoolEntry( "FullScreen" ); 65 fullscreen = cfg.readBoolEntry( "FullScreen" );
66 scaled = cfg.readBoolEntry( "Scaling" ); 66 scaled = cfg.readBoolEntry( "Scaling" );
67 looping = cfg.readBoolEntry( "Looping" ); 67 looping = cfg.readBoolEntry( "Looping" );
68 shuffled = cfg.readBoolEntry( "Shuffle" ); 68 shuffled = cfg.readBoolEntry( "Shuffle" );
69 videoGamma = cfg.readNumEntry( "VideoGamma" ); 69 videoGamma = cfg.readNumEntry( "VideoGamma" );
70 playing = FALSE; 70 playing = FALSE;
71 streaming = FALSE; 71 streaming = FALSE;
72 paused = FALSE; 72 paused = FALSE;
73 curPosition = 0; 73 curPosition = 0;
74 curLength = 0; 74 curLength = 0;
75 m_displayType = MediaSelection; 75 m_displayType = MediaSelection;
76} 76}
77 77
78 78
79void MediaPlayerState::writeConfig( Config& cfg ) const { 79void MediaPlayerState::writeConfig( Config& cfg ) const {
80 cfg.setGroup( "Options" ); 80 cfg.setGroup( "Options" );
81 cfg.writeEntry( "FullScreen", fullscreen ); 81 cfg.writeEntry( "FullScreen", fullscreen );
82 cfg.writeEntry( "Scaling", scaled ); 82 cfg.writeEntry( "Scaling", scaled );
83 cfg.writeEntry( "Looping", looping ); 83 cfg.writeEntry( "Looping", looping );
84 cfg.writeEntry( "Shuffle", shuffled ); 84 cfg.writeEntry( "Shuffle", shuffled );
85 cfg.writeEntry( "VideoGamma", videoGamma ); 85 cfg.writeEntry( "VideoGamma", videoGamma );
86} 86}
87 87
88char MediaPlayerState::view() const
89{
90 switch ( m_displayType ) {
91 case Audio: return 'a';
92 case Video: return 'v';
93 case MediaSelection: return 'l';
94 default: assert( false );
95 }
96 // never reached
97 return 42;
98}
99
100MediaPlayerState::DisplayType MediaPlayerState::displayType() const 88MediaPlayerState::DisplayType MediaPlayerState::displayType() const
101{ 89{
102 return m_displayType; 90 return m_displayType;
103} 91}
104 92
105// slots 93// slots
106void MediaPlayerState::setIsStreaming( bool b ) { 94void MediaPlayerState::setIsStreaming( bool b ) {
107 streaming = b; 95 streaming = b;
108} 96}
109 97
110void MediaPlayerState::setIsSeekable( bool b ) { 98void MediaPlayerState::setIsSeekable( bool b ) {
111 seekable = b; 99 seekable = b;
112 emit isSeekableToggled(b); 100 emit isSeekableToggled(b);
113} 101}
114 102
115 103
116void MediaPlayerState::setFullscreen( bool b ) { 104void MediaPlayerState::setFullscreen( bool b ) {
117 if ( fullscreen == b ) { 105 if ( fullscreen == b ) {
118 return; 106 return;
119 } 107 }
120 fullscreen = b; 108 fullscreen = b;
121 emit fullscreenToggled(b); 109 emit fullscreenToggled(b);
122} 110}
123 111
124 112
125void MediaPlayerState::setBlanked( bool b ) { 113void MediaPlayerState::setBlanked( bool b ) {
126 if ( blanked == b ) { 114 if ( blanked == b ) {
127 return; 115 return;
128 } 116 }
129 blanked = b; 117 blanked = b;
130 emit blankToggled(b); 118 emit blankToggled(b);
131} 119}
132 120
133 121
134void MediaPlayerState::setScaled( bool b ) { 122void MediaPlayerState::setScaled( bool b ) {
135 if ( scaled == b ) { 123 if ( scaled == b ) {
136 return; 124 return;
137 } 125 }
138 scaled = b; 126 scaled = b;
139 emit scaledToggled(b); 127 emit scaledToggled(b);
140} 128}
141 129
142void MediaPlayerState::setLooping( bool b ) { 130void MediaPlayerState::setLooping( bool b ) {
143 if ( looping == b ) { 131 if ( looping == b ) {
144 return; 132 return;
145 } 133 }
146 looping = b; 134 looping = b;
147 emit loopingToggled(b); 135 emit loopingToggled(b);
148} 136}
149 137
150void MediaPlayerState::setShuffled( bool b ) { 138void MediaPlayerState::setShuffled( bool b ) {
151 if ( shuffled == b ) { 139 if ( shuffled == b ) {
152 return; 140 return;
153 } 141 }
154 shuffled = b; 142 shuffled = b;
155 emit shuffledToggled(b); 143 emit shuffledToggled(b);
156} 144}
157 145
158void MediaPlayerState::setPaused( bool b ) { 146void MediaPlayerState::setPaused( bool b ) {
159 if ( paused == b ) { 147 if ( paused == b ) {
160 paused = FALSE; 148 paused = FALSE;
161 emit pausedToggled(FALSE); 149 emit pausedToggled(FALSE);
162 return; 150 return;
163 } 151 }
164 paused = b; 152 paused = b;
165 emit pausedToggled(b); 153 emit pausedToggled(b);
166} 154}
167 155
168void MediaPlayerState::setPlaying( bool b ) { 156void MediaPlayerState::setPlaying( bool b ) {
169 if ( playing == b ) { 157 if ( playing == b ) {
170 return; 158 return;
171 } 159 }
172 playing = b; 160 playing = b;
173 stopped = !b; 161 stopped = !b;
174 emit playingToggled(b); 162 emit playingToggled(b);
175} 163}
176 164
177void MediaPlayerState::setStopped( bool b ) { 165void MediaPlayerState::setStopped( bool b ) {
178 if ( stopped == b ) { 166 if ( stopped == b ) {
179 return; 167 return;
180 } 168 }
181 stopped = b; 169 stopped = b;
182 emit stopToggled(b); 170 emit stopToggled(b);
183} 171}
184 172
185void MediaPlayerState::setPosition( long p ) { 173void MediaPlayerState::setPosition( long p ) {
186 if ( curPosition == p ) { 174 if ( curPosition == p ) {
187 return; 175 return;
188 } 176 }
189 curPosition = p; 177 curPosition = p;
190 emit positionChanged(p); 178 emit positionChanged(p);
191} 179}
192 180
193void MediaPlayerState::updatePosition( long p ){ 181void MediaPlayerState::updatePosition( long p ){
194 if ( curPosition == p ) { 182 if ( curPosition == p ) {
195 return; 183 return;
196 } 184 }
197 curPosition = p; 185 curPosition = p;
198 emit positionUpdated(p); 186 emit positionUpdated(p);
199} 187}
200 188
201void MediaPlayerState::setVideoGamma( int v ){ 189void MediaPlayerState::setVideoGamma( int v ){
202 if ( videoGamma == v ) { 190 if ( videoGamma == v ) {
203 return; 191 return;
204 } 192 }
205 videoGamma = v; 193 videoGamma = v;
206 emit videoGammaChanged( v ); 194 emit videoGammaChanged( v );
207} 195}
208 196
209void MediaPlayerState::setLength( long l ) { 197void MediaPlayerState::setLength( long l ) {
210 if ( curLength == l ) { 198 if ( curLength == l ) {
211 return; 199 return;
212 } 200 }
213 curLength = l; 201 curLength = l;
214 emit lengthChanged(l); 202 emit lengthChanged(l);
215} 203}
216 204
217void MediaPlayerState::setView( char v ) {
218 switch ( v ) {
219 case 'a': setDisplayType( Audio ); return;
220 case 'v': setDisplayType( Video ); return;
221 case 'l': setDisplayType( MediaSelection ); return;
222 default: assert( false );
223 }
224}
225
226void MediaPlayerState::setDisplayType( DisplayType displayType ) 205void MediaPlayerState::setDisplayType( DisplayType displayType )
227{ 206{
228 if ( m_displayType == displayType ) 207 if ( m_displayType == displayType )
229 return; 208 return;
230 209
231 m_displayType = displayType; 210 m_displayType = displayType;
232 emit displayTypeChanged( m_displayType ); 211 emit displayTypeChanged( m_displayType );
233} 212}
234 213
235void MediaPlayerState::setPrev(){ 214void MediaPlayerState::setPrev(){
236 emit prev(); 215 emit prev();
237} 216}
238 217
239void MediaPlayerState::setNext() { 218void MediaPlayerState::setNext() {
240 emit next(); 219 emit next();
241} 220}
242 221
243void MediaPlayerState::setList() { 222void MediaPlayerState::setList() {
244 setPlaying( FALSE ); 223 setPlaying( FALSE );
245 setView('l'); 224 setDisplayType( MediaSelection );
246} 225}
247 226
248void MediaPlayerState::setVideo() { 227void MediaPlayerState::setVideo() {
249 setView('v'); 228 setDisplayType( Video );
250} 229}
251 230
252void MediaPlayerState::setAudio() { 231void MediaPlayerState::setAudio() {
253 setView('a'); 232 setDisplayType( Audio );
254} 233}
255 234
256void MediaPlayerState::toggleFullscreen() { 235void MediaPlayerState::toggleFullscreen() {
257 setFullscreen( !fullscreen ); 236 setFullscreen( !fullscreen );
258} 237}
259 238
260void MediaPlayerState::toggleScaled() { 239void MediaPlayerState::toggleScaled() {
261 setScaled( !scaled); 240 setScaled( !scaled);
262} 241}
263 242
264void MediaPlayerState::toggleLooping() { 243void MediaPlayerState::toggleLooping() {
265 setLooping( !looping); 244 setLooping( !looping);
266} 245}
267 246
268void MediaPlayerState::toggleShuffled() { 247void MediaPlayerState::toggleShuffled() {
269 setShuffled( !shuffled); 248 setShuffled( !shuffled);
270} 249}
271 250
272void MediaPlayerState::togglePaused() { 251void MediaPlayerState::togglePaused() {
273 setPaused( !paused); 252 setPaused( !paused);
274} 253}
275 254
276void MediaPlayerState::togglePlaying() { 255void MediaPlayerState::togglePlaying() {
277 setPlaying( !playing); 256 setPlaying( !playing);
278} 257}
279 258
280void MediaPlayerState::toggleBlank() { 259void MediaPlayerState::toggleBlank() {
281 setBlanked( !blanked); 260 setBlanked( !blanked);
282} 261}
283 262
284 263
285 264
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index b18780b..c887bb8 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,143 +1,141 @@
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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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// this file is based on work by trolltech 34// this file is based on work by trolltech
35 35
36#ifndef MEDIA_PLAYER_STATE_H 36#ifndef MEDIA_PLAYER_STATE_H
37#define MEDIA_PLAYER_STATE_H 37#define MEDIA_PLAYER_STATE_H
38 38
39 39
40#include <qobject.h> 40#include <qobject.h>
41 41
42 42
43class MediaPlayerDecoder; 43class MediaPlayerDecoder;
44class Config; 44class Config;
45 45
46 46
47class MediaPlayerState : public QObject { 47class MediaPlayerState : public QObject {
48Q_OBJECT 48Q_OBJECT
49public: 49public:
50 enum DisplayType { Audio, Video, MediaSelection }; 50 enum DisplayType { Audio, Video, MediaSelection };
51 51
52 MediaPlayerState( QObject *parent, const char *name ); 52 MediaPlayerState( QObject *parent, const char *name );
53 ~MediaPlayerState(); 53 ~MediaPlayerState();
54 54
55 bool isStreaming() const { return streaming; } 55 bool isStreaming() const { return streaming; }
56 bool isSeekable() const { return seekable; } 56 bool isSeekable() const { return seekable; }
57 bool isFullscreen() const { return fullscreen; } 57 bool isFullscreen() const { return fullscreen; }
58 bool isScaled() const { return scaled; } 58 bool isScaled() const { return scaled; }
59 bool isLooping() const { return looping; } 59 bool isLooping() const { return looping; }
60 bool isShuffled() const { return shuffled; } 60 bool isShuffled() const { return shuffled; }
61 bool isPaused() const { return paused; } 61 bool isPaused() const { return paused; }
62 bool isPlaying() const { return playing; } 62 bool isPlaying() const { return playing; }
63 bool isStopped() const { return stopped; } 63 bool isStopped() const { return stopped; }
64 long position() const { return curPosition; } 64 long position() const { return curPosition; }
65 long length() const { return curLength; } 65 long length() const { return curLength; }
66 char view() const;
67 DisplayType displayType() const; 66 DisplayType displayType() const;
68 67
69public slots: 68public slots:
70 void setIsStreaming( bool b ); 69 void setIsStreaming( bool b );
71 void setIsSeekable( bool b ); 70 void setIsSeekable( bool b );
72 void setFullscreen( bool b ); 71 void setFullscreen( bool b );
73 void setScaled( bool b ); 72 void setScaled( bool b );
74 void setLooping( bool b ); 73 void setLooping( bool b );
75 void setShuffled( bool b ); 74 void setShuffled( bool b );
76 void setPaused( bool b ); 75 void setPaused( bool b );
77 void setPlaying( bool b ); 76 void setPlaying( bool b );
78 void setStopped( bool b ); 77 void setStopped( bool b );
79 void setPosition( long p ); 78 void setPosition( long p );
80 void updatePosition( long p ); 79 void updatePosition( long p );
81 void setLength( long l ); 80 void setLength( long l );
82 void setView( char v );
83 void setDisplayType( MediaPlayerState::DisplayType displayType ); 81 void setDisplayType( MediaPlayerState::DisplayType displayType );
84 void setBlanked( bool b ); 82 void setBlanked( bool b );
85 void setVideoGamma( int v ); 83 void setVideoGamma( int v );
86 84
87 void setPrev(); 85 void setPrev();
88 void setNext(); 86 void setNext();
89 void setList(); 87 void setList();
90 void setVideo(); 88 void setVideo();
91 void setAudio(); 89 void setAudio();
92 90
93 void toggleFullscreen(); 91 void toggleFullscreen();
94 void toggleScaled(); 92 void toggleScaled();
95 void toggleLooping(); 93 void toggleLooping();
96 void toggleShuffled(); 94 void toggleShuffled();
97 void togglePaused(); 95 void togglePaused();
98 void togglePlaying(); 96 void togglePlaying();
99 void toggleBlank(); 97 void toggleBlank();
100 void writeConfig( Config& cfg ) const; 98 void writeConfig( Config& cfg ) const;
101 99
102 100
103signals: 101signals:
104 void fullscreenToggled( bool ); 102 void fullscreenToggled( bool );
105 void scaledToggled( bool ); 103 void scaledToggled( bool );
106 void loopingToggled( bool ); 104 void loopingToggled( bool );
107 void shuffledToggled( bool ); 105 void shuffledToggled( bool );
108 void pausedToggled( bool ); 106 void pausedToggled( bool );
109 void playingToggled( bool ); 107 void playingToggled( bool );
110 void stopToggled( bool ); 108 void stopToggled( bool );
111 void positionChanged( long ); // When the slider is moved 109 void positionChanged( long ); // When the slider is moved
112 void positionUpdated( long ); // When the media file progresses 110 void positionUpdated( long ); // When the media file progresses
113 void lengthChanged( long ); 111 void lengthChanged( long );
114 void displayTypeChanged( MediaPlayerState::DisplayType type ); 112 void displayTypeChanged( MediaPlayerState::DisplayType type );
115 void isSeekableToggled( bool ); 113 void isSeekableToggled( bool );
116 void blankToggled( bool ); 114 void blankToggled( bool );
117 void videoGammaChanged( int ); 115 void videoGammaChanged( int );
118 void prev(); 116 void prev();
119 void next(); 117 void next();
120 118
121private: 119private:
122 bool streaming : 1; 120 bool streaming : 1;
123 bool seekable : 1; 121 bool seekable : 1;
124 bool fullscreen: 1; 122 bool fullscreen: 1;
125 bool scaled : 1; 123 bool scaled : 1;
126 bool blanked : 1; 124 bool blanked : 1;
127 bool looping : 1; 125 bool looping : 1;
128 bool shuffled : 1; 126 bool shuffled : 1;
129 bool usePlaylist : 1; 127 bool usePlaylist : 1;
130 bool paused : 1; 128 bool paused : 1;
131 bool playing : 1; 129 bool playing : 1;
132 bool stopped : 1; 130 bool stopped : 1;
133 long curPosition; 131 long curPosition;
134 long curLength; 132 long curLength;
135 DisplayType m_displayType; 133 DisplayType m_displayType;
136 int videoGamma; 134 int videoGamma;
137 void readConfig( Config& cfg ); 135 void readConfig( Config& cfg );
138 136
139}; 137};
140 138
141 139
142#endif // MEDIA_PLAYER_STATE_H 140#endif // MEDIA_PLAYER_STATE_H
143 141
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
index db7c979..8be7a2f 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
@@ -1,228 +1,228 @@
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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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/qpemenubar.h> 34#include <qpe/qpemenubar.h>
35#include <qpe/qpetoolbar.h> 35#include <qpe/qpetoolbar.h>
36#include <qpe/fileselector.h> 36#include <qpe/fileselector.h>
37#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
38#include <qpe/storage.h> 38#include <qpe/storage.h>
39#include <qpe/mimetype.h> 39#include <qpe/mimetype.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41#include <qpe/global.h> 41#include <qpe/global.h>
42#include <qpe/resource.h> 42#include <qpe/resource.h>
43 43
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45#include <qaction.h> 45#include <qaction.h>
46#include <qcursor.h> 46#include <qcursor.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qlayout.h> 48#include <qlayout.h>
49 49
50#include "playlistselection.h" 50#include "playlistselection.h"
51#include "playlistwidget.h" 51#include "playlistwidget.h"
52#include "mediaplayerstate.h" 52#include "mediaplayerstate.h"
53#include "inputDialog.h" 53#include "inputDialog.h"
54 54
55//only needed for the random play 55//only needed for the random play
56#include <stdlib.h> 56#include <stdlib.h>
57 57
58#include "audiowidget.h" 58#include "audiowidget.h"
59#include "videowidget.h" 59#include "videowidget.h"
60#include "mediaplayerstate.h" 60#include "mediaplayerstate.h"
61 61
62extern MediaPlayerState *mediaPlayerState; 62extern MediaPlayerState *mediaPlayerState;
63 63
64PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) 64PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl )
65 : QMainWindow( parent, name, fl ) { 65 : QMainWindow( parent, name, fl ) {
66 66
67 d = new PlayListWidgetPrivate; 67 d = new PlayListWidgetPrivate;
68 d->setDocumentUsed = FALSE; 68 d->setDocumentUsed = FALSE;
69 69
70 setBackgroundMode( PaletteButton ); 70 setBackgroundMode( PaletteButton );
71 setToolBarsMovable( FALSE ); 71 setToolBarsMovable( FALSE );
72 72
73 // Create Toolbar 73 // Create Toolbar
74 QPEToolBar *toolbar = new QPEToolBar( this ); 74 QPEToolBar *toolbar = new QPEToolBar( this );
75 toolbar->setHorizontalStretchable( TRUE ); 75 toolbar->setHorizontalStretchable( TRUE );
76 76
77 // Create Menubar 77 // Create Menubar
78 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 78 QPEMenuBar *menu = new QPEMenuBar( toolbar );
79 menu->setMargin( 0 ); 79 menu->setMargin( 0 );
80 80
81 bar = new QPEToolBar( this ); 81 bar = new QPEToolBar( this );
82 bar->setLabel( tr( "Play Operations" ) ); 82 bar->setLabel( tr( "Play Operations" ) );
83 83
84 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); 84 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" );
85 tbDeletePlaylist->setFlat( TRUE ); 85 tbDeletePlaylist->setFlat( TRUE );
86 tbDeletePlaylist->setFixedSize( 20, 20 ); 86 tbDeletePlaylist->setFixedSize( 20, 20 );
87 87
88 tbDeletePlaylist->hide(); 88 tbDeletePlaylist->hide();
89 89
90 pmPlayList = new QPopupMenu( this ); 90 pmPlayList = new QPopupMenu( this );
91 menu->insertItem( tr( "File" ), pmPlayList ); 91 menu->insertItem( tr( "File" ), pmPlayList );
92 92
93 pmView = new QPopupMenu( this ); 93 pmView = new QPopupMenu( this );
94 menu->insertItem( tr( "View" ), pmView ); 94 menu->insertItem( tr( "View" ), pmView );
95 pmView->isCheckable(); 95 pmView->isCheckable();
96 96
97 skinsMenu = new QPopupMenu( this ); 97 skinsMenu = new QPopupMenu( this );
98 pmView->insertItem( tr( "Skins" ), skinsMenu ); 98 pmView->insertItem( tr( "Skins" ), skinsMenu );
99 skinsMenu->isCheckable(); 99 skinsMenu->isCheckable();
100 100
101 gammaMenu = new QPopupMenu( this ); 101 gammaMenu = new QPopupMenu( this );
102 pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); 102 pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu );
103 103
104 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); 104 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu );
105 gammaSlider->setRange( -40, 40 ); 105 gammaSlider->setRange( -40, 40 );
106 gammaSlider->setTickmarks( QSlider::Left ); 106 gammaSlider->setTickmarks( QSlider::Left );
107 gammaSlider->setTickInterval( 20 ); 107 gammaSlider->setTickInterval( 20 );
108 gammaSlider->setFocusPolicy( QWidget::StrongFocus ); 108 gammaSlider->setFocusPolicy( QWidget::StrongFocus );
109 gammaSlider->setValue( 0 ); 109 gammaSlider->setValue( 0 );
110 gammaSlider->setMinimumHeight( 50 ); 110 gammaSlider->setMinimumHeight( 50 );
111 111
112 gammaLCD = new QLCDNumber( 3, gammaMenu ); 112 gammaLCD = new QLCDNumber( 3, gammaMenu );
113 gammaLCD-> setFrameShape ( QFrame::NoFrame ); 113 gammaLCD-> setFrameShape ( QFrame::NoFrame );
114 gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); 114 gammaLCD-> setSegmentStyle ( QLCDNumber::Flat );
115 115
116 gammaMenu->insertItem( gammaSlider ); 116 gammaMenu->insertItem( gammaSlider );
117 gammaMenu->insertItem( gammaLCD ); 117 gammaMenu->insertItem( gammaLCD );
118 118
119 connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); 119 connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) );
120 120
121 vbox5 = new QVBox( this ); 121 vbox5 = new QVBox( this );
122 QVBox *vbox4 = new QVBox( vbox5 ); 122 QVBox *vbox4 = new QVBox( vbox5 );
123 QHBox *hbox6 = new QHBox( vbox4 ); 123 QHBox *hbox6 = new QHBox( vbox4 );
124 124
125 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 125 tabWidget = new QTabWidget( hbox6, "tabWidget" );
126 126
127 QWidget *pTab; 127 QWidget *pTab;
128 pTab = new QWidget( tabWidget, "pTab" ); 128 pTab = new QWidget( tabWidget, "pTab" );
129 tabWidget->insertTab( pTab, "Playlist"); 129 tabWidget->insertTab( pTab, "Playlist");
130 130
131 QGridLayout *Playout = new QGridLayout( pTab ); 131 QGridLayout *Playout = new QGridLayout( pTab );
132 Playout->setSpacing( 2); 132 Playout->setSpacing( 2);
133 Playout->setMargin( 2); 133 Playout->setMargin( 2);
134 134
135 // Add the playlist area 135 // Add the playlist area
136 QVBox *vbox3 = new QVBox( pTab ); 136 QVBox *vbox3 = new QVBox( pTab );
137 d->playListFrame = vbox3; 137 d->playListFrame = vbox3;
138 138
139 QHBox *hbox2 = new QHBox( vbox3 ); 139 QHBox *hbox2 = new QHBox( vbox3 );
140 d->selectedFiles = new PlayListSelection( hbox2 ); 140 d->selectedFiles = new PlayListSelection( hbox2 );
141 141
142 vbox1 = new QVBox( hbox2 ); 142 vbox1 = new QVBox( hbox2 );
143 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); 143 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold );
144 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch 144 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch
145 145
146 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 146 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
147 147
148 QWidget *aTab; 148 QWidget *aTab;
149 aTab = new QWidget( tabWidget, "aTab" ); 149 aTab = new QWidget( tabWidget, "aTab" );
150 150
151 QGridLayout *Alayout = new QGridLayout( aTab ); 151 QGridLayout *Alayout = new QGridLayout( aTab );
152 Alayout->setSpacing( 2 ); 152 Alayout->setSpacing( 2 );
153 Alayout->setMargin( 2 ); 153 Alayout->setMargin( 2 );
154 audioView = new QListView( aTab, "Audioview" ); 154 audioView = new QListView( aTab, "Audioview" );
155 audioView->addColumn( tr( "Title" ), 140 ); 155 audioView->addColumn( tr( "Title" ), 140 );
156 audioView->addColumn( tr( "Size" ), -1 ); 156 audioView->addColumn( tr( "Size" ), -1 );
157 audioView->addColumn( tr( "Media" ), 0 ); 157 audioView->addColumn( tr( "Media" ), 0 );
158 audioView->addColumn( tr( "Path" ), -1 ); 158 audioView->addColumn( tr( "Path" ), -1 );
159 audioView->setColumnAlignment( 1, Qt::AlignRight ); 159 audioView->setColumnAlignment( 1, Qt::AlignRight );
160 audioView->setColumnAlignment( 2, Qt::AlignRight ); 160 audioView->setColumnAlignment( 2, Qt::AlignRight );
161 audioView->setAllColumnsShowFocus( TRUE ); 161 audioView->setAllColumnsShowFocus( TRUE );
162 audioView->setSorting( 3, TRUE ); 162 audioView->setSorting( 3, TRUE );
163 audioView->setMultiSelection( TRUE ); 163 audioView->setMultiSelection( TRUE );
164 audioView->setSelectionMode( QListView::Extended ); 164 audioView->setSelectionMode( QListView::Extended );
165 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 165 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
166 tabWidget->insertTab( aTab, tr( "Audio" ) ); 166 tabWidget->insertTab( aTab, tr( "Audio" ) );
167 167
168 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); 168 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold );
169 169
170 QWidget *vTab; 170 QWidget *vTab;
171 vTab = new QWidget( tabWidget, "vTab" ); 171 vTab = new QWidget( tabWidget, "vTab" );
172 172
173 QGridLayout *Vlayout = new QGridLayout( vTab ); 173 QGridLayout *Vlayout = new QGridLayout( vTab );
174 Vlayout->setSpacing( 2 ); 174 Vlayout->setSpacing( 2 );
175 Vlayout->setMargin( 2 ); 175 Vlayout->setMargin( 2 );
176 videoView = new QListView( vTab, "Videoview" ); 176 videoView = new QListView( vTab, "Videoview" );
177 videoView->addColumn( tr( "Title" ), 140); 177 videoView->addColumn( tr( "Title" ), 140);
178 videoView->addColumn( tr( "Size" ), -1 ); 178 videoView->addColumn( tr( "Size" ), -1 );
179 videoView->addColumn(tr( "Media" ), 0 ); 179 videoView->addColumn(tr( "Media" ), 0 );
180 videoView->addColumn(tr( "Path" ), -1 ); 180 videoView->addColumn(tr( "Path" ), -1 );
181 videoView->setColumnAlignment( 1, Qt::AlignRight ); 181 videoView->setColumnAlignment( 1, Qt::AlignRight );
182 videoView->setColumnAlignment( 2, Qt::AlignRight ); 182 videoView->setColumnAlignment( 2, Qt::AlignRight );
183 videoView->setAllColumnsShowFocus( TRUE ); 183 videoView->setAllColumnsShowFocus( TRUE );
184 videoView->setSorting( 3, TRUE ); 184 videoView->setSorting( 3, TRUE );
185 videoView->setMultiSelection( TRUE ); 185 videoView->setMultiSelection( TRUE );
186 videoView->setSelectionMode( QListView::Extended ); 186 videoView->setSelectionMode( QListView::Extended );
187 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 187 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
188 188
189 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); 189 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold );
190 190
191 tabWidget->insertTab( vTab, tr( "Video" ) ); 191 tabWidget->insertTab( vTab, tr( "Video" ) );
192 192
193 //playlists list 193 //playlists list
194 QWidget *LTab; 194 QWidget *LTab;
195 LTab = new QWidget( tabWidget, "LTab" ); 195 LTab = new QWidget( tabWidget, "LTab" );
196 QGridLayout *Llayout = new QGridLayout( LTab ); 196 QGridLayout *Llayout = new QGridLayout( LTab );
197 Llayout->setSpacing( 2 ); 197 Llayout->setSpacing( 2 );
198 Llayout->setMargin( 2 ); 198 Llayout->setMargin( 2 );
199 199
200 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); 200 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE );
201 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 201 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
202 202
203 tabWidget->insertTab( LTab, tr( "Lists" ) ); 203 tabWidget->insertTab( LTab, tr( "Lists" ) );
204 204
205 setCentralWidget( vbox5 ); 205 setCentralWidget( vbox5 );
206} 206}
207 207
208 208
209 209
210PlayListWidgetGui::~PlayListWidgetGui() { 210PlayListWidgetGui::~PlayListWidgetGui() {
211} 211}
212 212
213void PlayListWidgetGui::setView( char view ) { 213void PlayListWidgetGui::setView( char view ) {
214 if ( view == 'l' ) 214 if ( view == 'l' )
215 showMaximized(); 215 showMaximized();
216 else 216 else
217 hide(); 217 hide();
218} 218}
219 219
220 220
221void PlayListWidgetGui::setActiveWindow() { 221void PlayListWidgetGui::setActiveWindow() {
222 // qDebug("SETTING active window"); 222 // qDebug("SETTING active window");
223 // When we get raised we need to ensure that it switches views 223 // When we get raised we need to ensure that it switches views
224 char origView = mediaPlayerState->view(); 224 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType();
225 mediaPlayerState->setView( 'l' ); // invalidate 225 mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate
226 mediaPlayerState->setView( origView ); // now switch back 226 mediaPlayerState->setDisplayType( origDisplayType ); // now switch back
227} 227}
228 228
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 71e08a6..e7d5a7b 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,259 +1,259 @@
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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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#include <qtimer.h> 35#include <qtimer.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include "xinecontrol.h" 39#include "xinecontrol.h"
40#include "mediaplayerstate.h" 40#include "mediaplayerstate.h"
41#include "videowidget.h" 41#include "videowidget.h"
42 42
43extern MediaPlayerState *mediaPlayerState; 43extern MediaPlayerState *mediaPlayerState;
44extern VideoWidget *videoUI; 44extern VideoWidget *videoUI;
45XineControl::XineControl( QObject *parent, const char *name ) 45XineControl::XineControl( QObject *parent, const char *name )
46 : QObject( parent, name ) { 46 : QObject( parent, name ) {
47 47
48 libXine = new XINE::Lib( videoUI->vidWidget() ); 48 libXine = new XINE::Lib( videoUI->vidWidget() );
49 49
50 connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); 50 connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) );
51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
52 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); 52 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
53 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 53 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
54 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 54 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
55 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 55 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
56 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 56 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
57 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 57 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
58 58
59 disabledSuspendScreenSaver = FALSE; 59 disabledSuspendScreenSaver = FALSE;
60} 60}
61 61
62XineControl::~XineControl() { 62XineControl::~XineControl() {
63#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 63#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
64 if ( disabledSuspendScreenSaver ) { 64 if ( disabledSuspendScreenSaver ) {
65 disabledSuspendScreenSaver = FALSE; 65 disabledSuspendScreenSaver = FALSE;
66 // Re-enable the suspend mode 66 // Re-enable the suspend mode
67 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 67 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
68 } 68 }
69#endif 69#endif
70 delete libXine; 70 delete libXine;
71} 71}
72 72
73void XineControl::play( const QString& fileName ) { 73void XineControl::play( const QString& fileName ) {
74 hasVideoChannel = FALSE; 74 hasVideoChannel = FALSE;
75 hasAudioChannel = FALSE; 75 hasAudioChannel = FALSE;
76 m_fileName = fileName; 76 m_fileName = fileName;
77 77
78 qDebug("<<FILENAME: " + fileName + ">>>>"); 78 qDebug("<<FILENAME: " + fileName + ">>>>");
79 79
80 if ( !libXine->play( fileName, 0, 0 ) ) { 80 if ( !libXine->play( fileName, 0, 0 ) ) {
81 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 81 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
82 // toggle stop so the the play button is reset 82 // toggle stop so the the play button is reset
83 mediaPlayerState->setPlaying( false ); 83 mediaPlayerState->setPlaying( false );
84 return; 84 return;
85 } 85 }
86 mediaPlayerState->setPlaying( true ); 86 mediaPlayerState->setPlaying( true );
87 87
88 char whichGui; 88 MediaPlayerState::DisplayType displayType;
89 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); 89 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
90 if ( !libXine->hasVideo() ) { 90 if ( !libXine->hasVideo() ) {
91 whichGui = 'a'; 91 displayType = MediaPlayerState::Audio;
92 qDebug("HAS AUDIO"); 92 qDebug("HAS AUDIO");
93 libXine->setShowVideo( false ); 93 libXine->setShowVideo( false );
94 hasAudioChannel = TRUE; 94 hasAudioChannel = TRUE;
95 } else { 95 } else {
96 whichGui = 'v'; 96 displayType = MediaPlayerState::Video;
97 qDebug("HAS VIDEO"); 97 qDebug("HAS VIDEO");
98 libXine->setShowVideo( true ); 98 libXine->setShowVideo( true );
99 hasVideoChannel = TRUE; 99 hasVideoChannel = TRUE;
100 } 100 }
101 // determine if slider is shown 101 // determine if slider is shown
102 mediaPlayerState->setIsSeekable( libXine->isSeekable() ); 102 mediaPlayerState->setIsSeekable( libXine->isSeekable() );
103 103
104 // which gui (video / audio) 104 // which gui (video / audio)
105 mediaPlayerState->setView( whichGui ); 105 mediaPlayerState->setDisplayType( displayType );
106 106
107#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 107#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
108 if ( !disabledSuspendScreenSaver ) { 108 if ( !disabledSuspendScreenSaver ) {
109 disabledSuspendScreenSaver = TRUE; 109 disabledSuspendScreenSaver = TRUE;
110 // Stop the screen from blanking and power saving state 110 // Stop the screen from blanking and power saving state
111 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 111 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
112 << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 112 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend );
113 } 113 }
114#endif 114#endif
115 115
116 length(); 116 length();
117 position(); 117 position();
118} 118}
119 119
120void XineControl::nextMedia() { 120void XineControl::nextMedia() {
121 mediaPlayerState->setNext(); 121 mediaPlayerState->setNext();
122} 122}
123 123
124void XineControl::setGamma( int value ) { 124void XineControl::setGamma( int value ) {
125 libXine->setGamma( value ); 125 libXine->setGamma( value );
126} 126}
127 127
128void XineControl::stop( bool isSet ) { 128void XineControl::stop( bool isSet ) {
129 if ( !isSet ) { 129 if ( !isSet ) {
130 libXine->stop(); 130 libXine->stop();
131 131
132#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 132#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
133 if ( disabledSuspendScreenSaver ) { 133 if ( disabledSuspendScreenSaver ) {
134 disabledSuspendScreenSaver = FALSE; 134 disabledSuspendScreenSaver = FALSE;
135 // Re-enable the suspend mode 135 // Re-enable the suspend mode
136 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 136 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
137 } 137 }
138#endif 138#endif
139 } 139 }
140} 140}
141 141
142/** 142/**
143 * Pause playback 143 * Pause playback
144 * @isSet 144 * @isSet
145 */ 145 */
146void XineControl::pause( bool isSet) { 146void XineControl::pause( bool isSet) {
147 if ( isSet ) { 147 if ( isSet ) {
148 libXine->pause(); 148 libXine->pause();
149 } else { 149 } else {
150 libXine->play( m_fileName, 0, m_currentTime ); 150 libXine->play( m_fileName, 0, m_currentTime );
151 } 151 }
152} 152}
153 153
154 154
155/** 155/**
156 * get current time in playback 156 * get current time in playback
157 */ 157 */
158long XineControl::currentTime() { 158long XineControl::currentTime() {
159 // todo: jede sekunde überprüfen 159 // todo: jede sekunde überprüfen
160 m_currentTime = libXine->currentTime(); 160 m_currentTime = libXine->currentTime();
161 return m_currentTime; 161 return m_currentTime;
162 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 162 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
163} 163}
164 164
165/** 165/**
166 * Set the length of the media file 166 * Set the length of the media file
167 */ 167 */
168void XineControl::length() { 168void XineControl::length() {
169 m_length = libXine->length(); 169 m_length = libXine->length();
170 mediaPlayerState->setLength( m_length ); 170 mediaPlayerState->setLength( m_length );
171} 171}
172 172
173 173
174/** 174/**
175 * Reports the position the xine backend is at right now 175 * Reports the position the xine backend is at right now
176 * @return long the postion in seconds 176 * @return long the postion in seconds
177 */ 177 */
178long XineControl::position() { 178long XineControl::position() {
179 m_position = ( currentTime() ); 179 m_position = ( currentTime() );
180 mediaPlayerState->updatePosition( m_position ); 180 mediaPlayerState->updatePosition( m_position );
181 long emitPos = (long)m_position; 181 long emitPos = (long)m_position;
182 emit positionChanged( emitPos ); 182 emit positionChanged( emitPos );
183 if( mediaPlayerState->isPlaying() ) { 183 if( mediaPlayerState->isPlaying() ) {
184 // needs to be stopped the media is stopped 184 // needs to be stopped the media is stopped
185 QTimer::singleShot( 1000, this, SLOT( position() ) ); 185 QTimer::singleShot( 1000, this, SLOT( position() ) );
186 } 186 }
187 // qDebug("POSITION : %d", m_position); 187 // qDebug("POSITION : %d", m_position);
188 return m_position; 188 return m_position;
189} 189}
190 190
191/** 191/**
192 * Set videoplayback to fullscreen 192 * Set videoplayback to fullscreen
193 * @param isSet 193 * @param isSet
194 */ 194 */
195void XineControl::setFullscreen( bool isSet ) { 195void XineControl::setFullscreen( bool isSet ) {
196 libXine->showVideoFullScreen( isSet ); 196 libXine->showVideoFullScreen( isSet );
197} 197}
198 198
199 199
200QString XineControl::getMetaInfo() { 200QString XineControl::getMetaInfo() {
201 201
202 QString returnString; 202 QString returnString;
203 203
204 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 204 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
205 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 205 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
206 } 206 }
207 207
208 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 208 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
209 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 209 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
210 } 210 }
211 211
212 if ( !libXine->metaInfo( 2 ).isEmpty() ) { 212 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
213 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); 213 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
214 } 214 }
215 215
216 if ( !libXine->metaInfo( 3 ).isEmpty() ) { 216 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
217 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); 217 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
218 } 218 }
219 219
220 if ( !libXine->metaInfo( 4 ).isEmpty() ) { 220 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
221 returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); 221 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
222 } 222 }
223 223
224 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 224 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
225 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 225 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
226 } 226 }
227 return returnString; 227 return returnString;
228} 228}
229 229
230QString XineControl::getErrorCode() { 230QString XineControl::getErrorCode() {
231 231
232 int errorCode = libXine->error(); 232 int errorCode = libXine->error();
233 233
234 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); 234 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) );
235 235
236 if ( errorCode == 1 ) { 236 if ( errorCode == 1 ) {
237 return tr( "No input plugin found for this media type" ); 237 return tr( "No input plugin found for this media type" );
238 } else if ( errorCode == 2 ) { 238 } else if ( errorCode == 2 ) {
239 return tr( "No demux plugin found for this media type" ); 239 return tr( "No demux plugin found for this media type" );
240 } else if ( errorCode == 3 ) { 240 } else if ( errorCode == 3 ) {
241 return tr( "Demuxing failed for this media type" ); 241 return tr( "Demuxing failed for this media type" );
242 } else if ( errorCode == 4 ) { 242 } else if ( errorCode == 4 ) {
243 return tr( "Malformed MRL" ); 243 return tr( "Malformed MRL" );
244 } else { 244 } else {
245 return tr( "Some other error" ); 245 return tr( "Some other error" );
246 } 246 }
247} 247}
248 248
249/** 249/**
250 * Seek to a position in the track 250 * Seek to a position in the track
251 * @param second the second to jump to 251 * @param second the second to jump to
252 */ 252 */
253void XineControl::seekTo( long second ) { 253void XineControl::seekTo( long second ) {
254 libXine->seekTo( (int)second ); 254 libXine->seekTo( (int)second );
255} 255}
256 256
257void XineControl::videoResized ( const QSize &s ) { 257void XineControl::videoResized ( const QSize &s ) {
258 libXine->resize( s ); 258 libXine->resize( s );
259} 259}