summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-17 02:45:43 (UTC)
committer llornkcor <llornkcor>2002-10-17 02:45:43 (UTC)
commitce65a2b92c8d647b0621120358bde62f7a893129 (patch) (unidiff)
tree819bc79171edb15aff5e0da7224110f0b5928906
parent4f2dc0f59515dd456dbe7b32eeda835ea231fca9 (diff)
downloadopie-ce65a2b92c8d647b0621120358bde62f7a893129.zip
opie-ce65a2b92c8d647b0621120358bde62f7a893129.tar.gz
opie-ce65a2b92c8d647b0621120358bde62f7a893129.tar.bz2
zaurus screenblanking - maybe better, maybe not- needs testing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 606f8e9..f0a01a1 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,85 +1,86 @@
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 ), currentFile( NULL ) { 36 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
37 37
38 fd=-1;fl=-1;
38 playList->setCaption( tr( "OpiePlayer: Initializating" ) ); 39 playList->setCaption( tr( "OpiePlayer: Initializating" ) );
39 40
40 qApp->processEvents(); 41 qApp->processEvents();
41 // QPEApplication::grabKeyboard(); // EVIL 42 // QPEApplication::grabKeyboard(); // EVIL
42 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
43 44
44 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
45 46
46 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 47 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
47 48
48 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 49 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
49 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 50 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
50 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
51 52
52 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 53 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
53 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 54 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
54 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 55 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
55 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 56 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
56 57
57 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 58 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
58 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 59 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
59 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 60 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
60 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 61 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
61 62
62 volControl = new VolumeControl; 63 volControl = new VolumeControl;
63 xineControl = new XineControl(); 64 xineControl = new XineControl();
64 playList->setCaption(tr("OpiePlayer")); 65 playList->setCaption(tr("OpiePlayer"));
65} 66}
66 67
67MediaPlayer::~MediaPlayer() { 68MediaPlayer::~MediaPlayer() {
68 delete xineControl; 69 delete xineControl;
69 delete volControl; 70 delete volControl;
70} 71}
71 72
72void MediaPlayer::pauseCheck( bool b ) { 73void MediaPlayer::pauseCheck( bool b ) {
73 if ( b && !mediaPlayerState->playing() ) { 74 if ( b && !mediaPlayerState->playing() ) {
74 mediaPlayerState->setPaused( FALSE ); 75 mediaPlayerState->setPaused( FALSE );
75 } 76 }
76} 77}
77 78
78void MediaPlayer::play() { 79void MediaPlayer::play() {
79 mediaPlayerState->setPlaying( FALSE ); 80 mediaPlayerState->setPlaying( FALSE );
80 mediaPlayerState->setPlaying( TRUE ); 81 mediaPlayerState->setPlaying( TRUE );
81} 82}
82 83
83void MediaPlayer::setPlaying( bool play ) { 84void MediaPlayer::setPlaying( bool play ) {
84 if ( !play ) { 85 if ( !play ) {
85 return; 86 return;
@@ -253,94 +254,111 @@ void MediaPlayer::timerEvent( QTimerEvent * ) {
253 254
254 QFont f; 255 QFont f;
255 f.setPixelSize( 20 ); 256 f.setPixelSize( 20 );
256 f.setBold( TRUE ); 257 f.setBold( TRUE );
257 p.setFont( f ); 258 p.setFont( f );
258 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 259 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
259 260
260 for ( unsigned int i = 0; i < 10; i++ ) { 261 for ( unsigned int i = 0; i < 10; i++ ) {
261 if ( v > i ) { 262 if ( v > i ) {
262 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 263 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
263 } else { 264 } else {
264 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 265 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
265 } 266 }
266 } 267 }
267 } else { 268 } else {
268 w = videoUI->width(); 269 w = videoUI->width();
269 h = videoUI->height(); 270 h = videoUI->height();
270 271
271 if ( drawnOnScreenDisplay ) { 272 if ( drawnOnScreenDisplay ) {
272 if ( onScreenDisplayVolume > v ) { 273 if ( onScreenDisplayVolume > v ) {
273 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 274 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
274 } 275 }
275 } 276 }
276 drawnOnScreenDisplay = TRUE; 277 drawnOnScreenDisplay = TRUE;
277 onScreenDisplayVolume = v; 278 onScreenDisplayVolume = v;
278 QPainter p( videoUI ); 279 QPainter p( videoUI );
279 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 280 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
280 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 281 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
281 282
282 QFont f; 283 QFont f;
283 f.setPixelSize( 20 ); 284 f.setPixelSize( 20 );
284 f.setBold( TRUE ); 285 f.setBold( TRUE );
285 p.setFont( f ); 286 p.setFont( f );
286 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 287 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
287 288
288 for ( unsigned int i = 0; i < 10; i++ ) { 289 for ( unsigned int i = 0; i < 10; i++ ) {
289 if ( v > i ) { 290 if ( v > i ) {
290 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 291 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
291 } else { 292 } else {
292 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 293 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
293 } 294 }
294 } 295 }
295 } 296 }
296} 297}
297 298
298 299
299void MediaPlayer::blank( bool b ) { 300void MediaPlayer::blank( bool b ) {
300 fd=open("/dev/fb0",O_RDWR); 301 fd=open("/dev/fb0",O_RDWR);
302#ifdef QT_QWS_EBX
303 fl= open( "/dev/fl", O_RDWR );
304#endif
301 if (fd != -1) { 305 if (fd != -1) {
302 if ( b ) { 306 if ( b ) {
303 qDebug("do blanking"); 307 qDebug("do blanking");
308#ifdef QT_QWS_EBX
309 ioctl( fd, FBIOBLANK, 1 );
310 if(fl !=-1) {
311 ioctl( fl, 2 );
312 ::close(fl);
313 }
314#else
304 ioctl( fd, FBIOBLANK, 3 ); 315 ioctl( fd, FBIOBLANK, 3 );
316#endif
305 isBlanked = TRUE; 317 isBlanked = TRUE;
306 } else { 318 } else {
307 qDebug("do unblanking"); 319 qDebug("do unblanking");
308 ioctl( fd, FBIOBLANK, 0); 320 ioctl( fd, FBIOBLANK, 0);
321#ifdef QT_QWS_EBX
322 if(fl != -1) {
323 ioctl( fl, 1);
324 ::close(fl);
325 }
326#endif
309 isBlanked = FALSE; 327 isBlanked = FALSE;
310 } 328 }
311 close( fd ); 329 close( fd );
312 } else { 330 } else {
313 qDebug("<< /dev/fb0 could not be opened >>"); 331 qDebug("<< /dev/fb0 could not be opened >>");
314 } 332 }
315} 333}
316 334
317void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 335void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
318 switch ( e->key() ) { 336 switch ( e->key() ) {
319////////////////////////////// Zaurus keys 337////////////////////////////// Zaurus keys
320 case Key_Home: 338 case Key_Home:
321 break; 339 break;
322 case Key_F9: //activity 340 case Key_F9: //activity
323 break; 341 break;
324 case Key_F10: //contacts 342 case Key_F10: //contacts
325 break; 343 break;
326 case Key_F11: //menu 344 case Key_F11: //menu
327 break; 345 break;
328 case Key_F12: //home 346 case Key_F12: //home
329 qDebug("Blank here"); 347 qDebug("Blank here");
330// mediaPlayerState->toggleBlank(); 348// mediaPlayerState->toggleBlank();
331 break; 349 break;
332 case Key_F13: //mail 350 case Key_F13: //mail
333 qDebug("Blank here"); 351 qDebug("Blank here");
334 // mediaPlayerState->toggleBlank(); 352 // mediaPlayerState->toggleBlank();
335 break; 353 break;
336 } 354 }
337} 355}
338 356
339void MediaPlayer::cleanUp() {// this happens on closing 357void MediaPlayer::cleanUp() {// this happens on closing
340 Config cfg( "OpiePlayer" ); 358 Config cfg( "OpiePlayer" );
341 mediaPlayerState->writeConfig( cfg ); 359 mediaPlayerState->writeConfig( cfg );
342 playList->writeDefaultPlaylist( ); 360 playList->writeDefaultPlaylist( );
343 361
344// QPEApplication::grabKeyboard(); 362// QPEApplication::grabKeyboard();
345// QPEApplication::ungrabKeyboard(); 363// QPEApplication::ungrabKeyboard();
346} 364}