summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/playlistwidget.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 9a9e1ec..0a84268 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -18,184 +18,184 @@
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qtoolbar.h>
#include <opie/ofiledialog.h>
#include <qmessagebox.h>
#include "playlistselection.h"
#include "playlistwidget.h"
#include "mediaplayer.h"
#include "mediaplayerstate.h"
#include "inputDialog.h"
#include "om3u.h"
#include "playlistfileview.h"
//only needed for the random play
#include <assert.h>
PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
: PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 )
{
mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" );
m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer");
d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
"opieplayer2/add_to_playlist",
this , SLOT(addSelected() ) );
d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
"opieplayer2/remove_from_playlist",
this , SLOT(removeSelected() ) );
d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
- this , SLOT( btnPlay( bool) ), TRUE );
+ this , SLOT( btnPlay(bool) ), TRUE );
d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
- mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
+ mediaPlayerState, SLOT( setShuffled(bool) ), TRUE );
d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
- mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
+ mediaPlayerState, SLOT( setLooping(bool) ), TRUE );
(void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
this, SLOT( addAllMusicToList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all video files" ),
this, SLOT( addAllVideoToList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all files" ),
this, SLOT( addAllToList() ) );
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Add File" ),
this,SLOT( openFile() ) );
(void)new MenuItem( pmPlayList, tr("Add URL"),
this,SLOT( openURL() ) );
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
this, SLOT(writem3u() ) );
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
audioView, SLOT( scanFiles() ) );
(void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
videoView, SLOT( scanFiles() ) );
pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
mediaPlayerState, SLOT( toggleFullscreen() ) );
Config cfg( "OpiePlayer" );
bool b= cfg.readBoolEntry("FullScreen", 0);
mediaPlayerState->setFullscreen( b );
pmView->setItemChecked( -16, b );
(void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
d->selectedFiles, SLOT(moveSelectedUp() ) );
(void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
d->selectedFiles, SLOT(removeSelected() ) );
(void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
d->selectedFiles, SLOT(moveSelectedDown() ) );
QVBox *stretch2 = new QVBox( vbox1 );
connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
SLOT( deletePlaylist() ) );
- connect( pmView, SIGNAL( activated( int ) ),
- this, SLOT( pmViewActivated( int ) ) );
- connect( skinsMenu, SIGNAL( activated( int ) ) ,
- this, SLOT( skinsMenuActivated( int ) ) );
- 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( pmView, SIGNAL( activated(int) ),
+ this, SLOT( pmViewActivated(int) ) );
+ connect( skinsMenu, SIGNAL( activated(int) ) ,
+ this, SLOT( skinsMenuActivated(int) ) );
+ 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( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
- this, SLOT( playIt( QListViewItem *) ) );
- connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
- mediaPlayerState, SLOT( setVideoGamma( int ) ) );
+ 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( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ),
+ this, SLOT( playIt(QListViewItem*) ) );
+ connect ( gammaSlider, SIGNAL( valueChanged(int) ),
+ mediaPlayerState, SLOT( setVideoGamma(int) ) );
connect( this, SIGNAL(skinSelected() ),
m_mp, SLOT( reloadSkins() ) );
// see which skins are installed
populateSkinsMenu();
initializeStates();
channel = new QCopChannel( "QPE/Application/opieplayer2", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT( qcopReceive(const QCString&, const QByteArray&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
loadList(DocLnk( currentPlaylist ) );
tabWidget->showPage( playListTab );
}
PlayListWidget::~PlayListWidget() {
delete d;
delete m_mp;
}
void PlayListWidget::initializeStates() {
d->tbPlay->setOn( mediaPlayerState->isPlaying() );
d->tbLoop->setOn( mediaPlayerState->isLooping() );
d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
d->playListFrame->show();
}
void PlayListWidget::writeDefaultPlaylist() {
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
QString filename=QPEApplication::documentDir() + "/default.m3u";
QString currentString = config.readEntry( "CurrentPlaylist", filename);
if( currentString == filename) {
Om3u *m3uList;
// qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
if( d->selectedFiles->first() ) {
m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
do {
// qDebug(d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
m3uList->write();
m3uList->close();
delete m3uList;
}
}
}
@@ -458,144 +458,144 @@ void PlayListWidget::addSelected() {
d->selectedFiles->addToSelection( lnk );
}
currentFileListView->clearSelection();
writeCurrentM3u();
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
writeCurrentM3u();
}
void PlayListWidget::playIt( QListViewItem *it) {
if(!it) return;
mediaPlayerState->setPlaying(FALSE);
mediaPlayerState->setPlaying(TRUE);
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
if(it) {
if ( currentTab() == CurrentPlayList )
return;
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 *) {
d->tbPlay->setEnabled( true );
- disconnect( audioView, SIGNAL( itemsSelected( bool ) ),
- d->tbPlay, SLOT( setEnabled( bool ) ) );
- disconnect( videoView, SIGNAL( itemsSelected( bool ) ),
- d->tbPlay, SLOT( setEnabled( bool ) ) );
+ disconnect( audioView, SIGNAL( itemsSelected(bool) ),
+ d->tbPlay, SLOT( setEnabled(bool) ) );
+ disconnect( videoView, SIGNAL( itemsSelected(bool) ),
+ d->tbPlay, SLOT( setEnabled(bool) ) );
currentFileListView = 0;
switch ( currentTab() ) {
case CurrentPlayList:
{
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
}
break;
case AudioFiles:
{
audioView->populateView();
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
- connect( audioView, SIGNAL( itemsSelected( bool ) ),
- d->tbPlay, SLOT( setEnabled( bool ) ) );
+ connect( audioView, SIGNAL( itemsSelected(bool) ),
+ d->tbPlay, SLOT( setEnabled(bool) ) );
d->tbPlay->setEnabled( audioView->hasSelection() );
currentFileListView = audioView;
}
break;
case VideoFiles:
{
videoView->populateView();
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
- connect( videoView, SIGNAL( itemsSelected( bool ) ),
- d->tbPlay, SLOT( setEnabled( bool ) ) );
+ connect( videoView, SIGNAL( itemsSelected(bool) ),
+ d->tbPlay, SLOT( setEnabled(bool) ) );
d->tbPlay->setEnabled( videoView->hasSelection() );
currentFileListView = videoView;
}
break;
case PlayLists:
{
if( tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->show();
}
playLists->reread();
d->tbAddToList->setEnabled(FALSE);
d->tbPlay->setEnabled( false );
}
break;
};
}
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(false);
mediaPlayerState->setPlaying(b);
insanityBool=FALSE;
}
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::playSelected() {
btnPlay( TRUE);
}
bool PlayListWidget::inFileListMode() const
{