summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-12 02:48:15 (UTC)
committer llornkcor <llornkcor>2002-11-12 02:48:15 (UTC)
commitee4ec981207254f6541e080a62b91bae8c9f1726 (patch) (side-by-side diff)
tree587a0f7e079193770f3c0bde6f381bb7acc55b33
parentc829e55b85c20034f0ae07336fd3f5b9a03d9a48 (diff)
downloadopie-ee4ec981207254f6541e080a62b91bae8c9f1726.zip
opie-ee4ec981207254f6541e080a62b91bae8c9f1726.tar.gz
opie-ee4ec981207254f6541e080a62b91bae8c9f1726.tar.bz2
sync with op2
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp7
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp163
2 files changed, 74 insertions, 96 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index ef7c8dc..9a55608 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -39,135 +39,136 @@ extern MediaPlayerState *mediaPlayerState;
static const int xo = -2; // movable x offset
static const int yo = 22; // movable y offset
struct MediaButton {
bool isToggle, isHeld, isDown;
};
//Layout information for the audioButtons (and if it is a toggle button or not)
MediaButton audioButtons[] = {
{ TRUE, FALSE, FALSE }, // play
{ FALSE, FALSE, FALSE }, // stop
{ FALSE, FALSE, FALSE }, // next
{ FALSE, FALSE, FALSE }, // previous
{ FALSE, FALSE, FALSE }, // volume up
{ FALSE, FALSE, FALSE }, // volume down
{ TRUE, FALSE, FALSE }, // repeat/loop
{ FALSE, FALSE, FALSE }, // playlist
{ FALSE, FALSE, FALSE }, // forward
{ FALSE, FALSE, FALSE } // back
};
const char *skin_mask_file_names[10] = {
"play", "stop", "next", "prev", "up",
"down", "loop", "playlist", "forward", "back"
};
static void changeTextColor( QWidget *w ) {
QPalette p = w->palette();
p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
w->setPalette( p );
}
static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
{
setCaption( tr("OpiePlayer") );
qDebug("<<<<<audioWidget");
Config cfg("OpiePlayer");
cfg.setGroup("Options");
skin = cfg.readEntry("Skin","default");
//skin = "scaleTest";
// color of background, frame, degree of transparency
+// QString skinPath = "opieplayer/skins/" + skin;
QString skinPath = "opieplayer2/skins/" + skin;
qDebug("skin path "+skinPath);
pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
imgButtonMask->fill( 0 );
for ( int i = 0; i < 10; i++ ) {
QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
masks[i] = new QBitmap( filename );
if ( !masks[i]->isNull() ) {
QImage imgMask = masks[i]->convertToImage();
uchar **dest = imgButtonMask->jumpTable();
for ( int y = 0; y < imgUp->height(); y++ ) {
uchar *line = dest[y];
for ( int x = 0; x < imgUp->width(); x++ )
if ( !qRed( imgMask.pixel( x, y ) ) )
line[x] = i + 1;
}
}
}
for ( int i = 0; i < 11; i++ ) {
buttonPixUp[i] = NULL;
buttonPixDown[i] = NULL;
}
setBackgroundPixmap( *pixBg );
songInfo.setFocusPolicy( QWidget::NoFocus );
- changeTextColor( &songInfo );
- songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
- songInfo.setFrameStyle( QFrame::NoFrame);
+// changeTextColor( &songInfo );
+// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
+// songInfo.setFrameStyle( QFrame::NoFrame);
// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
//NoFrame
// songInfo.setForegroundColor(Qt::white);
slider.setFixedHeight( 20 );
slider.setMinValue( 0 );
slider.setMaxValue( 1 );
slider.setFocusPolicy( QWidget::NoFocus );
slider.setBackgroundPixmap( *pixBg );
time.setFocusPolicy( QWidget::NoFocus );
time.setAlignment( Qt::AlignCenter );
time.setFrame(FALSE);
changeTextColor( &time );
resizeEvent( NULL );
connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
// Intialise state
setLength( mediaPlayerState->length() );
setPosition( mediaPlayerState->position() );
setLooping( mediaPlayerState->fullscreen() );
// setPaused( mediaPlayerState->paused() );
setPlaying( mediaPlayerState->playing() );
}
AudioWidget::~AudioWidget() {
for ( int i = 0; i < 10; i++ ) {
delete buttonPixUp[i];
delete buttonPixDown[i];
}
delete pixBg;
delete imgUp;
delete imgDn;
delete imgButtonMask;
for ( int i = 0; i < 10; i++ ) {
delete masks[i];
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index a937d7c..c28548c 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -199,174 +199,177 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
skinsMenu->isCheckable();
connect( skinsMenu, SIGNAL( activated( int ) ) ,
this, SLOT( skinsMenuActivated( int ) ) );
populateSkinsMenu();
QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
tabWidget = new QTabWidget( hbox6, "tabWidget" );
tabWidget->setTabShape(QTabWidget::Triangular);
QWidget *pTab;
pTab = new QWidget( tabWidget, "pTab" );
// playlistView = new QListView( pTab, "playlistview" );
// playlistView->setMinimumSize(236,260);
tabWidget->insertTab( pTab,"Playlist");
// Add the playlist area
QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
d->playListFrame = vbox3;
d->playListFrame ->setMinimumSize(235,260);
QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
d->selectedFiles = new PlayListSelection( hbox2);
QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
QWidget *aTab;
aTab = new QWidget( tabWidget, "aTab" );
audioView = new QListView( aTab, "Audioview" );
audioView->setMinimumSize(233,260);
audioView->addColumn( tr("Title"),140);
audioView->addColumn(tr("Size"), -1);
audioView->addColumn(tr("Media"),-1);
+ audioView->addColumn( tr( "Path" ), 0 );
+
audioView->setColumnAlignment(1, Qt::AlignRight);
audioView->setColumnAlignment(2, Qt::AlignRight);
audioView->setAllColumnsShowFocus(TRUE);
audioView->setMultiSelection( TRUE );
audioView->setSelectionMode( QListView::Extended);
tabWidget->insertTab(aTab,tr("Audio"));
QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
// audioView
// populateAudioView();
// videowidget
QWidget *vTab;
vTab = new QWidget( tabWidget, "vTab" );
videoView = new QListView( vTab, "Videoview" );
videoView->setMinimumSize(233,260);
videoView->addColumn(tr("Title"),140);
videoView->addColumn(tr("Size"),-1);
videoView->addColumn(tr("Media"),-1);
+ videoView->addColumn(tr( "Path" ), 0 );
videoView->setColumnAlignment(1, Qt::AlignRight);
videoView->setColumnAlignment(2, Qt::AlignRight);
videoView->setAllColumnsShowFocus(TRUE);
videoView->setMultiSelection( TRUE );
videoView->setSelectionMode( QListView::Extended);
QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
tabWidget->insertTab( vTab,tr("Video"));
QWidget *LTab;
LTab = new QWidget( tabWidget, "LTab" );
playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
playLists->setMinimumSize(233,260);
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)) );
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( 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","");
+ QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
loadList(DocLnk( currentPlaylist));
- setCaption(tr("OpiePlayer: ")+ currentPlaylist );
+ setCaption(tr("OpiePlayer: ")+ QFileInfo(currentPlaylist).baseName());
initializeStates();
}
PlayListWidget::~PlayListWidget() {
Config cfg( "OpiePlayer" );
writeConfig( cfg );
if ( d->current )
delete d->current;
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 {
@@ -378,112 +381,124 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
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() ) {
QMessageBox::critical( 0, tr("Out of space"),
tr( "There was a problem saving "
"the playlist.\n"
"Your playlist "
"may be missing some entries\n"
"the next time you start it." )
);
}
}
noOfFiles++;
}
}
while ( d->selectedFiles->next() );
cfg.writeEntry("NumberOfFiles", noOfFiles );
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->setDocumentUsed = false;
if ( mediaPlayerState->playlist() ) {
if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
d->selectedFiles->addToSelection( lnk );
}
else
mediaPlayerState->setPlaying( true);
}
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;
if ( fileref.isNull() ) {
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
readm3u( fileref);
}
else if(fileref.find("pls",0,TRUE) != -1) { //is pls
readPls( fileref);
}
else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
clearList();
loadList(DocLnk(fileref));
d->selectedFiles->first();
} else {
clearList();
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;
}
@@ -600,200 +615,160 @@ bool PlayListWidget::next() {
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() {
writem3u();
}
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
if( name.length()>0) {
setCaption("OpiePlayer: "+name);
// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
clearList();
readm3u(lnk.file());
tabWidget->setCurrentPage(0);
}
}
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() {
+ qDebug("addSelected");
+ DocLnk lnk;
+ QString filename;
+ switch (tabWidget->currentPageIndex()) {
- Config cfg( "OpiePlayer" );
- cfg.setGroup("PlayList");
- QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
-// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
+ case 0: //playlist
+ return;
+ break;
+ case 1: { //audio
+ filename=audioView->currentItem()->text(3);
+ // d->selectedFiles->next();
+ }
+ break;
+
+ case 2: { // video
+ filename=videoView->currentItem()->text(3);
+ // tabWidget->setCurrentPage(0);
+
+ }
+ break;
+ };
+ lnk.setName( QFileInfo(filename).baseName() ); //sets name
+ lnk.setFile( filename ); //sets file name
+ d->selectedFiles->addToSelection( lnk);
+ tabWidget->setCurrentPage(0);
+ writeCurrentM3u();
- switch (tabWidget->currentPageIndex()) {
- case 0: //playlist
- break;
- case 1: { //audio
-// QString entryName;
-// entryName.sprintf( "File%i", i + 1 );
-// QString linkFile = cfg.readEntry( entryName );
- QListViewItemIterator it( audioView );
- // iterate through all items of the listview
- for ( ; it.current(); ++it ) {
- if ( it.current()->isSelected() ) {
- QListIterator<DocLnk> dit( files.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it.current()->text(0) ) {
- d->selectedFiles->addToSelection( **dit );
- }
- }
- audioView->setSelected( it.current(),FALSE);
- }
- }
- tabWidget->setCurrentPage(0);
- }
- break;
- case 2: { // video
- QListViewItemIterator it( videoView );
- // iterate through all items of the listview
- for ( ; it.current(); ++it ) {
- if ( it.current()->isSelected() ) {
- QListIterator<DocLnk> dit( vFiles.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it.current()->text(0) ) {
- d->selectedFiles->addToSelection( **dit );
- }
- }
-
- videoView->setSelected( it.current(),FALSE);
- }
- }
-// for ( int i = 0; i < noOfFiles; i++ ) {
-// QString entryName;
-// entryName.sprintf( "File%i", i + 1 );
-// QString linkFile = cfg.readEntry( entryName );
-// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
-// int result= QMessageBox::warning(this,tr("OpiePlayer"),
-// tr("This is all ready in your playlist.\nContinue?"),
-// tr("Yes"),tr("No"),0,0,1);
-// if (result !=0)
-// return;
-// }
-// }
-// addToSelection( videoView->selectedItem() );
- tabWidget->setCurrentPage(0);
- }
- break;
- };
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
}
void PlayListWidget::playIt( QListViewItem *) {
// d->setDocumentUsed = FALSE;
// mediaPlayerState->curPosition =0;
qDebug("playIt");
mediaPlayerState->setPlaying(FALSE);
mediaPlayerState->setPlaying(TRUE);
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
- d->setDocumentUsed = FALSE;
-
- if(it) {
- switch (tabWidget->currentPageIndex()) {
- case 1: {
- QListIterator<DocLnk> dit( files.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it->text(0)) {
- d->selectedFiles->addToSelection( **dit );
- }
- }
- }
- break;
- case 2: {
- QListIterator<DocLnk> dit( vFiles.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it->text(0)) {
- d->selectedFiles->addToSelection( **dit );
- }
- }
- }
- break;
- case 0:
- break;
- };
- tabWidget->setCurrentPage(0);
- }
+ 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( QFileInfo(filename).baseName() ); //sets name
+ lnk.setFile( filename ); //sets file name
+ d->selectedFiles->addToSelection( lnk);
+
+ 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");
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
@@ -944,170 +919,173 @@ void PlayListWidget::listDelete() {
void PlayListWidget::scanForAudio() {
// qDebug("scan for audio");
files.detachChildren();
QListIterator<DocLnk> sdit( files.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
Global::findDocuments( &files, audioMimes);
audioScan = true;
}
void PlayListWidget::scanForVideo() {
// qDebug("scan for video");
vFiles.detachChildren();
QListIterator<DocLnk> sdit( vFiles.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
Global::findDocuments(&vFiles, "video/*");
videoScan = true;
}
void PlayListWidget::populateAudioView() {
audioView->clear();
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
if(!audioScan) scanForAudio();
QListIterator<DocLnk> dit( files.children() );
QListIterator<FileSystem> it ( fs );
QString storage;
for ( ; dit.current(); ++dit ) {
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
if(dit.current()->file().find(path) != -1 ) storage=name;
}
QListViewItem * newItem;
if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
long size;
if( dit.current()->file().left(4) == "http" )
size=0;
else
size = QFile( dit.current()->file() ).size();
// qDebug(dit.current()->name());
newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
- QString::number(size ), storage);
+ QString::number(size ), storage, dit.current()->file());
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
}
}
}
void PlayListWidget::populateVideoView() {
videoView->clear();
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
if(!videoScan ) scanForVideo();
QListIterator<DocLnk> Vdit( vFiles.children() );
QListIterator<FileSystem> it ( fs );
videoView->clear();
QString storage;
for ( ; Vdit.current(); ++Vdit ) {
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
if( Vdit.current()->file().find(path) != -1 ) storage=name;
}
QListViewItem * newItem;
if ( QFile( Vdit.current()->file()).exists() ) {
newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
- QString::number( QFile( Vdit.current()->file()).size() ), storage);
+ QString::number( QFile( Vdit.current()->file() ).size() ),
+ storage, Vdit.current()->file());
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
}
}
}
void PlayListWidget::openFile() {
qDebug("<<<<<<<<<OPEN File");
QString filename, name;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
filename = fileDlg->text();
qDebug( "Selected filename is " + filename );
// Om3u *m3uList;
DocLnk lnk;
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
if(filename.left(4) == "http") {
QString m3uFile, m3uFilePath;
if(filename.find(":",8,TRUE) != -1) { //found a port
m3uFile = filename.left( filename.find( ":",8,TRUE));
m3uFile = m3uFile.right( 7);
} else if(filename.left(4) == "http"){
m3uFile=filename;
m3uFile = m3uFile.right( m3uFile.length() - 7);
} else{
m3uFile=filename;
}
// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
lnk.setName( filename ); //sets name
lnk.setFile( filename ); //sets file name
lnk.setIcon("opieplayer2/musicfile");
d->selectedFiles->addToSelection( lnk );
writeCurrentM3u();
}
else if( filename.right( 3) == "m3u" ) {
readm3u( filename );
} else if( filename.right(3) == "pls" ) {
readPls( filename );
} else {
- d->selectedFiles->addToSelection( DocLnk(filename) );
+ lnk.setName( QFileInfo(filename).baseName() ); //sets name
+ lnk.setFile( filename ); //sets file name
+ d->selectedFiles->addToSelection( lnk);
writeCurrentM3u();
}
}
if( fileDlg ) {
delete fileDlg;
}
}
/*
reads m3u and shows files/urls to playlist widget */
void PlayListWidget::readm3u( const QString &filename ) {
qDebug( "read m3u filename " + filename );
Om3u *m3uList;
QString s, name;
m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readM3u();
DocLnk lnk;
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
// qDebug("reading "+ s);
if(s.left(4)=="http") {
lnk.setName( s ); //sets file name
lnk.setIcon("opieplayer2/musicfile");
if(s.right(4) != '.' || s.right(5) != '.')
lnk.setFile( s+"/"); //if url with no extension
else
lnk.setFile( s ); //sets file name
} else {
// if( QFileInfo( s ).exists() ) {
lnk.setName( QFileInfo(s).baseName());
// if(s.right(4) == '.') {//if regular file
if(s.left(1) != "/") {
// qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
lnk.setIcon("SoundPlayer");
} else {
// qDebug("set link2 "+s);
lnk.setFile( s);
lnk.setIcon("SoundPlayer");
}
}
d->selectedFiles->addToSelection( lnk );
}
Config config( "OpiePlayer" );
@@ -1132,101 +1110,100 @@ void PlayListWidget::readPls( const QString &filename ) {
qDebug( "pls filename is " + filename );
Om3u *m3uList;
QString s, name;
m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readPls();
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
// s.replace( QRegExp( "%20" )," " );
DocLnk lnk( s );
QFileInfo f( s );
QString name = f.baseName();
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
}
name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
lnk.setName( name );
if( s.at( s.length() - 4) == '.') {// if this is probably a file
lnk.setFile( s );
} else { //if its a url
if( name.right( 1 ).find( '/' ) == -1) {
s += "/";
}
lnk.setFile( s );
}
lnk.setType( "audio/x-mpegurl" );
lnk.writeLink();
d->selectedFiles->addToSelection( lnk );
}
m3uList->close();
if(m3uList) delete m3uList;
}
/*
writes current playlist to current m3u file */
void PlayListWidget::writeCurrentM3u() {
qDebug("writing to current m3u");
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
-
- if( d->selectedFiles->first()) {
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( 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;