summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/audiowidget.cpp
authorllornkcor <llornkcor>2002-02-24 21:51:51 (UTC)
committer llornkcor <llornkcor>2002-02-24 21:51:51 (UTC)
commit36b768c465c6ecddceb57ff1d7a5087e9848c897 (patch) (unidiff)
tree4ddde589e2393ca136e24cda4fc456612149ae72 /core/multimedia/opieplayer/audiowidget.cpp
parentade25ac278169f0e0c9ee0771e754adb46cf7ce2 (diff)
downloadopie-36b768c465c6ecddceb57ff1d7a5087e9848c897.zip
opie-36b768c465c6ecddceb57ff1d7a5087e9848c897.tar.gz
opie-36b768c465c6ecddceb57ff1d7a5087e9848c897.tar.bz2
changed mediaplayerplugininterface.h location
Diffstat (limited to 'core/multimedia/opieplayer/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp122
1 files changed, 61 insertions, 61 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 243c58c..0d88591 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -61,7 +61,7 @@ static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
61AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 61AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
62 QWidget( parent, name, f ) 62 QWidget( parent, name, f )
63{ 63{
64 setCaption( tr("MediaPlayer") ); 64 setCaption( tr("OpiePlayer") );
65 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 65 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
66 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); 66 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) );
67 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); 67 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) );
@@ -104,7 +104,7 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
104 104
105AudioWidget::~AudioWidget() { 105AudioWidget::~AudioWidget() {
106 for ( int i = 0; i < 4; i++ ) 106 for ( int i = 0; i < 4; i++ )
107 delete pixmaps[i]; 107 delete pixmaps[i];
108} 108}
109 109
110 110
@@ -119,7 +119,7 @@ void AudioWidget::sliderPressed() {
119void AudioWidget::sliderReleased() { 119void AudioWidget::sliderReleased() {
120 audioSliderBeingMoved = FALSE; 120 audioSliderBeingMoved = FALSE;
121 if ( slider->width() == 0 ) 121 if ( slider->width() == 0 )
122 return; 122 return;
123 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 123 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
124 mediaPlayerState->setPosition( val ); 124 mediaPlayerState->setPosition( val );
125} 125}
@@ -137,34 +137,34 @@ void AudioWidget::setLength( long max ) {
137 137
138void AudioWidget::setView( char view ) { 138void AudioWidget::setView( char view ) {
139 if ( view == 'a' ) { 139 if ( view == 'a' ) {
140 startTimer( 150 ); 140 startTimer( 150 );
141 showMaximized(); 141 showMaximized();
142 } else { 142 } else {
143 killTimers(); 143 killTimers();
144 hide(); 144 hide();
145 } 145 }
146} 146}
147 147
148 148
149void AudioWidget::updateSlider( long i, long max ) { 149void AudioWidget::updateSlider( long i, long max ) {
150 if ( max == 0 ) 150 if ( max == 0 )
151 return; 151 return;
152 // Will flicker too much if we don't do this 152 // Will flicker too much if we don't do this
153 // Scale to something reasonable 153 // Scale to something reasonable
154 int width = slider->width(); 154 int width = slider->width();
155 int val = int((double)i * width / max); 155 int val = int((double)i * width / max);
156 if ( !audioSliderBeingMoved ) { 156 if ( !audioSliderBeingMoved ) {
157 if ( slider->value() != val ) 157 if ( slider->value() != val )
158 slider->setValue( val ); 158 slider->setValue( val );
159 if ( slider->maxValue() != width ) 159 if ( slider->maxValue() != width )
160 slider->setMaxValue( width ); 160 slider->setMaxValue( width );
161 } 161 }
162} 162}
163 163
164 164
165void AudioWidget::setToggleButton( int i, bool down ) { 165void AudioWidget::setToggleButton( int i, bool down ) {
166 if ( down != audioButtons[i].isDown ) 166 if ( down != audioButtons[i].isDown )
167 toggleButton( i ); 167 toggleButton( i );
168} 168}
169 169
170 170
@@ -188,61 +188,61 @@ void AudioWidget::paintButton( QPainter *p, int i ) {
188void AudioWidget::timerEvent( QTimerEvent * ) { 188void AudioWidget::timerEvent( QTimerEvent * ) {
189 static int frame = 0; 189 static int frame = 0;
190 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 190 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
191 frame = frame >= 7 ? 0 : frame + 1; 191 frame = frame >= 7 ? 0 : frame + 1;
192 int x = audioButtons[AudioPlay].xPos; 192 int x = audioButtons[AudioPlay].xPos;
193 int y = audioButtons[AudioPlay].yPos; 193 int y = audioButtons[AudioPlay].yPos;
194 QPainter p( this ); 194 QPainter p( this );
195 // Optimize to only draw the little bit of the changing images which is different 195 // Optimize to only draw the little bit of the changing images which is different
196 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); 196 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
197 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); 197 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
198 } 198 }
199} 199}
200 200
201 201
202void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 202void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
203 for ( int i = 0; i < numButtons; i++ ) { 203 for ( int i = 0; i < numButtons; i++ ) {
204 int size = audioButtons[i].isBig; 204 int size = audioButtons[i].isBig;
205 int x = audioButtons[i].xPos; 205 int x = audioButtons[i].xPos;
206 int y = audioButtons[i].yPos; 206 int y = audioButtons[i].yPos;
207 if ( event->state() == QMouseEvent::LeftButton ) { 207 if ( event->state() == QMouseEvent::LeftButton ) {
208 // The test to see if the mouse click is inside the circular button or not 208 // The test to see if the mouse click is inside the circular button or not
209 // (compared with the radius squared to avoid a square-root of our distance) 209 // (compared with the radius squared to avoid a square-root of our distance)
210 int radius = 32 + 13 * size; 210 int radius = 32 + 13 * size;
211 QPoint center = QPoint( x + radius, y + radius ); 211 QPoint center = QPoint( x + radius, y + radius );
212 QPoint dXY = center - event->pos(); 212 QPoint dXY = center - event->pos();
213 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 213 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
214 bool isOnButton = dist <= (radius * radius); 214 bool isOnButton = dist <= (radius * radius);
215 // QRect r( x, y, 64 + 22*size, 64 + 22*size ); 215// QRect r( x, y, 64 + 22*size, 64 + 22*size );
216 // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 216// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
217 if ( isOnButton && !audioButtons[i].isHeld ) { 217 if ( isOnButton && !audioButtons[i].isHeld ) {
218 audioButtons[i].isHeld = TRUE; 218 audioButtons[i].isHeld = TRUE;
219 toggleButton(i); 219 toggleButton(i);
220 switch (i) { 220 switch (i) {
221 case AudioVolumeUp: emit moreClicked(); return; 221 case AudioVolumeUp: emit moreClicked(); return;
222 case AudioVolumeDown: emit lessClicked(); return; 222 case AudioVolumeDown: emit lessClicked(); return;
223 } 223 }
224 } else if ( !isOnButton && audioButtons[i].isHeld ) { 224 } else if ( !isOnButton && audioButtons[i].isHeld ) {
225 audioButtons[i].isHeld = FALSE; 225 audioButtons[i].isHeld = FALSE;
226 toggleButton(i); 226 toggleButton(i);
227 } 227 }
228 } else { 228 } else {
229 if ( audioButtons[i].isHeld ) { 229 if ( audioButtons[i].isHeld ) {
230 audioButtons[i].isHeld = FALSE; 230 audioButtons[i].isHeld = FALSE;
231 if ( !audioButtons[i].isToggle ) 231 if ( !audioButtons[i].isToggle )
232 setToggleButton( i, FALSE ); 232 setToggleButton( i, FALSE );
233 switch (i) { 233 switch (i) {
234 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 234 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
235 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 235 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
236 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 236 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
237 case AudioNext: mediaPlayerState->setNext(); return; 237 case AudioNext: mediaPlayerState->setNext(); return;
238 case AudioPrevious: mediaPlayerState->setPrev(); return; 238 case AudioPrevious: mediaPlayerState->setPrev(); return;
239 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 239 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
240 case AudioVolumeUp: emit moreReleased(); return; 240 case AudioVolumeUp: emit moreReleased(); return;
241 case AudioVolumeDown: emit lessReleased(); return; 241 case AudioVolumeDown: emit lessReleased(); return;
242 case AudioPlayList: mediaPlayerState->setList(); return; 242 case AudioPlayList: mediaPlayerState->setList(); return;
243 } 243 }
244 } 244 }
245 } 245 }
246 } 246 }
247} 247}
248 248
@@ -271,7 +271,7 @@ void AudioWidget::closeEvent( QCloseEvent* ) {
271void AudioWidget::paintEvent( QPaintEvent * ) { 271void AudioWidget::paintEvent( QPaintEvent * ) {
272 QPainter p( this ); 272 QPainter p( this );
273 for ( int i = 0; i < numButtons; i++ ) 273 for ( int i = 0; i < numButtons; i++ )
274 paintButton( &p, i ); 274 paintButton( &p, i );
275} 275}
276 276
277 277