author | simon <simon> | 2002-12-09 13:24:25 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 13:24:25 (UTC) |
commit | 235ef0e11bfd61c0debb530de8598ae38a396914 (patch) (unidiff) | |
tree | ee014a888c1130707fadd890d2cc4fa492ed01cb | |
parent | 94a4c102d20eb63104a66fd8fba141a716ae3623 (diff) | |
download | opie-235ef0e11bfd61c0debb530de8598ae38a396914.zip opie-235ef0e11bfd61c0debb530de8598ae38a396914.tar.gz opie-235ef0e11bfd61c0debb530de8598ae38a396914.tar.bz2 |
- one global variable less
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 |
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 8f34736..adef247 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -27,97 +27,99 @@ | |||
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 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
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 | ||
53 | namespace | 53 | namespace |
54 | { | 54 | { |
55 | 55 | ||
56 | const int xo = -2; // movable x offset | 56 | const int xo = -2; // movable x offset |
57 | const int yo = 22; // movable y offset | 57 | const int yo = 22; // movable y offset |
58 | 58 | ||
59 | const char * const skin_mask_file_names[10] = { | 59 | const char * const skin_mask_file_names[10] = { |
60 | "play", "stop", "next", "prev", "up", | 60 | "play", "stop", "next", "prev", "up", |
61 | "down", "loop", "playlist", "forward", "back" | 61 | "down", "loop", "playlist", "forward", "back" |
62 | }; | 62 | }; |
63 | 63 | ||
64 | void changeTextColor( QWidget * w) { | 64 | void changeTextColor( QWidget * w) { |
65 | QPalette p = w->palette(); | 65 | QPalette p = w->palette(); |
66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
68 | w->setPalette( p ); | 68 | w->setPalette( p ); |
69 | } | 69 | } |
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
74 | 74 | ||
75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
76 | audioSliderBeingMoved( false ) | ||
77 | { | ||
76 | 78 | ||
77 | Button defaultButton; | 79 | Button defaultButton; |
78 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | 80 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; |
79 | Button toggleButton; | 81 | Button toggleButton; |
80 | toggleButton.isToggle = true; | 82 | toggleButton.isToggle = true; |
81 | toggleButton.isHeld = toggleButton.isDown = false; | 83 | toggleButton.isHeld = toggleButton.isDown = false; |
82 | 84 | ||
83 | buttons.reserve( 10 ); | 85 | buttons.reserve( 10 ); |
84 | buttons.push_back( toggleButton ); // play | 86 | buttons.push_back( toggleButton ); // play |
85 | buttons.push_back( defaultButton ); // stop | 87 | buttons.push_back( defaultButton ); // stop |
86 | buttons.push_back( defaultButton ); // next | 88 | buttons.push_back( defaultButton ); // next |
87 | buttons.push_back( defaultButton ); // previous | 89 | buttons.push_back( defaultButton ); // previous |
88 | buttons.push_back( defaultButton ); // volume up | 90 | buttons.push_back( defaultButton ); // volume up |
89 | buttons.push_back( defaultButton ); // volume down | 91 | buttons.push_back( defaultButton ); // volume down |
90 | buttons.push_back( toggleButton ); // repeat/loop | 92 | buttons.push_back( toggleButton ); // repeat/loop |
91 | buttons.push_back( defaultButton ); // playlist | 93 | buttons.push_back( defaultButton ); // playlist |
92 | buttons.push_back( defaultButton ); // forward | 94 | buttons.push_back( defaultButton ); // forward |
93 | buttons.push_back( defaultButton ); // back | 95 | buttons.push_back( defaultButton ); // back |
94 | 96 | ||
95 | setCaption( tr("OpiePlayer") ); | 97 | setCaption( tr("OpiePlayer") ); |
96 | 98 | ||
97 | Config cfg("OpiePlayer"); | 99 | Config cfg("OpiePlayer"); |
98 | cfg.setGroup("Options"); | 100 | cfg.setGroup("Options"); |
99 | skin = cfg.readEntry("Skin","default"); | 101 | skin = cfg.readEntry("Skin","default"); |
100 | //skin = "scaleTest"; | 102 | //skin = "scaleTest"; |
101 | // color of background, frame, degree of transparency | 103 | // color of background, frame, degree of transparency |
102 | 104 | ||
103 | QString skinPath = "opieplayer2/skins/" + skin; | 105 | QString skinPath = "opieplayer2/skins/" + skin; |
104 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 106 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
105 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 107 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
106 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 108 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
107 | 109 | ||
108 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 110 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
109 | buttonMask.fill( 0 ); | 111 | buttonMask.fill( 0 ); |
110 | 112 | ||
111 | for ( int i = 0; i < 10; i++ ) { | 113 | for ( int i = 0; i < 10; i++ ) { |
112 | 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" ); |
113 | masks[i] = new QBitmap( filename ); | 115 | masks[i] = new QBitmap( filename ); |
114 | 116 | ||
115 | if ( !masks[i]->isNull() ) { | 117 | if ( !masks[i]->isNull() ) { |
116 | QImage imgMask = masks[i]->convertToImage(); | 118 | QImage imgMask = masks[i]->convertToImage(); |
117 | uchar **dest = buttonMask.jumpTable(); | 119 | uchar **dest = buttonMask.jumpTable(); |
118 | for ( int y = 0; y < imgUp.height(); y++ ) { | 120 | for ( int y = 0; y < imgUp.height(); y++ ) { |
119 | uchar *line = dest[y]; | 121 | uchar *line = dest[y]; |
120 | for ( int x = 0; x < imgUp.width(); x++ ) | 122 | for ( int x = 0; x < imgUp.width(); x++ ) |
121 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 123 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
122 | line[x] = i + 1; | 124 | line[x] = i + 1; |
123 | } | 125 | } |
@@ -187,99 +189,96 @@ AudioWidget::~AudioWidget() { | |||
187 | } | 189 | } |
188 | 190 | ||
189 | namespace { | 191 | namespace { |
190 | 192 | ||
191 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 193 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
192 | QPixmap pix( img.width(), img.height() ); | 194 | QPixmap pix( img.width(), img.height() ); |
193 | QPainter p( &pix ); | 195 | QPainter p( &pix ); |
194 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 196 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
195 | p.drawImage( 0, 0, img ); | 197 | p.drawImage( 0, 0, img ); |
196 | return pix; | 198 | return pix; |
197 | } | 199 | } |
198 | 200 | ||
199 | 201 | ||
200 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 202 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
201 | QPixmap *pixmap = new QPixmap( pix ); | 203 | QPixmap *pixmap = new QPixmap( pix ); |
202 | pixmap->setMask( mask ); | 204 | pixmap->setMask( mask ); |
203 | return pixmap; | 205 | return pixmap; |
204 | } | 206 | } |
205 | 207 | ||
206 | }; | 208 | }; |
207 | 209 | ||
208 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 210 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
209 | int h = height(); | 211 | int h = height(); |
210 | int w = width(); | 212 | int w = width(); |
211 | 213 | ||
212 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 214 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
213 | slider.setFixedWidth( w - 110 ); | 215 | slider.setFixedWidth( w - 110 ); |
214 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 216 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
215 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 217 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
216 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 218 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
217 | 219 | ||
218 | upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; | 220 | upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; |
219 | upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; | 221 | upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; |
220 | QPoint p = upperLeftOfButtonMask; | 222 | QPoint p = upperLeftOfButtonMask; |
221 | 223 | ||
222 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); | 224 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); |
223 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); | 225 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); |
224 | 226 | ||
225 | for ( int i = 0; i < 10; i++ ) { | 227 | for ( int i = 0; i < 10; i++ ) { |
226 | if ( !masks[i]->isNull() ) { | 228 | if ( !masks[i]->isNull() ) { |
227 | delete buttonPixUp[i]; | 229 | delete buttonPixUp[i]; |
228 | delete buttonPixDown[i]; | 230 | delete buttonPixDown[i]; |
229 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); | 231 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); |
230 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); | 232 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); |
231 | } | 233 | } |
232 | } | 234 | } |
233 | } | 235 | } |
234 | 236 | ||
235 | static bool audioSliderBeingMoved = FALSE; | ||
236 | |||
237 | |||
238 | void AudioWidget::sliderPressed() { | 237 | void AudioWidget::sliderPressed() { |
239 | audioSliderBeingMoved = TRUE; | 238 | audioSliderBeingMoved = TRUE; |
240 | } | 239 | } |
241 | 240 | ||
242 | 241 | ||
243 | void AudioWidget::sliderReleased() { | 242 | void AudioWidget::sliderReleased() { |
244 | audioSliderBeingMoved = FALSE; | 243 | audioSliderBeingMoved = FALSE; |
245 | if ( slider.width() == 0 ) | 244 | if ( slider.width() == 0 ) |
246 | return; | 245 | return; |
247 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 246 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
248 | mediaPlayerState.setPosition( val ); | 247 | mediaPlayerState.setPosition( val ); |
249 | } | 248 | } |
250 | 249 | ||
251 | void AudioWidget::setPosition( long i ) { | 250 | void AudioWidget::setPosition( long i ) { |
252 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 251 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
253 | updateSlider( i, mediaPlayerState.length() ); | 252 | updateSlider( i, mediaPlayerState.length() ); |
254 | } | 253 | } |
255 | 254 | ||
256 | 255 | ||
257 | void AudioWidget::setLength( long max ) { | 256 | void AudioWidget::setLength( long max ) { |
258 | updateSlider( mediaPlayerState.position(), max ); | 257 | updateSlider( mediaPlayerState.position(), max ); |
259 | } | 258 | } |
260 | 259 | ||
261 | 260 | ||
262 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 261 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
263 | if ( mediaType == MediaPlayerState::Audio ) { | 262 | if ( mediaType == MediaPlayerState::Audio ) { |
264 | // startTimer( 150 ); | 263 | // startTimer( 150 ); |
265 | showMaximized(); | 264 | showMaximized(); |
266 | return; | 265 | return; |
267 | } | 266 | } |
268 | 267 | ||
269 | killTimers(); | 268 | killTimers(); |
270 | hide(); | 269 | hide(); |
271 | } | 270 | } |
272 | 271 | ||
273 | 272 | ||
274 | void AudioWidget::setSeekable( bool isSeekable ) { | 273 | void AudioWidget::setSeekable( bool isSeekable ) { |
275 | 274 | ||
276 | if ( !isSeekable ) { | 275 | if ( !isSeekable ) { |
277 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 276 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
278 | if( !slider.isHidden()) { | 277 | if( !slider.isHidden()) { |
279 | slider.hide(); | 278 | slider.hide(); |
280 | } | 279 | } |
281 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 280 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
282 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 281 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
283 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 282 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
284 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 283 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
285 | } else { | 284 | } else { |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 4598d51..8426490 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -62,53 +62,54 @@ public slots: | |||
62 | void setLooping( bool b) { setToggleButton( Loop, b ); } | 62 | void setLooping( bool b) { setToggleButton( Loop, b ); } |
63 | void setPosition( long ); | 63 | void setPosition( long ); |
64 | void setSeekable( bool ); | 64 | void setSeekable( bool ); |
65 | 65 | ||
66 | public: | 66 | public: |
67 | virtual void setLength( long ); | 67 | virtual void setLength( long ); |
68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } | 68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } |
69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
70 | 70 | ||
71 | signals: | 71 | signals: |
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 | ||
78 | protected: | 78 | protected: |
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); |
89 | private slots: | 89 | private slots: |
90 | void skipFor(); | 90 | void skipFor(); |
91 | void skipBack(); | 91 | void skipBack(); |
92 | void stopSkip(); | 92 | void stopSkip(); |
93 | private: | 93 | private: |
94 | void setToggleButton( int, bool ); | 94 | void setToggleButton( int, bool ); |
95 | virtual void paintButton( QPainter &p, int i ); | 95 | virtual void paintButton( QPainter &p, int i ); |
96 | int skipDirection; | 96 | int skipDirection; |
97 | QString skin; | 97 | QString skin; |
98 | QPixmap pixBg; | 98 | QPixmap pixBg; |
99 | QImage imgUp; | 99 | QImage imgUp; |
100 | QImage imgDn; | 100 | QImage imgDn; |
101 | QBitmap *masks[10]; | 101 | QBitmap *masks[10]; |
102 | QPixmap *buttonPixUp[10]; | 102 | QPixmap *buttonPixUp[10]; |
103 | QPixmap *buttonPixDown[10]; | 103 | QPixmap *buttonPixDown[10]; |
104 | 104 | ||
105 | QPixmap *pixmaps[4]; | 105 | QPixmap *pixmaps[4]; |
106 | OTicker songInfo; | 106 | OTicker songInfo; |
107 | QSlider slider; | 107 | QSlider slider; |
108 | QLineEdit time; | 108 | QLineEdit time; |
109 | bool isStreaming : 1; | 109 | bool isStreaming : 1; |
110 | bool audioSliderBeingMoved : 1; | ||
110 | }; | 111 | }; |
111 | 112 | ||
112 | 113 | ||
113 | #endif // AUDIO_WIDGET_H | 114 | #endif // AUDIO_WIDGET_H |
114 | 115 | ||