summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-12-16 03:52:02 (UTC)
committer llornkcor <llornkcor>2002-12-16 03:52:02 (UTC)
commitb1880703eea8601e06cf3d3e8593b649cd1a485e (patch) (side-by-side diff)
treea7c9d9c1bc2971d4a062cfb68b433bffa4c557d1
parentde714f7a5d6b50b4689a217bbed58180da8acc27 (diff)
downloadopie-b1880703eea8601e06cf3d3e8593b649cd1a485e.zip
opie-b1880703eea8601e06cf3d3e8593b649cd1a485e.tar.gz
opie-b1880703eea8601e06cf3d3e8593b649cd1a485e.tar.bz2
some stuff from op2
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp45
1 files changed, 29 insertions, 16 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 8b25a4c..30e4daa 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -56,66 +56,66 @@
#include "playlistselection.h"
#include "playlistwidget.h"
#include "mediaplayerstate.h"
#include "inputDialog.h"
#include <stdlib.h>
#include "audiowidget.h"
#include "videowidget.h"
#include <unistd.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
// for setBacklight()
#include <linux/fb.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#define BUTTONS_ON_TOOLBAR
#define SIDE_BUTTONS
#define CAN_SAVE_LOAD_PLAYLISTS
extern AudioWidget *audioUI;
extern VideoWidget *videoUI;
extern MediaPlayerState *mediaPlayerState;
static inline QString fullBaseName ( const QFileInfo &fi )
{
- QString str = fi. fileName ( );
- return str. left ( str. findRev ( '.' ));
+ QString str = fi. fileName ( );
+ return str. left ( str. findRev ( '.' ));
}
QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
// 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 );
}
};
@@ -438,82 +438,94 @@ void PlayListWidget::addAllToList() {
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;
- if ( fileref.isNull() ) {
- QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
+ 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);
- if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
+ QString extension = fileInfo.extension(false);
+ if( extension.find( "m3u", 0, false) != -1) { //is m3u
readm3u( fileref);
}
- else if(fileref.find("pls",0,TRUE) != -1) { //is pls
+ else if( extension.find( "pls", 0, false) != -1 ) { //is pls
readPls( fileref);
}
- else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
+ else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
clearList();
- loadList(DocLnk(fileref));
+ DocLnk lnk;
+ lnk.setName( fileInfo.baseName() ); //sets name
+ lnk.setFile( fileref ); //sets file name
+ //addToSelection( lnk );
+
+ loadList( lnk);
d->selectedFiles->first();
} else {
clearList();
- addToSelection( DocLnk( fileref ) );
+ 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();
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() );
@@ -1162,73 +1174,74 @@ void PlayListWidget::writeCurrentM3u() {
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
Om3u *m3uList;
m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
if( d->selectedFiles->first()) {
do {
qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
}
}
/*
writes current playlist to m3u file */
void PlayListWidget::writem3u() {
InputDialog *fileDlg;
fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
fileDlg->exec();
QString name, filename, list;
Om3u *m3uList;
if( fileDlg->result() == 1 ) {
name = fileDlg->text();
// qDebug( filename );
-
- if( name.left( 1) != "/" ) {
- filename = QPEApplication::documentDir() + "/" + name;
- }
-
- if( name.right( 3 ) != "m3u" ) {
- filename = QPEApplication::documentDir() + "/" +name+".m3u";
+ if( name.find("/",0,true) != -1) {// assume they specify a file path
+ filename = name;
+ name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
}
+ else //otherwise dump it somewhere noticable
+ filename = QPEApplication::documentDir() + "/" + name;
+ if( filename.right( 3 ) != "m3u" ) //needs filename extension
+ filename += ".m3u";
+
if( d->selectedFiles->first()) {
m3uList = new Om3u(filename, IO_ReadWrite);
do {
m3uList->add( d->selectedFiles->current()->file());
}
while ( d->selectedFiles->next() );
// qDebug( list );
m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
if(fileDlg) delete fileDlg;
DocLnk lnk;
lnk.setFile( filename);
lnk.setIcon("opieplayer2/playlist2");
lnk.setName( name); //sets file name
// qDebug(filename);
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
currentPlayList=filename;
if(!lnk.writeLink()) {
qDebug("Writing doclink did not work");
}
setCaption(tr("OpiePlayer: ") + name);
}