summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 16:39:32 (UTC)
committer simon <simon>2002-12-09 16:39:32 (UTC)
commit1bb6aa52f2db85f65f75278310c328218caeae65 (patch) (side-by-side diff)
tree1983547bac0da80bde93554038a57713feb715c1
parent1ae041fba55e218a2523de441bec6ec3a1eecf02 (diff)
downloadopie-1bb6aa52f2db85f65f75278310c328218caeae65.zip
opie-1bb6aa52f2db85f65f75278310c328218caeae65.tar.gz
opie-1bb6aa52f2db85f65f75278310c328218caeae65.tar.bz2
- removing duplicated code in VideoWidget
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h4
4 files changed, 9 insertions, 27 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index c0ebd63..7eb75e6 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -48,61 +48,66 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
{
QPainter p( this );
if ( mediaPlayerState.isFullscreen() ) {
// Clear the background
p.setBrush( QBrush( Qt::black ) );
return;
}
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(), backgroundPixmap, pe->rect().topLeft() );
paintAllButtons( p );
QPainter p2( this );
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
paintAllButtons( p );
}
}
+void MediaWidget::makeVisible()
+{
+}
+
void MediaWidget::handleCommand( Command command, bool buttonDown )
{
switch ( command ) {
case Play: mediaPlayerState.togglePaused();
case Stop: mediaPlayerState.setPlaying(FALSE); return;
case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
case Loop: mediaPlayerState.setLooping( buttonDown ); return;
case VolumeUp: emit moreReleased(); return;
case VolumeDown: emit lessReleased(); return;
case PlayList: mediaPlayerState.setList(); return;
case Forward: emit forwardReleased(); return;
case Back: emit backReleased(); return;
+ case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
default: assert( false );
}
}
bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
{
return ( position.x() > 0 && position.y() > 0 &&
position.x() < buttonMask.width() &&
position.y() < buttonMask.height() &&
buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
}
void MediaWidget::paintAllButtons( QPainter &p )
{
for ( ButtonVector::const_iterator it = buttons.begin();
it != buttons.end(); ++it )
paintButton( p, *it );
}
void MediaWidget::paintButton( const Button &button )
{
QPainter p( this );
paintButton( p, button );
}
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index caae0a7..3f4c45d 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -62,48 +62,50 @@ public:
};
typedef std::vector<QBitmap> MaskVector;
typedef std::vector<QPixmap> PixmapVector;
MediaWidget( PlayListWidget &_playList, 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;
signals:
void moreReleased();
void lessReleased();
void forwardReleased();
void backReleased();
protected:
virtual void closeEvent( QCloseEvent * );
virtual void paintEvent( QPaintEvent *pe );
+ virtual void makeVisible();
+
void handleCommand( Command command, bool buttonDown );
bool isOverButton( const QPoint &position, int buttonId ) const;
void paintAllButtons( QPainter &p );
void paintButton( const Button &button );
void paintButton( QPainter &p, const Button &button );
void setToggleButton( Button &button, bool down );
void setToggleButton( Command command, bool down );
void toggleButton( Button &button );
MediaPlayerState &mediaPlayerState;
PlayListWidget &playList;
ButtonVector buttons;
QImage buttonMask;
QPoint upperLeftOfButtonMask;
QPixmap backgroundPixmap;
};
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 12316f8..cc586cc 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -256,72 +256,49 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
button.isHeld = TRUE;
toggleButton( button );
switch ( command ) {
case VolumeUp:
emit moreClicked();
return;
case VolumeDown:
emit lessClicked();
return;
default: break;
}
} else if ( !isOnButton && button.isHeld ) {
button.isHeld = FALSE;
toggleButton( button );
}
} else {
if ( button.isHeld ) {
button.isHeld = FALSE;
if ( button.type != ToggleButton ) {
setToggleButton( button, FALSE );
}
- switch( command ) {
-
- case Play: {
- if( mediaPlayerState.isPaused() ) {
- setToggleButton( button, FALSE );
- mediaPlayerState.setPaused( FALSE );
- return;
- } else if( !mediaPlayerState.isPaused() ) {
- setToggleButton( button, TRUE );
- mediaPlayerState.setPaused( TRUE );
- return;
- } else {
- return;
- }
- }
-
- case Stop: mediaPlayerState.setPlaying( FALSE ); return;
- case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
- case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
- case VolumeUp: emit moreReleased(); return;
- case VolumeDown: emit lessReleased(); return;
- case FullScreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
- default: break;
- }
+ handleCommand( command, button.isDown );
}
}
}
}
void VideoWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
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() {
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index c3bc131..ef88186 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -36,62 +36,60 @@
#include <qwidget.h>
#include <qimage.h>
#include <qpixmap.h>
#include "xinevideowidget.h"
#include "mediawidget.h"
class QPixmap;
class QSlider;
class VideoWidget : public MediaWidget {
Q_OBJECT
public:
VideoWidget( PlayListWidget &playList, 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();
+ virtual void makeVisible();
void backToNormal();
void setPosition( long );
public:
virtual void setPlaying( bool b);
virtual void setLength( long );
virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
signals:
void moreClicked();
void lessClicked();
- void moreReleased();
- void lessReleased();
void sliderMoved( long );
void videoResized ( const QSize &s );
protected:
void resizeEvent( QResizeEvent * );
void showEvent( QShowEvent *se );
void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private:
// Ticker songInfo;
QImage imgUp;
QImage imgDn;
QString skin;
QString backgroundPix;
QSlider *slider;
QImage *currentFrame;
int scaledWidth;