-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 5 |
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,149 +1,148 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // code added by L. J. Potter Sat 03-02-2002 06:17:54 #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/fileselector.h> #include <qpe/qpeapplication.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/resource.h> #include <qaction.h> #include <qimage.h> #include <qfile.h> #include <qlayout.h> #include <qlabel.h> #include <qlist.h> #include <qlistbox.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qtoolbutton.h> #include <qtabwidget.h> #include <qlistview.h> #include <qpoint.h> #include <qlineedit.h> #include <qpushbutton.h> //#include <qtimer.h> #include "playlistselection.h" #include "playlistwidget.h" #include "mediaplayerstate.h" -#include "fileBrowser.h" #include "inputDialog.h" #include <stdlib.h> #define BUTTONS_ON_TOOLBAR #define SIDE_BUTTONS #define CAN_SAVE_LOAD_PLAYLISTS extern MediaPlayerState *mediaPlayerState; // class myFileSelector { // }; class PlayListWidgetPrivate { public: QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; QFrame *playListFrame; FileSelector *files; PlayListSelection *selectedFiles; bool setDocumentUsed; DocLnk *current; }; class ToolButton : public QToolButton { public: ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) : QToolButton( parent, name ) { setTextLabel( name ); setPixmap( Resource::loadPixmap( icon ) ); setAutoRaise( TRUE ); setFocusPolicy( QWidget::NoFocus ); setToggleButton( t ); connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); QPEMenuToolFocusManager::manager()->addWidget( this ); } }; class MenuItem : public QAction { public: MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) : QAction( text, QString::null, 0, 0 ) { connect( this, SIGNAL( activated() ), handler, slot ); addTo( parent ); } }; PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { d = new PlayListWidgetPrivate; d->setDocumentUsed = FALSE; d->current = NULL; // menuTimer = new QTimer( this ,"menu timer"), // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); setBackgroundMode( PaletteButton ); setCaption( tr("OpiePlayer") ); setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); setToolBarsMovable( FALSE ); // Create Toolbar QPEToolBar *toolbar = new QPEToolBar( this ); toolbar->setHorizontalStretchable( TRUE ); // Create Menubar QPEMenuBar *menu = new QPEMenuBar( toolbar ); menu->setMargin( 0 ); QPEToolBar *bar = new QPEToolBar( this ); bar->setLabel( tr( "Play Operations" ) ); // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", // this , SLOT( addSelected()) ); tbDeletePlaylist = new QPushButton( Resource::loadIconSet("close"),"",bar,"close"); tbDeletePlaylist->setFlat(TRUE); tbDeletePlaylist->setFixedSize(20,20); connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", this , SLOT(addSelected()) ); d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", this , SLOT(removeSelected()) ); // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", this , SLOT( btnPlay(bool) ), TRUE ); d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); tbDeletePlaylist->hide(); QPopupMenu *pmPlayList = new QPopupMenu( this ); @@ -468,195 +467,195 @@ bool PlayListWidget::prev() { if ( !d->selectedFiles->next() ) d->selectedFiles->first(); } if ( cur == current() ) if ( !d->selectedFiles->next() ) d->selectedFiles->first(); return TRUE; } else { if ( !d->selectedFiles->prev() ) { if ( mediaPlayerState->looping() ) { return d->selectedFiles->last(); } else { return FALSE; } } return TRUE; } } else { return mediaPlayerState->looping(); } } bool PlayListWidget::next() { if ( mediaPlayerState->playlist() ) { if ( mediaPlayerState->shuffled() ) { return prev(); } else { if ( !d->selectedFiles->next() ) { if ( mediaPlayerState->looping() ) { return d->selectedFiles->first(); } else { return FALSE; } } return TRUE; } } else { return mediaPlayerState->looping(); } } bool PlayListWidget::first() { if ( mediaPlayerState->playlist() ) return d->selectedFiles->first(); else return mediaPlayerState->looping(); } bool PlayListWidget::last() { if ( mediaPlayerState->playlist() ) return d->selectedFiles->last(); else return mediaPlayerState->looping(); } void PlayListWidget::saveList() { QString filename; InputDialog *fileDlg; fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { filename = fileDlg->LineEdit1->text();//+".playlist"; qDebug("saving playlist "+filename+".playlist"); // DocLnk *lnk; // lnk.setName( filename); //sets file name // // lnk.setComment(title); // lnk.setFile( filename+".playlist"); //sets File property // lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D // lnk.setIcon("MPEGPlayer"); // if(!lnk.writeLink()) // qDebug("Writing doclink did not work"); Config cfg( filename +".playlist"); writeConfig( cfg ); } DocLnk lnk; lnk.setName( filename); //sets file name // lnk.setComment(title); lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D lnk.setIcon("MPEGPlayer"); if(!lnk.writeLink()) qDebug("Writing doclink did not work"); if(fileDlg) delete fileDlg; } void PlayListWidget::loadList( const DocLnk & lnk) { - + qDebug("load list "+ lnk.name()+".playlist"); clearList(); - Config cfg( lnk.file()); + Config cfg( lnk.name()+".playlist"); readConfig(cfg); tabWidget->setCurrentPage(0); setCaption("OpiePlayer: "+lnk.name()); } void PlayListWidget::setPlaylist( bool shown ) { if ( shown ) d->playListFrame->show(); else d->playListFrame->hide(); } void PlayListWidget::setView( char view ) { if ( view == 'l' ) showMaximized(); else hide(); } void PlayListWidget::addSelected() { switch (tabWidget->currentPageIndex()) { case 0: //playlist break; case 1: { //audio addToSelection( audioView->selectedItem() ); } break; case 2: { // video addToSelection( videoView->selectedItem() ); } break; }; } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); } void PlayListWidget::playIt( QListViewItem *it) { // d->setDocumentUsed = FALSE; mediaPlayerState->setPlaying(TRUE); } void PlayListWidget::addToSelection( QListViewItem *it) { d->setDocumentUsed = FALSE; if(it) { // qDebug("add to selection"); switch (tabWidget->currentPageIndex()) { case 1: { // qDebug("case 1"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { // qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { d->selectedFiles->addToSelection( **dit ); } } } break; case 2: { // qDebug("case 2"); QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) { // qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { d->selectedFiles->addToSelection( **dit ); } } } break; case 0: break; }; tabWidget->setCurrentPage(0); // mediaPlayerState->setPlaying( TRUE ); } } void PlayListWidget::tabChanged(QWidget *widg) { switch ( tabWidget->currentPageIndex()) { case 0: { if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(TRUE); d->tbAddToList->setEnabled(FALSE); } break; case 1: { |