summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-08 22:58:45 (UTC)
committer simon <simon>2002-12-08 22:58:45 (UTC)
commit7b38c0424eca2f49a0c9a931766c816e21f1d86b (patch) (side-by-side diff)
treee310c27ad3592e46fc1a46d963ae24b2f299c949
parentdf6b6a0222e99736284ed8ebb9a7d8068751339b (diff)
downloadopie-7b38c0424eca2f49a0c9a931766c816e21f1d86b.zip
opie-7b38c0424eca2f49a0c9a931766c816e21f1d86b.tar.gz
opie-7b38c0424eca2f49a0c9a931766c816e21f1d86b.tar.bz2
- merged the two duplicated toggleButton methods into a shared one
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
6 files changed, 9 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 10b1e58..2a158a8 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -311,56 +311,48 @@ void AudioWidget::updateSlider( long i, long max ) {
}
// Will flicker too much if we don't do this
// Scale to something reasonable
int width = slider.width();
int val = int((double)i * width / max);
if ( !audioSliderBeingMoved ) {
if ( slider.value() != val ) {
slider.setValue( val );
}
if ( slider.maxValue() != width ) {
slider.setMaxValue( width );
}
}
}
void AudioWidget::setToggleButton( int i, bool down ) {
qDebug("setToggleButton %d", i);
if ( down != buttons[i].isDown ) {
toggleButton( i );
}
}
-
-void AudioWidget::toggleButton( int i ) {
- buttons[i].isDown = !buttons[i].isDown;
- QPainter p(this);
- paintButton ( p, i );
-}
-
-
void AudioWidget::paintButton( QPainter &p, int i ) {
if ( buttons[i].isDown ) {
p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
} else {
p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
}
}
void AudioWidget::skipFor() {
skipDirection = +1;
startTimer( 50 );
mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
}
void AudioWidget::skipBack() {
skipDirection = -1;
startTimer( 50 );
mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
void AudioWidget::stopSkip() {
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index a1a839c..4598d51 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -70,46 +70,45 @@ public:
signals:
void moreClicked();
void lessClicked();
void forwardClicked();
void backClicked();
void sliderMoved(long);
protected:
void doBlank();
void doUnblank();
void paintEvent( QPaintEvent *pe );
void showEvent( QShowEvent *se );
void resizeEvent( QResizeEvent *re );
void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void timerEvent( QTimerEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private slots:
void skipFor();
void skipBack();
void stopSkip();
private:
- void toggleButton( int );
void setToggleButton( int, bool );
virtual void paintButton( QPainter &p, int i );
int skipDirection;
QString skin;
QPixmap pixBg;
QImage imgUp;
QImage imgDn;
QBitmap *masks[10];
QPixmap *buttonPixUp[10];
QPixmap *buttonPixDown[10];
QPixmap *pixmaps[4];
OTicker songInfo;
QSlider slider;
QLineEdit time;
bool isStreaming : 1;
};
#endif // AUDIO_WIDGET_H
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index ca84019..62266ad 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -47,32 +47,38 @@ void MediaWidget::closeEvent( QCloseEvent * )
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::repaintButton( int buttonId )
+void MediaWidget::paintButton( int buttonId )
{
QPainter p( this );
paintButton( p, buttonId );
}
+void MediaWidget::toggleButton( int buttonId )
+{
+ buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown;
+ paintButton( buttonId );
+}
+
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 066d2ac..46c304d 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -49,37 +49,39 @@ public:
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 * );
void handleCommand( Command command, bool buttonDown );
bool isOverButton( const QPoint &position, int buttonId ) const;
void paintButton( int buttonId );
virtual void paintButton( QPainter &p, int i ) = 0;
+ void toggleButton( int buttonId );
+
MediaPlayerState &mediaPlayerState;
PlayListWidget &playList;
ButtonVector buttons;
QImage buttonMask;
QPoint upperLeftOfButtonMask;
};
#endif // MEDIAWIDGET_H
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 3e677c6..77eab71 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -242,54 +242,48 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
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 ( slider->value() != val ) {
slider->setValue( val );
}
if ( slider->maxValue() != width ) {
slider->setMaxValue( width );
}
}
}
void VideoWidget::setToggleButton( int i, bool down ) {
if ( down != buttons[i].isDown ) {
toggleButton( i );
}
}
-void VideoWidget::toggleButton( int i ) {
- buttons[i].isDown = !buttons[i].isDown;
- QPainter p(this);
- paintButton ( p, i );
-}
-
void VideoWidget::paintButton( QPainter &p, int i ) {
if ( buttons[i].isDown ) {
p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
} else {
p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
}
}
void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
for ( unsigned int i = 0; i < buttons.size(); i++ ) {
if ( event->state() == QMouseEvent::LeftButton ) {
// The test to see if the mouse click is inside the button or not
bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
if ( isOnButton && !buttons[i].isHeld ) {
buttons[i].isHeld = TRUE;
toggleButton(i);
switch (i) {
case VideoVolUp:
emit moreClicked();
return;
case VideoVolDown:
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 28f720b..24e8741 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -87,40 +87,39 @@ signals:
protected:
void resizeEvent( QResizeEvent * );
void paintEvent( QPaintEvent *pe );
void showEvent( QShowEvent *se );
void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private:
// Ticker songInfo;
QPixmap pixBg;
QImage imgUp;
QImage imgDn;
QBitmap *masks[7];
QPixmap *buttonPixUp[7];
QPixmap *buttonPixDown[7];
QString skin;
// QPixmap *pixmaps[4];
virtual void paintButton( QPainter &p, int i );
- void toggleButton( int );
void setToggleButton( int, bool );
QString backgroundPix;
QSlider *slider;
QPixmap *pixmaps[3];
QImage *currentFrame;
int scaledWidth;
int scaledHeight;
XineVideoWidget* videoFrame;
};
#endif // VIDEO_WIDGET_H