-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/inputDialog.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 195 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 75 |
4 files changed, 227 insertions, 67 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 1b0de5d..125fd72 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -46,54 +46,49 @@ void Ticker::timerEvent( QTimerEvent * ) { void Ticker::drawContents( QPainter *p ) { QPixmap pm( width(), height() ); pm.fill( colorGroup().base() ); QPainter pmp( &pm ); for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); } p->drawPixmap( 0, 0, pm ); } - - struct MediaButton { int xPos, yPos; int color; bool isToggle, isBig, isHeld, isDown; }; - - // Layout information for the audioButtons (and if it is a toggle button or not) MediaButton audioButtons[] = { { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist }; static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : - QWidget( parent, name, f ) -{ + QWidget( parent, name, f ) { setCaption( tr("OpiePlayer - Audio") ); Config cfg("OpiePlayer"); cfg.setGroup("AudioWidget"); QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); @@ -118,28 +113,26 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 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() { mediaPlayerState->isStreaming = FALSE; for ( int i = 0; i < 3; i++ ) { delete pixmaps[i]; } } static bool audioSliderBeingMoved = FALSE; void AudioWidget::sliderPressed() { @@ -147,25 +140,24 @@ void AudioWidget::sliderPressed() { } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider->width() == 0 ) { return; } long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); mediaPlayerState->setPosition( val ); } - void AudioWidget::setPosition( long i ) { // qDebug("set position %d",i); updateSlider( i, mediaPlayerState->length() ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } void AudioWidget::setView( char view ) { diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp index 687aff6..c13ea63 100644 --- a/noncore/multimedia/opieplayer2/inputDialog.cpp +++ b/noncore/multimedia/opieplayer2/inputDialog.cpp @@ -2,47 +2,45 @@ #include <qpe/resource.h> #include <opie/ofiledialog.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" ); + : QDialog( parent, name, modal, fl ) { + if ( !name ) { + setName( "InputDialog" ); + } resize( 234, 115); setMaximumSize( QSize( 240, 40)); - setCaption( tr(name ) ); + 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 ) ); } /* * Destroys the object and frees any allocated resources */ -InputDialog::~InputDialog() -{ +InputDialog::~InputDialog() { inputText= LineEdit1->text(); - } void InputDialog::browse() { MimeTypes types; QStringList audio, video, all; audio << "audio/*"; audio << "playlist/plain"; audio << "audio/x-mpegurl"; video << "video/*"; video << "playlist/plain"; diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index d1d30e4..2f24b00 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp @@ -8,25 +8,25 @@ #include <qobject.h> #include <qdir.h> #include <qpe/mediaplayerplugininterface.h> #include "mediaplayerstate.h" //#define MediaPlayerDebug(x) qDebug x #define MediaPlayerDebug(x) MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) - : QObject( parent, name ), decoder( NULL ) { + : QObject( parent, name ) { Config cfg( "OpiePlayer" ); readConfig( cfg ); } MediaPlayerState::~MediaPlayerState() { Config cfg( "OpiePlayer" ); writeConfig( cfg ); } void MediaPlayerState::readConfig( Config& cfg ) { @@ -46,25 +46,200 @@ void MediaPlayerState::readConfig( Config& cfg ) { void MediaPlayerState::writeConfig( Config& cfg ) const { cfg.setGroup("Options"); cfg.writeEntry("FullScreen", isFullscreen ); cfg.writeEntry("Scaling", isScaled ); cfg.writeEntry("Looping", isLooping ); cfg.writeEntry("Shuffle", isShuffled ); cfg.writeEntry("UsePlayList", usePlaylist ); } -struct MediaPlayerPlugin { -#ifndef QT_NO_COMPONENT - QLibrary *library; -#endif - MediaPlayerPluginInterface *iface; - MediaPlayerDecoder *decoder; - MediaPlayerEncoder *encoder; -}; -static QValueList<MediaPlayerPlugin> pluginList; +// public stuff +bool MediaPlayerState::fullscreen() { + return isFullscreen; +} + +bool MediaPlayerState::scaled() { + return isScaled; +} + +bool MediaPlayerState::looping() { + return isLooping; +} + +bool MediaPlayerState::shuffled() { + return isShuffled; +} + + +bool MediaPlayerState:: playlist() { + return usePlaylist; +} + +bool MediaPlayerState::paused() { + return isPaused; +} + +bool MediaPlayerState::playing() { + return isPlaying; +} + +long MediaPlayerState::position() { + return curPosition; +} + +long MediaPlayerState::length() { + return curLength; +} + +char MediaPlayerState::view() { + return curView; +} + +// slots +void MediaPlayerState::setFullscreen( bool b ) { + if ( isFullscreen == b ) { + return; + } + isFullscreen = b; + emit fullscreenToggled(b); +} + + +void MediaPlayerState::setScaled( bool b ) { + if ( isScaled == b ) { + return; + } + isScaled = b; + emit scaledToggled(b); +} + +void MediaPlayerState::setLooping( bool b ) { + if ( isLooping == b ) { + return; + } + isLooping = b; + emit loopingToggled(b); +} + +void MediaPlayerState::setShuffled( bool b ) { + if ( isShuffled == b ) { + return; + } + isShuffled = b; + emit shuffledToggled(b); +} + +void MediaPlayerState::setPlaylist( bool b ) { + if ( usePlaylist == b ) { + return; + } + usePlaylist = b; + emit playlistToggled(b); +} + +void MediaPlayerState::setPaused( bool b ) { + if ( isPaused == b ) { + return; + } + isPaused = b; + emit pausedToggled(b); +} + +void MediaPlayerState::setPlaying( bool b ) { + if ( isPlaying == b ) { + return; + } + isPlaying = b; + emit playingToggled(b); +} + +void MediaPlayerState::setPosition( long p ) { + if ( curPosition == p ) { + return; + } + curPosition = p; + emit positionChanged(p); +} + +void MediaPlayerState::updatePosition( long p ){ + if ( curPosition == p ) { + return; + } + curPosition = p; + emit positionUpdated(p); +} + +void MediaPlayerState::setLength( long l ) { + if ( curLength == l ) { + return; + } + curLength = l; + emit lengthChanged(l); +} + +void MediaPlayerState::setView( char v ) { + if ( curView == v ) { + return; + } + curView = v; + emit viewChanged(v); +} + +void MediaPlayerState::setPrev(){ + emit prev(); +} + +void MediaPlayerState::setNext() { + emit next(); +} + +void MediaPlayerState::setList() { + setPlaying( FALSE ); + setView('l'); +} + +void MediaPlayerState::setVideo() { + setView('v'); +} + +void MediaPlayerState::setAudio() { + setView('a'); +} + + + +void MediaPlayerState::toggleFullscreen() { + setFullscreen( !isFullscreen ); +} + +void MediaPlayerState::toggleScaled() { + setScaled( !isScaled); +} + +void MediaPlayerState::toggleLooping() { + setLooping( !isLooping); +} + +void MediaPlayerState::toggleShuffled() { + setShuffled( !isShuffled); +} + +void MediaPlayerState::togglePlaylist() { + setPlaylist( !usePlaylist); +} + +void MediaPlayerState::togglePaused() { + setPaused( !isPaused); +} + +void MediaPlayerState::togglePlaying() { + setPlaying( !isPlaying); +} + + diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index 8a64939..7aa0ff2 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h @@ -8,64 +8,61 @@ class MediaPlayerDecoder; class Config; class MediaPlayerState : public QObject { Q_OBJECT public: MediaPlayerState( QObject *parent, const char *name ); ~MediaPlayerState(); bool isStreaming; - bool fullscreen() { return isFullscreen; } - bool scaled() { return isScaled; } - bool looping() { return isLooping; } - bool shuffled() { return isShuffled; } - bool playlist() { return usePlaylist; } - bool paused() { return isPaused; } - bool playing() { return isPlaying; } - long position() { return curPosition; } - long length() { return curLength; } - char view() { return curView; } - - MediaPlayerDecoder *newDecoder( const QString& file ); - MediaPlayerDecoder *curDecoder(); + bool fullscreen(); + bool scaled(); + bool looping(); + bool shuffled(); + bool playlist(); + bool paused(); + bool playing(); + long position(); + long length(); + char view(); public slots: - void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } - void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } - void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } - void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } - void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } - void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } - void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } - void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } - void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } - void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } - void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } - - void setPrev() { emit prev(); } - void setNext() { emit next(); } - void setList() { setPlaying( FALSE ); setView('l'); } - void setVideo() { setView('v'); } - void setAudio() { setView('a'); } - - void toggleFullscreen() { setFullscreen( !isFullscreen ); } - void toggleScaled() { setScaled( !isScaled); } - void toggleLooping() { setLooping( !isLooping); } - void toggleShuffled() { setShuffled( !isShuffled); } - void togglePlaylist() { setPlaylist( !usePlaylist); } - void togglePaused() { setPaused( !isPaused); } - void togglePlaying() { setPlaying( !isPlaying); } + void setFullscreen( bool b ); + void setScaled( bool b ); + void setLooping( bool b ); + void setShuffled( bool b ); + void setPlaylist( bool b ); + void setPaused( bool b ); + void setPlaying( bool b ); + void setPosition( long p ); + void updatePosition( long p ); + void setLength( long l ); + void setView( char v ); + + void setPrev() ; + void setNext(); + void setList(); + void setVideo(); + void setAudio(); + + void toggleFullscreen(); + void toggleScaled(); + void toggleLooping(); + void toggleShuffled(); + void togglePlaylist(); + void togglePaused(); + void togglePlaying(); signals: void fullscreenToggled( bool ); void scaledToggled( bool ); void loopingToggled( bool ); void shuffledToggled( bool ); void playlistToggled( bool ); void pausedToggled( bool ); void playingToggled( bool ); void positionChanged( long ); // When the slider is moved void positionUpdated( long ); // When the media file progresses void lengthChanged( long ); @@ -77,21 +74,19 @@ signals: private: bool isFullscreen; bool isScaled; bool isLooping; bool isShuffled; bool usePlaylist; bool isPaused; bool isPlaying; long curPosition; long curLength; char curView; - MediaPlayerDecoder *decoder; - void readConfig( Config& cfg ); void writeConfig( Config& cfg ) const; }; #endif // MEDIA_PLAYER_STATE_H |