summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp30
2 files changed, 28 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index 62240b2..2c4be1b 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,62 +1,69 @@
#include "inputDialog.h"
#include <qpe/resource.h>
-
+#include <qpe/qpeapplication.h>
+#include <qpe/config.h>
#include <opie/ofiledialog.h>
+#include <qfileinfo.h>
#include <qlineedit.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qpushbutton.h>
#include <qwhatsthis.h>
InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl ) {
if ( !name ) {
setName( "InputDialog" );
}
resize( 234, 115);
setMaximumSize( QSize( 240, 40));
setCaption( tr( name ) );
QPushButton *browserButton;
browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
browserButton->setGeometry( QRect( 205, 10, 22, 22));
connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
LineEdit1 = new QLineEdit( this, "LineEdit1" );
LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
LineEdit1->setFocus();
}
/*
* return the current text(input)
*/
QString InputDialog::text() const {
return LineEdit1->text();
}
/*
* Destroys the object and frees any allocated resources
*/
InputDialog::~InputDialog() {
}
void InputDialog::browse() {
-
+ Config cfg( "OpiePlayer" );
+ cfg.setGroup("Dialog");
MimeTypes types;
QStringList audio, video, all;
audio << "audio/*";
audio << "playlist/plain";
audio << "audio/x-mpegurl";
video << "video/*";
video << "playlist/plain";
all += audio;
all += video;
types.insert("All Media Files", all );
types.insert("Audio", audio );
types.insert("Video", video );
- QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
+ QString str = OFileDialog::getOpenFileName( 1,
+ cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
+ types, 0 );
+ if(str.left(2) == "//") str=str.right(str.length()-1);
LineEdit1->setText(str);
+ cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index b15f95e..0825eed 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -136,51 +136,51 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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 *) ) );
connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
mediaPlayerState, SLOT( setVideoGamma( int ) ) );
// see which skins are installed
videoScan=FALSE;
audioScan=FALSE;
populateSkinsMenu();
initializeStates();
cfg.setGroup("PlayList");
- QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
+ QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
loadList(DocLnk( currentPlaylist ) );
- setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
+
}
PlayListWidget::~PlayListWidget() {
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::writeDefaultPlaylist() {
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
QString filename=QPEApplication::documentDir() + "/default.m3u";
QString currentString = config.readEntry( "CurrentPlaylist", filename);
@@ -719,101 +719,107 @@ void PlayListWidget::openFile() {
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");
+
+// 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");
+// lnk.setIcon(MimeType(s).pixmap() );
+// lnk.setIcon("SoundPlayer");
} else {
// qDebug("set link2 "+s);
lnk.setFile( s);
- lnk.setIcon("SoundPlayer");
+// lnk.setIcon(MimeType(s).pixmap() );
+// lnk.setIcon("SoundPlayer");
}
}
d->selectedFiles->addToSelection( lnk );
}
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
config.write();
currentPlayList=filename;
// m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
d->selectedFiles->setSelectedItem( s);
setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
}
/*
reads pls and adds files/urls to playlist */
void PlayListWidget::readPls( const QString &filename ) {
@@ -821,126 +827,126 @@ void PlayListWidget::readPls( const QString &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 += "/";
- }
+// 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","default");
- 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());
+ qDebug( "add 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;
DocLnk lnk;
lnk.setFile( filename);
- lnk.setIcon("opieplayer2/playlist2");
+// 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);
}
}
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_F9: //activity
// if(audioUI->isHidden())
// audioUI->showMaximized();