summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-06-11 03:25:10 (UTC)
committer llornkcor <llornkcor>2003-06-11 03:25:10 (UTC)
commitbb6afc95ea64329f8fb9b7af8727b0c13747dde0 (patch) (side-by-side diff)
treecd9285a4860ce024a2f126da4b843c18cdeb533b
parentd47a08d2f8944deb1ee0945075c3443de82442ea (diff)
downloadopie-bb6afc95ea64329f8fb9b7af8727b0c13747dde0.zip
opie-bb6afc95ea64329f8fb9b7af8727b0c13747dde0.tar.gz
opie-bb6afc95ea64329f8fb9b7af8727b0c13747dde0.tar.bz2
fix setDocument handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp39
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h1
2 files changed, 26 insertions, 14 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index c6de5e6..5d0f6de 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -318,106 +318,107 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
tabWidget->insertTab(LTab,tr("Lists"));
connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
///audioView
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 *) ) );
//videoView
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 *) ) );
//playlists
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( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
setCentralWidget( vbox5 );
Config cfg( "OpiePlayer" );
readConfig( cfg );
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
loadList(DocLnk( currentPlaylist));
setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist)));
initializeStates();
+ // audioUI->setFocus();
}
PlayListWidget::~PlayListWidget() {
Config cfg( "OpiePlayer" );
writeConfig( cfg );
- if ( d->current )
- delete d->current;
- delete d;
+ if ( d->current )
+ delete d->current;
+ if(d) delete d;
}
void PlayListWidget::initializeStates() {
d->tbPlay->setOn( mediaPlayerState->playing() );
d->tbLoop->setOn( mediaPlayerState->looping() );
d->tbShuffle->setOn( mediaPlayerState->shuffled() );
setPlaylist( true);
}
void PlayListWidget::readConfig( Config& cfg ) {
cfg.setGroup("PlayList");
QString currentString = cfg.readEntry("current", "" );
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
for ( int i = 0; i < noOfFiles; i++ ) {
QString entryName;
entryName.sprintf( "File%i", i + 1 );
QString linkFile = cfg.readEntry( entryName );
DocLnk lnk( linkFile );
if ( lnk.isValid() ) {
d->selectedFiles->addToSelection( lnk );
}
}
d->selectedFiles->setSelectedItem( currentString);
}
void PlayListWidget::writeConfig( Config& cfg ) const {
d->selectedFiles->writeCurrent( cfg);
cfg.setGroup("PlayList");
int noOfFiles = 0;
d->selectedFiles->first();
do {
const DocLnk *lnk = d->selectedFiles->current();
if ( lnk ) {
QString entryName;
entryName.sprintf( "File%i", noOfFiles + 1 );
// qDebug(entryName);
cfg.writeEntry( entryName, lnk->linkFile() );
// if this link does exist, add it so we have the file
// next time...
if ( !QFile::exists( lnk->linkFile() ) ) {
// the way writing lnks doesn't really check for out
// of disk space, but check it anyway.
if ( !lnk->writeLink() ) {
@@ -449,133 +450,140 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
}
void PlayListWidget::clearList() {
while ( first() )
d->selectedFiles->removeSelected();
}
void PlayListWidget::addAllToList() {
DocLnkSet filesAll;
Global::findDocuments(&filesAll, "video/*;audio/*");
QListIterator<DocLnk> Adit( filesAll.children() );
for ( ; Adit.current(); ++Adit )
if(QFileInfo(Adit.current()->file()).exists())
d->selectedFiles->addToSelection( **Adit );
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::addAllMusicToList() {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit )
if(QFileInfo(dit.current()->file()).exists())
d->selectedFiles->addToSelection( **dit );
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::addAllVideoToList() {
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit )
if(QFileInfo( dit.current()->file()).exists())
d->selectedFiles->addToSelection( **dit );
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::setDocument(const QString& fileref) {
- qDebug(fileref);
- fromSetDocument = TRUE;
+ fromSetDocument = true;
+ d->setDocumentUsed = TRUE;
+ mediaPlayerState->setPlaying( FALSE );
+ qApp->processEvents();
+ mediaPlayerState->setPlaying( TRUE );
+}
+
+void PlayListWidget::setDocumentEx(const QString& fileref) {
+
QFileInfo fileInfo(fileref);
if ( !fileInfo.exists() ) {
QMessageBox::critical( 0, tr( "Invalid File" ),
tr( "There was a problem in getting the file." ) );
return;
}
-// qDebug("setDocument "+fileref);
+ qDebug("setDocument "+fileref);
QString extension = fileInfo.extension(false);
if( extension.find( "m3u", 0, false) != -1) { //is m3u
readm3u( fileref);
}
else if( extension.find( "pls", 0, false) != -1 ) { //is pls
readPls( fileref);
}
else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
clearList();
DocLnk lnk;
lnk.setName( fileInfo.baseName() ); //sets name
lnk.setFile( fileref ); //sets file name
//addToSelection( lnk );
loadList( lnk);
d->selectedFiles->first();
} else {
clearList();
DocLnk lnk;
lnk.setName( fileInfo.baseName() ); //sets name
lnk.setFile( fileref ); //sets file name
addToSelection( lnk );
// addToSelection( DocLnk( fileref ) );
d->setDocumentUsed = TRUE;
mediaPlayerState->setPlaying( FALSE );
qApp->processEvents();
mediaPlayerState->setPlaying( TRUE );
- qApp->processEvents();
+ // qApp->processEvents();
setCaption(tr("OpiePlayer"));
}
}
void PlayListWidget::setActiveWindow() {
qDebug("SETTING active window");
// When we get raised we need to ensure that it switches views
char origView = mediaPlayerState->view();
mediaPlayerState->setView( 'l' ); // invalidate
mediaPlayerState->setView( origView ); // now switch back
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() { // this is fugly
// if( fromSetDocument) {
// qDebug("from setDoc");
// DocLnkSet files;
// Global::findDocuments(&files, "video/*;audio/*");
// QListIterator<DocLnk> dit( files.children() );
// for ( ; dit.current(); ++dit ) {
// if(dit.current()->linkFile() == setDocFileRef) {
// qDebug(setDocFileRef);
// return dit;
// }
// }
// } else
qDebug("current");
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
{
qDebug("playlist");
if ( mediaPlayerState->playlist() ) {
return d->selectedFiles->current();
}
else if ( d->setDocumentUsed && d->current ) {
return d->current;
} else {
return &(d->files->selectedDocument());
@@ -714,202 +722,203 @@ void PlayListWidget::addSelected() {
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
return;
break;
case 1: { //audio
QListViewItemIterator it( audioView );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
filename = it.current()->text(3);
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
}
}
audioView->clearSelection();
// d->selectedFiles->next();
}
break;
case 2: { // video
QListViewItemIterator it( videoView );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
filename = it.current()->text(3);
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
}
}
videoView->clearSelection();
}
break;
};
// tabWidget->setCurrentPage(0);
writeCurrentM3u();
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
}
void PlayListWidget::playIt( QListViewItem *) {
// d->setDocumentUsed = FALSE;
// mediaPlayerState->curPosition =0;
qDebug("playIt");
- mediaPlayerState->setPlaying(FALSE);
+ // mediaPlayerState->setPlaying(FALSE);
mediaPlayerState->setPlaying(TRUE);
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
if(it) {
switch ( tabWidget->currentPageIndex()) {
case 0: //playlist
return;
break;
};
// case 1: {
DocLnk lnk;
QString filename;
filename=it->text(3);
lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
- writeCurrentM3u();
+ if(tabWidget->currentPageIndex() == 0)
+ writeCurrentM3u();
// tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::tabChanged(QWidget *) {
switch ( tabWidget->currentPageIndex()) {
case 0:
{
if( !tbDeletePlaylist->isHidden())
tbDeletePlaylist->hide();
d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
}
break;
case 1:
{
audioView->clear();
populateAudioView();
if( !tbDeletePlaylist->isHidden())
tbDeletePlaylist->hide();
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case 2:
{
videoView->clear();
populateVideoView();
if( !tbDeletePlaylist->isHidden())
tbDeletePlaylist->hide();
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case 3:
{
if( tbDeletePlaylist->isHidden())
tbDeletePlaylist->show();
playLists->reread();
}
break;
};
}
void PlayListWidget::btnPlay(bool b) {
- qDebug("<<<<<<<<<<<<<<<BtnPlay");
+ qDebug("<<<<<<<<<<<<<<<BtnPlay %d", b);
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
qDebug("1");
// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
// QMessageBox::message("Note","You are trying to play\na malformed url.");
// } else {
mediaPlayerState->setPlaying(b);
insanityBool=FALSE;
qDebug("insanity");
// }
}
break;
case 1:
{
qDebug("2");
// d->selectedFiles->unSelect();
addToSelection( audioView->currentItem() );
- mediaPlayerState->setPlaying(true);
+ mediaPlayerState->setPlaying( b);
d->selectedFiles->removeSelected( );
d->selectedFiles->unSelect();
tabWidget->setCurrentPage(1);
insanityBool=FALSE;
}// audioView->clearSelection();
break;
case 2:
{
qDebug("3");
addToSelection( videoView->currentItem() );
- mediaPlayerState->setPlaying(true);
+ mediaPlayerState->setPlaying( b);
// qApp->processEvents();
d->selectedFiles->removeSelected( );
d->selectedFiles->unSelect();
tabWidget->setCurrentPage(2);
insanityBool=FALSE;
}// videoView->clearSelection();
break;
};
}
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;
case 1: // Cancel
break;
};
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
{
switch (mouse) {
case 1:
break;
case 2:{
QPopupMenu m;
m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
m.insertSeparator();
if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
m.exec( QCursor::pos() );
}
break;
};
}
void PlayListWidget::playSelected()
{
qDebug("playSelected");
@@ -1414,81 +1423,83 @@ void PlayListWidget::populateSkinsMenu() {
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( 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 ) );
}
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
+ } else if ( msg == "next()" ) { //select next in lis
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);
+ setDocumentEx( (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;
+ } else if ( msg == "setDocument(QString)" ) { //loop or not loop
+ QCopEnvelope h("QPE/Application/opieplayer", "raise()");
}
}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index e66bcb9..0c0e367 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -57,81 +57,82 @@ public:
QString setDocFileRef, currentPlayList;
// retrieve the current playlist entry (media file link)
const DocLnk *current();
void useSelectedDocument();
/* QTimer * menuTimer; */
FileSelector* playLists;
QPushButton *tbDeletePlaylist;
int fd, selected;
public slots:
bool first();
bool last();
bool next();
bool prev();
/* void setFullScreen(); */
/* void setScaled(); */
protected:
QCopChannel * channel;
QPopupMenu *skinsMenu;
/* void contentsMousePressEvent( QMouseEvent * e ); */
/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
void keyReleaseEvent( QKeyEvent *e);
void keyPressEvent( QKeyEvent *e);
private:
int defaultSkinIndex;
bool audioScan, videoScan;
void doBlank();
void doUnblank();
void readm3u(const QString &);
void readPls(const QString &);
void initializeStates();
void readConfig( Config& cfg );
void writeConfig( Config& cfg ) const;
PlayListWidgetPrivate *d; // Private implementation data
void populateAudioView();
void populateVideoView();
private slots:
void qcopReceive(const QCString&, const QByteArray&);
void populateSkinsMenu();
void skinsMenuActivated(int);
void writem3u();
void writeCurrentM3u();
void scanForAudio();
void scanForVideo();
void openFile();
void setDocument( const QString& fileref );
+ void setDocumentEx( 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 setActiveWindow(); // need to handle this to show the right view
void setPlaylist( bool ); // Show/Hide the playlist
void setView( char );
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();
void listDelete();
protected slots:
/* void cancelMenuTimer(); */
/* void showFileMenu(); */
};
#endif // PLAY_LIST_WIDGET_H