-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index c3e206c..3838e2c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -88,65 +88,65 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye | |||
88 | { | 88 | { |
89 | setCaption( tr("OpiePlayer") ); | 89 | setCaption( tr("OpiePlayer") ); |
90 | 90 | ||
91 | Config cfg("OpiePlayer"); | 91 | Config cfg("OpiePlayer"); |
92 | cfg.setGroup("Options"); | 92 | cfg.setGroup("Options"); |
93 | skin = cfg.readEntry("Skin","default"); | 93 | skin = cfg.readEntry("Skin","default"); |
94 | //skin = "scaleTest"; | 94 | //skin = "scaleTest"; |
95 | // color of background, frame, degree of transparency | 95 | // color of background, frame, degree of transparency |
96 | 96 | ||
97 | QString skinPath = "opieplayer2/skins/" + skin; | 97 | QString skinPath = "opieplayer2/skins/" + skin; |
98 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 98 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
99 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 99 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
100 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 100 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
101 | 101 | ||
102 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 102 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
103 | buttonMask.fill( 0 ); | 103 | buttonMask.fill( 0 ); |
104 | 104 | ||
105 | for ( uint i = 0; i < buttonCount; i++ ) { | 105 | for ( uint i = 0; i < buttonCount; i++ ) { |
106 | Button button; | 106 | Button button; |
107 | button.command = skinInfo[ i ].command; | 107 | button.command = skinInfo[ i ].command; |
108 | button.type = skinInfo[ i ].type; | 108 | button.type = skinInfo[ i ].type; |
109 | 109 | ||
110 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); | 110 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); |
111 | button.mask =QBitmap( filename ); | 111 | button.mask =QBitmap( filename ); |
112 | 112 | ||
113 | if ( !button.mask.isNull() ) { | 113 | if ( !button.mask.isNull() ) { |
114 | QImage imgMask = button.mask.convertToImage(); | 114 | QImage imgMask = button.mask.convertToImage(); |
115 | uchar **dest = buttonMask.jumpTable(); | 115 | uchar **dest = buttonMask.jumpTable(); |
116 | for ( int y = 0; y < imgUp.height(); y++ ) { | 116 | for ( int y = 0; y < imgUp.height(); y++ ) { |
117 | uchar *line = dest[y]; | 117 | uchar *line = dest[y]; |
118 | for ( int x = 0; x < imgUp.width(); x++ ) | 118 | for ( int x = 0; x < imgUp.width(); x++ ) |
119 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 119 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
120 | line[x] = i + 1; | 120 | line[x] = button.command + 1; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | buttons.push_back( button ); | 124 | buttons.push_back( button ); |
125 | } | 125 | } |
126 | 126 | ||
127 | setBackgroundPixmap( backgroundPixmap ); | 127 | setBackgroundPixmap( backgroundPixmap ); |
128 | 128 | ||
129 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 129 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
130 | // changeTextColor( &songInfo ); | 130 | // changeTextColor( &songInfo ); |
131 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 131 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
132 | // songInfo.setFrameStyle( QFrame::NoFrame); | 132 | // songInfo.setFrameStyle( QFrame::NoFrame); |
133 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 133 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
134 | // songInfo.setForegroundColor(Qt::white); | 134 | // songInfo.setForegroundColor(Qt::white); |
135 | 135 | ||
136 | slider.setFixedHeight( 20 ); | 136 | slider.setFixedHeight( 20 ); |
137 | slider.setMinValue( 0 ); | 137 | slider.setMinValue( 0 ); |
138 | slider.setMaxValue( 1 ); | 138 | slider.setMaxValue( 1 ); |
139 | slider.setFocusPolicy( QWidget::NoFocus ); | 139 | slider.setFocusPolicy( QWidget::NoFocus ); |
140 | slider.setBackgroundPixmap( backgroundPixmap ); | 140 | slider.setBackgroundPixmap( backgroundPixmap ); |
141 | 141 | ||
142 | // Config cofg("qpe"); | 142 | // Config cofg("qpe"); |
143 | // cofg.setGroup("Appearance"); | 143 | // cofg.setGroup("Appearance"); |
144 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 144 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
145 | 145 | ||
146 | time.setFocusPolicy( QWidget::NoFocus ); | 146 | time.setFocusPolicy( QWidget::NoFocus ); |
147 | time.setAlignment( Qt::AlignCenter ); | 147 | time.setAlignment( Qt::AlignCenter ); |
148 | 148 | ||
149 | // time.setFrame(FALSE); | 149 | // time.setFrame(FALSE); |
150 | // changeTextColor( &time ); | 150 | // changeTextColor( &time ); |
151 | 151 | ||
152 | resizeEvent( NULL ); | 152 | resizeEvent( NULL ); |
@@ -309,98 +309,100 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
309 | void AudioWidget::skipFor() { | 309 | void AudioWidget::skipFor() { |
310 | skipDirection = +1; | 310 | skipDirection = +1; |
311 | startTimer( 50 ); | 311 | startTimer( 50 ); |
312 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 312 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
313 | } | 313 | } |
314 | 314 | ||
315 | void AudioWidget::skipBack() { | 315 | void AudioWidget::skipBack() { |
316 | skipDirection = -1; | 316 | skipDirection = -1; |
317 | startTimer( 50 ); | 317 | startTimer( 50 ); |
318 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 318 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | 322 | ||
323 | void AudioWidget::stopSkip() { | 323 | void AudioWidget::stopSkip() { |
324 | killTimers(); | 324 | killTimers(); |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | void AudioWidget::timerEvent( QTimerEvent * ) { | 328 | void AudioWidget::timerEvent( QTimerEvent * ) { |
329 | if ( skipDirection == +1 ) { | 329 | if ( skipDirection == +1 ) { |
330 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 330 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
331 | } else if ( skipDirection == -1 ) { | 331 | } else if ( skipDirection == -1 ) { |
332 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 332 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | 336 | ||
337 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 337 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
338 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { | 338 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
339 | 339 | ||
340 | Button &button = buttons[ i ]; | 340 | Button &button = buttons[ i ]; |
341 | Command command = button.command; | ||
341 | 342 | ||
342 | if ( event->state() == QMouseEvent::LeftButton ) { | 343 | if ( event->state() == QMouseEvent::LeftButton ) { |
343 | // The test to see if the mouse click is inside the button or not | 344 | // The test to see if the mouse click is inside the button or not |
344 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 345 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); |
345 | 346 | ||
346 | if ( isOnButton && !button.isHeld ) { | 347 | if ( isOnButton && !button.isHeld ) { |
347 | button.isHeld = TRUE; | 348 | button.isHeld = TRUE; |
348 | toggleButton( button ); | 349 | toggleButton( button ); |
349 | switch (i) { | 350 | switch ( command ) { |
350 | case VolumeUp: | 351 | case VolumeUp: |
351 | emit moreClicked(); | 352 | emit moreClicked(); |
352 | return; | 353 | return; |
353 | case VolumeDown: | 354 | case VolumeDown: |
354 | emit lessClicked(); | 355 | emit lessClicked(); |
355 | return; | 356 | return; |
356 | case Forward: | 357 | case Forward: |
357 | emit forwardClicked(); | 358 | emit forwardClicked(); |
358 | return; | 359 | return; |
359 | case Back: | 360 | case Back: |
360 | emit backClicked(); | 361 | emit backClicked(); |
361 | return; | 362 | return; |
363 | default: break; | ||
362 | } | 364 | } |
363 | } else if ( !isOnButton && button.isHeld ) { | 365 | } else if ( !isOnButton && button.isHeld ) { |
364 | button.isHeld = FALSE; | 366 | button.isHeld = FALSE; |
365 | toggleButton( button ); | 367 | toggleButton( button ); |
366 | } | 368 | } |
367 | } else { | 369 | } else { |
368 | if ( button.isHeld ) { | 370 | if ( button.isHeld ) { |
369 | button.isHeld = FALSE; | 371 | button.isHeld = FALSE; |
370 | if ( button.type != ToggleButton ) { | 372 | if ( button.type != ToggleButton ) { |
371 | setToggleButton( button, FALSE ); | 373 | setToggleButton( button, FALSE ); |
372 | } | 374 | } |
373 | qDebug("mouseEvent %d", i); | 375 | qDebug("mouseEvent %d", i); |
374 | handleCommand( static_cast<Command>( i ), button.isDown ); | 376 | handleCommand( command, button.isDown ); |
375 | } | 377 | } |
376 | } | 378 | } |
377 | } | 379 | } |
378 | } | 380 | } |
379 | 381 | ||
380 | 382 | ||
381 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 383 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
382 | mouseMoveEvent( event ); | 384 | mouseMoveEvent( event ); |
383 | } | 385 | } |
384 | 386 | ||
385 | 387 | ||
386 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 388 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
387 | mouseMoveEvent( event ); | 389 | mouseMoveEvent( event ); |
388 | } | 390 | } |
389 | 391 | ||
390 | 392 | ||
391 | void AudioWidget::showEvent( QShowEvent* ) { | 393 | void AudioWidget::showEvent( QShowEvent* ) { |
392 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 394 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
393 | mouseMoveEvent( &event ); | 395 | mouseMoveEvent( &event ); |
394 | } | 396 | } |
395 | 397 | ||
396 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 398 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
397 | switch ( e->key() ) { | 399 | switch ( e->key() ) { |
398 | ////////////////////////////// Zaurus keys | 400 | ////////////////////////////// Zaurus keys |
399 | case Key_Home: | 401 | case Key_Home: |
400 | break; | 402 | break; |
401 | case Key_F9: //activity | 403 | case Key_F9: //activity |
402 | hide(); | 404 | hide(); |
403 | // qDebug("Audio F9"); | 405 | // qDebug("Audio F9"); |
404 | break; | 406 | break; |
405 | case Key_F10: //contacts | 407 | case Key_F10: //contacts |
406 | break; | 408 | break; |