6 files changed, 68 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 8a3d3e0..5e91561 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,375 +1,376 @@ | |||
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 | 27 | ||
28 | 28 | ||
29 | #define FBIOBLANK 0x4611 | 29 | #define FBIOBLANK 0x4611 |
30 | 30 | ||
31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { | 32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
33 | 33 | ||
34 | audioUI = 0; | 34 | audioUI = 0; |
35 | videoUI = 0; | 35 | videoUI = 0; |
36 | xineControl = 0; | 36 | xineControl = 0; |
37 | recreateAudioAndVideoWidgets(); | 37 | recreateAudioAndVideoWidgets(); |
38 | 38 | ||
39 | fd=-1;fl=-1; | 39 | fd=-1;fl=-1; |
40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); | 40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
41 | 41 | ||
42 | qApp->processEvents(); | 42 | qApp->processEvents(); |
43 | // QPEApplication::grabKeyboard(); // EVIL | 43 | // QPEApplication::grabKeyboard(); // EVIL |
44 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 44 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
45 | 45 | ||
46 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 46 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
47 | 47 | ||
48 | // What is pauseCheck good for? (Simon) | 48 | // What is pauseCheck good for? (Simon) |
49 | // connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 49 | // connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
50 | 50 | ||
51 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 51 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
52 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 52 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
53 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 53 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
54 | 54 | ||
55 | volControl = new VolumeControl; | 55 | volControl = new VolumeControl; |
56 | Config cfg( "OpiePlayer" ); | 56 | Config cfg( "OpiePlayer" ); |
57 | cfg.setGroup("PlayList"); | 57 | cfg.setGroup("PlayList"); |
58 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 58 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
59 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 59 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
60 | } | 60 | } |
61 | 61 | ||
62 | MediaPlayer::~MediaPlayer() { | 62 | MediaPlayer::~MediaPlayer() { |
63 | delete xineControl; | 63 | delete xineControl; |
64 | delete audioUI; | 64 | delete audioUI; |
65 | delete videoUI; | 65 | delete videoUI; |
66 | delete volControl; | 66 | delete volControl; |
67 | } | 67 | } |
68 | 68 | ||
69 | void MediaPlayer::pauseCheck( bool b ) { | 69 | void MediaPlayer::pauseCheck( bool b ) { |
70 | if ( b && !mediaPlayerState.isPlaying() ) { | 70 | if ( b && !mediaPlayerState.isPlaying() ) { |
71 | mediaPlayerState.setPaused( FALSE ); | 71 | mediaPlayerState.setPaused( FALSE ); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | void MediaPlayer::play() { | 75 | void MediaPlayer::play() { |
76 | mediaPlayerState.setPlaying( FALSE ); | 76 | mediaPlayerState.setPlaying( FALSE ); |
77 | mediaPlayerState.setPlaying( TRUE ); | 77 | mediaPlayerState.setPlaying( TRUE ); |
78 | } | 78 | } |
79 | 79 | ||
80 | void MediaPlayer::setPlaying( bool play ) { | 80 | void MediaPlayer::setPlaying( bool play ) { |
81 | if ( !play ) { | 81 | if ( !play ) { |
82 | return; | 82 | return; |
83 | } | 83 | } |
84 | 84 | ||
85 | if ( mediaPlayerState.isPaused() ) { | 85 | if ( mediaPlayerState.isPaused() ) { |
86 | mediaPlayerState.setPaused( FALSE ); | 86 | mediaPlayerState.setPaused( FALSE ); |
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | 89 | ||
90 | QString tickerText, time, fileName; | 90 | QString tickerText, time, fileName; |
91 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { | 91 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { |
92 | //if playing in file list.. play in a different way | 92 | //if playing in file list.. play in a different way |
93 | // random and looping settings enabled causes problems here, | 93 | // random and looping settings enabled causes problems here, |
94 | // since there is no selected file in the playlist, but a selected file in the file list, | 94 | // since there is no selected file in the playlist, but a selected file in the file list, |
95 | // so we remember and shutoff | 95 | // so we remember and shutoff |
96 | l = mediaPlayerState.isLooping(); | 96 | l = mediaPlayerState.isLooping(); |
97 | if(l) { | 97 | if(l) { |
98 | mediaPlayerState.setLooping( false ); | 98 | mediaPlayerState.setLooping( false ); |
99 | } | 99 | } |
100 | r = mediaPlayerState.isShuffled(); | 100 | r = mediaPlayerState.isShuffled(); |
101 | mediaPlayerState.setShuffled( false ); | 101 | mediaPlayerState.setShuffled( false ); |
102 | } | 102 | } |
103 | 103 | ||
104 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 104 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
105 | fileName = playListEntry.name; | 105 | fileName = playListEntry.name; |
106 | xineControl->play( playListEntry.file ); | 106 | xineControl->play( playListEntry.file ); |
107 | 107 | ||
108 | long seconds = mediaPlayerState.length(); | 108 | long seconds = mediaPlayerState.length(); |
109 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 109 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
110 | 110 | ||
111 | if( fileName.left(4) == "http" ) { | 111 | if( fileName.left(4) == "http" ) { |
112 | fileName = QFileInfo( fileName ).baseName(); | 112 | fileName = QFileInfo( fileName ).baseName(); |
113 | if ( xineControl->getMetaInfo().isEmpty() ) { | 113 | if ( xineControl->getMetaInfo().isEmpty() ) { |
114 | tickerText = tr( " File: " ) + fileName; | 114 | tickerText = tr( " File: " ) + fileName; |
115 | } else { | 115 | } else { |
116 | tickerText = xineControl->getMetaInfo(); | 116 | tickerText = xineControl->getMetaInfo(); |
117 | } | 117 | } |
118 | } else { | 118 | } else { |
119 | if ( xineControl->getMetaInfo().isEmpty() ) { | 119 | if ( xineControl->getMetaInfo().isEmpty() ) { |
120 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 120 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
121 | } else { | 121 | } else { |
122 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 122 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | audioUI->setTickerText( tickerText ); | 125 | audioUI->setTickerText( tickerText ); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void MediaPlayer::prev() { | 129 | void MediaPlayer::prev() { |
130 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 130 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
131 | if ( playList.prev() ) { | 131 | if ( playList.prev() ) { |
132 | play(); | 132 | play(); |
133 | } else if ( mediaPlayerState.isLooping() ) { | 133 | } else if ( mediaPlayerState.isLooping() ) { |
134 | if ( playList.last() ) { | 134 | if ( playList.last() ) { |
135 | play(); | 135 | play(); |
136 | } | 136 | } |
137 | } else { | 137 | } else { |
138 | mediaPlayerState.setList(); | 138 | mediaPlayerState.setList(); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | void MediaPlayer::next() { | 144 | void MediaPlayer::next() { |
145 | 145 | ||
146 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 146 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
147 | if ( playList.next() ) { | 147 | if ( playList.next() ) { |
148 | play(); | 148 | play(); |
149 | } else if ( mediaPlayerState.isLooping() ) { | 149 | } else if ( mediaPlayerState.isLooping() ) { |
150 | if ( playList.first() ) { | 150 | if ( playList.first() ) { |
151 | play(); | 151 | play(); |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | mediaPlayerState.setList(); | 154 | mediaPlayerState.setList(); |
155 | } | 155 | } |
156 | } else { //if playing from file list, let's just stop | 156 | } else { //if playing from file list, let's just stop |
157 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 157 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
158 | mediaPlayerState.setPlaying(false); | 158 | mediaPlayerState.setPlaying(false); |
159 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 159 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
160 | if(l) mediaPlayerState.setLooping(l); | 160 | if(l) mediaPlayerState.setLooping(l); |
161 | if(r) mediaPlayerState.setShuffled(r); | 161 | if(r) mediaPlayerState.setShuffled(r); |
162 | } | 162 | } |
163 | qApp->processEvents(); | 163 | qApp->processEvents(); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | void MediaPlayer::startDecreasingVolume() { | 167 | void MediaPlayer::startDecreasingVolume() { |
168 | volumeDirection = -1; | 168 | volumeDirection = -1; |
169 | startTimer( 100 ); | 169 | startTimer( 100 ); |
170 | volControl->decVol(2); | 170 | volControl->decVol(2); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void MediaPlayer::startIncreasingVolume() { | 174 | void MediaPlayer::startIncreasingVolume() { |
175 | volumeDirection = +1; | 175 | volumeDirection = +1; |
176 | startTimer( 100 ); | 176 | startTimer( 100 ); |
177 | volControl->incVol(2); | 177 | volControl->incVol(2); |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | bool drawnOnScreenDisplay = FALSE; | 181 | bool drawnOnScreenDisplay = FALSE; |
182 | unsigned int onScreenDisplayVolume = 0; | 182 | unsigned int onScreenDisplayVolume = 0; |
183 | const int yoff = 110; | 183 | const int yoff = 110; |
184 | 184 | ||
185 | void MediaPlayer::stopChangingVolume() { | 185 | void MediaPlayer::stopChangingVolume() { |
186 | killTimers(); | 186 | killTimers(); |
187 | // Get rid of the on-screen display stuff | 187 | // Get rid of the on-screen display stuff |
188 | drawnOnScreenDisplay = FALSE; | 188 | drawnOnScreenDisplay = FALSE; |
189 | onScreenDisplayVolume = 0; | 189 | onScreenDisplayVolume = 0; |
190 | int w=0; | 190 | int w=0; |
191 | int h=0; | 191 | int h=0; |
192 | if( !xineControl->hasVideo() ) { | 192 | if( !xineControl->hasVideo() ) { |
193 | w = audioUI->width(); | 193 | w = audioUI->width(); |
194 | h = audioUI->height(); | 194 | h = audioUI->height(); |
195 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 195 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
196 | } else { | 196 | } else { |
197 | w = videoUI->width(); | 197 | w = videoUI->width(); |
198 | h = videoUI->height(); | 198 | h = videoUI->height(); |
199 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 199 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 204 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
205 | if ( volumeDirection == +1 ) { | 205 | if ( volumeDirection == +1 ) { |
206 | volControl->incVol( 2 ); | 206 | volControl->incVol( 2 ); |
207 | } else if ( volumeDirection == -1 ) { | 207 | } else if ( volumeDirection == -1 ) { |
208 | volControl->decVol( 2 ); | 208 | volControl->decVol( 2 ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | // TODO FIXME | 212 | // TODO FIXME |
213 | // huh?? | 213 | // huh?? |
214 | unsigned int v= 0; | 214 | unsigned int v= 0; |
215 | v = volControl->volume(); | 215 | v = volControl->volume(); |
216 | v = v / 10; | 216 | v = v / 10; |
217 | 217 | ||
218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | int w=0; int h=0; | 222 | int w=0; int h=0; |
223 | if( !xineControl->hasVideo() ) { | 223 | if( !xineControl->hasVideo() ) { |
224 | w = audioUI->width(); | 224 | w = audioUI->width(); |
225 | h = audioUI->height(); | 225 | h = audioUI->height(); |
226 | 226 | ||
227 | if ( drawnOnScreenDisplay ) { | 227 | if ( drawnOnScreenDisplay ) { |
228 | if ( onScreenDisplayVolume > v ) { | 228 | if ( onScreenDisplayVolume > v ) { |
229 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 229 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | drawnOnScreenDisplay = TRUE; | 232 | drawnOnScreenDisplay = TRUE; |
233 | onScreenDisplayVolume = v; | 233 | onScreenDisplayVolume = v; |
234 | QPainter p( audioUI ); | 234 | QPainter p( audioUI ); |
235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
237 | 237 | ||
238 | QFont f; | 238 | QFont f; |
239 | f.setPixelSize( 20 ); | 239 | f.setPixelSize( 20 ); |
240 | f.setBold( TRUE ); | 240 | f.setBold( TRUE ); |
241 | p.setFont( f ); | 241 | p.setFont( f ); |
242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
243 | 243 | ||
244 | for ( unsigned int i = 0; i < 10; i++ ) { | 244 | for ( unsigned int i = 0; i < 10; i++ ) { |
245 | if ( v > i ) { | 245 | if ( v > i ) { |
246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
247 | } else { | 247 | } else { |
248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } else { | 251 | } else { |
252 | w = videoUI->width(); | 252 | w = videoUI->width(); |
253 | h = videoUI->height(); | 253 | h = videoUI->height(); |
254 | 254 | ||
255 | if ( drawnOnScreenDisplay ) { | 255 | if ( drawnOnScreenDisplay ) { |
256 | if ( onScreenDisplayVolume > v ) { | 256 | if ( onScreenDisplayVolume > v ) { |
257 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 257 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | drawnOnScreenDisplay = TRUE; | 260 | drawnOnScreenDisplay = TRUE; |
261 | onScreenDisplayVolume = v; | 261 | onScreenDisplayVolume = v; |
262 | QPainter p( videoUI ); | 262 | QPainter p( videoUI ); |
263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
265 | 265 | ||
266 | QFont f; | 266 | QFont f; |
267 | f.setPixelSize( 20 ); | 267 | f.setPixelSize( 20 ); |
268 | f.setBold( TRUE ); | 268 | f.setBold( TRUE ); |
269 | p.setFont( f ); | 269 | p.setFont( f ); |
270 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 270 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
271 | 271 | ||
272 | for ( unsigned int i = 0; i < 10; i++ ) { | 272 | for ( unsigned int i = 0; i < 10; i++ ) { |
273 | if ( v > i ) { | 273 | if ( v > i ) { |
274 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 274 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
275 | } else { | 275 | } else { |
276 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 276 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void MediaPlayer::blank( bool b ) { | 283 | void MediaPlayer::blank( bool b ) { |
284 | fd=open("/dev/fb0",O_RDWR); | 284 | fd=open("/dev/fb0",O_RDWR); |
285 | #ifdef QT_QWS_EBX | 285 | #ifdef QT_QWS_EBX |
286 | fl= open( "/dev/fl", O_RDWR ); | 286 | fl= open( "/dev/fl", O_RDWR ); |
287 | #endif | 287 | #endif |
288 | if (fd != -1) { | 288 | if (fd != -1) { |
289 | if ( b ) { | 289 | if ( b ) { |
290 | qDebug("do blanking"); | 290 | qDebug("do blanking"); |
291 | #ifdef QT_QWS_EBX | 291 | #ifdef QT_QWS_EBX |
292 | ioctl( fd, FBIOBLANK, 1 ); | 292 | ioctl( fd, FBIOBLANK, 1 ); |
293 | if(fl !=-1) { | 293 | if(fl !=-1) { |
294 | ioctl( fl, 2 ); | 294 | ioctl( fl, 2 ); |
295 | ::close(fl); | 295 | ::close(fl); |
296 | } | 296 | } |
297 | #else | 297 | #else |
298 | ioctl( fd, FBIOBLANK, 3 ); | 298 | ioctl( fd, FBIOBLANK, 3 ); |
299 | #endif | 299 | #endif |
300 | isBlanked = TRUE; | 300 | isBlanked = TRUE; |
301 | } else { | 301 | } else { |
302 | qDebug("do unblanking"); | 302 | qDebug("do unblanking"); |
303 | ioctl( fd, FBIOBLANK, 0); | 303 | ioctl( fd, FBIOBLANK, 0); |
304 | #ifdef QT_QWS_EBX | 304 | #ifdef QT_QWS_EBX |
305 | if(fl != -1) { | 305 | if(fl != -1) { |
306 | ioctl( fl, 1); | 306 | ioctl( fl, 1); |
307 | ::close(fl); | 307 | ::close(fl); |
308 | } | 308 | } |
309 | #endif | 309 | #endif |
310 | isBlanked = FALSE; | 310 | isBlanked = FALSE; |
311 | } | 311 | } |
312 | close( fd ); | 312 | close( fd ); |
313 | } else { | 313 | } else { |
314 | qDebug("<< /dev/fb0 could not be opened >>"); | 314 | qDebug("<< /dev/fb0 could not be opened >>"); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 318 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
319 | switch ( e->key() ) { | 319 | switch ( e->key() ) { |
320 | ////////////////////////////// Zaurus keys | 320 | ////////////////////////////// Zaurus keys |
321 | case Key_Home: | 321 | case Key_Home: |
322 | break; | 322 | break; |
323 | case Key_F9: //activity | 323 | case Key_F9: //activity |
324 | break; | 324 | break; |
325 | case Key_F10: //contacts | 325 | case Key_F10: //contacts |
326 | break; | 326 | break; |
327 | case Key_F11: //menu | 327 | case Key_F11: //menu |
328 | break; | 328 | break; |
329 | case Key_F12: //home | 329 | case Key_F12: //home |
330 | qDebug("Blank here"); | 330 | qDebug("Blank here"); |
331 | // mediaPlayerState->toggleBlank(); | 331 | // mediaPlayerState->toggleBlank(); |
332 | break; | 332 | break; |
333 | case Key_F13: //mail | 333 | case Key_F13: //mail |
334 | qDebug("Blank here"); | 334 | qDebug("Blank here"); |
335 | // mediaPlayerState->toggleBlank(); | 335 | // mediaPlayerState->toggleBlank(); |
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | void MediaPlayer::cleanUp() {// this happens on closing | 340 | void MediaPlayer::cleanUp() {// this happens on closing |
341 | Config cfg( "OpiePlayer" ); | 341 | Config cfg( "OpiePlayer" ); |
342 | mediaPlayerState.writeConfig( cfg ); | 342 | mediaPlayerState.writeConfig( cfg ); |
343 | playList.writeDefaultPlaylist( ); | 343 | playList.writeDefaultPlaylist( ); |
344 | 344 | ||
345 | // QPEApplication::grabKeyboard(); | 345 | // QPEApplication::grabKeyboard(); |
346 | // QPEApplication::ungrabKeyboard(); | 346 | // QPEApplication::ungrabKeyboard(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void MediaPlayer::recreateAudioAndVideoWidgets() | 349 | void MediaPlayer::recreateAudioAndVideoWidgets() |
350 | { | 350 | { |
351 | delete xineControl; | 351 | delete xineControl; |
352 | delete audioUI; | 352 | delete audioUI; |
353 | delete videoUI; | 353 | delete videoUI; |
354 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 354 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
355 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 355 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
356 | 356 | ||
357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
361 | 361 | ||
362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
366 | 366 | ||
367 | xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); | 367 | xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); |
368 | mediaPlayerState.setBackendInitialized(); | ||
368 | } | 369 | } |
369 | 370 | ||
370 | void MediaPlayer::reloadSkins() | 371 | void MediaPlayer::reloadSkins() |
371 | { | 372 | { |
372 | audioUI->loadSkin(); | 373 | audioUI->loadSkin(); |
373 | videoUI->loadSkin(); | 374 | videoUI->loadSkin(); |
374 | } | 375 | } |
375 | 376 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 40fa1a4..d54d870 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,264 +1,277 @@ | |||
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 | ||
50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 50 | MediaPlayerState::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 | backendInitialized = false; | ||
56 | } | 57 | } |
57 | 58 | ||
58 | 59 | ||
59 | MediaPlayerState::~MediaPlayerState() { | 60 | MediaPlayerState::~MediaPlayerState() { |
60 | } | 61 | } |
61 | 62 | ||
62 | 63 | ||
63 | void MediaPlayerState::readConfig( Config& cfg ) { | 64 | void MediaPlayerState::readConfig( Config& cfg ) { |
64 | cfg.setGroup("Options"); | 65 | cfg.setGroup("Options"); |
65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); | 66 | fullscreen = cfg.readBoolEntry( "FullScreen" ); |
66 | scaled = cfg.readBoolEntry( "Scaling" ); | 67 | scaled = cfg.readBoolEntry( "Scaling" ); |
67 | looping = cfg.readBoolEntry( "Looping" ); | 68 | looping = cfg.readBoolEntry( "Looping" ); |
68 | shuffled = cfg.readBoolEntry( "Shuffle" ); | 69 | shuffled = cfg.readBoolEntry( "Shuffle" ); |
69 | videoGamma = cfg.readNumEntry( "VideoGamma" ); | 70 | videoGamma = cfg.readNumEntry( "VideoGamma" ); |
70 | playing = FALSE; | 71 | playing = FALSE; |
71 | streaming = FALSE; | 72 | streaming = FALSE; |
72 | paused = FALSE; | 73 | paused = FALSE; |
73 | curPosition = 0; | 74 | curPosition = 0; |
74 | curLength = 0; | 75 | curLength = 0; |
75 | m_displayType = MediaSelection; | 76 | m_displayType = MediaSelection; |
76 | } | 77 | } |
77 | 78 | ||
78 | 79 | ||
79 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 80 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
80 | cfg.setGroup( "Options" ); | 81 | cfg.setGroup( "Options" ); |
81 | cfg.writeEntry( "FullScreen", fullscreen ); | 82 | cfg.writeEntry( "FullScreen", fullscreen ); |
82 | cfg.writeEntry( "Scaling", scaled ); | 83 | cfg.writeEntry( "Scaling", scaled ); |
83 | cfg.writeEntry( "Looping", looping ); | 84 | cfg.writeEntry( "Looping", looping ); |
84 | cfg.writeEntry( "Shuffle", shuffled ); | 85 | cfg.writeEntry( "Shuffle", shuffled ); |
85 | cfg.writeEntry( "VideoGamma", videoGamma ); | 86 | cfg.writeEntry( "VideoGamma", videoGamma ); |
86 | } | 87 | } |
87 | 88 | ||
89 | bool MediaPlayerState::isInitialized() const | ||
90 | { | ||
91 | return backendInitialized; // for now, more to come (skin stuff) | ||
92 | } | ||
93 | |||
94 | void MediaPlayerState::setBackendInitialized() | ||
95 | { | ||
96 | assert( backendInitialized == false ); | ||
97 | backendInitialized = true; | ||
98 | emit initialized(); | ||
99 | } | ||
100 | |||
88 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const | 101 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const |
89 | { | 102 | { |
90 | return m_displayType; | 103 | return m_displayType; |
91 | } | 104 | } |
92 | 105 | ||
93 | // slots | 106 | // slots |
94 | void MediaPlayerState::setIsStreaming( bool b ) { | 107 | void MediaPlayerState::setIsStreaming( bool b ) { |
95 | streaming = b; | 108 | streaming = b; |
96 | } | 109 | } |
97 | 110 | ||
98 | void MediaPlayerState::setIsSeekable( bool b ) { | 111 | void MediaPlayerState::setIsSeekable( bool b ) { |
99 | seekable = b; | 112 | seekable = b; |
100 | emit isSeekableToggled(b); | 113 | emit isSeekableToggled(b); |
101 | } | 114 | } |
102 | 115 | ||
103 | 116 | ||
104 | void MediaPlayerState::setFullscreen( bool b ) { | 117 | void MediaPlayerState::setFullscreen( bool b ) { |
105 | if ( fullscreen == b ) { | 118 | if ( fullscreen == b ) { |
106 | return; | 119 | return; |
107 | } | 120 | } |
108 | fullscreen = b; | 121 | fullscreen = b; |
109 | emit fullscreenToggled(b); | 122 | emit fullscreenToggled(b); |
110 | } | 123 | } |
111 | 124 | ||
112 | 125 | ||
113 | void MediaPlayerState::setBlanked( bool b ) { | 126 | void MediaPlayerState::setBlanked( bool b ) { |
114 | if ( blanked == b ) { | 127 | if ( blanked == b ) { |
115 | return; | 128 | return; |
116 | } | 129 | } |
117 | blanked = b; | 130 | blanked = b; |
118 | emit blankToggled(b); | 131 | emit blankToggled(b); |
119 | } | 132 | } |
120 | 133 | ||
121 | 134 | ||
122 | void MediaPlayerState::setScaled( bool b ) { | 135 | void MediaPlayerState::setScaled( bool b ) { |
123 | if ( scaled == b ) { | 136 | if ( scaled == b ) { |
124 | return; | 137 | return; |
125 | } | 138 | } |
126 | scaled = b; | 139 | scaled = b; |
127 | emit scaledToggled(b); | 140 | emit scaledToggled(b); |
128 | } | 141 | } |
129 | 142 | ||
130 | void MediaPlayerState::setLooping( bool b ) { | 143 | void MediaPlayerState::setLooping( bool b ) { |
131 | if ( looping == b ) { | 144 | if ( looping == b ) { |
132 | return; | 145 | return; |
133 | } | 146 | } |
134 | looping = b; | 147 | looping = b; |
135 | emit loopingToggled(b); | 148 | emit loopingToggled(b); |
136 | } | 149 | } |
137 | 150 | ||
138 | void MediaPlayerState::setShuffled( bool b ) { | 151 | void MediaPlayerState::setShuffled( bool b ) { |
139 | if ( shuffled == b ) { | 152 | if ( shuffled == b ) { |
140 | return; | 153 | return; |
141 | } | 154 | } |
142 | shuffled = b; | 155 | shuffled = b; |
143 | emit shuffledToggled(b); | 156 | emit shuffledToggled(b); |
144 | } | 157 | } |
145 | 158 | ||
146 | void MediaPlayerState::setPaused( bool b ) { | 159 | void MediaPlayerState::setPaused( bool b ) { |
147 | if ( paused == b ) { | 160 | if ( paused == b ) { |
148 | paused = FALSE; | 161 | paused = FALSE; |
149 | emit pausedToggled(FALSE); | 162 | emit pausedToggled(FALSE); |
150 | return; | 163 | return; |
151 | } | 164 | } |
152 | paused = b; | 165 | paused = b; |
153 | emit pausedToggled(b); | 166 | emit pausedToggled(b); |
154 | } | 167 | } |
155 | 168 | ||
156 | void MediaPlayerState::setPlaying( bool b ) { | 169 | void MediaPlayerState::setPlaying( bool b ) { |
157 | if ( playing == b ) { | 170 | if ( playing == b ) { |
158 | return; | 171 | return; |
159 | } | 172 | } |
160 | playing = b; | 173 | playing = b; |
161 | stopped = !b; | 174 | stopped = !b; |
162 | emit playingToggled(b); | 175 | emit playingToggled(b); |
163 | } | 176 | } |
164 | 177 | ||
165 | void MediaPlayerState::setStopped( bool b ) { | 178 | void MediaPlayerState::setStopped( bool b ) { |
166 | if ( stopped == b ) { | 179 | if ( stopped == b ) { |
167 | return; | 180 | return; |
168 | } | 181 | } |
169 | stopped = b; | 182 | stopped = b; |
170 | emit stopToggled(b); | 183 | emit stopToggled(b); |
171 | } | 184 | } |
172 | 185 | ||
173 | void MediaPlayerState::setPosition( long p ) { | 186 | void MediaPlayerState::setPosition( long p ) { |
174 | if ( curPosition == p ) { | 187 | if ( curPosition == p ) { |
175 | return; | 188 | return; |
176 | } | 189 | } |
177 | curPosition = p; | 190 | curPosition = p; |
178 | emit positionChanged(p); | 191 | emit positionChanged(p); |
179 | } | 192 | } |
180 | 193 | ||
181 | void MediaPlayerState::updatePosition( long p ){ | 194 | void MediaPlayerState::updatePosition( long p ){ |
182 | if ( curPosition == p ) { | 195 | if ( curPosition == p ) { |
183 | return; | 196 | return; |
184 | } | 197 | } |
185 | curPosition = p; | 198 | curPosition = p; |
186 | emit positionUpdated(p); | 199 | emit positionUpdated(p); |
187 | } | 200 | } |
188 | 201 | ||
189 | void MediaPlayerState::setVideoGamma( int v ){ | 202 | void MediaPlayerState::setVideoGamma( int v ){ |
190 | if ( videoGamma == v ) { | 203 | if ( videoGamma == v ) { |
191 | return; | 204 | return; |
192 | } | 205 | } |
193 | videoGamma = v; | 206 | videoGamma = v; |
194 | emit videoGammaChanged( v ); | 207 | emit videoGammaChanged( v ); |
195 | } | 208 | } |
196 | 209 | ||
197 | void MediaPlayerState::setLength( long l ) { | 210 | void MediaPlayerState::setLength( long l ) { |
198 | if ( curLength == l ) { | 211 | if ( curLength == l ) { |
199 | return; | 212 | return; |
200 | } | 213 | } |
201 | curLength = l; | 214 | curLength = l; |
202 | emit lengthChanged(l); | 215 | emit lengthChanged(l); |
203 | } | 216 | } |
204 | 217 | ||
205 | void MediaPlayerState::setDisplayType( DisplayType displayType ) | 218 | void MediaPlayerState::setDisplayType( DisplayType displayType ) |
206 | { | 219 | { |
207 | if ( m_displayType == displayType ) | 220 | if ( m_displayType == displayType ) |
208 | return; | 221 | return; |
209 | 222 | ||
210 | m_displayType = displayType; | 223 | m_displayType = displayType; |
211 | emit displayTypeChanged( m_displayType ); | 224 | emit displayTypeChanged( m_displayType ); |
212 | } | 225 | } |
213 | 226 | ||
214 | void MediaPlayerState::setPrev(){ | 227 | void MediaPlayerState::setPrev(){ |
215 | emit prev(); | 228 | emit prev(); |
216 | } | 229 | } |
217 | 230 | ||
218 | void MediaPlayerState::setNext() { | 231 | void MediaPlayerState::setNext() { |
219 | emit next(); | 232 | emit next(); |
220 | } | 233 | } |
221 | 234 | ||
222 | void MediaPlayerState::setList() { | 235 | void MediaPlayerState::setList() { |
223 | setPlaying( FALSE ); | 236 | setPlaying( FALSE ); |
224 | setDisplayType( MediaSelection ); | 237 | setDisplayType( MediaSelection ); |
225 | } | 238 | } |
226 | 239 | ||
227 | void MediaPlayerState::setVideo() { | 240 | void MediaPlayerState::setVideo() { |
228 | setDisplayType( Video ); | 241 | setDisplayType( Video ); |
229 | } | 242 | } |
230 | 243 | ||
231 | void MediaPlayerState::setAudio() { | 244 | void MediaPlayerState::setAudio() { |
232 | setDisplayType( Audio ); | 245 | setDisplayType( Audio ); |
233 | } | 246 | } |
234 | 247 | ||
235 | void MediaPlayerState::toggleFullscreen() { | 248 | void MediaPlayerState::toggleFullscreen() { |
236 | setFullscreen( !fullscreen ); | 249 | setFullscreen( !fullscreen ); |
237 | } | 250 | } |
238 | 251 | ||
239 | void MediaPlayerState::toggleScaled() { | 252 | void MediaPlayerState::toggleScaled() { |
240 | setScaled( !scaled); | 253 | setScaled( !scaled); |
241 | } | 254 | } |
242 | 255 | ||
243 | void MediaPlayerState::toggleLooping() { | 256 | void MediaPlayerState::toggleLooping() { |
244 | setLooping( !looping); | 257 | setLooping( !looping); |
245 | } | 258 | } |
246 | 259 | ||
247 | void MediaPlayerState::toggleShuffled() { | 260 | void MediaPlayerState::toggleShuffled() { |
248 | setShuffled( !shuffled); | 261 | setShuffled( !shuffled); |
249 | } | 262 | } |
250 | 263 | ||
251 | void MediaPlayerState::togglePaused() { | 264 | void MediaPlayerState::togglePaused() { |
252 | setPaused( !paused); | 265 | setPaused( !paused); |
253 | } | 266 | } |
254 | 267 | ||
255 | void MediaPlayerState::togglePlaying() { | 268 | void MediaPlayerState::togglePlaying() { |
256 | setPlaying( !playing); | 269 | setPlaying( !playing); |
257 | } | 270 | } |
258 | 271 | ||
259 | void MediaPlayerState::toggleBlank() { | 272 | void MediaPlayerState::toggleBlank() { |
260 | setBlanked( !blanked); | 273 | setBlanked( !blanked); |
261 | } | 274 | } |
262 | 275 | ||
263 | 276 | ||
264 | 277 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index c887bb8..6fe6d76 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h | |||
@@ -1,141 +1,146 @@ | |||
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 | ||
43 | class MediaPlayerDecoder; | 43 | class MediaPlayerDecoder; |
44 | class Config; | 44 | class Config; |
45 | 45 | ||
46 | 46 | ||
47 | class MediaPlayerState : public QObject { | 47 | class MediaPlayerState : public QObject { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
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 | bool isInitialized() const; | ||
64 | long position() const { return curPosition; } | 65 | long position() const { return curPosition; } |
65 | long length() const { return curLength; } | 66 | long length() const { return curLength; } |
66 | DisplayType displayType() const; | 67 | DisplayType displayType() const; |
67 | 68 | ||
68 | public slots: | 69 | public slots: |
69 | void setIsStreaming( bool b ); | 70 | void setIsStreaming( bool b ); |
70 | void setIsSeekable( bool b ); | 71 | void setIsSeekable( bool b ); |
71 | void setFullscreen( bool b ); | 72 | void setFullscreen( bool b ); |
72 | void setScaled( bool b ); | 73 | void setScaled( bool b ); |
73 | void setLooping( bool b ); | 74 | void setLooping( bool b ); |
74 | void setShuffled( bool b ); | 75 | void setShuffled( bool b ); |
75 | void setPaused( bool b ); | 76 | void setPaused( bool b ); |
76 | void setPlaying( bool b ); | 77 | void setPlaying( bool b ); |
77 | void setStopped( bool b ); | 78 | void setStopped( bool b ); |
78 | void setPosition( long p ); | 79 | void setPosition( long p ); |
79 | void updatePosition( long p ); | 80 | void updatePosition( long p ); |
80 | void setLength( long l ); | 81 | void setLength( long l ); |
81 | void setDisplayType( MediaPlayerState::DisplayType displayType ); | 82 | void setDisplayType( MediaPlayerState::DisplayType displayType ); |
82 | void setBlanked( bool b ); | 83 | void setBlanked( bool b ); |
83 | void setVideoGamma( int v ); | 84 | void setVideoGamma( int v ); |
84 | 85 | ||
85 | void setPrev(); | 86 | void setPrev(); |
86 | void setNext(); | 87 | void setNext(); |
87 | void setList(); | 88 | void setList(); |
88 | void setVideo(); | 89 | void setVideo(); |
89 | void setAudio(); | 90 | void setAudio(); |
90 | 91 | ||
91 | void toggleFullscreen(); | 92 | void toggleFullscreen(); |
92 | void toggleScaled(); | 93 | void toggleScaled(); |
93 | void toggleLooping(); | 94 | void toggleLooping(); |
94 | void toggleShuffled(); | 95 | void toggleShuffled(); |
95 | void togglePaused(); | 96 | void togglePaused(); |
96 | void togglePlaying(); | 97 | void togglePlaying(); |
97 | void toggleBlank(); | 98 | void toggleBlank(); |
98 | void writeConfig( Config& cfg ) const; | 99 | void writeConfig( Config& cfg ) const; |
99 | 100 | ||
101 | void setBackendInitialized(); | ||
100 | 102 | ||
101 | signals: | 103 | signals: |
102 | void fullscreenToggled( bool ); | 104 | void fullscreenToggled( bool ); |
103 | void scaledToggled( bool ); | 105 | void scaledToggled( bool ); |
104 | void loopingToggled( bool ); | 106 | void loopingToggled( bool ); |
105 | void shuffledToggled( bool ); | 107 | void shuffledToggled( bool ); |
106 | void pausedToggled( bool ); | 108 | void pausedToggled( bool ); |
107 | void playingToggled( bool ); | 109 | void playingToggled( bool ); |
108 | void stopToggled( bool ); | 110 | void stopToggled( bool ); |
109 | void positionChanged( long ); // When the slider is moved | 111 | void positionChanged( long ); // When the slider is moved |
110 | void positionUpdated( long ); // When the media file progresses | 112 | void positionUpdated( long ); // When the media file progresses |
111 | void lengthChanged( long ); | 113 | void lengthChanged( long ); |
112 | void displayTypeChanged( MediaPlayerState::DisplayType type ); | 114 | void displayTypeChanged( MediaPlayerState::DisplayType type ); |
113 | void isSeekableToggled( bool ); | 115 | void isSeekableToggled( bool ); |
114 | void blankToggled( bool ); | 116 | void blankToggled( bool ); |
115 | void videoGammaChanged( int ); | 117 | void videoGammaChanged( int ); |
116 | void prev(); | 118 | void prev(); |
117 | void next(); | 119 | void next(); |
118 | 120 | ||
121 | void initialized(); | ||
122 | |||
119 | private: | 123 | private: |
120 | bool streaming : 1; | 124 | bool streaming : 1; |
121 | bool seekable : 1; | 125 | bool seekable : 1; |
122 | bool fullscreen: 1; | 126 | bool fullscreen: 1; |
123 | bool scaled : 1; | 127 | bool scaled : 1; |
124 | bool blanked : 1; | 128 | bool blanked : 1; |
125 | bool looping : 1; | 129 | bool looping : 1; |
126 | bool shuffled : 1; | 130 | bool shuffled : 1; |
127 | bool usePlaylist : 1; | 131 | bool usePlaylist : 1; |
128 | bool paused : 1; | 132 | bool paused : 1; |
129 | bool playing : 1; | 133 | bool playing : 1; |
130 | bool stopped : 1; | 134 | bool stopped : 1; |
135 | bool backendInitialized : 1; | ||
131 | long curPosition; | 136 | long curPosition; |
132 | long curLength; | 137 | long curLength; |
133 | DisplayType m_displayType; | 138 | DisplayType m_displayType; |
134 | int videoGamma; | 139 | int videoGamma; |
135 | void readConfig( Config& cfg ); | 140 | void readConfig( Config& cfg ); |
136 | 141 | ||
137 | }; | 142 | }; |
138 | 143 | ||
139 | 144 | ||
140 | #endif // MEDIA_PLAYER_STATE_H | 145 | #endif // MEDIA_PLAYER_STATE_H |
141 | 146 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index cba7b6d..8e4f56d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,665 +1,667 @@ | |||
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/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdatetime.h> | 41 | #include <qdatetime.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | #include "playlistselection.h" | 47 | #include "playlistselection.h" |
48 | #include "playlistwidget.h" | 48 | #include "playlistwidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "inputDialog.h" | 50 | #include "inputDialog.h" |
51 | #include "om3u.h" | 51 | #include "om3u.h" |
52 | #include "playlistfileview.h" | 52 | #include "playlistfileview.h" |
53 | 53 | ||
54 | //only needed for the random play | 54 | //only needed for the random play |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <assert.h> | 56 | #include <assert.h> |
57 | 57 | ||
58 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 58 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) | 59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) |
60 | { | 60 | { |
61 | 61 | ||
62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
63 | "opieplayer2/add_to_playlist", | 63 | "opieplayer2/add_to_playlist", |
64 | this , SLOT(addSelected() ) ); | 64 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
66 | "opieplayer2/remove_from_playlist", | 66 | "opieplayer2/remove_from_playlist", |
67 | this , SLOT(removeSelected() ) ); | 67 | this , SLOT(removeSelected() ) ); |
68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 68 | d->tbPlay = new PlayButton( mediaPlayerState, bar, tr( "Play" ), "opieplayer2/play", |
69 | this , SLOT( btnPlay( bool) ), TRUE ); | 69 | this , SLOT( btnPlay( bool) ), TRUE ); |
70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
73 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 73 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
74 | 74 | ||
75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
77 | this, SLOT( addAllMusicToList() ) ); | 77 | this, SLOT( addAllMusicToList() ) ); |
78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
79 | this, SLOT( addAllVideoToList() ) ); | 79 | this, SLOT( addAllVideoToList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
81 | this, SLOT( addAllToList() ) ); | 81 | this, SLOT( addAllToList() ) ); |
82 | pmPlayList->insertSeparator(-1); | 82 | pmPlayList->insertSeparator(-1); |
83 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 83 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
84 | // this, SLOT( saveList() ) ); | 84 | // this, SLOT( saveList() ) ); |
85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
86 | this, SLOT(writem3u() ) ); | 86 | this, SLOT(writem3u() ) ); |
87 | pmPlayList->insertSeparator(-1); | 87 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
89 | this,SLOT( openFile() ) ); | 89 | this,SLOT( openFile() ) ); |
90 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
92 | audioView, SLOT( scanFiles() ) ); | 92 | audioView, SLOT( scanFiles() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
94 | videoView, SLOT( scanFiles() ) ); | 94 | videoView, SLOT( scanFiles() ) ); |
95 | 95 | ||
96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
97 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 97 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
98 | 98 | ||
99 | Config cfg( "OpiePlayer" ); | 99 | Config cfg( "OpiePlayer" ); |
100 | bool b= cfg.readBoolEntry("FullScreen", 0); | 100 | bool b= cfg.readBoolEntry("FullScreen", 0); |
101 | mediaPlayerState.setFullscreen( b ); | 101 | mediaPlayerState.setFullscreen( b ); |
102 | pmView->setItemChecked( -16, b ); | 102 | pmView->setItemChecked( -16, b ); |
103 | 103 | ||
104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
107 | d->selectedFiles, SLOT(removeSelected() ) ); | 107 | d->selectedFiles, SLOT(removeSelected() ) ); |
108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
110 | // QVBox *stretch2 = new QVBox( vbox1 ); | 110 | // QVBox *stretch2 = new QVBox( vbox1 ); |
111 | 111 | ||
112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
113 | SLOT( deletePlaylist() ) ); | 113 | SLOT( deletePlaylist() ) ); |
114 | connect( pmView, SIGNAL( activated( int ) ), | 114 | connect( pmView, SIGNAL( activated( int ) ), |
115 | this, SLOT( pmViewActivated( int ) ) ); | 115 | this, SLOT( pmViewActivated( int ) ) ); |
116 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 116 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
117 | this, SLOT( skinsMenuActivated( int ) ) ); | 117 | this, SLOT( skinsMenuActivated( int ) ) ); |
118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
119 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 119 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
120 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 120 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
121 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 121 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
122 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 122 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
123 | this,SLOT( playIt( QListViewItem *) ) ); | 123 | this,SLOT( playIt( QListViewItem *) ) ); |
124 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 124 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
125 | this, SLOT( addToSelection( QListViewItem *) ) ); | 125 | this, SLOT( addToSelection( QListViewItem *) ) ); |
126 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 126 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
128 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 132 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
133 | this, SLOT( loadList( const DocLnk & ) ) ); | 133 | this, SLOT( loadList( const DocLnk & ) ) ); |
134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
135 | this, SLOT( tabChanged( QWidget* ) ) ); | 135 | this, SLOT( tabChanged( QWidget* ) ) ); |
136 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 136 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
137 | d->tbPlay, SLOT( setOn( bool ) ) ); | 137 | d->tbPlay, SLOT( setOn( bool ) ) ); |
138 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 138 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
139 | d->tbLoop, SLOT( setOn( bool ) ) ); | 139 | d->tbLoop, SLOT( setOn( bool ) ) ); |
140 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 140 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
141 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 141 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
142 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 142 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
143 | this, SLOT( playIt( QListViewItem *) ) ); | 143 | this, SLOT( playIt( QListViewItem *) ) ); |
144 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 144 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
145 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 145 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
146 | 146 | ||
147 | // see which skins are installed | 147 | // see which skins are installed |
148 | populateSkinsMenu(); | 148 | populateSkinsMenu(); |
149 | initializeStates(); | 149 | initializeStates(); |
150 | 150 | ||
151 | cfg.setGroup("PlayList"); | 151 | cfg.setGroup("PlayList"); |
152 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 152 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
153 | loadList(DocLnk( currentPlaylist ) ); | 153 | loadList(DocLnk( currentPlaylist ) ); |
154 | |||
155 | tabWidget->showPage( playListTab ); | ||
154 | } | 156 | } |
155 | 157 | ||
156 | 158 | ||
157 | PlayListWidget::~PlayListWidget() { | 159 | PlayListWidget::~PlayListWidget() { |
158 | delete d; | 160 | delete d; |
159 | } | 161 | } |
160 | 162 | ||
161 | 163 | ||
162 | void PlayListWidget::initializeStates() { | 164 | void PlayListWidget::initializeStates() { |
163 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 165 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
164 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 166 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
165 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 167 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
166 | d->playListFrame->show(); | 168 | d->playListFrame->show(); |
167 | } | 169 | } |
168 | 170 | ||
169 | void PlayListWidget::writeDefaultPlaylist() { | 171 | void PlayListWidget::writeDefaultPlaylist() { |
170 | 172 | ||
171 | Config config( "OpiePlayer" ); | 173 | Config config( "OpiePlayer" ); |
172 | config.setGroup( "PlayList" ); | 174 | config.setGroup( "PlayList" ); |
173 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 175 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
174 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 176 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
175 | if( currentString == filename) { | 177 | if( currentString == filename) { |
176 | Om3u *m3uList; | 178 | Om3u *m3uList; |
177 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 179 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
178 | if( d->selectedFiles->first() ) { | 180 | if( d->selectedFiles->first() ) { |
179 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 181 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
180 | do { | 182 | do { |
181 | // qDebug(d->selectedFiles->current()->file()); | 183 | // qDebug(d->selectedFiles->current()->file()); |
182 | m3uList->add( d->selectedFiles->current()->file() ); | 184 | m3uList->add( d->selectedFiles->current()->file() ); |
183 | } | 185 | } |
184 | while ( d->selectedFiles->next() ); | 186 | while ( d->selectedFiles->next() ); |
185 | 187 | ||
186 | m3uList->write(); | 188 | m3uList->write(); |
187 | m3uList->close(); | 189 | m3uList->close(); |
188 | delete m3uList; | 190 | delete m3uList; |
189 | 191 | ||
190 | } | 192 | } |
191 | } | 193 | } |
192 | } | 194 | } |
193 | 195 | ||
194 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 196 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
195 | d->setDocumentUsed = FALSE; | 197 | d->setDocumentUsed = FALSE; |
196 | if( QFileInfo( lnk.file() ).exists() || | 198 | if( QFileInfo( lnk.file() ).exists() || |
197 | lnk.file().left(4) == "http" ) { | 199 | lnk.file().left(4) == "http" ) { |
198 | d->selectedFiles->addToSelection( lnk ); | 200 | d->selectedFiles->addToSelection( lnk ); |
199 | } | 201 | } |
200 | // writeCurrentM3u(); | 202 | // writeCurrentM3u(); |
201 | } | 203 | } |
202 | 204 | ||
203 | 205 | ||
204 | void PlayListWidget::clearList() { | 206 | void PlayListWidget::clearList() { |
205 | while ( first() ) { | 207 | while ( first() ) { |
206 | d->selectedFiles->removeSelected(); | 208 | d->selectedFiles->removeSelected(); |
207 | } | 209 | } |
208 | Config cfg( "OpiePlayer" ); | 210 | Config cfg( "OpiePlayer" ); |
209 | cfg.setGroup("PlayList"); | 211 | cfg.setGroup("PlayList"); |
210 | cfg.writeEntry("CurrentPlaylist","default"); | 212 | cfg.writeEntry("CurrentPlaylist","default"); |
211 | setCaption("OpiePlayer"); | 213 | setCaption("OpiePlayer"); |
212 | } | 214 | } |
213 | 215 | ||
214 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
215 | switch (mouse) { | 217 | switch (mouse) { |
216 | case LeftButton: | 218 | case LeftButton: |
217 | break; | 219 | break; |
218 | case RightButton: | 220 | case RightButton: |
219 | { | 221 | { |
220 | QPopupMenu m; | 222 | QPopupMenu m; |
221 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
222 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
223 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
224 | } | 226 | } |
225 | break; | 227 | break; |
226 | } | 228 | } |
227 | } | 229 | } |
228 | 230 | ||
229 | 231 | ||
230 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
231 | switch (mouse) { | 233 | switch (mouse) { |
232 | case LeftButton: | 234 | case LeftButton: |
233 | break; | 235 | break; |
234 | case RightButton: | 236 | case RightButton: |
235 | { | 237 | { |
236 | QPopupMenu m; | 238 | QPopupMenu m; |
237 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
238 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
239 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
240 | } | 242 | } |
241 | break; | 243 | break; |
242 | } | 244 | } |
243 | } | 245 | } |
244 | 246 | ||
245 | 247 | ||
246 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
247 | 249 | ||
248 | // QTime t; | 250 | // QTime t; |
249 | // t.start(); | 251 | // t.start(); |
250 | 252 | ||
251 | audioView->populateView(); | 253 | audioView->populateView(); |
252 | 254 | ||
253 | QListViewItemIterator audioIt( audioView ); | 255 | QListViewItemIterator audioIt( audioView ); |
254 | DocLnk lnk; | 256 | DocLnk lnk; |
255 | QString filename; | 257 | QString filename; |
256 | // iterate through all items of the listview | 258 | // iterate through all items of the listview |
257 | for ( ; audioIt.current(); ++audioIt ) { | 259 | for ( ; audioIt.current(); ++audioIt ) { |
258 | filename = audioIt.current()->text(3); | 260 | filename = audioIt.current()->text(3); |
259 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
260 | lnk.setFile( filename ); //sets file name | 262 | lnk.setFile( filename ); //sets file name |
261 | d->selectedFiles->addToSelection( lnk); | 263 | d->selectedFiles->addToSelection( lnk); |
262 | } | 264 | } |
263 | 265 | ||
264 | videoView->populateView(); | 266 | videoView->populateView(); |
265 | 267 | ||
266 | QListViewItemIterator videoIt( videoView ); | 268 | QListViewItemIterator videoIt( videoView ); |
267 | for ( ; videoIt.current(); ++videoIt ) { | 269 | for ( ; videoIt.current(); ++videoIt ) { |
268 | filename = videoIt.current()->text(3); | 270 | filename = videoIt.current()->text(3); |
269 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
270 | lnk.setFile( filename ); //sets file name | 272 | lnk.setFile( filename ); //sets file name |
271 | d->selectedFiles->addToSelection( lnk); | 273 | d->selectedFiles->addToSelection( lnk); |
272 | } | 274 | } |
273 | 275 | ||
274 | // d->selectedFiles->addToSelection( ); | 276 | // d->selectedFiles->addToSelection( ); |
275 | // if ( it.current()->isSelected() ) | 277 | // if ( it.current()->isSelected() ) |
276 | // lst->append( audioIt.current() ); | 278 | // lst->append( audioIt.current() ); |
277 | // } | 279 | // } |
278 | 280 | ||
279 | 281 | ||
280 | // if(!audioScan) | 282 | // if(!audioScan) |
281 | // scanForAudio(); | 283 | // scanForAudio(); |
282 | // if(!videoScan) | 284 | // if(!videoScan) |
283 | // scanForVideo(); | 285 | // scanForVideo(); |
284 | 286 | ||
285 | // DocLnkSet filesAll; | 287 | // DocLnkSet filesAll; |
286 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
287 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 289 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
288 | // for ( ; Adit.current(); ++Adit ) { | 290 | // for ( ; Adit.current(); ++Adit ) { |
289 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
290 | // d->selectedFiles->addToSelection( **Adit ); | 292 | // d->selectedFiles->addToSelection( **Adit ); |
291 | // } | 293 | // } |
292 | // } | 294 | // } |
293 | 295 | ||
294 | // qDebug("elapsed time %d", t.elapsed() ); | 296 | // qDebug("elapsed time %d", t.elapsed() ); |
295 | 297 | ||
296 | tabWidget->setCurrentPage(0); | 298 | tabWidget->setCurrentPage(0); |
297 | 299 | ||
298 | writeCurrentM3u(); | 300 | writeCurrentM3u(); |
299 | d->selectedFiles->first(); | 301 | d->selectedFiles->first(); |
300 | } | 302 | } |
301 | 303 | ||
302 | 304 | ||
303 | void PlayListWidget::addAllMusicToList() { | 305 | void PlayListWidget::addAllMusicToList() { |
304 | 306 | ||
305 | audioView->populateView(); | 307 | audioView->populateView(); |
306 | 308 | ||
307 | QListViewItemIterator audioIt( audioView ); | 309 | QListViewItemIterator audioIt( audioView ); |
308 | DocLnk lnk; | 310 | DocLnk lnk; |
309 | QString filename; | 311 | QString filename; |
310 | // iterate through all items of the listview | 312 | // iterate through all items of the listview |
311 | for ( ; audioIt.current(); ++audioIt ) { | 313 | for ( ; audioIt.current(); ++audioIt ) { |
312 | filename = audioIt.current()->text(3); | 314 | filename = audioIt.current()->text(3); |
313 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
314 | lnk.setFile( filename ); //sets file name | 316 | lnk.setFile( filename ); //sets file name |
315 | d->selectedFiles->addToSelection( lnk); | 317 | d->selectedFiles->addToSelection( lnk); |
316 | } | 318 | } |
317 | 319 | ||
318 | /* if(!audioScan) | 320 | /* if(!audioScan) |
319 | scanForAudio(); | 321 | scanForAudio(); |
320 | QListIterator<DocLnk> dit( files.children() ); | 322 | QListIterator<DocLnk> dit( files.children() ); |
321 | for ( ; dit.current(); ++dit ) { | 323 | for ( ; dit.current(); ++dit ) { |
322 | if( QFileInfo(dit.current()->file() ).exists() ) { | 324 | if( QFileInfo(dit.current()->file() ).exists() ) { |
323 | d->selectedFiles->addToSelection( **dit ); | 325 | d->selectedFiles->addToSelection( **dit ); |
324 | } | 326 | } |
325 | } | 327 | } |
326 | */ | 328 | */ |
327 | tabWidget->setCurrentPage(0); | 329 | tabWidget->setCurrentPage(0); |
328 | writeCurrentM3u(); | 330 | writeCurrentM3u(); |
329 | d->selectedFiles->first(); | 331 | d->selectedFiles->first(); |
330 | } | 332 | } |
331 | 333 | ||
332 | 334 | ||
333 | void PlayListWidget::addAllVideoToList() { | 335 | void PlayListWidget::addAllVideoToList() { |
334 | 336 | ||
335 | videoView->populateView(); | 337 | videoView->populateView(); |
336 | 338 | ||
337 | QListViewItemIterator videoIt( videoView ); | 339 | QListViewItemIterator videoIt( videoView ); |
338 | DocLnk lnk; | 340 | DocLnk lnk; |
339 | QString filename; | 341 | QString filename; |
340 | for ( ; videoIt.current(); ++videoIt ) { | 342 | for ( ; videoIt.current(); ++videoIt ) { |
341 | filename = videoIt.current()->text(3); | 343 | filename = videoIt.current()->text(3); |
342 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
343 | lnk.setFile( filename ); //sets file name | 345 | lnk.setFile( filename ); //sets file name |
344 | d->selectedFiles->addToSelection( lnk); | 346 | d->selectedFiles->addToSelection( lnk); |
345 | } | 347 | } |
346 | 348 | ||
347 | 349 | ||
348 | /* if(!videoScan) | 350 | /* if(!videoScan) |
349 | scanForVideo(); | 351 | scanForVideo(); |
350 | QListIterator<DocLnk> dit( vFiles.children() ); | 352 | QListIterator<DocLnk> dit( vFiles.children() ); |
351 | for ( ; dit.current(); ++dit ) { | 353 | for ( ; dit.current(); ++dit ) { |
352 | if( QFileInfo( dit.current()->file() ).exists() ) { | 354 | if( QFileInfo( dit.current()->file() ).exists() ) { |
353 | d->selectedFiles->addToSelection( **dit ); | 355 | d->selectedFiles->addToSelection( **dit ); |
354 | } | 356 | } |
355 | } | 357 | } |
356 | */ | 358 | */ |
357 | tabWidget->setCurrentPage(0); | 359 | tabWidget->setCurrentPage(0); |
358 | writeCurrentM3u(); | 360 | writeCurrentM3u(); |
359 | d->selectedFiles->first(); | 361 | d->selectedFiles->first(); |
360 | } | 362 | } |
361 | 363 | ||
362 | 364 | ||
363 | void PlayListWidget::setDocument( const QString& fileref ) { | 365 | void PlayListWidget::setDocument( const QString& fileref ) { |
364 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
365 | fromSetDocument = TRUE; | 367 | fromSetDocument = TRUE; |
366 | if ( fileref.isNull() ) { | 368 | if ( fileref.isNull() ) { |
367 | QMessageBox::warning( this, tr( "Invalid File" ), | 369 | QMessageBox::warning( this, tr( "Invalid File" ), |
368 | tr( "There was a problem in getting the file." ) ); | 370 | tr( "There was a problem in getting the file." ) ); |
369 | return; | 371 | return; |
370 | } | 372 | } |
371 | 373 | ||
372 | clearList(); | 374 | clearList(); |
373 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 375 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
374 | readm3u( fileref ); | 376 | readm3u( fileref ); |
375 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 377 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
376 | readm3u( DocLnk( fileref).file() ); | 378 | readm3u( DocLnk( fileref).file() ); |
377 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 379 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
378 | readPls( fileref ); | 380 | readPls( fileref ); |
379 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 381 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
380 | readPls( DocLnk( fileref).file() ); | 382 | readPls( DocLnk( fileref).file() ); |
381 | } else { | 383 | } else { |
382 | clearList(); | 384 | clearList(); |
383 | addToSelection( DocLnk( fileref ) ); | 385 | addToSelection( DocLnk( fileref ) ); |
384 | writeCurrentM3u(); | 386 | writeCurrentM3u(); |
385 | 387 | ||
386 | d->setDocumentUsed = TRUE; | 388 | d->setDocumentUsed = TRUE; |
387 | mediaPlayerState.setPlaying( FALSE ); | 389 | mediaPlayerState.setPlaying( FALSE ); |
388 | mediaPlayerState.setPlaying( TRUE ); | 390 | mediaPlayerState.setPlaying( TRUE ); |
389 | } | 391 | } |
390 | } | 392 | } |
391 | 393 | ||
392 | 394 | ||
393 | void PlayListWidget::useSelectedDocument() { | 395 | void PlayListWidget::useSelectedDocument() { |
394 | d->setDocumentUsed = FALSE; | 396 | d->setDocumentUsed = FALSE; |
395 | } | 397 | } |
396 | 398 | ||
397 | 399 | ||
398 | const DocLnk *PlayListWidget::current() const { // this is fugly | 400 | const DocLnk *PlayListWidget::current() const { // this is fugly |
399 | assert( currentTab() == CurrentPlayList ); | 401 | assert( currentTab() == CurrentPlayList ); |
400 | 402 | ||
401 | const DocLnk *lnk = d->selectedFiles->current(); | 403 | const DocLnk *lnk = d->selectedFiles->current(); |
402 | if ( !lnk ) { | 404 | if ( !lnk ) { |
403 | d->selectedFiles->first(); | 405 | d->selectedFiles->first(); |
404 | lnk = d->selectedFiles->current(); | 406 | lnk = d->selectedFiles->current(); |
405 | } | 407 | } |
406 | assert( lnk ); | 408 | assert( lnk ); |
407 | return lnk; | 409 | return lnk; |
408 | } | 410 | } |
409 | 411 | ||
410 | 412 | ||
411 | bool PlayListWidget::prev() { | 413 | bool PlayListWidget::prev() { |
412 | if ( mediaPlayerState.isShuffled() ) { | 414 | if ( mediaPlayerState.isShuffled() ) { |
413 | const DocLnk *cur = current(); | 415 | const DocLnk *cur = current(); |
414 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 416 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
415 | for ( int i = 0; i < j; i++ ) { | 417 | for ( int i = 0; i < j; i++ ) { |
416 | if ( !d->selectedFiles->next() ) | 418 | if ( !d->selectedFiles->next() ) |
417 | d->selectedFiles->first(); | 419 | d->selectedFiles->first(); |
418 | } | 420 | } |
419 | if ( cur == current() ) | 421 | if ( cur == current() ) |
420 | if ( !d->selectedFiles->next() ) { | 422 | if ( !d->selectedFiles->next() ) { |
421 | d->selectedFiles->first(); | 423 | d->selectedFiles->first(); |
422 | } | 424 | } |
423 | return TRUE; | 425 | return TRUE; |
424 | } else { | 426 | } else { |
425 | if ( !d->selectedFiles->prev() ) { | 427 | if ( !d->selectedFiles->prev() ) { |
426 | if ( mediaPlayerState.isLooping() ) { | 428 | if ( mediaPlayerState.isLooping() ) { |
427 | return d->selectedFiles->last(); | 429 | return d->selectedFiles->last(); |
428 | } else { | 430 | } else { |
429 | return FALSE; | 431 | return FALSE; |
430 | } | 432 | } |
431 | } | 433 | } |
432 | return TRUE; | 434 | return TRUE; |
433 | } | 435 | } |
434 | } | 436 | } |
435 | 437 | ||
436 | 438 | ||
437 | bool PlayListWidget::next() { | 439 | bool PlayListWidget::next() { |
438 | //qDebug("<<<<<<<<<<<<next()"); | 440 | //qDebug("<<<<<<<<<<<<next()"); |
439 | if ( mediaPlayerState.isShuffled() ) { | 441 | if ( mediaPlayerState.isShuffled() ) { |
440 | return prev(); | 442 | return prev(); |
441 | } else { | 443 | } else { |
442 | if ( !d->selectedFiles->next() ) { | 444 | if ( !d->selectedFiles->next() ) { |
443 | if ( mediaPlayerState.isLooping() ) { | 445 | if ( mediaPlayerState.isLooping() ) { |
444 | return d->selectedFiles->first(); | 446 | return d->selectedFiles->first(); |
445 | } else { | 447 | } else { |
446 | return FALSE; | 448 | return FALSE; |
447 | } | 449 | } |
448 | } | 450 | } |
449 | return TRUE; | 451 | return TRUE; |
450 | } | 452 | } |
451 | } | 453 | } |
452 | 454 | ||
453 | 455 | ||
454 | bool PlayListWidget::first() { | 456 | bool PlayListWidget::first() { |
455 | return d->selectedFiles->first(); | 457 | return d->selectedFiles->first(); |
456 | } | 458 | } |
457 | 459 | ||
458 | 460 | ||
459 | bool PlayListWidget::last() { | 461 | bool PlayListWidget::last() { |
460 | return d->selectedFiles->last(); | 462 | return d->selectedFiles->last(); |
461 | } | 463 | } |
462 | 464 | ||
463 | 465 | ||
464 | void PlayListWidget::saveList() { | 466 | void PlayListWidget::saveList() { |
465 | writem3u(); | 467 | writem3u(); |
466 | } | 468 | } |
467 | 469 | ||
468 | 470 | ||
469 | void PlayListWidget::loadList( const DocLnk & lnk) { | 471 | void PlayListWidget::loadList( const DocLnk & lnk) { |
470 | QString name = lnk.name(); | 472 | QString name = lnk.name(); |
471 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 473 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
472 | 474 | ||
473 | if( name.length()>0) { | 475 | if( name.length()>0) { |
474 | setCaption("OpiePlayer: "+name); | 476 | setCaption("OpiePlayer: "+name); |
475 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 477 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
476 | clearList(); | 478 | clearList(); |
477 | readm3u(lnk.file()); | 479 | readm3u(lnk.file()); |
478 | tabWidget->setCurrentPage(0); | 480 | tabWidget->setCurrentPage(0); |
479 | } | 481 | } |
480 | } | 482 | } |
481 | 483 | ||
482 | void PlayListWidget::addSelected() { | 484 | void PlayListWidget::addSelected() { |
483 | assert( inFileListMode() ); | 485 | assert( inFileListMode() ); |
484 | 486 | ||
485 | QListViewItemIterator it( currentFileListView ); | 487 | QListViewItemIterator it( currentFileListView ); |
486 | for ( ; it.current(); ++it ) | 488 | for ( ; it.current(); ++it ) |
487 | if ( it.current()->isSelected() ) { | 489 | if ( it.current()->isSelected() ) { |
488 | QString filename = it.current()->text(3); | 490 | QString filename = it.current()->text(3); |
489 | 491 | ||
490 | DocLnk lnk; | 492 | DocLnk lnk; |
491 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 493 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
492 | lnk.setFile( filename ); //sets file name | 494 | lnk.setFile( filename ); //sets file name |
493 | 495 | ||
494 | d->selectedFiles->addToSelection( lnk ); | 496 | d->selectedFiles->addToSelection( lnk ); |
495 | } | 497 | } |
496 | 498 | ||
497 | currentFileListView->clearSelection(); | 499 | currentFileListView->clearSelection(); |
498 | 500 | ||
499 | // tabWidget->setCurrentPage( 0 ); | 501 | // tabWidget->setCurrentPage( 0 ); |
500 | writeCurrentM3u(); | 502 | writeCurrentM3u(); |
501 | } | 503 | } |
502 | 504 | ||
503 | 505 | ||
504 | void PlayListWidget::removeSelected() { | 506 | void PlayListWidget::removeSelected() { |
505 | d->selectedFiles->removeSelected( ); | 507 | d->selectedFiles->removeSelected( ); |
506 | writeCurrentM3u(); | 508 | writeCurrentM3u(); |
507 | } | 509 | } |
508 | 510 | ||
509 | 511 | ||
510 | void PlayListWidget::playIt( QListViewItem *it) { | 512 | void PlayListWidget::playIt( QListViewItem *it) { |
511 | if(!it) return; | 513 | if(!it) return; |
512 | mediaPlayerState.setPlaying(FALSE); | 514 | mediaPlayerState.setPlaying(FALSE); |
513 | mediaPlayerState.setPlaying(TRUE); | 515 | mediaPlayerState.setPlaying(TRUE); |
514 | d->selectedFiles->unSelect(); | 516 | d->selectedFiles->unSelect(); |
515 | } | 517 | } |
516 | 518 | ||
517 | 519 | ||
518 | void PlayListWidget::addToSelection( QListViewItem *it) { | 520 | void PlayListWidget::addToSelection( QListViewItem *it) { |
519 | d->setDocumentUsed = FALSE; | 521 | d->setDocumentUsed = FALSE; |
520 | 522 | ||
521 | if(it) { | 523 | if(it) { |
522 | if ( currentTab() == CurrentPlayList ) | 524 | if ( currentTab() == CurrentPlayList ) |
523 | return; | 525 | return; |
524 | // case 1: { | 526 | // case 1: { |
525 | DocLnk lnk; | 527 | DocLnk lnk; |
526 | QString filename; | 528 | QString filename; |
527 | 529 | ||
528 | filename=it->text(3); | 530 | filename=it->text(3); |
529 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 531 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
530 | lnk.setFile( filename ); //sets file name | 532 | lnk.setFile( filename ); //sets file name |
531 | d->selectedFiles->addToSelection( lnk); | 533 | d->selectedFiles->addToSelection( lnk); |
532 | 534 | ||
533 | writeCurrentM3u(); | 535 | writeCurrentM3u(); |
534 | // tabWidget->setCurrentPage(0); | 536 | // tabWidget->setCurrentPage(0); |
535 | 537 | ||
536 | } | 538 | } |
537 | } | 539 | } |
538 | 540 | ||
539 | 541 | ||
540 | void PlayListWidget::tabChanged(QWidget *) { | 542 | void PlayListWidget::tabChanged(QWidget *) { |
541 | 543 | ||
542 | d->tbPlay->setEnabled( true ); | 544 | d->tbPlay->setEnabled( true ); |
543 | 545 | ||
544 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), | 546 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), |
545 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 547 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
546 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), | 548 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), |
547 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 549 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
548 | 550 | ||
549 | currentFileListView = 0; | 551 | currentFileListView = 0; |
550 | 552 | ||
551 | switch ( currentTab() ) { | 553 | switch ( currentTab() ) { |
552 | case CurrentPlayList: | 554 | case CurrentPlayList: |
553 | { | 555 | { |
554 | if( !tbDeletePlaylist->isHidden() ) { | 556 | if( !tbDeletePlaylist->isHidden() ) { |
555 | tbDeletePlaylist->hide(); | 557 | tbDeletePlaylist->hide(); |
556 | } | 558 | } |
557 | d->tbRemoveFromList->setEnabled(TRUE); | 559 | d->tbRemoveFromList->setEnabled(TRUE); |
558 | d->tbAddToList->setEnabled(FALSE); | 560 | d->tbAddToList->setEnabled(FALSE); |
559 | 561 | ||
560 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 562 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
561 | } | 563 | } |
562 | break; | 564 | break; |
563 | case AudioFiles: | 565 | case AudioFiles: |
564 | { | 566 | { |
565 | audioView->populateView(); | 567 | audioView->populateView(); |
566 | 568 | ||
567 | if( !tbDeletePlaylist->isHidden() ) { | 569 | if( !tbDeletePlaylist->isHidden() ) { |
568 | tbDeletePlaylist->hide(); | 570 | tbDeletePlaylist->hide(); |
569 | } | 571 | } |
570 | d->tbRemoveFromList->setEnabled(FALSE); | 572 | d->tbRemoveFromList->setEnabled(FALSE); |
571 | d->tbAddToList->setEnabled(TRUE); | 573 | d->tbAddToList->setEnabled(TRUE); |
572 | 574 | ||
573 | connect( audioView, SIGNAL( itemsSelected( bool ) ), | 575 | connect( audioView, SIGNAL( itemsSelected( bool ) ), |
574 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 576 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
575 | 577 | ||
576 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 578 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
577 | 579 | ||
578 | currentFileListView = audioView; | 580 | currentFileListView = audioView; |
579 | } | 581 | } |
580 | break; | 582 | break; |
581 | case VideoFiles: | 583 | case VideoFiles: |
582 | { | 584 | { |
583 | videoView->populateView(); | 585 | videoView->populateView(); |
584 | if( !tbDeletePlaylist->isHidden() ) { | 586 | if( !tbDeletePlaylist->isHidden() ) { |
585 | tbDeletePlaylist->hide(); | 587 | tbDeletePlaylist->hide(); |
586 | } | 588 | } |
587 | d->tbRemoveFromList->setEnabled(FALSE); | 589 | d->tbRemoveFromList->setEnabled(FALSE); |
588 | d->tbAddToList->setEnabled(TRUE); | 590 | d->tbAddToList->setEnabled(TRUE); |
589 | 591 | ||
590 | connect( videoView, SIGNAL( itemsSelected( bool ) ), | 592 | connect( videoView, SIGNAL( itemsSelected( bool ) ), |
591 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 593 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
592 | 594 | ||
593 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 595 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
594 | 596 | ||
595 | currentFileListView = videoView; | 597 | currentFileListView = videoView; |
596 | } | 598 | } |
597 | break; | 599 | break; |
598 | case PlayLists: | 600 | case PlayLists: |
599 | { | 601 | { |
600 | if( tbDeletePlaylist->isHidden() ) { | 602 | if( tbDeletePlaylist->isHidden() ) { |
601 | tbDeletePlaylist->show(); | 603 | tbDeletePlaylist->show(); |
602 | } | 604 | } |
603 | playLists->reread(); | 605 | playLists->reread(); |
604 | d->tbAddToList->setEnabled(FALSE); | 606 | d->tbAddToList->setEnabled(FALSE); |
605 | 607 | ||
606 | d->tbPlay->setEnabled( false ); | 608 | d->tbPlay->setEnabled( false ); |
607 | } | 609 | } |
608 | break; | 610 | break; |
609 | }; | 611 | }; |
610 | } | 612 | } |
611 | 613 | ||
612 | 614 | ||
613 | void PlayListWidget::btnPlay(bool b) { | 615 | void PlayListWidget::btnPlay(bool b) { |
614 | // mediaPlayerState->setPlaying(false); | 616 | // mediaPlayerState->setPlaying(false); |
615 | mediaPlayerState.setPlaying(b); | 617 | mediaPlayerState.setPlaying(b); |
616 | insanityBool=FALSE; | 618 | insanityBool=FALSE; |
617 | } | 619 | } |
618 | 620 | ||
619 | void PlayListWidget::deletePlaylist() { | 621 | void PlayListWidget::deletePlaylist() { |
620 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
621 | (tr("You really want to delete\nthis playlist?")), | 623 | (tr("You really want to delete\nthis playlist?")), |
622 | (tr("Yes")), (tr("No")), 0 )){ | 624 | (tr("Yes")), (tr("No")), 0 )){ |
623 | case 0: // Yes clicked, | 625 | case 0: // Yes clicked, |
624 | QFile().remove(playLists->selectedDocument().file()); | 626 | QFile().remove(playLists->selectedDocument().file()); |
625 | QFile().remove(playLists->selectedDocument().linkFile()); | 627 | QFile().remove(playLists->selectedDocument().linkFile()); |
626 | playLists->reread(); | 628 | playLists->reread(); |
627 | break; | 629 | break; |
628 | case 1: // Cancel | 630 | case 1: // Cancel |
629 | break; | 631 | break; |
630 | }; | 632 | }; |
631 | } | 633 | } |
632 | 634 | ||
633 | 635 | ||
634 | void PlayListWidget::playSelected() { | 636 | void PlayListWidget::playSelected() { |
635 | btnPlay( TRUE); | 637 | btnPlay( TRUE); |
636 | } | 638 | } |
637 | 639 | ||
638 | bool PlayListWidget::inFileListMode() const | 640 | bool PlayListWidget::inFileListMode() const |
639 | { | 641 | { |
640 | TabType tab = currentTab(); | 642 | TabType tab = currentTab(); |
641 | return tab == AudioFiles || tab == VideoFiles; | 643 | return tab == AudioFiles || tab == VideoFiles; |
642 | } | 644 | } |
643 | 645 | ||
644 | void PlayListWidget::openFile() { | 646 | void PlayListWidget::openFile() { |
645 | // http://66.28.164.33:2080 | 647 | // http://66.28.164.33:2080 |
646 | // http://somafm.com/star0242.m3u | 648 | // http://somafm.com/star0242.m3u |
647 | QString filename, name; | 649 | QString filename, name; |
648 | InputDialog *fileDlg; | 650 | InputDialog *fileDlg; |
649 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 651 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
650 | fileDlg->exec(); | 652 | fileDlg->exec(); |
651 | if( fileDlg->result() == 1 ) { | 653 | if( fileDlg->result() == 1 ) { |
652 | filename = fileDlg->text(); | 654 | filename = fileDlg->text(); |
653 | qDebug( "Selected filename is " + filename ); | 655 | qDebug( "Selected filename is " + filename ); |
654 | // Om3u *m3uList; | 656 | // Om3u *m3uList; |
655 | DocLnk lnk; | 657 | DocLnk lnk; |
656 | Config cfg( "OpiePlayer" ); | 658 | Config cfg( "OpiePlayer" ); |
657 | cfg.setGroup("PlayList"); | 659 | cfg.setGroup("PlayList"); |
658 | 660 | ||
659 | if(filename.left(4) == "http") { | 661 | if(filename.left(4) == "http") { |
660 | QString m3uFile, m3uFilePath; | 662 | QString m3uFile, m3uFilePath; |
661 | if(filename.find(":",8,TRUE) != -1) { //found a port | 663 | if(filename.find(":",8,TRUE) != -1) { //found a port |
662 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 664 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
663 | m3uFile = m3uFile.right( 7); | 665 | m3uFile = m3uFile.right( 7); |
664 | } else if(filename.left(4) == "http"){ | 666 | } else if(filename.left(4) == "http"){ |
665 | m3uFile=filename; | 667 | m3uFile=filename; |
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index 5886458..23b7a70 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -1,206 +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 | #include "playlistfileview.h" | 54 | #include "playlistfileview.h" |
55 | 55 | ||
56 | //only needed for the random play | 56 | //only needed for the random play |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | 58 | ||
59 | #include "mediaplayerstate.h" | 59 | #include "mediaplayerstate.h" |
60 | 60 | ||
61 | PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) | 61 | PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) |
62 | : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { | 62 | : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { |
63 | 63 | ||
64 | d = new PlayListWidgetPrivate; | 64 | d = new PlayListWidgetPrivate; |
65 | d->setDocumentUsed = FALSE; | 65 | d->setDocumentUsed = FALSE; |
66 | 66 | ||
67 | setBackgroundMode( PaletteButton ); | 67 | setBackgroundMode( PaletteButton ); |
68 | setToolBarsMovable( FALSE ); | 68 | setToolBarsMovable( FALSE ); |
69 | 69 | ||
70 | // Create Toolbar | 70 | // Create Toolbar |
71 | QPEToolBar *toolbar = new QPEToolBar( this ); | 71 | QPEToolBar *toolbar = new QPEToolBar( this ); |
72 | toolbar->setHorizontalStretchable( TRUE ); | 72 | toolbar->setHorizontalStretchable( TRUE ); |
73 | 73 | ||
74 | // Create Menubar | 74 | // Create Menubar |
75 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 75 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
76 | menu->setMargin( 0 ); | 76 | menu->setMargin( 0 ); |
77 | 77 | ||
78 | bar = new QPEToolBar( this ); | 78 | bar = new QPEToolBar( this ); |
79 | bar->setLabel( tr( "Play Operations" ) ); | 79 | bar->setLabel( tr( "Play Operations" ) ); |
80 | 80 | ||
81 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | 81 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); |
82 | tbDeletePlaylist->setFlat( TRUE ); | 82 | tbDeletePlaylist->setFlat( TRUE ); |
83 | tbDeletePlaylist->setFixedSize( 20, 20 ); | 83 | tbDeletePlaylist->setFixedSize( 20, 20 ); |
84 | 84 | ||
85 | tbDeletePlaylist->hide(); | 85 | tbDeletePlaylist->hide(); |
86 | 86 | ||
87 | pmPlayList = new QPopupMenu( this ); | 87 | pmPlayList = new QPopupMenu( this ); |
88 | menu->insertItem( tr( "File" ), pmPlayList ); | 88 | menu->insertItem( tr( "File" ), pmPlayList ); |
89 | 89 | ||
90 | pmView = new QPopupMenu( this ); | 90 | pmView = new QPopupMenu( this ); |
91 | menu->insertItem( tr( "View" ), pmView ); | 91 | menu->insertItem( tr( "View" ), pmView ); |
92 | pmView->isCheckable(); | 92 | pmView->isCheckable(); |
93 | 93 | ||
94 | skinsMenu = new QPopupMenu( this ); | 94 | skinsMenu = new QPopupMenu( this ); |
95 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 95 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
96 | skinsMenu->isCheckable(); | 96 | skinsMenu->isCheckable(); |
97 | 97 | ||
98 | gammaMenu = new QPopupMenu( this ); | 98 | gammaMenu = new QPopupMenu( this ); |
99 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); | 99 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); |
100 | 100 | ||
101 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); | 101 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); |
102 | gammaSlider->setRange( -40, 40 ); | 102 | gammaSlider->setRange( -40, 40 ); |
103 | gammaSlider->setTickmarks( QSlider::Left ); | 103 | gammaSlider->setTickmarks( QSlider::Left ); |
104 | gammaSlider->setTickInterval( 20 ); | 104 | gammaSlider->setTickInterval( 20 ); |
105 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); | 105 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); |
106 | gammaSlider->setValue( 0 ); | 106 | gammaSlider->setValue( 0 ); |
107 | gammaSlider->setMinimumHeight( 50 ); | 107 | gammaSlider->setMinimumHeight( 50 ); |
108 | 108 | ||
109 | gammaLCD = new QLCDNumber( 3, gammaMenu ); | 109 | gammaLCD = new QLCDNumber( 3, gammaMenu ); |
110 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); | 110 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); |
111 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); | 111 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); |
112 | 112 | ||
113 | gammaMenu->insertItem( gammaSlider ); | 113 | gammaMenu->insertItem( gammaSlider ); |
114 | gammaMenu->insertItem( gammaLCD ); | 114 | gammaMenu->insertItem( gammaLCD ); |
115 | 115 | ||
116 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); | 116 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); |
117 | 117 | ||
118 | vbox5 = new QVBox( this ); | 118 | vbox5 = new QVBox( this ); |
119 | QVBox *vbox4 = new QVBox( vbox5 ); | 119 | QVBox *vbox4 = new QVBox( vbox5 ); |
120 | QHBox *hbox6 = new QHBox( vbox4 ); | 120 | QHBox *hbox6 = new QHBox( vbox4 ); |
121 | 121 | ||
122 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 122 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
123 | 123 | ||
124 | QWidget *pTab; | 124 | playListTab = new QWidget( tabWidget, "PlayListTab" ); |
125 | pTab = new QWidget( tabWidget, "pTab" ); | 125 | tabWidget->insertTab( playListTab, "Playlist"); |
126 | tabWidget->insertTab( pTab, "Playlist"); | ||
127 | 126 | ||
128 | QGridLayout *Playout = new QGridLayout( pTab ); | 127 | QGridLayout *Playout = new QGridLayout( playListTab ); |
129 | Playout->setSpacing( 2); | 128 | Playout->setSpacing( 2); |
130 | Playout->setMargin( 2); | 129 | Playout->setMargin( 2); |
131 | 130 | ||
132 | // Add the playlist area | 131 | // Add the playlist area |
133 | QVBox *vbox3 = new QVBox( pTab ); | 132 | QVBox *vbox3 = new QVBox( playListTab ); |
134 | d->playListFrame = vbox3; | 133 | d->playListFrame = vbox3; |
135 | 134 | ||
136 | QHBox *hbox2 = new QHBox( vbox3 ); | 135 | QHBox *hbox2 = new QHBox( vbox3 ); |
137 | d->selectedFiles = new PlayListSelection( hbox2 ); | 136 | d->selectedFiles = new PlayListSelection( hbox2 ); |
138 | 137 | ||
139 | vbox1 = new QVBox( hbox2 ); | 138 | vbox1 = new QVBox( hbox2 ); |
140 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | 139 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); |
141 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | 140 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch |
142 | 141 | ||
143 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 142 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
144 | 143 | ||
145 | QWidget *aTab; | 144 | QWidget *aTab; |
146 | aTab = new QWidget( tabWidget, "aTab" ); | 145 | aTab = new QWidget( tabWidget, "aTab" ); |
147 | 146 | ||
148 | QGridLayout *Alayout = new QGridLayout( aTab ); | 147 | QGridLayout *Alayout = new QGridLayout( aTab ); |
149 | Alayout->setSpacing( 2 ); | 148 | Alayout->setSpacing( 2 ); |
150 | Alayout->setMargin( 2 ); | 149 | Alayout->setMargin( 2 ); |
151 | // no m3u's here please | 150 | // no m3u's here please |
152 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", "opieplayer2/musicfile", aTab, "Audioview" ); | 151 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", "opieplayer2/musicfile", aTab, "Audioview" ); |
153 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 152 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
154 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 153 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
155 | 154 | ||
156 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 155 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
157 | 156 | ||
158 | QWidget *vTab; | 157 | QWidget *vTab; |
159 | vTab = new QWidget( tabWidget, "vTab" ); | 158 | vTab = new QWidget( tabWidget, "vTab" ); |
160 | 159 | ||
161 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 160 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
162 | Vlayout->setSpacing( 2 ); | 161 | Vlayout->setSpacing( 2 ); |
163 | Vlayout->setMargin( 2 ); | 162 | Vlayout->setMargin( 2 ); |
164 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); | 163 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); |
165 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 164 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
166 | 165 | ||
167 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 166 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
168 | 167 | ||
169 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 168 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
170 | 169 | ||
171 | //playlists list | 170 | //playlists list |
172 | QWidget *LTab; | 171 | QWidget *LTab; |
173 | LTab = new QWidget( tabWidget, "LTab" ); | 172 | LTab = new QWidget( tabWidget, "LTab" ); |
174 | QGridLayout *Llayout = new QGridLayout( LTab ); | 173 | QGridLayout *Llayout = new QGridLayout( LTab ); |
175 | Llayout->setSpacing( 2 ); | 174 | Llayout->setSpacing( 2 ); |
176 | Llayout->setMargin( 2 ); | 175 | Llayout->setMargin( 2 ); |
177 | 176 | ||
178 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); | 177 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); |
179 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 178 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
180 | 179 | ||
181 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 180 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
182 | 181 | ||
183 | setCentralWidget( vbox5 ); | 182 | setCentralWidget( vbox5 ); |
184 | } | 183 | } |
185 | 184 | ||
186 | 185 | ||
187 | 186 | ||
188 | PlayListWidgetGui::~PlayListWidgetGui() { | 187 | PlayListWidgetGui::~PlayListWidgetGui() { |
189 | } | 188 | } |
190 | 189 | ||
191 | void PlayListWidgetGui::setView( char view ) { | 190 | void PlayListWidgetGui::setView( char view ) { |
192 | if ( view == 'l' ) | 191 | if ( view == 'l' ) |
193 | showMaximized(); | 192 | showMaximized(); |
194 | else | 193 | else |
195 | hide(); | 194 | hide(); |
196 | } | 195 | } |
197 | 196 | ||
198 | 197 | ||
199 | void PlayListWidgetGui::setActiveWindow() { | 198 | void PlayListWidgetGui::setActiveWindow() { |
200 | // qDebug("SETTING active window"); | 199 | // qDebug("SETTING active window"); |
201 | // When we get raised we need to ensure that it switches views | 200 | // When we get raised we need to ensure that it switches views |
202 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); | 201 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); |
203 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate | 202 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate |
204 | mediaPlayerState.setDisplayType( origDisplayType ); // now switch back | 203 | mediaPlayerState.setDisplayType( origDisplayType ); // now switch back |
205 | } | 204 | } |
206 | 205 | ||
206 | PlayButton::PlayButton( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name, | ||
207 | const QString &icon, QObject *handler, const QString &slot, bool t ) | ||
208 | : ToolButton( parent, name, icon, handler, slot, t ), mediaPlayerState( _mediaPlayerState ), | ||
209 | m_lastEnableStatus( true ) | ||
210 | { | ||
211 | connect( &mediaPlayerState, SIGNAL( initialized() ), | ||
212 | this, SLOT( checkInitializationStatus() ) ); | ||
213 | } | ||
214 | |||
215 | void PlayButton::setEnabled( bool enable ) | ||
216 | { | ||
217 | m_lastEnableStatus = enable; | ||
218 | |||
219 | enable &= mediaPlayerState.isInitialized(); | ||
220 | |||
221 | ToolButton::setEnabled( enable ); | ||
222 | } | ||
223 | |||
224 | void PlayButton::checkInitializationStatus() | ||
225 | { | ||
226 | setEnabled( m_lastEnableStatus ); | ||
227 | } | ||
228 | |||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h index 0d8af43..1aa8ac8 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h | |||
@@ -1,132 +1,151 @@ | |||
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 | #ifndef PLAY_LIST_WIDGET_GUI_H | 34 | #ifndef PLAY_LIST_WIDGET_GUI_H |
35 | #define PLAY_LIST_WIDGET_GUI_H | 35 | #define PLAY_LIST_WIDGET_GUI_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/qpemenubar.h> | 40 | #include <qpe/qpemenubar.h> |
41 | 41 | ||
42 | #include <qtabwidget.h> | 42 | #include <qtabwidget.h> |
43 | #include <qpe/fileselector.h> | 43 | #include <qpe/fileselector.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qslider.h> | 47 | #include <qslider.h> |
48 | #include <qlcdnumber.h> | 48 | #include <qlcdnumber.h> |
49 | 49 | ||
50 | class PlayListWidgetPrivate; | 50 | class PlayListWidgetPrivate; |
51 | class PlayListSelection; | 51 | class PlayListSelection; |
52 | class MediaPlayerState; | 52 | class MediaPlayerState; |
53 | class PlayListFileView; | 53 | class PlayListFileView; |
54 | 54 | ||
55 | class Config; | 55 | class Config; |
56 | class QPEToolBar; | 56 | class QPEToolBar; |
57 | class QListViewItem; | 57 | class QListViewItem; |
58 | class QListView; | 58 | class QListView; |
59 | class QPoint; | 59 | class QPoint; |
60 | class QAction; | 60 | class QAction; |
61 | class QLabel; | 61 | class QLabel; |
62 | 62 | ||
63 | class PlayListWidgetPrivate { | 63 | class PlayListWidgetPrivate { |
64 | public: | 64 | public: |
65 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 65 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
66 | QFrame *playListFrame; | 66 | QFrame *playListFrame; |
67 | PlayListSelection *selectedFiles; | 67 | PlayListSelection *selectedFiles; |
68 | bool setDocumentUsed; | 68 | bool setDocumentUsed; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | class ToolButton : public QToolButton { | 72 | class ToolButton : public QToolButton { |
73 | Q_OBJECT | ||
73 | public: | 74 | public: |
74 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 75 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
75 | : QToolButton( parent, name ) { | 76 | : QToolButton( parent, name ) { |
76 | setTextLabel( name ); | 77 | setTextLabel( name ); |
77 | setPixmap( Resource::loadPixmap( icon ) ); | 78 | setPixmap( Resource::loadPixmap( icon ) ); |
78 | setAutoRaise( TRUE ); | 79 | setAutoRaise( TRUE ); |
79 | setFocusPolicy( QWidget::NoFocus ); | 80 | setFocusPolicy( QWidget::NoFocus ); |
80 | setToggleButton( t ); | 81 | setToggleButton( t ); |
81 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 82 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
82 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 83 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
83 | } | 84 | } |
84 | }; | 85 | }; |
85 | 86 | ||
87 | class PlayButton : public ToolButton | ||
88 | { | ||
89 | Q_OBJECT | ||
90 | public: | ||
91 | PlayButton( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name, | ||
92 | const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ); | ||
93 | |||
94 | protected: | ||
95 | virtual void setEnabled( bool enable ); | ||
96 | |||
97 | private slots: | ||
98 | void checkInitializationStatus(); | ||
99 | |||
100 | private: | ||
101 | MediaPlayerState &mediaPlayerState; | ||
102 | bool m_lastEnableStatus : 1; | ||
103 | }; | ||
86 | 104 | ||
87 | class MenuItem : public QAction { | 105 | class MenuItem : public QAction { |
88 | 106 | ||
89 | public: | 107 | public: |
90 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 108 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
91 | : QAction( text, QString::null, 0, 0 ) { | 109 | : QAction( text, QString::null, 0, 0 ) { |
92 | connect( this, SIGNAL( activated() ), handler, slot ); | 110 | connect( this, SIGNAL( activated() ), handler, slot ); |
93 | addTo( parent ); | 111 | addTo( parent ); |
94 | } | 112 | } |
95 | }; | 113 | }; |
96 | 114 | ||
97 | class PlayListWidgetGui : public QMainWindow { | 115 | class PlayListWidgetGui : public QMainWindow { |
98 | Q_OBJECT | 116 | Q_OBJECT |
99 | public: | 117 | public: |
100 | PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 118 | PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
101 | ~PlayListWidgetGui(); | 119 | ~PlayListWidgetGui(); |
102 | 120 | ||
103 | protected: | 121 | protected: |
104 | QTabWidget * tabWidget; | 122 | QTabWidget * tabWidget; |
105 | PlayListFileView *audioView, *videoView; | 123 | PlayListFileView *audioView, *videoView; |
106 | QListView *playlistView; | 124 | QListView *playlistView; |
107 | QLabel *libString; | 125 | QLabel *libString; |
108 | QPopupMenu *pmView ; | 126 | QPopupMenu *pmView ; |
109 | QPopupMenu *gammaMenu; | 127 | QPopupMenu *gammaMenu; |
110 | QSlider *gammaSlider; | 128 | QSlider *gammaSlider; |
111 | QLCDNumber *gammaLCD; | 129 | QLCDNumber *gammaLCD; |
112 | bool fromSetDocument; | 130 | bool fromSetDocument; |
113 | bool insanityBool; | 131 | bool insanityBool; |
114 | QString setDocFileRef; | 132 | QString setDocFileRef; |
115 | // retrieve the current playlist entry (media file link) | 133 | // retrieve the current playlist entry (media file link) |
116 | QPushButton *tbDeletePlaylist; | 134 | QPushButton *tbDeletePlaylist; |
117 | int selected; | 135 | int selected; |
118 | QPopupMenu *pmPlayList; | 136 | QPopupMenu *pmPlayList; |
119 | FileSelector* playLists; | 137 | FileSelector* playLists; |
120 | QPopupMenu *skinsMenu; | 138 | QPopupMenu *skinsMenu; |
121 | PlayListWidgetPrivate *d; // Private implementation data | 139 | PlayListWidgetPrivate *d; // Private implementation data |
122 | QVBox *vbox1; | 140 | QVBox *vbox1; |
123 | QVBox *vbox5; | 141 | QVBox *vbox5; |
124 | QPEToolBar *bar; | 142 | QPEToolBar *bar; |
143 | QWidget *playListTab; | ||
125 | void setActiveWindow(); // need to handle this to show the right view | 144 | void setActiveWindow(); // need to handle this to show the right view |
126 | void setView( char ); | 145 | void setView( char ); |
127 | 146 | ||
128 | MediaPlayerState &mediaPlayerState; | 147 | MediaPlayerState &mediaPlayerState; |
129 | }; | 148 | }; |
130 | 149 | ||
131 | #endif | 150 | #endif |
132 | 151 | ||