-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 8b0f501..1f19b30 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,364 +1,367 @@ | |||
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 | ||
27 | extern AudioWidget *audioUI; | 27 | extern AudioWidget *audioUI; |
28 | extern VideoWidget *videoUI; | 28 | extern VideoWidget *videoUI; |
29 | extern PlayListWidget *playList; | 29 | extern PlayListWidget *playList; |
30 | extern MediaPlayerState *mediaPlayerState; | 30 | extern MediaPlayerState *mediaPlayerState; |
31 | 31 | ||
32 | 32 | ||
33 | #define FBIOBLANK 0x4611 | 33 | #define FBIOBLANK 0x4611 |
34 | 34 | ||
35 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 35 | MediaPlayer::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 | 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 | playList->setCaption(tr("OpiePlayer")); | 65 | Config cfg( "OpiePlayer" ); |
66 | cfg.setGroup("PlayList"); | ||
67 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | ||
68 | playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | ||
66 | } | 69 | } |
67 | 70 | ||
68 | MediaPlayer::~MediaPlayer() { | 71 | MediaPlayer::~MediaPlayer() { |
69 | delete xineControl; | 72 | delete xineControl; |
70 | delete volControl; | 73 | delete volControl; |
71 | } | 74 | } |
72 | 75 | ||
73 | void MediaPlayer::pauseCheck( bool b ) { | 76 | void MediaPlayer::pauseCheck( bool b ) { |
74 | if ( b && !mediaPlayerState->playing() ) { | 77 | if ( b && !mediaPlayerState->playing() ) { |
75 | mediaPlayerState->setPaused( FALSE ); | 78 | mediaPlayerState->setPaused( FALSE ); |
76 | } | 79 | } |
77 | } | 80 | } |
78 | 81 | ||
79 | void MediaPlayer::play() { | 82 | void MediaPlayer::play() { |
80 | mediaPlayerState->setPlaying( FALSE ); | 83 | mediaPlayerState->setPlaying( FALSE ); |
81 | mediaPlayerState->setPlaying( TRUE ); | 84 | mediaPlayerState->setPlaying( TRUE ); |
82 | } | 85 | } |
83 | 86 | ||
84 | void MediaPlayer::setPlaying( bool play ) { | 87 | void MediaPlayer::setPlaying( bool play ) { |
85 | if ( !play ) { | 88 | if ( !play ) { |
86 | return; | 89 | return; |
87 | } | 90 | } |
88 | 91 | ||
89 | if ( mediaPlayerState->paused() ) { | 92 | if ( mediaPlayerState->paused() ) { |
90 | mediaPlayerState->setPaused( FALSE ); | 93 | mediaPlayerState->setPaused( FALSE ); |
91 | return; | 94 | return; |
92 | } | 95 | } |
93 | 96 | ||
94 | QString tickerText, time, fileName; | 97 | QString tickerText, time, fileName; |
95 | if( playList->whichList() == 0 ) { //check for filelist | 98 | if( playList->whichList() == 0 ) { //check for filelist |
96 | const DocLnk *playListCurrent = playList->current(); | 99 | const DocLnk *playListCurrent = playList->current(); |
97 | if ( playListCurrent != NULL ) { | 100 | if ( playListCurrent != NULL ) { |
98 | currentFile = playListCurrent; | 101 | currentFile = playListCurrent; |
99 | } | 102 | } |
100 | xineControl->play( currentFile->file() ); | 103 | xineControl->play( currentFile->file() ); |
101 | fileName = currentFile->name(); | 104 | fileName = currentFile->name(); |
102 | long seconds = mediaPlayerState->length();// | 105 | long seconds = mediaPlayerState->length();// |
103 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 106 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
104 | //qDebug(time); | 107 | //qDebug(time); |
105 | 108 | ||
106 | } else { | 109 | } else { |
107 | //if playing in file list.. play in a different way | 110 | //if playing in file list.. play in a different way |
108 | // random and looping settings enabled causes problems here, | 111 | // random and looping settings enabled causes problems here, |
109 | // since there is no selected file in the playlist, but a selected file in the file list, | 112 | // since there is no selected file in the playlist, but a selected file in the file list, |
110 | // so we remember and shutoff | 113 | // so we remember and shutoff |
111 | l = mediaPlayerState->looping(); | 114 | l = mediaPlayerState->looping(); |
112 | if(l) { | 115 | if(l) { |
113 | mediaPlayerState->setLooping( false ); | 116 | mediaPlayerState->setLooping( false ); |
114 | } | 117 | } |
115 | r = mediaPlayerState->shuffled(); | 118 | r = mediaPlayerState->shuffled(); |
116 | mediaPlayerState->setShuffled( false ); | 119 | mediaPlayerState->setShuffled( false ); |
117 | 120 | ||
118 | fileName = playList->currentFileListPathName(); | 121 | fileName = playList->currentFileListPathName(); |
119 | xineControl->play( fileName ); | 122 | xineControl->play( fileName ); |
120 | long seconds = mediaPlayerState->length(); | 123 | long seconds = mediaPlayerState->length(); |
121 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 124 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
122 | //qDebug(time); | 125 | //qDebug(time); |
123 | if( fileName.left(4) != "http" ) { | 126 | if( fileName.left(4) != "http" ) { |
124 | fileName = QFileInfo( fileName ).baseName(); | 127 | fileName = QFileInfo( fileName ).baseName(); |
125 | } | 128 | } |
126 | 129 | ||
127 | } | 130 | } |
128 | 131 | ||
129 | if( fileName.left(4) == "http" ) { | 132 | if( fileName.left(4) == "http" ) { |
130 | if ( xineControl->getMetaInfo().isEmpty() ) { | 133 | if ( xineControl->getMetaInfo().isEmpty() ) { |
131 | tickerText = tr( " File: " ) + fileName; | 134 | tickerText = tr( " File: " ) + fileName; |
132 | } else { | 135 | } else { |
133 | tickerText = xineControl->getMetaInfo(); | 136 | tickerText = xineControl->getMetaInfo(); |
134 | } | 137 | } |
135 | } else { | 138 | } else { |
136 | if ( xineControl->getMetaInfo().isEmpty() ) { | 139 | if ( xineControl->getMetaInfo().isEmpty() ) { |
137 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 140 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
138 | } else { | 141 | } else { |
139 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 142 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; |
140 | } | 143 | } |
141 | } | 144 | } |
142 | audioUI->setTickerText( tickerText ); | 145 | audioUI->setTickerText( tickerText ); |
143 | } | 146 | } |
144 | 147 | ||
145 | 148 | ||
146 | void MediaPlayer::prev() { | 149 | void MediaPlayer::prev() { |
147 | if( playList->whichList() == 0 ) { //if using the playlist | 150 | if( playList->whichList() == 0 ) { //if using the playlist |
148 | if ( playList->prev() ) { | 151 | if ( playList->prev() ) { |
149 | play(); | 152 | play(); |
150 | } else if ( mediaPlayerState->looping() ) { | 153 | } else if ( mediaPlayerState->looping() ) { |
151 | if ( playList->last() ) { | 154 | if ( playList->last() ) { |
152 | play(); | 155 | play(); |
153 | } | 156 | } |
154 | } else { | 157 | } else { |
155 | mediaPlayerState->setList(); | 158 | mediaPlayerState->setList(); |
156 | } | 159 | } |
157 | } | 160 | } |
158 | } | 161 | } |
159 | 162 | ||
160 | 163 | ||
161 | void MediaPlayer::next() { | 164 | void MediaPlayer::next() { |
162 | 165 | ||
163 | if(playList->whichList() == 0) { //if using the playlist | 166 | if(playList->whichList() == 0) { //if using the playlist |
164 | if ( playList->next() ) { | 167 | if ( playList->next() ) { |
165 | play(); | 168 | play(); |
166 | } else if ( mediaPlayerState->looping() ) { | 169 | } else if ( mediaPlayerState->looping() ) { |
167 | if ( playList->first() ) { | 170 | if ( playList->first() ) { |
168 | play(); | 171 | play(); |
169 | } | 172 | } |
170 | } else { | 173 | } else { |
171 | mediaPlayerState->setList(); | 174 | mediaPlayerState->setList(); |
172 | } | 175 | } |
173 | } else { //if playing from file list, let's just stop | 176 | } else { //if playing from file list, let's just stop |
174 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 177 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
175 | mediaPlayerState->setPlaying(false); | 178 | mediaPlayerState->setPlaying(false); |
176 | mediaPlayerState->setView('l'); | 179 | mediaPlayerState->setView('l'); |
177 | if(l) mediaPlayerState->setLooping(l); | 180 | if(l) mediaPlayerState->setLooping(l); |
178 | if(r) mediaPlayerState->setShuffled(r); | 181 | if(r) mediaPlayerState->setShuffled(r); |
179 | } | 182 | } |
180 | qApp->processEvents(); | 183 | qApp->processEvents(); |
181 | } | 184 | } |
182 | 185 | ||
183 | 186 | ||
184 | void MediaPlayer::startDecreasingVolume() { | 187 | void MediaPlayer::startDecreasingVolume() { |
185 | volumeDirection = -1; | 188 | volumeDirection = -1; |
186 | startTimer( 100 ); | 189 | startTimer( 100 ); |
187 | volControl->decVol(2); | 190 | volControl->decVol(2); |
188 | } | 191 | } |
189 | 192 | ||
190 | 193 | ||
191 | void MediaPlayer::startIncreasingVolume() { | 194 | void MediaPlayer::startIncreasingVolume() { |
192 | volumeDirection = +1; | 195 | volumeDirection = +1; |
193 | startTimer( 100 ); | 196 | startTimer( 100 ); |
194 | volControl->incVol(2); | 197 | volControl->incVol(2); |
195 | } | 198 | } |
196 | 199 | ||
197 | 200 | ||
198 | bool drawnOnScreenDisplay = FALSE; | 201 | bool drawnOnScreenDisplay = FALSE; |
199 | unsigned int onScreenDisplayVolume = 0; | 202 | unsigned int onScreenDisplayVolume = 0; |
200 | const int yoff = 110; | 203 | const int yoff = 110; |
201 | 204 | ||
202 | void MediaPlayer::stopChangingVolume() { | 205 | void MediaPlayer::stopChangingVolume() { |
203 | killTimers(); | 206 | killTimers(); |
204 | // Get rid of the on-screen display stuff | 207 | // Get rid of the on-screen display stuff |
205 | drawnOnScreenDisplay = FALSE; | 208 | drawnOnScreenDisplay = FALSE; |
206 | onScreenDisplayVolume = 0; | 209 | onScreenDisplayVolume = 0; |
207 | int w=0; | 210 | int w=0; |
208 | int h=0; | 211 | int h=0; |
209 | if( !xineControl->hasVideo() ) { | 212 | if( !xineControl->hasVideo() ) { |
210 | w = audioUI->width(); | 213 | w = audioUI->width(); |
211 | h = audioUI->height(); | 214 | h = audioUI->height(); |
212 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 215 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
213 | } else { | 216 | } else { |
214 | w = videoUI->width(); | 217 | w = videoUI->width(); |
215 | h = videoUI->height(); | 218 | h = videoUI->height(); |
216 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 219 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
217 | } | 220 | } |
218 | } | 221 | } |
219 | 222 | ||
220 | 223 | ||
221 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 224 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
222 | if ( volumeDirection == +1 ) { | 225 | if ( volumeDirection == +1 ) { |
223 | volControl->incVol( 2 ); | 226 | volControl->incVol( 2 ); |
224 | } else if ( volumeDirection == -1 ) { | 227 | } else if ( volumeDirection == -1 ) { |
225 | volControl->decVol( 2 ); | 228 | volControl->decVol( 2 ); |
226 | } | 229 | } |
227 | 230 | ||
228 | 231 | ||
229 | // TODO FIXME | 232 | // TODO FIXME |
230 | // huh?? | 233 | // huh?? |
231 | unsigned int v= 0; | 234 | unsigned int v= 0; |
232 | v = volControl->volume(); | 235 | v = volControl->volume(); |
233 | v = v / 10; | 236 | v = v / 10; |
234 | 237 | ||
235 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 238 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
236 | return; | 239 | return; |
237 | } | 240 | } |
238 | 241 | ||
239 | int w=0; int h=0; | 242 | int w=0; int h=0; |
240 | if( !xineControl->hasVideo() ) { | 243 | if( !xineControl->hasVideo() ) { |
241 | w = audioUI->width(); | 244 | w = audioUI->width(); |
242 | h = audioUI->height(); | 245 | h = audioUI->height(); |
243 | 246 | ||
244 | if ( drawnOnScreenDisplay ) { | 247 | if ( drawnOnScreenDisplay ) { |
245 | if ( onScreenDisplayVolume > v ) { | 248 | if ( onScreenDisplayVolume > v ) { |
246 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 249 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
247 | } | 250 | } |
248 | } | 251 | } |
249 | drawnOnScreenDisplay = TRUE; | 252 | drawnOnScreenDisplay = TRUE; |
250 | onScreenDisplayVolume = v; | 253 | onScreenDisplayVolume = v; |
251 | QPainter p( audioUI ); | 254 | QPainter p( audioUI ); |
252 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 255 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
253 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 256 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
254 | 257 | ||
255 | QFont f; | 258 | QFont f; |
256 | f.setPixelSize( 20 ); | 259 | f.setPixelSize( 20 ); |
257 | f.setBold( TRUE ); | 260 | f.setBold( TRUE ); |
258 | p.setFont( f ); | 261 | p.setFont( f ); |
259 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 262 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
260 | 263 | ||
261 | for ( unsigned int i = 0; i < 10; i++ ) { | 264 | for ( unsigned int i = 0; i < 10; i++ ) { |
262 | if ( v > i ) { | 265 | if ( v > i ) { |
263 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 266 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
264 | } else { | 267 | } else { |
265 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 268 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
266 | } | 269 | } |
267 | } | 270 | } |
268 | } else { | 271 | } else { |
269 | w = videoUI->width(); | 272 | w = videoUI->width(); |
270 | h = videoUI->height(); | 273 | h = videoUI->height(); |
271 | 274 | ||
272 | if ( drawnOnScreenDisplay ) { | 275 | if ( drawnOnScreenDisplay ) { |
273 | if ( onScreenDisplayVolume > v ) { | 276 | if ( onScreenDisplayVolume > v ) { |
274 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 277 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
275 | } | 278 | } |
276 | } | 279 | } |
277 | drawnOnScreenDisplay = TRUE; | 280 | drawnOnScreenDisplay = TRUE; |
278 | onScreenDisplayVolume = v; | 281 | onScreenDisplayVolume = v; |
279 | QPainter p( videoUI ); | 282 | QPainter p( videoUI ); |
280 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 283 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
281 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 284 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
282 | 285 | ||
283 | QFont f; | 286 | QFont f; |
284 | f.setPixelSize( 20 ); | 287 | f.setPixelSize( 20 ); |
285 | f.setBold( TRUE ); | 288 | f.setBold( TRUE ); |
286 | p.setFont( f ); | 289 | p.setFont( f ); |
287 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 290 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
288 | 291 | ||
289 | for ( unsigned int i = 0; i < 10; i++ ) { | 292 | for ( unsigned int i = 0; i < 10; i++ ) { |
290 | if ( v > i ) { | 293 | if ( v > i ) { |
291 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 294 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
292 | } else { | 295 | } else { |
293 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 296 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
294 | } | 297 | } |
295 | } | 298 | } |
296 | } | 299 | } |
297 | } | 300 | } |
298 | 301 | ||
299 | 302 | ||
300 | void MediaPlayer::blank( bool b ) { | 303 | void MediaPlayer::blank( bool b ) { |
301 | fd=open("/dev/fb0",O_RDWR); | 304 | fd=open("/dev/fb0",O_RDWR); |
302 | #ifdef QT_QWS_EBX | 305 | #ifdef QT_QWS_EBX |
303 | fl= open( "/dev/fl", O_RDWR ); | 306 | fl= open( "/dev/fl", O_RDWR ); |
304 | #endif | 307 | #endif |
305 | if (fd != -1) { | 308 | if (fd != -1) { |
306 | if ( b ) { | 309 | if ( b ) { |
307 | qDebug("do blanking"); | 310 | qDebug("do blanking"); |
308 | #ifdef QT_QWS_EBX | 311 | #ifdef QT_QWS_EBX |
309 | ioctl( fd, FBIOBLANK, 1 ); | 312 | ioctl( fd, FBIOBLANK, 1 ); |
310 | if(fl !=-1) { | 313 | if(fl !=-1) { |
311 | ioctl( fl, 2 ); | 314 | ioctl( fl, 2 ); |
312 | ::close(fl); | 315 | ::close(fl); |
313 | } | 316 | } |
314 | #else | 317 | #else |
315 | ioctl( fd, FBIOBLANK, 3 ); | 318 | ioctl( fd, FBIOBLANK, 3 ); |
316 | #endif | 319 | #endif |
317 | isBlanked = TRUE; | 320 | isBlanked = TRUE; |
318 | } else { | 321 | } else { |
319 | qDebug("do unblanking"); | 322 | qDebug("do unblanking"); |
320 | ioctl( fd, FBIOBLANK, 0); | 323 | ioctl( fd, FBIOBLANK, 0); |
321 | #ifdef QT_QWS_EBX | 324 | #ifdef QT_QWS_EBX |
322 | if(fl != -1) { | 325 | if(fl != -1) { |
323 | ioctl( fl, 1); | 326 | ioctl( fl, 1); |
324 | ::close(fl); | 327 | ::close(fl); |
325 | } | 328 | } |
326 | #endif | 329 | #endif |
327 | isBlanked = FALSE; | 330 | isBlanked = FALSE; |
328 | } | 331 | } |
329 | close( fd ); | 332 | close( fd ); |
330 | } else { | 333 | } else { |
331 | qDebug("<< /dev/fb0 could not be opened >>"); | 334 | qDebug("<< /dev/fb0 could not be opened >>"); |
332 | } | 335 | } |
333 | } | 336 | } |
334 | 337 | ||
335 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 338 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
336 | switch ( e->key() ) { | 339 | switch ( e->key() ) { |
337 | ////////////////////////////// Zaurus keys | 340 | ////////////////////////////// Zaurus keys |
338 | case Key_Home: | 341 | case Key_Home: |
339 | break; | 342 | break; |
340 | case Key_F9: //activity | 343 | case Key_F9: //activity |
341 | break; | 344 | break; |
342 | case Key_F10: //contacts | 345 | case Key_F10: //contacts |
343 | break; | 346 | break; |
344 | case Key_F11: //menu | 347 | case Key_F11: //menu |
345 | break; | 348 | break; |
346 | case Key_F12: //home | 349 | case Key_F12: //home |
347 | qDebug("Blank here"); | 350 | qDebug("Blank here"); |
348 | // mediaPlayerState->toggleBlank(); | 351 | // mediaPlayerState->toggleBlank(); |
349 | break; | 352 | break; |
350 | case Key_F13: //mail | 353 | case Key_F13: //mail |
351 | qDebug("Blank here"); | 354 | qDebug("Blank here"); |
352 | // mediaPlayerState->toggleBlank(); | 355 | // mediaPlayerState->toggleBlank(); |
353 | break; | 356 | break; |
354 | } | 357 | } |
355 | } | 358 | } |
356 | 359 | ||
357 | void MediaPlayer::cleanUp() {// this happens on closing | 360 | void MediaPlayer::cleanUp() {// this happens on closing |
358 | Config cfg( "OpiePlayer" ); | 361 | Config cfg( "OpiePlayer" ); |
359 | mediaPlayerState->writeConfig( cfg ); | 362 | mediaPlayerState->writeConfig( cfg ); |
360 | playList->writeDefaultPlaylist( ); | 363 | playList->writeDefaultPlaylist( ); |
361 | 364 | ||
362 | // QPEApplication::grabKeyboard(); | 365 | // QPEApplication::grabKeyboard(); |
363 | // QPEApplication::ungrabKeyboard(); | 366 | // QPEApplication::ungrabKeyboard(); |
364 | } | 367 | } |