author | llornkcor <llornkcor> | 2002-03-19 12:15:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-19 12:15:24 (UTC) |
commit | 58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5 (patch) (side-by-side diff) | |
tree | 6f58918f36e66d026d4bbb67574f2d195f15b6ad | |
parent | 7a4ff15ff356a484a498249f01354dce549eaec2 (diff) | |
download | opie-58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5.zip opie-58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5.tar.gz opie-58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5.tar.bz2 |
reverted back till I figure out
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.h | 1 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 14 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mpegplayer.pro | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 8 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 135 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 1 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 5 |
8 files changed, 124 insertions, 46 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 3901446..cda3f77 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -199,62 +199,64 @@ void AudioWidget::timerEvent( QTimerEvent * ) { p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); } } void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numButtons; i++ ) { int size = audioButtons[i].isBig; int x = audioButtons[i].xPos; int y = audioButtons[i].yPos; if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the circular button or not // (compared with the radius squared to avoid a square-root of our distance) int radius = 32 + 13 * size; QPoint center = QPoint( x + radius, y + radius ); QPoint dXY = center - event->pos(); int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); bool isOnButton = dist <= (radius * radius); // QRect r( x, y, 64 + 22*size, 64 + 22*size ); // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); - qDebug("button toggled %d",i); + qDebug("button toggled1 %d",i); switch (i) { case AudioVolumeUp: emit moreClicked(); return; case AudioVolumeDown: emit lessClicked(); return; } } else if ( !isOnButton && audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; toggleButton(i); + qDebug("button toggled2 %d",i); } } else { if ( audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; if ( !audioButtons[i].isToggle ) setToggleButton( i, FALSE ); + qDebug("button toggled3 %d",i); switch (i) { case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; case AudioStop: mediaPlayerState->setPlaying(FALSE); return; case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; case AudioNext: mediaPlayerState->setNext(); return; case AudioPrevious: mediaPlayerState->setPrev(); return; case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; case AudioVolumeUp: emit moreReleased(); return; case AudioVolumeDown: emit lessReleased(); return; case AudioPlayList: mediaPlayerState->setList(); return; } } } } } void AudioWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { mouseMoveEvent( event ); diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h index a2850aa..d1d72b6 100644 --- a/core/multimedia/opieplayer/audiowidget.h +++ b/core/multimedia/opieplayer/audiowidget.h @@ -1,43 +1,44 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ + #ifndef AUDIO_WIDGET_H #define AUDIO_WIDGET_H #include <qwidget.h> #include <qpainter.h> #include <qdrawutil.h> #include <qpixmap.h> #include <qstring.h> #include <qslider.h> #include <qframe.h> class QPixmap; enum AudioButtons { AudioPlay, AudioStop, AudioPause, AudioNext, AudioPrevious, AudioVolumeUp, AudioVolumeDown, AudioLoop, diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 4b2827e..b9f96de 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -1,46 +1,45 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // L.J.Potter added changes Fri 02-15-2002 - #include <qpe/qpeapplication.h> #ifdef Q_WS_QWS #include <qpe/qcopenvelope_qws.h> #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <errno.h> #include <unistd.h> #include "loopcontrol.h" #include "videowidget.h" #include "audiodevice.h" #include <qpe/mediaplayerplugininterface.h> #include "mediaplayerstate.h" extern VideoWidget *videoUI; // now only needed to tell it to play a frame extern MediaPlayerState *mediaPlayerState; //#define DecodeLoopDebug(x) qDebug x #define DecodeLoopDebug(x) @@ -200,68 +199,69 @@ void LoopControl::startVideo() { current_frame++; } if ( prev_frame == -1 || current_frame > prev_frame ) { if ( current_frame > prev_frame + 1 ) { mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); } moreVideo = videoUI->playVideo(); prev_frame = current_frame; } } else { moreVideo = FALSE; killTimer( videoId ); } } } void LoopControl::startAudio() { +//qDebug("start audio"); audioMutex->lock(); if ( moreAudio ) { if ( !isMuted && mediaPlayerState->curDecoder() ) { currentSample = audioSampleCounter + 1; if ( currentSample != audioSampleCounter + 1 ) qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); long samplesRead = 0; bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; long sampleWaitTime = currentSample - sampleWeShouldBeAt; // if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { // usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); // } // else if ( sampleWaitTime <= -5000 ) { -// // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); +// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); // currentSample = sampleWeShouldBeAt; // } audioDevice->write( audioBuffer, samplesRead * 2 * channels ); audioSampleCounter = currentSample + samplesRead - 1; moreAudio = readOk && (audioSampleCounter <= total_audio_samples); } else { moreAudio = FALSE; } } audioMutex->unlock(); } void LoopControl::killTimers() { audioMutex->lock(); @@ -357,69 +357,67 @@ bool LoopControl::init( const QString& filename ) { current_frame = total_video_frames = total_audio_samples = 0; qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); mediaPlayerState->libMpeg3Decoder()->close(); } } if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { audioMutex->unlock(); return FALSE; } hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; if ( hasAudioChannel ) { int astream = 0; channels = mediaPlayerState->curDecoder()->audioChannels( astream ); -// qDebug( "LC- channels = %d", channels ); + qDebug( "LC- channels = %d", channels ); if ( !total_audio_samples ) total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); // total_audio_samples += 1000; mediaPlayerState->setLength( total_audio_samples ); freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); -// qDebug( "LC- frequency = %d", freq ); + qDebug( "LC- frequency = %d", freq ); audioSampleCounter = 0; int bits_per_sample; - if ( mediaPlayerState->curDecoder()->pluginName() == QString("WavPlugin") ) { + if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); -// qDebug("using stupid hack"); + qDebug("using stupid hack"); } else { bits_per_sample=0; -// freq=44100; - channels=2; } audioDevice = new AudioDevice( freq, channels, bits_per_sample); audioBuffer = new char[ audioDevice->bufferSize() ]; channels = audioDevice->channels(); //### must check which frequency is actually used. static const int size = 1; short int buf[size]; long samplesRead = 0; mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); } if ( hasVideoChannel ) { total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); mediaPlayerState->setLength( total_video_frames ); framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); if ( framerate <= 1.0 ) { DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); framerate = 25; diff --git a/core/multimedia/opieplayer/mpegplayer.pro b/core/multimedia/opieplayer/mpegplayer.pro index b9e9ffe..241e29e 100644 --- a/core/multimedia/opieplayer/mpegplayer.pro +++ b/core/multimedia/opieplayer/mpegplayer.pro @@ -1,26 +1,26 @@ TEMPLATE = app CONFIG = qt warn_on release #release DESTDIR = $(OPIEDIR)/bin HEADERS = loopcontrol.h mediaplayerplugininterface.h playlistselection.h mediaplayerstate.h \ videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h SOURCES = main.cpp \ loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp TARGET = mpegplayer INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lpthread # INTERFACES = # INCLUDEPATH += $(OPIEDIR)/include # CONFIG+=static # TMAKE_CXXFLAGS += -DQPIM_STANDALONE # LIBS += libmpeg3/libmpeg3.a -lpthread # LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -TRANSLATIONS = ../i18n/de/mpegplayer.ts +TRANSLATIONS += ../i18n/de/mpegplayer.ts TRANSLATIONS += ../i18n/pt_BR/mpegplayer.ts diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 991301a..756e3b4 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp @@ -34,69 +34,69 @@ class PlayListSelectionItem : public QListViewItem { public: PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { setText( 0, f->name() ); setPixmap( 0, f->pixmap() ); } ~PlayListSelectionItem() { }; const DocLnk *file() const { return fl; } private: const DocLnk *fl; }; PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) : QListView( parent, name ) { qDebug("starting playlistselector"); // #ifdef USE_PLAYLIST_BACKGROUND // setStaticBackground( TRUE ); // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); - setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); +// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); // #endif // addColumn("Title",236); // setAllColumnsShowFocus( TRUE ); addColumn( tr( "Playlist Selection" ) ); header()->hide(); setSorting( -1, FALSE ); } PlayListSelection::~PlayListSelection() { } // #ifdef USE_PLAYLIST_BACKGROUND void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { // qDebug("drawBackground"); p->fillRect( r, QBrush( white ) ); - QImage logo = Resource::loadImage( "launcher/opielogo" ); - if ( !logo.isNull() ) - p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); +// QImage logo = Resource::loadImage( "launcher/opielogo" ); +// if ( !logo.isNull() ) +// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); } // #endif void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { if ( event->state() == QMouseEvent::LeftButton ) { QListViewItem *currentItem = selectedItem(); QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); if ( currentItem && currentItem->itemAbove() == itemUnder ) moveSelectedUp(); else if ( currentItem && currentItem->itemBelow() == itemUnder ) moveSelectedDown(); } } const DocLnk *PlayListSelection::current() { PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); if ( item ) return item->file(); return NULL; } diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 524747e..cf665c8 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -85,48 +85,49 @@ public: setToggleButton( t ); connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); QPEMenuToolFocusManager::manager()->addWidget( this ); } }; class MenuItem : public QAction { public: MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) : QAction( text, QString::null, 0, 0 ) { connect( this, SIGNAL( activated() ), handler, slot ); addTo( parent ); } }; PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, 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" ) ); 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", // this , SLOT( addSelected()) ); tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); tbDeletePlaylist->setFlat(TRUE); @@ -185,86 +186,86 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 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); 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()) ); 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( "Title",150); - audioView->addColumn("Size", 45); - audioView->addColumn("Media",35); + audioView->addColumn( "Title",140); + audioView->addColumn("Size", -1); + audioView->addColumn("Media",-1); audioView->setColumnAlignment(1, Qt::AlignRight); audioView->setColumnAlignment(2, Qt::AlignRight); audioView->setAllColumnsShowFocus(TRUE); tabWidget->insertTab(aTab,"Audio"); QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); // audioView Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); QString storage; for ( ; dit.current(); ++dit ) { QListViewItem * newItem; if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; else storage="RAM"; 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" )); } } // videowidget QWidget *vTab; vTab = new QWidget( tabWidget, "vTab" ); videoView = new QListView( vTab, "Videoview" ); videoView->setMinimumSize(233,260); - videoView->addColumn("Title",150); - videoView->addColumn("Size",45); - videoView->addColumn("Media",35); + videoView->addColumn("Title",140); + videoView->addColumn("Size",-1); + videoView->addColumn("Media",-1); videoView->setColumnAlignment(1, Qt::AlignRight); videoView->setColumnAlignment(2, Qt::AlignRight); videoView->setAllColumnsShowFocus(TRUE); QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); tabWidget->insertTab( vTab,"Video"); Global::findDocuments(&vFiles, "video/*"); QListIterator<DocLnk> Vdit( vFiles.children() ); for ( ; Vdit.current(); ++Vdit ) { if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; else storage="RAM"; 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" )); } } //playlists list @@ -465,80 +466,92 @@ void PlayListWidget::setActiveWindow() { 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() ); // for ( ; dit.current(); ++dit ) { // if(dit.current()->linkFile() == setDocFileRef) { // qDebug(setDocFileRef); // return dit; // } // } // } else - switch (tabWidget->currentPageIndex()) { - case 0: //playlist - { +// qDebug("current"); +// switch (tabWidget->currentPageIndex()) { +// case 0: //playlist +// { + qDebug("playlist"); if ( mediaPlayerState->playlist() ) { return d->selectedFiles->current(); } else if ( d->setDocumentUsed && d->current ) { return d->current; } else { return d->files->selected(); } - } - break; - case 1: { //audio - Global::findDocuments(&files, "audio/*"); - QListIterator<DocLnk> dit( files.children() ); - for ( ; dit.current(); ++dit ) { - if( dit.current()->name() == audioView->currentItem()->text(0)) - return dit; - } - } - break; - case 2: { // video - Global::findDocuments(&vFiles, "video/*"); - QListIterator<DocLnk> Vdit( vFiles.children() ); - for ( ; Vdit.current(); ++Vdit ) { - if( Vdit.current()->name() == videoView->currentItem()->text(0)) - return Vdit; - } - } - break; - }; +// } +// break; +// case 1://audio +// { +// qDebug("audioView"); +// Global::findDocuments(&files, "audio/*"); +// QListIterator<DocLnk> dit( files.children() ); +// for ( ; dit.current(); ++dit ) { +// if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { +// qDebug("here"); +// insanityBool=TRUE; +// return dit; +// } +// } +// } +// break; +// case 2: // video +// { +// qDebug("videoView"); +// Global::findDocuments(&vFiles, "video/*"); +// QListIterator<DocLnk> Vdit( vFiles.children() ); +// for ( ; Vdit.current(); ++Vdit ) { +// if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { +// insanityBool=TRUE; +// return Vdit; +// } +// } +// } +// break; +// }; +// return 0; } bool PlayListWidget::prev() { if ( mediaPlayerState->playlist() ) { if ( mediaPlayerState->shuffled() ) { const DocLnk *cur = current(); int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); for ( int i = 0; i < j; i++ ) { if ( !d->selectedFiles->next() ) d->selectedFiles->first(); } if ( cur == current() ) if ( !d->selectedFiles->next() ) d->selectedFiles->first(); return TRUE; } else { if ( !d->selectedFiles->prev() ) { if ( mediaPlayerState->looping() ) { return d->selectedFiles->last(); } else { return FALSE; } } return TRUE; @@ -633,57 +646,88 @@ void PlayListWidget::loadList( const DocLnk & lnk) { readConfig(cfg); tabWidget->setCurrentPage(0); Config config( "MediaPlayer" ); config.writeEntry("CurrentPlaylist", name); d->selectedFiles->first(); } } 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() { + Config cfg( "MediaPlayer" ); + cfg.setGroup("PlayList"); + QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); + int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); + switch (tabWidget->currentPageIndex()) { case 0: //playlist break; case 1: { //audio + for ( int i = 0; i < noOfFiles; i++ ) { + QString entryName; + entryName.sprintf( "File%i", i + 1 ); + QString linkFile = cfg.readEntry( entryName ); + if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { + int result= QMessageBox::warning(this,"OpiePlayer", + tr("This is all ready in your playlist.\nContinue?"), + tr("Yes"),tr("No"),0,0,1); + if (result !=0) + return; + } + } addToSelection( audioView->selectedItem() ); + tabWidget->setCurrentPage(1); } break; case 2: { // video + 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,"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(2); } break; }; } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); } void PlayListWidget::playIt( QListViewItem *it) { // d->setDocumentUsed = FALSE; mediaPlayerState->setPlaying(TRUE); } void PlayListWidget::addToSelection( QListViewItem *it) { d->setDocumentUsed = FALSE; if(it) { // qDebug("add to selection"); switch (tabWidget->currentPageIndex()) { case 1: { // qDebug("case 1"); QListIterator<DocLnk> dit( files.children() ); @@ -734,50 +778,81 @@ void PlayListWidget::tabChanged(QWidget *widg) { } break; case 2: { if( !tbDeletePlaylist->isHidden()) tbDeletePlaylist->hide(); d->tbRemoveFromList->setEnabled(FALSE); d->tbAddToList->setEnabled(TRUE); } break; case 3: { if( tbDeletePlaylist->isHidden()) tbDeletePlaylist->show(); playLists->reread(); } break; }; } /* play button is pressed*/ void PlayListWidget::btnPlay(bool b) { +// mediaPlayerState->setPlaying(b); + switch ( tabWidget->currentPageIndex()) { + case 0: + { mediaPlayerState->setPlaying(b); } + break; + case 1: + { + addToSelection( audioView->selectedItem() ); + mediaPlayerState->setPlaying(b); +// qApp->processEvents(); + d->selectedFiles->removeSelected( ); + tabWidget->setCurrentPage(1); +// mediaPlayerState->setPlaying(FALSE); + } + break; + case 2: + { + addToSelection( videoView->selectedItem() ); + mediaPlayerState->setPlaying(b); + qApp->processEvents(); + d->selectedFiles->removeSelected( ); + tabWidget->setCurrentPage(2); +// mediaPlayerState->setPlaying(FALSE); + } + break; + }; + + + + +} 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->selected()->file()); QFile().remove(playLists->selected()->linkFile()); playLists->reread(); break; case 1: // Cancel break; }; } void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { switch (mouse) { case 1: break; case 2:{ QPopupMenu m; m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index effc600..10a42df 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h @@ -28,48 +28,49 @@ /* #include <qtimer.h> */ class PlayListWidgetPrivate; class Config; class QListViewItem; class QListView; class QPoint; class QAction; class QLabel; class PlayListWidget : public QMainWindow { Q_OBJECT public: PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); ~PlayListWidget(); QTabWidget * tabWidget; QAction *fullScreenButton, *scaleButton; DocLnkSet files; DocLnkSet vFiles; QListView *audioView, *videoView, *playlistView; QLabel *libString; bool fromSetDocument; + bool insanityBool; QString setDocFileRef; // retrieve the current playlist entry (media file link) const DocLnk *current(); void useSelectedDocument(); /* QTimer * menuTimer; */ FileSelector* playLists; QPushButton *tbDeletePlaylist; public slots: void setDocument( const QString& fileref ); void addToSelection( const DocLnk& ); // Add a media file to the playlist void addToSelection( QListViewItem* ); // Add a media file to the playlist void setActiveWindow(); // need to handle this to show the right view void setPlaylist( bool ); // Show/Hide the playlist void setView( char ); void clearList(); void addAllToList(); void addAllMusicToList(); void addAllVideoToList(); void saveList(); // Save the playlist void loadList( const DocLnk &); // Load a playlist void playIt( QListViewItem *); void btnPlay(bool); void deletePlaylist(); diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index bb5f9e8..23b36e5 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp @@ -182,59 +182,60 @@ void VideoWidget::paintButton( QPainter *p, int i ) { } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numButtons; i++ ) { int x = videoButtons[i].xPos; int y = videoButtons[i].yPos; if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the circular button or not // (compared with the radius squared to avoid a square-root of our distance) int radius = 16; QPoint center = QPoint( x + radius, y + radius ); QPoint dXY = center - event->pos(); int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); bool isOnButton = dist <= (radius * radius); if ( isOnButton != videoButtons[i].isHeld ) { videoButtons[i].isHeld = isOnButton; toggleButton(i); } } else { if ( videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; if ( !videoButtons[i].isToggle ) setToggleButton( i, FALSE ); + } + } switch (i) { case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; case VideoStop: mediaPlayerState->setPlaying(FALSE); return; case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; case VideoNext: mediaPlayerState->setNext(); return; case VideoPrevious: mediaPlayerState->setPrev(); return; case VideoPlayList: mediaPlayerState->setList(); return; case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; } - } - } + } } void VideoWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { if ( mediaPlayerState->fullscreen() ) { mediaPlayerState->setFullscreen( FALSE ); makeVisible(); mouseMoveEvent( event ); } } void VideoWidget::makeVisible() { if ( mediaPlayerState->fullscreen() ) { setBackgroundMode( QWidget::NoBackground ); showFullScreen(); resize( qApp->desktop()->size() ); |