Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index cb58888..9969526 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -9,25 +9,24 @@ | |||
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 | |||
22 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/fileselector.h> | 23 | #include <qpe/fileselector.h> |
25 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
26 | 25 | ||
27 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
29 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
30 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
31 | #include <qaction.h> | 30 | #include <qaction.h> |
32 | #include <qimage.h> | 31 | #include <qimage.h> |
33 | #include <qfile.h> | 32 | #include <qfile.h> |
@@ -247,83 +246,88 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
247 | if ( QFile( Vdit.current()->file()).exists() ) { | 246 | if ( QFile( Vdit.current()->file()).exists() ) { |
248 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 247 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
249 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 248 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
250 | } | 249 | } |
251 | } | 250 | } |
252 | 251 | ||
253 | //playlists list | 252 | //playlists list |
254 | QWidget *LTab; | 253 | QWidget *LTab; |
255 | LTab = new QWidget( tabWidget, "LTab" ); | 254 | LTab = new QWidget( tabWidget, "LTab" ); |
256 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 255 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
257 | playLists->setMinimumSize(233,260);; | 256 | playLists->setMinimumSize(233,260);; |
258 | tabWidget->insertTab(LTab,"Lists"); | 257 | tabWidget->insertTab(LTab,"Lists"); |
258 | |||
259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
260 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 260 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
261 | 261 | ||
262 | 262 | ||
263 | // add the library area | 263 | // add the library area |
264 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 264 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
265 | 265 | ||
266 | 266 | ||
267 | connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 267 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
268 | this, SLOT( fauxPlay( QListViewItem *) ) ); | 268 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
269 | connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 269 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
270 | this, SLOT( fauxPlay( QListViewItem *)) ); | 270 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
271 | 271 | ||
272 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 272 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
273 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 273 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
274 | 274 | ||
275 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 275 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
276 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 276 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
277 | 277 | ||
278 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 278 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
279 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 279 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
280 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 280 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
281 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 281 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
282 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 282 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
283 | 283 | ||
284 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 284 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
285 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 285 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
286 | 286 | ||
287 | setCentralWidget( vbox5 ); | 287 | setCentralWidget( vbox5 ); |
288 | 288 | ||
289 | Config cfg( "MediaPlayer" ); | 289 | Config cfg( "MediaPlayer" ); |
290 | readConfig( cfg ); | 290 | readConfig( cfg ); |
291 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | ||
292 | // qDebug("currentList is "+currentPlaylist); | ||
293 | loadList(DocLnk( currentPlaylist)); | ||
294 | setCaption("OpiePlayer: "+ currentPlaylist ); | ||
291 | 295 | ||
292 | initializeStates(); | 296 | initializeStates(); |
293 | } | 297 | } |
294 | 298 | ||
295 | 299 | ||
296 | PlayListWidget::~PlayListWidget() { | 300 | PlayListWidget::~PlayListWidget() { |
297 | Config cfg( "MediaPlayer" ); | 301 | Config cfg( "MediaPlayer" ); |
298 | writeConfig( cfg ); | 302 | writeConfig( cfg ); |
299 | 303 | ||
304 | |||
300 | if ( d->current ) | 305 | if ( d->current ) |
301 | delete d->current; | 306 | delete d->current; |
302 | delete d; | 307 | delete d; |
303 | } | 308 | } |
304 | 309 | ||
305 | 310 | ||
306 | void PlayListWidget::initializeStates() { | 311 | void PlayListWidget::initializeStates() { |
307 | 312 | ||
308 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 313 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
309 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 314 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
310 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 315 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
311 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 316 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
312 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 317 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
313 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 318 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
314 | // setPlaylist( mediaPlayerState->playlist() ); | 319 | // setPlaylist( mediaPlayerState->playlist() ); |
315 | setPlaylist( true); | 320 | setPlaylist( true); |
316 | d->selectedFiles->first(); | 321 | d->selectedFiles->first(); |
317 | |||
318 | } | 322 | } |
319 | 323 | ||
320 | 324 | ||
321 | void PlayListWidget::readConfig( Config& cfg ) { | 325 | void PlayListWidget::readConfig( Config& cfg ) { |
322 | cfg.setGroup("PlayList"); | 326 | cfg.setGroup("PlayList"); |
323 | 327 | ||
324 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 328 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
325 | 329 | ||
326 | for ( int i = 0; i < noOfFiles; i++ ) { | 330 | for ( int i = 0; i < noOfFiles; i++ ) { |
327 | QString entryName; | 331 | QString entryName; |
328 | entryName.sprintf( "File%i", i + 1 ); | 332 | entryName.sprintf( "File%i", i + 1 ); |
329 | QString linkFile = cfg.readEntry( entryName ); | 333 | QString linkFile = cfg.readEntry( entryName ); |
@@ -363,25 +367,25 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
363 | } | 367 | } |
364 | noOfFiles++; | 368 | noOfFiles++; |
365 | } | 369 | } |
366 | } while ( d->selectedFiles->next() ); | 370 | } while ( d->selectedFiles->next() ); |
367 | 371 | ||
368 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 372 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
369 | 373 | ||
370 | 374 | ||
371 | } | 375 | } |
372 | 376 | ||
373 | 377 | ||
374 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 378 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
375 | qDebug("add"); | 379 | // qDebug("add"); |
376 | d->setDocumentUsed = FALSE; | 380 | d->setDocumentUsed = FALSE; |
377 | if ( mediaPlayerState->playlist() ) | 381 | if ( mediaPlayerState->playlist() ) |
378 | d->selectedFiles->addToSelection( lnk ); | 382 | d->selectedFiles->addToSelection( lnk ); |
379 | else | 383 | else |
380 | mediaPlayerState->setPlaying( TRUE ); | 384 | mediaPlayerState->setPlaying( TRUE ); |
381 | } | 385 | } |
382 | 386 | ||
383 | 387 | ||
384 | void PlayListWidget::clearList() { | 388 | void PlayListWidget::clearList() { |
385 | while ( first() ) | 389 | while ( first() ) |
386 | d->selectedFiles->removeSelected(); | 390 | d->selectedFiles->removeSelected(); |
387 | } | 391 | } |
@@ -410,24 +414,25 @@ void PlayListWidget::addAllVideoToList() { | |||
410 | Global::findDocuments(&files, "video/*"); | 414 | Global::findDocuments(&files, "video/*"); |
411 | QListIterator<DocLnk> dit( files.children() ); | 415 | QListIterator<DocLnk> dit( files.children() ); |
412 | for ( ; dit.current(); ++dit ) | 416 | for ( ; dit.current(); ++dit ) |
413 | d->selectedFiles->addToSelection( **dit ); | 417 | d->selectedFiles->addToSelection( **dit ); |
414 | } | 418 | } |
415 | 419 | ||
416 | 420 | ||
417 | void PlayListWidget::setDocument(const QString& fileref) { | 421 | void PlayListWidget::setDocument(const QString& fileref) { |
418 | if ( fileref.isNull() ) { | 422 | if ( fileref.isNull() ) { |
419 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 423 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
420 | return; | 424 | return; |
421 | } | 425 | } |
426 | // qDebug("setDocument"); | ||
422 | if(fileref.find("playlist",0,TRUE) == -1) { | 427 | if(fileref.find("playlist",0,TRUE) == -1) { |
423 | addToSelection( DocLnk( fileref ) ); | 428 | addToSelection( DocLnk( fileref ) ); |
424 | d->setDocumentUsed = TRUE; | 429 | d->setDocumentUsed = TRUE; |
425 | qApp->processEvents(); | 430 | qApp->processEvents(); |
426 | mediaPlayerState->setPlaying( FALSE ); | 431 | mediaPlayerState->setPlaying( FALSE ); |
427 | qApp->processEvents(); | 432 | qApp->processEvents(); |
428 | mediaPlayerState->setPlaying( TRUE ); | 433 | mediaPlayerState->setPlaying( TRUE ); |
429 | d->selectedFiles->removeSelected( ); | 434 | d->selectedFiles->removeSelected( ); |
430 | } else { | 435 | } else { |
431 | loadList(DocLnk(fileref)); | 436 | loadList(DocLnk(fileref)); |
432 | d->selectedFiles->first(); | 437 | d->selectedFiles->first(); |
433 | // mediaPlayerState->setPlaying( TRUE ); | 438 | // mediaPlayerState->setPlaying( TRUE ); |
@@ -527,51 +532,70 @@ bool PlayListWidget::last() { | |||
527 | else | 532 | else |
528 | return mediaPlayerState->looping(); | 533 | return mediaPlayerState->looping(); |
529 | } | 534 | } |
530 | 535 | ||
531 | 536 | ||
532 | void PlayListWidget::saveList() { | 537 | void PlayListWidget::saveList() { |
533 | 538 | ||
534 | QString filename; | 539 | QString filename; |
535 | InputDialog *fileDlg; | 540 | InputDialog *fileDlg; |
536 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); | 541 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); |
537 | fileDlg->exec(); | 542 | fileDlg->exec(); |
538 | if( fileDlg->result() == 1 ) { | 543 | if( fileDlg->result() == 1 ) { |
544 | if ( d->current ) | ||
545 | delete d->current; | ||
539 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 546 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
540 | qDebug("saving playlist "+filename+".playlist"); | 547 | // qDebug("saving playlist "+filename+".playlist"); |
541 | Config cfg( filename +".playlist"); | 548 | Config cfg( filename +".playlist"); |
542 | writeConfig( cfg ); | 549 | writeConfig( cfg ); |
550 | if( playLists->selected()->name() == filename) { | ||
551 | // qDebug("same name so delete lnk"); | ||
552 | QFile().remove(playLists->selected()->file()); | ||
553 | QFile().remove(playLists->selected()->linkFile()); | ||
554 | playLists->reread(); | ||
555 | } | ||
556 | |||
543 | DocLnk lnk; | 557 | DocLnk lnk; |
544 | // lnk.setComment( ""); | 558 | // lnk.setComment( ""); |
545 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 559 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
546 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 560 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
547 | lnk.setIcon("mpegplayer/playlist2"); | 561 | lnk.setIcon("mpegplayer/playlist2"); |
548 | lnk.setName( filename); //sets file name | 562 | lnk.setName( filename); //sets file name |
549 | if(!lnk.writeLink()) | 563 | if(!lnk.writeLink()) |
550 | qDebug("Writing doclink did not work"); | 564 | qDebug("Writing doclink did not work"); |
551 | } | 565 | } |
552 | 566 | Config config( "MediaPlayer" ); | |
567 | config.writeEntry("CurrentPlaylist",filename); | ||
568 | setCaption("OpiePlayer: "+filename); | ||
569 | d->selectedFiles->first(); | ||
553 | if(fileDlg) | 570 | if(fileDlg) |
554 | delete fileDlg; | 571 | delete fileDlg; |
555 | 572 | ||
556 | } | 573 | } |
557 | 574 | ||
558 | 575 | ||
559 | void PlayListWidget::loadList( const DocLnk & lnk) { | 576 | void PlayListWidget::loadList( const DocLnk & lnk) { |
560 | qDebug("load list "+ lnk.name()+".playlist"); | 577 | QString name= lnk.name(); |
578 | // qDebug("currentList is "+name); | ||
579 | if( name.length()>1) { | ||
580 | setCaption("OpiePlayer: "+name); | ||
581 | // qDebug("load list "+ name+".playlist"); | ||
561 | clearList(); | 582 | clearList(); |
562 | Config cfg( lnk.name()+".playlist"); | 583 | Config cfg( name+".playlist"); |
563 | readConfig(cfg); | 584 | readConfig(cfg); |
564 | tabWidget->setCurrentPage(0); | 585 | tabWidget->setCurrentPage(0); |
565 | setCaption("OpiePlayer: "+lnk.name()); | 586 | Config config( "MediaPlayer" ); |
587 | config.writeEntry("CurrentPlaylist", name); | ||
588 | d->selectedFiles->first(); | ||
589 | } | ||
566 | } | 590 | } |
567 | 591 | ||
568 | 592 | ||
569 | void PlayListWidget::setPlaylist( bool shown ) { | 593 | void PlayListWidget::setPlaylist( bool shown ) { |
570 | if ( shown ) | 594 | if ( shown ) |
571 | d->playListFrame->show(); | 595 | d->playListFrame->show(); |
572 | else | 596 | else |
573 | d->playListFrame->hide(); | 597 | d->playListFrame->hide(); |
574 | } | 598 | } |
575 | 599 | ||
576 | 600 | ||
577 | void PlayListWidget::setView( char view ) { | 601 | void PlayListWidget::setView( char view ) { |