-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 172 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 36 |
2 files changed, 131 insertions, 77 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index db6533a..3b8f6d7 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,48 +1,51 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | ||
22 | |||
21 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/fileselector.h> | 25 | #include <qpe/fileselector.h> |
24 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/lnkproperties.h> | ||
25 | 28 | ||
26 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
27 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
28 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
29 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
30 | #include <qaction.h> | 33 | #include <qaction.h> |
31 | #include <qimage.h> | 34 | #include <qimage.h> |
32 | #include <qfile.h> | 35 | #include <qfile.h> |
33 | #include <qdir.h> | 36 | #include <qdir.h> |
34 | #include <qlayout.h> | 37 | #include <qlayout.h> |
35 | #include <qlabel.h> | 38 | #include <qlabel.h> |
36 | #include <qlist.h> | 39 | #include <qlist.h> |
37 | #include <qlistbox.h> | 40 | #include <qlistbox.h> |
38 | #include <qmainwindow.h> | 41 | #include <qmainwindow.h> |
39 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
40 | #include <qtoolbutton.h> | 43 | #include <qtoolbutton.h> |
41 | #include <qtabwidget.h> | 44 | #include <qtabwidget.h> |
42 | #include <qlistview.h> | 45 | #include <qlistview.h> |
43 | #include <qpoint.h> | 46 | #include <qpoint.h> |
44 | #include <qlineedit.h> | 47 | #include <qlineedit.h> |
45 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
46 | 49 | ||
47 | //#include <qtimer.h> | 50 | //#include <qtimer.h> |
48 | 51 | ||
@@ -186,150 +189,124 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
186 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 189 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
187 | d->playListFrame = vbox3; | 190 | d->playListFrame = vbox3; |
188 | d->playListFrame ->setMinimumSize(235,260); | 191 | d->playListFrame ->setMinimumSize(235,260); |
189 | 192 | ||
190 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 193 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
191 | 194 | ||
192 | d->selectedFiles = new PlayListSelection( hbox2); | 195 | d->selectedFiles = new PlayListSelection( hbox2); |
193 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 196 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
194 | 197 | ||
195 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 198 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
196 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 199 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
197 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 200 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
198 | 201 | ||
199 | 202 | ||
200 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 203 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
201 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 204 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
202 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 205 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
203 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 206 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
204 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 207 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
205 | 208 | ||
206 | QWidget *aTab; | 209 | QWidget *aTab; |
207 | aTab = new QWidget( tabWidget, "aTab" ); | 210 | aTab = new QWidget( tabWidget, "aTab" ); |
208 | audioView = new QListView( aTab, "Audioview" ); | 211 | audioView = new QListView( aTab, "Audioview" ); |
209 | audioView->setMinimumSize(233,260); | 212 | audioView->setMinimumSize(233,260); |
210 | audioView->addColumn( "Title",140); | 213 | audioView->addColumn( tr("Title"),140); |
211 | audioView->addColumn("Size", -1); | 214 | audioView->addColumn(tr("Size"), -1); |
212 | audioView->addColumn("Media",-1); | 215 | audioView->addColumn(tr("Media"),-1); |
213 | audioView->setColumnAlignment(1, Qt::AlignRight); | 216 | audioView->setColumnAlignment(1, Qt::AlignRight); |
214 | audioView->setColumnAlignment(2, Qt::AlignRight); | 217 | audioView->setColumnAlignment(2, Qt::AlignRight); |
215 | audioView->setAllColumnsShowFocus(TRUE); | 218 | audioView->setAllColumnsShowFocus(TRUE); |
216 | tabWidget->insertTab(aTab,"Audio"); | 219 | tabWidget->insertTab(aTab,tr("Audio")); |
217 | 220 | ||
218 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 221 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
219 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 222 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
220 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 223 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
221 | 224 | ||
222 | 225 | ||
223 | // audioView | 226 | // audioView |
224 | Global::findDocuments(&files, "audio/*"); | 227 | populateAudioView(); |
225 | QListIterator<DocLnk> dit( files.children() ); | ||
226 | QString storage; | ||
227 | for ( ; dit.current(); ++dit ) { | ||
228 | QListViewItem * newItem; | ||
229 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
230 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | ||
231 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
232 | else storage="RAM"; | ||
233 | if ( QFile( dit.current()->file()).exists() ) { | ||
234 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | ||
235 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | ||
236 | } | ||
237 | } | ||
238 | // videowidget | 228 | // videowidget |
239 | 229 | ||
240 | QWidget *vTab; | 230 | QWidget *vTab; |
241 | vTab = new QWidget( tabWidget, "vTab" ); | 231 | vTab = new QWidget( tabWidget, "vTab" ); |
242 | videoView = new QListView( vTab, "Videoview" ); | 232 | videoView = new QListView( vTab, "Videoview" ); |
243 | videoView->setMinimumSize(233,260); | 233 | videoView->setMinimumSize(233,260); |
244 | 234 | ||
245 | videoView->addColumn("Title",140); | 235 | videoView->addColumn(tr("Title"),140); |
246 | videoView->addColumn("Size",-1); | 236 | videoView->addColumn(tr("Size"),-1); |
247 | videoView->addColumn("Media",-1); | 237 | videoView->addColumn(tr("Media"),-1); |
248 | videoView->setColumnAlignment(1, Qt::AlignRight); | 238 | videoView->setColumnAlignment(1, Qt::AlignRight); |
249 | videoView->setColumnAlignment(2, Qt::AlignRight); | 239 | videoView->setColumnAlignment(2, Qt::AlignRight); |
250 | videoView->setAllColumnsShowFocus(TRUE); | 240 | videoView->setAllColumnsShowFocus(TRUE); |
251 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 241 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
252 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 242 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
253 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 243 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
254 | 244 | ||
255 | tabWidget->insertTab( vTab,"Video"); | 245 | tabWidget->insertTab( vTab,tr("Video")); |
256 | 246 | ||
257 | Global::findDocuments(&vFiles, "video/*"); | ||
258 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
259 | for ( ; Vdit.current(); ++Vdit ) { | ||
260 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
261 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | ||
262 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
263 | else storage="RAM"; | ||
264 | QListViewItem * newItem; | ||
265 | if ( QFile( Vdit.current()->file()).exists() ) { | ||
266 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
267 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | ||
268 | } | ||
269 | } | ||
270 | 247 | ||
271 | //playlists list | 248 | //playlists list |
272 | QWidget *LTab; | 249 | QWidget *LTab; |
273 | LTab = new QWidget( tabWidget, "LTab" ); | 250 | LTab = new QWidget( tabWidget, "LTab" ); |
274 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 251 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
275 | playLists->setMinimumSize(233,260);; | 252 | playLists->setMinimumSize(233,260);; |
276 | tabWidget->insertTab(LTab,"Lists"); | 253 | tabWidget->insertTab(LTab,tr("Lists")); |
277 | 254 | ||
278 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 255 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
279 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 256 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
280 | 257 | ||
281 | 258 | ||
282 | // add the library area | 259 | // add the library area |
283 | 260 | ||
284 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 261 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
285 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 262 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
286 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 263 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
287 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 264 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
288 | 265 | ||
289 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 266 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
290 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 267 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
291 | 268 | ||
292 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 269 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
293 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 270 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
294 | 271 | ||
295 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 272 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
296 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 273 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
297 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 274 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
298 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 275 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
299 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 276 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
300 | 277 | ||
301 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 278 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
302 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 279 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
303 | 280 | ||
304 | setCentralWidget( vbox5 ); | 281 | setCentralWidget( vbox5 ); |
305 | 282 | ||
306 | Config cfg( "MediaPlayer" ); | 283 | Config cfg( "MediaPlayer" ); |
307 | readConfig( cfg ); | 284 | readConfig( cfg ); |
308 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 285 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
309 | // qDebug("currentList is "+currentPlaylist); | 286 | // qDebug("currentList is "+currentPlaylist); |
310 | loadList(DocLnk( currentPlaylist)); | 287 | loadList(DocLnk( currentPlaylist)); |
311 | setCaption("OpiePlayer: "+ currentPlaylist ); | 288 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
312 | 289 | ||
313 | initializeStates(); | 290 | initializeStates(); |
314 | } | 291 | } |
315 | 292 | ||
316 | 293 | ||
317 | PlayListWidget::~PlayListWidget() { | 294 | PlayListWidget::~PlayListWidget() { |
318 | Config cfg( "MediaPlayer" ); | 295 | Config cfg( "MediaPlayer" ); |
319 | writeConfig( cfg ); | 296 | writeConfig( cfg ); |
320 | 297 | ||
321 | 298 | ||
322 | if ( d->current ) | 299 | if ( d->current ) |
323 | delete d->current; | 300 | delete d->current; |
324 | delete d; | 301 | delete d; |
325 | } | 302 | } |
326 | 303 | ||
327 | 304 | ||
328 | void PlayListWidget::initializeStates() { | 305 | void PlayListWidget::initializeStates() { |
329 | 306 | ||
330 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 307 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
331 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 308 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
332 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 309 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
333 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 310 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
334 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 311 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
335 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 312 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
@@ -429,92 +406,92 @@ void PlayListWidget::addAllMusicToList() { | |||
429 | void PlayListWidget::addAllVideoToList() { | 406 | void PlayListWidget::addAllVideoToList() { |
430 | DocLnkSet files; | 407 | DocLnkSet files; |
431 | Global::findDocuments(&files, "video/*"); | 408 | Global::findDocuments(&files, "video/*"); |
432 | QListIterator<DocLnk> dit( files.children() ); | 409 | QListIterator<DocLnk> dit( files.children() ); |
433 | for ( ; dit.current(); ++dit ) | 410 | for ( ; dit.current(); ++dit ) |
434 | d->selectedFiles->addToSelection( **dit ); | 411 | d->selectedFiles->addToSelection( **dit ); |
435 | } | 412 | } |
436 | 413 | ||
437 | 414 | ||
438 | void PlayListWidget::setDocument(const QString& fileref) { | 415 | void PlayListWidget::setDocument(const QString& fileref) { |
439 | fromSetDocument = TRUE; | 416 | fromSetDocument = TRUE; |
440 | if ( fileref.isNull() ) { | 417 | if ( fileref.isNull() ) { |
441 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 418 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
442 | return; | 419 | return; |
443 | } | 420 | } |
444 | // qDebug("setDocument "+fileref); | 421 | // qDebug("setDocument "+fileref); |
445 | if(fileref.find("playlist",0,TRUE) == -1) { | 422 | if(fileref.find("playlist",0,TRUE) == -1) { |
446 | clearList(); | 423 | clearList(); |
447 | addToSelection( DocLnk( fileref ) ); | 424 | addToSelection( DocLnk( fileref ) ); |
448 | d->setDocumentUsed = TRUE; | 425 | d->setDocumentUsed = TRUE; |
449 | mediaPlayerState->setPlaying( FALSE ); | 426 | mediaPlayerState->setPlaying( FALSE ); |
450 | qApp->processEvents(); | 427 | qApp->processEvents(); |
451 | mediaPlayerState->setPlaying( TRUE ); | 428 | mediaPlayerState->setPlaying( TRUE ); |
452 | qApp->processEvents(); | 429 | qApp->processEvents(); |
453 | setCaption("OpiePlayer"); | 430 | setCaption(tr("OpiePlayer")); |
454 | 431 | ||
455 | } else { //is playlist | 432 | } else { //is playlist |
456 | clearList(); | 433 | clearList(); |
457 | loadList(DocLnk(fileref)); | 434 | loadList(DocLnk(fileref)); |
458 | d->selectedFiles->first(); | 435 | d->selectedFiles->first(); |
459 | } | 436 | } |
460 | } | 437 | } |
461 | 438 | ||
462 | 439 | ||
463 | void PlayListWidget::setActiveWindow() { | 440 | void PlayListWidget::setActiveWindow() { |
464 | // When we get raised we need to ensure that it switches views | 441 | // When we get raised we need to ensure that it switches views |
465 | char origView = mediaPlayerState->view(); | 442 | char origView = mediaPlayerState->view(); |
466 | mediaPlayerState->setView( 'l' ); // invalidate | 443 | mediaPlayerState->setView( 'l' ); // invalidate |
467 | mediaPlayerState->setView( origView ); // now switch back | 444 | mediaPlayerState->setView( origView ); // now switch back |
468 | } | 445 | } |
469 | 446 | ||
470 | 447 | ||
471 | void PlayListWidget::useSelectedDocument() { | 448 | void PlayListWidget::useSelectedDocument() { |
472 | d->setDocumentUsed = FALSE; | 449 | d->setDocumentUsed = FALSE; |
473 | } | 450 | } |
474 | 451 | ||
475 | 452 | ||
476 | const DocLnk *PlayListWidget::current() { // this is fugly | 453 | const DocLnk *PlayListWidget::current() { // this is fugly |
477 | 454 | ||
478 | // if( fromSetDocument) { | 455 | // if( fromSetDocument) { |
479 | // qDebug("from setDoc"); | 456 | // qDebug("from setDoc"); |
480 | // DocLnkSet files; | 457 | // DocLnkSet files; |
481 | // Global::findDocuments(&files, "video/*;audio/*"); | 458 | // Global::findDocuments(&files, "video/*;audio/*"); |
482 | // QListIterator<DocLnk> dit( files.children() ); | 459 | // QListIterator<DocLnk> dit( files.children() ); |
483 | // for ( ; dit.current(); ++dit ) { | 460 | // for ( ; dit.current(); ++dit ) { |
484 | // if(dit.current()->linkFile() == setDocFileRef) { | 461 | // if(dit.current()->linkFile() == setDocFileRef) { |
485 | // qDebug(setDocFileRef); | 462 | // qDebug(setDocFileRef); |
486 | // return dit; | 463 | // return dit; |
487 | // } | 464 | // } |
488 | // } | 465 | // } |
489 | // } else | 466 | // } else |
490 | // qDebug("current"); | 467 | // qDebug("current"); |
491 | // switch (tabWidget->currentPageIndex()) { | 468 | // switch (tabWidget->currentPageIndex()) { |
492 | // case 0: //playlist | 469 | // case 0: //playlist |
493 | // { | 470 | // { |
494 | qDebug("playlist"); | 471 | qDebug("playlist"); |
495 | if ( mediaPlayerState->playlist() ) { | 472 | if ( mediaPlayerState->playlist() ) { |
496 | return d->selectedFiles->current(); | 473 | return d->selectedFiles->current(); |
497 | } | 474 | } |
498 | else if ( d->setDocumentUsed && d->current ) { | 475 | else if ( d->setDocumentUsed && d->current ) { |
499 | return d->current; | 476 | return d->current; |
500 | } else { | 477 | } else { |
501 | return d->files->selected(); | 478 | return d->files->selected(); |
502 | } | 479 | } |
503 | // } | 480 | // } |
504 | // break; | 481 | // break; |
505 | // case 1://audio | 482 | // case 1://audio |
506 | // { | 483 | // { |
507 | // qDebug("audioView"); | 484 | // qDebug("audioView"); |
508 | // Global::findDocuments(&files, "audio/*"); | 485 | // Global::findDocuments(&files, "audio/*"); |
509 | // QListIterator<DocLnk> dit( files.children() ); | 486 | // QListIterator<DocLnk> dit( files.children() ); |
510 | // for ( ; dit.current(); ++dit ) { | 487 | // for ( ; dit.current(); ++dit ) { |
511 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 488 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
512 | // qDebug("here"); | 489 | // qDebug("here"); |
513 | // insanityBool=TRUE; | 490 | // insanityBool=TRUE; |
514 | // return dit; | 491 | // return dit; |
515 | // } | 492 | // } |
516 | // } | 493 | // } |
517 | // } | 494 | // } |
518 | // break; | 495 | // break; |
519 | // case 2: // video | 496 | // case 2: // video |
520 | // { | 497 | // { |
@@ -581,76 +558,76 @@ bool PlayListWidget::next() { | |||
581 | } | 558 | } |
582 | } | 559 | } |
583 | 560 | ||
584 | 561 | ||
585 | bool PlayListWidget::first() { | 562 | bool PlayListWidget::first() { |
586 | if ( mediaPlayerState->playlist() ) | 563 | if ( mediaPlayerState->playlist() ) |
587 | return d->selectedFiles->first(); | 564 | return d->selectedFiles->first(); |
588 | else | 565 | else |
589 | return mediaPlayerState->looping(); | 566 | return mediaPlayerState->looping(); |
590 | } | 567 | } |
591 | 568 | ||
592 | 569 | ||
593 | bool PlayListWidget::last() { | 570 | bool PlayListWidget::last() { |
594 | if ( mediaPlayerState->playlist() ) | 571 | if ( mediaPlayerState->playlist() ) |
595 | return d->selectedFiles->last(); | 572 | return d->selectedFiles->last(); |
596 | else | 573 | else |
597 | return mediaPlayerState->looping(); | 574 | return mediaPlayerState->looping(); |
598 | } | 575 | } |
599 | 576 | ||
600 | 577 | ||
601 | void PlayListWidget::saveList() { | 578 | void PlayListWidget::saveList() { |
602 | 579 | ||
603 | QString filename; | 580 | QString filename; |
604 | InputDialog *fileDlg; | 581 | InputDialog *fileDlg; |
605 | fileDlg = new InputDialog(this,"Save Playlist",TRUE, 0); | 582 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
606 | fileDlg->exec(); | 583 | fileDlg->exec(); |
607 | if( fileDlg->result() == 1 ) { | 584 | if( fileDlg->result() == 1 ) { |
608 | if ( d->current ) | 585 | if ( d->current ) |
609 | delete d->current; | 586 | delete d->current; |
610 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 587 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
611 | // qDebug("saving playlist "+filename+".playlist"); | 588 | // qDebug("saving playlist "+filename+".playlist"); |
612 | Config cfg( filename +".playlist"); | 589 | Config cfg( filename +".playlist"); |
613 | writeConfig( cfg ); | 590 | writeConfig( cfg ); |
614 | if( playLists->selected()->name() == filename) { | 591 | if( playLists->selected()->name() == filename) { |
615 | // qDebug("same name so delete lnk"); | 592 | // qDebug("same name so delete lnk"); |
616 | QFile().remove(playLists->selected()->file()); | 593 | QFile().remove(playLists->selected()->file()); |
617 | QFile().remove(playLists->selected()->linkFile()); | 594 | QFile().remove(playLists->selected()->linkFile()); |
618 | playLists->reread(); | 595 | playLists->reread(); |
619 | } | 596 | } |
620 | 597 | ||
621 | DocLnk lnk; | 598 | DocLnk lnk; |
622 | // lnk.setComment( ""); | 599 | // lnk.setComment( ""); |
623 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 600 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
624 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 601 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
625 | lnk.setIcon("mpegplayer/playlist2"); | 602 | lnk.setIcon("mpegplayer/playlist2"); |
626 | lnk.setName( filename); //sets file name | 603 | lnk.setName( filename); //sets file name |
627 | if(!lnk.writeLink()) | 604 | if(!lnk.writeLink()) |
628 | qDebug("Writing doclink did not work"); | 605 | qDebug("Writing doclink did not work"); |
629 | } | 606 | } |
630 | Config config( "MediaPlayer" ); | 607 | Config config( "MediaPlayer" ); |
631 | config.writeEntry("CurrentPlaylist",filename); | 608 | config.writeEntry("CurrentPlaylist",filename); |
632 | setCaption("OpiePlayer: "+filename); | 609 | setCaption(tr("OpiePlayer: ")+filename); |
633 | d->selectedFiles->first(); | 610 | d->selectedFiles->first(); |
634 | if(fileDlg) | 611 | if(fileDlg) |
635 | delete fileDlg; | 612 | delete fileDlg; |
636 | } | 613 | } |
637 | 614 | ||
638 | void PlayListWidget::loadList( const DocLnk & lnk) { | 615 | void PlayListWidget::loadList( const DocLnk & lnk) { |
639 | QString name= lnk.name(); | 616 | QString name= lnk.name(); |
640 | // qDebug("currentList is "+name); | 617 | // qDebug("currentList is "+name); |
641 | if( name.length()>1) { | 618 | if( name.length()>1) { |
642 | setCaption("OpiePlayer: "+name); | 619 | setCaption("OpiePlayer: "+name); |
643 | // qDebug("load list "+ name+".playlist"); | 620 | // qDebug("load list "+ name+".playlist"); |
644 | clearList(); | 621 | clearList(); |
645 | Config cfg( name+".playlist"); | 622 | Config cfg( name+".playlist"); |
646 | readConfig(cfg); | 623 | readConfig(cfg); |
647 | tabWidget->setCurrentPage(0); | 624 | tabWidget->setCurrentPage(0); |
648 | Config config( "MediaPlayer" ); | 625 | Config config( "MediaPlayer" ); |
649 | config.writeEntry("CurrentPlaylist", name); | 626 | config.writeEntry("CurrentPlaylist", name); |
650 | d->selectedFiles->first(); | 627 | d->selectedFiles->first(); |
651 | } | 628 | } |
652 | } | 629 | } |
653 | 630 | ||
654 | void PlayListWidget::setPlaylist( bool shown ) { | 631 | void PlayListWidget::setPlaylist( bool shown ) { |
655 | if ( shown ) | 632 | if ( shown ) |
656 | d->playListFrame->show(); | 633 | d->playListFrame->show(); |
@@ -660,232 +637,305 @@ void PlayListWidget::setPlaylist( bool shown ) { | |||
660 | 637 | ||
661 | void PlayListWidget::setView( char view ) { | 638 | void PlayListWidget::setView( char view ) { |
662 | if ( view == 'l' ) | 639 | if ( view == 'l' ) |
663 | showMaximized(); | 640 | showMaximized(); |
664 | else | 641 | else |
665 | hide(); | 642 | hide(); |
666 | } | 643 | } |
667 | 644 | ||
668 | void PlayListWidget::addSelected() { | 645 | void PlayListWidget::addSelected() { |
669 | 646 | ||
670 | Config cfg( "MediaPlayer" ); | 647 | Config cfg( "MediaPlayer" ); |
671 | cfg.setGroup("PlayList"); | 648 | cfg.setGroup("PlayList"); |
672 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 649 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
673 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 650 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
674 | 651 | ||
675 | switch (tabWidget->currentPageIndex()) { | 652 | switch (tabWidget->currentPageIndex()) { |
676 | case 0: //playlist | 653 | case 0: //playlist |
677 | break; | 654 | break; |
678 | case 1: { //audio | 655 | case 1: { //audio |
679 | for ( int i = 0; i < noOfFiles; i++ ) { | 656 | for ( int i = 0; i < noOfFiles; i++ ) { |
680 | QString entryName; | 657 | QString entryName; |
681 | entryName.sprintf( "File%i", i + 1 ); | 658 | entryName.sprintf( "File%i", i + 1 ); |
682 | QString linkFile = cfg.readEntry( entryName ); | 659 | QString linkFile = cfg.readEntry( entryName ); |
683 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { | 660 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { |
684 | int result= QMessageBox::warning(this,"OpiePlayer", | 661 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
685 | tr("This is all ready in your playlist.\nContinue?"), | 662 | tr("This is all ready in your playlist.\nContinue?"), |
686 | tr("Yes"),tr("No"),0,0,1); | 663 | tr("Yes"),tr("No"),0,0,1); |
687 | if (result !=0) | 664 | if (result !=0) |
688 | return; | 665 | return; |
689 | } | 666 | } |
690 | } | 667 | } |
691 | addToSelection( audioView->selectedItem() ); | 668 | addToSelection( audioView->selectedItem() ); |
692 | tabWidget->setCurrentPage(1); | 669 | tabWidget->setCurrentPage(1); |
693 | } | 670 | } |
694 | break; | 671 | break; |
695 | case 2: { // video | 672 | case 2: { // video |
696 | for ( int i = 0; i < noOfFiles; i++ ) { | 673 | for ( int i = 0; i < noOfFiles; i++ ) { |
697 | QString entryName; | 674 | QString entryName; |
698 | entryName.sprintf( "File%i", i + 1 ); | 675 | entryName.sprintf( "File%i", i + 1 ); |
699 | QString linkFile = cfg.readEntry( entryName ); | 676 | QString linkFile = cfg.readEntry( entryName ); |
700 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 677 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
701 | int result= QMessageBox::warning(this,"OpiePlayer", | 678 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
702 | tr("This is all ready in your playlist.\nContinue?"), | 679 | tr("This is all ready in your playlist.\nContinue?"), |
703 | tr("Yes"),tr("No"),0,0,1); | 680 | tr("Yes"),tr("No"),0,0,1); |
704 | if (result !=0) | 681 | if (result !=0) |
705 | return; | 682 | return; |
706 | } | 683 | } |
707 | } | 684 | } |
708 | addToSelection( videoView->selectedItem() ); | 685 | addToSelection( videoView->selectedItem() ); |
709 | tabWidget->setCurrentPage(2); | 686 | tabWidget->setCurrentPage(2); |
710 | } | 687 | } |
711 | break; | 688 | break; |
712 | }; | 689 | }; |
713 | } | 690 | } |
714 | 691 | ||
715 | void PlayListWidget::removeSelected() { | 692 | void PlayListWidget::removeSelected() { |
716 | d->selectedFiles->removeSelected( ); | 693 | d->selectedFiles->removeSelected( ); |
717 | } | 694 | } |
718 | 695 | ||
719 | |||
720 | void PlayListWidget::playIt( QListViewItem *it) { | 696 | void PlayListWidget::playIt( QListViewItem *it) { |
721 | // d->setDocumentUsed = FALSE; | 697 | // d->setDocumentUsed = FALSE; |
722 | mediaPlayerState->setPlaying(TRUE); | 698 | mediaPlayerState->setPlaying(TRUE); |
723 | } | 699 | } |
724 | 700 | ||
725 | void PlayListWidget::addToSelection( QListViewItem *it) { | 701 | void PlayListWidget::addToSelection( QListViewItem *it) { |
726 | d->setDocumentUsed = FALSE; | 702 | d->setDocumentUsed = FALSE; |
727 | 703 | ||
728 | if(it) { | 704 | if(it) { |
729 | // qDebug("add to selection"); | ||
730 | switch (tabWidget->currentPageIndex()) { | 705 | switch (tabWidget->currentPageIndex()) { |
731 | case 1: { | 706 | case 1: { |
732 | // qDebug("case 1"); | ||
733 | QListIterator<DocLnk> dit( files.children() ); | 707 | QListIterator<DocLnk> dit( files.children() ); |
734 | for ( ; dit.current(); ++dit ) { | 708 | for ( ; dit.current(); ++dit ) { |
735 | // qDebug(dit.current()->name()); | ||
736 | if( dit.current()->name() == it->text(0)) { | 709 | if( dit.current()->name() == it->text(0)) { |
737 | d->selectedFiles->addToSelection( **dit ); | 710 | d->selectedFiles->addToSelection( **dit ); |
738 | } | 711 | } |
739 | } | 712 | } |
740 | } | 713 | } |
741 | break; | 714 | break; |
742 | case 2: { | 715 | case 2: { |
743 | // qDebug("case 2"); | ||
744 | QListIterator<DocLnk> dit( vFiles.children() ); | 716 | QListIterator<DocLnk> dit( vFiles.children() ); |
745 | for ( ; dit.current(); ++dit ) { | 717 | for ( ; dit.current(); ++dit ) { |
746 | // qDebug(dit.current()->name()); | ||
747 | if( dit.current()->name() == it->text(0)) { | 718 | if( dit.current()->name() == it->text(0)) { |
748 | d->selectedFiles->addToSelection( **dit ); | 719 | d->selectedFiles->addToSelection( **dit ); |
749 | } | 720 | } |
750 | } | 721 | } |
751 | } | 722 | } |
752 | break; | 723 | break; |
753 | case 0: | 724 | case 0: |
754 | break; | 725 | break; |
755 | }; | 726 | }; |
756 | tabWidget->setCurrentPage(0); | 727 | tabWidget->setCurrentPage(0); |
757 | // mediaPlayerState->setPlaying( TRUE ); | ||
758 | } | 728 | } |
759 | } | 729 | } |
760 | 730 | ||
761 | void PlayListWidget::tabChanged(QWidget *widg) { | 731 | void PlayListWidget::tabChanged(QWidget *widg) { |
762 | 732 | ||
763 | switch ( tabWidget->currentPageIndex()) { | 733 | switch ( tabWidget->currentPageIndex()) { |
764 | case 0: | 734 | case 0: |
765 | { | 735 | { |
766 | if( !tbDeletePlaylist->isHidden()) | 736 | if( !tbDeletePlaylist->isHidden()) |
767 | tbDeletePlaylist->hide(); | 737 | tbDeletePlaylist->hide(); |
768 | d->tbRemoveFromList->setEnabled(TRUE); | 738 | d->tbRemoveFromList->setEnabled(TRUE); |
769 | d->tbAddToList->setEnabled(FALSE); | 739 | d->tbAddToList->setEnabled(FALSE); |
770 | } | 740 | } |
771 | break; | 741 | break; |
772 | case 1: | 742 | case 1: |
773 | { | 743 | { |
774 | if( !tbDeletePlaylist->isHidden()) | 744 | if( !tbDeletePlaylist->isHidden()) |
775 | tbDeletePlaylist->hide(); | 745 | tbDeletePlaylist->hide(); |
776 | d->tbRemoveFromList->setEnabled(FALSE); | 746 | d->tbRemoveFromList->setEnabled(FALSE); |
777 | d->tbAddToList->setEnabled(TRUE); | 747 | d->tbAddToList->setEnabled(TRUE); |
778 | } | 748 | } |
779 | break; | 749 | break; |
780 | case 2: | 750 | case 2: |
781 | { | 751 | { |
782 | if( !tbDeletePlaylist->isHidden()) | 752 | if( !tbDeletePlaylist->isHidden()) |
783 | tbDeletePlaylist->hide(); | 753 | tbDeletePlaylist->hide(); |
784 | d->tbRemoveFromList->setEnabled(FALSE); | 754 | d->tbRemoveFromList->setEnabled(FALSE); |
785 | d->tbAddToList->setEnabled(TRUE); | 755 | d->tbAddToList->setEnabled(TRUE); |
786 | } | 756 | } |
787 | break; | 757 | break; |
788 | case 3: | 758 | case 3: |
789 | { | 759 | { |
790 | if( tbDeletePlaylist->isHidden()) | 760 | if( tbDeletePlaylist->isHidden()) |
791 | tbDeletePlaylist->show(); | 761 | tbDeletePlaylist->show(); |
792 | playLists->reread(); | 762 | playLists->reread(); |
793 | } | 763 | } |
794 | break; | 764 | break; |
795 | }; | 765 | }; |
796 | } | 766 | } |
797 | 767 | ||
798 | 768 | ||
799 | /* | 769 | |
800 | play button is pressed*/ | ||
801 | void PlayListWidget::btnPlay(bool b) { | 770 | void PlayListWidget::btnPlay(bool b) { |
771 | |||
802 | // mediaPlayerState->setPlaying(b); | 772 | // mediaPlayerState->setPlaying(b); |
803 | switch ( tabWidget->currentPageIndex()) { | 773 | switch ( tabWidget->currentPageIndex()) { |
804 | case 0: | 774 | case 0: |
805 | { | 775 | { |
806 | mediaPlayerState->setPlaying(b); | 776 | mediaPlayerState->setPlaying(b); |
807 | } | 777 | } |
808 | break; | 778 | break; |
809 | case 1: | 779 | case 1: |
810 | { | 780 | { |
811 | addToSelection( audioView->selectedItem() ); | 781 | addToSelection( audioView->selectedItem() ); |
812 | mediaPlayerState->setPlaying(b); | 782 | mediaPlayerState->setPlaying(b); |
813 | // qApp->processEvents(); | 783 | // qApp->processEvents(); |
814 | d->selectedFiles->removeSelected( ); | 784 | d->selectedFiles->removeSelected( ); |
815 | tabWidget->setCurrentPage(1); | 785 | tabWidget->setCurrentPage(1); |
816 | d->selectedFiles->unSelect(); | 786 | d->selectedFiles->unSelect(); |
817 | // mediaPlayerState->setPlaying(FALSE); | 787 | // mediaPlayerState->setPlaying(FALSE); |
818 | } | 788 | } |
819 | break; | 789 | break; |
820 | case 2: | 790 | case 2: |
821 | { | 791 | { |
822 | addToSelection( videoView->selectedItem() ); | 792 | addToSelection( videoView->selectedItem() ); |
823 | mediaPlayerState->setPlaying(b); | 793 | mediaPlayerState->setPlaying(b); |
824 | qApp->processEvents(); | 794 | qApp->processEvents(); |
825 | d->selectedFiles->removeSelected( ); | 795 | d->selectedFiles->removeSelected( ); |
826 | tabWidget->setCurrentPage(2); | 796 | tabWidget->setCurrentPage(2); |
827 | d->selectedFiles->unSelect(); | 797 | d->selectedFiles->unSelect(); |
828 | // mediaPlayerState->setPlaying(FALSE); | 798 | // mediaPlayerState->setPlaying(FALSE); |
829 | } | 799 | } |
830 | break; | 800 | break; |
831 | }; | 801 | }; |
832 | |||
833 | |||
834 | |||
835 | |||
836 | } | 802 | } |
837 | 803 | ||
838 | void PlayListWidget::deletePlaylist() { | 804 | void PlayListWidget::deletePlaylist() { |
839 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 805 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
840 | (tr("You really want to delete\nthis playlist?")), | 806 | (tr("You really want to delete\nthis playlist?")), |
841 | (tr("Yes")), (tr("No")), 0 )){ | 807 | (tr("Yes")), (tr("No")), 0 )){ |
842 | case 0: // Yes clicked, | 808 | case 0: // Yes clicked, |
843 | QFile().remove(playLists->selected()->file()); | 809 | QFile().remove(playLists->selected()->file()); |
844 | QFile().remove(playLists->selected()->linkFile()); | 810 | QFile().remove(playLists->selected()->linkFile()); |
845 | playLists->reread(); | 811 | playLists->reread(); |
846 | break; | 812 | break; |
847 | case 1: // Cancel | 813 | case 1: // Cancel |
848 | break; | 814 | break; |
849 | }; | 815 | }; |
850 | 816 | ||
851 | } | 817 | } |
852 | 818 | ||
853 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 819 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
854 | { | 820 | { |
855 | switch (mouse) { | 821 | switch (mouse) { |
856 | case 1: | 822 | case 1: |
857 | break; | 823 | break; |
858 | case 2:{ | 824 | case 2:{ |
859 | QPopupMenu m; | 825 | QPopupMenu m; |
860 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 826 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
861 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 827 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
862 | // m.insertSeparator(); | 828 | m.insertSeparator(); |
863 | // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 829 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
864 | m.exec( QCursor::pos() ); | 830 | m.exec( QCursor::pos() ); |
865 | } | 831 | } |
866 | break; | 832 | break; |
867 | }; | 833 | }; |
868 | |||
869 | } | 834 | } |
870 | 835 | ||
871 | void PlayListWidget::playSelected() | 836 | void PlayListWidget::playSelected() |
872 | { | 837 | { |
873 | btnPlay( TRUE); | 838 | btnPlay( TRUE); |
874 | } | 839 | } |
875 | 840 | ||
876 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 841 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
877 | { | 842 | { |
878 | switch (mouse) { | 843 | switch (mouse) { |
879 | case 1: | 844 | case 1: |
880 | break; | 845 | break; |
881 | case 2:{ | 846 | case 2:{ |
882 | QPopupMenu m; | 847 | QPopupMenu m; |
883 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 848 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
884 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 849 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
885 | // m.insertSeparator(); | 850 | // m.insertSeparator(); |
886 | m.exec( QCursor::pos() ); | 851 | m.exec( QCursor::pos() ); |
887 | } | 852 | } |
888 | break; | 853 | break; |
889 | }; | 854 | }; |
890 | 855 | ||
891 | } | 856 | } |
857 | |||
858 | void PlayListWidget::listDelete() { | ||
859 | Config cfg( "MediaPlayer" ); | ||
860 | cfg.setGroup("PlayList"); | ||
861 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | ||
862 | QString file; | ||
863 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | ||
864 | switch ( tabWidget->currentPageIndex()) { | ||
865 | case 0: | ||
866 | break; | ||
867 | case 1: | ||
868 | { | ||
869 | file = audioView->selectedItem()->text(0); | ||
870 | // Global::findDocuments(&files, "audio/*"); | ||
871 | // AppLnkSet appFiles; | ||
872 | QListIterator<DocLnk> dit( files.children() ); | ||
873 | for ( ; dit.current(); ++dit ) { | ||
874 | if( dit.current()->name() == file) { | ||
875 | qDebug(file); | ||
876 | LnkProperties prop( dit.current() ); | ||
877 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | ||
878 | prop.showMaximized(); | ||
879 | prop.exec(); | ||
880 | } | ||
881 | } | ||
882 | populateAudioView(); | ||
883 | } | ||
884 | break; | ||
885 | case 2: | ||
886 | { | ||
887 | // file = videoView->selectedItem()->text(0); | ||
888 | // for ( int i = 0; i < noOfFiles; i++ ) { | ||
889 | // QString entryName; | ||
890 | // entryName.sprintf( "File%i", i + 1 ); | ||
891 | // QString linkFile = cfg.readEntry( entryName ); | ||
892 | // AppLnk lnk( AppLnk(linkFile)); | ||
893 | // if( lnk.name() == file ) { | ||
894 | // LnkProperties prop( &lnk); | ||
895 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | ||
896 | // prop.showMaximized(); | ||
897 | // prop.exec(); | ||
898 | // } | ||
899 | // } | ||
900 | } | ||
901 | break; | ||
902 | }; | ||
903 | } | ||
904 | |||
905 | void PlayListWidget::populateAudioView() { | ||
906 | // if(files) | ||
907 | // files.~DocLnkSet(); | ||
908 | Global::findDocuments(&files, "audio/*"); | ||
909 | QListIterator<DocLnk> dit( files.children() ); | ||
910 | audioView->clear(); | ||
911 | QString storage; | ||
912 | for ( ; dit.current(); ++dit ) { | ||
913 | QListViewItem * newItem; | ||
914 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); | ||
915 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); | ||
916 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); | ||
917 | else storage=tr("RAM"); | ||
918 | if ( QFile( dit.current()->file()).exists() ) { | ||
919 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | ||
920 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | ||
921 | } | ||
922 | } | ||
923 | } | ||
924 | |||
925 | void PlayListWidget::populateVideoView() { | ||
926 | Global::findDocuments(&vFiles, "video/*"); | ||
927 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
928 | videoView->clear(); | ||
929 | QString storage; | ||
930 | for ( ; Vdit.current(); ++Vdit ) { | ||
931 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); | ||
932 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); | ||
933 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); | ||
934 | else storage=tr("RAM"); | ||
935 | QListViewItem * newItem; | ||
936 | if ( QFile( Vdit.current()->file()).exists() ) { | ||
937 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
938 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | ||
939 | } | ||
940 | } | ||
941 | } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 10a42df..186ca1b 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -37,72 +37,76 @@ class QPoint; | |||
37 | class QAction; | 37 | class QAction; |
38 | class QLabel; | 38 | class QLabel; |
39 | 39 | ||
40 | class PlayListWidget : public QMainWindow { | 40 | class PlayListWidget : public QMainWindow { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 43 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
44 | ~PlayListWidget(); | 44 | ~PlayListWidget(); |
45 | QTabWidget * tabWidget; | 45 | QTabWidget * tabWidget; |
46 | QAction *fullScreenButton, *scaleButton; | 46 | QAction *fullScreenButton, *scaleButton; |
47 | DocLnkSet files; | 47 | DocLnkSet files; |
48 | DocLnkSet vFiles; | 48 | DocLnkSet vFiles; |
49 | QListView *audioView, *videoView, *playlistView; | 49 | QListView *audioView, *videoView, *playlistView; |
50 | QLabel *libString; | 50 | QLabel *libString; |
51 | bool fromSetDocument; | 51 | bool fromSetDocument; |
52 | bool insanityBool; | 52 | bool insanityBool; |
53 | QString setDocFileRef; | 53 | QString setDocFileRef; |
54 | // retrieve the current playlist entry (media file link) | 54 | // retrieve the current playlist entry (media file link) |
55 | const DocLnk *current(); | 55 | const DocLnk *current(); |
56 | void useSelectedDocument(); | 56 | void useSelectedDocument(); |
57 | /* QTimer * menuTimer; */ | 57 | /* QTimer * menuTimer; */ |
58 | FileSelector* playLists; | 58 | FileSelector* playLists; |
59 | QPushButton *tbDeletePlaylist; | 59 | QPushButton *tbDeletePlaylist; |
60 | public slots: | 60 | public slots: |
61 | bool first(); | ||
62 | bool last(); | ||
63 | bool next(); | ||
64 | bool prev(); | ||
65 | /* void setFullScreen(); */ | ||
66 | /* void setScaled(); */ | ||
67 | protected: | ||
68 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | ||
69 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | ||
70 | |||
71 | private: | ||
72 | void initializeStates(); | ||
73 | void readConfig( Config& cfg ); | ||
74 | void writeConfig( Config& cfg ) const; | ||
75 | PlayListWidgetPrivate *d; // Private implementation data | ||
76 | void populateAudioView(); | ||
77 | void populateVideoView(); | ||
78 | private slots: | ||
61 | void setDocument( const QString& fileref ); | 79 | void setDocument( const QString& fileref ); |
62 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
63 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
64 | void setActiveWindow(); // need to handle this to show the right view | 82 | void setActiveWindow(); // need to handle this to show the right view |
65 | void setPlaylist( bool ); // Show/Hide the playlist | 83 | void setPlaylist( bool ); // Show/Hide the playlist |
66 | void setView( char ); | 84 | void setView( char ); |
67 | void clearList(); | 85 | void clearList(); |
68 | void addAllToList(); | 86 | void addAllToList(); |
69 | void addAllMusicToList(); | 87 | void addAllMusicToList(); |
70 | void addAllVideoToList(); | 88 | void addAllVideoToList(); |
71 | void saveList(); // Save the playlist | 89 | void saveList(); // Save the playlist |
72 | void loadList( const DocLnk &); // Load a playlist | 90 | void loadList( const DocLnk &); // Load a playlist |
73 | void playIt( QListViewItem *); | 91 | void playIt( QListViewItem *); |
74 | 92 | ||
75 | void btnPlay(bool); | 93 | void btnPlay(bool); |
76 | void deletePlaylist(); | 94 | void deletePlaylist(); |
77 | bool first(); | ||
78 | bool last(); | ||
79 | bool next(); | ||
80 | bool prev(); | ||
81 | void addSelected(); | 95 | void addSelected(); |
82 | void removeSelected(); | 96 | void removeSelected(); |
83 | void tabChanged(QWidget*); | 97 | void tabChanged(QWidget*); |
84 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 98 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
85 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
86 | void playSelected(); | 100 | void playSelected(); |
87 | /* void setFullScreen(); */ | 101 | void listDelete(); |
88 | /* void setScaled(); */ | 102 | |
89 | protected: | ||
90 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | ||
91 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | ||
92 | |||
93 | private: | ||
94 | void initializeStates(); | ||
95 | void readConfig( Config& cfg ); | ||
96 | void writeConfig( Config& cfg ) const; | ||
97 | PlayListWidgetPrivate *d; // Private implementation data | ||
98 | |||
99 | protected slots: | 103 | protected slots: |
100 | /* void cancelMenuTimer(); */ | 104 | /* void cancelMenuTimer(); */ |
101 | /* void showFileMenu(); */ | 105 | /* void showFileMenu(); */ |
102 | 106 | ||
103 | 107 | ||
104 | }; | 108 | }; |
105 | 109 | ||
106 | 110 | ||
107 | #endif // PLAY_LIST_WIDGET_H | 111 | #endif // PLAY_LIST_WIDGET_H |
108 | 112 | ||