summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 13:40:24 (UTC)
committer simon <simon>2002-12-09 13:40:24 (UTC)
commitd0d993b584bba77905955466897a50cea758103c (patch) (unidiff)
treefabf38ac7ef2d454a311bd2d264ca1eeab02e2b0
parentd1324d850a3c8269bd6009de6fdf6c321954b371 (diff)
downloadopie-d0d993b584bba77905955466897a50cea758103c.zip
opie-d0d993b584bba77905955466897a50cea758103c.tar.gz
opie-d0d993b584bba77905955466897a50cea758103c.tar.bz2
- buttonPixUp/Down are now vectors, too
- removed unused and uninitialized pixmaps array
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp22
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h6
2 files changed, 10 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index fe7ddc1..2081b4f 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -120,28 +120,26 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
120 QImage imgMask = masks[i].convertToImage(); 120 QImage imgMask = masks[i].convertToImage();
121 uchar **dest = buttonMask.jumpTable(); 121 uchar **dest = buttonMask.jumpTable();
122 for ( int y = 0; y < imgUp.height(); y++ ) { 122 for ( int y = 0; y < imgUp.height(); y++ ) {
123 uchar *line = dest[y]; 123 uchar *line = dest[y];
124 for ( int x = 0; x < imgUp.width(); x++ ) 124 for ( int x = 0; x < imgUp.width(); x++ )
125 if ( !qRed( imgMask.pixel( x, y ) ) ) 125 if ( !qRed( imgMask.pixel( x, y ) ) )
126 line[x] = i + 1; 126 line[x] = i + 1;
127 } 127 }
128 } 128 }
129 129
130 } 130 }
131 131
132 for ( int i = 0; i < 10; i++ ) { 132 buttonPixUp.resize( masks.size(), QPixmap() );
133 buttonPixUp[i] = 0l; 133 buttonPixDown.resize( masks.size(), QPixmap() );
134 buttonPixDown[i] = 0l;
135 }
136 134
137 setBackgroundPixmap( pixBg ); 135 setBackgroundPixmap( pixBg );
138 136
139 songInfo.setFocusPolicy( QWidget::NoFocus ); 137 songInfo.setFocusPolicy( QWidget::NoFocus );
140// changeTextColor( &songInfo ); 138// changeTextColor( &songInfo );
141// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 139// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
142// songInfo.setFrameStyle( QFrame::NoFrame); 140// songInfo.setFrameStyle( QFrame::NoFrame);
143 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
144// songInfo.setForegroundColor(Qt::white); 142// songInfo.setForegroundColor(Qt::white);
145 143
146 slider.setFixedHeight( 20 ); 144 slider.setFixedHeight( 20 );
147 slider.setMinValue( 0 ); 145 slider.setMinValue( 0 );
@@ -171,71 +169,65 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
171 169
172 // Intialise state 170 // Intialise state
173 setLength( mediaPlayerState.length() ); 171 setLength( mediaPlayerState.length() );
174 setPosition( mediaPlayerState.position() ); 172 setPosition( mediaPlayerState.position() );
175 setLooping( mediaPlayerState.isFullscreen() ); 173 setLooping( mediaPlayerState.isFullscreen() );
176 // setPaused( mediaPlayerState->paused() ); 174 // setPaused( mediaPlayerState->paused() );
177 setPlaying( mediaPlayerState.isPlaying() ); 175 setPlaying( mediaPlayerState.isPlaying() );
178 176
179} 177}
180 178
181AudioWidget::~AudioWidget() { 179AudioWidget::~AudioWidget() {
182 180
183 for ( int i = 0; i < 10; i++ ) {
184 delete buttonPixUp[i];
185 delete buttonPixDown[i];
186 }
187// mediaPlayerState->setPlaying(false); 181// mediaPlayerState->setPlaying(false);
188} 182}
189 183
190namespace { 184namespace {
191 185
192QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 186QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
193 QPixmap pix( img.width(), img.height() ); 187 QPixmap pix( img.width(), img.height() );
194 QPainter p( &pix ); 188 QPainter p( &pix );
195 p.drawTiledPixmap( pix.rect(), bg, offset ); 189 p.drawTiledPixmap( pix.rect(), bg, offset );
196 p.drawImage( 0, 0, img ); 190 p.drawImage( 0, 0, img );
197 return pix; 191 return pix;
198} 192}
199 193
200 194
201QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 195QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
202 QPixmap *pixmap = new QPixmap( pix ); 196 QPixmap pixmap( pix );
203 pixmap->setMask( mask ); 197 pixmap.setMask( mask );
204 return pixmap; 198 return pixmap;
205} 199}
206 200
207}; 201};
208 202
209void AudioWidget::resizeEvent( QResizeEvent * ) { 203void AudioWidget::resizeEvent( QResizeEvent * ) {
210 int h = height(); 204 int h = height();
211 int w = width(); 205 int w = width();
212 206
213 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 207 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
214 slider.setFixedWidth( w - 110 ); 208 slider.setFixedWidth( w - 110 );
215 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 209 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
216 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 210 slider.setBackgroundOrigin( QWidget::ParentOrigin );
217 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 211 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
218 212
219 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; 213 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2;
220 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; 214 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
221 QPoint p = upperLeftOfButtonMask; 215 QPoint p = upperLeftOfButtonMask;
222 216
223 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); 217 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p );
224 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); 218 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p );
225 219
226 for ( int i = 0; i < 10; i++ ) { 220 for ( int i = 0; i < 10; i++ ) {
227 if ( !masks[i].isNull() ) { 221 if ( !masks[i].isNull() ) {
228 delete buttonPixUp[i];
229 delete buttonPixDown[i];
230 buttonPixUp[i] = maskPixToMask( pixUp, masks[i] ); 222 buttonPixUp[i] = maskPixToMask( pixUp, masks[i] );
231 buttonPixDown[i] = maskPixToMask( pixDn, masks[i] ); 223 buttonPixDown[i] = maskPixToMask( pixDn, masks[i] );
232 } 224 }
233 } 225 }
234} 226}
235 227
236void AudioWidget::sliderPressed() { 228void AudioWidget::sliderPressed() {
237 audioSliderBeingMoved = TRUE; 229 audioSliderBeingMoved = TRUE;
238} 230}
239 231
240 232
241void AudioWidget::sliderReleased() { 233void AudioWidget::sliderReleased() {
@@ -323,27 +315,27 @@ void AudioWidget::updateSlider( long i, long max ) {
323} 315}
324 316
325 317
326void AudioWidget::setToggleButton( int i, bool down ) { 318void AudioWidget::setToggleButton( int i, bool down ) {
327 qDebug("setToggleButton %d", i); 319 qDebug("setToggleButton %d", i);
328 if ( down != buttons[i].isDown ) { 320 if ( down != buttons[i].isDown ) {
329 toggleButton( i ); 321 toggleButton( i );
330 } 322 }
331} 323}
332 324
333void AudioWidget::paintButton( QPainter &p, int i ) { 325void AudioWidget::paintButton( QPainter &p, int i ) {
334 if ( buttons[i].isDown ) { 326 if ( buttons[i].isDown ) {
335 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 327 p.drawPixmap( upperLeftOfButtonMask, buttonPixDown[i] );
336 } else { 328 } else {
337 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 329 p.drawPixmap( upperLeftOfButtonMask, buttonPixUp[i] );
338 } 330 }
339} 331}
340 332
341 333
342void AudioWidget::skipFor() { 334void AudioWidget::skipFor() {
343 skipDirection = +1; 335 skipDirection = +1;
344 startTimer( 50 ); 336 startTimer( 50 );
345 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 337 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
346} 338}
347 339
348void AudioWidget::skipBack() { 340void AudioWidget::skipBack() {
349 skipDirection = -1; 341 skipDirection = -1;
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index bc7262c..73ce1e5 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -83,35 +83,35 @@ protected:
83 void resizeEvent( QResizeEvent *re ); 83 void resizeEvent( QResizeEvent *re );
84 void mouseMoveEvent( QMouseEvent *event ); 84 void mouseMoveEvent( QMouseEvent *event );
85 void mousePressEvent( QMouseEvent *event ); 85 void mousePressEvent( QMouseEvent *event );
86 void mouseReleaseEvent( QMouseEvent *event ); 86 void mouseReleaseEvent( QMouseEvent *event );
87 void timerEvent( QTimerEvent *event ); 87 void timerEvent( QTimerEvent *event );
88 void keyReleaseEvent( QKeyEvent *e); 88 void keyReleaseEvent( QKeyEvent *e);
89private slots: 89private slots:
90 void skipFor(); 90 void skipFor();
91 void skipBack(); 91 void skipBack();
92 void stopSkip(); 92 void stopSkip();
93private: 93private:
94 typedef std::vector<QBitmap> MaskVector; 94 typedef std::vector<QBitmap> MaskVector;
95 typedef std::vector<QPixmap> PixmapVector;
95 96
96 void setToggleButton( int, bool ); 97 void setToggleButton( int, bool );
97 virtual void paintButton( QPainter &p, int i ); 98 virtual void paintButton( QPainter &p, int i );
98 int skipDirection; 99 int skipDirection;
99 QString skin; 100 QString skin;
100 QPixmap pixBg; 101 QPixmap pixBg;
101 QImage imgUp; 102 QImage imgUp;
102 QImage imgDn; 103 QImage imgDn;
103 MaskVector masks; 104 MaskVector masks;
104 QPixmap *buttonPixUp[10]; 105 PixmapVector buttonPixUp;
105 QPixmap *buttonPixDown[10]; 106 PixmapVector buttonPixDown;
106 107
107 QPixmap *pixmaps[4];
108 OTicker songInfo; 108 OTicker songInfo;
109 QSlider slider; 109 QSlider slider;
110 QLineEdit time; 110 QLineEdit time;
111 bool isStreaming : 1; 111 bool isStreaming : 1;
112 bool audioSliderBeingMoved : 1; 112 bool audioSliderBeingMoved : 1;
113}; 113};
114 114
115 115
116#endif // AUDIO_WIDGET_H 116#endif // AUDIO_WIDGET_H
117 117