summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 20:32:42 (UTC)
committer simon <simon>2002-12-02 20:32:42 (UTC)
commit6cd1494f86f2f60614c9b9a7b959666dec2500ee (patch) (side-by-side diff)
tree5f5cdbae8be03210fae087eecec2f6b2d070569c
parentabeed050bedee6e2697ea417ed74ab621361da48 (diff)
downloadopie-6cd1494f86f2f60614c9b9a7b959666dec2500ee.zip
opie-6cd1494f86f2f60614c9b9a7b959666dec2500ee.tar.gz
opie-6cd1494f86f2f60614c9b9a7b959666dec2500ee.tar.bz2
- the audiowidget and the videowidget don't rely on the mediaplayerstate
singleton anymore
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp75
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp75
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
7 files changed, 87 insertions, 86 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index f4edb79..d9beb90 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -41,25 +41,24 @@
#include <qbutton.h>
#include <qpainter.h>
#include <qframe.h>
#include <qlayout.h>
#include <qdir.h>
#include <stdlib.h>
#include <stdio.h>
#include "audiowidget.h"
#include "mediaplayerstate.h"
#include "playlistwidget.h"
-extern MediaPlayerState *mediaPlayerState;
extern PlayListWidget *playList;
static const int xo = -2; // movable x offset
static const int yo = 22; // movable y offset
struct MediaButton {
bool isToggle, isHeld, isDown;
};
//Layout information for the audioButtons (and if it is a toggle button or not)
MediaButton audioButtons[] = {
{ TRUE, FALSE, FALSE }, // play
@@ -81,27 +80,27 @@ const char * const skin_mask_file_names[10] = {
static void changeTextColor( QWidget *w ) {
QPalette p = w->palette();
p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
w->setPalette( p );
}
static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
-AudioWidget::AudioWidget(QWidget* parent, const char* name) :
+AudioWidget::AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
- MediaWidget( parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
+ MediaWidget( mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
setCaption( tr("OpiePlayer") );
Config cfg("OpiePlayer");
cfg.setGroup("Options");
skin = cfg.readEntry("Skin","default");
//skin = "scaleTest";
// color of background, frame, degree of transparency
QString skinPath = "opieplayer2/skins/" + skin;
pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
@@ -150,38 +149,38 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name) :
// Config cofg("qpe");
// cofg.setGroup("Appearance");
// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
time.setFocusPolicy( QWidget::NoFocus );
time.setAlignment( Qt::AlignCenter );
// time.setFrame(FALSE);
// changeTextColor( &time );
resizeEvent( NULL );
- connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
- connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
+ connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
+ connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
// Intialise state
- setLength( mediaPlayerState->length() );
- setPosition( mediaPlayerState->position() );
- setLooping( mediaPlayerState->isFullscreen() );
+ setLength( mediaPlayerState.length() );
+ setPosition( mediaPlayerState.position() );
+ setLooping( mediaPlayerState.isFullscreen() );
// setPaused( mediaPlayerState->paused() );
- setPlaying( mediaPlayerState->isPlaying() );
+ setPlaying( mediaPlayerState.isPlaying() );
}
AudioWidget::~AudioWidget() {
for ( int i = 0; i < 10; i++ ) {
delete buttonPixUp[i];
delete buttonPixDown[i];
}
for ( int i = 0; i < 10; i++ ) {
delete masks[i];
}
@@ -237,69 +236,69 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
static bool audioSliderBeingMoved = FALSE;
void AudioWidget::sliderPressed() {
audioSliderBeingMoved = TRUE;
}
void AudioWidget::sliderReleased() {
audioSliderBeingMoved = FALSE;
if ( slider.width() == 0 )
return;
- long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
- mediaPlayerState->setPosition( val );
+ 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() );
+ updateSlider( i, mediaPlayerState.length() );
}
void AudioWidget::setLength( long max ) {
- updateSlider( mediaPlayerState->position(), max );
+ updateSlider( mediaPlayerState.position(), max );
}
void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
if ( mediaType == MediaPlayerState::Audio ) {
// startTimer( 150 );
showMaximized();
return;
}
killTimers();
hide();
}
void AudioWidget::setSeekable( bool isSeekable ) {
if ( !isSeekable ) {
qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
if( !slider.isHidden()) {
slider.hide();
}
- disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
- disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
+ disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
+ disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
} else {
// this stops the slider from being moved, thus
// does not stop stream when it reaches the end
slider.show();
qDebug( " CONNECT SET POSTION " );
- connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
- connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
+ connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
+ connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
}
}
static QString timeAsString( long length ) {
int minutes = length / 60;
int seconds = length % 60;
return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
}
@@ -345,45 +344,45 @@ void AudioWidget::toggleButton( int i ) {
void AudioWidget::paintButton( QPainter *p, int i ) {
if ( audioButtons[i].isDown ) {
p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
} else {
p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
}
}
void AudioWidget::skipFor() {
skipDirection = +1;
startTimer( 50 );
- mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
+ mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
}
void AudioWidget::skipBack() {
skipDirection = -1;
startTimer( 50 );
- mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
+ mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
void AudioWidget::stopSkip() {
killTimers();
}
void AudioWidget::timerEvent( QTimerEvent * ) {
if ( skipDirection == +1 ) {
- mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
+ mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
} else if ( skipDirection == -1 ) {
- mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
+ mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
}
void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
for ( int i = 0; i < numButtons; i++ ) {
if ( event->state() == QMouseEvent::LeftButton ) {
// The test to see if the mouse click is inside the button or not
int x = event->pos().x() - xoff;
int y = event->pos().y() - yoff;
bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width()
@@ -411,38 +410,38 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
audioButtons[i].isHeld = FALSE;
toggleButton(i);
}
} else {
if ( audioButtons[i].isHeld ) {
audioButtons[i].isHeld = FALSE;
if ( !audioButtons[i].isToggle ) {
setToggleButton( i, FALSE );
}
qDebug("mouseEvent %d", i);
switch (i) {
case AudioPlay:
- if( mediaPlayerState->isPaused() ) {
- mediaPlayerState->setPaused( FALSE );
+ if( mediaPlayerState.isPaused() ) {
+ mediaPlayerState.setPaused( FALSE );
return;
- } else if( !mediaPlayerState->isPaused() ) {
- mediaPlayerState->setPaused( TRUE );
+ } else if( !mediaPlayerState.isPaused() ) {
+ mediaPlayerState.setPaused( TRUE );
return;
}
- case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
- case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return;
- case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return;
- case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
+ case AudioStop: mediaPlayerState.setPlaying(FALSE); return;
+ case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
+ case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) 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;
+ case AudioPlayList: mediaPlayerState.setList(); return;
case AudioForward: emit forwardReleased(); return;
case AudioBack: emit backReleased(); return;
}
}
}
}
}
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
@@ -451,25 +450,25 @@ void AudioWidget::mousePressEvent( QMouseEvent *event ) {
void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
void AudioWidget::closeEvent( QCloseEvent* ) {
- mediaPlayerState->setList();
+ mediaPlayerState.setList();
}
void AudioWidget::paintEvent( QPaintEvent * pe ) {
if ( !pe->erased() ) {
// Combine with background and double buffer
QPixmap pix( pe->rect().size() );
QPainter p( &pix );
p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
for ( int i = 0; i < numButtons; i++ )
paintButton( &p, i );
@@ -485,59 +484,59 @@ void AudioWidget::paintEvent( QPaintEvent * pe ) {
void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
hide();
// qDebug("Audio F9");
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
- mediaPlayerState->toggleBlank();
+ mediaPlayerState.toggleBlank();
break;
case Key_F12: //home
break;
case Key_F13: //mail
- mediaPlayerState->toggleBlank();
+ mediaPlayerState.toggleBlank();
break;
case Key_Space: {
- if(mediaPlayerState->isPlaying()) {
+ if(mediaPlayerState.isPlaying()) {
// toggleButton(1);
- mediaPlayerState->setPlaying(FALSE);
+ mediaPlayerState.setPlaying(FALSE);
// toggleButton(1);
} else {
// toggleButton(0);
- mediaPlayerState->setPlaying(TRUE);
+ mediaPlayerState.setPlaying(TRUE);
// toggleButton(0);
}
}
break;
case Key_Down:
// toggleButton(6);
emit lessClicked();
emit lessReleased();
// toggleButton(6);
break;
case Key_Up:
// toggleButton(5);
emit moreClicked();
emit moreReleased();
// toggleButton(5);
break;
case Key_Right:
// toggleButton(3);
- mediaPlayerState->setNext();
+ mediaPlayerState.setNext();
// toggleButton(3);
break;
case Key_Left:
// toggleButton(4);
- mediaPlayerState->setPrev();
+ mediaPlayerState.setPrev();
// toggleButton(4);
break;
case Key_Escape: {
}
break;
};
}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 83927f1..087d711 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -59,25 +59,25 @@ enum AudioButtons {
AudioVolumeUp,
AudioVolumeDown,
AudioLoop,
AudioPlayList,
AudioForward,
AudioBack
};
};
class AudioWidget : public MediaWidget {
Q_OBJECT
public:
- AudioWidget( QWidget* parent=0, const char* name=0 );
+ AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
~AudioWidget();
void setTickerText( const QString &text ) { songInfo.setText( text ); }
public slots:
void updateSlider( long, long );
void sliderPressed( );
void sliderReleased( );
void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
void setPosition( long );
void setSeekable( bool );
public:
virtual void setLength( long );
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index 02fdbf3..fd47ea5 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -10,25 +10,25 @@ MediaPlayerState *mediaPlayerState;
PlayListWidget *playList;
AudioWidget *audioUI;
VideoWidget *videoUI;
int main(int argc, char **argv) {
QPEApplication a(argc,argv);
MediaPlayerState st( 0, "mediaPlayerState" );
mediaPlayerState = &st;
PlayListWidget pl( st, 0, "playList" );
playList = &pl;
pl.showMaximized();
- AudioWidget aw( 0, "audioUI" );
+ AudioWidget aw( st, 0, "audioUI" );
audioUI = &aw;
- VideoWidget vw( 0, "videoUI" );
+ VideoWidget vw( st, 0, "videoUI" );
videoUI = &vw;
a.processEvents();
MediaPlayer mp( st, 0, "mediaPlayer" );
a.showMainDocumentWidget(&pl);
return a.exec();
}
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 83456a0..d58e87e 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -13,29 +13,29 @@
You should have received a copy of the GNU Library 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 "mediawidget.h"
extern MediaPlayerState *mediaPlayerState;
-MediaWidget::MediaWidget( QWidget *parent, const char *name )
- : QWidget( parent, name )
+MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
+ : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState )
{
- connect( mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
+ connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
- connect( mediaPlayerState, SIGNAL( lengthChanged( long ) ),
+ connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
this, SLOT( setLength( long ) ) );
- connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ),
+ connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
this, SLOT( setPlaying( bool ) ) );
}
MediaWidget::~MediaWidget()
{
}
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index fc5198e..64adba9 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -19,24 +19,27 @@
#ifndef MEDIAWIDGET_H
#define MEDIAWIDGET_H
#include <qwidget.h>
#include "mediaplayerstate.h"
class MediaWidget : public QWidget
{
Q_OBJECT
public:
- MediaWidget( QWidget *parent = 0, const char *name = 0 );
+ MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
virtual ~MediaWidget();
public slots:
virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
virtual void setLength( long length ) = 0;
virtual void setPlaying( bool playing ) = 0;
+
+protected:
+ MediaPlayerState &mediaPlayerState;
};
#endif // MEDIAWIDGET_H
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index e0ca243..b4ecb4c 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -44,25 +44,24 @@
#include "videowidget.h"
#include "mediaplayerstate.h"
#include "playlistwidget.h"
#ifdef Q_WS_QWS
# define USE_DIRECT_PAINTER
# include <qdirectpainter_qws.h>
# include <qgfxraster_qws.h>
#endif
-extern MediaPlayerState *mediaPlayerState;
extern PlayListWidget *playList;
static const int xo = 2; // movable x offset
static const int yo = 0; // movable y offset
struct MediaButton {
bool isToggle, isHeld, isDown;
};
MediaButton videoButtons[] = {
@@ -73,26 +72,26 @@ MediaButton videoButtons[] = {
{ FALSE, FALSE, FALSE }, // volUp
{ FALSE, FALSE, FALSE }, // volDown
{ TRUE, FALSE, FALSE } // fullscreen
};
const char *skinV_mask_file_names[7] = {
"stop","play","back","fwd","up","down","full"
};
static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
-VideoWidget::VideoWidget(QWidget* parent, const char* name) :
-MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) {
+VideoWidget::VideoWidget(MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
+MediaWidget( mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) {
setCaption( tr("OpiePlayer - Video") );
videoFrame = new XineVideoWidget ( this, "Video frame" );
connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
Config cfg("OpiePlayer");
cfg.setGroup("Options");
skin = cfg.readEntry("Skin","default");
@@ -128,28 +127,28 @@ MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) {
}
setBackgroundPixmap( *pixBg );
slider = new QSlider( Qt::Horizontal, this );
slider->setMinValue( 0 );
slider->setMaxValue( 1 );
slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
//slider->setFocusPolicy( QWidget::NoFocus );
resizeEvent( NULL );
- setLength( mediaPlayerState->length() );
- setPosition( mediaPlayerState->position() );
- setFullscreen( mediaPlayerState->isFullscreen() );
- setPlaying( mediaPlayerState->isPlaying() );
+ setLength( mediaPlayerState.length() );
+ setPosition( mediaPlayerState.position() );
+ setFullscreen( mediaPlayerState.isFullscreen() );
+ setPlaying( mediaPlayerState.isPlaying() );
}
VideoWidget::~VideoWidget() {
for ( int i = 0; i < 7; i++ ) {
delete buttonPixUp[i];
delete buttonPixDown[i];
}
delete pixBg;
delete imgUp;
@@ -212,58 +211,58 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
static bool videoSliderBeingMoved = FALSE;
void VideoWidget::sliderPressed() {
videoSliderBeingMoved = TRUE;
}
void VideoWidget::sliderReleased() {
videoSliderBeingMoved = FALSE;
if ( slider->width() == 0 ) {
return;
}
- long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
- mediaPlayerState->setPosition( val );
+ long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
+ mediaPlayerState.setPosition( val );
}
void VideoWidget::setPosition( long i ) {
- updateSlider( i, mediaPlayerState->length() );
+ updateSlider( i, mediaPlayerState.length() );
}
void VideoWidget::setLength( long max ) {
- updateSlider( mediaPlayerState->position(), max );
+ updateSlider( mediaPlayerState.position(), max );
}
void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
{
if ( displayType == MediaPlayerState::Video ) {
makeVisible();
return;
}
// Effectively blank the view next time we show it so it looks nicer
scaledWidth = 0;
scaledHeight = 0;
hide();
}
void VideoWidget::updateSlider( long i, long max ) {
// Will flicker too much if we don't do this
if ( max == 0 ) {
return;
}
int width = slider->width();
int val = int((double)i * width / max);
- if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) {
+ if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
if ( slider->value() != val ) {
slider->setValue( val );
}
if ( slider->maxValue() != width ) {
slider->setMaxValue( width );
}
}
}
void VideoWidget::setToggleButton( int i, bool down ) {
if ( down != videoButtons[i].isDown ) {
toggleButton( i );
@@ -314,125 +313,125 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
}
} else {
if ( videoButtons[i].isHeld ) {
videoButtons[i].isHeld = FALSE;
if ( !videoButtons[i].isToggle ) {
setToggleButton( i, FALSE );
}
switch(i) {
case VideoPlay: {
- if( mediaPlayerState->isPaused() ) {
+ if( mediaPlayerState.isPaused() ) {
setToggleButton( i, FALSE );
- mediaPlayerState->setPaused( FALSE );
+ mediaPlayerState.setPaused( FALSE );
return;
- } else if( !mediaPlayerState->isPaused() ) {
+ } else if( !mediaPlayerState.isPaused() ) {
setToggleButton( i, TRUE );
- mediaPlayerState->setPaused( TRUE );
+ mediaPlayerState.setPaused( TRUE );
return;
} else {
return;
}
}
- case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
- case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return;
- case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return;
+ case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
+ case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
+ case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
case VideoVolUp: emit moreReleased(); return;
case VideoVolDown: emit lessReleased(); return;
- case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
+ case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
}
}
}
}
}
void VideoWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
- if ( mediaPlayerState->isFullscreen() ) {
- mediaPlayerState->setFullscreen( FALSE );
+ if ( mediaPlayerState.isFullscreen() ) {
+ mediaPlayerState.setFullscreen( FALSE );
makeVisible();
}
mouseMoveEvent( event );
}
void VideoWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
void VideoWidget::backToNormal() {
- mediaPlayerState->setFullscreen( FALSE );
+ mediaPlayerState.setFullscreen( FALSE );
makeVisible();
}
void VideoWidget::makeVisible() {
- if ( mediaPlayerState->isFullscreen() ) {
+ if ( mediaPlayerState.isFullscreen() ) {
setBackgroundMode( QWidget::NoBackground );
showFullScreen();
resize( qApp->desktop()->size() );
videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
slider->hide();
- disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
- disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
+ disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
+ disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
} else {
showNormal();
showMaximized();
setBackgroundPixmap( *pixBg );
QWidget *d = QApplication::desktop();
int w = d->width();
int h = d->height();
if(w>h) {
int newW=(w/2)-(246/2); //this will only work with 320x240
videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
} else {
videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
}
- if ( !mediaPlayerState->isSeekable() ) {
+ if ( !mediaPlayerState.isSeekable() ) {
if( !slider->isHidden()) {
slider->hide();
}
- disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
- disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
+ disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
+ disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
} else {
slider->show();
- connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
- connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
+ connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
+ connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
}
}
}
void VideoWidget::paintEvent( QPaintEvent * pe) {
QPainter p( this );
- if ( mediaPlayerState->isFullscreen() ) {
+ if ( mediaPlayerState.isFullscreen() ) {
// Clear the background
p.setBrush( QBrush( Qt::black ) );
} else {
if ( !pe->erased() ) {
// Combine with background and double buffer
QPixmap pix( pe->rect().size() );
QPainter p( &pix );
p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
for ( int i = 0; i < numVButtons; i++ ) {
paintButton( &p, i );
}
@@ -440,69 +439,69 @@ void VideoWidget::paintEvent( QPaintEvent * pe) {
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
for ( int i = 0; i < numVButtons; i++ )
paintButton( &p, i );
}
//slider->repaint( TRUE );
}
}
void VideoWidget::closeEvent( QCloseEvent* ) {
- mediaPlayerState->setList();
+ mediaPlayerState.setList();
}
void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
break;
case Key_F10: //contacts
// hide();
break;
case Key_F11: //menu
break;
case Key_F12: //home
break;
case Key_F13: //mail
break;
case Key_Space: {
- if(mediaPlayerState->isPlaying()) {
- mediaPlayerState->setPlaying(FALSE);
+ if(mediaPlayerState.isPlaying()) {
+ mediaPlayerState.setPlaying(FALSE);
} else {
- mediaPlayerState->setPlaying(TRUE);
+ mediaPlayerState.setPlaying(TRUE);
}
}
break;
case Key_Down:
// toggleButton(6);
emit lessClicked();
emit lessReleased();
// toggleButton(6);
break;
case Key_Up:
// toggleButton(5);
emit moreClicked();
emit moreReleased();
// toggleButton(5);
break;
case Key_Right:
- mediaPlayerState->setNext();
+ mediaPlayerState.setNext();
break;
case Key_Left:
- mediaPlayerState->setPrev();
+ mediaPlayerState.setPrev();
break;
case Key_Escape:
break;
};
}
XineVideoWidget* VideoWidget::vidWidget() {
return videoFrame;
}
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 816ce2e..38eb726 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -47,25 +47,25 @@ enum VideoButtons {
VideoPlay,
// VideoPause,
VideoPrevious,
VideoNext,
VideoVolUp,
VideoVolDown,
VideoFullscreen
};
class VideoWidget : public MediaWidget {
Q_OBJECT
public:
- VideoWidget( QWidget* parent=0, const char* name=0 );
+ VideoWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
~VideoWidget();
XineVideoWidget* vidWidget();
public slots:
void updateSlider( long, long );
void sliderPressed( );
void sliderReleased( );
void setFullscreen( bool b );
void makeVisible();
void backToNormal();
void setPosition( long );