summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp98
1 files changed, 58 insertions, 40 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 218fd49..250645c 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -22,40 +22,42 @@
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/lnkproperties.h>
#include <qpe/storage.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/resource.h>
+
#include <qaction.h>
#include <qimage.h>
#include <qfile.h>
#include <qdir.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qlist.h>
#include <qlistbox.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qtoolbutton.h>
#include <qtabwidget.h>
#include <qlistview.h>
#include <qpoint.h>
#include <qlineedit.h>
#include <qpushbutton.h>
+#include <qregexp.h>
//#include <qtimer.h>
#include "playlistselection.h"
#include "playlistwidget.h"
#include "mediaplayerstate.h"
#include "inputDialog.h"
#include <stdlib.h>
#define BUTTONS_ON_TOOLBAR
@@ -108,76 +110,76 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
d = new PlayListWidgetPrivate;
d->setDocumentUsed = FALSE;
d->current = NULL;
fromSetDocument = FALSE;
insanityBool=FALSE;
// menuTimer = new QTimer( this ,"menu timer"),
// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
setBackgroundMode( PaletteButton );
setCaption( tr("OpiePlayer") );
- setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
+ setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
setToolBarsMovable( FALSE );
// Create Toolbar
QPEToolBar *toolbar = new QPEToolBar( this );
toolbar->setHorizontalStretchable( TRUE );
// Create Menubar
QPEMenuBar *menu = new QPEMenuBar( toolbar );
menu->setMargin( 0 );
QPEToolBar *bar = new QPEToolBar( this );
bar->setLabel( tr( "Play Operations" ) );
-// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list",
+// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
// this , SLOT( addSelected()) );
tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
tbDeletePlaylist->setFlat(TRUE);
tbDeletePlaylist->setFixedSize(20,20);
connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
- d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist",
+ d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
this , SLOT(addSelected()) );
- d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist",
+ d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
this , SLOT(removeSelected()) );
-// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
- d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play",
+// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
+ d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
this , SLOT( btnPlay(bool) ), TRUE );
- d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle",
+ d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
- d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop",
+ d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
mediaPlayerState, SLOT(setLooping(bool)), TRUE );
tbDeletePlaylist->hide();
QPopupMenu *pmPlayList = new QPopupMenu( this );
menu->insertItem( tr( "File" ), pmPlayList );
new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
// pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
QPopupMenu *pmView = new QPopupMenu( this );
menu->insertItem( tr( "View" ), pmView );
fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
fullScreenButton->addTo(pmView);
- scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0);
+ scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
scaleButton->addTo(pmView);
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;
@@ -195,27 +197,27 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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);
connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
- new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
- new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
- new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
+ 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->setColumnAlignment(1, Qt::AlignRight);
audioView->setColumnAlignment(2, Qt::AlignRight);
audioView->setAllColumnsShowFocus(TRUE);
@@ -420,32 +422,33 @@ void PlayListWidget::addAllVideoToList() {
d->selectedFiles->addToSelection( **dit );
}
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
- clearList();
- addToSelection( DocLnk( fileref ) );
- d->setDocumentUsed = TRUE;
- d->selectedFiles->first();
- qApp->processEvents();
- }
- else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
+// if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
+// clearList();
+// addToSelection( DocLnk( fileref ) );
+// d->setDocumentUsed = TRUE;
+// d->selectedFiles->first();
+// qApp->processEvents();
+// }
+// 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"));
@@ -610,25 +613,25 @@ void PlayListWidget::saveList() {
// if( playLists->selected()->name() == filename) {
// qDebug("same name so delete lnk");
// QFile().remove(playLists->selected()->file());
// QFile().remove(playLists->selected()->linkFile());
// playLists->reread();
// }
// qDebug("new doclnk");
DocLnk lnk;
// lnk.setComment( "");
lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
- lnk.setIcon("mpegplayer/playlist2");
+ lnk.setIcon("opieplayer/playlist2");
lnk.setName( filename); //sets file name
// qDebug(filename);
if(!lnk.writeLink())
qDebug("Writing doclink did not work");
}
Config config( "OpiePlayer" );
config.writeEntry("CurrentPlaylist",filename);
setCaption(tr("OpiePlayer: ")+filename);
d->selectedFiles->first();
if(fileDlg)
delete fileDlg;
}
@@ -937,67 +940,82 @@ void PlayListWidget::populateAudioView() {
audioView->clear();
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() ) {
newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
- newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
+ newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
}
}
}
void PlayListWidget::populateVideoView() {
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
Global::findDocuments(&vFiles, "video/*");
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);
- newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
+ newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
}
}
}
void PlayListWidget::openFile() {
- QString filename;
+ QString filename, name;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
filename = fileDlg->LineEdit1->text();
+
+// InputDialog *fileDlg2;
+// fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0);
+// fileDlg2->exec();
+// if( fileDlg2->result() == 1 ) {
+// name = fileDlg2->LineEdit1->text();
+// }
+//http://205.188.234.129:8030
+ qDebug(filename);
+ DocLnk lnk;
+// if(filename.left(7) == "http://")
+// name= filename.right(filename.length()-filename.find("http://")-7);
+// else name = filename;
+// qDebug("name is "+name);
+// lnk.setComment(filename);
+ lnk.setName(filename); //sets file name
+ if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
+ filename += "/";
+ lnk.setFile(filename); //sets File property
+
+ lnk.setType("audio/x-mpegurl");
+ lnk.setExec("opieplayer");
+ lnk.setIcon("opieplayer/MPEGPlayer");
+
+ if(!lnk.writeLink())
+ qDebug("Writing doclink did not work");
+ d->selectedFiles->addToSelection( lnk);
+// if(fileDlg2)
+// delete fileDlg2;
}
- qDebug(filename);
- DocLnk lnk;
- QString name = filename.right(filename.length()-filename.find("http://")-7);
- qDebug(name);
- lnk.setName( name); //sets file name
-// lnk.setComment();
- lnk.setFile(filename); //sets File property
-// problem is, the launcher sees this as a broken link and does not display it :(
- lnk.setType("audio/x-mpegurl");
- lnk.setExec("opieplayer");
- lnk.setIcon("opieplayer/MPEGPlayer");
-
- if(!lnk.writeLink())
- qDebug("Writing doclink did not work");
- d->selectedFiles->addToSelection( lnk);
+
if(fileDlg)
- delete fileDlg;
+ delete fileDlg;
}