author | simon <simon> | 2002-12-09 15:57:34 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 15:57:34 (UTC) |
commit | f676d71c1fe40539ceb0c0708fdaefcc9b5e1800 (patch) (unidiff) | |
tree | 5298119bdbd8bffafcd1a31aed1c6fbcb908d3bc | |
parent | 743155915f659d701ad468eadcc2b2173b6e2770 (diff) | |
download | opie-f676d71c1fe40539ceb0c0708fdaefcc9b5e1800.zip opie-f676d71c1fe40539ceb0c0708fdaefcc9b5e1800.tar.gz opie-f676d71c1fe40539ceb0c0708fdaefcc9b5e1800.tar.bz2 |
- back to a vector :P
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 16 |
4 files changed, 19 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 714509e..c3e206c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -59,201 +59,202 @@ const int yo = 22; // movable y offset | |||
59 | const MediaWidget::SkinButtonInfo skinInfo[] = | 59 | const MediaWidget::SkinButtonInfo skinInfo[] = |
60 | { | 60 | { |
61 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 61 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
62 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 62 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
63 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, | 63 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, |
64 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, | 64 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, |
65 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 65 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
66 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 66 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
67 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, | 67 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, |
68 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, | 68 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, |
69 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, | 69 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, |
70 | { MediaWidget::Back, "back", MediaWidget::NormalButton } | 70 | { MediaWidget::Back, "back", MediaWidget::NormalButton } |
71 | }; | 71 | }; |
72 | 72 | ||
73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
74 | 74 | ||
75 | void changeTextColor( QWidget * w) { | 75 | void changeTextColor( QWidget * w) { |
76 | QPalette p = w->palette(); | 76 | QPalette p = w->palette(); |
77 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 77 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
78 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 78 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
79 | w->setPalette( p ); | 79 | w->setPalette( p ); |
80 | } | 80 | } |
81 | 81 | ||
82 | } | 82 | } |
83 | 83 | ||
84 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 84 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
85 | 85 | ||
86 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 86 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
87 | audioSliderBeingMoved( false ) | 87 | audioSliderBeingMoved( false ) |
88 | { | 88 | { |
89 | setCaption( tr("OpiePlayer") ); | 89 | setCaption( tr("OpiePlayer") ); |
90 | 90 | ||
91 | Config cfg("OpiePlayer"); | 91 | Config cfg("OpiePlayer"); |
92 | cfg.setGroup("Options"); | 92 | cfg.setGroup("Options"); |
93 | skin = cfg.readEntry("Skin","default"); | 93 | skin = cfg.readEntry("Skin","default"); |
94 | //skin = "scaleTest"; | 94 | //skin = "scaleTest"; |
95 | // color of background, frame, degree of transparency | 95 | // color of background, frame, degree of transparency |
96 | 96 | ||
97 | QString skinPath = "opieplayer2/skins/" + skin; | 97 | QString skinPath = "opieplayer2/skins/" + skin; |
98 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 98 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
99 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 99 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
100 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 100 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
101 | 101 | ||
102 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 102 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
103 | buttonMask.fill( 0 ); | 103 | buttonMask.fill( 0 ); |
104 | 104 | ||
105 | for ( uint i = 0; i < buttonCount; i++ ) { | 105 | for ( uint i = 0; i < buttonCount; i++ ) { |
106 | Button button; | 106 | Button button; |
107 | button.command = skinInfo[ i ].command; | ||
107 | button.type = skinInfo[ i ].type; | 108 | button.type = skinInfo[ i ].type; |
108 | 109 | ||
109 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); | 110 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); |
110 | button.mask =QBitmap( filename ); | 111 | button.mask =QBitmap( filename ); |
111 | 112 | ||
112 | if ( !button.mask.isNull() ) { | 113 | if ( !button.mask.isNull() ) { |
113 | QImage imgMask = button.mask.convertToImage(); | 114 | QImage imgMask = button.mask.convertToImage(); |
114 | uchar **dest = buttonMask.jumpTable(); | 115 | uchar **dest = buttonMask.jumpTable(); |
115 | for ( int y = 0; y < imgUp.height(); y++ ) { | 116 | for ( int y = 0; y < imgUp.height(); y++ ) { |
116 | uchar *line = dest[y]; | 117 | uchar *line = dest[y]; |
117 | for ( int x = 0; x < imgUp.width(); x++ ) | 118 | for ( int x = 0; x < imgUp.width(); x++ ) |
118 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 119 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
119 | line[x] = i + 1; | 120 | line[x] = i + 1; |
120 | } | 121 | } |
121 | } | 122 | } |
122 | 123 | ||
123 | buttons.insert( i, button ); | 124 | buttons.push_back( button ); |
124 | } | 125 | } |
125 | 126 | ||
126 | setBackgroundPixmap( backgroundPixmap ); | 127 | setBackgroundPixmap( backgroundPixmap ); |
127 | 128 | ||
128 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 129 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
129 | // changeTextColor( &songInfo ); | 130 | // changeTextColor( &songInfo ); |
130 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 131 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
131 | // songInfo.setFrameStyle( QFrame::NoFrame); | 132 | // songInfo.setFrameStyle( QFrame::NoFrame); |
132 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 133 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
133 | // songInfo.setForegroundColor(Qt::white); | 134 | // songInfo.setForegroundColor(Qt::white); |
134 | 135 | ||
135 | slider.setFixedHeight( 20 ); | 136 | slider.setFixedHeight( 20 ); |
136 | slider.setMinValue( 0 ); | 137 | slider.setMinValue( 0 ); |
137 | slider.setMaxValue( 1 ); | 138 | slider.setMaxValue( 1 ); |
138 | slider.setFocusPolicy( QWidget::NoFocus ); | 139 | slider.setFocusPolicy( QWidget::NoFocus ); |
139 | slider.setBackgroundPixmap( backgroundPixmap ); | 140 | slider.setBackgroundPixmap( backgroundPixmap ); |
140 | 141 | ||
141 | // Config cofg("qpe"); | 142 | // Config cofg("qpe"); |
142 | // cofg.setGroup("Appearance"); | 143 | // cofg.setGroup("Appearance"); |
143 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 144 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
144 | 145 | ||
145 | time.setFocusPolicy( QWidget::NoFocus ); | 146 | time.setFocusPolicy( QWidget::NoFocus ); |
146 | time.setAlignment( Qt::AlignCenter ); | 147 | time.setAlignment( Qt::AlignCenter ); |
147 | 148 | ||
148 | // time.setFrame(FALSE); | 149 | // time.setFrame(FALSE); |
149 | // changeTextColor( &time ); | 150 | // changeTextColor( &time ); |
150 | 151 | ||
151 | resizeEvent( NULL ); | 152 | resizeEvent( NULL ); |
152 | 153 | ||
153 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 154 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
154 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 155 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
155 | 156 | ||
156 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 157 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
157 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 158 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
158 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 159 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
159 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 160 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
160 | 161 | ||
161 | // Intialise state | 162 | // Intialise state |
162 | setLength( mediaPlayerState.length() ); | 163 | setLength( mediaPlayerState.length() ); |
163 | setPosition( mediaPlayerState.position() ); | 164 | setPosition( mediaPlayerState.position() ); |
164 | setLooping( mediaPlayerState.isFullscreen() ); | 165 | setLooping( mediaPlayerState.isFullscreen() ); |
165 | // setPaused( mediaPlayerState->paused() ); | 166 | // setPaused( mediaPlayerState->paused() ); |
166 | setPlaying( mediaPlayerState.isPlaying() ); | 167 | setPlaying( mediaPlayerState.isPlaying() ); |
167 | 168 | ||
168 | } | 169 | } |
169 | 170 | ||
170 | AudioWidget::~AudioWidget() { | 171 | AudioWidget::~AudioWidget() { |
171 | 172 | ||
172 | // mediaPlayerState->setPlaying(false); | 173 | // mediaPlayerState->setPlaying(false); |
173 | } | 174 | } |
174 | 175 | ||
175 | namespace { | 176 | namespace { |
176 | 177 | ||
177 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 178 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
178 | QPixmap pix( img.width(), img.height() ); | 179 | QPixmap pix( img.width(), img.height() ); |
179 | QPainter p( &pix ); | 180 | QPainter p( &pix ); |
180 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 181 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
181 | p.drawImage( 0, 0, img ); | 182 | p.drawImage( 0, 0, img ); |
182 | return pix; | 183 | return pix; |
183 | } | 184 | } |
184 | 185 | ||
185 | 186 | ||
186 | QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { | 187 | QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { |
187 | QPixmap pixmap( pix ); | 188 | QPixmap pixmap( pix ); |
188 | pixmap.setMask( mask ); | 189 | pixmap.setMask( mask ); |
189 | return pixmap; | 190 | return pixmap; |
190 | } | 191 | } |
191 | 192 | ||
192 | }; | 193 | }; |
193 | 194 | ||
194 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 195 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
195 | int h = height(); | 196 | int h = height(); |
196 | int w = width(); | 197 | int w = width(); |
197 | 198 | ||
198 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 199 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
199 | slider.setFixedWidth( w - 110 ); | 200 | slider.setFixedWidth( w - 110 ); |
200 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 201 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
201 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 202 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
202 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 203 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
203 | 204 | ||
204 | upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; | 205 | upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; |
205 | upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; | 206 | upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; |
206 | QPoint p = upperLeftOfButtonMask; | 207 | QPoint p = upperLeftOfButtonMask; |
207 | 208 | ||
208 | QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p ); | 209 | QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p ); |
209 | QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p ); | 210 | QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p ); |
210 | 211 | ||
211 | for ( uint i = 0; i < buttons.count(); i++ ) { | 212 | for ( uint i = 0; i < buttons.size(); i++ ) { |
212 | if ( !buttons[i].mask.isNull() ) { | 213 | if ( !buttons[i].mask.isNull() ) { |
213 | buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); | 214 | buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); |
214 | buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); | 215 | buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); |
215 | } | 216 | } |
216 | } | 217 | } |
217 | } | 218 | } |
218 | 219 | ||
219 | void AudioWidget::sliderPressed() { | 220 | void AudioWidget::sliderPressed() { |
220 | audioSliderBeingMoved = TRUE; | 221 | audioSliderBeingMoved = TRUE; |
221 | } | 222 | } |
222 | 223 | ||
223 | 224 | ||
224 | void AudioWidget::sliderReleased() { | 225 | void AudioWidget::sliderReleased() { |
225 | audioSliderBeingMoved = FALSE; | 226 | audioSliderBeingMoved = FALSE; |
226 | if ( slider.width() == 0 ) | 227 | if ( slider.width() == 0 ) |
227 | return; | 228 | return; |
228 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 229 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
229 | mediaPlayerState.setPosition( val ); | 230 | mediaPlayerState.setPosition( val ); |
230 | } | 231 | } |
231 | 232 | ||
232 | void AudioWidget::setPosition( long i ) { | 233 | void AudioWidget::setPosition( long i ) { |
233 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 234 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
234 | updateSlider( i, mediaPlayerState.length() ); | 235 | updateSlider( i, mediaPlayerState.length() ); |
235 | } | 236 | } |
236 | 237 | ||
237 | 238 | ||
238 | void AudioWidget::setLength( long max ) { | 239 | void AudioWidget::setLength( long max ) { |
239 | updateSlider( mediaPlayerState.position(), max ); | 240 | updateSlider( mediaPlayerState.position(), max ); |
240 | } | 241 | } |
241 | 242 | ||
242 | 243 | ||
243 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 244 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
244 | if ( mediaType == MediaPlayerState::Audio ) { | 245 | if ( mediaType == MediaPlayerState::Audio ) { |
245 | // startTimer( 150 ); | 246 | // startTimer( 150 ); |
246 | showMaximized(); | 247 | showMaximized(); |
247 | return; | 248 | return; |
248 | } | 249 | } |
249 | 250 | ||
250 | killTimers(); | 251 | killTimers(); |
251 | hide(); | 252 | hide(); |
252 | } | 253 | } |
253 | 254 | ||
254 | 255 | ||
255 | void AudioWidget::setSeekable( bool isSeekable ) { | 256 | void AudioWidget::setSeekable( bool isSeekable ) { |
256 | 257 | ||
257 | if ( !isSeekable ) { | 258 | if ( !isSeekable ) { |
258 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 259 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
259 | if( !slider.isHidden()) { | 260 | if( !slider.isHidden()) { |
@@ -289,97 +290,97 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
289 | 290 | ||
290 | if ( max == 0 ) { | 291 | if ( max == 0 ) { |
291 | return; | 292 | return; |
292 | } | 293 | } |
293 | // Will flicker too much if we don't do this | 294 | // Will flicker too much if we don't do this |
294 | // Scale to something reasonable | 295 | // Scale to something reasonable |
295 | int width = slider.width(); | 296 | int width = slider.width(); |
296 | int val = int((double)i * width / max); | 297 | int val = int((double)i * width / max); |
297 | if ( !audioSliderBeingMoved ) { | 298 | if ( !audioSliderBeingMoved ) { |
298 | if ( slider.value() != val ) { | 299 | if ( slider.value() != val ) { |
299 | slider.setValue( val ); | 300 | slider.setValue( val ); |
300 | } | 301 | } |
301 | 302 | ||
302 | if ( slider.maxValue() != width ) { | 303 | if ( slider.maxValue() != width ) { |
303 | slider.setMaxValue( width ); | 304 | slider.setMaxValue( width ); |
304 | } | 305 | } |
305 | } | 306 | } |
306 | } | 307 | } |
307 | 308 | ||
308 | void AudioWidget::skipFor() { | 309 | void AudioWidget::skipFor() { |
309 | skipDirection = +1; | 310 | skipDirection = +1; |
310 | startTimer( 50 ); | 311 | startTimer( 50 ); |
311 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 312 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
312 | } | 313 | } |
313 | 314 | ||
314 | void AudioWidget::skipBack() { | 315 | void AudioWidget::skipBack() { |
315 | skipDirection = -1; | 316 | skipDirection = -1; |
316 | startTimer( 50 ); | 317 | startTimer( 50 ); |
317 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 318 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
318 | } | 319 | } |
319 | 320 | ||
320 | 321 | ||
321 | 322 | ||
322 | void AudioWidget::stopSkip() { | 323 | void AudioWidget::stopSkip() { |
323 | killTimers(); | 324 | killTimers(); |
324 | } | 325 | } |
325 | 326 | ||
326 | 327 | ||
327 | void AudioWidget::timerEvent( QTimerEvent * ) { | 328 | void AudioWidget::timerEvent( QTimerEvent * ) { |
328 | if ( skipDirection == +1 ) { | 329 | if ( skipDirection == +1 ) { |
329 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 330 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
330 | } else if ( skipDirection == -1 ) { | 331 | } else if ( skipDirection == -1 ) { |
331 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 332 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
332 | } | 333 | } |
333 | } | 334 | } |
334 | 335 | ||
335 | 336 | ||
336 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 337 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
337 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 338 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
338 | 339 | ||
339 | Button &button = buttons[ i ]; | 340 | Button &button = buttons[ i ]; |
340 | 341 | ||
341 | if ( event->state() == QMouseEvent::LeftButton ) { | 342 | if ( event->state() == QMouseEvent::LeftButton ) { |
342 | // The test to see if the mouse click is inside the button or not | 343 | // The test to see if the mouse click is inside the button or not |
343 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 344 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
344 | 345 | ||
345 | if ( isOnButton && !button.isHeld ) { | 346 | if ( isOnButton && !button.isHeld ) { |
346 | button.isHeld = TRUE; | 347 | button.isHeld = TRUE; |
347 | toggleButton( button ); | 348 | toggleButton( button ); |
348 | switch (i) { | 349 | switch (i) { |
349 | case VolumeUp: | 350 | case VolumeUp: |
350 | emit moreClicked(); | 351 | emit moreClicked(); |
351 | return; | 352 | return; |
352 | case VolumeDown: | 353 | case VolumeDown: |
353 | emit lessClicked(); | 354 | emit lessClicked(); |
354 | return; | 355 | return; |
355 | case Forward: | 356 | case Forward: |
356 | emit forwardClicked(); | 357 | emit forwardClicked(); |
357 | return; | 358 | return; |
358 | case Back: | 359 | case Back: |
359 | emit backClicked(); | 360 | emit backClicked(); |
360 | return; | 361 | return; |
361 | } | 362 | } |
362 | } else if ( !isOnButton && button.isHeld ) { | 363 | } else if ( !isOnButton && button.isHeld ) { |
363 | button.isHeld = FALSE; | 364 | button.isHeld = FALSE; |
364 | toggleButton( button ); | 365 | toggleButton( button ); |
365 | } | 366 | } |
366 | } else { | 367 | } else { |
367 | if ( button.isHeld ) { | 368 | if ( button.isHeld ) { |
368 | button.isHeld = FALSE; | 369 | button.isHeld = FALSE; |
369 | if ( button.type != ToggleButton ) { | 370 | if ( button.type != ToggleButton ) { |
370 | setToggleButton( button, FALSE ); | 371 | setToggleButton( button, FALSE ); |
371 | } | 372 | } |
372 | qDebug("mouseEvent %d", i); | 373 | qDebug("mouseEvent %d", i); |
373 | handleCommand( static_cast<Command>( i ), button.isDown ); | 374 | handleCommand( static_cast<Command>( i ), button.isDown ); |
374 | } | 375 | } |
375 | } | 376 | } |
376 | } | 377 | } |
377 | } | 378 | } |
378 | 379 | ||
379 | 380 | ||
380 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 381 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
381 | mouseMoveEvent( event ); | 382 | mouseMoveEvent( event ); |
382 | } | 383 | } |
383 | 384 | ||
384 | 385 | ||
385 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 386 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 66129c9..7891a7e 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -37,95 +37,96 @@ MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPla | |||
37 | 37 | ||
38 | MediaWidget::~MediaWidget() | 38 | MediaWidget::~MediaWidget() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | void MediaWidget::closeEvent( QCloseEvent * ) | 42 | void MediaWidget::closeEvent( QCloseEvent * ) |
43 | { | 43 | { |
44 | mediaPlayerState.setList(); | 44 | mediaPlayerState.setList(); |
45 | } | 45 | } |
46 | 46 | ||
47 | void MediaWidget::paintEvent( QPaintEvent *pe ) | 47 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
48 | { | 48 | { |
49 | QPainter p( this ); | 49 | QPainter p( this ); |
50 | 50 | ||
51 | if ( mediaPlayerState.isFullscreen() ) { | 51 | if ( mediaPlayerState.isFullscreen() ) { |
52 | // Clear the background | 52 | // Clear the background |
53 | p.setBrush( QBrush( Qt::black ) ); | 53 | p.setBrush( QBrush( Qt::black ) ); |
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | 56 | ||
57 | if ( !pe->erased() ) { | 57 | if ( !pe->erased() ) { |
58 | // Combine with background and double buffer | 58 | // Combine with background and double buffer |
59 | QPixmap pix( pe->rect().size() ); | 59 | QPixmap pix( pe->rect().size() ); |
60 | QPainter p( &pix ); | 60 | QPainter p( &pix ); |
61 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 61 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
62 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | 62 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); |
63 | paintAllButtons( p ); | 63 | paintAllButtons( p ); |
64 | QPainter p2( this ); | 64 | QPainter p2( this ); |
65 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 65 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
66 | } else { | 66 | } else { |
67 | QPainter p( this ); | 67 | QPainter p( this ); |
68 | paintAllButtons( p ); | 68 | paintAllButtons( p ); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 72 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
73 | { | 73 | { |
74 | switch ( command ) { | 74 | switch ( command ) { |
75 | case Play: mediaPlayerState.togglePaused(); | 75 | case Play: mediaPlayerState.togglePaused(); |
76 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 76 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
77 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 77 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
78 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 78 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
79 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 79 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
80 | case VolumeUp: emit moreReleased(); return; | 80 | case VolumeUp: emit moreReleased(); return; |
81 | case VolumeDown: emit lessReleased(); return; | 81 | case VolumeDown: emit lessReleased(); return; |
82 | case PlayList: mediaPlayerState.setList(); return; | 82 | case PlayList: mediaPlayerState.setList(); return; |
83 | case Forward: emit forwardReleased(); return; | 83 | case Forward: emit forwardReleased(); return; |
84 | case Back: emit backReleased(); return; | 84 | case Back: emit backReleased(); return; |
85 | default: assert( false ); | ||
85 | } | 86 | } |
86 | } | 87 | } |
87 | 88 | ||
88 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 89 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
89 | { | 90 | { |
90 | return ( position.x() > 0 && position.y() > 0 && | 91 | return ( position.x() > 0 && position.y() > 0 && |
91 | position.x() < buttonMask.width() && | 92 | position.x() < buttonMask.width() && |
92 | position.y() < buttonMask.height() && | 93 | position.y() < buttonMask.height() && |
93 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 94 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
94 | } | 95 | } |
95 | 96 | ||
96 | void MediaWidget::paintAllButtons( QPainter &p ) | 97 | void MediaWidget::paintAllButtons( QPainter &p ) |
97 | { | 98 | { |
98 | for ( ButtonMap::ConstIterator it = buttons.begin(); | 99 | for ( ButtonVector::const_iterator it = buttons.begin(); |
99 | it != buttons.end(); ++it ) | 100 | it != buttons.end(); ++it ) |
100 | paintButton( p, *it ); | 101 | paintButton( p, *it ); |
101 | } | 102 | } |
102 | 103 | ||
103 | void MediaWidget::paintButton( const Button &button ) | 104 | void MediaWidget::paintButton( const Button &button ) |
104 | { | 105 | { |
105 | QPainter p( this ); | 106 | QPainter p( this ); |
106 | paintButton( p, button ); | 107 | paintButton( p, button ); |
107 | } | 108 | } |
108 | 109 | ||
109 | void MediaWidget::paintButton( QPainter &p, const Button &button ) | 110 | void MediaWidget::paintButton( QPainter &p, const Button &button ) |
110 | { | 111 | { |
111 | if ( button.isDown ) | 112 | if ( button.isDown ) |
112 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | 113 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); |
113 | else | 114 | else |
114 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | 115 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); |
115 | } | 116 | } |
116 | 117 | ||
117 | void MediaWidget::setToggleButton( Button &button, bool down ) | 118 | void MediaWidget::setToggleButton( Button &button, bool down ) |
118 | { | 119 | { |
119 | if ( down != button.isDown ) | 120 | if ( down != button.isDown ) |
120 | toggleButton( button ); | 121 | toggleButton( button ); |
121 | } | 122 | } |
122 | 123 | ||
123 | void MediaWidget::toggleButton( Button &button ) | 124 | void MediaWidget::toggleButton( Button &button ) |
124 | { | 125 | { |
125 | button.isDown = !button.isDown; | 126 | button.isDown = !button.isDown; |
126 | 127 | ||
127 | paintButton( button ); | 128 | paintButton( button ); |
128 | } | 129 | } |
129 | 130 | ||
130 | /* vim: et sw=4 ts=4 | 131 | /* vim: et sw=4 ts=4 |
131 | */ | 132 | */ |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 05b7b71..efba6f3 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,111 +1,111 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
4 | (C) 2002 L. Potter <ljp@llornkcor.com> | 4 | (C) 2002 L. Potter <ljp@llornkcor.com> |
5 | (C) 2002 Holger Freyther <zecke@handhelds.org> | 5 | (C) 2002 Holger Freyther <zecke@handhelds.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #ifndef MEDIAWIDGET_H | 23 | #ifndef MEDIAWIDGET_H |
24 | #define MEDIAWIDGET_H | 24 | #define MEDIAWIDGET_H |
25 | 25 | ||
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | 28 | ||
29 | #include "mediaplayerstate.h" | 29 | #include "mediaplayerstate.h" |
30 | #include "playlistwidget.h" | 30 | #include "playlistwidget.h" |
31 | 31 | ||
32 | #include <vector> | 32 | #include <vector> |
33 | 33 | ||
34 | class MediaWidget : public QWidget | 34 | class MediaWidget : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; | 38 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, Undefined }; |
39 | enum ButtonType { NormalButton, ToggleButton }; | 39 | enum ButtonType { NormalButton, ToggleButton }; |
40 | 40 | ||
41 | struct Button | 41 | struct Button |
42 | { | 42 | { |
43 | Button() : type( NormalButton ), isHeld( false ), isDown( false ) {} | 43 | Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {} |
44 | |||
45 | Command command; | ||
44 | 46 | ||
45 | ButtonType type : 1; | 47 | ButtonType type : 1; |
46 | bool isHeld : 1; | 48 | bool isHeld : 1; |
47 | bool isDown : 1; | 49 | bool isDown : 1; |
48 | 50 | ||
49 | QBitmap mask; | 51 | QBitmap mask; |
50 | QPixmap pixUp; | 52 | QPixmap pixUp; |
51 | QPixmap pixDown; | 53 | QPixmap pixDown; |
52 | }; | 54 | }; |
53 | typedef std::vector<Button> ButtonVector; | 55 | typedef std::vector<Button> ButtonVector; |
54 | // when the transition is done this should be Command -> Button | ||
55 | typedef QMap<int, Button> ButtonMap; | ||
56 | 56 | ||
57 | struct SkinButtonInfo | 57 | struct SkinButtonInfo |
58 | { | 58 | { |
59 | Command command; | 59 | Command command; |
60 | const char *fileName; | 60 | const char *fileName; |
61 | ButtonType type; | 61 | ButtonType type; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | typedef std::vector<QBitmap> MaskVector; | 64 | typedef std::vector<QBitmap> MaskVector; |
65 | typedef std::vector<QPixmap> PixmapVector; | 65 | typedef std::vector<QPixmap> PixmapVector; |
66 | 66 | ||
67 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 67 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
68 | virtual ~MediaWidget(); | 68 | virtual ~MediaWidget(); |
69 | 69 | ||
70 | public slots: | 70 | public slots: |
71 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 71 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
72 | virtual void setLength( long length ) = 0; | 72 | virtual void setLength( long length ) = 0; |
73 | virtual void setPlaying( bool playing ) = 0; | 73 | virtual void setPlaying( bool playing ) = 0; |
74 | 74 | ||
75 | signals: | 75 | signals: |
76 | void moreReleased(); | 76 | void moreReleased(); |
77 | void lessReleased(); | 77 | void lessReleased(); |
78 | void forwardReleased(); | 78 | void forwardReleased(); |
79 | void backReleased(); | 79 | void backReleased(); |
80 | 80 | ||
81 | protected: | 81 | protected: |
82 | virtual void closeEvent( QCloseEvent * ); | 82 | virtual void closeEvent( QCloseEvent * ); |
83 | 83 | ||
84 | virtual void paintEvent( QPaintEvent *pe ); | 84 | virtual void paintEvent( QPaintEvent *pe ); |
85 | 85 | ||
86 | void handleCommand( Command command, bool buttonDown ); | 86 | void handleCommand( Command command, bool buttonDown ); |
87 | 87 | ||
88 | bool isOverButton( const QPoint &position, int buttonId ) const; | 88 | bool isOverButton( const QPoint &position, int buttonId ) const; |
89 | 89 | ||
90 | void paintAllButtons( QPainter &p ); | 90 | void paintAllButtons( QPainter &p ); |
91 | void paintButton( const Button &button ); | 91 | void paintButton( const Button &button ); |
92 | void paintButton( QPainter &p, const Button &button ); | 92 | void paintButton( QPainter &p, const Button &button ); |
93 | 93 | ||
94 | void setToggleButton( Button &button, bool down ); | 94 | void setToggleButton( Button &button, bool down ); |
95 | void toggleButton( Button &button ); | 95 | void toggleButton( Button &button ); |
96 | 96 | ||
97 | MediaPlayerState &mediaPlayerState; | 97 | MediaPlayerState &mediaPlayerState; |
98 | PlayListWidget &playList; | 98 | PlayListWidget &playList; |
99 | 99 | ||
100 | ButtonMap buttons; | 100 | ButtonVector buttons; |
101 | 101 | ||
102 | QImage buttonMask; | 102 | QImage buttonMask; |
103 | 103 | ||
104 | QPoint upperLeftOfButtonMask; | 104 | QPoint upperLeftOfButtonMask; |
105 | 105 | ||
106 | QPixmap backgroundPixmap; | 106 | QPixmap backgroundPixmap; |
107 | }; | 107 | }; |
108 | 108 | ||
109 | #endif // MEDIAWIDGET_H | 109 | #endif // MEDIAWIDGET_H |
110 | /* vim: et sw=4 ts=4 | 110 | /* vim: et sw=4 ts=4 |
111 | */ | 111 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 9782b68..f59772e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -29,103 +29,103 @@ | |||
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 | 37 | ||
38 | 38 | ||
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qpainter.h> | 40 | #include <qpainter.h> |
41 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
42 | #include <qslider.h> | 42 | #include <qslider.h> |
43 | #include <qdrawutil.h> | 43 | #include <qdrawutil.h> |
44 | #include "videowidget.h" | 44 | #include "videowidget.h" |
45 | #include "mediaplayerstate.h" | 45 | #include "mediaplayerstate.h" |
46 | #include "playlistwidget.h" | 46 | #include "playlistwidget.h" |
47 | 47 | ||
48 | 48 | ||
49 | #ifdef Q_WS_QWS | 49 | #ifdef Q_WS_QWS |
50 | # define USE_DIRECT_PAINTER | 50 | # define USE_DIRECT_PAINTER |
51 | # include <qdirectpainter_qws.h> | 51 | # include <qdirectpainter_qws.h> |
52 | # include <qgfxraster_qws.h> | 52 | # include <qgfxraster_qws.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | namespace | 56 | namespace |
57 | { | 57 | { |
58 | 58 | ||
59 | const int xo = 2; // movable x offset | 59 | const int xo = 2; // movable x offset |
60 | const int yo = 0; // movable y offset | 60 | const int yo = 0; // movable y offset |
61 | 61 | ||
62 | const char * const skinV_mask_file_names[7] = { | 62 | const char * const skinV_mask_file_names[7] = { |
63 | "play","stop","fwd","back","up","down","full" | 63 | "play","stop","fwd","back","up","down","full" |
64 | }; | 64 | }; |
65 | 65 | ||
66 | } | 66 | } |
67 | 67 | ||
68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) | 69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) |
70 | { | 70 | { |
71 | setCaption( tr("OpiePlayer - Video") ); | 71 | setCaption( tr("OpiePlayer - Video") ); |
72 | 72 | ||
73 | Button defaultButton; | 73 | Button defaultButton; |
74 | Button toggleButton = defaultButton; | 74 | Button toggleButton = defaultButton; |
75 | toggleButton.type = ToggleButton; | 75 | toggleButton.type = ToggleButton; |
76 | 76 | ||
77 | buttons.insert( 0, toggleButton ); // play | 77 | buttons.push_back( toggleButton ); // play |
78 | buttons.insert( 1, toggleButton ); // stop | 78 | buttons.push_back( toggleButton ); // stop |
79 | buttons.insert( 2, toggleButton ); // next | 79 | buttons.push_back( toggleButton ); // next |
80 | buttons.insert( 3, toggleButton ); // previous | 80 | buttons.push_back( toggleButton ); // previous |
81 | buttons.insert( 4, toggleButton ); // volUp | 81 | buttons.push_back( toggleButton ); // volUp |
82 | buttons.insert( 5, toggleButton ); // volDown | 82 | buttons.push_back( toggleButton ); // volDown |
83 | buttons.insert( 6, toggleButton ); // fullscreen | 83 | buttons.push_back( toggleButton ); // fullscreen |
84 | 84 | ||
85 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 85 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
86 | 86 | ||
87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
88 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 88 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
89 | 89 | ||
90 | Config cfg("OpiePlayer"); | 90 | Config cfg("OpiePlayer"); |
91 | cfg.setGroup("Options"); | 91 | cfg.setGroup("Options"); |
92 | skin = cfg.readEntry("Skin","default"); | 92 | skin = cfg.readEntry("Skin","default"); |
93 | 93 | ||
94 | QString skinPath = "opieplayer2/skins/" + skin; | 94 | QString skinPath = "opieplayer2/skins/" + skin; |
95 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 95 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
96 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 96 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
97 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 97 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
98 | 98 | ||
99 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 99 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
100 | buttonMask.fill( 0 ); | 100 | buttonMask.fill( 0 ); |
101 | 101 | ||
102 | for ( int i = 0; i < 7; i++ ) { | 102 | for ( int i = 0; i < 7; i++ ) { |
103 | Button &button = buttons[ i ]; | 103 | Button &button = buttons[ i ]; |
104 | 104 | ||
105 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 105 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
106 | button.mask = QBitmap( filename ); | 106 | button.mask = QBitmap( filename ); |
107 | 107 | ||
108 | if ( !button.mask.isNull() ) { | 108 | if ( !button.mask.isNull() ) { |
109 | QImage imgMask = button.mask.convertToImage(); | 109 | QImage imgMask = button.mask.convertToImage(); |
110 | uchar **dest = buttonMask.jumpTable(); | 110 | uchar **dest = buttonMask.jumpTable(); |
111 | for ( int y = 0; y < imgUp.height(); y++ ) { | 111 | for ( int y = 0; y < imgUp.height(); y++ ) { |
112 | uchar *line = dest[y]; | 112 | uchar *line = dest[y]; |
113 | for ( int x = 0; x < imgUp.width(); x++ ) { | 113 | for ( int x = 0; x < imgUp.width(); x++ ) { |
114 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 114 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
115 | line[x] = i + 1; | 115 | line[x] = i + 1; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | setBackgroundPixmap( backgroundPixmap ); | 121 | setBackgroundPixmap( backgroundPixmap ); |
122 | 122 | ||
123 | slider = new QSlider( Qt::Horizontal, this ); | 123 | slider = new QSlider( Qt::Horizontal, this ); |
124 | slider->setMinValue( 0 ); | 124 | slider->setMinValue( 0 ); |
125 | slider->setMaxValue( 1 ); | 125 | slider->setMaxValue( 1 ); |
126 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 126 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
127 | //slider->setFocusPolicy( QWidget::NoFocus ); | 127 | //slider->setFocusPolicy( QWidget::NoFocus ); |
128 | 128 | ||
129 | resizeEvent( NULL ); | 129 | resizeEvent( NULL ); |
130 | 130 | ||
131 | setLength( mediaPlayerState.length() ); | 131 | setLength( mediaPlayerState.length() ); |
@@ -198,97 +198,97 @@ void VideoWidget::sliderReleased() { | |||
198 | videoSliderBeingMoved = FALSE; | 198 | videoSliderBeingMoved = FALSE; |
199 | if ( slider->width() == 0 ) { | 199 | if ( slider->width() == 0 ) { |
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 202 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
203 | mediaPlayerState.setPosition( val ); | 203 | mediaPlayerState.setPosition( val ); |
204 | } | 204 | } |
205 | 205 | ||
206 | void VideoWidget::setPosition( long i ) { | 206 | void VideoWidget::setPosition( long i ) { |
207 | updateSlider( i, mediaPlayerState.length() ); | 207 | updateSlider( i, mediaPlayerState.length() ); |
208 | } | 208 | } |
209 | 209 | ||
210 | 210 | ||
211 | void VideoWidget::setLength( long max ) { | 211 | void VideoWidget::setLength( long max ) { |
212 | updateSlider( mediaPlayerState.position(), max ); | 212 | updateSlider( mediaPlayerState.position(), max ); |
213 | } | 213 | } |
214 | 214 | ||
215 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 215 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
216 | { | 216 | { |
217 | if ( displayType == MediaPlayerState::Video ) { | 217 | if ( displayType == MediaPlayerState::Video ) { |
218 | makeVisible(); | 218 | makeVisible(); |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | // Effectively blank the view next time we show it so it looks nicer | 222 | // Effectively blank the view next time we show it so it looks nicer |
223 | scaledWidth = 0; | 223 | scaledWidth = 0; |
224 | scaledHeight = 0; | 224 | scaledHeight = 0; |
225 | hide(); | 225 | hide(); |
226 | } | 226 | } |
227 | 227 | ||
228 | void VideoWidget::updateSlider( long i, long max ) { | 228 | void VideoWidget::updateSlider( long i, long max ) { |
229 | // Will flicker too much if we don't do this | 229 | // Will flicker too much if we don't do this |
230 | if ( max == 0 ) { | 230 | if ( max == 0 ) { |
231 | return; | 231 | return; |
232 | } | 232 | } |
233 | int width = slider->width(); | 233 | int width = slider->width(); |
234 | int val = int((double)i * width / max); | 234 | int val = int((double)i * width / max); |
235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
236 | if ( slider->value() != val ) { | 236 | if ( slider->value() != val ) { |
237 | slider->setValue( val ); | 237 | slider->setValue( val ); |
238 | } | 238 | } |
239 | if ( slider->maxValue() != width ) { | 239 | if ( slider->maxValue() != width ) { |
240 | slider->setMaxValue( width ); | 240 | slider->setMaxValue( width ); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 245 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
246 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 246 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
247 | 247 | ||
248 | Button &button = buttons[ i ]; | 248 | Button &button = buttons[ i ]; |
249 | 249 | ||
250 | if ( event->state() == QMouseEvent::LeftButton ) { | 250 | if ( event->state() == QMouseEvent::LeftButton ) { |
251 | // The test to see if the mouse click is inside the button or not | 251 | // The test to see if the mouse click is inside the button or not |
252 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 252 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
253 | 253 | ||
254 | if ( isOnButton && !button.isHeld ) { | 254 | if ( isOnButton && !button.isHeld ) { |
255 | button.isHeld = TRUE; | 255 | button.isHeld = TRUE; |
256 | toggleButton( button ); | 256 | toggleButton( button ); |
257 | 257 | ||
258 | switch (i) { | 258 | switch (i) { |
259 | case VideoVolUp: | 259 | case VideoVolUp: |
260 | emit moreClicked(); | 260 | emit moreClicked(); |
261 | return; | 261 | return; |
262 | case VideoVolDown: | 262 | case VideoVolDown: |
263 | emit lessClicked(); | 263 | emit lessClicked(); |
264 | return; | 264 | return; |
265 | } | 265 | } |
266 | } else if ( !isOnButton && button.isHeld ) { | 266 | } else if ( !isOnButton && button.isHeld ) { |
267 | button.isHeld = FALSE; | 267 | button.isHeld = FALSE; |
268 | toggleButton( button ); | 268 | toggleButton( button ); |
269 | } | 269 | } |
270 | } else { | 270 | } else { |
271 | 271 | ||
272 | if ( button.isHeld ) { | 272 | if ( button.isHeld ) { |
273 | button.isHeld = FALSE; | 273 | button.isHeld = FALSE; |
274 | if ( button.type != ToggleButton ) { | 274 | if ( button.type != ToggleButton ) { |
275 | setToggleButton( button, FALSE ); | 275 | setToggleButton( button, FALSE ); |
276 | } | 276 | } |
277 | 277 | ||
278 | switch(i) { | 278 | switch(i) { |
279 | 279 | ||
280 | case VideoPlay: { | 280 | case VideoPlay: { |
281 | if( mediaPlayerState.isPaused() ) { | 281 | if( mediaPlayerState.isPaused() ) { |
282 | setToggleButton( button, FALSE ); | 282 | setToggleButton( button, FALSE ); |
283 | mediaPlayerState.setPaused( FALSE ); | 283 | mediaPlayerState.setPaused( FALSE ); |
284 | return; | 284 | return; |
285 | } else if( !mediaPlayerState.isPaused() ) { | 285 | } else if( !mediaPlayerState.isPaused() ) { |
286 | setToggleButton( button, TRUE ); | 286 | setToggleButton( button, TRUE ); |
287 | mediaPlayerState.setPaused( TRUE ); | 287 | mediaPlayerState.setPaused( TRUE ); |
288 | return; | 288 | return; |
289 | } else { | 289 | } else { |
290 | return; | 290 | return; |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; | 294 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; |