summaryrefslogtreecommitdiff
authorbipolar <bipolar>2002-03-03 17:24:21 (UTC)
committer bipolar <bipolar>2002-03-03 17:24:21 (UTC)
commit9dfc9322b87eda3264b3b53039170c199c327e88 (patch) (unidiff)
treecdfb0c21a4378d484c4fe5d5e59f2804443deb23
parenta99347380a9006ec81a9dba2340d6aaab690a86e (diff)
downloadopie-9dfc9322b87eda3264b3b53039170c199c327e88.zip
opie-9dfc9322b87eda3264b3b53039170c199c327e88.tar.gz
opie-9dfc9322b87eda3264b3b53039170c199c327e88.tar.bz2
committed by ljp (llornkcor): opps, fixed loading playlists
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 7862d8d..ae03ec8 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,117 +1,116 @@
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 21
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
24#include <qpe/fileselector.h> 24#include <qpe/fileselector.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26 26
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#include <qpe/global.h> 29#include <qpe/global.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qaction.h> 31#include <qaction.h>
32#include <qimage.h> 32#include <qimage.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlist.h> 36#include <qlist.h>
37#include <qlistbox.h> 37#include <qlistbox.h>
38#include <qmainwindow.h> 38#include <qmainwindow.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qtabwidget.h> 41#include <qtabwidget.h>
42#include <qlistview.h> 42#include <qlistview.h>
43#include <qpoint.h> 43#include <qpoint.h>
44#include <qlineedit.h> 44#include <qlineedit.h>
45#include <qpushbutton.h> 45#include <qpushbutton.h>
46 46
47//#include <qtimer.h> 47//#include <qtimer.h>
48 48
49#include "playlistselection.h" 49#include "playlistselection.h"
50#include "playlistwidget.h" 50#include "playlistwidget.h"
51#include "mediaplayerstate.h" 51#include "mediaplayerstate.h"
52 52
53#include "fileBrowser.h"
54#include "inputDialog.h" 53#include "inputDialog.h"
55 54
56#include <stdlib.h> 55#include <stdlib.h>
57 56
58#define BUTTONS_ON_TOOLBAR 57#define BUTTONS_ON_TOOLBAR
59#define SIDE_BUTTONS 58#define SIDE_BUTTONS
60#define CAN_SAVE_LOAD_PLAYLISTS 59#define CAN_SAVE_LOAD_PLAYLISTS
61 60
62extern MediaPlayerState *mediaPlayerState; 61extern MediaPlayerState *mediaPlayerState;
63 62
64// class myFileSelector { 63// class myFileSelector {
65 64
66// }; 65// };
67class PlayListWidgetPrivate { 66class PlayListWidgetPrivate {
68public: 67public:
69 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 68 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
70 QFrame *playListFrame; 69 QFrame *playListFrame;
71 FileSelector *files; 70 FileSelector *files;
72 PlayListSelection *selectedFiles; 71 PlayListSelection *selectedFiles;
73 bool setDocumentUsed; 72 bool setDocumentUsed;
74 DocLnk *current; 73 DocLnk *current;
75}; 74};
76 75
77 76
78class ToolButton : public QToolButton { 77class ToolButton : public QToolButton {
79public: 78public:
80 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 79 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
81 : QToolButton( parent, name ) { 80 : QToolButton( parent, name ) {
82 setTextLabel( name ); 81 setTextLabel( name );
83 setPixmap( Resource::loadPixmap( icon ) ); 82 setPixmap( Resource::loadPixmap( icon ) );
84 setAutoRaise( TRUE ); 83 setAutoRaise( TRUE );
85 setFocusPolicy( QWidget::NoFocus ); 84 setFocusPolicy( QWidget::NoFocus );
86 setToggleButton( t ); 85 setToggleButton( t );
87 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 86 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
88 QPEMenuToolFocusManager::manager()->addWidget( this ); 87 QPEMenuToolFocusManager::manager()->addWidget( this );
89 } 88 }
90}; 89};
91 90
92 91
93class MenuItem : public QAction { 92class MenuItem : public QAction {
94public: 93public:
95 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 94 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
96 : QAction( text, QString::null, 0, 0 ) { 95 : QAction( text, QString::null, 0, 0 ) {
97 connect( this, SIGNAL( activated() ), handler, slot ); 96 connect( this, SIGNAL( activated() ), handler, slot );
98 addTo( parent ); 97 addTo( parent );
99 } 98 }
100}; 99};
101 100
102 101
103PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 102PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
104 : QMainWindow( parent, name, fl ) { 103 : QMainWindow( parent, name, fl ) {
105 104
106 d = new PlayListWidgetPrivate; 105 d = new PlayListWidgetPrivate;
107 d->setDocumentUsed = FALSE; 106 d->setDocumentUsed = FALSE;
108 d->current = NULL; 107 d->current = NULL;
109// menuTimer = new QTimer( this ,"menu timer"), 108// menuTimer = new QTimer( this ,"menu timer"),
110// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 109// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
111 110
112 setBackgroundMode( PaletteButton ); 111 setBackgroundMode( PaletteButton );
113 112
114 setCaption( tr("OpiePlayer") ); 113 setCaption( tr("OpiePlayer") );
115 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 114 setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
116 115
117 setToolBarsMovable( FALSE ); 116 setToolBarsMovable( FALSE );
@@ -500,131 +499,131 @@ bool PlayListWidget::next() {
500 return FALSE; 499 return FALSE;
501 } 500 }
502 } 501 }
503 return TRUE; 502 return TRUE;
504 } 503 }
505 } else { 504 } else {
506 return mediaPlayerState->looping(); 505 return mediaPlayerState->looping();
507 } 506 }
508} 507}
509 508
510 509
511bool PlayListWidget::first() { 510bool PlayListWidget::first() {
512 if ( mediaPlayerState->playlist() ) 511 if ( mediaPlayerState->playlist() )
513 return d->selectedFiles->first(); 512 return d->selectedFiles->first();
514 else 513 else
515 return mediaPlayerState->looping(); 514 return mediaPlayerState->looping();
516} 515}
517 516
518 517
519bool PlayListWidget::last() { 518bool PlayListWidget::last() {
520 if ( mediaPlayerState->playlist() ) 519 if ( mediaPlayerState->playlist() )
521 return d->selectedFiles->last(); 520 return d->selectedFiles->last();
522 else 521 else
523 return mediaPlayerState->looping(); 522 return mediaPlayerState->looping();
524} 523}
525 524
526 525
527void PlayListWidget::saveList() { 526void PlayListWidget::saveList() {
528 527
529 QString filename; 528 QString filename;
530 InputDialog *fileDlg; 529 InputDialog *fileDlg;
531 fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); 530 fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0);
532 fileDlg->exec(); 531 fileDlg->exec();
533 if( fileDlg->result() == 1 ) { 532 if( fileDlg->result() == 1 ) {
534 filename = fileDlg->LineEdit1->text();//+".playlist"; 533 filename = fileDlg->LineEdit1->text();//+".playlist";
535 qDebug("saving playlist "+filename+".playlist"); 534 qDebug("saving playlist "+filename+".playlist");
536 535
537// DocLnk *lnk; 536// DocLnk *lnk;
538// lnk.setName( filename); //sets file name 537// lnk.setName( filename); //sets file name
539// // lnk.setComment(title); 538// // lnk.setComment(title);
540// lnk.setFile( filename+".playlist"); //sets File property 539// lnk.setFile( filename+".playlist"); //sets File property
541// lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D 540// lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D
542// lnk.setIcon("MPEGPlayer"); 541// lnk.setIcon("MPEGPlayer");
543// if(!lnk.writeLink()) 542// if(!lnk.writeLink())
544// qDebug("Writing doclink did not work"); 543// qDebug("Writing doclink did not work");
545 544
546 Config cfg( filename +".playlist"); 545 Config cfg( filename +".playlist");
547 writeConfig( cfg ); 546 writeConfig( cfg );
548 } 547 }
549 DocLnk lnk; 548 DocLnk lnk;
550 lnk.setName( filename); //sets file name 549 lnk.setName( filename); //sets file name
551// lnk.setComment(title); 550// lnk.setComment(title);
552 lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property 551 lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property
553 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 552 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
554 lnk.setIcon("MPEGPlayer"); 553 lnk.setIcon("MPEGPlayer");
555 if(!lnk.writeLink()) 554 if(!lnk.writeLink())
556 qDebug("Writing doclink did not work"); 555 qDebug("Writing doclink did not work");
557 556
558 if(fileDlg) 557 if(fileDlg)
559 delete fileDlg; 558 delete fileDlg;
560} 559}
561 560
562 561
563void PlayListWidget::loadList( const DocLnk & lnk) { 562void PlayListWidget::loadList( const DocLnk & lnk) {
564 563 qDebug("load list "+ lnk.name()+".playlist");
565 clearList(); 564 clearList();
566 Config cfg( lnk.file()); 565 Config cfg( lnk.name()+".playlist");
567 readConfig(cfg); 566 readConfig(cfg);
568 tabWidget->setCurrentPage(0); 567 tabWidget->setCurrentPage(0);
569 setCaption("OpiePlayer: "+lnk.name()); 568 setCaption("OpiePlayer: "+lnk.name());
570} 569}
571 570
572 571
573void PlayListWidget::setPlaylist( bool shown ) { 572void PlayListWidget::setPlaylist( bool shown ) {
574 if ( shown ) 573 if ( shown )
575 d->playListFrame->show(); 574 d->playListFrame->show();
576 else 575 else
577 d->playListFrame->hide(); 576 d->playListFrame->hide();
578} 577}
579 578
580 579
581void PlayListWidget::setView( char view ) { 580void PlayListWidget::setView( char view ) {
582 if ( view == 'l' ) 581 if ( view == 'l' )
583 showMaximized(); 582 showMaximized();
584 else 583 else
585 hide(); 584 hide();
586} 585}
587 586
588void PlayListWidget::addSelected() { 587void PlayListWidget::addSelected() {
589 588
590 switch (tabWidget->currentPageIndex()) { 589 switch (tabWidget->currentPageIndex()) {
591 case 0: //playlist 590 case 0: //playlist
592 break; 591 break;
593 case 1: { //audio 592 case 1: { //audio
594 addToSelection( audioView->selectedItem() ); 593 addToSelection( audioView->selectedItem() );
595 } 594 }
596 break; 595 break;
597 case 2: { // video 596 case 2: { // video
598 addToSelection( videoView->selectedItem() ); 597 addToSelection( videoView->selectedItem() );
599 } 598 }
600 break; 599 break;
601 }; 600 };
602} 601}
603 602
604void PlayListWidget::removeSelected() { 603void PlayListWidget::removeSelected() {
605 d->selectedFiles->removeSelected( ); 604 d->selectedFiles->removeSelected( );
606} 605}
607 606
608 607
609void PlayListWidget::playIt( QListViewItem *it) { 608void PlayListWidget::playIt( QListViewItem *it) {
610// d->setDocumentUsed = FALSE; 609// d->setDocumentUsed = FALSE;
611 mediaPlayerState->setPlaying(TRUE); 610 mediaPlayerState->setPlaying(TRUE);
612} 611}
613 612
614void PlayListWidget::addToSelection( QListViewItem *it) { 613void PlayListWidget::addToSelection( QListViewItem *it) {
615 d->setDocumentUsed = FALSE; 614 d->setDocumentUsed = FALSE;
616 615
617 if(it) { 616 if(it) {
618// qDebug("add to selection"); 617// qDebug("add to selection");
619 switch (tabWidget->currentPageIndex()) { 618 switch (tabWidget->currentPageIndex()) {
620 case 1: { 619 case 1: {
621// qDebug("case 1"); 620// qDebug("case 1");
622 QListIterator<DocLnk> dit( files.children() ); 621 QListIterator<DocLnk> dit( files.children() );
623 for ( ; dit.current(); ++dit ) { 622 for ( ; dit.current(); ++dit ) {
624// qDebug(dit.current()->name()); 623// qDebug(dit.current()->name());
625 if( dit.current()->name() == it->text(0)) { 624 if( dit.current()->name() == it->text(0)) {
626 d->selectedFiles->addToSelection( **dit ); 625 d->selectedFiles->addToSelection( **dit );
627 } 626 }
628 } 627 }
629 } 628 }
630 break; 629 break;