summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-02 11:38:17 (UTC)
committer harlekin <harlekin>2002-08-02 11:38:17 (UTC)
commitd3a54af5288cd30fc1a4f2dafc9f848b245046d6 (patch) (unidiff)
tree7390858ac62708bfc81078493e580a57297c61fa
parent471dc69956af37e7c5f481c10482f280db853491 (diff)
downloadopie-d3a54af5288cd30fc1a4f2dafc9f848b245046d6.zip
opie-d3a54af5288cd30fc1a4f2dafc9f848b245046d6.tar.gz
opie-d3a54af5288cd30fc1a4f2dafc9f848b245046d6.tar.bz2
theme work
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp38
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp1
4 files changed, 26 insertions, 16 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 689366e..300a5c8 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,490 +1,490 @@
1 1
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qbutton.h> 8#include <qbutton.h>
9#include <qpainter.h> 9#include <qpainter.h>
10#include <qframe.h> 10#include <qframe.h>
11#include <qlayout.h> 11#include <qlayout.h>
12 12
13#include <stdlib.h> 13#include <stdlib.h>
14#include <stdio.h> 14#include <stdio.h>
15 15
16#include "audiowidget.h" 16#include "audiowidget.h"
17#include "mediaplayerstate.h" 17#include "mediaplayerstate.h"
18 18
19extern MediaPlayerState *mediaPlayerState; 19extern MediaPlayerState *mediaPlayerState;
20 20
21static const int xo = -2; // movable x offset 21static const int xo = -2; // movable x offset
22static const int yo = 22; // movable y offset 22static const int yo = 22; // movable y offset
23 23
24 24
25Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 25Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
26 setFrameStyle( WinPanel | Sunken ); 26 setFrameStyle( WinPanel | Sunken );
27 setText( "No Song" ); 27 setText( "No Song" );
28} 28}
29 29
30Ticker::~Ticker() { 30Ticker::~Ticker() {
31} 31}
32 32
33void Ticker::setText( const QString& text ) { 33void Ticker::setText( const QString& text ) {
34 pos = 0; // reset it everytime the text is changed 34 pos = 0; // reset it everytime the text is changed
35 scrollText = text; 35 scrollText = text;
36 pixelLen = fontMetrics().width( scrollText ); 36 pixelLen = fontMetrics().width( scrollText );
37 killTimers(); 37 killTimers();
38 if ( pixelLen > width() ) { 38 if ( pixelLen > width() ) {
39 startTimer( 50 ); 39 startTimer( 50 );
40 } 40 }
41 update(); 41 update();
42} 42}
43 43
44 44
45void Ticker::timerEvent( QTimerEvent * ) { 45void Ticker::timerEvent( QTimerEvent * ) {
46 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 46 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
47 scroll( -1, 0, contentsRect() ); 47 scroll( -1, 0, contentsRect() );
48 repaint( FALSE ); 48 repaint( FALSE );
49} 49}
50 50
51void Ticker::drawContents( QPainter *p ) { 51void Ticker::drawContents( QPainter *p ) {
52 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 52 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
53 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 53 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
54 QPixmap pm( width(), height() ); 54 QPixmap pm( width(), height() );
55 pm.fill( colorGroup().base() ); 55 pm.fill( colorGroup().base() );
56 QPainter pmp( &pm ); 56 QPainter pmp( &pm );
57 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 57 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
58 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 58 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
59 } 59 }
60 p->drawPixmap( 0, 0, pm ); 60 p->drawPixmap( 0, 0, pm );
61} 61}
62 62
63struct MediaButton { 63struct MediaButton {
64 bool isToggle, isHeld, isDown; 64 bool isToggle, isHeld, isDown;
65}; 65};
66 66
67//Layout information for the audioButtons (and if it is a toggle button or not) 67//Layout information for the audioButtons (and if it is a toggle button or not)
68MediaButton audioButtons[] = { 68MediaButton audioButtons[] = {
69 { TRUE, FALSE, FALSE }, // play 69 { TRUE, FALSE, FALSE }, // play
70 { FALSE, FALSE, FALSE }, // stop 70 { FALSE, FALSE, FALSE }, // stop
71 { TRUE, FALSE, FALSE }, // pause 71 { TRUE, FALSE, FALSE }, // pause
72 { FALSE, FALSE, FALSE }, // next 72 { FALSE, FALSE, FALSE }, // next
73 { FALSE, FALSE, FALSE }, // previous 73 { FALSE, FALSE, FALSE }, // previous
74 { FALSE, FALSE, FALSE }, // volume up 74 { FALSE, FALSE, FALSE }, // volume up
75 { FALSE, FALSE, FALSE }, // volume down 75 { FALSE, FALSE, FALSE }, // volume down
76 { TRUE, FALSE, FALSE }, // repeat/loop 76 { TRUE, FALSE, FALSE }, // repeat/loop
77 { FALSE, FALSE, FALSE }, // playlist 77 { FALSE, FALSE, FALSE }, // playlist
78 { FALSE, FALSE, FALSE }, // forward 78 { FALSE, FALSE, FALSE }, // forward
79 { FALSE, FALSE, FALSE } // back 79 { FALSE, FALSE, FALSE } // back
80}; 80};
81 81
82const char *skin_mask_file_names[11] = { 82const char *skin_mask_file_names[11] = {
83 "play", "stop", "pause", "next", "prev", "up", 83 "play", "stop", "pause", "next", "prev", "up",
84 "down", "loop", "playlist", "forward", "back" 84 "down", "loop", "playlist", "forward", "back"
85}; 85};
86 86
87 87
88static void changeTextColor( QWidget *w ) { 88static void changeTextColor( QWidget *w ) {
89 QPalette p = w->palette(); 89 QPalette p = w->palette();
90 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 90 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
91 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 91 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
92 w->setPalette( p ); 92 w->setPalette( p );
93} 93}
94 94
95static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 95static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
96 96
97 97
98AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 98AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
99 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 99 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
100 setCaption( tr("OpiePlayer") ); 100 setCaption( tr("OpiePlayer") );
101 101
102 Config cfg("OpiePlayer"); 102 Config cfg("OpiePlayer");
103 cfg.setGroup("AudioWidget"); 103 cfg.setGroup("AudioWidget");
104 skin = cfg.readEntry("Skin","default"); 104 skin = cfg.readEntry("Skin","default");
105 //skin = "scaleTest"; 105 //skin = "scaleTest";
106// color of background, frame, degree of transparency 106// color of background, frame, degree of transparency
107 107
108 QString skinPath = "opieplayer/skins/" + skin; 108 QString skinPath = "opieplayer/skins/" + skin;
109 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 109 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
110 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 110 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
111 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 111 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
112 112
113 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 113 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
114 imgButtonMask->fill( 0 ); 114 imgButtonMask->fill( 0 );
115 115
116 for ( int i = 0; i < 11; i++ ) { 116 for ( int i = 0; i < 11; i++ ) {
117 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 117 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
118 masks[i] = new QBitmap( filename ); 118 masks[i] = new QBitmap( filename );
119 119
120 if ( !masks[i]->isNull() ) { 120 if ( !masks[i]->isNull() ) {
121 QImage imgMask = masks[i]->convertToImage(); 121 QImage imgMask = masks[i]->convertToImage();
122 uchar **dest = imgButtonMask->jumpTable(); 122 uchar **dest = imgButtonMask->jumpTable();
123 for ( int y = 0; y < imgUp->height(); y++ ) { 123 for ( int y = 0; y < imgUp->height(); y++ ) {
124 uchar *line = dest[y]; 124 uchar *line = dest[y];
125 for ( int x = 0; x < imgUp->width(); x++ ) 125 for ( int x = 0; x < imgUp->width(); x++ )
126 if ( !qRed( imgMask.pixel( x, y ) ) ) 126 if ( !qRed( imgMask.pixel( x, y ) ) )
127 line[x] = i + 1; 127 line[x] = i + 1;
128 } 128 }
129 } 129 }
130 130
131 } 131 }
132 132
133 for ( int i = 0; i < 11; i++ ) { 133 for ( int i = 0; i < 11; i++ ) {
134 buttonPixUp[i] = NULL; 134 buttonPixUp[i] = NULL;
135 buttonPixDown[i] = NULL; 135 buttonPixDown[i] = NULL;
136 } 136 }
137 137
138 setBackgroundPixmap( *pixBg ); 138 setBackgroundPixmap( *pixBg );
139 139
140 songInfo.setFocusPolicy( QWidget::NoFocus ); 140 songInfo.setFocusPolicy( QWidget::NoFocus );
141 changeTextColor( &songInfo ); 141 changeTextColor( &songInfo );
142 142
143 slider.setFixedHeight( 20 ); 143 slider.setFixedHeight( 20 );
144 slider.setMinValue( 0 ); 144 slider.setMinValue( 0 );
145 slider.setMaxValue( 1 ); 145 slider.setMaxValue( 1 );
146 slider.setFocusPolicy( QWidget::NoFocus ); 146 slider.setFocusPolicy( QWidget::NoFocus );
147 slider.setBackgroundPixmap( *pixBg ); 147 slider.setBackgroundPixmap( *pixBg );
148 148
149 time.setFocusPolicy( QWidget::NoFocus ); 149 time.setFocusPolicy( QWidget::NoFocus );
150 time.setAlignment( Qt::AlignCenter ); 150 time.setAlignment( Qt::AlignCenter );
151 time.setFrame(FALSE); 151 time.setFrame(FALSE);
152 changeTextColor( &time ); 152 changeTextColor( &time );
153 153
154 resizeEvent( NULL ); 154 resizeEvent( NULL );
155 155
156 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 156 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
157 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 157 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
158 158
159 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 159 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
160 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 160 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
161 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 161 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
162 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 162 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
163 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 163 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
164 164
165 // Intialise state 165 // Intialise state
166 setLength( mediaPlayerState->length() ); 166 setLength( mediaPlayerState->length() );
167 setPosition( mediaPlayerState->position() ); 167 setPosition( mediaPlayerState->position() );
168 setLooping( mediaPlayerState->fullscreen() ); 168 setLooping( mediaPlayerState->fullscreen() );
169 setPaused( mediaPlayerState->paused() ); 169 setPaused( mediaPlayerState->paused() );
170 setPlaying( mediaPlayerState->playing() ); 170 setPlaying( mediaPlayerState->playing() );
171 171
172} 172}
173 173
174AudioWidget::~AudioWidget() { 174AudioWidget::~AudioWidget() {
175 175
176 for ( int i = 0; i < 11; i++ ) { 176 for ( int i = 0; i < 11; i++ ) {
177 delete buttonPixUp[i]; 177 delete buttonPixUp[i];
178 delete buttonPixDown[i]; 178 delete buttonPixDown[i];
179 } 179 }
180 delete pixBg; 180 delete pixBg;
181 delete imgUp; 181 delete imgUp;
182 delete imgDn; 182 delete imgDn;
183 delete imgButtonMask; 183 delete imgButtonMask;
184 for ( int i = 0; i < 11; i++ ) { 184 for ( int i = 0; i < 11; i++ ) {
185 delete masks[i]; 185 delete masks[i];
186 } 186 }
187} 187}
188 188
189QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 189QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
190 QPixmap pix( img.width(), img.height() ); 190 QPixmap pix( img.width(), img.height() );
191 QPainter p( &pix ); 191 QPainter p( &pix );
192 p.drawTiledPixmap( pix.rect(), bg, offset ); 192 p.drawTiledPixmap( pix.rect(), bg, offset );
193 p.drawImage( 0, 0, img ); 193 p.drawImage( 0, 0, img );
194 return new QPixmap( pix ); 194 return new QPixmap( pix );
195} 195}
196 196
197 197
198QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 198QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
199{ 199{
200 QPixmap *pixmap = new QPixmap( pix ); 200 QPixmap *pixmap = new QPixmap( pix );
201 pixmap->setMask( mask ); 201 pixmap->setMask( mask );
202 return pixmap; 202 return pixmap;
203} 203}
204 204
205 205
206 206
207void AudioWidget::resizeEvent( QResizeEvent * ) { 207void AudioWidget::resizeEvent( QResizeEvent * ) {
208 int h = height(); 208 int h = height();
209 int w = width(); 209 int w = width();
210 210
211 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 211 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
212 slider.setFixedWidth( w - 110 ); 212 slider.setFixedWidth( w - 110 );
213 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 213 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
214 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 214 slider.setBackgroundOrigin( QWidget::ParentOrigin );
215 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 215 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
216 216
217 xoff = ( w - imgUp->width() ) / 2; 217 xoff = ( w - imgUp->width() ) / 2;
218 yoff = (( h - imgUp->height() ) / 2) - 10; 218 yoff = (( h - imgUp->height() ) / 2) - 10;
219 QPoint p( xoff, yoff ); 219 QPoint p( xoff, yoff );
220 220
221 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 221 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
222 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 222 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
223 223
224 for ( int i = 0; i < 11; i++ ) { 224 for ( int i = 0; i < 11; i++ ) {
225 if ( !masks[i]->isNull() ) { 225 if ( !masks[i]->isNull() ) {
226 delete buttonPixUp[i]; 226 delete buttonPixUp[i];
227 delete buttonPixDown[i]; 227 delete buttonPixDown[i];
228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
230 } 230 }
231 } 231 }
232 232
233 delete pixUp; 233 delete pixUp;
234 delete pixDn; 234 delete pixDn;
235} 235}
236 236
237static bool audioSliderBeingMoved = FALSE; 237static bool audioSliderBeingMoved = FALSE;
238 238
239 239
240void AudioWidget::sliderPressed() { 240void AudioWidget::sliderPressed() {
241 audioSliderBeingMoved = TRUE; 241 audioSliderBeingMoved = TRUE;
242} 242}
243 243
244 244
245void AudioWidget::sliderReleased() { 245void AudioWidget::sliderReleased() {
246 audioSliderBeingMoved = FALSE; 246 audioSliderBeingMoved = FALSE;
247 if ( slider.width() == 0 ) 247 if ( slider.width() == 0 )
248 return; 248 return;
249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
250 mediaPlayerState->setPosition( val ); 250 mediaPlayerState->setPosition( val );
251} 251}
252 252
253void AudioWidget::setPosition( long i ) { 253void AudioWidget::setPosition( long i ) {
254 // qDebug("set position %d",i); 254 // qDebug("set position %d",i);
255 updateSlider( i, mediaPlayerState->length() ); 255 updateSlider( i, mediaPlayerState->length() );
256} 256}
257 257
258 258
259void AudioWidget::setLength( long max ) { 259void AudioWidget::setLength( long max ) {
260 updateSlider( mediaPlayerState->position(), max ); 260 updateSlider( mediaPlayerState->position(), max );
261} 261}
262 262
263 263
264void AudioWidget::setView( char view ) { 264void AudioWidget::setView( char view ) {
265 if (mediaPlayerState->streaming() ) { 265 if (mediaPlayerState->streaming() ) {
266 if( !slider.isHidden()) slider.hide(); 266 if( !slider.isHidden()) slider.hide();
267 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 267 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
268 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 268 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
269 } else { 269 } else {
270 // this stops the slider from being moved, thus 270 // this stops the slider from being moved, thus
271 // does not stop stream when it reaches the end 271 // does not stop stream when it reaches the end
272 slider.show(); 272 slider.show();
273 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 273 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
274 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 274 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
275 } 275 }
276 276
277 if ( view == 'a' ) { 277 if ( view == 'a' ) {
278 startTimer( 150 ); 278 startTimer( 150 );
279 showMaximized(); 279 showMaximized();
280 } else { 280 } else {
281 killTimers(); 281 killTimers();
282 hide(); 282 hide();
283 } 283 }
284} 284}
285 285
286 286
287static QString timeAsString( long length ) { 287static QString timeAsString( long length ) {
288 length /= 44100; 288 length /= 44100;
289 int minutes = length / 60; 289 int minutes = length / 60;
290 int seconds = length % 60; 290 int seconds = length % 60;
291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
292} 292}
293 293
294void AudioWidget::updateSlider( long i, long max ) { 294void AudioWidget::updateSlider( long i, long max ) {
295 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 295 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
296 if ( max == 0 ) { 296 if ( max == 0 ) {
297 return; 297 return;
298 } 298 }
299 // Will flicker too much if we don't do this 299 // Will flicker too much if we don't do this
300 // Scale to something reasonable 300 // Scale to something reasonable
301 int width = slider.width(); 301 int width = slider.width();
302 int val = int((double)i * width / max); 302 int val = int((double)i * width / max);
303 if ( !audioSliderBeingMoved ) { 303 if ( !audioSliderBeingMoved ) {
304 if ( slider.value() != val ) { 304 if ( slider.value() != val ) {
305 slider.setValue( val ); 305 slider.setValue( val );
306 } 306 }
307 307
308 if ( slider.maxValue() != width ) { 308 if ( slider.maxValue() != width ) {
309 slider.setMaxValue( width ); 309 slider.setMaxValue( width );
310 } 310 }
311 } 311 }
312} 312}
313 313
314 314
315void AudioWidget::setToggleButton( int i, bool down ) { 315void AudioWidget::setToggleButton( int i, bool down ) {
316 if ( down != audioButtons[i].isDown ) { 316 if ( down != audioButtons[i].isDown ) {
317 toggleButton( i ); 317 toggleButton( i );
318 } 318 }
319} 319}
320 320
321 321
322void AudioWidget::toggleButton( int i ) { 322void AudioWidget::toggleButton( int i ) {
323 audioButtons[i].isDown = !audioButtons[i].isDown; 323 audioButtons[i].isDown = !audioButtons[i].isDown;
324 QPainter p(this); 324 QPainter p(this);
325 paintButton ( &p, i ); 325 paintButton ( &p, i );
326} 326}
327 327
328 328
329void AudioWidget::paintButton( QPainter *p, int i ) { 329void AudioWidget::paintButton( QPainter *p, int i ) {
330 if ( audioButtons[i].isDown ) 330 if ( audioButtons[i].isDown )
331 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 331 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
332 else 332 else
333 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 333 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
334} 334}
335 335
336 336
337void AudioWidget::timerEvent( QTimerEvent * ) { 337void AudioWidget::timerEvent( QTimerEvent * ) {
338// static int frame = 0; 338// static int frame = 0;
339// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 339// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
340// frame = frame >= 7 ? 0 : frame + 1; 340// frame = frame >= 7 ? 0 : frame + 1;
341// } 341// }
342} 342}
343 343
344 344
345void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 345void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
346 for ( int i = 0; i < numButtons; i++ ) { 346 for ( int i = 0; i < numButtons; i++ ) {
347 if ( event->state() == QMouseEvent::LeftButton ) { 347 if ( event->state() == QMouseEvent::LeftButton ) {
348 348
349 // The test to see if the mouse click is inside the button or not 349 // The test to see if the mouse click is inside the button or not
350 int x = event->pos().x() - xoff; 350 int x = event->pos().x() - xoff;
351 int y = event->pos().y() - yoff; 351 int y = event->pos().y() - yoff;
352 352
353 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 353 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
354 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 354 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
355 355
356 if ( isOnButton && i == AudioVolumeUp ) 356 if ( isOnButton && i == AudioVolumeUp )
357 qDebug("on up"); 357 qDebug("on up");
358 358
359 if ( isOnButton && !audioButtons[i].isHeld ) { 359 if ( isOnButton && !audioButtons[i].isHeld ) {
360 audioButtons[i].isHeld = TRUE; 360 audioButtons[i].isHeld = TRUE;
361 toggleButton(i); 361 toggleButton(i);
362 switch (i) { 362 switch (i) {
363 case AudioVolumeUp: 363 case AudioVolumeUp:
364 qDebug("more clicked"); 364 qDebug("more clicked");
365 emit moreClicked(); 365 emit moreClicked();
366 return; 366 return;
367 case AudioVolumeDown: emit lessClicked(); return; 367 case AudioVolumeDown: emit lessClicked(); return;
368 } 368 }
369 } else if ( !isOnButton && audioButtons[i].isHeld ) { 369 } else if ( !isOnButton && audioButtons[i].isHeld ) {
370 audioButtons[i].isHeld = FALSE; 370 audioButtons[i].isHeld = FALSE;
371 toggleButton(i); 371 toggleButton(i);
372 } 372 }
373 } else { 373 } else {
374 if ( audioButtons[i].isHeld ) { 374 if ( audioButtons[i].isHeld ) {
375 audioButtons[i].isHeld = FALSE; 375 audioButtons[i].isHeld = FALSE;
376 if ( !audioButtons[i].isToggle ) 376 if ( !audioButtons[i].isToggle )
377 setToggleButton( i, FALSE ); 377 setToggleButton( i, FALSE );
378 switch (i) { 378 switch (i) {
379 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 379 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
380 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 380 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
381 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 381 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
382 case AudioNext: mediaPlayerState->setNext(); return; 382 case AudioNext: mediaPlayerState->setNext(); return;
383 case AudioPrevious: mediaPlayerState->setPrev(); return; 383 case AudioPrevious: mediaPlayerState->setPrev(); return;
384 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 384 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
385 case AudioVolumeUp: emit moreReleased(); return; 385 case AudioVolumeUp: emit moreReleased(); return;
386 case AudioVolumeDown: emit lessReleased(); return; 386 case AudioVolumeDown: emit lessReleased(); return;
387 case AudioPlayList: mediaPlayerState->setList(); return; 387 case AudioPlayList: mediaPlayerState->setList(); return;
388 } 388 }
389 } 389 }
390 } 390 }
391 } 391 }
392} 392}
393 393
394 394
395void AudioWidget::mousePressEvent( QMouseEvent *event ) { 395void AudioWidget::mousePressEvent( QMouseEvent *event ) {
396 mouseMoveEvent( event ); 396 mouseMoveEvent( event );
397} 397}
398 398
399 399
400void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 400void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
401 mouseMoveEvent( event ); 401 mouseMoveEvent( event );
402} 402}
403 403
404 404
405void AudioWidget::showEvent( QShowEvent* ) { 405void AudioWidget::showEvent( QShowEvent* ) {
406 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 406 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
407 mouseMoveEvent( &event ); 407 mouseMoveEvent( &event );
408} 408}
409 409
410 410
411void AudioWidget::closeEvent( QCloseEvent* ) { 411void AudioWidget::closeEvent( QCloseEvent* ) {
412 mediaPlayerState->setList(); 412 mediaPlayerState->setList();
413} 413}
414 414
415 415
416void AudioWidget::paintEvent( QPaintEvent * pe) { 416void AudioWidget::paintEvent( QPaintEvent * pe) {
417 if ( !pe->erased() ) { 417 if ( !pe->erased() ) {
418 // Combine with background and double buffer 418 // Combine with background and double buffer
419 QPixmap pix( pe->rect().size() ); 419 QPixmap pix( pe->rect().size() );
420 QPainter p( &pix ); 420 QPainter p( &pix );
421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
423 for ( int i = 0; i < numButtons; i++ ) 423 for ( int i = 0; i < numButtons; i++ )
424 paintButton( &p, i ); 424 paintButton( &p, i );
425 QPainter p2( this ); 425 QPainter p2( this );
426 p2.drawPixmap( pe->rect().topLeft(), pix ); 426 p2.drawPixmap( pe->rect().topLeft(), pix );
427 } else { 427 } else {
428 QPainter p( this ); 428 QPainter p( this );
429 for ( int i = 0; i < numButtons; i++ ) 429 for ( int i = 0; i < numButtons; i++ )
430 paintButton( &p, i ); 430 paintButton( &p, i );
431 } 431 }
432} 432}
433 433
434void AudioWidget::keyReleaseEvent( QKeyEvent *e) 434void AudioWidget::keyReleaseEvent( QKeyEvent *e)
435{ 435{
436 switch ( e->key() ) { 436 switch ( e->key() ) {
437////////////////////////////// Zaurus keys 437////////////////////////////// Zaurus keys
438 case Key_Home: 438 case Key_Home:
439 break; 439 break;
440 case Key_F9: //activity 440 case Key_F9: //activity
441 hide(); 441 hide();
442// qDebug("Audio F9"); 442// qDebug("Audio F9");
443 break; 443 break;
444 case Key_F10: //contacts 444 case Key_F10: //contacts
445 break; 445 break;
446 case Key_F11: //menu 446 case Key_F11: //menu
447 break; 447 break;
448 case Key_F12: //home 448 case Key_F12: //home
449 break; 449 break;
450 case Key_F13: //mail 450 case Key_F13: //mail
451 break; 451 break;
452 case Key_Space: { 452 case Key_Space: {
453 if(mediaPlayerState->playing()) { 453 if(mediaPlayerState->playing()) {
454// toggleButton(1); 454// toggleButton(1);
455 mediaPlayerState->setPlaying(FALSE); 455 mediaPlayerState->setPlaying(FALSE);
456// toggleButton(1); 456// toggleButton(1);
457 } else { 457 } else {
458// toggleButton(0); 458// toggleButton(0);
459 mediaPlayerState->setPlaying(TRUE); 459 mediaPlayerState->setPlaying(TRUE);
460// toggleButton(0); 460// toggleButton(0);
461 } 461 }
462 } 462 }
463 break; 463 break;
464 case Key_Down: 464 case Key_Down:
465 toggleButton(6); 465 toggleButton(6);
466 emit lessClicked(); 466 emit lessClicked();
467 emit lessReleased(); 467 emit lessReleased();
468 toggleButton(6); 468 toggleButton(6);
469 break; 469 break;
470 case Key_Up: 470 case Key_Up:
471 toggleButton(5); 471 toggleButton(5);
472 emit moreClicked(); 472 emit moreClicked();
473 emit moreReleased(); 473 emit moreReleased();
474 toggleButton(5); 474 toggleButton(5);
475 break; 475 break;
476 case Key_Right: 476 case Key_Right:
477// toggleButton(3); 477// toggleButton(3);
478 mediaPlayerState->setNext(); 478 mediaPlayerState->setNext();
479// toggleButton(3); 479// toggleButton(3);
480 break; 480 break;
481 case Key_Left: 481 case Key_Left:
482// toggleButton(4); 482// toggleButton(4);
483 mediaPlayerState->setPrev(); 483 mediaPlayerState->setPrev();
484// toggleButton(4); 484// toggleButton(4);
485 break; 485 break;
486 case Key_Escape: 486 case Key_Escape:
487 break; 487 break;
488 488
489 }; 489 };
490} 490}
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index bce6b89..48caf00 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,376 +1,384 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
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/resource.h> 34#include <qpe/resource.h>
35#include <qpe/mediaplayerplugininterface.h> 35#include <qpe/mediaplayerplugininterface.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qpainter.h> 39#include <qpainter.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qslider.h> 41#include <qslider.h>
42#include <qdrawutil.h> 42#include <qdrawutil.h>
43#include "videowidget.h" 43#include "videowidget.h"
44#include "mediaplayerstate.h" 44#include "mediaplayerstate.h"
45 45
46 46
47#ifdef Q_WS_QWS 47#ifdef Q_WS_QWS
48# define USE_DIRECT_PAINTER 48# define USE_DIRECT_PAINTER
49# include <qdirectpainter_qws.h> 49# include <qdirectpainter_qws.h>
50# include <qgfxraster_qws.h> 50# include <qgfxraster_qws.h>
51#endif 51#endif
52 52
53 53
54extern MediaPlayerState *mediaPlayerState; 54extern MediaPlayerState *mediaPlayerState;
55 55
56 56
57static const int xo = 2; // movable x offset 57static const int xo = 2; // movable x offset
58static const int yo = 0; // movable y offset 58static const int yo = 0; // movable y offset
59 59
60 60
61struct MediaButton { 61struct MediaButton {
62 int xPos, yPos; 62 int xPos, yPos;
63 bool isToggle, isHeld, isDown; 63 bool isToggle, isHeld, isDown;
64 int controlType; 64 int controlType;
65}; 65};
66 66
67 67
68// Layout information for the videoButtons (and if it is a toggle button or not) 68// Layout information for the videoButtons (and if it is a toggle button or not)
69MediaButton videoButtons[] = { 69MediaButton videoButtons[] = {
70 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 70 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous
71 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 71 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop
72 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 72 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play
73 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 73 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause
74 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 74 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next
75 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 75 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist
76 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 76 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen
77}; 77};
78 78
79 79
80static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 80static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
81 81
82 82
83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
84 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 84 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
85 setCaption( tr("OpiePlayer - Video") ); 85 setCaption( tr("OpiePlayer - Video") );
86 Config cfg("OpiePlayer"); 86 Config cfg("OpiePlayer");
87 cfg.setGroup("VideoWidget"); 87 cfg.setGroup("VideoWidget");
88 88
89 QString backgroundPix, Button0aPix, Button0bPix, controlsPix; 89 QString Button0aPix, Button0bPix, controlsPix;
90 backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish"); 90 //backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish");
91 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); 91 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a");
92 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); 92 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b");
93 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); 93 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" );
94 94
95 cfg.setGroup("AudioWidget");
96 QString skin = cfg.readEntry("Skin","default");
97 QString skinPath = "opieplayer/skins/" + skin;
98 backgroundPix = QString("%1/background").arg(skinPath) ;
99
95 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 100 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
96 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); 101 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) );
97 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); 102 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) );
98 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); 103 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) );
99 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 104 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
100 105
101 slider = new QSlider( Qt::Horizontal, this ); 106 slider = new QSlider( Qt::Horizontal, this );
102 slider->setMinValue( 0 ); 107 slider->setMinValue( 0 );
103 slider->setMaxValue( 1 ); 108 slider->setMaxValue( 1 );
104 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 109 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
105 slider->setFocusPolicy( QWidget::NoFocus ); 110 slider->setFocusPolicy( QWidget::NoFocus );
106 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 111 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
107 112
108 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 113 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
109 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 114 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
110 115
111 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 116 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
112 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 117 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
113 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 118 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
114 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 119 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
115 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 120 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
116 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 121 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
117 122
118 // Intialise state 123 // Intialise state
119 setLength( mediaPlayerState->length() ); 124 setLength( mediaPlayerState->length() );
120 setPosition( mediaPlayerState->position() ); 125 setPosition( mediaPlayerState->position() );
121 setFullscreen( mediaPlayerState->fullscreen() ); 126 setFullscreen( mediaPlayerState->fullscreen() );
122 setPaused( mediaPlayerState->paused() ); 127 setPaused( mediaPlayerState->paused() );
123 setPlaying( mediaPlayerState->playing() ); 128 setPlaying( mediaPlayerState->playing() );
124 129
125 videoFrame = new XineVideoWidget( 240, 155 ,this, "Video frame" ); 130 videoFrame = new XineVideoWidget( 240, 155 ,this, "Video frame" );
126 videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); 131
127} 132}
128 133
129 134
130VideoWidget::~VideoWidget() { 135VideoWidget::~VideoWidget() {
131 for ( int i = 0; i < 3; i++ ) { 136 for ( int i = 0; i < 3; i++ ) {
132 delete pixmaps[i]; 137 delete pixmaps[i];
133 } 138 }
134 delete currentFrame; 139 delete currentFrame;
135} 140}
136 141
137 142
138static bool videoSliderBeingMoved = FALSE; 143static bool videoSliderBeingMoved = FALSE;
139 144
140 145
141void VideoWidget::sliderPressed() { 146void VideoWidget::sliderPressed() {
142 videoSliderBeingMoved = TRUE; 147 videoSliderBeingMoved = TRUE;
143} 148}
144 149
145 150
146void VideoWidget::sliderReleased() { 151void VideoWidget::sliderReleased() {
147 videoSliderBeingMoved = FALSE; 152 videoSliderBeingMoved = FALSE;
148 if ( slider->width() == 0 ) { 153 if ( slider->width() == 0 ) {
149 return; 154 return;
150 } 155 }
151 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 156 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
152 mediaPlayerState->setPosition( val ); 157 mediaPlayerState->setPosition( val );
153} 158}
154 159
155 160
156void VideoWidget::setPosition( long i ) { 161void VideoWidget::setPosition( long i ) {
157 updateSlider( i, mediaPlayerState->length() ); 162 updateSlider( i, mediaPlayerState->length() );
158} 163}
159 164
160 165
161void VideoWidget::setLength( long max ) { 166void VideoWidget::setLength( long max ) {
162 updateSlider( mediaPlayerState->position(), max ); 167 updateSlider( mediaPlayerState->position(), max );
163} 168}
164 169
165 170
166void VideoWidget::setView( char view ) { 171void VideoWidget::setView( char view ) {
167 if ( view == 'v' ) { 172 if ( view == 'v' ) {
168 makeVisible(); 173 makeVisible();
169 } else { 174 } else {
170 // Effectively blank the view next time we show it so it looks nicer 175 // Effectively blank the view next time we show it so it looks nicer
171 scaledWidth = 0; 176 scaledWidth = 0;
172 scaledHeight = 0; 177 scaledHeight = 0;
173 hide(); 178 hide();
174 } 179 }
175} 180}
176 181
177 182
178void VideoWidget::updateSlider( long i, long max ) { 183void VideoWidget::updateSlider( long i, long max ) {
179 // Will flicker too much if we don't do this 184 // Will flicker too much if we don't do this
180 if ( max == 0 ) { 185 if ( max == 0 ) {
181 return; 186 return;
182 } 187 }
183 int width = slider->width(); 188 int width = slider->width();
184 int val = int((double)i * width / max); 189 int val = int((double)i * width / max);
185 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 190 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
186 if ( slider->value() != val ) { 191 if ( slider->value() != val ) {
187 slider->setValue( val ); 192 slider->setValue( val );
188 } 193 }
189 if ( slider->maxValue() != width ) { 194 if ( slider->maxValue() != width ) {
190 slider->setMaxValue( width ); 195 slider->setMaxValue( width );
191 } 196 }
192 } 197 }
193} 198}
194 199
195 200
196void VideoWidget::setToggleButton( int i, bool down ) { 201void VideoWidget::setToggleButton( int i, bool down ) {
197 if ( down != videoButtons[i].isDown ) { 202 if ( down != videoButtons[i].isDown ) {
198 toggleButton( i ); 203 toggleButton( i );
199 } 204 }
200} 205}
201 206
202 207
203void VideoWidget::toggleButton( int i ) { 208void VideoWidget::toggleButton( int i ) {
204 videoButtons[i].isDown = !videoButtons[i].isDown; 209 videoButtons[i].isDown = !videoButtons[i].isDown;
205 QPainter p(this); 210 QPainter p(this);
206 paintButton ( &p, i ); 211 paintButton ( &p, i );
207} 212}
208 213
209 214
210void VideoWidget::paintButton( QPainter *p, int i ) { 215void VideoWidget::paintButton( QPainter *p, int i ) {
211 int x = videoButtons[i].xPos; 216 int x = videoButtons[i].xPos;
212 int y = videoButtons[i].yPos; 217 int y = videoButtons[i].yPos;
213 int offset = 10 + videoButtons[i].isDown; 218 int offset = 10 + videoButtons[i].isDown;
214 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); 219 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
215 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); 220 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
216} 221}
217 222
218 223
219void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 224void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
220 for ( int i = 0; i < numButtons; i++ ) { 225 for ( int i = 0; i < numButtons; i++ ) {
221 int x = videoButtons[i].xPos; 226 int x = videoButtons[i].xPos;
222 int y = videoButtons[i].yPos; 227 int y = videoButtons[i].yPos;
223 if ( event->state() == QMouseEvent::LeftButton ) { 228 if ( event->state() == QMouseEvent::LeftButton ) {
224 // The test to see if the mouse click is inside the circular button or not 229 // The test to see if the mouse click is inside the circular button or not
225 // (compared with the radius squared to avoid a square-root of our distance) 230 // (compared with the radius squared to avoid a square-root of our distance)
226 int radius = 16; 231 int radius = 16;
227 QPoint center = QPoint( x + radius, y + radius ); 232 QPoint center = QPoint( x + radius, y + radius );
228 QPoint dXY = center - event->pos(); 233 QPoint dXY = center - event->pos();
229 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 234 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
230 bool isOnButton = dist <= (radius * radius); 235 bool isOnButton = dist <= (radius * radius);
231 if ( isOnButton != videoButtons[i].isHeld ) { 236 if ( isOnButton != videoButtons[i].isHeld ) {
232 videoButtons[i].isHeld = isOnButton; 237 videoButtons[i].isHeld = isOnButton;
233 toggleButton(i); 238 toggleButton(i);
234 } 239 }
235 } else { 240 } else {
236 if ( videoButtons[i].isHeld ) { 241 if ( videoButtons[i].isHeld ) {
237 videoButtons[i].isHeld = FALSE; 242 videoButtons[i].isHeld = FALSE;
238 if ( !videoButtons[i].isToggle ) 243 if ( !videoButtons[i].isToggle )
239 setToggleButton( i, FALSE ); 244 setToggleButton( i, FALSE );
240 } 245 }
241 } 246 }
242 switch (i) { 247 switch (i) {
243 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 248 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
244 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 249 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
245 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 250 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
246 case VideoNext: mediaPlayerState->setNext(); return; 251 case VideoNext: mediaPlayerState->setNext(); return;
247 case VideoPrevious: mediaPlayerState->setPrev(); return; 252 case VideoPrevious: mediaPlayerState->setPrev(); return;
248 case VideoPlayList: mediaPlayerState->setList(); return; 253 case VideoPlayList: mediaPlayerState->setList(); return;
249 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 254 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
250 } 255 }
251 256
252 } 257 }
253} 258}
254 259
255 260
256void VideoWidget::mousePressEvent( QMouseEvent *event ) { 261void VideoWidget::mousePressEvent( QMouseEvent *event ) {
257 mouseMoveEvent( event ); 262 mouseMoveEvent( event );
258} 263}
259 264
260 265
261void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 266void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
262 if ( mediaPlayerState->fullscreen() ) { 267 if ( mediaPlayerState->fullscreen() ) {
263 mediaPlayerState->setFullscreen( FALSE ); 268 mediaPlayerState->setFullscreen( FALSE );
264 makeVisible(); 269 makeVisible();
265 270
266 mouseMoveEvent( event ); 271 mouseMoveEvent( event );
267 } 272 }
268} 273}
269 274
270 275
271void VideoWidget::makeVisible() { 276void VideoWidget::makeVisible() {
272 if ( mediaPlayerState->fullscreen() ) { 277 if ( mediaPlayerState->fullscreen() ) {
273 setBackgroundMode( QWidget::NoBackground ); 278 setBackgroundMode( QWidget::NoBackground );
274 showFullScreen(); 279 showFullScreen();
275 resize( qApp->desktop()->size() ); 280 resize( qApp->desktop()->size() );
276 slider->hide(); 281 slider->hide();
277 } else { 282 } else {
278 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 283 setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
279 showNormal(); 284 showNormal();
280 showMaximized(); 285 showMaximized();
281 slider->show(); 286 slider->show();
282 } 287 }
283} 288}
284 289
285 290
286void VideoWidget::paintEvent( QPaintEvent * ) { 291void VideoWidget::paintEvent( QPaintEvent * ) {
287 QPainter p( this ); 292 QPainter p( this );
288 293
289 if ( mediaPlayerState->fullscreen() ) { 294 if ( mediaPlayerState->fullscreen() ) {
290 // Clear the background 295 // Clear the background
291 p.setBrush( QBrush( Qt::black ) ); 296 p.setBrush( QBrush( Qt::black ) );
292 videoFrame->setGeometry( QRect( 0, 0 , 240 ,340 ) ); 297 videoFrame->setGeometry( QRect( 0, 0 , 240 ,340 ) );
293 298
294 } else { 299 } else {
300
301 videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) );
295 // draw the buttons 302 // draw the buttons
303
296 for ( int i = 0; i < numButtons; i++ ) { 304 for ( int i = 0; i < numButtons; i++ ) {
297 paintButton( &p, i ); 305 paintButton( &p, i );
298 } 306 }
299 // draw the slider 307 // draw the slider
300 slider->repaint( TRUE ); 308 slider->repaint( TRUE );
301 } 309 }
302} 310}
303 311
304 312
305void VideoWidget::closeEvent( QCloseEvent* ) { 313void VideoWidget::closeEvent( QCloseEvent* ) {
306 mediaPlayerState->setList(); 314 mediaPlayerState->setList();
307} 315}
308 316
309 317
310bool VideoWidget::playVideo() { 318bool VideoWidget::playVideo() {
311 bool result = FALSE; 319 bool result = FALSE;
312 320
313 int stream = 0; 321 int stream = 0;
314 322
315 int sw = 240; 323 int sw = 240;
316 int sh = 320; 324 int sh = 320;
317 int dd = QPixmap::defaultDepth(); 325 int dd = QPixmap::defaultDepth();
318 int w = height(); 326 int w = height();
319 int h = width(); 327 int h = width();
320 328
321 return true; 329 return true;
322} 330}
323 331
324 332
325 333
326void VideoWidget::keyReleaseEvent( QKeyEvent *e) 334void VideoWidget::keyReleaseEvent( QKeyEvent *e)
327{ 335{
328 switch ( e->key() ) { 336 switch ( e->key() ) {
329////////////////////////////// Zaurus keys 337////////////////////////////// Zaurus keys
330 case Key_Home: 338 case Key_Home:
331 break; 339 break;
332 case Key_F9: //activity 340 case Key_F9: //activity
333 break; 341 break;
334 case Key_F10: //contacts 342 case Key_F10: //contacts
335// hide(); 343// hide();
336 break; 344 break;
337 case Key_F11: //menu 345 case Key_F11: //menu
338 break; 346 break;
339 case Key_F12: //home 347 case Key_F12: //home
340 break; 348 break;
341 case Key_F13: //mail 349 case Key_F13: //mail
342 break; 350 break;
343 case Key_Space: { 351 case Key_Space: {
344 if(mediaPlayerState->playing()) { 352 if(mediaPlayerState->playing()) {
345 mediaPlayerState->setPlaying(FALSE); 353 mediaPlayerState->setPlaying(FALSE);
346 } else { 354 } else {
347 mediaPlayerState->setPlaying(TRUE); 355 mediaPlayerState->setPlaying(TRUE);
348 } 356 }
349 } 357 }
350 break; 358 break;
351 case Key_Down: 359 case Key_Down:
352// toggleButton(6); 360// toggleButton(6);
353// emit lessClicked(); 361// emit lessClicked();
354// emit lessReleased(); 362// emit lessReleased();
355// toggleButton(6); 363// toggleButton(6);
356 break; 364 break;
357 case Key_Up: 365 case Key_Up:
358// toggleButton(5); 366// toggleButton(5);
359// emit moreClicked(); 367// emit moreClicked();
360// emit moreReleased(); 368// emit moreReleased();
361// toggleButton(5); 369// toggleButton(5);
362 break; 370 break;
363 case Key_Right: 371 case Key_Right:
364 mediaPlayerState->setNext(); 372 mediaPlayerState->setNext();
365 break; 373 break;
366 case Key_Left: 374 case Key_Left:
367 mediaPlayerState->setPrev(); 375 mediaPlayerState->setPrev();
368 break; 376 break;
369 case Key_Escape: 377 case Key_Escape:
370 break; 378 break;
371 379
372 }; 380 };
373} 381}
374XineVideoWidget* VideoWidget::vidWidget() { 382XineVideoWidget* VideoWidget::vidWidget() {
375 return videoFrame; 383 return videoFrame;
376} 384}
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 8f98889..0122d5d 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,100 +1,101 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
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#ifndef VIDEO_WIDGET_H 34#ifndef VIDEO_WIDGET_H
35#define VIDEO_WIDGET_H 35#define VIDEO_WIDGET_H
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include "xinevideowidget.h" 38#include "xinevideowidget.h"
39 39
40class QPixmap; 40class QPixmap;
41class QSlider; 41class QSlider;
42 42
43enum VideoButtons { 43enum VideoButtons {
44 VideoPrevious, 44 VideoPrevious,
45 VideoStop, 45 VideoStop,
46 VideoPlay, 46 VideoPlay,
47 VideoPause, 47 VideoPause,
48 VideoNext, 48 VideoNext,
49 VideoPlayList, 49 VideoPlayList,
50 VideoFullscreen 50 VideoFullscreen
51}; 51};
52 52
53class VideoWidget : public QWidget { 53class VideoWidget : public QWidget {
54 Q_OBJECT 54 Q_OBJECT
55public: 55public:
56 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 56 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
57 ~VideoWidget(); 57 ~VideoWidget();
58 58
59 bool playVideo(); 59 bool playVideo();
60 XineVideoWidget* vidWidget(); 60 XineVideoWidget* vidWidget();
61public slots: 61public slots:
62 void updateSlider( long, long ); 62 void updateSlider( long, long );
63 void sliderPressed( ); 63 void sliderPressed( );
64 void sliderReleased( ); 64 void sliderReleased( );
65 void setPaused( bool b) { setToggleButton( VideoPause, b ); } 65 void setPaused( bool b) { setToggleButton( VideoPause, b ); }
66 void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } 66 void setPlaying( bool b) { setToggleButton( VideoPlay, b ); }
67 void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); } 67 void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); }
68 void makeVisible(); 68 void makeVisible();
69 void setPosition( long ); 69 void setPosition( long );
70 void setLength( long ); 70 void setLength( long );
71 void setView( char ); 71 void setView( char );
72 72
73signals: 73signals:
74 void sliderMoved( long ); 74 void sliderMoved( long );
75 75
76protected: 76protected:
77 void paintEvent( QPaintEvent *pe ); 77 void paintEvent( QPaintEvent *pe );
78 void mouseMoveEvent( QMouseEvent *event ); 78 void mouseMoveEvent( QMouseEvent *event );
79 void mousePressEvent( QMouseEvent *event ); 79 void mousePressEvent( QMouseEvent *event );
80 void mouseReleaseEvent( QMouseEvent *event ); 80 void mouseReleaseEvent( QMouseEvent *event );
81 void closeEvent( QCloseEvent *event ); 81 void closeEvent( QCloseEvent *event );
82 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
83 83
84private: 84private:
85 void paintButton( QPainter *p, int i ); 85 void paintButton( QPainter *p, int i );
86 void toggleButton( int ); 86 void toggleButton( int );
87 void setToggleButton( int, bool ); 87 void setToggleButton( int, bool );
88 88
89 QString backgroundPix;
89 QSlider *slider; 90 QSlider *slider;
90 QPixmap *pixmaps[3]; 91 QPixmap *pixmaps[3];
91 QImage *currentFrame; 92 QImage *currentFrame;
92 int scaledWidth; 93 int scaledWidth;
93 int scaledHeight; 94 int scaledHeight;
94 XineVideoWidget* videoFrame; 95 XineVideoWidget* videoFrame;
95}; 96};
96 97
97#endif // VIDEO_WIDGET_H 98#endif // VIDEO_WIDGET_H
98 99
99 100
100 101
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 3be9fa4..3faeab1 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,122 +1,123 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
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 34
35#include <qtimer.h> 35#include <qtimer.h>
36#include "xinecontrol.h" 36#include "xinecontrol.h"
37#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
38#include "videowidget.h" 38#include "videowidget.h"
39 39
40extern MediaPlayerState *mediaPlayerState; 40extern MediaPlayerState *mediaPlayerState;
41extern VideoWidget *videoUI; 41extern VideoWidget *videoUI;
42XineControl::XineControl( QObject *parent, const char *name ) 42XineControl::XineControl( QObject *parent, const char *name )
43 : QObject( parent, name ) { 43 : QObject( parent, name ) {
44 libXine = new XINE::Lib(videoUI->vidWidget() ); 44 libXine = new XINE::Lib(videoUI->vidWidget() );
45 45
46 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 46 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
47 connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) ); 47 connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) );
48 connect(this, SIGNAL( postitionChanged(int position) ), mediaPlayerState, SLOT( setPosition( long p ) ) );
48 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 49 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
49 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 50 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
50 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 51 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
51 52
52} 53}
53 54
54XineControl::~XineControl() { 55XineControl::~XineControl() {
55 delete libXine; 56 delete libXine;
56} 57}
57 58
58void XineControl::play( const QString& fileName ) { 59void XineControl::play( const QString& fileName ) {
59 libXine->play( fileName ); 60 libXine->play( fileName );
60 mediaPlayerState->setPlaying( true ); 61 mediaPlayerState->setPlaying( true );
61 // default to audio view until we know how to handle video 62 // default to audio view until we know how to handle video
62 // MediaDetect mdetect; 63 // MediaDetect mdetect;
63 char whichGui = mdetect.videoOrAudio( fileName ); 64 char whichGui = mdetect.videoOrAudio( fileName );
64 if (whichGui == 'f') { 65 if (whichGui == 'f') {
65 qDebug("Nicht erkannter Dateityp"); 66 qDebug("Nicht erkannter Dateityp");
66 return; 67 return;
67 } 68 }
68 69
69 if (whichGui == 'a') { 70 if (whichGui == 'a') {
70 libXine->setShowVideo( false ); 71 libXine->setShowVideo( false );
71 } else { 72 } else {
72 libXine->setShowVideo( true ); 73 libXine->setShowVideo( true );
73 } 74 }
74 75
75 // determine if slider is shown 76 // determine if slider is shown
76 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); 77 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) );
77 mediaPlayerState->setIsStreaming( libXine->isSeekable() ); 78 mediaPlayerState->setIsStreaming( libXine->isSeekable() );
78 // which gui (video / audio) 79 // which gui (video / audio)
79 mediaPlayerState->setView( whichGui ); 80 mediaPlayerState->setView( whichGui );
80 81
81} 82}
82 83
83void XineControl::stop( bool isSet ) { 84void XineControl::stop( bool isSet ) {
84 if ( !isSet) { 85 if ( !isSet) {
85 libXine->stop(); 86 libXine->stop();
86 mediaPlayerState->setList(); 87 mediaPlayerState->setList();
87 //mediaPlayerState->setPlaying( false ); 88 //mediaPlayerState->setPlaying( false );
88 } else { 89 } else {
89 // play again 90 // play again
90 } 91 }
91} 92}
92 93
93void XineControl::pause( bool isSet) { 94void XineControl::pause( bool isSet) {
94 libXine->pause(); 95 libXine->pause();
95} 96}
96 97
97int XineControl::currentTime() { 98int XineControl::currentTime() {
98 // todo: jede sekunde überprüfen 99 // todo: jede sekunde überprüfen
99 m_currentTime = libXine->currentTime(); 100 m_currentTime = libXine->currentTime();
100 return m_currentTime; 101 return m_currentTime;
101} 102}
102 103
103void XineControl::length() { 104void XineControl::length() {
104 m_length = libXine->length(); 105 m_length = libXine->length();
105 mediaPlayerState->setLength( m_length ); 106 mediaPlayerState->setLength( m_length );
106} 107}
107 108
108int XineControl::position() { 109int XineControl::position() {
109 m_position = (m_currentTime/m_length*100); 110 m_position = (m_currentTime/m_length*100);
110 mediaPlayerState->setPosition( m_position ); 111 mediaPlayerState->setPosition( m_position );
111 return m_position; 112 return m_position;
112 emit positionChanged( m_position ); 113 emit positionChanged( m_position );
113 QTimer::singleShot( 1000, this, SLOT( position ) ); 114 QTimer::singleShot( 1000, this, SLOT( position ) );
114} 115}
115 116
116void XineControl::setFullscreen( bool isSet ) { 117void XineControl::setFullscreen( bool isSet ) {
117 libXine->showVideoFullScreen( isSet); 118 libXine->showVideoFullScreen( isSet);
118} 119}
119 120
120void XineControl::seekTo( long second ) { 121void XineControl::seekTo( long second ) {
121 // libXine-> 122 // libXine->
122} 123}