-rw-r--r-- | noncore/multimedia/opieplayer2/main.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 48 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | 12 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.h | 4 |
5 files changed, 35 insertions, 34 deletions
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp index 24aba6c..02fdbf3 100644 --- a/noncore/multimedia/opieplayer2/main.cpp +++ b/noncore/multimedia/opieplayer2/main.cpp @@ -7,25 +7,25 @@ #include "mediaplayer.h" MediaPlayerState *mediaPlayerState; PlayListWidget *playList; AudioWidget *audioUI; VideoWidget *videoUI; int main(int argc, char **argv) { QPEApplication a(argc,argv); MediaPlayerState st( 0, "mediaPlayerState" ); mediaPlayerState = &st; - PlayListWidget pl( 0, "playList" ); + PlayListWidget pl( st, 0, "playList" ); playList = &pl; pl.showMaximized(); AudioWidget aw( 0, "audioUI" ); audioUI = &aw; VideoWidget vw( 0, "videoUI" ); videoUI = &vw; a.processEvents(); MediaPlayer mp( st, 0, "mediaPlayer" ); a.showMainDocumentWidget(&pl); return a.exec(); diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index b08204e..7ba342b 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -55,67 +55,67 @@ #include <assert.h> #include "audiowidget.h" #include "videowidget.h" extern MediaPlayerState *mediaPlayerState; // extern AudioWidget *audioUI; // extern VideoWidget *videoUI; QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; // no m3u's here please -PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) - : PlayListWidgetGui( parent, name, fl ) { +PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) + : PlayListWidgetGui( mediaPlayerState, parent, name ) { 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 ); + &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", - mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); + &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" ), this,SLOT( scanForAudio() ) ); (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), - mediaPlayerState, SLOT( toggleFullscreen() ) ); + &mediaPlayerState, SLOT( toggleFullscreen() ) ); Config cfg( "OpiePlayer" ); bool b= cfg.readBoolEntry("FullScreen", 0); - mediaPlayerState->setFullscreen( b ); + 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() ) ); @@ -132,58 +132,58 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 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 ) ), + connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); - connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), + connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); - connect( mediaPlayerState, SIGNAL( shuffledToggled( 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 ) ) ); + &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); // see which skins are installed videoScan=false; audioScan=false; audioPopulated=false; videoPopulated=false; populateSkinsMenu(); initializeStates(); cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); loadList(DocLnk( currentPlaylist ) ); } PlayListWidget::~PlayListWidget() { delete d; } void PlayListWidget::initializeStates() { - d->tbPlay->setOn( mediaPlayerState->isPlaying() ); - d->tbLoop->setOn( mediaPlayerState->isLooping() ); - d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); + 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>>>>>>>>>>>>>>>>>>>"); @@ -395,81 +395,81 @@ void PlayListWidget::setDocument( const QString& fileref ) { } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { readm3u( DocLnk( fileref).file() ); } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls readPls( fileref ); } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { readPls( DocLnk( fileref).file() ); } else { clearList(); addToSelection( DocLnk( fileref ) ); writeCurrentM3u(); d->setDocumentUsed = TRUE; - mediaPlayerState->setPlaying( FALSE ); - mediaPlayerState->setPlaying( TRUE ); + mediaPlayerState.setPlaying( FALSE ); + mediaPlayerState.setPlaying( TRUE ); } } void PlayListWidget::useSelectedDocument() { d->setDocumentUsed = FALSE; } const DocLnk *PlayListWidget::current() const { // this is fugly assert( currentTab() == CurrentPlayList ); const DocLnk *lnk = d->selectedFiles->current(); if ( !lnk ) { d->selectedFiles->first(); lnk = d->selectedFiles->current(); } assert( lnk ); return lnk; } bool PlayListWidget::prev() { - if ( mediaPlayerState->isShuffled() ) { + if ( mediaPlayerState.isShuffled() ) { const DocLnk *cur = current(); int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); for ( int i = 0; i < j; i++ ) { 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->isLooping() ) { + if ( mediaPlayerState.isLooping() ) { return d->selectedFiles->last(); } else { return FALSE; } } return TRUE; } } bool PlayListWidget::next() { //qDebug("<<<<<<<<<<<<next()"); - if ( mediaPlayerState->isShuffled() ) { + if ( mediaPlayerState.isShuffled() ) { return prev(); } else { if ( !d->selectedFiles->next() ) { - if ( mediaPlayerState->isLooping() ) { + if ( mediaPlayerState.isLooping() ) { return d->selectedFiles->first(); } else { return FALSE; } } return TRUE; } } bool PlayListWidget::first() { return d->selectedFiles->first(); @@ -521,26 +521,26 @@ void PlayListWidget::addSelected() { writeCurrentM3u(); } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); writeCurrentM3u(); } void PlayListWidget::playIt( QListViewItem *it) { if(!it) return; - mediaPlayerState->setPlaying(FALSE); - mediaPlayerState->setPlaying(TRUE); + mediaPlayerState.setPlaying(FALSE); + mediaPlayerState.setPlaying(TRUE); d->selectedFiles->unSelect(); } void PlayListWidget::addToSelection( QListViewItem *it) { d->setDocumentUsed = FALSE; if(it) { if ( currentTab() == CurrentPlayList ) return; // case 1: { DocLnk lnk; @@ -605,25 +605,25 @@ void PlayListWidget::tabChanged(QWidget *) { playLists->reread(); d->tbAddToList->setEnabled(FALSE); d->tbPlay->setEnabled( false ); } break; }; } void PlayListWidget::btnPlay(bool b) { // mediaPlayerState->setPlaying(false); - mediaPlayerState->setPlaying(b); + mediaPlayerState.setPlaying(b); insanityBool=FALSE; } void PlayListWidget::deletePlaylist() { switch( QMessageBox::information( this, (tr("Remove Playlist?")), (tr("You really want to delete\nthis playlist?")), (tr("Yes")), (tr("No")), 0 )){ case 0: // Yes clicked, QFile().remove(playLists->selectedDocument().file()); QFile().remove(playLists->selectedDocument().linkFile()); playLists->reread(); break; @@ -1040,26 +1040,26 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 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(); + 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; diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index fa2837a..3f52e63 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h @@ -60,25 +60,25 @@ public: 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( QWidget* parent=0, const char* name=0, WFlags fl=0 ); + PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~PlayListWidget(); DocLnkSet files; DocLnkSet vFiles; bool fromSetDocument; bool insanityBool; QString setDocFileRef, currentPlayList; // retrieve the current playlist entry (media file link) const DocLnk *current() const; void useSelectedDocument(); int selected; TabType currentTab() const; @@ -125,16 +125,17 @@ private slots: 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(); + }; #endif // PLAY_LIST_WIDGET_H diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index 8be7a2f..f47ddcc 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp @@ -50,28 +50,26 @@ #include "playlistselection.h" #include "playlistwidget.h" #include "mediaplayerstate.h" #include "inputDialog.h" //only needed for the random play #include <stdlib.h> #include "audiowidget.h" #include "videowidget.h" #include "mediaplayerstate.h" -extern MediaPlayerState *mediaPlayerState; - -PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) - : QMainWindow( parent, name, fl ) { +PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) + : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { d = new PlayListWidgetPrivate; d->setDocumentUsed = FALSE; setBackgroundMode( PaletteButton ); setToolBarsMovable( FALSE ); // Create Toolbar QPEToolBar *toolbar = new QPEToolBar( this ); toolbar->setHorizontalStretchable( TRUE ); // Create Menubar @@ -212,17 +210,17 @@ PlayListWidgetGui::~PlayListWidgetGui() { void PlayListWidgetGui::setView( char view ) { if ( view == 'l' ) showMaximized(); else hide(); } void PlayListWidgetGui::setActiveWindow() { // qDebug("SETTING active window"); // When we get raised we need to ensure that it switches views - MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); - mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate - mediaPlayerState->setDisplayType( origDisplayType ); // now switch back + MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); + mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate + mediaPlayerState.setDisplayType( origDisplayType ); // now switch back } diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h index 4eefb93..9b5252a 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h @@ -40,24 +40,25 @@ #include <qpe/qpemenubar.h> #include <qtabwidget.h> #include <qpe/fileselector.h> #include <qpushbutton.h> #include <qpopupmenu.h> #include <qaction.h> #include <qslider.h> #include <qlcdnumber.h> class PlayListWidgetPrivate; class PlayListSelection; +class MediaPlayerState; class Config; class QPEToolBar; class QListViewItem; class QListView; class QPoint; class QAction; class QLabel; class PlayListWidgetPrivate { public: QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; @@ -86,25 +87,25 @@ 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 ); } }; class PlayListWidgetGui : public QMainWindow { Q_OBJECT public: - PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 ); + PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~PlayListWidgetGui(); protected: QTabWidget * tabWidget; QListView *audioView, *videoView, *playlistView; QLabel *libString; QPopupMenu *pmView ; QPopupMenu *gammaMenu; QSlider *gammaSlider; QLCDNumber *gammaLCD; bool fromSetDocument; bool insanityBool; @@ -113,16 +114,17 @@ protected: QPushButton *tbDeletePlaylist; int selected; QPopupMenu *pmPlayList; FileSelector* playLists; QPopupMenu *skinsMenu; PlayListWidgetPrivate *d; // Private implementation data QVBox *vbox1; QVBox *vbox5; QPEToolBar *bar; void setActiveWindow(); // need to handle this to show the right view void setView( char ); + MediaPlayerState &mediaPlayerState; }; #endif |