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
@@ -108,146 +108,138 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
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 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 110 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
111 buttonMask.fill( 0 ); 111 buttonMask.fill( 0 );
112 112
113 masks.reserve( 10 ); 113 masks.reserve( 10 );
114 114
115 for ( uint i = 0; i < masks.capacity(); i++ ) { 115 for ( uint i = 0; i < masks.capacity(); i++ ) {
116 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); 116 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
117 masks.push_back( QBitmap( filename ) ); 117 masks.push_back( QBitmap( filename ) );
118 118
119 if ( !masks[i].isNull() ) { 119 if ( !masks[i].isNull() ) {
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 );
148 slider.setMaxValue( 1 ); 146 slider.setMaxValue( 1 );
149 slider.setFocusPolicy( QWidget::NoFocus ); 147 slider.setFocusPolicy( QWidget::NoFocus );
150 slider.setBackgroundPixmap( pixBg ); 148 slider.setBackgroundPixmap( pixBg );
151 149
152// Config cofg("qpe"); 150// Config cofg("qpe");
153// cofg.setGroup("Appearance"); 151// cofg.setGroup("Appearance");
154// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
155 153
156 time.setFocusPolicy( QWidget::NoFocus ); 154 time.setFocusPolicy( QWidget::NoFocus );
157 time.setAlignment( Qt::AlignCenter ); 155 time.setAlignment( Qt::AlignCenter );
158 156
159// time.setFrame(FALSE); 157// time.setFrame(FALSE);
160// changeTextColor( &time ); 158// changeTextColor( &time );
161 159
162 resizeEvent( NULL ); 160 resizeEvent( NULL );
163 161
164 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 162 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
165 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 163 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
166 164
167 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 165 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
168 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 166 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
169 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 167 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
170 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 168 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
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() {
242 audioSliderBeingMoved = FALSE; 234 audioSliderBeingMoved = FALSE;
243 if ( slider.width() == 0 ) 235 if ( slider.width() == 0 )
244 return; 236 return;
245 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 237 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
246 mediaPlayerState.setPosition( val ); 238 mediaPlayerState.setPosition( val );
247} 239}
248 240
249void AudioWidget::setPosition( long i ) { 241void AudioWidget::setPosition( long i ) {
250 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 242 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
251 updateSlider( i, mediaPlayerState.length() ); 243 updateSlider( i, mediaPlayerState.length() );
252} 244}
253 245
@@ -311,51 +303,51 @@ void AudioWidget::updateSlider( long i, long max ) {
311 // Scale to something reasonable 303 // Scale to something reasonable
312 int width = slider.width(); 304 int width = slider.width();
313 int val = int((double)i * width / max); 305 int val = int((double)i * width / max);
314 if ( !audioSliderBeingMoved ) { 306 if ( !audioSliderBeingMoved ) {
315 if ( slider.value() != val ) { 307 if ( slider.value() != val ) {
316 slider.setValue( val ); 308 slider.setValue( val );
317 } 309 }
318 310
319 if ( slider.maxValue() != width ) { 311 if ( slider.maxValue() != width ) {
320 slider.setMaxValue( width ); 312 slider.setMaxValue( width );
321 } 313 }
322 } 314 }
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;
350 startTimer( 50 ); 342 startTimer( 50 );
351 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 343 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
352} 344}
353 345
354 346
355 347
356void AudioWidget::stopSkip() { 348void AudioWidget::stopSkip() {
357 killTimers(); 349 killTimers();
358} 350}
359 351
360 352
361void AudioWidget::timerEvent( QTimerEvent * ) { 353void AudioWidget::timerEvent( QTimerEvent * ) {
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
@@ -71,47 +71,47 @@ public:
71signals: 71signals:
72 void moreClicked(); 72 void moreClicked();
73 void lessClicked(); 73 void lessClicked();
74 void forwardClicked(); 74 void forwardClicked();
75 void backClicked(); 75 void backClicked();
76 void sliderMoved(long); 76 void sliderMoved(long);
77 77
78protected: 78protected:
79 void doBlank(); 79 void doBlank();
80 void doUnblank(); 80 void doUnblank();
81 void paintEvent( QPaintEvent *pe ); 81 void paintEvent( QPaintEvent *pe );
82 void showEvent( QShowEvent *se ); 82 void showEvent( QShowEvent *se );
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