-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6e2457f..707f4d2 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -318,695 +318,696 @@ void PlayListWidget::addAllMusicToList() { | |||
318 | } | 318 | } |
319 | 319 | ||
320 | /* if(!audioScan) | 320 | /* if(!audioScan) |
321 | scanForAudio(); | 321 | scanForAudio(); |
322 | QListIterator<DocLnk> dit( files.children() ); | 322 | QListIterator<DocLnk> dit( files.children() ); |
323 | for ( ; dit.current(); ++dit ) { | 323 | for ( ; dit.current(); ++dit ) { |
324 | if( QFileInfo(dit.current()->file() ).exists() ) { | 324 | if( QFileInfo(dit.current()->file() ).exists() ) { |
325 | d->selectedFiles->addToSelection( **dit ); | 325 | d->selectedFiles->addToSelection( **dit ); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | */ | 328 | */ |
329 | tabWidget->setCurrentPage(0); | 329 | tabWidget->setCurrentPage(0); |
330 | writeCurrentM3u(); | 330 | writeCurrentM3u(); |
331 | d->selectedFiles->first(); | 331 | d->selectedFiles->first(); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | void PlayListWidget::addAllVideoToList() { | 335 | void PlayListWidget::addAllVideoToList() { |
336 | 336 | ||
337 | videoView->populateView(); | 337 | videoView->populateView(); |
338 | 338 | ||
339 | QListViewItemIterator videoIt( videoView ); | 339 | QListViewItemIterator videoIt( videoView ); |
340 | DocLnk lnk; | 340 | DocLnk lnk; |
341 | QString filename; | 341 | QString filename; |
342 | for ( ; videoIt.current(); ++videoIt ) { | 342 | for ( ; videoIt.current(); ++videoIt ) { |
343 | filename = videoIt.current()->text(3); | 343 | filename = videoIt.current()->text(3); |
344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
345 | lnk.setFile( filename ); //sets file name | 345 | lnk.setFile( filename ); //sets file name |
346 | d->selectedFiles->addToSelection( lnk); | 346 | d->selectedFiles->addToSelection( lnk); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | /* if(!videoScan) | 350 | /* if(!videoScan) |
351 | scanForVideo(); | 351 | scanForVideo(); |
352 | QListIterator<DocLnk> dit( vFiles.children() ); | 352 | QListIterator<DocLnk> dit( vFiles.children() ); |
353 | for ( ; dit.current(); ++dit ) { | 353 | for ( ; dit.current(); ++dit ) { |
354 | if( QFileInfo( dit.current()->file() ).exists() ) { | 354 | if( QFileInfo( dit.current()->file() ).exists() ) { |
355 | d->selectedFiles->addToSelection( **dit ); | 355 | d->selectedFiles->addToSelection( **dit ); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | */ | 358 | */ |
359 | tabWidget->setCurrentPage(0); | 359 | tabWidget->setCurrentPage(0); |
360 | writeCurrentM3u(); | 360 | writeCurrentM3u(); |
361 | d->selectedFiles->first(); | 361 | d->selectedFiles->first(); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | void PlayListWidget::setDocument( const QString& fileref ) { | 365 | void PlayListWidget::setDocument( const QString& fileref ) { |
366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
367 | fromSetDocument = TRUE; | 367 | fromSetDocument = TRUE; |
368 | QFileInfo fileInfo(fileref); | 368 | QFileInfo fileInfo(fileref); |
369 | 369 | ||
370 | if ( !fileInfo.exists() ) { | 370 | if ( !fileInfo.exists() ) { |
371 | QMessageBox::warning( this, tr( "Invalid File" ), | 371 | QMessageBox::warning( this, tr( "Invalid File" ), |
372 | tr( "There was a problem in getting the file." ) ); | 372 | tr( "There was a problem in getting the file." ) ); |
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | 375 | ||
376 | clearList(); | 376 | clearList(); |
377 | QString extension = fileInfo.extension(false); | 377 | QString extension = fileInfo.extension(false); |
378 | 378 | ||
379 | if( extension.find( "m3u", 0, false) != -1 | 379 | if( extension.find( "m3u", 0, false) != -1 |
380 | || extension.find( "pls", 0, false) != -1 ) { | 380 | || extension.find( "pls", 0, false) != -1 ) { |
381 | readListFromFile( fileref ); | 381 | readListFromFile( fileref ); |
382 | } else { | 382 | } else { |
383 | clearList(); | 383 | clearList(); |
384 | DocLnk lnk; | 384 | DocLnk lnk; |
385 | lnk.setName( fileInfo.baseName() ); //sets name | 385 | lnk.setName( fileInfo.baseName() ); //sets name |
386 | lnk.setFile( fileref ); //sets file name | 386 | lnk.setFile( fileref ); //sets file name |
387 | addToSelection( lnk ); | 387 | addToSelection( lnk ); |
388 | writeCurrentM3u(); | 388 | writeCurrentM3u(); |
389 | 389 | ||
390 | d->setDocumentUsed = TRUE; | 390 | d->setDocumentUsed = TRUE; |
391 | mediaPlayerState.setPlaying( FALSE ); | 391 | mediaPlayerState.setPlaying( FALSE ); |
392 | mediaPlayerState.setPlaying( TRUE ); | 392 | mediaPlayerState.setPlaying( TRUE ); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | void PlayListWidget::useSelectedDocument() { | 397 | void PlayListWidget::useSelectedDocument() { |
398 | d->setDocumentUsed = FALSE; | 398 | d->setDocumentUsed = FALSE; |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | const DocLnk *PlayListWidget::current() const { // this is fugly | 402 | const DocLnk *PlayListWidget::current() const { // this is fugly |
403 | assert( currentTab() == CurrentPlayList ); | 403 | assert( currentTab() == CurrentPlayList ); |
404 | 404 | ||
405 | const DocLnk *lnk = d->selectedFiles->current(); | 405 | const DocLnk *lnk = d->selectedFiles->current(); |
406 | if ( !lnk ) { | 406 | if ( !lnk ) { |
407 | d->selectedFiles->first(); | 407 | d->selectedFiles->first(); |
408 | lnk = d->selectedFiles->current(); | 408 | lnk = d->selectedFiles->current(); |
409 | } | 409 | } |
410 | assert( lnk ); | 410 | assert( lnk ); |
411 | return lnk; | 411 | return lnk; |
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | bool PlayListWidget::prev() { | 415 | bool PlayListWidget::prev() { |
416 | if ( mediaPlayerState.isShuffled() ) { | 416 | if ( mediaPlayerState.isShuffled() ) { |
417 | const DocLnk *cur = current(); | 417 | const DocLnk *cur = current(); |
418 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 418 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
419 | for ( int i = 0; i < j; i++ ) { | 419 | for ( int i = 0; i < j; i++ ) { |
420 | if ( !d->selectedFiles->next() ) | 420 | if ( !d->selectedFiles->next() ) |
421 | d->selectedFiles->first(); | 421 | d->selectedFiles->first(); |
422 | } | 422 | } |
423 | if ( cur == current() ) | 423 | if ( cur == current() ) |
424 | if ( !d->selectedFiles->next() ) { | 424 | if ( !d->selectedFiles->next() ) { |
425 | d->selectedFiles->first(); | 425 | d->selectedFiles->first(); |
426 | } | 426 | } |
427 | return TRUE; | 427 | return TRUE; |
428 | } else { | 428 | } else { |
429 | if ( !d->selectedFiles->prev() ) { | 429 | if ( !d->selectedFiles->prev() ) { |
430 | if ( mediaPlayerState.isLooping() ) { | 430 | if ( mediaPlayerState.isLooping() ) { |
431 | return d->selectedFiles->last(); | 431 | return d->selectedFiles->last(); |
432 | } else { | 432 | } else { |
433 | return FALSE; | 433 | return FALSE; |
434 | } | 434 | } |
435 | } | 435 | } |
436 | return TRUE; | 436 | return TRUE; |
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | bool PlayListWidget::next() { | 441 | bool PlayListWidget::next() { |
442 | //qDebug("<<<<<<<<<<<<next()"); | 442 | //qDebug("<<<<<<<<<<<<next()"); |
443 | if ( mediaPlayerState.isShuffled() ) { | 443 | if ( mediaPlayerState.isShuffled() ) { |
444 | return prev(); | 444 | return prev(); |
445 | } else { | 445 | } else { |
446 | if ( !d->selectedFiles->next() ) { | 446 | if ( !d->selectedFiles->next() ) { |
447 | if ( mediaPlayerState.isLooping() ) { | 447 | if ( mediaPlayerState.isLooping() ) { |
448 | return d->selectedFiles->first(); | 448 | return d->selectedFiles->first(); |
449 | } else { | 449 | } else { |
450 | return FALSE; | 450 | return FALSE; |
451 | } | 451 | } |
452 | } | 452 | } |
453 | return TRUE; | 453 | return TRUE; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | bool PlayListWidget::first() { | 458 | bool PlayListWidget::first() { |
459 | return d->selectedFiles->first(); | 459 | return d->selectedFiles->first(); |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
463 | bool PlayListWidget::last() { | 463 | bool PlayListWidget::last() { |
464 | return d->selectedFiles->last(); | 464 | return d->selectedFiles->last(); |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | void PlayListWidget::saveList() { | 468 | void PlayListWidget::saveList() { |
469 | writem3u(); | 469 | writem3u(); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | void PlayListWidget::loadList( const DocLnk & lnk) { | 473 | void PlayListWidget::loadList( const DocLnk & lnk) { |
474 | QString name = lnk.name(); | 474 | QString name = lnk.name(); |
475 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 475 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
476 | 476 | ||
477 | if( name.length()>0) { | 477 | if( name.length()>0) { |
478 | setCaption("OpiePlayer: "+name); | 478 | setCaption("OpiePlayer: "+name); |
479 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 479 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
480 | clearList(); | 480 | clearList(); |
481 | // readm3u(lnk.file()); | 481 | // readm3u(lnk.file()); |
482 | readListFromFile(lnk.file()); | 482 | readListFromFile(lnk.file()); |
483 | tabWidget->setCurrentPage(0); | 483 | tabWidget->setCurrentPage(0); |
484 | } | 484 | } |
485 | } | 485 | } |
486 | 486 | ||
487 | void PlayListWidget::addSelected() { | 487 | void PlayListWidget::addSelected() { |
488 | assert( inFileListMode() ); | 488 | assert( inFileListMode() ); |
489 | 489 | ||
490 | QListViewItemIterator it( currentFileListView ); | 490 | QListViewItemIterator it( currentFileListView ); |
491 | for ( ; it.current(); ++it ) | 491 | for ( ; it.current(); ++it ) |
492 | if ( it.current()->isSelected() ) { | 492 | if ( it.current()->isSelected() ) { |
493 | QString filename = it.current()->text(3); | 493 | QString filename = it.current()->text(3); |
494 | 494 | ||
495 | DocLnk lnk; | 495 | DocLnk lnk; |
496 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 496 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
497 | lnk.setFile( filename ); //sets file name | 497 | lnk.setFile( filename ); //sets file name |
498 | 498 | ||
499 | d->selectedFiles->addToSelection( lnk ); | 499 | d->selectedFiles->addToSelection( lnk ); |
500 | } | 500 | } |
501 | 501 | ||
502 | currentFileListView->clearSelection(); | 502 | currentFileListView->clearSelection(); |
503 | 503 | ||
504 | // tabWidget->setCurrentPage( 0 ); | 504 | // tabWidget->setCurrentPage( 0 ); |
505 | writeCurrentM3u(); | 505 | writeCurrentM3u(); |
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | void PlayListWidget::removeSelected() { | 509 | void PlayListWidget::removeSelected() { |
510 | d->selectedFiles->removeSelected( ); | 510 | d->selectedFiles->removeSelected( ); |
511 | writeCurrentM3u(); | 511 | writeCurrentM3u(); |
512 | } | 512 | } |
513 | 513 | ||
514 | 514 | ||
515 | void PlayListWidget::playIt( QListViewItem *it) { | 515 | void PlayListWidget::playIt( QListViewItem *it) { |
516 | if(!it) return; | 516 | if(!it) return; |
517 | mediaPlayerState.setPlaying(FALSE); | 517 | mediaPlayerState.setPlaying(FALSE); |
518 | mediaPlayerState.setPlaying(TRUE); | 518 | mediaPlayerState.setPlaying(TRUE); |
519 | d->selectedFiles->unSelect(); | 519 | d->selectedFiles->unSelect(); |
520 | } | 520 | } |
521 | 521 | ||
522 | 522 | ||
523 | void PlayListWidget::addToSelection( QListViewItem *it) { | 523 | void PlayListWidget::addToSelection( QListViewItem *it) { |
524 | d->setDocumentUsed = FALSE; | 524 | d->setDocumentUsed = FALSE; |
525 | 525 | ||
526 | if(it) { | 526 | if(it) { |
527 | if ( currentTab() == CurrentPlayList ) | 527 | if ( currentTab() == CurrentPlayList ) |
528 | return; | 528 | return; |
529 | // case 1: { | 529 | // case 1: { |
530 | DocLnk lnk; | 530 | DocLnk lnk; |
531 | QString filename; | 531 | QString filename; |
532 | 532 | ||
533 | filename=it->text(3); | 533 | filename=it->text(3); |
534 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 534 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
535 | lnk.setFile( filename ); //sets file name | 535 | lnk.setFile( filename ); //sets file name |
536 | d->selectedFiles->addToSelection( lnk); | 536 | d->selectedFiles->addToSelection( lnk); |
537 | 537 | ||
538 | writeCurrentM3u(); | 538 | writeCurrentM3u(); |
539 | // tabWidget->setCurrentPage(0); | 539 | // tabWidget->setCurrentPage(0); |
540 | 540 | ||
541 | } | 541 | } |
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
545 | void PlayListWidget::tabChanged(QWidget *) { | 545 | void PlayListWidget::tabChanged(QWidget *) { |
546 | 546 | ||
547 | d->tbPlay->setEnabled( true ); | 547 | d->tbPlay->setEnabled( true ); |
548 | 548 | ||
549 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), | 549 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), |
550 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 550 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
551 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), | 551 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), |
552 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 552 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
553 | 553 | ||
554 | currentFileListView = 0; | 554 | currentFileListView = 0; |
555 | 555 | ||
556 | switch ( currentTab() ) { | 556 | switch ( currentTab() ) { |
557 | case CurrentPlayList: | 557 | case CurrentPlayList: |
558 | { | 558 | { |
559 | if( !tbDeletePlaylist->isHidden() ) { | 559 | if( !tbDeletePlaylist->isHidden() ) { |
560 | tbDeletePlaylist->hide(); | 560 | tbDeletePlaylist->hide(); |
561 | } | 561 | } |
562 | d->tbRemoveFromList->setEnabled(TRUE); | 562 | d->tbRemoveFromList->setEnabled(TRUE); |
563 | d->tbAddToList->setEnabled(FALSE); | 563 | d->tbAddToList->setEnabled(FALSE); |
564 | 564 | ||
565 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 565 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
566 | } | 566 | } |
567 | break; | 567 | break; |
568 | case AudioFiles: | 568 | case AudioFiles: |
569 | { | 569 | { |
570 | audioView->populateView(); | 570 | audioView->populateView(); |
571 | 571 | ||
572 | if( !tbDeletePlaylist->isHidden() ) { | 572 | if( !tbDeletePlaylist->isHidden() ) { |
573 | tbDeletePlaylist->hide(); | 573 | tbDeletePlaylist->hide(); |
574 | } | 574 | } |
575 | d->tbRemoveFromList->setEnabled(FALSE); | 575 | d->tbRemoveFromList->setEnabled(FALSE); |
576 | d->tbAddToList->setEnabled(TRUE); | 576 | d->tbAddToList->setEnabled(TRUE); |
577 | 577 | ||
578 | connect( audioView, SIGNAL( itemsSelected( bool ) ), | 578 | connect( audioView, SIGNAL( itemsSelected( bool ) ), |
579 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 579 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
580 | 580 | ||
581 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 581 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
582 | 582 | ||
583 | currentFileListView = audioView; | 583 | currentFileListView = audioView; |
584 | } | 584 | } |
585 | break; | 585 | break; |
586 | case VideoFiles: | 586 | case VideoFiles: |
587 | { | 587 | { |
588 | videoView->populateView(); | 588 | videoView->populateView(); |
589 | if( !tbDeletePlaylist->isHidden() ) { | 589 | if( !tbDeletePlaylist->isHidden() ) { |
590 | tbDeletePlaylist->hide(); | 590 | tbDeletePlaylist->hide(); |
591 | } | 591 | } |
592 | d->tbRemoveFromList->setEnabled(FALSE); | 592 | d->tbRemoveFromList->setEnabled(FALSE); |
593 | d->tbAddToList->setEnabled(TRUE); | 593 | d->tbAddToList->setEnabled(TRUE); |
594 | 594 | ||
595 | connect( videoView, SIGNAL( itemsSelected( bool ) ), | 595 | connect( videoView, SIGNAL( itemsSelected( bool ) ), |
596 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 596 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
597 | 597 | ||
598 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 598 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
599 | 599 | ||
600 | currentFileListView = videoView; | 600 | currentFileListView = videoView; |
601 | } | 601 | } |
602 | break; | 602 | break; |
603 | case PlayLists: | 603 | case PlayLists: |
604 | { | 604 | { |
605 | if( tbDeletePlaylist->isHidden() ) { | 605 | if( tbDeletePlaylist->isHidden() ) { |
606 | tbDeletePlaylist->show(); | 606 | tbDeletePlaylist->show(); |
607 | } | 607 | } |
608 | playLists->reread(); | 608 | playLists->reread(); |
609 | d->tbAddToList->setEnabled(FALSE); | 609 | d->tbAddToList->setEnabled(FALSE); |
610 | 610 | ||
611 | d->tbPlay->setEnabled( false ); | 611 | d->tbPlay->setEnabled( false ); |
612 | } | 612 | } |
613 | break; | 613 | break; |
614 | }; | 614 | }; |
615 | } | 615 | } |
616 | 616 | ||
617 | 617 | ||
618 | void PlayListWidget::btnPlay(bool b) { | 618 | void PlayListWidget::btnPlay(bool b) { |
619 | // mediaPlayerState->setPlaying(false); | 619 | // mediaPlayerState->setPlaying(false); |
620 | mediaPlayerState.setPlaying(b); | 620 | mediaPlayerState.setPlaying(b); |
621 | insanityBool=FALSE; | 621 | insanityBool=FALSE; |
622 | } | 622 | } |
623 | 623 | ||
624 | void PlayListWidget::deletePlaylist() { | 624 | void PlayListWidget::deletePlaylist() { |
625 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 625 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
626 | (tr("You really want to delete\nthis playlist?")), | 626 | (tr("You really want to delete\nthis playlist?")), |
627 | (tr("Yes")), (tr("No")), 0 )){ | 627 | (tr("Yes")), (tr("No")), 0 )){ |
628 | case 0: // Yes clicked, | 628 | case 0: // Yes clicked, |
629 | QFile().remove(playLists->selectedDocument().file()); | 629 | QFile().remove(playLists->selectedDocument().file()); |
630 | QFile().remove(playLists->selectedDocument().linkFile()); | 630 | QFile().remove(playLists->selectedDocument().linkFile()); |
631 | playLists->reread(); | 631 | playLists->reread(); |
632 | break; | 632 | break; |
633 | case 1: // Cancel | 633 | case 1: // Cancel |
634 | break; | 634 | break; |
635 | }; | 635 | }; |
636 | } | 636 | } |
637 | 637 | ||
638 | 638 | ||
639 | void PlayListWidget::playSelected() { | 639 | void PlayListWidget::playSelected() { |
640 | btnPlay( TRUE); | 640 | btnPlay( TRUE); |
641 | } | 641 | } |
642 | 642 | ||
643 | bool PlayListWidget::inFileListMode() const | 643 | bool PlayListWidget::inFileListMode() const |
644 | { | 644 | { |
645 | TabType tab = currentTab(); | 645 | TabType tab = currentTab(); |
646 | return tab == AudioFiles || tab == VideoFiles; | 646 | return tab == AudioFiles || tab == VideoFiles; |
647 | } | 647 | } |
648 | 648 | ||
649 | void PlayListWidget::openFile() { | 649 | void PlayListWidget::openFile() { |
650 | // http://66.28.164.33:2080 | 650 | // http://66.28.164.33:2080 |
651 | // http://somafm.com/star0242.m3u | 651 | // http://somafm.com/star0242.m3u |
652 | QString filename, name; | 652 | QString filename, name; |
653 | InputDialog *fileDlg; | 653 | InputDialog *fileDlg; |
654 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 654 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
655 | fileDlg->exec(); | 655 | fileDlg->exec(); |
656 | if( fileDlg->result() == 1 ) { | 656 | if( fileDlg->result() == 1 ) { |
657 | filename = fileDlg->text(); | 657 | filename = fileDlg->text(); |
658 | qDebug( "Selected filename is " + filename ); | 658 | qDebug( "Selected filename is " + filename ); |
659 | // Om3u *m3uList; | 659 | // Om3u *m3uList; |
660 | DocLnk lnk; | 660 | DocLnk lnk; |
661 | Config cfg( "OpiePlayer" ); | 661 | Config cfg( "OpiePlayer" ); |
662 | cfg.setGroup("PlayList"); | 662 | cfg.setGroup("PlayList"); |
663 | 663 | ||
664 | if(filename.left(4) == "http") { | 664 | if(filename.left(4) == "http") { |
665 | QString m3uFile, m3uFilePath; | 665 | QString m3uFile, m3uFilePath; |
666 | if(filename.find(":",8,TRUE) != -1) { //found a port | 666 | if(filename.find(":",8,TRUE) != -1) { //found a port |
667 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 667 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
668 | m3uFile = m3uFile.right( 7); | 668 | m3uFile = m3uFile.right( 7); |
669 | } else if(filename.left(4) == "http"){ | 669 | } else if(filename.left(4) == "http"){ |
670 | m3uFile=filename; | 670 | m3uFile=filename; |
671 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 671 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
672 | } else{ | 672 | } else{ |
673 | m3uFile=filename; | 673 | m3uFile=filename; |
674 | } | 674 | } |
675 | 675 | ||
676 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 676 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
677 | lnk.setName( filename ); //sets name | 677 | lnk.setName( filename ); //sets name |
678 | lnk.setFile( filename ); //sets file name | 678 | lnk.setFile( filename ); //sets file name |
679 | 679 | ||
680 | // lnk.setIcon("opieplayer2/musicfile"); | 680 | // lnk.setIcon("opieplayer2/musicfile"); |
681 | 681 | ||
682 | d->selectedFiles->addToSelection( lnk ); | 682 | d->selectedFiles->addToSelection( lnk ); |
683 | writeCurrentM3u(); | 683 | writeCurrentM3u(); |
684 | d->selectedFiles->setSelectedItem( lnk.name()); | 684 | d->selectedFiles->setSelectedItem( lnk.name()); |
685 | } | 685 | } |
686 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 686 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
687 | readListFromFile( filename ); | 687 | readListFromFile( filename ); |
688 | // readPls( filename ); | 688 | // readPls( filename ); |
689 | } else { | 689 | } else { |
690 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 690 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
691 | lnk.setFile( filename ); //sets file name | 691 | lnk.setFile( filename ); //sets file name |
692 | d->selectedFiles->addToSelection( lnk); | 692 | d->selectedFiles->addToSelection( lnk); |
693 | writeCurrentM3u(); | 693 | writeCurrentM3u(); |
694 | d->selectedFiles->setSelectedItem( lnk.name()); | 694 | d->selectedFiles->setSelectedItem( lnk.name()); |
695 | } | 695 | } |
696 | } | 696 | } |
697 | 697 | ||
698 | 698 | ||
699 | delete fileDlg; | 699 | delete fileDlg; |
700 | } | 700 | } |
701 | 701 | ||
702 | void PlayListWidget::readListFromFile( const QString &filename ) { | 702 | void PlayListWidget::readListFromFile( const QString &filename ) { |
703 | qDebug( "read list filename " + filename ); | 703 | qDebug( "read list filename " + filename ); |
704 | QFileInfo fi(filename); | 704 | QFileInfo fi(filename); |
705 | Om3u *m3uList; | 705 | Om3u *m3uList; |
706 | QString s, name; | 706 | QString s, name; |
707 | m3uList = new Om3u( filename, IO_ReadOnly ); | 707 | m3uList = new Om3u( filename, IO_ReadOnly ); |
708 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 708 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
709 | m3uList->readM3u(); | 709 | m3uList->readM3u(); |
710 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 710 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
711 | m3uList->readPls(); | 711 | m3uList->readPls(); |
712 | 712 | ||
713 | DocLnk lnk; | 713 | DocLnk lnk; |
714 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 714 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
715 | s = *it; | 715 | s = *it; |
716 | // qDebug(s); | 716 | // qDebug(s); |
717 | if(s.left(4)=="http") { | 717 | if(s.left(4)=="http") { |
718 | lnk.setName( s ); //sets file name | 718 | lnk.setName( s ); //sets file name |
719 | lnk.setIcon("opieplayer2/musicfile"); | 719 | lnk.setIcon("opieplayer2/musicfile"); |
720 | lnk.setFile( s ); //sets file name | 720 | lnk.setFile( s ); //sets file name |
721 | 721 | ||
722 | } else { //is file | 722 | } else { //is file |
723 | lnk.setName( QFileInfo(s).baseName()); | 723 | lnk.setName( QFileInfo(s).baseName()); |
724 | if(s.left(1) != "/") { | 724 | if(s.left(1) != "/") { |
725 | 725 | ||
726 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 726 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
727 | } else { | 727 | } else { |
728 | lnk.setFile( s); | 728 | lnk.setFile( s); |
729 | } | 729 | } |
730 | } | 730 | } |
731 | d->selectedFiles->addToSelection( lnk ); | 731 | d->selectedFiles->addToSelection( lnk ); |
732 | } | 732 | } |
733 | Config config( "OpiePlayer" ); | 733 | Config config( "OpiePlayer" ); |
734 | config.setGroup( "PlayList" ); | 734 | config.setGroup( "PlayList" ); |
735 | 735 | ||
736 | config.writeEntry("CurrentPlaylist",filename); | 736 | config.writeEntry("CurrentPlaylist",filename); |
737 | config.write(); | 737 | config.write(); |
738 | currentPlayList=filename; | 738 | currentPlayList=filename; |
739 | 739 | ||
740 | // m3uList->write(); | 740 | // m3uList->write(); |
741 | m3uList->close(); | 741 | m3uList->close(); |
742 | delete m3uList; | 742 | delete m3uList; |
743 | 743 | ||
744 | d->selectedFiles->setSelectedItem( s); | 744 | d->selectedFiles->setSelectedItem( s); |
745 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 745 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
746 | 746 | ||
747 | } | 747 | } |
748 | 748 | ||
749 | // /* | 749 | // /* |
750 | // reads pls and adds files/urls to playlist */ | 750 | // reads pls and adds files/urls to playlist */ |
751 | // void PlayListWidget::readPls( const QString &filename ) { | 751 | // void PlayListWidget::readPls( const QString &filename ) { |
752 | 752 | ||
753 | // qDebug( "pls filename is " + filename ); | 753 | // qDebug( "pls filename is " + filename ); |
754 | // Om3u *m3uList; | 754 | // Om3u *m3uList; |
755 | // QString s, name; | 755 | // QString s, name; |
756 | // m3uList = new Om3u( filename, IO_ReadOnly ); | 756 | // m3uList = new Om3u( filename, IO_ReadOnly ); |
757 | // m3uList->readPls(); | 757 | // m3uList->readPls(); |
758 | 758 | ||
759 | // for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 759 | // for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
760 | // s = *it; | 760 | // s = *it; |
761 | // // s.replace( QRegExp( "%20" )," " ); | 761 | // // s.replace( QRegExp( "%20" )," " ); |
762 | // DocLnk lnk( s ); | 762 | // DocLnk lnk( s ); |
763 | // QFileInfo f( s ); | 763 | // QFileInfo f( s ); |
764 | // QString name = f.baseName(); | 764 | // QString name = f.baseName(); |
765 | 765 | ||
766 | // if( name.left( 4 ) == "http" ) { | 766 | // if( name.left( 4 ) == "http" ) { |
767 | // name = s.right( s.length() - 7); | 767 | // name = s.right( s.length() - 7); |
768 | // } else { | 768 | // } else { |
769 | // name = s; | 769 | // name = s; |
770 | // } | 770 | // } |
771 | 771 | ||
772 | // name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 772 | // name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
773 | 773 | ||
774 | // lnk.setName( name ); | 774 | // lnk.setName( name ); |
775 | // if( s.at( s.length() - 4) == '.') {// if this is probably a file | 775 | // if( s.at( s.length() - 4) == '.') {// if this is probably a file |
776 | // lnk.setFile( s ); | 776 | // lnk.setFile( s ); |
777 | // } else { //if its a url | 777 | // } else { //if its a url |
778 | // // if( name.right( 1 ).find( '/' ) == -1) { | 778 | // // if( name.right( 1 ).find( '/' ) == -1) { |
779 | // // s += "/"; | 779 | // // s += "/"; |
780 | // // } | 780 | // // } |
781 | // lnk.setFile( s ); | 781 | // lnk.setFile( s ); |
782 | // } | 782 | // } |
783 | // lnk.setType( "audio/x-mpegurl" ); | 783 | // lnk.setType( "audio/x-mpegurl" ); |
784 | 784 | ||
785 | // lnk.writeLink(); | 785 | // lnk.writeLink(); |
786 | // d->selectedFiles->addToSelection( lnk ); | 786 | // d->selectedFiles->addToSelection( lnk ); |
787 | // } | 787 | // } |
788 | 788 | ||
789 | // m3uList->close(); | 789 | // m3uList->close(); |
790 | // delete m3uList; | 790 | // delete m3uList; |
791 | // } | 791 | // } |
792 | 792 | ||
793 | // /* | 793 | // /* |
794 | // writes current playlist to current m3u file */ | 794 | // writes current playlist to current m3u file */ |
795 | void PlayListWidget::writeCurrentM3u() { | 795 | void PlayListWidget::writeCurrentM3u() { |
796 | qDebug("writing to current m3u"); | 796 | qDebug("writing to current m3u"); |
797 | Config cfg( "OpiePlayer" ); | 797 | Config cfg( "OpiePlayer" ); |
798 | cfg.setGroup("PlayList"); | 798 | cfg.setGroup("PlayList"); |
799 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 799 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
800 | 800 | ||
801 | Om3u *m3uList; | 801 | Om3u *m3uList; |
802 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 802 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
803 | if( d->selectedFiles->first()) { | 803 | if( d->selectedFiles->first()) { |
804 | 804 | ||
805 | do { | 805 | do { |
806 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 806 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
807 | m3uList->add( d->selectedFiles->current()->file() ); | 807 | m3uList->add( d->selectedFiles->current()->file() ); |
808 | } | 808 | } |
809 | while ( d->selectedFiles->next() ); | 809 | while ( d->selectedFiles->next() ); |
810 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 810 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
811 | m3uList->write(); | 811 | m3uList->write(); |
812 | m3uList->close(); | 812 | m3uList->close(); |
813 | } | 813 | } |
814 | delete m3uList; | 814 | delete m3uList; |
815 | 815 | ||
816 | } | 816 | } |
817 | 817 | ||
818 | /* | 818 | /* |
819 | writes current playlist to m3u file */ | 819 | writes current playlist to m3u file */ |
820 | void PlayListWidget::writem3u() { | 820 | void PlayListWidget::writem3u() { |
821 | InputDialog *fileDlg; | 821 | InputDialog *fileDlg; |
822 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 822 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
823 | fileDlg->exec(); | 823 | fileDlg->exec(); |
824 | QString name, filename, list; | 824 | QString name, filename, list; |
825 | Om3u *m3uList; | 825 | Om3u *m3uList; |
826 | 826 | ||
827 | if( fileDlg->result() == 1 ) { | 827 | if( fileDlg->result() == 1 ) { |
828 | name = fileDlg->text(); | 828 | name = fileDlg->text(); |
829 | // qDebug( filename ); | 829 | // qDebug( filename ); |
830 | 830 | if( name.find("/",0,true) != -1) {// assume they specify a file path | |
831 | if( name.left( 1) != "/" ) { | 831 | filename = name; |
832 | filename = QPEApplication::documentDir() + "/" + name; | 832 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
833 | } | ||
834 | |||
835 | if( name.right( 3 ) != "m3u" ) { | ||
836 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | ||
837 | } | 833 | } |
834 | else //otherwise dump it somewhere noticable | ||
835 | filename = QPEApplication::documentDir() + "/" + name; | ||
838 | 836 | ||
839 | if( d->selectedFiles->first()) { | 837 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
840 | m3uList = new Om3u(filename, IO_ReadWrite); | 838 | filename += ".m3u"; |
839 | |||
840 | if( d->selectedFiles->first()) { //ramble through playlist view | ||
841 | m3uList = new Om3u( filename, IO_ReadWrite); | ||
841 | 842 | ||
842 | do { | 843 | do { |
843 | m3uList->add( d->selectedFiles->current()->file()); | 844 | m3uList->add( d->selectedFiles->current()->file()); |
844 | } | 845 | } |
845 | while ( d->selectedFiles->next() ); | 846 | while ( d->selectedFiles->next() ); |
846 | // qDebug( list ); | 847 | // qDebug( list ); |
847 | m3uList->write(); | 848 | m3uList->write(); |
848 | m3uList->close(); | 849 | m3uList->close(); |
849 | delete m3uList; | 850 | delete m3uList; |
850 | 851 | ||
851 | delete fileDlg; | 852 | delete fileDlg; |
852 | 853 | ||
853 | DocLnk lnk; | 854 | DocLnk lnk; |
854 | lnk.setFile( filename); | 855 | lnk.setFile( filename); |
855 | lnk.setIcon("opieplayer2/playlist2"); | 856 | lnk.setIcon("opieplayer2/playlist2"); |
856 | lnk.setName( name); //sets file name | 857 | lnk.setName( name); //sets file name |
857 | 858 | ||
858 | // qDebug(filename); | 859 | // qDebug(filename); |
859 | Config config( "OpiePlayer" ); | 860 | Config config( "OpiePlayer" ); |
860 | config.setGroup( "PlayList" ); | 861 | config.setGroup( "PlayList" ); |
861 | 862 | ||
862 | config.writeEntry("CurrentPlaylist",filename); | 863 | config.writeEntry("CurrentPlaylist",filename); |
863 | currentPlayList=filename; | 864 | currentPlayList=filename; |
864 | 865 | ||
865 | if(!lnk.writeLink()) { | 866 | if(!lnk.writeLink()) { |
866 | qDebug("Writing doclink did not work"); | 867 | qDebug("Writing doclink did not work"); |
867 | } | 868 | } |
868 | 869 | ||
869 | setCaption(tr("OpiePlayer: ") + name); | 870 | setCaption(tr("OpiePlayer: ") + name); |
870 | } | 871 | } |
871 | } | 872 | } |
872 | } | 873 | } |
873 | 874 | ||
874 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 875 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
875 | switch ( e->key() ) { | 876 | switch ( e->key() ) { |
876 | ////////////////////////////// Zaurus keys | 877 | ////////////////////////////// Zaurus keys |
877 | case Key_F9: //activity | 878 | case Key_F9: //activity |
878 | // if(audioUI->isHidden()) | 879 | // if(audioUI->isHidden()) |
879 | // audioUI->showMaximized(); | 880 | // audioUI->showMaximized(); |
880 | break; | 881 | break; |
881 | case Key_F10: //contacts | 882 | case Key_F10: //contacts |
882 | // if( videoUI->isHidden()) | 883 | // if( videoUI->isHidden()) |
883 | // videoUI->showMaximized(); | 884 | // videoUI->showMaximized(); |
884 | break; | 885 | break; |
885 | case Key_F11: //menu | 886 | case Key_F11: //menu |
886 | break; | 887 | break; |
887 | case Key_F12: //home | 888 | case Key_F12: //home |
888 | // doBlank(); | 889 | // doBlank(); |
889 | break; | 890 | break; |
890 | case Key_F13: //mail | 891 | case Key_F13: //mail |
891 | // doUnblank(); | 892 | // doUnblank(); |
892 | break; | 893 | break; |
893 | case Key_Q: //add to playlist | 894 | case Key_Q: //add to playlist |
894 | addSelected(); | 895 | addSelected(); |
895 | break; | 896 | break; |
896 | case Key_R: //remove from playlist | 897 | case Key_R: //remove from playlist |
897 | removeSelected(); | 898 | removeSelected(); |
898 | break; | 899 | break; |
899 | // case Key_P: //play | 900 | // case Key_P: //play |
900 | // qDebug("Play"); | 901 | // qDebug("Play"); |
901 | // playSelected(); | 902 | // playSelected(); |
902 | // break; | 903 | // break; |
903 | case Key_Space: | 904 | case Key_Space: |
904 | // playSelected(); puh | 905 | // playSelected(); puh |
905 | break; | 906 | break; |
906 | case Key_1: | 907 | case Key_1: |
907 | tabWidget->setCurrentPage( 0 ); | 908 | tabWidget->setCurrentPage( 0 ); |
908 | break; | 909 | break; |
909 | case Key_2: | 910 | case Key_2: |
910 | tabWidget->setCurrentPage( 1 ); | 911 | tabWidget->setCurrentPage( 1 ); |
911 | break; | 912 | break; |
912 | case Key_3: | 913 | case Key_3: |
913 | tabWidget->setCurrentPage( 2 ); | 914 | tabWidget->setCurrentPage( 2 ); |
914 | break; | 915 | break; |
915 | case Key_4: | 916 | case Key_4: |
916 | tabWidget->setCurrentPage( 3 ); | 917 | tabWidget->setCurrentPage( 3 ); |
917 | break; | 918 | break; |
918 | case Key_Down: | 919 | case Key_Down: |
919 | if ( !d->selectedFiles->next() ) | 920 | if ( !d->selectedFiles->next() ) |
920 | d->selectedFiles->first(); | 921 | d->selectedFiles->first(); |
921 | break; | 922 | break; |
922 | case Key_Up: | 923 | case Key_Up: |
923 | if ( !d->selectedFiles->prev() ) | 924 | if ( !d->selectedFiles->prev() ) |
924 | // d->selectedFiles->last(); | 925 | // d->selectedFiles->last(); |
925 | break; | 926 | break; |
926 | } | 927 | } |
927 | } | 928 | } |
928 | 929 | ||
929 | void PlayListWidget::pmViewActivated(int index) { | 930 | void PlayListWidget::pmViewActivated(int index) { |
930 | // qDebug("%d", index); | 931 | // qDebug("%d", index); |
931 | switch(index) { | 932 | switch(index) { |
932 | case -16: | 933 | case -16: |
933 | { | 934 | { |
934 | mediaPlayerState.toggleFullscreen(); | 935 | mediaPlayerState.toggleFullscreen(); |
935 | bool b=mediaPlayerState.isFullscreen(); | 936 | bool b=mediaPlayerState.isFullscreen(); |
936 | pmView->setItemChecked( index, b); | 937 | pmView->setItemChecked( index, b); |
937 | Config cfg( "OpiePlayer" ); | 938 | Config cfg( "OpiePlayer" ); |
938 | cfg.writeEntry( "FullScreen", b ); | 939 | cfg.writeEntry( "FullScreen", b ); |
939 | } | 940 | } |
940 | break; | 941 | break; |
941 | }; | 942 | }; |
942 | } | 943 | } |
943 | 944 | ||
944 | void PlayListWidget::populateSkinsMenu() { | 945 | void PlayListWidget::populateSkinsMenu() { |
945 | int item = 0; | 946 | int item = 0; |
946 | defaultSkinIndex = 0; | 947 | defaultSkinIndex = 0; |
947 | QString skinName; | 948 | QString skinName; |
948 | Config cfg( "OpiePlayer" ); | 949 | Config cfg( "OpiePlayer" ); |
949 | cfg.setGroup("Options" ); | 950 | cfg.setGroup("Options" ); |
950 | QString skin = cfg.readEntry( "Skin", "default" ); | 951 | QString skin = cfg.readEntry( "Skin", "default" ); |
951 | 952 | ||
952 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 953 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
953 | skinsDir.setFilter( QDir::Dirs ); | 954 | skinsDir.setFilter( QDir::Dirs ); |
954 | skinsDir.setSorting(QDir::Name ); | 955 | skinsDir.setSorting(QDir::Name ); |
955 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 956 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
956 | QFileInfoListIterator it( *skinslist ); | 957 | QFileInfoListIterator it( *skinslist ); |
957 | QFileInfo *fi; | 958 | QFileInfo *fi; |
958 | while ( ( fi = it.current() ) ) { | 959 | while ( ( fi = it.current() ) ) { |
959 | skinName = fi->fileName(); | 960 | skinName = fi->fileName(); |
960 | // qDebug( fi->fileName() ); | 961 | // qDebug( fi->fileName() ); |
961 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 962 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
962 | item = skinsMenu->insertItem( fi->fileName() ) ; | 963 | item = skinsMenu->insertItem( fi->fileName() ) ; |
963 | } | 964 | } |
964 | if( skinName == "default" ) { | 965 | if( skinName == "default" ) { |
965 | defaultSkinIndex = item; | 966 | defaultSkinIndex = item; |
966 | } | 967 | } |
967 | if( skinName == skin ) { | 968 | if( skinName == skin ) { |
968 | skinsMenu->setItemChecked( item, TRUE ); | 969 | skinsMenu->setItemChecked( item, TRUE ); |
969 | } | 970 | } |
970 | ++it; | 971 | ++it; |
971 | } | 972 | } |
972 | } | 973 | } |
973 | 974 | ||
974 | void PlayListWidget::skinsMenuActivated( int item ) { | 975 | void PlayListWidget::skinsMenuActivated( int item ) { |
975 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 976 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
976 | skinsMenu->setItemChecked( i, FALSE ); | 977 | skinsMenu->setItemChecked( i, FALSE ); |
977 | } | 978 | } |
978 | skinsMenu->setItemChecked( item, TRUE ); | 979 | skinsMenu->setItemChecked( item, TRUE ); |
979 | 980 | ||
980 | { | 981 | { |
981 | Config cfg( "OpiePlayer" ); | 982 | Config cfg( "OpiePlayer" ); |
982 | cfg.setGroup("Options"); | 983 | cfg.setGroup("Options"); |
983 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 984 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
984 | } | 985 | } |
985 | 986 | ||
986 | emit skinSelected(); | 987 | emit skinSelected(); |
987 | } | 988 | } |
988 | 989 | ||
989 | PlayListWidget::TabType PlayListWidget::currentTab() const | 990 | PlayListWidget::TabType PlayListWidget::currentTab() const |
990 | { | 991 | { |
991 | static const TabType indexToTabType[ TabTypeCount ] = | 992 | static const TabType indexToTabType[ TabTypeCount ] = |
992 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 993 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
993 | 994 | ||
994 | int index = tabWidget->currentPageIndex(); | 995 | int index = tabWidget->currentPageIndex(); |
995 | assert( index < TabTypeCount && index >= 0 ); | 996 | assert( index < TabTypeCount && index >= 0 ); |
996 | 997 | ||
997 | return indexToTabType[ index ]; | 998 | return indexToTabType[ index ]; |
998 | } | 999 | } |
999 | 1000 | ||
1000 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 1001 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
1001 | { | 1002 | { |
1002 | if ( currentTab() == CurrentPlayList ) { | 1003 | if ( currentTab() == CurrentPlayList ) { |
1003 | const DocLnk *lnk = current(); | 1004 | const DocLnk *lnk = current(); |
1004 | return Entry( lnk->name(), lnk->file() ); | 1005 | return Entry( lnk->name(), lnk->file() ); |
1005 | } | 1006 | } |
1006 | 1007 | ||
1007 | return Entry( currentFileListPathName() ); | 1008 | return Entry( currentFileListPathName() ); |
1008 | } | 1009 | } |
1009 | 1010 | ||
1010 | QString PlayListWidget::currentFileListPathName() const { | 1011 | QString PlayListWidget::currentFileListPathName() const { |
1011 | return currentFileListView->currentItem()->text( 3 ); | 1012 | return currentFileListView->currentItem()->text( 3 ); |
1012 | } | 1013 | } |