summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp15
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h4
2 files changed, 10 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 46d374d..74bc390 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -35,370 +35,369 @@
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <opie/oticker.h> 37#include <opie/oticker.h>
38 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qbutton.h> 41#include <qbutton.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48 48
49#include "audiowidget.h" 49#include "audiowidget.h"
50#include "mediaplayerstate.h" 50#include "mediaplayerstate.h"
51#include "playlistwidget.h" 51#include "playlistwidget.h"
52 52
53extern MediaPlayerState *mediaPlayerState; 53extern MediaPlayerState *mediaPlayerState;
54extern PlayListWidget *playList; 54extern PlayListWidget *playList;
55 55
56static const int xo = -2; // movable x offset 56static const int xo = -2; // movable x offset
57static const int yo = 22; // movable y offset 57static const int yo = 22; // movable y offset
58 58
59struct MediaButton { 59struct MediaButton {
60 bool isToggle, isHeld, isDown; 60 bool isToggle, isHeld, isDown;
61}; 61};
62 62
63//Layout information for the audioButtons (and if it is a toggle button or not) 63//Layout information for the audioButtons (and if it is a toggle button or not)
64MediaButton audioButtons[] = { 64MediaButton audioButtons[] = {
65 { TRUE, FALSE, FALSE }, // play 65 { TRUE, FALSE, FALSE }, // play
66 { FALSE, FALSE, FALSE }, // stop 66 { FALSE, FALSE, FALSE }, // stop
67 { FALSE, FALSE, FALSE }, // next 67 { FALSE, FALSE, FALSE }, // next
68 { FALSE, FALSE, FALSE }, // previous 68 { FALSE, FALSE, FALSE }, // previous
69 { FALSE, FALSE, FALSE }, // volume up 69 { FALSE, FALSE, FALSE }, // volume up
70 { FALSE, FALSE, FALSE }, // volume down 70 { FALSE, FALSE, FALSE }, // volume down
71 { TRUE, FALSE, FALSE }, // repeat/loop 71 { TRUE, FALSE, FALSE }, // repeat/loop
72 { FALSE, FALSE, FALSE }, // playlist 72 { FALSE, FALSE, FALSE }, // playlist
73 { FALSE, FALSE, FALSE }, // forward 73 { FALSE, FALSE, FALSE }, // forward
74 { FALSE, FALSE, FALSE } // back 74 { FALSE, FALSE, FALSE } // back
75}; 75};
76 76
77const char * const skin_mask_file_names[10] = { 77const char * const skin_mask_file_names[10] = {
78 "play", "stop", "next", "prev", "up", 78 "play", "stop", "next", "prev", "up",
79 "down", "loop", "playlist", "forward", "back" 79 "down", "loop", "playlist", "forward", "back"
80}; 80};
81 81
82 82
83static void changeTextColor( QWidget *w ) { 83static void changeTextColor( QWidget *w ) {
84 QPalette p = w->palette(); 84 QPalette p = w->palette();
85 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 85 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
86 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 86 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
87 w->setPalette( p ); 87 w->setPalette( p );
88} 88}
89 89
90static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 90static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
91 91
92 92
93AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 93AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
94 94
95 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 95 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
96 96
97 setCaption( tr("OpiePlayer") ); 97 setCaption( tr("OpiePlayer") );
98 98
99 Config cfg("OpiePlayer"); 99 Config cfg("OpiePlayer");
100 cfg.setGroup("Options"); 100 cfg.setGroup("Options");
101 skin = cfg.readEntry("Skin","default"); 101 skin = cfg.readEntry("Skin","default");
102 //skin = "scaleTest"; 102 //skin = "scaleTest";
103 // color of background, frame, degree of transparency 103 // color of background, frame, degree of transparency
104 104
105 QString skinPath = "opieplayer2/skins/" + skin; 105 QString skinPath = "opieplayer2/skins/" + skin;
106 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 106 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
107 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 107 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
108 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 108 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
109 109
110 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 110 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
111 imgButtonMask.fill( 0 ); 111 imgButtonMask.fill( 0 );
112 112
113 for ( int i = 0; i < 10; i++ ) { 113 for ( int i = 0; i < 10; i++ ) {
114 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); 114 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
115 masks[i] = new QBitmap( filename ); 115 masks[i] = new QBitmap( filename );
116 116
117 if ( !masks[i]->isNull() ) { 117 if ( !masks[i]->isNull() ) {
118 QImage imgMask = masks[i]->convertToImage(); 118 QImage imgMask = masks[i]->convertToImage();
119 uchar **dest = imgButtonMask.jumpTable(); 119 uchar **dest = imgButtonMask.jumpTable();
120 for ( int y = 0; y < imgUp.height(); y++ ) { 120 for ( int y = 0; y < imgUp.height(); y++ ) {
121 uchar *line = dest[y]; 121 uchar *line = dest[y];
122 for ( int x = 0; x < imgUp.width(); x++ ) 122 for ( int x = 0; x < imgUp.width(); x++ )
123 if ( !qRed( imgMask.pixel( x, y ) ) ) 123 if ( !qRed( imgMask.pixel( x, y ) ) )
124 line[x] = i + 1; 124 line[x] = i + 1;
125 } 125 }
126 } 126 }
127 127
128 } 128 }
129 129
130 for ( int i = 0; i < 10; i++ ) { 130 for ( int i = 0; i < 10; i++ ) {
131 buttonPixUp[i] = 0l; 131 buttonPixUp[i] = 0l;
132 buttonPixDown[i] = 0l; 132 buttonPixDown[i] = 0l;
133 } 133 }
134 134
135 setBackgroundPixmap( pixBg ); 135 setBackgroundPixmap( pixBg );
136 136
137 songInfo.setFocusPolicy( QWidget::NoFocus ); 137 songInfo.setFocusPolicy( QWidget::NoFocus );
138// changeTextColor( &songInfo ); 138// changeTextColor( &songInfo );
139// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 139// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
140// songInfo.setFrameStyle( QFrame::NoFrame); 140// songInfo.setFrameStyle( QFrame::NoFrame);
141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
142// songInfo.setForegroundColor(Qt::white); 142// songInfo.setForegroundColor(Qt::white);
143 143
144 slider.setFixedHeight( 20 ); 144 slider.setFixedHeight( 20 );
145 slider.setMinValue( 0 ); 145 slider.setMinValue( 0 );
146 slider.setMaxValue( 1 ); 146 slider.setMaxValue( 1 );
147 slider.setFocusPolicy( QWidget::NoFocus ); 147 slider.setFocusPolicy( QWidget::NoFocus );
148 slider.setBackgroundPixmap( pixBg ); 148 slider.setBackgroundPixmap( pixBg );
149 149
150// Config cofg("qpe"); 150// Config cofg("qpe");
151// cofg.setGroup("Appearance"); 151// cofg.setGroup("Appearance");
152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
153 153
154 time.setFocusPolicy( QWidget::NoFocus ); 154 time.setFocusPolicy( QWidget::NoFocus );
155 time.setAlignment( Qt::AlignCenter ); 155 time.setAlignment( Qt::AlignCenter );
156 156
157// time.setFrame(FALSE); 157// time.setFrame(FALSE);
158// changeTextColor( &time ); 158// changeTextColor( &time );
159 159
160 resizeEvent( NULL ); 160 resizeEvent( NULL );
161 161
162 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 162 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
163 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 163 connect( mediaPlayerState, SIGNAL( mediaTypeChanged(MediaPlayerState::MediaType) ), this, SLOT( setMediaType(MediaPlayerState::MediaType) ) );
164 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 164 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
165 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 165 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
166 connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 166 connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
167 167
168 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 168 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
169 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 169 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
170 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 170 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
171 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 171 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
172 172
173 // Intialise state 173 // Intialise state
174 setLength( mediaPlayerState->length() ); 174 setLength( mediaPlayerState->length() );
175 setPosition( mediaPlayerState->position() ); 175 setPosition( mediaPlayerState->position() );
176 setLooping( mediaPlayerState->isFullscreen() ); 176 setLooping( mediaPlayerState->isFullscreen() );
177 // setPaused( mediaPlayerState->paused() ); 177 // setPaused( mediaPlayerState->paused() );
178 setPlaying( mediaPlayerState->isPlaying() ); 178 setPlaying( mediaPlayerState->isPlaying() );
179 179
180} 180}
181 181
182AudioWidget::~AudioWidget() { 182AudioWidget::~AudioWidget() {
183 183
184 for ( int i = 0; i < 10; i++ ) { 184 for ( int i = 0; i < 10; i++ ) {
185 delete buttonPixUp[i]; 185 delete buttonPixUp[i];
186 delete buttonPixDown[i]; 186 delete buttonPixDown[i];
187 } 187 }
188 for ( int i = 0; i < 10; i++ ) { 188 for ( int i = 0; i < 10; i++ ) {
189 delete masks[i]; 189 delete masks[i];
190 } 190 }
191// mediaPlayerState->setPlaying(false); 191// mediaPlayerState->setPlaying(false);
192} 192}
193 193
194namespace { 194namespace {
195 195
196QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 196QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
197 QPixmap pix( img.width(), img.height() ); 197 QPixmap pix( img.width(), img.height() );
198 QPainter p( &pix ); 198 QPainter p( &pix );
199 p.drawTiledPixmap( pix.rect(), bg, offset ); 199 p.drawTiledPixmap( pix.rect(), bg, offset );
200 p.drawImage( 0, 0, img ); 200 p.drawImage( 0, 0, img );
201 return pix; 201 return pix;
202} 202}
203 203
204 204
205QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 205QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
206 QPixmap *pixmap = new QPixmap( pix ); 206 QPixmap *pixmap = new QPixmap( pix );
207 pixmap->setMask( mask ); 207 pixmap->setMask( mask );
208 return pixmap; 208 return pixmap;
209} 209}
210 210
211}; 211};
212 212
213void AudioWidget::resizeEvent( QResizeEvent * ) { 213void AudioWidget::resizeEvent( QResizeEvent * ) {
214 int h = height(); 214 int h = height();
215 int w = width(); 215 int w = width();
216 216
217 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 217 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
218 slider.setFixedWidth( w - 110 ); 218 slider.setFixedWidth( w - 110 );
219 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 219 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
220 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 220 slider.setBackgroundOrigin( QWidget::ParentOrigin );
221 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 221 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
222 222
223 xoff = ( w - imgUp.width() ) / 2; 223 xoff = ( w - imgUp.width() ) / 2;
224 yoff = (( h - imgUp.height() ) / 2) - 10; 224 yoff = (( h - imgUp.height() ) / 2) - 10;
225 QPoint p( xoff, yoff ); 225 QPoint p( xoff, yoff );
226 226
227 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); 227 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p );
228 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); 228 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p );
229 229
230 for ( int i = 0; i < 10; i++ ) { 230 for ( int i = 0; i < 10; i++ ) {
231 if ( !masks[i]->isNull() ) { 231 if ( !masks[i]->isNull() ) {
232 delete buttonPixUp[i]; 232 delete buttonPixUp[i];
233 delete buttonPixDown[i]; 233 delete buttonPixDown[i];
234 buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); 234 buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] );
235 buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); 235 buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] );
236 } 236 }
237 } 237 }
238} 238}
239 239
240static bool audioSliderBeingMoved = FALSE; 240static bool audioSliderBeingMoved = FALSE;
241 241
242 242
243void AudioWidget::sliderPressed() { 243void AudioWidget::sliderPressed() {
244 audioSliderBeingMoved = TRUE; 244 audioSliderBeingMoved = TRUE;
245} 245}
246 246
247 247
248void AudioWidget::sliderReleased() { 248void AudioWidget::sliderReleased() {
249 audioSliderBeingMoved = FALSE; 249 audioSliderBeingMoved = FALSE;
250 if ( slider.width() == 0 ) 250 if ( slider.width() == 0 )
251 return; 251 return;
252 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 252 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
253 mediaPlayerState->setPosition( val ); 253 mediaPlayerState->setPosition( val );
254} 254}
255 255
256void AudioWidget::setPosition( long i ) { 256void AudioWidget::setPosition( long i ) {
257 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 257 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
258 updateSlider( i, mediaPlayerState->length() ); 258 updateSlider( i, mediaPlayerState->length() );
259} 259}
260 260
261 261
262void AudioWidget::setLength( long max ) { 262void AudioWidget::setLength( long max ) {
263 updateSlider( mediaPlayerState->position(), max ); 263 updateSlider( mediaPlayerState->position(), max );
264} 264}
265 265
266 266
267void AudioWidget::setView( char view ) { 267void AudioWidget::setMediaType( MediaPlayerState::MediaType mediaType ) {
268 268 if ( mediaType == MediaPlayerState::Video ) {
269if ( view == 'a' ) {
270 // startTimer( 150 );
271 showMaximized();
272 } else {
273 killTimers(); 269 killTimers();
274 hide(); 270 hide();
271 return;
275 } 272 }
276 // qApp->processEvents(); 273
274 // startTimer( 150 );
275 showMaximized();
277} 276}
278 277
279 278
280void AudioWidget::setSeekable( bool isSeekable ) { 279void AudioWidget::setSeekable( bool isSeekable ) {
281 280
282 if ( !isSeekable ) { 281 if ( !isSeekable ) {
283 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 282 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
284 if( !slider.isHidden()) { 283 if( !slider.isHidden()) {
285 slider.hide(); 284 slider.hide();
286 } 285 }
287 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 286 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
288 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 287 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
289 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 288 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
290 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 289 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
291 } else { 290 } else {
292 // this stops the slider from being moved, thus 291 // this stops the slider from being moved, thus
293 // does not stop stream when it reaches the end 292 // does not stop stream when it reaches the end
294 slider.show(); 293 slider.show();
295 qDebug( " CONNECT SET POSTION " ); 294 qDebug( " CONNECT SET POSTION " );
296 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 295 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
297 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 296 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
298 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 297 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
299 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 298 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
300 } 299 }
301} 300}
302 301
303 302
304static QString timeAsString( long length ) { 303static QString timeAsString( long length ) {
305 int minutes = length / 60; 304 int minutes = length / 60;
306 int seconds = length % 60; 305 int seconds = length % 60;
307 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 306 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
308} 307}
309 308
310void AudioWidget::updateSlider( long i, long max ) { 309void AudioWidget::updateSlider( long i, long max ) {
311 310
312 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 311 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
313// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 312// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
314 313
315 if ( max == 0 ) { 314 if ( max == 0 ) {
316 return; 315 return;
317 } 316 }
318 // Will flicker too much if we don't do this 317 // Will flicker too much if we don't do this
319 // Scale to something reasonable 318 // Scale to something reasonable
320 int width = slider.width(); 319 int width = slider.width();
321 int val = int((double)i * width / max); 320 int val = int((double)i * width / max);
322 if ( !audioSliderBeingMoved ) { 321 if ( !audioSliderBeingMoved ) {
323 if ( slider.value() != val ) { 322 if ( slider.value() != val ) {
324 slider.setValue( val ); 323 slider.setValue( val );
325 } 324 }
326 325
327 if ( slider.maxValue() != width ) { 326 if ( slider.maxValue() != width ) {
328 slider.setMaxValue( width ); 327 slider.setMaxValue( width );
329 } 328 }
330 } 329 }
331} 330}
332 331
333 332
334void AudioWidget::setToggleButton( int i, bool down ) { 333void AudioWidget::setToggleButton( int i, bool down ) {
335 qDebug("setToggleButton %d", i); 334 qDebug("setToggleButton %d", i);
336 if ( down != audioButtons[i].isDown ) { 335 if ( down != audioButtons[i].isDown ) {
337 toggleButton( i ); 336 toggleButton( i );
338 } 337 }
339} 338}
340 339
341 340
342void AudioWidget::toggleButton( int i ) { 341void AudioWidget::toggleButton( int i ) {
343 audioButtons[i].isDown = !audioButtons[i].isDown; 342 audioButtons[i].isDown = !audioButtons[i].isDown;
344 QPainter p(this); 343 QPainter p(this);
345 paintButton ( &p, i ); 344 paintButton ( &p, i );
346} 345}
347 346
348 347
349void AudioWidget::paintButton( QPainter *p, int i ) { 348void AudioWidget::paintButton( QPainter *p, int i ) {
350 if ( audioButtons[i].isDown ) { 349 if ( audioButtons[i].isDown ) {
351 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 350 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
352 } else { 351 } else {
353 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 352 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
354 } 353 }
355} 354}
356 355
357 356
358void AudioWidget::skipFor() { 357void AudioWidget::skipFor() {
359 skipDirection = +1; 358 skipDirection = +1;
360 startTimer( 50 ); 359 startTimer( 50 );
361 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 360 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
362} 361}
363 362
364void AudioWidget::skipBack() { 363void AudioWidget::skipBack() {
365 skipDirection = -1; 364 skipDirection = -1;
366 startTimer( 50 ); 365 startTimer( 50 );
367 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 366 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
368} 367}
369 368
370 369
371 370
372void AudioWidget::stopSkip() { 371void AudioWidget::stopSkip() {
373 killTimers(); 372 killTimers();
374} 373}
375 374
376 375
377void AudioWidget::timerEvent( QTimerEvent * ) { 376void AudioWidget::timerEvent( QTimerEvent * ) {
378 if ( skipDirection == +1 ) { 377 if ( skipDirection == +1 ) {
379 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 378 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
380 } else if ( skipDirection == -1 ) { 379 } else if ( skipDirection == -1 ) {
381 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 380 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
382 } 381 }
383} 382}
384 383
385 384
386void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 385void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
387 for ( int i = 0; i < numButtons; i++ ) { 386 for ( int i = 0; i < numButtons; i++ ) {
388 if ( event->state() == QMouseEvent::LeftButton ) { 387 if ( event->state() == QMouseEvent::LeftButton ) {
389 // The test to see if the mouse click is inside the button or not 388 // The test to see if the mouse click is inside the button or not
390 int x = event->pos().x() - xoff; 389 int x = event->pos().x() - xoff;
391 int y = event->pos().y() - yoff; 390 int y = event->pos().y() - yoff;
392 391
393 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() 392 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width()
394 && y < imgButtonMask.height() 393 && y < imgButtonMask.height()
395 && imgButtonMask.pixelIndex( x, y ) == i + 1 ); 394 && imgButtonMask.pixelIndex( x, y ) == i + 1 );
396 395
397 if ( isOnButton && !audioButtons[i].isHeld ) { 396 if ( isOnButton && !audioButtons[i].isHeld ) {
398 audioButtons[i].isHeld = TRUE; 397 audioButtons[i].isHeld = TRUE;
399 toggleButton(i); 398 toggleButton(i);
400 switch (i) { 399 switch (i) {
401 case AudioVolumeUp: 400 case AudioVolumeUp:
402 emit moreClicked(); 401 emit moreClicked();
403 return; 402 return;
404 case AudioVolumeDown: 403 case AudioVolumeDown:
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 54adb36..3f0c059 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,135 +1,137 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef AUDIO_WIDGET_H 34#ifndef AUDIO_WIDGET_H
35#define AUDIO_WIDGET_H 35#define AUDIO_WIDGET_H
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qdrawutil.h> 39#include <qdrawutil.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qstring.h> 41#include <qstring.h>
42#include <qslider.h> 42#include <qslider.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlineedit.h> 44#include <qlineedit.h>
45#include <qimage.h> 45#include <qimage.h>
46 46
47#include <opie/oticker.h> 47#include <opie/oticker.h>
48 48
49#include "mediaplayerstate.h"
50
49class QPixmap; 51class QPixmap;
50 52
51namespace { 53namespace {
52 54
53enum AudioButtons { 55enum AudioButtons {
54 AudioPlay=0, 56 AudioPlay=0,
55 AudioStop, 57 AudioStop,
56 AudioNext, 58 AudioNext,
57 AudioPrevious, 59 AudioPrevious,
58 AudioVolumeUp, 60 AudioVolumeUp,
59 AudioVolumeDown, 61 AudioVolumeDown,
60 AudioLoop, 62 AudioLoop,
61 AudioPlayList, 63 AudioPlayList,
62 AudioForward, 64 AudioForward,
63 AudioBack 65 AudioBack
64}; 66};
65}; 67};
66 68
67class AudioWidget : public QWidget { 69class AudioWidget : public QWidget {
68 Q_OBJECT 70 Q_OBJECT
69public: 71public:
70 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 72 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
71 ~AudioWidget(); 73 ~AudioWidget();
72 void setTickerText( const QString &text ) { songInfo.setText( text ); } 74 void setTickerText( const QString &text ) { songInfo.setText( text ); }
73public slots: 75public slots:
74 void updateSlider( long, long ); 76 void updateSlider( long, long );
75 void sliderPressed( ); 77 void sliderPressed( );
76 void sliderReleased( ); 78 void sliderReleased( );
77 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 79 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
78 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } 80 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
79 void setPosition( long ); 81 void setPosition( long );
80 void setLength( long ); 82 void setLength( long );
81 void setSeekable( bool ); 83 void setSeekable( bool );
82 void setView( char ); 84 void setMediaType( MediaPlayerState::MediaType mediaType );
83 85
84signals: 86signals:
85 void moreClicked(); 87 void moreClicked();
86 void lessClicked(); 88 void lessClicked();
87 void moreReleased(); 89 void moreReleased();
88 void lessReleased(); 90 void lessReleased();
89 void forwardClicked(); 91 void forwardClicked();
90 void backClicked(); 92 void backClicked();
91 void forwardReleased(); 93 void forwardReleased();
92 void backReleased(); 94 void backReleased();
93 void sliderMoved(long); 95 void sliderMoved(long);
94 96
95protected: 97protected:
96 void doBlank(); 98 void doBlank();
97 void doUnblank(); 99 void doUnblank();
98 void paintEvent( QPaintEvent *pe ); 100 void paintEvent( QPaintEvent *pe );
99 void showEvent( QShowEvent *se ); 101 void showEvent( QShowEvent *se );
100 void resizeEvent( QResizeEvent *re ); 102 void resizeEvent( QResizeEvent *re );
101 void mouseMoveEvent( QMouseEvent *event ); 103 void mouseMoveEvent( QMouseEvent *event );
102 void mousePressEvent( QMouseEvent *event ); 104 void mousePressEvent( QMouseEvent *event );
103 void mouseReleaseEvent( QMouseEvent *event ); 105 void mouseReleaseEvent( QMouseEvent *event );
104 void timerEvent( QTimerEvent *event ); 106 void timerEvent( QTimerEvent *event );
105 void closeEvent( QCloseEvent *event ); 107 void closeEvent( QCloseEvent *event );
106 void keyReleaseEvent( QKeyEvent *e); 108 void keyReleaseEvent( QKeyEvent *e);
107private slots: 109private slots:
108 void skipFor(); 110 void skipFor();
109 void skipBack(); 111 void skipBack();
110 void stopSkip(); 112 void stopSkip();
111private: 113private:
112 void toggleButton( int ); 114 void toggleButton( int );
113 void setToggleButton( int, bool ); 115 void setToggleButton( int, bool );
114 void paintButton( QPainter *p, int i ); 116 void paintButton( QPainter *p, int i );
115 int skipDirection; 117 int skipDirection;
116 QString skin; 118 QString skin;
117 QPixmap pixBg; 119 QPixmap pixBg;
118 QImage imgUp; 120 QImage imgUp;
119 QImage imgDn; 121 QImage imgDn;
120 QImage imgButtonMask; 122 QImage imgButtonMask;
121 QBitmap *masks[10]; 123 QBitmap *masks[10];
122 QPixmap *buttonPixUp[10]; 124 QPixmap *buttonPixUp[10];
123 QPixmap *buttonPixDown[10]; 125 QPixmap *buttonPixDown[10];
124 126
125 QPixmap *pixmaps[4]; 127 QPixmap *pixmaps[4];
126 OTicker songInfo; 128 OTicker songInfo;
127 QSlider slider; 129 QSlider slider;
128 QLineEdit time; 130 QLineEdit time;
129 int xoff, yoff; 131 int xoff, yoff;
130 bool isStreaming : 1; 132 bool isStreaming : 1;
131}; 133};
132 134
133 135
134#endif // AUDIO_WIDGET_H 136#endif // AUDIO_WIDGET_H
135 137