Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 6d867e5..bf3590b 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -72,26 +72,27 @@ void Ticker::setText( const QString& text ) { | |||
72 | } | 72 | } |
73 | update(); | 73 | update(); |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | void Ticker::timerEvent( QTimerEvent * ) { | 77 | void Ticker::timerEvent( QTimerEvent * ) { |
78 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 78 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; |
79 | scroll( -1, 0, contentsRect() ); | 79 | scroll( -1, 0, contentsRect() ); |
80 | repaint( FALSE ); | 80 | repaint( FALSE ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void Ticker::drawContents( QPainter *p ) { | 83 | void Ticker::drawContents( QPainter *p ) { |
84 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | 84 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
85 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 85 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
86 | } | ||
86 | QPixmap pm( width(), height() ); | 87 | QPixmap pm( width(), height() ); |
87 | pm.fill( colorGroup().base() ); | 88 | pm.fill( colorGroup().base() ); |
88 | QPainter pmp( &pm ); | 89 | QPainter pmp( &pm ); |
89 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 90 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
90 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 91 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
91 | } | 92 | } |
92 | p->drawPixmap( 0, 0, pm ); | 93 | p->drawPixmap( 0, 0, pm ); |
93 | } | 94 | } |
94 | 95 | ||
95 | struct MediaButton { | 96 | struct MediaButton { |
96 | bool isToggle, isHeld, isDown; | 97 | bool isToggle, isHeld, isDown; |
97 | }; | 98 | }; |
@@ -118,27 +119,26 @@ const char *skin_mask_file_names[10] = { | |||
118 | 119 | ||
119 | static void changeTextColor( QWidget *w ) { | 120 | static void changeTextColor( QWidget *w ) { |
120 | QPalette p = w->palette(); | 121 | QPalette p = w->palette(); |
121 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 122 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
122 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 123 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
123 | w->setPalette( p ); | 124 | w->setPalette( p ); |
124 | } | 125 | } |
125 | 126 | ||
126 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 127 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
127 | 128 | ||
128 | 129 | ||
129 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 130 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
130 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | ||
131 | |||
132 | 131 | ||
132 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | ||
133 | 133 | ||
134 | setCaption( tr("OpiePlayer") ); | 134 | setCaption( tr("OpiePlayer") ); |
135 | 135 | ||
136 | Config cfg("OpiePlayer"); | 136 | Config cfg("OpiePlayer"); |
137 | cfg.setGroup("Options"); | 137 | cfg.setGroup("Options"); |
138 | skin = cfg.readEntry("Skin","default"); | 138 | skin = cfg.readEntry("Skin","default"); |
139 | //skin = "scaleTest"; | 139 | //skin = "scaleTest"; |
140 | // color of background, frame, degree of transparency | 140 | // color of background, frame, degree of transparency |
141 | 141 | ||
142 | QString skinPath = "opieplayer2/skins/" + skin; | 142 | QString skinPath = "opieplayer2/skins/" + skin; |
143 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 143 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
144 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 144 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
@@ -227,26 +227,25 @@ AudioWidget::~AudioWidget() { | |||
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 230 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
231 | QPixmap pix( img.width(), img.height() ); | 231 | QPixmap pix( img.width(), img.height() ); |
232 | QPainter p( &pix ); | 232 | QPainter p( &pix ); |
233 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 233 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
234 | p.drawImage( 0, 0, img ); | 234 | p.drawImage( 0, 0, img ); |
235 | return new QPixmap( pix ); | 235 | return new QPixmap( pix ); |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | 239 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
240 | { | ||
241 | QPixmap *pixmap = new QPixmap( pix ); | 240 | QPixmap *pixmap = new QPixmap( pix ); |
242 | pixmap->setMask( mask ); | 241 | pixmap->setMask( mask ); |
243 | return pixmap; | 242 | return pixmap; |
244 | } | 243 | } |
245 | 244 | ||
246 | 245 | ||
247 | 246 | ||
248 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 247 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
249 | int h = height(); | 248 | int h = height(); |
250 | int w = width(); | 249 | int w = width(); |
251 | 250 | ||
252 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 251 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
@@ -433,26 +432,25 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
433 | emit moreClicked(); | 432 | emit moreClicked(); |
434 | return; | 433 | return; |
435 | case AudioVolumeDown: | 434 | case AudioVolumeDown: |
436 | emit lessClicked(); | 435 | emit lessClicked(); |
437 | return; | 436 | return; |
438 | case AudioForward: | 437 | case AudioForward: |
439 | emit forwardClicked(); | 438 | emit forwardClicked(); |
440 | return; | 439 | return; |
441 | case AudioBack: | 440 | case AudioBack: |
442 | emit backClicked(); | 441 | emit backClicked(); |
443 | return; | 442 | return; |
444 | } | 443 | } |
445 | } | 444 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
446 | else if ( !isOnButton && audioButtons[i].isHeld ) { | ||
447 | audioButtons[i].isHeld = FALSE; | 445 | audioButtons[i].isHeld = FALSE; |
448 | toggleButton(i); | 446 | toggleButton(i); |
449 | } | 447 | } |
450 | } else { | 448 | } else { |
451 | if ( audioButtons[i].isHeld ) { | 449 | if ( audioButtons[i].isHeld ) { |
452 | audioButtons[i].isHeld = FALSE; | 450 | audioButtons[i].isHeld = FALSE; |
453 | if ( !audioButtons[i].isToggle ) { | 451 | if ( !audioButtons[i].isToggle ) { |
454 | setToggleButton( i, FALSE ); | 452 | setToggleButton( i, FALSE ); |
455 | } | 453 | } |
456 | switch (i) { | 454 | switch (i) { |
457 | case AudioPlay: | 455 | case AudioPlay: |
458 | if( mediaPlayerState->isPaused ) { | 456 | if( mediaPlayerState->isPaused ) { |
@@ -513,26 +511,25 @@ void AudioWidget::paintEvent( QPaintEvent * pe) { | |||
513 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 511 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
514 | for ( int i = 0; i < numButtons; i++ ) | 512 | for ( int i = 0; i < numButtons; i++ ) |
515 | paintButton( &p, i ); | 513 | paintButton( &p, i ); |
516 | QPainter p2( this ); | 514 | QPainter p2( this ); |
517 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 515 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
518 | } else { | 516 | } else { |
519 | QPainter p( this ); | 517 | QPainter p( this ); |
520 | for ( int i = 0; i < numButtons; i++ ) | 518 | for ( int i = 0; i < numButtons; i++ ) |
521 | paintButton( &p, i ); | 519 | paintButton( &p, i ); |
522 | } | 520 | } |
523 | } | 521 | } |
524 | 522 | ||
525 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 523 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
526 | { | ||
527 | switch ( e->key() ) { | 524 | switch ( e->key() ) { |
528 | ////////////////////////////// Zaurus keys | 525 | ////////////////////////////// Zaurus keys |
529 | case Key_Home: | 526 | case Key_Home: |
530 | break; | 527 | break; |
531 | case Key_F9: //activity | 528 | case Key_F9: //activity |
532 | hide(); | 529 | hide(); |
533 | // qDebug("Audio F9"); | 530 | // qDebug("Audio F9"); |
534 | break; | 531 | break; |
535 | case Key_F10: //contacts | 532 | case Key_F10: //contacts |
536 | break; | 533 | break; |
537 | case Key_F11: //menu | 534 | case Key_F11: //menu |
538 | mediaPlayerState->toggleBlank(); | 535 | mediaPlayerState->toggleBlank(); |