summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 15:23:45 (UTC)
committer simon <simon>2002-12-09 15:23:45 (UTC)
commitab22599627d84a6c6427d2440da4271b48f47c8e (patch) (side-by-side diff)
tree7afdd78444dc58245a5dd3a110f454354ddd3e2f
parent47d689545e68f2439cc88630ac78016712f92cc9 (diff)
downloadopie-ab22599627d84a6c6427d2440da4271b48f47c8e.zip
opie-ab22599627d84a6c6427d2440da4271b48f47c8e.tar.gz
opie-ab22599627d84a6c6427d2440da4271b48f47c8e.tar.bz2
- minor cleanup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp11
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
2 files changed, 8 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 3a44185..b73a5c0 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -51,70 +51,73 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
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() );
for ( unsigned int i = 0; i < buttons.count(); i++ ) {
paintButton( p, buttons[ i ] );
}
QPainter p2( this );
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
for ( unsigned int i = 0; i < buttons.count(); i++ )
paintButton( p, buttons[ i ] );
}
}
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;
}
}
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::paintButton( int buttonId )
+void MediaWidget::paintButton( const Button &button )
{
QPainter p( this );
- paintButton( p, buttons[ buttonId ] );
+ paintButton( p, button );
}
void MediaWidget::paintButton( QPainter &p, const Button &button )
{
if ( button.isDown )
p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
else
p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
}
void MediaWidget::toggleButton( int buttonId )
{
- buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown;
- paintButton( buttonId );
+ Button &button = buttons[ buttonId ];
+
+ button.isDown = !button.isDown;
+
+ paintButton( button );
}
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 8cdaad1..dcf7fb8 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -42,68 +42,68 @@ public:
{
Button() : type( NormalButton ), isHeld( false ), isDown( false ) {}
ButtonType type : 1;
bool isHeld : 1;
bool isDown : 1;
QBitmap mask;
QPixmap pixUp;
QPixmap pixDown;
};
typedef std::vector<Button> ButtonVector;
// when the transition is done this should be Command -> Button
typedef QMap<int, Button> ButtonMap;
struct SkinButtonInfo
{
Command command;
const char *fileName;
ButtonType type;
};
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 );
void handleCommand( Command command, bool buttonDown );
bool isOverButton( const QPoint &position, int buttonId ) const;
- void paintButton( int buttonId );
+ void paintButton( const Button &button );
void paintButton( QPainter &p, const Button &button );
void toggleButton( int buttonId );
MediaPlayerState &mediaPlayerState;
PlayListWidget &playList;
ButtonMap buttons;
QImage buttonMask;
QPoint upperLeftOfButtonMask;
QPixmap backgroundPixmap;
};
#endif // MEDIAWIDGET_H
/* vim: et sw=4 ts=4
*/