-rw-r--r-- | noncore/multimedia/opieplayer2/README | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 49 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 3 |
3 files changed, 74 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/README b/noncore/multimedia/opieplayer2/README new file mode 100644 index 0000000..8db1376 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/README @@ -0,0 +1,22 @@ +qcop channel is: +QPE/Application/opieplayer2 + +qcop calls enabled: +"play()" //plays current selection +"stop()" //stops playing +"togglePause()"//pauses +"next()" //select next in list +"prev()" //select previous in list +"toggleLooping()" //loop or not loop +"toggleShuffled()" //shuffled or not shuffled +"play(QString)" //play this now, needs full file path +"add(QString)" //add to playlist, needs full file path + + +qcop calls to be enabled: +"volUp()" //volume more +"volDown()" //volume less +"rem(QString)" //remove from playlist +"getPlaylist()" // gets list of songs in current playlist + + diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 580460e..c91a565 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -55,192 +55,197 @@ #include <stdlib.h> #include <assert.h> PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) { d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", this , SLOT(addSelected() ) ); d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", this , SLOT(removeSelected() ) ); d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", this , SLOT( btnPlay( bool) ), TRUE ); d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); pmPlayList->insertSeparator(-1); // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), // this, SLOT( saveList() ) ); (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), this, SLOT(writem3u() ) ); pmPlayList->insertSeparator(-1); (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); pmPlayList->insertSeparator(-1); (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), audioView, SLOT( scanFiles() ) ); (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), videoView, SLOT( scanFiles() ) ); pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), &mediaPlayerState, SLOT( toggleFullscreen() ) ); Config cfg( "OpiePlayer" ); bool b= cfg.readBoolEntry("FullScreen", 0); mediaPlayerState.setFullscreen( b ); pmView->setItemChecked( -16, b ); (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) ); (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) ); (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) ); // QVBox *stretch2 = new QVBox( vbox1 ); connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), this,SLOT( playIt( QListViewItem *) ) ); connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), this,SLOT( playIt( QListViewItem *) ) ); connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); connect ( gammaSlider, SIGNAL( valueChanged( int ) ), &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); // see which skins are installed populateSkinsMenu(); initializeStates(); + channel = new QCopChannel( "QPE/Application/opieplayer2", this ); + connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), + this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); + + cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); loadList(DocLnk( currentPlaylist ) ); tabWidget->showPage( playListTab ); } PlayListWidget::~PlayListWidget() { delete d; } void PlayListWidget::initializeStates() { d->tbPlay->setOn( mediaPlayerState.isPlaying() ); d->tbLoop->setOn( mediaPlayerState.isLooping() ); d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); d->playListFrame->show(); } void PlayListWidget::writeDefaultPlaylist() { Config config( "OpiePlayer" ); config.setGroup( "PlayList" ); QString filename=QPEApplication::documentDir() + "/default.m3u"; QString currentString = config.readEntry( "CurrentPlaylist", filename); if( currentString == filename) { Om3u *m3uList; // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); if( d->selectedFiles->first() ) { m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); do { // qDebug(d->selectedFiles->current()->file()); m3uList->add( d->selectedFiles->current()->file() ); } while ( d->selectedFiles->next() ); m3uList->write(); m3uList->close(); delete m3uList; } } } void PlayListWidget::addToSelection( const DocLnk& lnk ) { d->setDocumentUsed = FALSE; if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) { d->selectedFiles->addToSelection( lnk ); } // writeCurrentM3u(); } void PlayListWidget::clearList() { while ( first() ) { d->selectedFiles->removeSelected(); } Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); cfg.writeEntry("CurrentPlaylist","default"); setCaption("OpiePlayer"); } void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { switch (mouse) { case LeftButton: break; case RightButton: { QPopupMenu m; m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); m.exec( QCursor::pos() ); } break; } } void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { switch (mouse) { case LeftButton: break; case RightButton: { QPopupMenu m; m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); m.exec( QCursor::pos() ); } break; } } @@ -821,96 +826,140 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { break; case Key_Down: if ( !d->selectedFiles->next() ) d->selectedFiles->first(); break; case Key_Up: if ( !d->selectedFiles->prev() ) // d->selectedFiles->last(); break; } } void PlayListWidget::pmViewActivated(int index) { // qDebug("%d", index); switch(index) { case -16: { mediaPlayerState.toggleFullscreen(); bool b=mediaPlayerState.isFullscreen(); pmView->setItemChecked( index, b); Config cfg( "OpiePlayer" ); cfg.writeEntry( "FullScreen", b ); } break; }; } void PlayListWidget::populateSkinsMenu() { int item = 0; defaultSkinIndex = 0; QString skinName; Config cfg( "OpiePlayer" ); cfg.setGroup("Options" ); QString skin = cfg.readEntry( "Skin", "default" ); QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); skinsDir.setFilter( QDir::Dirs ); skinsDir.setSorting(QDir::Name ); const QFileInfoList *skinslist = skinsDir.entryInfoList(); QFileInfoListIterator it( *skinslist ); QFileInfo *fi; while ( ( fi = it.current() ) ) { skinName = fi->fileName(); // qDebug( fi->fileName() ); if( skinName != "." && skinName != ".." && skinName !="CVS" ) { item = skinsMenu->insertItem( fi->fileName() ) ; } if( skinName == "default" ) { defaultSkinIndex = item; } if( skinName == skin ) { skinsMenu->setItemChecked( item, TRUE ); } ++it; } } void PlayListWidget::skinsMenuActivated( int item ) { for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { skinsMenu->setItemChecked( i, FALSE ); } skinsMenu->setItemChecked( item, TRUE ); { Config cfg( "OpiePlayer" ); cfg.setGroup("Options"); cfg.writeEntry("Skin", skinsMenu->text( item ) ); } emit skinSelected(); } PlayListWidget::TabType PlayListWidget::currentTab() const { static const TabType indexToTabType[ TabTypeCount ] = { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; int index = tabWidget->currentPageIndex(); assert( index < TabTypeCount && index >= 0 ); return indexToTabType[ index ]; } PlayListWidget::Entry PlayListWidget::currentEntry() const { if ( currentTab() == CurrentPlayList ) { const DocLnk *lnk = current(); return Entry( lnk->name(), lnk->file() ); } return Entry( currentFileListPathName() ); } QString PlayListWidget::currentFileListPathName() const { return currentFileListView->currentItem()->text( 3 ); } + + +void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { + qDebug("qcop message "+msg ); + QDataStream stream ( data, IO_ReadOnly ); + if ( msg == "play()" ) { //plays current selection + btnPlay( true); + } else if ( msg == "stop()" ) { + mediaPlayerState.setPlaying( false); + } else if ( msg == "togglePause()" ) { + mediaPlayerState.togglePaused(); + } else if ( msg == "next()" ) { //select next in list + mediaPlayerState.setNext(); + } else if ( msg == "prev()" ) { //select previous in list + mediaPlayerState.setPrev(); + } else if ( msg == "toggleLooping()" ) { //loop or not loop + mediaPlayerState.toggleLooping(); + } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled + mediaPlayerState.toggleShuffled(); + } else if ( msg == "volUp()" ) { //volume more +// emit moreClicked(); +// emit moreReleased(); + } else if ( msg == "volDown()" ) { //volume less +// emit lessClicked(); +// emit lessReleased(); + } else if ( msg == "play(QString)" ) { //play this now + QString file; + stream >> file; + setDocument( (const QString &) file); + } else if ( msg == "add(QString)" ) { //add to playlist + QString file; + stream >> file; + QFileInfo fileInfo(file); + DocLnk lnk; + lnk.setName( fileInfo.baseName() ); //sets name + lnk.setFile( file ); //sets file name + addToSelection( lnk ); + } else if ( msg == "rem(QString)" ) { //remove from playlist + QString file; + stream >> file; + + } + +} diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index cb65d5c..54e9d16 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h @@ -1,139 +1,142 @@ /* This file is part of the Opie Project Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> Copyright (c) 2002 L. Potter <ljp@llornkcor.com> Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef PLAY_LIST_WIDGET_H #define PLAY_LIST_WIDGET_H #include <qmainwindow.h> #include <qpe/applnk.h> #include <qtabwidget.h> #include <qpe/fileselector.h> #include <qpushbutton.h> #include <qpopupmenu.h> +#include <qpe/qcopenvelope_qws.h> #include "playlistwidgetgui.h" //class PlayListWidgetPrivate; class Config; class QListViewItem; class QListView; class QPoint; class QAction; class QLabel; class PlayListWidget : public PlayListWidgetGui { Q_OBJECT public: enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; enum { TabTypeCount = 4 }; struct Entry { Entry( const QString &_name, const QString &_fileName ) : name( _name ), file( _fileName ) {} Entry( const QString &_fileName ) : name( _fileName ), file( _fileName ) {} QString name; QString file; }; PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~PlayListWidget(); // retrieve the current playlist entry (media file link) const DocLnk *current() const; void useSelectedDocument(); TabType currentTab() const; Entry currentEntry() const; public slots: bool first(); bool last(); bool next(); bool prev(); void writeDefaultPlaylist( ); QString currentFileListPathName() const; protected: + QCopChannel * channel; void keyReleaseEvent( QKeyEvent *e); signals: void skinSelected(); private: int defaultSkinIndex; /* void readm3u(const QString &); */ /* void readPls(const QString &); */ void readListFromFile(const QString &); void initializeStates(); bool inFileListMode() const; private slots: + void qcopReceive(const QCString&, const QByteArray&); void populateSkinsMenu(); void skinsMenuActivated(int); void pmViewActivated(int); void writem3u(); void writeCurrentM3u(); void openFile(); void setDocument( const QString& fileref ); void addToSelection( const DocLnk& ); // Add a media file to the playlist void addToSelection( QListViewItem* ); // Add a media file to the playlist void clearList(); void addAllToList(); void addAllMusicToList(); void addAllVideoToList(); void saveList(); // Save the playlist void loadList( const DocLnk &); // Load a playlist void playIt( QListViewItem *); void btnPlay(bool); void deletePlaylist(); void addSelected(); void removeSelected(); void tabChanged(QWidget*); void viewPressed( int, QListViewItem *, const QPoint&, int); void playlistViewPressed( int, QListViewItem *, const QPoint&, int); void playSelected(); private: bool fromSetDocument; bool insanityBool; QString setDocFileRef, currentPlayList; int selected; QListView *currentFileListView; }; #endif // PLAY_LIST_WIDGET_H |