summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/audiowidget.cpp
authorsimon <simon>2002-12-08 22:20:24 (UTC)
committer simon <simon>2002-12-08 22:20:24 (UTC)
commit00252c667bf6c6af3f2a1d2519bf23e448e8f174 (patch) (side-by-side diff)
tree4ecb004aa67d993561178b33cad2a6f0a9e85049 /noncore/multimedia/opieplayer2/audiowidget.cpp
parent695398075ec5e4d01f29c40c00538ee8c60404d2 (diff)
downloadopie-00252c667bf6c6af3f2a1d2519bf23e448e8f174.zip
opie-00252c667bf6c6af3f2a1d2519bf23e448e8f174.tar.gz
opie-00252c667bf6c6af3f2a1d2519bf23e448e8f174.tar.bz2
- share the buttons data in a buttons member variable in the base class
Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 7fb3781..a9d5a88 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -71,35 +71,35 @@ void changeTextColor( QWidget * w) {
}
AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
Button defaultButton;
defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false;
Button toggleButton;
toggleButton.isToggle = true;
toggleButton.isHeld = toggleButton.isDown = false;
- audioButtons.reserve( 10 );
- audioButtons.push_back( toggleButton ); // play
- audioButtons.push_back( defaultButton ); // stop
- audioButtons.push_back( defaultButton ); // next
- audioButtons.push_back( defaultButton ); // previous
- audioButtons.push_back( defaultButton ); // volume up
- audioButtons.push_back( defaultButton ); // volume down
- audioButtons.push_back( toggleButton ); // repeat/loop
- audioButtons.push_back( defaultButton ); // playlist
- audioButtons.push_back( defaultButton ); // forward
- audioButtons.push_back( defaultButton ); // back
+ buttons.reserve( 10 );
+ buttons.push_back( toggleButton ); // play
+ buttons.push_back( defaultButton ); // stop
+ buttons.push_back( defaultButton ); // next
+ buttons.push_back( defaultButton ); // previous
+ buttons.push_back( defaultButton ); // volume up
+ buttons.push_back( defaultButton ); // volume down
+ buttons.push_back( toggleButton ); // repeat/loop
+ buttons.push_back( defaultButton ); // playlist
+ buttons.push_back( defaultButton ); // forward
+ buttons.push_back( defaultButton ); // back
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) ) );
@@ -318,39 +318,39 @@ void AudioWidget::updateSlider( long i, long max ) {
slider.setValue( val );
}
if ( slider.maxValue() != width ) {
slider.setMaxValue( width );
}
}
}
void AudioWidget::setToggleButton( int i, bool down ) {
qDebug("setToggleButton %d", i);
- if ( down != audioButtons[i].isDown ) {
+ if ( down != buttons[i].isDown ) {
toggleButton( i );
}
}
void AudioWidget::toggleButton( int i ) {
- audioButtons[i].isDown = !audioButtons[i].isDown;
+ buttons[i].isDown = !buttons[i].isDown;
QPainter p(this);
paintButton ( &p, i );
}
void AudioWidget::paintButton( QPainter *p, int i ) {
- if ( audioButtons[i].isDown ) {
+ if ( buttons[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 );
}
@@ -369,63 +369,63 @@ void AudioWidget::stopSkip() {
void AudioWidget::timerEvent( QTimerEvent * ) {
if ( skipDirection == +1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
} else if ( skipDirection == -1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
}
void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
- for ( unsigned int i = 0; i < audioButtons.size(); i++ ) {
+ 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
int x = event->pos().x() - xoff;
int y = event->pos().y() - yoff;
bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width()
&& y < imgButtonMask.height()
&& imgButtonMask.pixelIndex( x, y ) == i + 1 );
- if ( isOnButton && !audioButtons[i].isHeld ) {
- audioButtons[i].isHeld = TRUE;
+ if ( isOnButton && !buttons[i].isHeld ) {
+ buttons[i].isHeld = TRUE;
toggleButton(i);
switch (i) {
case VolumeUp:
emit moreClicked();
return;
case VolumeDown:
emit lessClicked();
return;
case Forward:
emit forwardClicked();
return;
case Back:
emit backClicked();
return;
}
- } else if ( !isOnButton && audioButtons[i].isHeld ) {
- audioButtons[i].isHeld = FALSE;
+ } else if ( !isOnButton && buttons[i].isHeld ) {
+ buttons[i].isHeld = FALSE;
toggleButton(i);
}
} else {
- if ( audioButtons[i].isHeld ) {
- audioButtons[i].isHeld = FALSE;
- if ( !audioButtons[i].isToggle ) {
+ if ( buttons[i].isHeld ) {
+ buttons[i].isHeld = FALSE;
+ if ( !buttons[i].isToggle ) {
setToggleButton( i, FALSE );
}
qDebug("mouseEvent %d", i);
- handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown );
+ handleCommand( static_cast<Command>( i ), buttons[ i ].isDown );
}
}
}
}
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
@@ -437,31 +437,31 @@ void AudioWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
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 ( unsigned int i = 0; i < audioButtons.size(); i++ )
+ for ( unsigned int i = 0; i < buttons.size(); i++ )
paintButton( &p, i );
QPainter p2( this );
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
- for ( unsigned int i = 0; i < audioButtons.size(); i++ )
+ for ( unsigned int i = 0; i < buttons.size(); i++ )
paintButton( &p, i );
}
}
void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
hide();
// qDebug("Audio F9");