summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-11-10 15:46:12 (UTC)
committer harlekin <harlekin>2002-11-10 15:46:12 (UTC)
commitee6938139a5f8f24da901ab5a41930a98af00d44 (patch) (unidiff)
treedc9c2d23efc1e9fe600206d8c10d1c0c567208b6
parentb0b173498acde27957f8ed9297bb2ed2346eb700 (diff)
downloadopie-ee6938139a5f8f24da901ab5a41930a98af00d44.zip
opie-ee6938139a5f8f24da901ab5a41930a98af00d44.tar.gz
opie-ee6938139a5f8f24da901ab5a41930a98af00d44.tar.bz2
better seek slider code for videowidget too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp9
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp36
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp2
5 files changed, 30 insertions, 19 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 00d516c..de91a59 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,583 +1,584 @@
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/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#include <qwidget.h> 38#include <qwidget.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qbutton.h> 40#include <qbutton.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <stdio.h> 46#include <stdio.h>
47 47
48#include "audiowidget.h" 48#include "audiowidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50#include "playlistwidget.h" 50#include "playlistwidget.h"
51 51
52extern MediaPlayerState *mediaPlayerState; 52extern MediaPlayerState *mediaPlayerState;
53extern PlayListWidget *playList; 53extern PlayListWidget *playList;
54 54
55static const int xo = -2; // movable x offset 55static const int xo = -2; // movable x offset
56static const int yo = 22; // movable y offset 56static const int yo = 22; // movable y offset
57 57
58 58
59Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 59Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
60 setFrameStyle( WinPanel | Sunken ); 60 setFrameStyle( WinPanel | Sunken );
61 //setText( "No Song" ); 61 //setText( "No Song" );
62} 62}
63 63
64Ticker::~Ticker() { 64Ticker::~Ticker() {
65} 65}
66 66
67void Ticker::setText( const QString& text ) { 67void Ticker::setText( const QString& text ) {
68 pos = 0; // reset it everytime the text is changed 68 pos = 0; // reset it everytime the text is changed
69 scrollText = text; 69 scrollText = text;
70 pixelLen = fontMetrics().width( scrollText ); 70 pixelLen = fontMetrics().width( scrollText );
71 killTimers(); 71 killTimers();
72 if ( pixelLen > width() ) { 72 if ( pixelLen > width() ) {
73 startTimer( 50 ); 73 startTimer( 50 );
74 } 74 }
75 update(); 75 update();
76} 76}
77 77
78 78
79void Ticker::timerEvent( QTimerEvent * ) { 79void Ticker::timerEvent( QTimerEvent * ) {
80 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 80 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
81 scroll( -1, 0, contentsRect() ); 81 scroll( -1, 0, contentsRect() );
82 repaint( FALSE ); 82 repaint( FALSE );
83} 83}
84 84
85void Ticker::drawContents( QPainter *p ) { 85void Ticker::drawContents( QPainter *p ) {
86 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 86 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
87 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 87 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
88 } 88 }
89 QPixmap pm( width(), height() ); 89 QPixmap pm( width(), height() );
90 pm.fill( colorGroup().base() ); 90 pm.fill( colorGroup().base() );
91 QPainter pmp( &pm ); 91 QPainter pmp( &pm );
92 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 92 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
93 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 93 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
94 } 94 }
95 p->drawPixmap( 0, 0, pm ); 95 p->drawPixmap( 0, 0, pm );
96} 96}
97 97
98struct MediaButton { 98struct MediaButton {
99 bool isToggle, isHeld, isDown; 99 bool isToggle, isHeld, isDown;
100}; 100};
101 101
102//Layout information for the audioButtons (and if it is a toggle button or not) 102//Layout information for the audioButtons (and if it is a toggle button or not)
103MediaButton audioButtons[] = { 103MediaButton audioButtons[] = {
104 { TRUE, FALSE, FALSE }, // play 104 { TRUE, FALSE, FALSE }, // play
105 { FALSE, FALSE, FALSE }, // stop 105 { FALSE, FALSE, FALSE }, // stop
106 { FALSE, FALSE, FALSE }, // next 106 { FALSE, FALSE, FALSE }, // next
107 { FALSE, FALSE, FALSE }, // previous 107 { FALSE, FALSE, FALSE }, // previous
108 { FALSE, FALSE, FALSE }, // volume up 108 { FALSE, FALSE, FALSE }, // volume up
109 { FALSE, FALSE, FALSE }, // volume down 109 { FALSE, FALSE, FALSE }, // volume down
110 { TRUE, FALSE, FALSE }, // repeat/loop 110 { TRUE, FALSE, FALSE }, // repeat/loop
111 { FALSE, FALSE, FALSE }, // playlist 111 { FALSE, FALSE, FALSE }, // playlist
112 { FALSE, FALSE, FALSE }, // forward 112 { FALSE, FALSE, FALSE }, // forward
113 { FALSE, FALSE, FALSE } // back 113 { FALSE, FALSE, FALSE } // back
114}; 114};
115 115
116const char *skin_mask_file_names[10] = { 116const char *skin_mask_file_names[10] = {
117 "play", "stop", "next", "prev", "up", 117 "play", "stop", "next", "prev", "up",
118 "down", "loop", "playlist", "forward", "back" 118 "down", "loop", "playlist", "forward", "back"
119}; 119};
120 120
121 121
122static void changeTextColor( QWidget *w ) { 122static void changeTextColor( QWidget *w ) {
123 QPalette p = w->palette(); 123 QPalette p = w->palette();
124 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 124 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
125 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 125 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
126 w->setPalette( p ); 126 w->setPalette( p );
127} 127}
128 128
129static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 129static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
130 130
131 131
132AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 132AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
133 133
134 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 134 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
135 135
136 setCaption( tr("OpiePlayer") ); 136 setCaption( tr("OpiePlayer") );
137 137
138 Config cfg("OpiePlayer"); 138 Config cfg("OpiePlayer");
139 cfg.setGroup("Options"); 139 cfg.setGroup("Options");
140 skin = cfg.readEntry("Skin","default"); 140 skin = cfg.readEntry("Skin","default");
141 //skin = "scaleTest"; 141 //skin = "scaleTest";
142 // color of background, frame, degree of transparency 142 // color of background, frame, degree of transparency
143 143
144 QString skinPath = "opieplayer2/skins/" + skin; 144 QString skinPath = "opieplayer2/skins/" + skin;
145 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 145 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
146 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 146 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
147 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 147 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
148 148
149 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 149 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
150 imgButtonMask->fill( 0 ); 150 imgButtonMask->fill( 0 );
151 151
152 for ( int i = 0; i < 10; i++ ) { 152 for ( int i = 0; i < 10; i++ ) {
153 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); 153 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
154 masks[i] = new QBitmap( filename ); 154 masks[i] = new QBitmap( filename );
155 155
156 if ( !masks[i]->isNull() ) { 156 if ( !masks[i]->isNull() ) {
157 QImage imgMask = masks[i]->convertToImage(); 157 QImage imgMask = masks[i]->convertToImage();
158 uchar **dest = imgButtonMask->jumpTable(); 158 uchar **dest = imgButtonMask->jumpTable();
159 for ( int y = 0; y < imgUp->height(); y++ ) { 159 for ( int y = 0; y < imgUp->height(); y++ ) {
160 uchar *line = dest[y]; 160 uchar *line = dest[y];
161 for ( int x = 0; x < imgUp->width(); x++ ) 161 for ( int x = 0; x < imgUp->width(); x++ )
162 if ( !qRed( imgMask.pixel( x, y ) ) ) 162 if ( !qRed( imgMask.pixel( x, y ) ) )
163 line[x] = i + 1; 163 line[x] = i + 1;
164 } 164 }
165 } 165 }
166 166
167 } 167 }
168 168
169 for ( int i = 0; i < 10; i++ ) { 169 for ( int i = 0; i < 10; i++ ) {
170 buttonPixUp[i] = 0l; 170 buttonPixUp[i] = 0l;
171 buttonPixDown[i] = 0l; 171 buttonPixDown[i] = 0l;
172 } 172 }
173 173
174 setBackgroundPixmap( *pixBg ); 174 setBackgroundPixmap( *pixBg );
175 175
176 songInfo.setFocusPolicy( QWidget::NoFocus ); 176 songInfo.setFocusPolicy( QWidget::NoFocus );
177 changeTextColor( &songInfo ); 177 changeTextColor( &songInfo );
178 178
179 slider.setFixedHeight( 20 ); 179 slider.setFixedHeight( 20 );
180 slider.setMinValue( 0 ); 180 slider.setMinValue( 0 );
181 slider.setMaxValue( 1 ); 181 slider.setMaxValue( 1 );
182 slider.setFocusPolicy( QWidget::NoFocus ); 182 slider.setFocusPolicy( QWidget::NoFocus );
183 slider.setBackgroundPixmap( *pixBg ); 183 slider.setBackgroundPixmap( *pixBg );
184 184
185 time.setFocusPolicy( QWidget::NoFocus ); 185 time.setFocusPolicy( QWidget::NoFocus );
186 time.setAlignment( Qt::AlignCenter ); 186 time.setAlignment( Qt::AlignCenter );
187 time.setFrame(FALSE); 187 time.setFrame(FALSE);
188 changeTextColor( &time ); 188 changeTextColor( &time );
189 189
190 resizeEvent( NULL ); 190 resizeEvent( NULL );
191 191
192 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
193 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
194
195 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 192 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
196 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 193 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
197 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 194 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
198 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 195 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
199 connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 196 connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
200 197
201 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 198 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
202 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 199 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
203 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 200 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
204 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 201 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
205 202
206 // Intialise state 203 // Intialise state
207 setLength( mediaPlayerState->length() ); 204 setLength( mediaPlayerState->length() );
208 setPosition( mediaPlayerState->position() ); 205 setPosition( mediaPlayerState->position() );
209 setLooping( mediaPlayerState->fullscreen() ); 206 setLooping( mediaPlayerState->fullscreen() );
210 // setPaused( mediaPlayerState->paused() ); 207 // setPaused( mediaPlayerState->paused() );
211 setPlaying( mediaPlayerState->playing() ); 208 setPlaying( mediaPlayerState->playing() );
212 209
213} 210}
214 211
215AudioWidget::~AudioWidget() { 212AudioWidget::~AudioWidget() {
216 213
217 for ( int i = 0; i < 10; i++ ) { 214 for ( int i = 0; i < 10; i++ ) {
218 delete buttonPixUp[i]; 215 delete buttonPixUp[i];
219 delete buttonPixDown[i]; 216 delete buttonPixDown[i];
220 } 217 }
221 delete pixBg; 218 delete pixBg;
222 delete imgUp; 219 delete imgUp;
223 delete imgDn; 220 delete imgDn;
224 delete imgButtonMask; 221 delete imgButtonMask;
225 for ( int i = 0; i < 10; i++ ) { 222 for ( int i = 0; i < 10; i++ ) {
226 delete masks[i]; 223 delete masks[i];
227 } 224 }
228// mediaPlayerState->setPlaying(false); 225// mediaPlayerState->setPlaying(false);
229} 226}
230 227
231namespace { 228namespace {
232 229
233QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 230QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
234 QPixmap pix( img.width(), img.height() ); 231 QPixmap pix( img.width(), img.height() );
235 QPainter p( &pix ); 232 QPainter p( &pix );
236 p.drawTiledPixmap( pix.rect(), bg, offset ); 233 p.drawTiledPixmap( pix.rect(), bg, offset );
237 p.drawImage( 0, 0, img ); 234 p.drawImage( 0, 0, img );
238 return new QPixmap( pix ); 235 return new QPixmap( pix );
239} 236}
240 237
241 238
242QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 239QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
243 QPixmap *pixmap = new QPixmap( pix ); 240 QPixmap *pixmap = new QPixmap( pix );
244 pixmap->setMask( mask ); 241 pixmap->setMask( mask );
245 return pixmap; 242 return pixmap;
246} 243}
247 244
248}; 245};
249 246
250void AudioWidget::resizeEvent( QResizeEvent * ) { 247void AudioWidget::resizeEvent( QResizeEvent * ) {
251 int h = height(); 248 int h = height();
252 int w = width(); 249 int w = width();
253 250
254 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 251 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
255 slider.setFixedWidth( w - 110 ); 252 slider.setFixedWidth( w - 110 );
256 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 253 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
257 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 254 slider.setBackgroundOrigin( QWidget::ParentOrigin );
258 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 255 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
259 256
260 xoff = ( w - imgUp->width() ) / 2; 257 xoff = ( w - imgUp->width() ) / 2;
261 yoff = (( h - imgUp->height() ) / 2) - 10; 258 yoff = (( h - imgUp->height() ) / 2) - 10;
262 QPoint p( xoff, yoff ); 259 QPoint p( xoff, yoff );
263 260
264 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 261 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
265 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 262 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
266 263
267 for ( int i = 0; i < 10; i++ ) { 264 for ( int i = 0; i < 10; i++ ) {
268 if ( !masks[i]->isNull() ) { 265 if ( !masks[i]->isNull() ) {
269 delete buttonPixUp[i]; 266 delete buttonPixUp[i];
270 delete buttonPixDown[i]; 267 delete buttonPixDown[i];
271 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 268 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
272 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 269 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
273 } 270 }
274 } 271 }
275 272
276 delete pixUp; 273 delete pixUp;
277 delete pixDn; 274 delete pixDn;
278} 275}
279 276
280static bool audioSliderBeingMoved = FALSE; 277static bool audioSliderBeingMoved = FALSE;
281 278
282 279
283void AudioWidget::sliderPressed() { 280void AudioWidget::sliderPressed() {
284 audioSliderBeingMoved = TRUE; 281 audioSliderBeingMoved = TRUE;
285} 282}
286 283
287 284
288void AudioWidget::sliderReleased() { 285void AudioWidget::sliderReleased() {
289 audioSliderBeingMoved = FALSE; 286 audioSliderBeingMoved = FALSE;
290 if ( slider.width() == 0 ) 287 if ( slider.width() == 0 )
291 return; 288 return;
292 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 289 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
293 mediaPlayerState->setPosition( val ); 290 mediaPlayerState->setPosition( val );
294} 291}
295 292
296void AudioWidget::setPosition( long i ) { 293void AudioWidget::setPosition( long i ) {
297 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 294 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
298 updateSlider( i, mediaPlayerState->length() ); 295 updateSlider( i, mediaPlayerState->length() );
299} 296}
300 297
301 298
302void AudioWidget::setLength( long max ) { 299void AudioWidget::setLength( long max ) {
303 updateSlider( mediaPlayerState->position(), max ); 300 updateSlider( mediaPlayerState->position(), max );
304} 301}
305 302
306 303
307void AudioWidget::setView( char view ) { 304void AudioWidget::setView( char view ) {
308 305
309if ( view == 'a' ) { 306if ( view == 'a' ) {
310 // startTimer( 150 ); 307 // startTimer( 150 );
311 showMaximized(); 308 showMaximized();
312 } else { 309 } else {
313 killTimers(); 310 killTimers();
314 hide(); 311 hide();
315 } 312 }
316 // qApp->processEvents(); 313 // qApp->processEvents();
317} 314}
318 315
319 316
320void AudioWidget::setSeekable( bool isSeekable ) { 317void AudioWidget::setSeekable( bool isSeekable ) {
321 318
322 if ( isSeekable ) { 319 if ( !isSeekable ) {
323 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 320 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
324 if( !slider.isHidden()) { 321 if( !slider.isHidden()) {
325 slider.hide(); 322 slider.hide();
326 } 323 }
327 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 324 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
328 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 325 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
326 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
327 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
329 } else { 328 } else {
330 // this stops the slider from being moved, thus 329 // this stops the slider from being moved, thus
331 // does not stop stream when it reaches the end 330 // does not stop stream when it reaches the end
332 slider.show(); 331 slider.show();
333 qDebug( " CONNECT SET POSTION " ); 332 qDebug( " CONNECT SET POSTION " );
334 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 333 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
335 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 334 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
335 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
336 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
336 } 337 }
337} 338}
338 339
339 340
340static QString timeAsString( long length ) { 341static QString timeAsString( long length ) {
341 int minutes = length / 60; 342 int minutes = length / 60;
342 int seconds = length % 60; 343 int seconds = length % 60;
343 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 344 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
344} 345}
345 346
346void AudioWidget::updateSlider( long i, long max ) { 347void AudioWidget::updateSlider( long i, long max ) {
347 348
348 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 349 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
349// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 350// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
350 351
351 if ( max == 0 ) { 352 if ( max == 0 ) {
352 return; 353 return;
353 } 354 }
354 // Will flicker too much if we don't do this 355 // Will flicker too much if we don't do this
355 // Scale to something reasonable 356 // Scale to something reasonable
356 int width = slider.width(); 357 int width = slider.width();
357 int val = int((double)i * width / max); 358 int val = int((double)i * width / max);
358 if ( !audioSliderBeingMoved ) { 359 if ( !audioSliderBeingMoved ) {
359 if ( slider.value() != val ) { 360 if ( slider.value() != val ) {
360 slider.setValue( val ); 361 slider.setValue( val );
361 } 362 }
362 363
363 if ( slider.maxValue() != width ) { 364 if ( slider.maxValue() != width ) {
364 slider.setMaxValue( width ); 365 slider.setMaxValue( width );
365 } 366 }
366 } 367 }
367} 368}
368 369
369 370
370void AudioWidget::setToggleButton( int i, bool down ) { 371void AudioWidget::setToggleButton( int i, bool down ) {
371 qDebug("setToggleButton %d", i); 372 qDebug("setToggleButton %d", i);
372 if ( down != audioButtons[i].isDown ) { 373 if ( down != audioButtons[i].isDown ) {
373 toggleButton( i ); 374 toggleButton( i );
374 } 375 }
375} 376}
376 377
377 378
378void AudioWidget::toggleButton( int i ) { 379void AudioWidget::toggleButton( int i ) {
379 audioButtons[i].isDown = !audioButtons[i].isDown; 380 audioButtons[i].isDown = !audioButtons[i].isDown;
380 QPainter p(this); 381 QPainter p(this);
381 paintButton ( &p, i ); 382 paintButton ( &p, i );
382} 383}
383 384
384 385
385void AudioWidget::paintButton( QPainter *p, int i ) { 386void AudioWidget::paintButton( QPainter *p, int i ) {
386 if ( audioButtons[i].isDown ) { 387 if ( audioButtons[i].isDown ) {
387 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 388 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
388 } else { 389 } else {
389 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 390 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
390 } 391 }
391} 392}
392 393
393 394
394void AudioWidget::skipFor() { 395void AudioWidget::skipFor() {
395 skipDirection = +1; 396 skipDirection = +1;
396 startTimer( 50 ); 397 startTimer( 50 );
397 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 398 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
398} 399}
399 400
400void AudioWidget::skipBack() { 401void AudioWidget::skipBack() {
401 skipDirection = -1; 402 skipDirection = -1;
402 startTimer( 50 ); 403 startTimer( 50 );
403 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 404 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
404} 405}
405 406
406 407
407 408
408void AudioWidget::stopSkip() { 409void AudioWidget::stopSkip() {
409 killTimers(); 410 killTimers();
410} 411}
411 412
412 413
413void AudioWidget::timerEvent( QTimerEvent * ) { 414void AudioWidget::timerEvent( QTimerEvent * ) {
414 if ( skipDirection == +1 ) { 415 if ( skipDirection == +1 ) {
415 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 416 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
416 } else if ( skipDirection == -1 ) { 417 } else if ( skipDirection == -1 ) {
417 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 418 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
418 } 419 }
419} 420}
420 421
421 422
422void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 423void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
423 for ( int i = 0; i < numButtons; i++ ) { 424 for ( int i = 0; i < numButtons; i++ ) {
424 if ( event->state() == QMouseEvent::LeftButton ) { 425 if ( event->state() == QMouseEvent::LeftButton ) {
425 // The test to see if the mouse click is inside the button or not 426 // The test to see if the mouse click is inside the button or not
426 int x = event->pos().x() - xoff; 427 int x = event->pos().x() - xoff;
427 int y = event->pos().y() - yoff; 428 int y = event->pos().y() - yoff;
428 429
429 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 430 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
430 && y < imgButtonMask->height() 431 && y < imgButtonMask->height()
431 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 432 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
432 433
433 if ( isOnButton && !audioButtons[i].isHeld ) { 434 if ( isOnButton && !audioButtons[i].isHeld ) {
434 audioButtons[i].isHeld = TRUE; 435 audioButtons[i].isHeld = TRUE;
435 toggleButton(i); 436 toggleButton(i);
436 switch (i) { 437 switch (i) {
437 case AudioVolumeUp: 438 case AudioVolumeUp:
438 emit moreClicked(); 439 emit moreClicked();
439 return; 440 return;
440 case AudioVolumeDown: 441 case AudioVolumeDown:
441 emit lessClicked(); 442 emit lessClicked();
442 return; 443 return;
443 case AudioForward: 444 case AudioForward:
444 emit forwardClicked(); 445 emit forwardClicked();
445 return; 446 return;
446 case AudioBack: 447 case AudioBack:
447 emit backClicked(); 448 emit backClicked();
448 return; 449 return;
449 } 450 }
450 } else if ( !isOnButton && audioButtons[i].isHeld ) { 451 } else if ( !isOnButton && audioButtons[i].isHeld ) {
451 audioButtons[i].isHeld = FALSE; 452 audioButtons[i].isHeld = FALSE;
452 toggleButton(i); 453 toggleButton(i);
453 } 454 }
454 } else { 455 } else {
455 if ( audioButtons[i].isHeld ) { 456 if ( audioButtons[i].isHeld ) {
456 audioButtons[i].isHeld = FALSE; 457 audioButtons[i].isHeld = FALSE;
457 if ( !audioButtons[i].isToggle ) { 458 if ( !audioButtons[i].isToggle ) {
458 setToggleButton( i, FALSE ); 459 setToggleButton( i, FALSE );
459 } 460 }
460 qDebug("mouseEvent %d", i); 461 qDebug("mouseEvent %d", i);
461 switch (i) { 462 switch (i) {
462 case AudioPlay: 463 case AudioPlay:
463 if( mediaPlayerState->isPaused ) { 464 if( mediaPlayerState->isPaused ) {
464 mediaPlayerState->setPaused( FALSE ); 465 mediaPlayerState->setPaused( FALSE );
465 return; 466 return;
466 } else if( !mediaPlayerState->isPaused ) { 467 } else if( !mediaPlayerState->isPaused ) {
467 mediaPlayerState->setPaused( TRUE ); 468 mediaPlayerState->setPaused( TRUE );
468 return; 469 return;
469 } 470 }
470 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 471 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
471 case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return; 472 case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return;
472 case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return; 473 case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return;
473 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 474 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
474 case AudioVolumeUp: emit moreReleased(); return; 475 case AudioVolumeUp: emit moreReleased(); return;
475 case AudioVolumeDown: emit lessReleased(); return; 476 case AudioVolumeDown: emit lessReleased(); return;
476 case AudioPlayList: mediaPlayerState->setList(); return; 477 case AudioPlayList: mediaPlayerState->setList(); return;
477 case AudioForward: emit forwardReleased(); return; 478 case AudioForward: emit forwardReleased(); return;
478 case AudioBack: emit backReleased(); return; 479 case AudioBack: emit backReleased(); return;
479 } 480 }
480 } 481 }
481 } 482 }
482 } 483 }
483} 484}
484 485
485 486
486void AudioWidget::mousePressEvent( QMouseEvent *event ) { 487void AudioWidget::mousePressEvent( QMouseEvent *event ) {
487 mouseMoveEvent( event ); 488 mouseMoveEvent( event );
488} 489}
489 490
490 491
491void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 492void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
492 mouseMoveEvent( event ); 493 mouseMoveEvent( event );
493} 494}
494 495
495 496
496void AudioWidget::showEvent( QShowEvent* ) { 497void AudioWidget::showEvent( QShowEvent* ) {
497 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 498 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
498 mouseMoveEvent( &event ); 499 mouseMoveEvent( &event );
499} 500}
500 501
501 502
502void AudioWidget::closeEvent( QCloseEvent* ) { 503void AudioWidget::closeEvent( QCloseEvent* ) {
503 mediaPlayerState->setList(); 504 mediaPlayerState->setList();
504} 505}
505 506
506 507
507void AudioWidget::paintEvent( QPaintEvent * pe ) { 508void AudioWidget::paintEvent( QPaintEvent * pe ) {
508 if ( !pe->erased() ) { 509 if ( !pe->erased() ) {
509 // Combine with background and double buffer 510 // Combine with background and double buffer
510 QPixmap pix( pe->rect().size() ); 511 QPixmap pix( pe->rect().size() );
511 QPainter p( &pix ); 512 QPainter p( &pix );
512 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 513 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
513 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 514 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
514 for ( int i = 0; i < numButtons; i++ ) 515 for ( int i = 0; i < numButtons; i++ )
515 paintButton( &p, i ); 516 paintButton( &p, i );
516 QPainter p2( this ); 517 QPainter p2( this );
517 p2.drawPixmap( pe->rect().topLeft(), pix ); 518 p2.drawPixmap( pe->rect().topLeft(), pix );
518 } else { 519 } else {
519 QPainter p( this ); 520 QPainter p( this );
520 for ( int i = 0; i < numButtons; i++ ) 521 for ( int i = 0; i < numButtons; i++ )
521 paintButton( &p, i ); 522 paintButton( &p, i );
522 } 523 }
523} 524}
524 525
525void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 526void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
526 switch ( e->key() ) { 527 switch ( e->key() ) {
527 ////////////////////////////// Zaurus keys 528 ////////////////////////////// Zaurus keys
528 case Key_Home: 529 case Key_Home:
529 break; 530 break;
530 case Key_F9: //activity 531 case Key_F9: //activity
531 hide(); 532 hide();
532 // qDebug("Audio F9"); 533 // qDebug("Audio F9");
533 break; 534 break;
534 case Key_F10: //contacts 535 case Key_F10: //contacts
535 break; 536 break;
536 case Key_F11: //menu 537 case Key_F11: //menu
537 mediaPlayerState->toggleBlank(); 538 mediaPlayerState->toggleBlank();
538 break; 539 break;
539 case Key_F12: //home 540 case Key_F12: //home
540 break; 541 break;
541 case Key_F13: //mail 542 case Key_F13: //mail
542 mediaPlayerState->toggleBlank(); 543 mediaPlayerState->toggleBlank();
543 break; 544 break;
544 case Key_Space: { 545 case Key_Space: {
545 if(mediaPlayerState->playing()) { 546 if(mediaPlayerState->playing()) {
546 // toggleButton(1); 547 // toggleButton(1);
547 mediaPlayerState->setPlaying(FALSE); 548 mediaPlayerState->setPlaying(FALSE);
548 // toggleButton(1); 549 // toggleButton(1);
549 } else { 550 } else {
550 // toggleButton(0); 551 // toggleButton(0);
551 mediaPlayerState->setPlaying(TRUE); 552 mediaPlayerState->setPlaying(TRUE);
552 // toggleButton(0); 553 // toggleButton(0);
553 } 554 }
554 } 555 }
555 break; 556 break;
556 case Key_Down: 557 case Key_Down:
557 // toggleButton(6); 558 // toggleButton(6);
558 emit lessClicked(); 559 emit lessClicked();
559 emit lessReleased(); 560 emit lessReleased();
560 // toggleButton(6); 561 // toggleButton(6);
561 break; 562 break;
562 case Key_Up: 563 case Key_Up:
563 // toggleButton(5); 564 // toggleButton(5);
564 emit moreClicked(); 565 emit moreClicked();
565 emit moreReleased(); 566 emit moreReleased();
566 // toggleButton(5); 567 // toggleButton(5);
567 break; 568 break;
568 case Key_Right: 569 case Key_Right:
569 // toggleButton(3); 570 // toggleButton(3);
570 mediaPlayerState->setNext(); 571 mediaPlayerState->setNext();
571 // toggleButton(3); 572 // toggleButton(3);
572 break; 573 break;
573 case Key_Left: 574 case Key_Left:
574 // toggleButton(4); 575 // toggleButton(4);
575 mediaPlayerState->setPrev(); 576 mediaPlayerState->setPrev();
576 // toggleButton(4); 577 // toggleButton(4);
577 break; 578 break;
578 case Key_Escape: { 579 case Key_Escape: {
579 } 580 }
580 break; 581 break;
581 582
582 }; 583 };
583} 584}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 09dc19b..bcd941e 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,151 +1,150 @@
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 AUDIO_WIDGET_H 34#ifndef AUDIO_WIDGET_H
35#define AUDIO_WIDGET_H 35#define AUDIO_WIDGET_H
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qdrawutil.h> 39#include <qdrawutil.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qstring.h> 41#include <qstring.h>
42#include <qslider.h> 42#include <qslider.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlineedit.h> 44#include <qlineedit.h>
45 45
46 46
47class QPixmap; 47class QPixmap;
48 48
49namespace { 49namespace {
50 50
51enum AudioButtons { 51enum AudioButtons {
52 AudioPlay=0, 52 AudioPlay=0,
53 AudioStop, 53 AudioStop,
54 AudioNext, 54 AudioNext,
55 AudioPrevious, 55 AudioPrevious,
56 AudioVolumeUp, 56 AudioVolumeUp,
57 AudioVolumeDown, 57 AudioVolumeDown,
58 AudioLoop, 58 AudioLoop,
59 AudioPlayList, 59 AudioPlayList,
60 AudioForward, 60 AudioForward,
61 AudioBack 61 AudioBack
62}; 62};
63}; 63};
64 64
65class Ticker : public QFrame { 65class Ticker : public QFrame {
66 Q_OBJECT 66 Q_OBJECT
67 67
68public: 68public:
69 Ticker( QWidget* parent=0 ); 69 Ticker( QWidget* parent=0 );
70 ~Ticker(); 70 ~Ticker();
71 void setText( const QString& text ) ; 71 void setText( const QString& text ) ;
72 72
73protected: 73protected:
74 void timerEvent( QTimerEvent * ); 74 void timerEvent( QTimerEvent * );
75 void drawContents( QPainter *p ); 75 void drawContents( QPainter *p );
76private: 76private:
77 QString scrollText; 77 QString scrollText;
78 int pos, pixelLen; 78 int pos, pixelLen;
79}; 79};
80 80
81 81
82class AudioWidget : public QWidget { 82class AudioWidget : public QWidget {
83 Q_OBJECT 83 Q_OBJECT
84public: 84public:
85 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 85 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
86 ~AudioWidget(); 86 ~AudioWidget();
87 void setTickerText( const QString &text ) { songInfo.setText( text ); } 87 void setTickerText( const QString &text ) { songInfo.setText( text ); }
88public slots: 88public slots:
89 void updateSlider( long, long ); 89 void updateSlider( long, long );
90 void sliderPressed( ); 90 void sliderPressed( );
91 void sliderReleased( ); 91 void sliderReleased( );
92// void setPaused( bool b) { setToggleButton( AudioPause, b ); }
93 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 92 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
94 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } 93 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
95 void setPosition( long ); 94 void setPosition( long );
96 void setLength( long ); 95 void setLength( long );
97 void setSeekable( bool ); 96 void setSeekable( bool );
98 void setView( char ); 97 void setView( char );
99 98
100signals: 99signals:
101 void moreClicked(); 100 void moreClicked();
102 void lessClicked(); 101 void lessClicked();
103 void moreReleased(); 102 void moreReleased();
104 void lessReleased(); 103 void lessReleased();
105 void forwardClicked(); 104 void forwardClicked();
106 void backClicked(); 105 void backClicked();
107 void forwardReleased(); 106 void forwardReleased();
108 void backReleased(); 107 void backReleased();
109 void sliderMoved(long); 108 void sliderMoved(long);
110 109
111protected: 110protected:
112 void doBlank(); 111 void doBlank();
113 void doUnblank(); 112 void doUnblank();
114 void paintEvent( QPaintEvent *pe ); 113 void paintEvent( QPaintEvent *pe );
115 void showEvent( QShowEvent *se ); 114 void showEvent( QShowEvent *se );
116 void resizeEvent( QResizeEvent *re ); 115 void resizeEvent( QResizeEvent *re );
117 void mouseMoveEvent( QMouseEvent *event ); 116 void mouseMoveEvent( QMouseEvent *event );
118 void mousePressEvent( QMouseEvent *event ); 117 void mousePressEvent( QMouseEvent *event );
119 void mouseReleaseEvent( QMouseEvent *event ); 118 void mouseReleaseEvent( QMouseEvent *event );
120 void timerEvent( QTimerEvent *event ); 119 void timerEvent( QTimerEvent *event );
121 void closeEvent( QCloseEvent *event ); 120 void closeEvent( QCloseEvent *event );
122 void keyReleaseEvent( QKeyEvent *e); 121 void keyReleaseEvent( QKeyEvent *e);
123private slots: 122private slots:
124 void skipFor(); 123 void skipFor();
125 void skipBack(); 124 void skipBack();
126 void stopSkip(); 125 void stopSkip();
127private: 126private:
128 void toggleButton( int ); 127 void toggleButton( int );
129 void setToggleButton( int, bool ); 128 void setToggleButton( int, bool );
130 void paintButton( QPainter *p, int i ); 129 void paintButton( QPainter *p, int i );
131 int skipDirection; 130 int skipDirection;
132 QString skin; 131 QString skin;
133 QPixmap *pixBg; 132 QPixmap *pixBg;
134 QImage *imgUp; 133 QImage *imgUp;
135 QImage *imgDn; 134 QImage *imgDn;
136 QImage *imgButtonMask; 135 QImage *imgButtonMask;
137 QBitmap *masks[10]; 136 QBitmap *masks[10];
138 QPixmap *buttonPixUp[10]; 137 QPixmap *buttonPixUp[10];
139 QPixmap *buttonPixDown[10]; 138 QPixmap *buttonPixDown[10];
140 139
141 QPixmap *pixmaps[4]; 140 QPixmap *pixmaps[4];
142 Ticker songInfo; 141 Ticker songInfo;
143 QSlider slider; 142 QSlider slider;
144 QLineEdit time; 143 QLineEdit time;
145 int xoff, yoff; 144 int xoff, yoff;
146 bool isStreaming : 1; 145 bool isStreaming : 1;
147}; 146};
148 147
149 148
150#endif // AUDIO_WIDGET_H 149#endif // AUDIO_WIDGET_H
151 150
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 7d71d09..a847605 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,510 +1,520 @@
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/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/mediaplayerplugininterface.h> 36#include <qpe/mediaplayerplugininterface.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38 38
39 39
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qpixmap.h> 42#include <qpixmap.h>
43#include <qslider.h> 43#include <qslider.h>
44#include <qdrawutil.h> 44#include <qdrawutil.h>
45#include "videowidget.h" 45#include "videowidget.h"
46#include "mediaplayerstate.h" 46#include "mediaplayerstate.h"
47#include "playlistwidget.h" 47#include "playlistwidget.h"
48 48
49 49
50#ifdef Q_WS_QWS 50#ifdef Q_WS_QWS
51# define USE_DIRECT_PAINTER 51# define USE_DIRECT_PAINTER
52# include <qdirectpainter_qws.h> 52# include <qdirectpainter_qws.h>
53# include <qgfxraster_qws.h> 53# include <qgfxraster_qws.h>
54#endif 54#endif
55 55
56 56
57extern MediaPlayerState *mediaPlayerState; 57extern MediaPlayerState *mediaPlayerState;
58extern PlayListWidget *playList; 58extern PlayListWidget *playList;
59 59
60 60
61static const int xo = 2; // movable x offset 61static const int xo = 2; // movable x offset
62static const int yo = 0; // movable y offset 62static const int yo = 0; // movable y offset
63 63
64 64
65struct MediaButton { 65struct MediaButton {
66 bool isToggle, isHeld, isDown; 66 bool isToggle, isHeld, isDown;
67}; 67};
68 68
69MediaButton videoButtons[] = { 69MediaButton videoButtons[] = {
70 { FALSE, FALSE, FALSE }, // stop 70 { FALSE, FALSE, FALSE }, // stop
71 { TRUE, FALSE, FALSE }, // play 71 { TRUE, FALSE, FALSE }, // play
72 { FALSE, FALSE, FALSE }, // previous 72 { FALSE, FALSE, FALSE }, // previous
73 { FALSE, FALSE, FALSE }, // next 73 { FALSE, FALSE, FALSE }, // next
74 { FALSE, FALSE, FALSE }, // volUp 74 { FALSE, FALSE, FALSE }, // volUp
75 { FALSE, FALSE, FALSE }, // volDown 75 { FALSE, FALSE, FALSE }, // volDown
76 { TRUE, FALSE, FALSE } // fullscreen 76 { TRUE, FALSE, FALSE } // fullscreen
77}; 77};
78 78
79const char *skinV_mask_file_names[7] = { 79const char *skinV_mask_file_names[7] = {
80"stop","play","back","fwd","up","down","full" 80"stop","play","back","fwd","up","down","full"
81}; 81};
82 82
83static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 83static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
84 84
85 85
86VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 86VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
87QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 87QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
88 88
89 89
90 setCaption( tr("OpiePlayer - Video") ); 90 setCaption( tr("OpiePlayer - Video") );
91 91
92 videoFrame = new XineVideoWidget ( this, "Video frame" ); 92 videoFrame = new XineVideoWidget ( this, "Video frame" );
93 93
94 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 94 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
95 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 95 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
96 96
97 Config cfg("OpiePlayer"); 97 Config cfg("OpiePlayer");
98 cfg.setGroup("Options"); 98 cfg.setGroup("Options");
99 skin = cfg.readEntry("Skin","default"); 99 skin = cfg.readEntry("Skin","default");
100 100
101 QString skinPath = "opieplayer2/skins/" + skin; 101 QString skinPath = "opieplayer2/skins/" + skin;
102 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 102 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
103 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 103 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
104 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 104 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
105 105
106 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 106 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
107 imgButtonMask->fill( 0 ); 107 imgButtonMask->fill( 0 );
108 108
109 for ( int i = 0; i < 7; i++ ) { 109 for ( int i = 0; i < 7; i++ ) {
110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
111 masks[i] = new QBitmap( filename ); 111 masks[i] = new QBitmap( filename );
112 112
113 if ( !masks[i]->isNull() ) { 113 if ( !masks[i]->isNull() ) {
114 QImage imgMask = masks[i]->convertToImage(); 114 QImage imgMask = masks[i]->convertToImage();
115 uchar **dest = imgButtonMask->jumpTable(); 115 uchar **dest = imgButtonMask->jumpTable();
116 for ( int y = 0; y < imgUp->height(); y++ ) { 116 for ( int y = 0; y < imgUp->height(); y++ ) {
117 uchar *line = dest[y]; 117 uchar *line = dest[y];
118 for ( int x = 0; x < imgUp->width(); x++ ) { 118 for ( int x = 0; x < imgUp->width(); x++ ) {
119 if ( !qRed( imgMask.pixel( x, y ) ) ) 119 if ( !qRed( imgMask.pixel( x, y ) ) )
120 line[x] = i + 1; 120 line[x] = i + 1;
121 } 121 }
122 } 122 }
123 } 123 }
124 } 124 }
125 125
126 for ( int i = 0; i < 7; i++ ) { 126 for ( int i = 0; i < 7; i++ ) {
127 buttonPixUp[i] = NULL; 127 buttonPixUp[i] = NULL;
128 buttonPixDown[i] = NULL; 128 buttonPixDown[i] = NULL;
129 } 129 }
130 130
131 setBackgroundPixmap( *pixBg ); 131 setBackgroundPixmap( *pixBg );
132 132
133 slider = new QSlider( Qt::Horizontal, this ); 133 slider = new QSlider( Qt::Horizontal, this );
134 slider->setMinValue( 0 ); 134 slider->setMinValue( 0 );
135 slider->setMaxValue( 1 ); 135 slider->setMaxValue( 1 );
136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
137 //slider->setFocusPolicy( QWidget::NoFocus ); 137 //slider->setFocusPolicy( QWidget::NoFocus );
138 138
139 resizeEvent( NULL ); 139 resizeEvent( NULL );
140 140
141 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
142 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
143 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 141 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
144 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 142 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
145 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 143 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
144 connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
146 145
147 setLength( mediaPlayerState->length() ); 146 setLength( mediaPlayerState->length() );
148 setPosition( mediaPlayerState->position() ); 147 setPosition( mediaPlayerState->position() );
149 setFullscreen( mediaPlayerState->fullscreen() ); 148 setFullscreen( mediaPlayerState->fullscreen() );
150 setPlaying( mediaPlayerState->playing() ); 149 setPlaying( mediaPlayerState->playing() );
151} 150}
152 151
153 152
154VideoWidget::~VideoWidget() { 153VideoWidget::~VideoWidget() {
155 154
156 for ( int i = 0; i < 7; i++ ) { 155 for ( int i = 0; i < 7; i++ ) {
157 delete buttonPixUp[i]; 156 delete buttonPixUp[i];
158 delete buttonPixDown[i]; 157 delete buttonPixDown[i];
159 } 158 }
160 159
161 delete pixBg; 160 delete pixBg;
162 delete imgUp; 161 delete imgUp;
163 delete imgDn; 162 delete imgDn;
164 delete imgButtonMask; 163 delete imgButtonMask;
165 for ( int i = 0; i < 7; i++ ) { 164 for ( int i = 0; i < 7; i++ ) {
166 delete masks[i]; 165 delete masks[i];
167 } 166 }
168 167
169} 168}
170 169
171QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 170QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
172 QPixmap pix( img.width(), img.height() ); 171 QPixmap pix( img.width(), img.height() );
173 QPainter p( &pix ); 172 QPainter p( &pix );
174 p.drawTiledPixmap( pix.rect(), bg, offset ); 173 p.drawTiledPixmap( pix.rect(), bg, offset );
175 p.drawImage( 0, 0, img ); 174 p.drawImage( 0, 0, img );
176 return new QPixmap( pix ); 175 return new QPixmap( pix );
177} 176}
178 177
179QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 178QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
180 QPixmap *pixmap = new QPixmap( pix ); 179 QPixmap *pixmap = new QPixmap( pix );
181 pixmap->setMask( mask ); 180 pixmap->setMask( mask );
182 return pixmap; 181 return pixmap;
183} 182}
184 183
185void VideoWidget::resizeEvent( QResizeEvent * ) { 184void VideoWidget::resizeEvent( QResizeEvent * ) {
186 int h = height(); 185 int h = height();
187 int w = width(); 186 int w = width();
188 //int Vh = 160; 187 //int Vh = 160;
189 //int Vw = 220; 188 //int Vw = 220;
190 189
191 slider->setFixedWidth( w - 20 ); 190 slider->setFixedWidth( w - 20 );
192 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 191 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
193 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 192 slider->setBackgroundOrigin( QWidget::ParentOrigin );
194 slider->setFocusPolicy( QWidget::NoFocus ); 193 slider->setFocusPolicy( QWidget::NoFocus );
195 slider->setBackgroundPixmap( *pixBg ); 194 slider->setBackgroundPixmap( *pixBg );
196 195
197 xoff = 0;// ( imgUp->width() ) / 2; 196 xoff = 0;// ( imgUp->width() ) / 2;
198 if(w>h) 197 if(w>h)
199 yoff = 0; 198 yoff = 0;
200 else 199 else
201 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 200 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
202 QPoint p( xoff, yoff ); 201 QPoint p( xoff, yoff );
203 202
204 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 203 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
205 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 204 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
206 205
207 for ( int i = 0; i < 7; i++ ) { 206 for ( int i = 0; i < 7; i++ ) {
208 if ( !masks[i]->isNull() ) { 207 if ( !masks[i]->isNull() ) {
209 delete buttonPixUp[i]; 208 delete buttonPixUp[i];
210 delete buttonPixDown[i]; 209 delete buttonPixDown[i];
211 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 210 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
212 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 211 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
213 } 212 }
214 } 213 }
215 214
216 delete pixUp; 215 delete pixUp;
217 delete pixDn; 216 delete pixDn;
218} 217}
219 218
220static bool videoSliderBeingMoved = FALSE; 219static bool videoSliderBeingMoved = FALSE;
221 220
222void VideoWidget::sliderPressed() { 221void VideoWidget::sliderPressed() {
223 videoSliderBeingMoved = TRUE; 222 videoSliderBeingMoved = TRUE;
224} 223}
225 224
226void VideoWidget::sliderReleased() { 225void VideoWidget::sliderReleased() {
227 videoSliderBeingMoved = FALSE; 226 videoSliderBeingMoved = FALSE;
228 if ( slider->width() == 0 ) { 227 if ( slider->width() == 0 ) {
229 return; 228 return;
230 } 229 }
231 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 230 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
232 mediaPlayerState->setPosition( val ); 231 mediaPlayerState->setPosition( val );
233} 232}
234 233
235void VideoWidget::setPosition( long i ) { 234void VideoWidget::setPosition( long i ) {
236 updateSlider( i, mediaPlayerState->length() ); 235 updateSlider( i, mediaPlayerState->length() );
237} 236}
238 237
239 238
240void VideoWidget::setLength( long max ) { 239void VideoWidget::setLength( long max ) {
241 updateSlider( mediaPlayerState->position(), max ); 240 updateSlider( mediaPlayerState->position(), max );
242} 241}
243 242
244void VideoWidget::setView( char view ) { 243void VideoWidget::setView( char view ) {
245 244
246 if ( view == 'v' ) { 245 if ( view == 'v' ) {
247 makeVisible(); 246 makeVisible();
248 } else { 247 } else {
249 // Effectively blank the view next time we show it so it looks nicer 248 // Effectively blank the view next time we show it so it looks nicer
250 scaledWidth = 0; 249 scaledWidth = 0;
251 scaledHeight = 0; 250 scaledHeight = 0;
252 hide(); 251 hide();
253 } 252 }
254} 253}
255 254
256void VideoWidget::updateSlider( long i, long max ) { 255void VideoWidget::updateSlider( long i, long max ) {
257 // Will flicker too much if we don't do this 256 // Will flicker too much if we don't do this
258 if ( max == 0 ) { 257 if ( max == 0 ) {
259 return; 258 return;
260 } 259 }
261 int width = slider->width(); 260 int width = slider->width();
262 int val = int((double)i * width / max); 261 int val = int((double)i * width / max);
263 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 262 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
264 if ( slider->value() != val ) { 263 if ( slider->value() != val ) {
265 slider->setValue( val ); 264 slider->setValue( val );
266 } 265 }
267 if ( slider->maxValue() != width ) { 266 if ( slider->maxValue() != width ) {
268 slider->setMaxValue( width ); 267 slider->setMaxValue( width );
269 } 268 }
270 } 269 }
271} 270}
272 271
273void VideoWidget::setToggleButton( int i, bool down ) { 272void VideoWidget::setToggleButton( int i, bool down ) {
274 if ( down != videoButtons[i].isDown ) { 273 if ( down != videoButtons[i].isDown ) {
275 toggleButton( i ); 274 toggleButton( i );
276 } 275 }
277} 276}
278 277
279void VideoWidget::toggleButton( int i ) { 278void VideoWidget::toggleButton( int i ) {
280 videoButtons[i].isDown = !videoButtons[i].isDown; 279 videoButtons[i].isDown = !videoButtons[i].isDown;
281 QPainter p(this); 280 QPainter p(this);
282 paintButton ( &p, i ); 281 paintButton ( &p, i );
283} 282}
284 283
285void VideoWidget::paintButton( QPainter *p, int i ) { 284void VideoWidget::paintButton( QPainter *p, int i ) {
286 285
287 if ( videoButtons[i].isDown ) { 286 if ( videoButtons[i].isDown ) {
288 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 287 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
289 } else { 288 } else {
290 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 289 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
291 } 290 }
292} 291}
293 292
294void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 293void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
295 for ( int i = 0; i < numVButtons; i++ ) { 294 for ( int i = 0; i < numVButtons; i++ ) {
296 if ( event->state() == QMouseEvent::LeftButton ) { 295 if ( event->state() == QMouseEvent::LeftButton ) {
297 // The test to see if the mouse click is inside the button or not 296 // The test to see if the mouse click is inside the button or not
298 int x = event->pos().x() - xoff; 297 int x = event->pos().x() - xoff;
299 int y = event->pos().y() - yoff; 298 int y = event->pos().y() - yoff;
300 299
301 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 300 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
302 && y < imgButtonMask->height() 301 && y < imgButtonMask->height()
303 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 302 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
304 303
305 if ( isOnButton && !videoButtons[i].isHeld ) { 304 if ( isOnButton && !videoButtons[i].isHeld ) {
306 videoButtons[i].isHeld = TRUE; 305 videoButtons[i].isHeld = TRUE;
307 toggleButton(i); 306 toggleButton(i);
308 307
309 switch (i) { 308 switch (i) {
310 case VideoVolUp: 309 case VideoVolUp:
311 emit moreClicked(); 310 emit moreClicked();
312 return; 311 return;
313 case VideoVolDown: 312 case VideoVolDown:
314 emit lessClicked(); 313 emit lessClicked();
315 return; 314 return;
316 } 315 }
317 } else if ( !isOnButton && videoButtons[i].isHeld ) { 316 } else if ( !isOnButton && videoButtons[i].isHeld ) {
318 videoButtons[i].isHeld = FALSE; 317 videoButtons[i].isHeld = FALSE;
319 toggleButton(i); 318 toggleButton(i);
320 } 319 }
321 } else { 320 } else {
322 321
323 if ( videoButtons[i].isHeld ) { 322 if ( videoButtons[i].isHeld ) {
324 videoButtons[i].isHeld = FALSE; 323 videoButtons[i].isHeld = FALSE;
325 if ( !videoButtons[i].isToggle ) { 324 if ( !videoButtons[i].isToggle ) {
326 setToggleButton( i, FALSE ); 325 setToggleButton( i, FALSE );
327 } 326 }
328 327
329 switch(i) { 328 switch(i) {
330 329
331 case VideoPlay: { 330 case VideoPlay: {
332 if( mediaPlayerState->isPaused ) { 331 if( mediaPlayerState->isPaused ) {
333 setToggleButton( i, FALSE ); 332 setToggleButton( i, FALSE );
334 mediaPlayerState->setPaused( FALSE ); 333 mediaPlayerState->setPaused( FALSE );
335 return; 334 return;
336 } else if( !mediaPlayerState->isPaused ) { 335 } else if( !mediaPlayerState->isPaused ) {
337 setToggleButton( i, TRUE ); 336 setToggleButton( i, TRUE );
338 mediaPlayerState->setPaused( TRUE ); 337 mediaPlayerState->setPaused( TRUE );
339 return; 338 return;
340 } else { 339 } else {
341 return; 340 return;
342 } 341 }
343 } 342 }
344 343
345 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 344 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
346 case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; 345 case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return;
347 case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; 346 case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return;
348 case VideoVolUp: emit moreReleased(); return; 347 case VideoVolUp: emit moreReleased(); return;
349 case VideoVolDown: emit lessReleased(); return; 348 case VideoVolDown: emit lessReleased(); return;
350 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 349 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
351 } 350 }
352 } 351 }
353 } 352 }
354 } 353 }
355} 354}
356 355
357void VideoWidget::mousePressEvent( QMouseEvent *event ) { 356void VideoWidget::mousePressEvent( QMouseEvent *event ) {
358 mouseMoveEvent( event ); 357 mouseMoveEvent( event );
359} 358}
360 359
361void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 360void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
362 if ( mediaPlayerState->fullscreen() ) { 361 if ( mediaPlayerState->fullscreen() ) {
363 mediaPlayerState->setFullscreen( FALSE ); 362 mediaPlayerState->setFullscreen( FALSE );
364 makeVisible(); 363 makeVisible();
365 } 364 }
366 mouseMoveEvent( event ); 365 mouseMoveEvent( event );
367} 366}
368 367
369void VideoWidget::showEvent( QShowEvent* ) { 368void VideoWidget::showEvent( QShowEvent* ) {
370 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 369 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
371 mouseMoveEvent( &event ); 370 mouseMoveEvent( &event );
372} 371}
373 372
374 373
375 void VideoWidget::backToNormal() { 374 void VideoWidget::backToNormal() {
376 mediaPlayerState->setFullscreen( FALSE ); 375 mediaPlayerState->setFullscreen( FALSE );
377 makeVisible(); 376 makeVisible();
378 } 377 }
379 378
380void VideoWidget::makeVisible() { 379void VideoWidget::makeVisible() {
381 if ( mediaPlayerState->fullscreen() ) { 380 if ( mediaPlayerState->fullscreen() ) {
382 setBackgroundMode( QWidget::NoBackground ); 381 setBackgroundMode( QWidget::NoBackground );
383 showFullScreen(); 382 showFullScreen();
384 resize( qApp->desktop()->size() ); 383 resize( qApp->desktop()->size() );
385 slider->hide(); 384 slider->hide();
386 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 385 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
387 } else { 386 } else {
388 showNormal(); 387 showNormal();
389 showMaximized(); 388 showMaximized();
390 setBackgroundPixmap( *pixBg ); 389 setBackgroundPixmap( *pixBg );
391 if ( mediaPlayerState->seekable() ) {
392 slider->hide();
393 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
394 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
395 } else {
396 slider->show();
397 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
398 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
399 }
400 QWidget *d = QApplication::desktop(); 390 QWidget *d = QApplication::desktop();
401 int w = d->width(); 391 int w = d->width();
402 int h = d->height(); 392 int h = d->height();
403 393
404 if(w>h) { 394 if(w>h) {
405 int newW=(w/2)-(246/2); //this will only work with 320x240 395 int newW=(w/2)-(246/2); //this will only work with 320x240
406 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 396 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
407 } else 397 } else {
408 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 398 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
399 }
400 }
401}
402
403
404void VideoWidget::setSeekable( bool isSeekable ) {
409 405
410// qApp->processEvents(); 406 if ( !isSeekable || mediaPlayerState->fullscreen() ) {
407 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
408 if( !slider->isHidden()) {
409 slider->hide();
410 }
411 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
412 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
413 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
414 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
415 } else {
416 slider->show();
417 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
418 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
419 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
420 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
411 } 421 }
412} 422}
413 423
414 424
415void VideoWidget::paintEvent( QPaintEvent * pe) { 425void VideoWidget::paintEvent( QPaintEvent * pe) {
416 QPainter p( this ); 426 QPainter p( this );
417 427
418 if ( mediaPlayerState->fullscreen() ) { 428 if ( mediaPlayerState->fullscreen() ) {
419 // Clear the background 429 // Clear the background
420 p.setBrush( QBrush( Qt::black ) ); 430 p.setBrush( QBrush( Qt::black ) );
421 } else { 431 } else {
422 if ( !pe->erased() ) { 432 if ( !pe->erased() ) {
423 // Combine with background and double buffer 433 // Combine with background and double buffer
424 QPixmap pix( pe->rect().size() ); 434 QPixmap pix( pe->rect().size() );
425 QPainter p( &pix ); 435 QPainter p( &pix );
426 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 436 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
427 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 437 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
428 for ( int i = 0; i < numVButtons; i++ ) { 438 for ( int i = 0; i < numVButtons; i++ ) {
429 paintButton( &p, i ); 439 paintButton( &p, i );
430 } 440 }
431 QPainter p2( this ); 441 QPainter p2( this );
432 p2.drawPixmap( pe->rect().topLeft(), pix ); 442 p2.drawPixmap( pe->rect().topLeft(), pix );
433 } else { 443 } else {
434 QPainter p( this ); 444 QPainter p( this );
435 for ( int i = 0; i < numVButtons; i++ ) 445 for ( int i = 0; i < numVButtons; i++ )
436 paintButton( &p, i ); 446 paintButton( &p, i );
437 } 447 }
438 //slider->repaint( TRUE ); 448 //slider->repaint( TRUE );
439 } 449 }
440} 450}
441 451
442 452
443void VideoWidget::closeEvent( QCloseEvent* ) { 453void VideoWidget::closeEvent( QCloseEvent* ) {
444 mediaPlayerState->setList(); 454 mediaPlayerState->setList();
445} 455}
446 456
447 457
448 458
449void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 459void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
450 switch ( e->key() ) { 460 switch ( e->key() ) {
451////////////////////////////// Zaurus keys 461////////////////////////////// Zaurus keys
452 case Key_Home: 462 case Key_Home:
453 break; 463 break;
454 case Key_F9: //activity 464 case Key_F9: //activity
455 break; 465 break;
456 case Key_F10: //contacts 466 case Key_F10: //contacts
457// hide(); 467// hide();
458 break; 468 break;
459 case Key_F11: //menu 469 case Key_F11: //menu
460 break; 470 break;
461 case Key_F12: //home 471 case Key_F12: //home
462 break; 472 break;
463 case Key_F13: //mail 473 case Key_F13: //mail
464 break; 474 break;
465 case Key_Space: { 475 case Key_Space: {
466 if(mediaPlayerState->playing()) { 476 if(mediaPlayerState->playing()) {
467 mediaPlayerState->setPlaying(FALSE); 477 mediaPlayerState->setPlaying(FALSE);
468 } else { 478 } else {
469 mediaPlayerState->setPlaying(TRUE); 479 mediaPlayerState->setPlaying(TRUE);
470 } 480 }
471 } 481 }
472 break; 482 break;
473 case Key_Down: 483 case Key_Down:
474// toggleButton(6); 484// toggleButton(6);
475 emit lessClicked(); 485 emit lessClicked();
476 emit lessReleased(); 486 emit lessReleased();
477// toggleButton(6); 487// toggleButton(6);
478 break; 488 break;
479 case Key_Up: 489 case Key_Up:
480// toggleButton(5); 490// toggleButton(5);
481 emit moreClicked(); 491 emit moreClicked();
482 emit moreReleased(); 492 emit moreReleased();
483// toggleButton(5); 493// toggleButton(5);
484 break; 494 break;
485 case Key_Right: 495 case Key_Right:
486 mediaPlayerState->setNext(); 496 mediaPlayerState->setNext();
487 break; 497 break;
488 case Key_Left: 498 case Key_Left:
489 mediaPlayerState->setPrev(); 499 mediaPlayerState->setPrev();
490 break; 500 break;
491 case Key_Escape: 501 case Key_Escape:
492 break; 502 break;
493 503
494 }; 504 };
495} 505}
496 506
497XineVideoWidget* VideoWidget::vidWidget() { 507XineVideoWidget* VideoWidget::vidWidget() {
498 return videoFrame; 508 return videoFrame;
499} 509}
500 510
501 511
502void VideoWidget::setFullscreen ( bool b ) { 512void VideoWidget::setFullscreen ( bool b ) {
503 setToggleButton( VideoFullscreen, b ); 513 setToggleButton( VideoFullscreen, b );
504} 514}
505 515
506 516
507void VideoWidget::setPlaying( bool b) { 517void VideoWidget::setPlaying( bool b) {
508 setToggleButton( VideoPlay, b ); 518 setToggleButton( VideoPlay, b );
509} 519}
510 520
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 990fa5f..fd02805 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,123 +1,124 @@
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 VideoStop = 0, 44 VideoStop = 0,
45 VideoPlay, 45 VideoPlay,
46// VideoPause, 46// VideoPause,
47 VideoPrevious, 47 VideoPrevious,
48 VideoNext, 48 VideoNext,
49 VideoVolUp, 49 VideoVolUp,
50 VideoVolDown, 50 VideoVolDown,
51 VideoFullscreen 51 VideoFullscreen
52}; 52};
53 53
54class VideoWidget : public QWidget { 54class VideoWidget : public QWidget {
55 Q_OBJECT 55 Q_OBJECT
56public: 56public:
57 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 57 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
58 ~VideoWidget(); 58 ~VideoWidget();
59 59
60 60
61 XineVideoWidget* vidWidget(); 61 XineVideoWidget* vidWidget();
62public slots: 62public slots:
63 void updateSlider( long, long ); 63 void updateSlider( long, long );
64 void sliderPressed( ); 64 void sliderPressed( );
65 void sliderReleased( ); 65 void sliderReleased( );
66 void setPlaying( bool b); 66 void setPlaying( bool b);
67 void setFullscreen( bool b ); 67 void setFullscreen( bool b );
68 void makeVisible(); 68 void makeVisible();
69 void backToNormal(); 69 void backToNormal();
70 void setPosition( long ); 70 void setPosition( long );
71 void setLength( long ); 71 void setLength( long );
72 void setSeekable( bool );
72 void setView( char ); 73 void setView( char );
73 74
74signals: 75signals:
75 void moreClicked(); 76 void moreClicked();
76 void lessClicked(); 77 void lessClicked();
77 void moreReleased(); 78 void moreReleased();
78 void lessReleased(); 79 void lessReleased();
79 void sliderMoved( long ); 80 void sliderMoved( long );
80 void videoResized ( const QSize &s ); 81 void videoResized ( const QSize &s );
81 82
82protected: 83protected:
83 84
84 void resizeEvent( QResizeEvent * ); 85 void resizeEvent( QResizeEvent * );
85 void paintEvent( QPaintEvent *pe ); 86 void paintEvent( QPaintEvent *pe );
86 void showEvent( QShowEvent *se ); 87 void showEvent( QShowEvent *se );
87 void mouseMoveEvent( QMouseEvent *event ); 88 void mouseMoveEvent( QMouseEvent *event );
88 void mousePressEvent( QMouseEvent *event ); 89 void mousePressEvent( QMouseEvent *event );
89 void mouseReleaseEvent( QMouseEvent *event ); 90 void mouseReleaseEvent( QMouseEvent *event );
90 void closeEvent( QCloseEvent *event ); 91 void closeEvent( QCloseEvent *event );
91 void keyReleaseEvent( QKeyEvent *e); 92 void keyReleaseEvent( QKeyEvent *e);
92 93
93private: 94private:
94// Ticker songInfo; 95// Ticker songInfo;
95 QPixmap *pixBg; 96 QPixmap *pixBg;
96 QImage *imgUp; 97 QImage *imgUp;
97 QImage *imgDn; 98 QImage *imgDn;
98 QImage *imgButtonMask; 99 QImage *imgButtonMask;
99 QBitmap *masks[7]; 100 QBitmap *masks[7];
100 QPixmap *buttonPixUp[7]; 101 QPixmap *buttonPixUp[7];
101 QPixmap *buttonPixDown[7]; 102 QPixmap *buttonPixDown[7];
102 QString skin; 103 QString skin;
103// QPixmap *pixmaps[4]; 104// QPixmap *pixmaps[4];
104 int xoff, yoff; 105 int xoff, yoff;
105 106
106 107
107 void paintButton( QPainter *p, int i ); 108 void paintButton( QPainter *p, int i );
108 void toggleButton( int ); 109 void toggleButton( int );
109 void setToggleButton( int, bool ); 110 void setToggleButton( int, bool );
110 111
111 QString backgroundPix; 112 QString backgroundPix;
112 QSlider *slider; 113 QSlider *slider;
113 QPixmap *pixmaps[3]; 114 QPixmap *pixmaps[3];
114 QImage *currentFrame; 115 QImage *currentFrame;
115 int scaledWidth; 116 int scaledWidth;
116 int scaledHeight; 117 int scaledHeight;
117 XineVideoWidget* videoFrame; 118 XineVideoWidget* videoFrame;
118}; 119};
119 120
120#endif // VIDEO_WIDGET_H 121#endif // VIDEO_WIDGET_H
121 122
122 123
123 124
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 65ac127..c46994a 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,259 +1,259 @@
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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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 <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include "xinecontrol.h" 39#include "xinecontrol.h"
40#include "mediaplayerstate.h" 40#include "mediaplayerstate.h"
41#include "videowidget.h" 41#include "videowidget.h"
42 42
43extern MediaPlayerState *mediaPlayerState; 43extern MediaPlayerState *mediaPlayerState;
44extern VideoWidget *videoUI; 44extern VideoWidget *videoUI;
45XineControl::XineControl( QObject *parent, const char *name ) 45XineControl::XineControl( QObject *parent, const char *name )
46 : QObject( parent, name ) { 46 : QObject( parent, name ) {
47 47
48 libXine = new XINE::Lib( videoUI->vidWidget() ); 48 libXine = new XINE::Lib( videoUI->vidWidget() );
49 49
50 connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); 50 connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) );
51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
52 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); 52 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
53 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 53 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
54 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 54 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
55 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 55 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
56 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 56 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
57 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 57 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
58 58
59 disabledSuspendScreenSaver = FALSE; 59 disabledSuspendScreenSaver = FALSE;
60} 60}
61 61
62XineControl::~XineControl() { 62XineControl::~XineControl() {
63#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 63#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
64 if ( disabledSuspendScreenSaver ) { 64 if ( disabledSuspendScreenSaver ) {
65 disabledSuspendScreenSaver = FALSE; 65 disabledSuspendScreenSaver = FALSE;
66 // Re-enable the suspend mode 66 // Re-enable the suspend mode
67 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 67 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
68 } 68 }
69#endif 69#endif
70 delete libXine; 70 delete libXine;
71} 71}
72 72
73void XineControl::play( const QString& fileName ) { 73void XineControl::play( const QString& fileName ) {
74 hasVideoChannel = FALSE; 74 hasVideoChannel = FALSE;
75 hasAudioChannel = FALSE; 75 hasAudioChannel = FALSE;
76 m_fileName = fileName; 76 m_fileName = fileName;
77 77
78 qDebug("<<FILENAME: " + fileName + ">>>>"); 78 qDebug("<<FILENAME: " + fileName + ">>>>");
79 79
80 if ( !libXine->play( fileName, 0, 0 ) ) { 80 if ( !libXine->play( fileName, 0, 0 ) ) {
81 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 81 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
82 // toggle stop so the the play button is reset 82 // toggle stop so the the play button is reset
83 mediaPlayerState->setPlaying( false ); 83 mediaPlayerState->setPlaying( false );
84 return; 84 return;
85 } 85 }
86 mediaPlayerState->setPlaying( true ); 86 mediaPlayerState->setPlaying( true );
87 87
88 char whichGui; 88 char whichGui;
89 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); 89 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
90 if ( !libXine->hasVideo() ) { 90 if ( !libXine->hasVideo() ) {
91 whichGui = 'a'; 91 whichGui = 'a';
92 qDebug("HAS AUDIO"); 92 qDebug("HAS AUDIO");
93 libXine->setShowVideo( false ); 93 libXine->setShowVideo( false );
94 hasAudioChannel = TRUE; 94 hasAudioChannel = TRUE;
95 } else { 95 } else {
96 whichGui = 'v'; 96 whichGui = 'v';
97 qDebug("HAS VIDEO"); 97 qDebug("HAS VIDEO");
98 libXine->setShowVideo( true ); 98 libXine->setShowVideo( true );
99 hasVideoChannel = TRUE; 99 hasVideoChannel = TRUE;
100 } 100 }
101 // determine if slider is shown 101 // determine if slider is shown
102 mediaPlayerState->setIsSeekable( !libXine->isSeekable() ); 102 mediaPlayerState->setIsSeekable( libXine->isSeekable() );
103 103
104 // which gui (video / audio) 104 // which gui (video / audio)
105 mediaPlayerState->setView( whichGui ); 105 mediaPlayerState->setView( whichGui );
106 106
107#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 107#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
108 if ( !disabledSuspendScreenSaver ) { 108 if ( !disabledSuspendScreenSaver ) {
109 disabledSuspendScreenSaver = TRUE; 109 disabledSuspendScreenSaver = TRUE;
110 // Stop the screen from blanking and power saving state 110 // Stop the screen from blanking and power saving state
111 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 111 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
112 << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 112 << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend );
113 } 113 }
114#endif 114#endif
115 115
116 length(); 116 length();
117 position(); 117 position();
118} 118}
119 119
120void XineControl::nextMedia() { 120void XineControl::nextMedia() {
121 mediaPlayerState->setNext(); 121 mediaPlayerState->setNext();
122} 122}
123 123
124void XineControl::setGamma( int value ) { 124void XineControl::setGamma( int value ) {
125 libXine->setGamma( value ); 125 libXine->setGamma( value );
126} 126}
127 127
128void XineControl::stop( bool isSet ) { 128void XineControl::stop( bool isSet ) {
129 if ( !isSet ) { 129 if ( !isSet ) {
130 libXine->stop(); 130 libXine->stop();
131 131
132#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 132#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
133 if ( disabledSuspendScreenSaver ) { 133 if ( disabledSuspendScreenSaver ) {
134 disabledSuspendScreenSaver = FALSE; 134 disabledSuspendScreenSaver = FALSE;
135 // Re-enable the suspend mode 135 // Re-enable the suspend mode
136 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 136 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
137 } 137 }
138#endif 138#endif
139 } 139 }
140} 140}
141 141
142/** 142/**
143 * Pause playback 143 * Pause playback
144 * @isSet 144 * @isSet
145 */ 145 */
146void XineControl::pause( bool isSet) { 146void XineControl::pause( bool isSet) {
147 if ( isSet ) { 147 if ( isSet ) {
148 libXine->pause(); 148 libXine->pause();
149 } else { 149 } else {
150 libXine->play( m_fileName, 0, m_currentTime ); 150 libXine->play( m_fileName, 0, m_currentTime );
151 } 151 }
152} 152}
153 153
154 154
155/** 155/**
156 * get current time in playback 156 * get current time in playback
157 */ 157 */
158long XineControl::currentTime() { 158long XineControl::currentTime() {
159 // todo: jede sekunde überprüfen 159 // todo: jede sekunde überprüfen
160 m_currentTime = libXine->currentTime(); 160 m_currentTime = libXine->currentTime();
161 return m_currentTime; 161 return m_currentTime;
162 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 162 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
163} 163}
164 164
165/** 165/**
166 * Set the length of the media file 166 * Set the length of the media file
167 */ 167 */
168void XineControl::length() { 168void XineControl::length() {
169 m_length = libXine->length(); 169 m_length = libXine->length();
170 mediaPlayerState->setLength( m_length ); 170 mediaPlayerState->setLength( m_length );
171} 171}
172 172
173 173
174/** 174/**
175 * Reports the position the xine backend is at right now 175 * Reports the position the xine backend is at right now
176 * @return long the postion in seconds 176 * @return long the postion in seconds
177 */ 177 */
178long XineControl::position() { 178long XineControl::position() {
179 m_position = ( currentTime() ); 179 m_position = ( currentTime() );
180 mediaPlayerState->updatePosition( m_position ); 180 mediaPlayerState->updatePosition( m_position );
181 long emitPos = (long)m_position; 181 long emitPos = (long)m_position;
182 emit positionChanged( emitPos ); 182 emit positionChanged( emitPos );
183 if( mediaPlayerState->isPlaying ) { 183 if( mediaPlayerState->isPlaying ) {
184 // needs to be stopped the media is stopped 184 // needs to be stopped the media is stopped
185 QTimer::singleShot( 1000, this, SLOT( position() ) ); 185 QTimer::singleShot( 1000, this, SLOT( position() ) );
186 } 186 }
187 // qDebug("POSITION : %d", m_position); 187 // qDebug("POSITION : %d", m_position);
188 return m_position; 188 return m_position;
189} 189}
190 190
191/** 191/**
192 * Set videoplayback to fullscreen 192 * Set videoplayback to fullscreen
193 * @param isSet 193 * @param isSet
194 */ 194 */
195void XineControl::setFullscreen( bool isSet ) { 195void XineControl::setFullscreen( bool isSet ) {
196 libXine->showVideoFullScreen( isSet ); 196 libXine->showVideoFullScreen( isSet );
197} 197}
198 198
199 199
200QString XineControl::getMetaInfo() { 200QString XineControl::getMetaInfo() {
201 201
202 QString returnString; 202 QString returnString;
203 203
204 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 204 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
205 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 205 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
206 } 206 }
207 207
208 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 208 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
209 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 209 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
210 } 210 }
211 211
212 if ( !libXine->metaInfo( 2 ).isEmpty() ) { 212 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
213 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); 213 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
214 } 214 }
215 215
216 if ( !libXine->metaInfo( 3 ).isEmpty() ) { 216 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
217 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); 217 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
218 } 218 }
219 219
220 if ( !libXine->metaInfo( 4 ).isEmpty() ) { 220 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
221 returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); 221 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
222 } 222 }
223 223
224 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 224 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
225 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 225 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
226 } 226 }
227 return returnString; 227 return returnString;
228} 228}
229 229
230QString XineControl::getErrorCode() { 230QString XineControl::getErrorCode() {
231 231
232 int errorCode = libXine->error(); 232 int errorCode = libXine->error();
233 233
234 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); 234 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) );
235 235
236 if ( errorCode == 1 ) { 236 if ( errorCode == 1 ) {
237 return tr( "No input plugin found for this media type" ); 237 return tr( "No input plugin found for this media type" );
238 } else if ( errorCode == 2 ) { 238 } else if ( errorCode == 2 ) {
239 return tr( "No demux plugin found for this media type" ); 239 return tr( "No demux plugin found for this media type" );
240 } else if ( errorCode == 3 ) { 240 } else if ( errorCode == 3 ) {
241 return tr( "Demuxing failed for this media type" ); 241 return tr( "Demuxing failed for this media type" );
242 } else if ( errorCode == 4 ) { 242 } else if ( errorCode == 4 ) {
243 return tr( "Malformed MRL" ); 243 return tr( "Malformed MRL" );
244 } else { 244 } else {
245 return tr( "Some other error" ); 245 return tr( "Some other error" );
246 } 246 }
247} 247}
248 248
249/** 249/**
250 * Seek to a position in the track 250 * Seek to a position in the track
251 * @param second the second to jump to 251 * @param second the second to jump to
252 */ 252 */
253void XineControl::seekTo( long second ) { 253void XineControl::seekTo( long second ) {
254 libXine->seekTo( (int)second ); 254 libXine->seekTo( (int)second );
255} 255}
256 256
257void XineControl::videoResized ( const QSize &s ) { 257void XineControl::videoResized ( const QSize &s ) {
258 libXine->resize( s ); 258 libXine->resize( s );
259} 259}