summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-18 17:35:58 (UTC)
committer harlekin <harlekin>2002-08-18 17:35:58 (UTC)
commita5c95b42314fe8f7bdcfe2644e980d43c257fee0 (patch) (unidiff)
treedc27b266a5e1e60fa269e2182a9cfd36507b12ca
parent6171a4b58f242c75e9ce02728651ca4fb743e747 (diff)
downloadopie-a5c95b42314fe8f7bdcfe2644e980d43c257fee0.zip
opie-a5c95b42314fe8f7bdcfe2644e980d43c257fee0.tar.gz
opie-a5c95b42314fe8f7bdcfe2644e980d43c257fee0.tar.bz2
hack to make startup faster, still need sanity checks
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp3
5 files changed, 13 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 604ed3a..6d867e5 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,590 +1,593 @@
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 44
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 50
51extern MediaPlayerState *mediaPlayerState; 51extern MediaPlayerState *mediaPlayerState;
52 52
53static const int xo = -2; // movable x offset 53static const int xo = -2; // movable x offset
54static const int yo = 22; // movable y offset 54static const int yo = 22; // movable y offset
55 55
56 56
57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
58 setFrameStyle( WinPanel | Sunken ); 58 setFrameStyle( WinPanel | Sunken );
59 setText( "No Song" ); 59 setText( "No Song" );
60} 60}
61 61
62Ticker::~Ticker() { 62Ticker::~Ticker() {
63} 63}
64 64
65void Ticker::setText( const QString& text ) { 65void Ticker::setText( const QString& text ) {
66 pos = 0; // reset it everytime the text is changed 66 pos = 0; // reset it everytime the text is changed
67 scrollText = text; 67 scrollText = text;
68 pixelLen = fontMetrics().width( scrollText ); 68 pixelLen = fontMetrics().width( scrollText );
69 killTimers(); 69 killTimers();
70 if ( pixelLen > width() ) { 70 if ( pixelLen > width() ) {
71 startTimer( 50 ); 71 startTimer( 50 );
72 } 72 }
73 update(); 73 update();
74} 74}
75 75
76 76
77void Ticker::timerEvent( QTimerEvent * ) { 77void Ticker::timerEvent( QTimerEvent * ) {
78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
79 scroll( -1, 0, contentsRect() ); 79 scroll( -1, 0, contentsRect() );
80 repaint( FALSE ); 80 repaint( FALSE );
81} 81}
82 82
83void Ticker::drawContents( QPainter *p ) { 83void Ticker::drawContents( QPainter *p ) {
84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
86 QPixmap pm( width(), height() ); 86 QPixmap pm( width(), height() );
87 pm.fill( colorGroup().base() ); 87 pm.fill( colorGroup().base() );
88 QPainter pmp( &pm ); 88 QPainter pmp( &pm );
89 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 89 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
90 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 90 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
91 } 91 }
92 p->drawPixmap( 0, 0, pm ); 92 p->drawPixmap( 0, 0, pm );
93} 93}
94 94
95struct MediaButton { 95struct MediaButton {
96 bool isToggle, isHeld, isDown; 96 bool isToggle, isHeld, isDown;
97}; 97};
98 98
99//Layout information for the audioButtons (and if it is a toggle button or not) 99//Layout information for the audioButtons (and if it is a toggle button or not)
100MediaButton audioButtons[] = { 100MediaButton audioButtons[] = {
101 { TRUE, FALSE, FALSE }, // play 101 { TRUE, FALSE, FALSE }, // play
102 { FALSE, FALSE, FALSE }, // stop 102 { FALSE, FALSE, FALSE }, // stop
103 { FALSE, FALSE, FALSE }, // next 103 { FALSE, FALSE, FALSE }, // next
104 { FALSE, FALSE, FALSE }, // previous 104 { FALSE, FALSE, FALSE }, // previous
105 { FALSE, FALSE, FALSE }, // volume up 105 { FALSE, FALSE, FALSE }, // volume up
106 { FALSE, FALSE, FALSE }, // volume down 106 { FALSE, FALSE, FALSE }, // volume down
107 { TRUE, FALSE, FALSE }, // repeat/loop 107 { TRUE, FALSE, FALSE }, // repeat/loop
108 { FALSE, FALSE, FALSE }, // playlist 108 { FALSE, FALSE, FALSE }, // playlist
109 { FALSE, FALSE, FALSE }, // forward 109 { FALSE, FALSE, FALSE }, // forward
110 { FALSE, FALSE, FALSE } // back 110 { FALSE, FALSE, FALSE } // back
111}; 111};
112 112
113const char *skin_mask_file_names[10] = { 113const char *skin_mask_file_names[10] = {
114 "play", "stop", "next", "prev", "up", 114 "play", "stop", "next", "prev", "up",
115 "down", "loop", "playlist", "forward", "back" 115 "down", "loop", "playlist", "forward", "back"
116}; 116};
117 117
118 118
119static void changeTextColor( QWidget *w ) { 119static void changeTextColor( QWidget *w ) {
120 QPalette p = w->palette(); 120 QPalette p = w->palette();
121 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 121 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
122 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 122 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
123 w->setPalette( p ); 123 w->setPalette( p );
124} 124}
125 125
126static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 126static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
127 127
128 128
129AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 129AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
130 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 130 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
131
132
133
131 setCaption( tr("OpiePlayer") ); 134 setCaption( tr("OpiePlayer") );
132 135
133 Config cfg("OpiePlayer"); 136 Config cfg("OpiePlayer");
134 cfg.setGroup("Options"); 137 cfg.setGroup("Options");
135 skin = cfg.readEntry("Skin","default"); 138 skin = cfg.readEntry("Skin","default");
136 //skin = "scaleTest"; 139 //skin = "scaleTest";
137// color of background, frame, degree of transparency 140// color of background, frame, degree of transparency
138 141
139 QString skinPath = "opieplayer2/skins/" + skin; 142 QString skinPath = "opieplayer2/skins/" + skin;
140 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 143 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
141 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 144 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
142 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 145 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
143 146
144 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 147 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
145 imgButtonMask->fill( 0 ); 148 imgButtonMask->fill( 0 );
146 149
147 for ( int i = 0; i < 10; i++ ) { 150 for ( int i = 0; i < 10; i++ ) {
148 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 151 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
149 masks[i] = new QBitmap( filename ); 152 masks[i] = new QBitmap( filename );
150 153
151 if ( !masks[i]->isNull() ) { 154 if ( !masks[i]->isNull() ) {
152 QImage imgMask = masks[i]->convertToImage(); 155 QImage imgMask = masks[i]->convertToImage();
153 uchar **dest = imgButtonMask->jumpTable(); 156 uchar **dest = imgButtonMask->jumpTable();
154 for ( int y = 0; y < imgUp->height(); y++ ) { 157 for ( int y = 0; y < imgUp->height(); y++ ) {
155 uchar *line = dest[y]; 158 uchar *line = dest[y];
156 for ( int x = 0; x < imgUp->width(); x++ ) 159 for ( int x = 0; x < imgUp->width(); x++ )
157 if ( !qRed( imgMask.pixel( x, y ) ) ) 160 if ( !qRed( imgMask.pixel( x, y ) ) )
158 line[x] = i + 1; 161 line[x] = i + 1;
159 } 162 }
160 } 163 }
161 164
162 } 165 }
163 166
164 for ( int i = 0; i < 10; i++ ) { 167 for ( int i = 0; i < 10; i++ ) {
165 buttonPixUp[i] = NULL; 168 buttonPixUp[i] = NULL;
166 buttonPixDown[i] = NULL; 169 buttonPixDown[i] = NULL;
167 } 170 }
168 171
169 setBackgroundPixmap( *pixBg ); 172 setBackgroundPixmap( *pixBg );
170 173
171 songInfo.setFocusPolicy( QWidget::NoFocus ); 174 songInfo.setFocusPolicy( QWidget::NoFocus );
172 changeTextColor( &songInfo ); 175 changeTextColor( &songInfo );
173 176
174 slider.setFixedHeight( 20 ); 177 slider.setFixedHeight( 20 );
175 slider.setMinValue( 0 ); 178 slider.setMinValue( 0 );
176 slider.setMaxValue( 1 ); 179 slider.setMaxValue( 1 );
177 slider.setFocusPolicy( QWidget::NoFocus ); 180 slider.setFocusPolicy( QWidget::NoFocus );
178 slider.setBackgroundPixmap( *pixBg ); 181 slider.setBackgroundPixmap( *pixBg );
179 182
180 time.setFocusPolicy( QWidget::NoFocus ); 183 time.setFocusPolicy( QWidget::NoFocus );
181 time.setAlignment( Qt::AlignCenter ); 184 time.setAlignment( Qt::AlignCenter );
182 time.setFrame(FALSE); 185 time.setFrame(FALSE);
183 changeTextColor( &time ); 186 changeTextColor( &time );
184 187
185 resizeEvent( NULL ); 188 resizeEvent( NULL );
186 189
187 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 190 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
188 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 191 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
189 192
190 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 193 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
191 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 194 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
192 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 195 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
193// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 196// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
194 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 197 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
195 198
196 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 199 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
197 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 200 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
198 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 201 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
199 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 202 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
200 203
201 204
202 205
203 // Intialise state 206 // Intialise state
204 setLength( mediaPlayerState->length() ); 207 setLength( mediaPlayerState->length() );
205 setPosition( mediaPlayerState->position() ); 208 setPosition( mediaPlayerState->position() );
206 setLooping( mediaPlayerState->fullscreen() ); 209 setLooping( mediaPlayerState->fullscreen() );
207// setPaused( mediaPlayerState->paused() ); 210// setPaused( mediaPlayerState->paused() );
208 setPlaying( mediaPlayerState->playing() ); 211 setPlaying( mediaPlayerState->playing() );
209 212
210} 213}
211 214
212AudioWidget::~AudioWidget() { 215AudioWidget::~AudioWidget() {
213 216
214 for ( int i = 0; i < 10; i++ ) { 217 for ( int i = 0; i < 10; i++ ) {
215 delete buttonPixUp[i]; 218 delete buttonPixUp[i];
216 delete buttonPixDown[i]; 219 delete buttonPixDown[i];
217 } 220 }
218 delete pixBg; 221 delete pixBg;
219 delete imgUp; 222 delete imgUp;
220 delete imgDn; 223 delete imgDn;
221 delete imgButtonMask; 224 delete imgButtonMask;
222 for ( int i = 0; i < 10; i++ ) { 225 for ( int i = 0; i < 10; i++ ) {
223 delete masks[i]; 226 delete masks[i];
224 } 227 }
225} 228}
226 229
227QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 230QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
228 QPixmap pix( img.width(), img.height() ); 231 QPixmap pix( img.width(), img.height() );
229 QPainter p( &pix ); 232 QPainter p( &pix );
230 p.drawTiledPixmap( pix.rect(), bg, offset ); 233 p.drawTiledPixmap( pix.rect(), bg, offset );
231 p.drawImage( 0, 0, img ); 234 p.drawImage( 0, 0, img );
232 return new QPixmap( pix ); 235 return new QPixmap( pix );
233} 236}
234 237
235 238
236QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 239QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
237{ 240{
238 QPixmap *pixmap = new QPixmap( pix ); 241 QPixmap *pixmap = new QPixmap( pix );
239 pixmap->setMask( mask ); 242 pixmap->setMask( mask );
240 return pixmap; 243 return pixmap;
241} 244}
242 245
243 246
244 247
245void AudioWidget::resizeEvent( QResizeEvent * ) { 248void AudioWidget::resizeEvent( QResizeEvent * ) {
246 int h = height(); 249 int h = height();
247 int w = width(); 250 int w = width();
248 251
249 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 252 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
250 slider.setFixedWidth( w - 110 ); 253 slider.setFixedWidth( w - 110 );
251 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 254 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
252 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 255 slider.setBackgroundOrigin( QWidget::ParentOrigin );
253 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 256 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
254 257
255 xoff = ( w - imgUp->width() ) / 2; 258 xoff = ( w - imgUp->width() ) / 2;
256 yoff = (( h - imgUp->height() ) / 2) - 10; 259 yoff = (( h - imgUp->height() ) / 2) - 10;
257 QPoint p( xoff, yoff ); 260 QPoint p( xoff, yoff );
258 261
259 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 262 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
260 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 263 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
261 264
262 for ( int i = 0; i < 10; i++ ) { 265 for ( int i = 0; i < 10; i++ ) {
263 if ( !masks[i]->isNull() ) { 266 if ( !masks[i]->isNull() ) {
264 delete buttonPixUp[i]; 267 delete buttonPixUp[i];
265 delete buttonPixDown[i]; 268 delete buttonPixDown[i];
266 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 269 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
267 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 270 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
268 } 271 }
269 } 272 }
270 273
271 delete pixUp; 274 delete pixUp;
272 delete pixDn; 275 delete pixDn;
273} 276}
274 277
275static bool audioSliderBeingMoved = FALSE; 278static bool audioSliderBeingMoved = FALSE;
276 279
277 280
278void AudioWidget::sliderPressed() { 281void AudioWidget::sliderPressed() {
279 audioSliderBeingMoved = TRUE; 282 audioSliderBeingMoved = TRUE;
280} 283}
281 284
282 285
283void AudioWidget::sliderReleased() { 286void AudioWidget::sliderReleased() {
284 audioSliderBeingMoved = FALSE; 287 audioSliderBeingMoved = FALSE;
285 if ( slider.width() == 0 ) 288 if ( slider.width() == 0 )
286 return; 289 return;
287 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 290 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
288 mediaPlayerState->setPosition( val ); 291 mediaPlayerState->setPosition( val );
289} 292}
290 293
291void AudioWidget::setPosition( long i ) { 294void AudioWidget::setPosition( long i ) {
292// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 295// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
293 updateSlider( i, mediaPlayerState->length() ); 296 updateSlider( i, mediaPlayerState->length() );
294} 297}
295 298
296 299
297void AudioWidget::setLength( long max ) { 300void AudioWidget::setLength( long max ) {
298 updateSlider( mediaPlayerState->position(), max ); 301 updateSlider( mediaPlayerState->position(), max );
299} 302}
300 303
301 304
302void AudioWidget::setView( char view ) { 305void AudioWidget::setView( char view ) {
303 306
304// this isnt working for some reason 307// this isnt working for some reason
305 308
306 if ( mediaPlayerState->streaming() ) { 309 if ( mediaPlayerState->streaming() ) {
307 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 310 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
308 if( !slider.isHidden()) { 311 if( !slider.isHidden()) {
309 slider.hide(); 312 slider.hide();
310 } 313 }
311 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 314 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
312 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 315 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
313 } else { 316 } else {
314 // this stops the slider from being moved, thus 317 // this stops the slider from being moved, thus
315 // does not stop stream when it reaches the end 318 // does not stop stream when it reaches the end
316 slider.show(); 319 slider.show();
317 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 320 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
318 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 321 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
319 } 322 }
320 323
321 if ( view == 'a' ) { 324 if ( view == 'a' ) {
322 // startTimer( 150 ); 325 // startTimer( 150 );
323 showMaximized(); 326 showMaximized();
324 } else { 327 } else {
325 killTimers(); 328 killTimers();
326 hide(); 329 hide();
327 } 330 }
328 qApp->processEvents(); 331 qApp->processEvents();
329} 332}
330 333
331 334
332static QString timeAsString( long length ) { 335static QString timeAsString( long length ) {
333 int minutes = length / 60; 336 int minutes = length / 60;
334 int seconds = length % 60; 337 int seconds = length % 60;
335 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 338 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
336} 339}
337 340
338void AudioWidget::updateSlider( long i, long max ) { 341void AudioWidget::updateSlider( long i, long max ) {
339 342
340 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 343 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
341// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 344// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
342 345
343 if ( max == 0 ) { 346 if ( max == 0 ) {
344 return; 347 return;
345 } 348 }
346 // Will flicker too much if we don't do this 349 // Will flicker too much if we don't do this
347 // Scale to something reasonable 350 // Scale to something reasonable
348 int width = slider.width(); 351 int width = slider.width();
349 int val = int((double)i * width / max); 352 int val = int((double)i * width / max);
350 if ( !audioSliderBeingMoved ) { 353 if ( !audioSliderBeingMoved ) {
351 if ( slider.value() != val ) { 354 if ( slider.value() != val ) {
352 slider.setValue( val ); 355 slider.setValue( val );
353 } 356 }
354 357
355 if ( slider.maxValue() != width ) { 358 if ( slider.maxValue() != width ) {
356 slider.setMaxValue( width ); 359 slider.setMaxValue( width );
357 } 360 }
358 } 361 }
359} 362}
360 363
361 364
362void AudioWidget::setToggleButton( int i, bool down ) { 365void AudioWidget::setToggleButton( int i, bool down ) {
363 qDebug("setToggleButton %d", i); 366 qDebug("setToggleButton %d", i);
364 if ( down != audioButtons[i].isDown ) { 367 if ( down != audioButtons[i].isDown ) {
365 toggleButton( i ); 368 toggleButton( i );
366 } 369 }
367} 370}
368 371
369 372
370void AudioWidget::toggleButton( int i ) { 373void AudioWidget::toggleButton( int i ) {
371 audioButtons[i].isDown = !audioButtons[i].isDown; 374 audioButtons[i].isDown = !audioButtons[i].isDown;
372 QPainter p(this); 375 QPainter p(this);
373 paintButton ( &p, i ); 376 paintButton ( &p, i );
374} 377}
375 378
376 379
377void AudioWidget::paintButton( QPainter *p, int i ) { 380void AudioWidget::paintButton( QPainter *p, int i ) {
378 if ( audioButtons[i].isDown ) { 381 if ( audioButtons[i].isDown ) {
379 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 382 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
380 } else { 383 } else {
381 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 384 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
382 } 385 }
383} 386}
384 387
385 388
386void AudioWidget::skipFor() { 389void AudioWidget::skipFor() {
387 skipDirection = +1; 390 skipDirection = +1;
388 startTimer( 50 ); 391 startTimer( 50 );
389 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 392 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
390} 393}
391 394
392void AudioWidget::skipBack() { 395void AudioWidget::skipBack() {
393 skipDirection = -1; 396 skipDirection = -1;
394 startTimer( 50 ); 397 startTimer( 50 );
395 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 398 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
396} 399}
397 400
398 401
399 402
400void AudioWidget::stopSkip() { 403void AudioWidget::stopSkip() {
401 killTimers(); 404 killTimers();
402} 405}
403 406
404 407
405void AudioWidget::timerEvent( QTimerEvent * ) { 408void AudioWidget::timerEvent( QTimerEvent * ) {
406 if ( skipDirection == +1 ) { 409 if ( skipDirection == +1 ) {
407 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 410 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
408 } else if ( skipDirection == -1 ) { 411 } else if ( skipDirection == -1 ) {
409 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 412 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
410 } 413 }
411} 414}
412 415
413 416
414void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 417void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
415 for ( int i = 0; i < numButtons; i++ ) { 418 for ( int i = 0; i < numButtons; i++ ) {
416 if ( event->state() == QMouseEvent::LeftButton ) { 419 if ( event->state() == QMouseEvent::LeftButton ) {
417 // The test to see if the mouse click is inside the button or not 420 // The test to see if the mouse click is inside the button or not
418 int x = event->pos().x() - xoff; 421 int x = event->pos().x() - xoff;
419 int y = event->pos().y() - yoff; 422 int y = event->pos().y() - yoff;
420 423
421 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 424 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
422 && y < imgButtonMask->height() 425 && y < imgButtonMask->height()
423 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 426 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
424 427
425 if ( isOnButton && !audioButtons[i].isHeld ) { 428 if ( isOnButton && !audioButtons[i].isHeld ) {
426 audioButtons[i].isHeld = TRUE; 429 audioButtons[i].isHeld = TRUE;
427 toggleButton(i); 430 toggleButton(i);
428 switch (i) { 431 switch (i) {
429 case AudioVolumeUp: 432 case AudioVolumeUp:
430 emit moreClicked(); 433 emit moreClicked();
431 return; 434 return;
432 case AudioVolumeDown: 435 case AudioVolumeDown:
433 emit lessClicked(); 436 emit lessClicked();
434 return; 437 return;
435 case AudioForward: 438 case AudioForward:
436 emit forwardClicked(); 439 emit forwardClicked();
437 return; 440 return;
438 case AudioBack: 441 case AudioBack:
439 emit backClicked(); 442 emit backClicked();
440 return; 443 return;
441 } 444 }
442 } 445 }
443 else if ( !isOnButton && audioButtons[i].isHeld ) { 446 else if ( !isOnButton && audioButtons[i].isHeld ) {
444 audioButtons[i].isHeld = FALSE; 447 audioButtons[i].isHeld = FALSE;
445 toggleButton(i); 448 toggleButton(i);
446 } 449 }
447 } else { 450 } else {
448 if ( audioButtons[i].isHeld ) { 451 if ( audioButtons[i].isHeld ) {
449 audioButtons[i].isHeld = FALSE; 452 audioButtons[i].isHeld = FALSE;
450 if ( !audioButtons[i].isToggle ) { 453 if ( !audioButtons[i].isToggle ) {
451 setToggleButton( i, FALSE ); 454 setToggleButton( i, FALSE );
452 } 455 }
453 switch (i) { 456 switch (i) {
454 case AudioPlay: 457 case AudioPlay:
455 if( mediaPlayerState->isPaused ) { 458 if( mediaPlayerState->isPaused ) {
456// setToggleButton( i, FALSE ); 459// setToggleButton( i, FALSE );
457 mediaPlayerState->setPaused( FALSE ); 460 mediaPlayerState->setPaused( FALSE );
458 return; 461 return;
459 } else if( !mediaPlayerState->isPaused ) { 462 } else if( !mediaPlayerState->isPaused ) {
460// setToggleButton( i, TRUE ); 463// setToggleButton( i, TRUE );
461 mediaPlayerState->setPaused( TRUE ); 464 mediaPlayerState->setPaused( TRUE );
462 return; 465 return;
463 } else { 466 } else {
464 // setToggleButton( i, TRUE ); 467 // setToggleButton( i, TRUE );
465 // mediaPlayerState->setPlaying( videoButtons[i].isDown ); 468 // mediaPlayerState->setPlaying( videoButtons[i].isDown );
466 } 469 }
467 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 470 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
468 case AudioNext: mediaPlayerState->setNext(); return; 471 case AudioNext: mediaPlayerState->setNext(); return;
469 case AudioPrevious: mediaPlayerState->setPrev(); return; 472 case AudioPrevious: mediaPlayerState->setPrev(); return;
470 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 473 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
471 case AudioVolumeUp: emit moreReleased(); return; 474 case AudioVolumeUp: emit moreReleased(); return;
472 case AudioVolumeDown: emit lessReleased(); return; 475 case AudioVolumeDown: emit lessReleased(); return;
473 case AudioPlayList: mediaPlayerState->setList(); return; 476 case AudioPlayList: mediaPlayerState->setList(); return;
474 case AudioForward: emit forwardReleased(); return; 477 case AudioForward: emit forwardReleased(); return;
475 case AudioBack: emit backReleased(); return; 478 case AudioBack: emit backReleased(); return;
476 } 479 }
477 } 480 }
478 } 481 }
479 } 482 }
480} 483}
481 484
482 485
483void AudioWidget::mousePressEvent( QMouseEvent *event ) { 486void AudioWidget::mousePressEvent( QMouseEvent *event ) {
484 mouseMoveEvent( event ); 487 mouseMoveEvent( event );
485} 488}
486 489
487 490
488void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 491void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
489 mouseMoveEvent( event ); 492 mouseMoveEvent( event );
490} 493}
491 494
492 495
493void AudioWidget::showEvent( QShowEvent* ) { 496void AudioWidget::showEvent( QShowEvent* ) {
494 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 497 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
495 mouseMoveEvent( &event ); 498 mouseMoveEvent( &event );
496} 499}
497 500
498 501
499void AudioWidget::closeEvent( QCloseEvent* ) { 502void AudioWidget::closeEvent( QCloseEvent* ) {
500 mediaPlayerState->setList(); 503 mediaPlayerState->setList();
501} 504}
502 505
503 506
504void AudioWidget::paintEvent( QPaintEvent * pe) { 507void AudioWidget::paintEvent( QPaintEvent * pe) {
505 if ( !pe->erased() ) { 508 if ( !pe->erased() ) {
506 // Combine with background and double buffer 509 // Combine with background and double buffer
507 QPixmap pix( pe->rect().size() ); 510 QPixmap pix( pe->rect().size() );
508 QPainter p( &pix ); 511 QPainter p( &pix );
509 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 512 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
510 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 513 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
511 for ( int i = 0; i < numButtons; i++ ) 514 for ( int i = 0; i < numButtons; i++ )
512 paintButton( &p, i ); 515 paintButton( &p, i );
513 QPainter p2( this ); 516 QPainter p2( this );
514 p2.drawPixmap( pe->rect().topLeft(), pix ); 517 p2.drawPixmap( pe->rect().topLeft(), pix );
515 } else { 518 } else {
516 QPainter p( this ); 519 QPainter p( this );
517 for ( int i = 0; i < numButtons; i++ ) 520 for ( int i = 0; i < numButtons; i++ )
518 paintButton( &p, i ); 521 paintButton( &p, i );
519 } 522 }
520} 523}
521 524
522void AudioWidget::keyReleaseEvent( QKeyEvent *e) 525void AudioWidget::keyReleaseEvent( QKeyEvent *e)
523{ 526{
524 switch ( e->key() ) { 527 switch ( e->key() ) {
525////////////////////////////// Zaurus keys 528////////////////////////////// Zaurus keys
526 case Key_Home: 529 case Key_Home:
527 break; 530 break;
528 case Key_F9: //activity 531 case Key_F9: //activity
529 hide(); 532 hide();
530// qDebug("Audio F9"); 533// qDebug("Audio F9");
531 break; 534 break;
532 case Key_F10: //contacts 535 case Key_F10: //contacts
533 break; 536 break;
534 case Key_F11: //menu 537 case Key_F11: //menu
535 mediaPlayerState->toggleBlank(); 538 mediaPlayerState->toggleBlank();
536 break; 539 break;
537 case Key_F12: //home 540 case Key_F12: //home
538 break; 541 break;
539 case Key_F13: //mail 542 case Key_F13: //mail
540 mediaPlayerState->toggleBlank(); 543 mediaPlayerState->toggleBlank();
541 break; 544 break;
542 case Key_Space: { 545 case Key_Space: {
543 if(mediaPlayerState->playing()) { 546 if(mediaPlayerState->playing()) {
544// toggleButton(1); 547// toggleButton(1);
545 mediaPlayerState->setPlaying(FALSE); 548 mediaPlayerState->setPlaying(FALSE);
546// toggleButton(1); 549// toggleButton(1);
547 } else { 550 } else {
548// toggleButton(0); 551// toggleButton(0);
549 mediaPlayerState->setPlaying(TRUE); 552 mediaPlayerState->setPlaying(TRUE);
550// toggleButton(0); 553// toggleButton(0);
551 } 554 }
552 } 555 }
553 break; 556 break;
554 case Key_Down: 557 case Key_Down:
555// toggleButton(6); 558// toggleButton(6);
556 emit lessClicked(); 559 emit lessClicked();
557 emit lessReleased(); 560 emit lessReleased();
558// toggleButton(6); 561// toggleButton(6);
559 break; 562 break;
560 case Key_Up: 563 case Key_Up:
561// toggleButton(5); 564// toggleButton(5);
562 emit moreClicked(); 565 emit moreClicked();
563 emit moreReleased(); 566 emit moreReleased();
564// toggleButton(5); 567// toggleButton(5);
565 break; 568 break;
566 case Key_Right: 569 case Key_Right:
567// toggleButton(3); 570// toggleButton(3);
568 mediaPlayerState->setNext(); 571 mediaPlayerState->setNext();
569// toggleButton(3); 572// toggleButton(3);
570 break; 573 break;
571 case Key_Left: 574 case Key_Left:
572// toggleButton(4); 575// toggleButton(4);
573 mediaPlayerState->setPrev(); 576 mediaPlayerState->setPrev();
574// toggleButton(4); 577// toggleButton(4);
575 break; 578 break;
576 case Key_Escape: { 579 case Key_Escape: {
577#if defined(QT_QWS_IPAQ) 580#if defined(QT_QWS_IPAQ)
578 if( mediaPlayerState->isPaused ) { 581 if( mediaPlayerState->isPaused ) {
579 setToggleButton( i, FALSE ); 582 setToggleButton( i, FALSE );
580 mediaPlayerState->setPaused( FALSE ); 583 mediaPlayerState->setPaused( FALSE );
581 } else if( !mediaPlayerState->isPaused ) { 584 } else if( !mediaPlayerState->isPaused ) {
582 setToggleButton( i, TRUE ); 585 setToggleButton( i, TRUE );
583 mediaPlayerState->setPaused( TRUE ); 586 mediaPlayerState->setPaused( TRUE );
584 } 587 }
585#endif 588#endif
586 } 589 }
587 break; 590 break;
588 591
589 }; 592 };
590} 593}
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index 827f773..e951554 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -1,33 +1,34 @@
1 1
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include "mediaplayerstate.h" 3#include "mediaplayerstate.h"
4#include "playlistwidget.h" 4#include "playlistwidget.h"
5#include "audiowidget.h" 5#include "audiowidget.h"
6#include "videowidget.h" 6#include "videowidget.h"
7#include "mediaplayer.h" 7#include "mediaplayer.h"
8 8
9MediaPlayerState *mediaPlayerState; 9MediaPlayerState *mediaPlayerState;
10PlayListWidget *playList; 10PlayListWidget *playList;
11AudioWidget *audioUI; 11AudioWidget *audioUI;
12VideoWidget *videoUI; 12VideoWidget *videoUI;
13 13
14int main(int argc, char **argv) { 14int main(int argc, char **argv) {
15 QPEApplication a(argc,argv); 15 QPEApplication a(argc,argv);
16 16
17 MediaPlayerState st( 0, "mediaPlayerState" ); 17 MediaPlayerState st( 0, "mediaPlayerState" );
18 mediaPlayerState = &st; 18 mediaPlayerState = &st;
19 PlayListWidget pl( 0, "playList" ); 19 PlayListWidget pl( 0, "playList" );
20 playList = &pl; 20 playList = &pl;
21 pl.showMaximized();
21 AudioWidget aw( 0, "audioUI" ); 22 AudioWidget aw( 0, "audioUI" );
22 audioUI = &aw; 23 audioUI = &aw;
23 VideoWidget vw( 0, "videoUI" ); 24 VideoWidget vw( 0, "videoUI" );
24 videoUI = &vw; 25 videoUI = &vw;
25 26 a.processEvents();
26 MediaPlayer mp( 0, "mediaPlayer" ); 27 MediaPlayer mp( 0, "mediaPlayer" );
27 28
28 a.showMainDocumentWidget(&pl); 29 a.showMainDocumentWidget(&pl);
29 30
30 return a.exec(); 31 return a.exec();
31} 32}
32 33
33 34
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 87f4f0c..5531e81 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,297 +1,296 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6 6
7#include <qmainwindow.h> 7#include <qmainwindow.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qwidgetstack.h> 9#include <qwidgetstack.h>
10#include <qfile.h> 10#include <qfile.h>
11 11
12#include "mediaplayer.h" 12#include "mediaplayer.h"
13#include "playlistwidget.h" 13#include "playlistwidget.h"
14#include "audiowidget.h" 14#include "audiowidget.h"
15#include "videowidget.h" 15#include "videowidget.h"
16#include "volumecontrol.h" 16#include "volumecontrol.h"
17 17
18#include "mediaplayerstate.h" 18#include "mediaplayerstate.h"
19 19
20// for setBacklight() 20// for setBacklight()
21#include <linux/fb.h> 21#include <linux/fb.h>
22#include <sys/file.h> 22#include <sys/file.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24 24
25 25
26extern AudioWidget *audioUI; 26extern AudioWidget *audioUI;
27extern VideoWidget *videoUI; 27extern VideoWidget *videoUI;
28extern PlayListWidget *playList; 28extern PlayListWidget *playList;
29extern MediaPlayerState *mediaPlayerState; 29extern MediaPlayerState *mediaPlayerState;
30 30
31 31
32#define FBIOBLANK 0x4611 32#define FBIOBLANK 0x4611
33 33
34MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 34MediaPlayer::MediaPlayer( QObject *parent, const char *name )
35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
36 36
37 37 qApp->processEvents();
38 // xineControl = new XineControl(); 38 // QPEApplication::grabKeyboard(); // EVIL
39// QPEApplication::grabKeyboard(); // EVIL
40 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 39 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
41 40
42 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 41 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
43 42
44 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 43 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
45 44
46 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 45 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
47 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 46 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
48 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 47 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
49 48
50 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 49 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
51 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 50 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
52 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 51 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
53 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 52 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
54 53
55 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 54 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
56 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 55 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
57 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 56 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
58 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 57 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
59 58
60 volControl = new VolumeControl; 59 volControl = new VolumeControl;
61 xineControl = new XineControl(); 60 xineControl = new XineControl();
62} 61}
63 62
64MediaPlayer::~MediaPlayer() { 63MediaPlayer::~MediaPlayer() {
65 delete xineControl; 64 delete xineControl;
66 delete volControl; 65 delete volControl;
67} 66}
68 67
69void MediaPlayer::pauseCheck( bool b ) { 68void MediaPlayer::pauseCheck( bool b ) {
70 if ( b && !mediaPlayerState->playing() ) { 69 if ( b && !mediaPlayerState->playing() ) {
71 mediaPlayerState->setPaused( FALSE ); 70 mediaPlayerState->setPaused( FALSE );
72 } 71 }
73} 72}
74 73
75void MediaPlayer::play() { 74void MediaPlayer::play() {
76 mediaPlayerState->setPlaying( FALSE ); 75 mediaPlayerState->setPlaying( FALSE );
77 mediaPlayerState->setPlaying( TRUE ); 76 mediaPlayerState->setPlaying( TRUE );
78} 77}
79 78
80void MediaPlayer::setPlaying( bool play ) { 79void MediaPlayer::setPlaying( bool play ) {
81 if ( !play ) { 80 if ( !play ) {
82 return; 81 return;
83 } 82 }
84 83
85 if ( mediaPlayerState->paused() ) { 84 if ( mediaPlayerState->paused() ) {
86 mediaPlayerState->setPaused( FALSE ); 85 mediaPlayerState->setPaused( FALSE );
87 return; 86 return;
88 } 87 }
89 88
90 const DocLnk *playListCurrent = playList->current(); 89 const DocLnk *playListCurrent = playList->current();
91 if ( playListCurrent != NULL ) { 90 if ( playListCurrent != NULL ) {
92 currentFile = playListCurrent; 91 currentFile = playListCurrent;
93 } 92 }
94 93
95 xineControl->play( currentFile->file() ); 94 xineControl->play( currentFile->file() );
96 95
97 xineControl->length(); 96 xineControl->length();
98 long seconds = mediaPlayerState->length();// 97 long seconds = mediaPlayerState->length();//
99 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 98 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
100 qDebug(time); 99 qDebug(time);
101 100
102 QString tickerText; 101 QString tickerText;
103 if( currentFile->file().left(4) == "http" ) 102 if( currentFile->file().left(4) == "http" )
104 tickerText= tr( " File: " ) + currentFile->name(); 103 tickerText= tr( " File: " ) + currentFile->name();
105 else 104 else
106 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 105 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
107 106
108 audioUI->setTickerText( currentFile->file( ) ); 107 audioUI->setTickerText( currentFile->file( ) );
109 108
110} 109}
111 110
112 111
113void MediaPlayer::prev() { 112void MediaPlayer::prev() {
114 if ( playList->prev() ) { 113 if ( playList->prev() ) {
115 play(); 114 play();
116 } else if ( mediaPlayerState->looping() ) { 115 } else if ( mediaPlayerState->looping() ) {
117 if ( playList->last() ) { 116 if ( playList->last() ) {
118 play(); 117 play();
119 } 118 }
120 } else { 119 } else {
121 mediaPlayerState->setList(); 120 mediaPlayerState->setList();
122 } 121 }
123} 122}
124 123
125 124
126void MediaPlayer::next() { 125void MediaPlayer::next() {
127 if ( playList->next() ) { 126 if ( playList->next() ) {
128 play(); 127 play();
129 } else if ( mediaPlayerState->looping() ) { 128 } else if ( mediaPlayerState->looping() ) {
130 if ( playList->first() ) { 129 if ( playList->first() ) {
131 play(); 130 play();
132 } 131 }
133 } else { 132 } else {
134 mediaPlayerState->setList(); 133 mediaPlayerState->setList();
135 } 134 }
136} 135}
137 136
138 137
139void MediaPlayer::startDecreasingVolume() { 138void MediaPlayer::startDecreasingVolume() {
140 volumeDirection = -1; 139 volumeDirection = -1;
141 startTimer( 100 ); 140 startTimer( 100 );
142 volControl->decVol(2); 141 volControl->decVol(2);
143} 142}
144 143
145 144
146void MediaPlayer::startIncreasingVolume() { 145void MediaPlayer::startIncreasingVolume() {
147 volumeDirection = +1; 146 volumeDirection = +1;
148 startTimer( 100 ); 147 startTimer( 100 );
149 volControl->incVol(2); 148 volControl->incVol(2);
150} 149}
151 150
152 151
153bool drawnOnScreenDisplay = FALSE; 152bool drawnOnScreenDisplay = FALSE;
154unsigned int onScreenDisplayVolume = 0; 153unsigned int onScreenDisplayVolume = 0;
155const int yoff = 110; 154const int yoff = 110;
156 155
157void MediaPlayer::stopChangingVolume() { 156void MediaPlayer::stopChangingVolume() {
158 killTimers(); 157 killTimers();
159 // Get rid of the on-screen display stuff 158 // Get rid of the on-screen display stuff
160 drawnOnScreenDisplay = FALSE; 159 drawnOnScreenDisplay = FALSE;
161 onScreenDisplayVolume = 0; 160 onScreenDisplayVolume = 0;
162 int w=0; 161 int w=0;
163 int h=0; 162 int h=0;
164 if( !xineControl->hasVideo()) { 163 if( !xineControl->hasVideo()) {
165 w = audioUI->width(); 164 w = audioUI->width();
166 h = audioUI->height(); 165 h = audioUI->height();
167 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 166 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
168 } else { 167 } else {
169 w = videoUI->width(); 168 w = videoUI->width();
170 h = videoUI->height(); 169 h = videoUI->height();
171 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 170 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
172 } 171 }
173} 172}
174 173
175 174
176void MediaPlayer::timerEvent( QTimerEvent * ) { 175void MediaPlayer::timerEvent( QTimerEvent * ) {
177 if ( volumeDirection == +1 ) { 176 if ( volumeDirection == +1 ) {
178 volControl->incVol(2); 177 volControl->incVol(2);
179 } else if ( volumeDirection == -1 ) { 178 } else if ( volumeDirection == -1 ) {
180 volControl->decVol(2); 179 volControl->decVol(2);
181 } 180 }
182 181
183 182
184 // TODO FIXME 183 // TODO FIXME
185 unsigned int v; 184 unsigned int v;
186 v = volControl->getVolume(); 185 v = volControl->getVolume();
187 v = v / 10; 186 v = v / 10;
188 187
189 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 188 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
190 return; 189 return;
191 } 190 }
192 191
193 int w=0; int h=0; 192 int w=0; int h=0;
194 if( !xineControl->hasVideo()) { 193 if( !xineControl->hasVideo()) {
195 w = audioUI->width(); 194 w = audioUI->width();
196 h = audioUI->height(); 195 h = audioUI->height();
197 196
198 if ( drawnOnScreenDisplay ) { 197 if ( drawnOnScreenDisplay ) {
199 if ( onScreenDisplayVolume > v ) { 198 if ( onScreenDisplayVolume > v ) {
200 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 199 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
201 } 200 }
202 } 201 }
203 drawnOnScreenDisplay = TRUE; 202 drawnOnScreenDisplay = TRUE;
204 onScreenDisplayVolume = v; 203 onScreenDisplayVolume = v;
205 QPainter p( audioUI ); 204 QPainter p( audioUI );
206 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 205 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
207 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 206 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
208 207
209 QFont f; 208 QFont f;
210 f.setPixelSize( 20 ); 209 f.setPixelSize( 20 );
211 f.setBold( TRUE ); 210 f.setBold( TRUE );
212 p.setFont( f ); 211 p.setFont( f );
213 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 212 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
214 213
215 for ( unsigned int i = 0; i < 10; i++ ) { 214 for ( unsigned int i = 0; i < 10; i++ ) {
216 if ( v > i ) { 215 if ( v > i ) {
217 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 216 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
218 } else { 217 } else {
219 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 218 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
220 } 219 }
221 } 220 }
222 } else { 221 } else {
223 w = videoUI->width(); 222 w = videoUI->width();
224 h = videoUI->height(); 223 h = videoUI->height();
225 224
226 if ( drawnOnScreenDisplay ) { 225 if ( drawnOnScreenDisplay ) {
227 if ( onScreenDisplayVolume > v ) { 226 if ( onScreenDisplayVolume > v ) {
228 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 227 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
229 } 228 }
230 } 229 }
231 drawnOnScreenDisplay = TRUE; 230 drawnOnScreenDisplay = TRUE;
232 onScreenDisplayVolume = v; 231 onScreenDisplayVolume = v;
233 QPainter p( videoUI ); 232 QPainter p( videoUI );
234 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 233 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
235 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 234 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
236 235
237 QFont f; 236 QFont f;
238 f.setPixelSize( 20 ); 237 f.setPixelSize( 20 );
239 f.setBold( TRUE ); 238 f.setBold( TRUE );
240 p.setFont( f ); 239 p.setFont( f );
241 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 240 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
242 241
243 for ( unsigned int i = 0; i < 10; i++ ) { 242 for ( unsigned int i = 0; i < 10; i++ ) {
244 if ( v > i ) { 243 if ( v > i ) {
245 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 244 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
246 } else { 245 } else {
247 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 246 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
248 } 247 }
249 } 248 }
250 } 249 }
251} 250}
252 251
253 252
254void MediaPlayer::blank( bool b ) { 253void MediaPlayer::blank( bool b ) {
255 fd=open("/dev/fb0",O_RDWR); 254 fd=open("/dev/fb0",O_RDWR);
256 if (fd != -1) { 255 if (fd != -1) {
257 if ( b ) { 256 if ( b ) {
258 qDebug("do blanking"); 257 qDebug("do blanking");
259 ioctl( fd, FBIOBLANK, 3 ); 258 ioctl( fd, FBIOBLANK, 3 );
260 isBlanked = TRUE; 259 isBlanked = TRUE;
261 } else { 260 } else {
262 qDebug("do unblanking"); 261 qDebug("do unblanking");
263 ioctl( fd, FBIOBLANK, 0); 262 ioctl( fd, FBIOBLANK, 0);
264 isBlanked = FALSE; 263 isBlanked = FALSE;
265 } 264 }
266 close( fd ); 265 close( fd );
267 } else { 266 } else {
268 qDebug("<< /dev/fb0 could not be opend >>"); 267 qDebug("<< /dev/fb0 could not be opend >>");
269 } 268 }
270} 269}
271 270
272void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 271void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
273 switch ( e->key() ) { 272 switch ( e->key() ) {
274////////////////////////////// Zaurus keys 273////////////////////////////// Zaurus keys
275 case Key_Home: 274 case Key_Home:
276 break; 275 break;
277 case Key_F9: //activity 276 case Key_F9: //activity
278 break; 277 break;
279 case Key_F10: //contacts 278 case Key_F10: //contacts
280 break; 279 break;
281 case Key_F11: //menu 280 case Key_F11: //menu
282 break; 281 break;
283 case Key_F12: //home 282 case Key_F12: //home
284 qDebug("Blank here"); 283 qDebug("Blank here");
285// mediaPlayerState->toggleBlank(); 284// mediaPlayerState->toggleBlank();
286 break; 285 break;
287 case Key_F13: //mail 286 case Key_F13: //mail
288 qDebug("Blank here"); 287 qDebug("Blank here");
289 // mediaPlayerState->toggleBlank(); 288 // mediaPlayerState->toggleBlank();
290 break; 289 break;
291 } 290 }
292} 291}
293 292
294void MediaPlayer::cleanUp() { 293void MediaPlayer::cleanUp() {
295// QPEApplication::grabKeyboard(); 294// QPEApplication::grabKeyboard();
296// QPEApplication::ungrabKeyboard(); 295// QPEApplication::ungrabKeyboard();
297} 296}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 874800a..39f5090 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1286 +1,1286 @@
1 1
2#define QTOPIA_INTERNAL_FSLP 2#define QTOPIA_INTERNAL_FSLP
3#include <qpe/qpemenubar.h> 3#include <qpe/qpemenubar.h>
4#include <qpe/qpetoolbar.h> 4#include <qpe/qpetoolbar.h>
5#include <qpe/fileselector.h> 5#include <qpe/fileselector.h>
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7#include <qpe/lnkproperties.h> 7#include <qpe/lnkproperties.h>
8#include <qpe/storage.h> 8#include <qpe/storage.h>
9 9
10#include <qpe/applnk.h> 10#include <qpe/applnk.h>
11#include <qpopupmenu.h> 11#include <qpopupmenu.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include <qpe/global.h> 13#include <qpe/global.h>
14#include <qpe/resource.h> 14#include <qpe/resource.h>
15#include <qaction.h> 15#include <qaction.h>
16#include <qcursor.h> 16#include <qcursor.h>
17#include <qimage.h> 17#include <qimage.h>
18#include <qfile.h> 18#include <qfile.h>
19#include <qdir.h> 19#include <qdir.h>
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qlist.h> 22#include <qlist.h>
23#include <qlistbox.h> 23#include <qlistbox.h>
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27#include <qtabwidget.h> 27#include <qtabwidget.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <qpoint.h> 29#include <qpoint.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34 34
35 35
36#include "playlistselection.h" 36#include "playlistselection.h"
37#include "playlistwidget.h" 37#include "playlistwidget.h"
38#include "mediaplayerstate.h" 38#include "mediaplayerstate.h"
39 39
40#include "inputDialog.h" 40#include "inputDialog.h"
41 41
42#include <stdlib.h> 42#include <stdlib.h>
43#include "audiowidget.h" 43#include "audiowidget.h"
44#include "videowidget.h" 44#include "videowidget.h"
45 45
46#define BUTTONS_ON_TOOLBAR 46#define BUTTONS_ON_TOOLBAR
47#define SIDE_BUTTONS 47#define SIDE_BUTTONS
48#define CAN_SAVE_LOAD_PLAYLISTS 48#define CAN_SAVE_LOAD_PLAYLISTS
49 49
50extern MediaPlayerState *mediaPlayerState; 50extern MediaPlayerState *mediaPlayerState;
51 51
52 52
53class PlayListWidgetPrivate { 53class PlayListWidgetPrivate {
54public: 54public:
55 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 55 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
56 QFrame *playListFrame; 56 QFrame *playListFrame;
57 FileSelector *files; 57 FileSelector *files;
58 PlayListSelection *selectedFiles; 58 PlayListSelection *selectedFiles;
59 bool setDocumentUsed; 59 bool setDocumentUsed;
60 DocLnk *current; 60 DocLnk *current;
61}; 61};
62 62
63 63
64class ToolButton : public QToolButton { 64class ToolButton : public QToolButton {
65public: 65public:
66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
67 : QToolButton( parent, name ) { 67 : QToolButton( parent, name ) {
68 setTextLabel( name ); 68 setTextLabel( name );
69 setPixmap( Resource::loadPixmap( icon ) ); 69 setPixmap( Resource::loadPixmap( icon ) );
70 setAutoRaise( TRUE ); 70 setAutoRaise( TRUE );
71 setFocusPolicy( QWidget::NoFocus ); 71 setFocusPolicy( QWidget::NoFocus );
72 setToggleButton( t ); 72 setToggleButton( t );
73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
74 QPEMenuToolFocusManager::manager()->addWidget( this ); 74 QPEMenuToolFocusManager::manager()->addWidget( this );
75 } 75 }
76}; 76};
77 77
78 78
79class MenuItem : public QAction { 79class MenuItem : public QAction {
80public: 80public:
81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
82 : QAction( text, QString::null, 0, 0 ) { 82 : QAction( text, QString::null, 0, 0 ) {
83 connect( this, SIGNAL( activated() ), handler, slot ); 83 connect( this, SIGNAL( activated() ), handler, slot );
84 addTo( parent ); 84 addTo( parent );
85 } 85 }
86}; 86};
87 87
88 88
89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
90 : QMainWindow( parent, name, fl ) { 90 : QMainWindow( parent, name, fl ) {
91 91
92 d = new PlayListWidgetPrivate; 92 d = new PlayListWidgetPrivate;
93 d->setDocumentUsed = FALSE; 93 d->setDocumentUsed = FALSE;
94 d->current = NULL; 94 d->current = NULL;
95 fromSetDocument = FALSE; 95 fromSetDocument = FALSE;
96 insanityBool=FALSE; 96 insanityBool=FALSE;
97 audioScan = FALSE; 97 audioScan = FALSE;
98 videoScan = FALSE; 98 videoScan = FALSE;
99 99
100 setBackgroundMode( PaletteButton ); 100 setBackgroundMode( PaletteButton );
101 101
102 setCaption( tr("OpiePlayer") ); 102 setCaption( tr("OpiePlayer") );
103 setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); 103 setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) );
104 104
105 setToolBarsMovable( FALSE ); 105 setToolBarsMovable( FALSE );
106 106
107 // Create Toolbar 107 // Create Toolbar
108 QPEToolBar *toolbar = new QPEToolBar( this ); 108 QPEToolBar *toolbar = new QPEToolBar( this );
109 toolbar->setHorizontalStretchable( TRUE ); 109 toolbar->setHorizontalStretchable( TRUE );
110 110
111 // Create Menubar 111 // Create Menubar
112 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 112 QPEMenuBar *menu = new QPEMenuBar( toolbar );
113 menu->setMargin( 0 ); 113 menu->setMargin( 0 );
114 114
115 QPEToolBar *bar = new QPEToolBar( this ); 115 QPEToolBar *bar = new QPEToolBar( this );
116 bar->setLabel( tr( "Play Operations" ) ); 116 bar->setLabel( tr( "Play Operations" ) );
117 117
118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
119 tbDeletePlaylist->setFlat(TRUE); 119 tbDeletePlaylist->setFlat(TRUE);
120 tbDeletePlaylist->setFixedSize(20,20); 120 tbDeletePlaylist->setFixedSize(20,20);
121 121
122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
123 this , SLOT(addSelected()) ); 123 this , SLOT(addSelected()) );
124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
125 this , SLOT(removeSelected()) ); 125 this , SLOT(removeSelected()) );
126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
127 this , SLOT( btnPlay(bool) ), TRUE ); 127 this , SLOT( btnPlay(bool) ), TRUE );
128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", 130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop",
131 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 131 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
132 tbDeletePlaylist->hide(); 132 tbDeletePlaylist->hide();
133 133
134 QPopupMenu *pmPlayList = new QPopupMenu( this ); 134 QPopupMenu *pmPlayList = new QPopupMenu( this );
135 menu->insertItem( tr( "File" ), pmPlayList ); 135 menu->insertItem( tr( "File" ), pmPlayList );
136 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 136 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
137 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 137 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
138 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 138 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
139 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 139 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
140 pmPlayList->insertSeparator(-1); 140 pmPlayList->insertSeparator(-1);
141 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 141 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
142 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 142 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
143 pmPlayList->insertSeparator(-1); 143 pmPlayList->insertSeparator(-1);
144 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 144 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
145 pmPlayList->insertSeparator(-1); 145 pmPlayList->insertSeparator(-1);
146 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 146 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
147 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 147 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
148 148
149 149
150 pmView = new QPopupMenu( this ); 150 pmView = new QPopupMenu( this );
151 menu->insertItem( tr( "View" ), pmView ); 151 menu->insertItem( tr( "View" ), pmView );
152 pmView->isCheckable(); 152 pmView->isCheckable();
153 153
154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
155 155
156 Config cfg( "OpiePlayer" ); 156 Config cfg( "OpiePlayer" );
157 bool b= cfg.readBoolEntry("FullScreen", 0); 157 bool b= cfg.readBoolEntry("FullScreen", 0);
158 mediaPlayerState->setFullscreen( b ); 158 mediaPlayerState->setFullscreen( b );
159 pmView->setItemChecked( -16, b ); 159 pmView->setItemChecked( -16, b );
160 160
161 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); 161 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) );
162 162
163 pmView->insertSeparator(-1); 163 pmView->insertSeparator(-1);
164 164
165 skinsMenu = new QPopupMenu( this ); 165 skinsMenu = new QPopupMenu( this );
166 pmView->insertItem( tr( "Skins" ), skinsMenu ); 166 pmView->insertItem( tr( "Skins" ), skinsMenu );
167 skinsMenu->isCheckable(); 167 skinsMenu->isCheckable();
168 populateSkinsMenu(); 168 populateSkinsMenu();
169 169
170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
172 172
173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
174 174
175 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 175 tabWidget = new QTabWidget( hbox6, "tabWidget" );
176 // tabWidget->setTabShape(QTabWidget::Triangular); 176 // tabWidget->setTabShape(QTabWidget::Triangular);
177 177
178 QWidget *pTab; 178 QWidget *pTab;
179 pTab = new QWidget( tabWidget, "pTab" ); 179 pTab = new QWidget( tabWidget, "pTab" );
180 tabWidget->insertTab( pTab,"Playlist"); 180 tabWidget->insertTab( pTab,"Playlist");
181 181
182 182
183 QGridLayout *Playout = new QGridLayout( pTab ); 183 QGridLayout *Playout = new QGridLayout( pTab );
184 Playout->setSpacing( 2); 184 Playout->setSpacing( 2);
185 Playout->setMargin( 2); 185 Playout->setMargin( 2);
186 186
187 // Add the playlist area 187 // Add the playlist area
188 188
189 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 189 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
190 d->playListFrame = vbox3; 190 d->playListFrame = vbox3;
191 191
192 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 192 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
193 193
194 d->selectedFiles = new PlayListSelection( hbox2); 194 d->selectedFiles = new PlayListSelection( hbox2);
195 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 195 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
196 196
197 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 197 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
198 198
199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
200 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 200 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) );
201 new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); 201 new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) );
202 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 202 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) );
203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
204 204
205 205
206 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 206 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
207 207
208 QWidget *aTab; 208 QWidget *aTab;
209 aTab = new QWidget( tabWidget, "aTab" ); 209 aTab = new QWidget( tabWidget, "aTab" );
210 210
211 QGridLayout *Alayout = new QGridLayout( aTab ); 211 QGridLayout *Alayout = new QGridLayout( aTab );
212 Alayout->setSpacing( 2); 212 Alayout->setSpacing( 2);
213 Alayout->setMargin( 2); 213 Alayout->setMargin( 2);
214 214
215 audioView = new QListView( aTab, "Audioview" ); 215 audioView = new QListView( aTab, "Audioview" );
216 audioView->addColumn( tr("Title"),140); 216 audioView->addColumn( tr("Title"),140);
217 audioView->addColumn(tr("Size"), -1); 217 audioView->addColumn(tr("Size"), -1);
218 audioView->addColumn(tr("Media"),-1); 218 audioView->addColumn(tr("Media"),-1);
219 audioView->setColumnAlignment(1, Qt::AlignRight); 219 audioView->setColumnAlignment(1, Qt::AlignRight);
220 audioView->setColumnAlignment(2, Qt::AlignRight); 220 audioView->setColumnAlignment(2, Qt::AlignRight);
221 audioView->setAllColumnsShowFocus(TRUE); 221 audioView->setAllColumnsShowFocus(TRUE);
222 audioView->setSorting(0,TRUE); 222 audioView->setSorting(0,TRUE);
223 223
224 audioView->setMultiSelection( TRUE ); 224 audioView->setMultiSelection( TRUE );
225 audioView->setSelectionMode( QListView::Extended); 225 audioView->setSelectionMode( QListView::Extended);
226 226
227 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 227 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
228 228
229 tabWidget->insertTab(aTab,tr("Audio")); 229 tabWidget->insertTab(aTab,tr("Audio"));
230 230
231 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 231 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
232 232
233 QWidget *vTab; 233 QWidget *vTab;
234 vTab = new QWidget( tabWidget, "vTab" ); 234 vTab = new QWidget( tabWidget, "vTab" );
235 235
236 QGridLayout *Vlayout = new QGridLayout( vTab ); 236 QGridLayout *Vlayout = new QGridLayout( vTab );
237 Vlayout->setSpacing( 2); 237 Vlayout->setSpacing( 2);
238 Vlayout->setMargin( 2); 238 Vlayout->setMargin( 2);
239 239
240 videoView = new QListView( vTab, "Videoview" ); 240 videoView = new QListView( vTab, "Videoview" );
241 241
242 videoView->addColumn(tr("Title"),140); 242 videoView->addColumn(tr("Title"),140);
243 videoView->addColumn(tr("Size"),-1); 243 videoView->addColumn(tr("Size"),-1);
244 videoView->addColumn(tr("Media"),-1); 244 videoView->addColumn(tr("Media"),-1);
245 videoView->setColumnAlignment(1, Qt::AlignRight); 245 videoView->setColumnAlignment(1, Qt::AlignRight);
246 videoView->setColumnAlignment(2, Qt::AlignRight); 246 videoView->setColumnAlignment(2, Qt::AlignRight);
247 videoView->setAllColumnsShowFocus(TRUE); 247 videoView->setAllColumnsShowFocus(TRUE);
248 videoView->setSorting(0,TRUE); 248 videoView->setSorting(0,TRUE);
249 249
250 videoView->setMultiSelection( TRUE ); 250 videoView->setMultiSelection( TRUE );
251 videoView->setSelectionMode( QListView::Extended); 251 videoView->setSelectionMode( QListView::Extended);
252 252
253 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 253 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
254 254
255 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 255 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
256 256
257 tabWidget->insertTab( vTab,tr("Video")); 257 tabWidget->insertTab( vTab,tr("Video"));
258 258
259 //playlists list 259 //playlists list
260 QWidget *LTab; 260 QWidget *LTab;
261 LTab = new QWidget( tabWidget, "LTab" ); 261 LTab = new QWidget( tabWidget, "LTab" );
262 QGridLayout *Llayout = new QGridLayout( LTab ); 262 QGridLayout *Llayout = new QGridLayout( LTab );
263 Llayout->setSpacing( 2); 263 Llayout->setSpacing( 2);
264 Llayout->setMargin( 2); 264 Llayout->setMargin( 2);
265 265
266 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 266 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
267 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 267 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
268 268
269 tabWidget->insertTab(LTab,tr("Lists")); 269 tabWidget->insertTab(LTab,tr("Lists"));
270 270
271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
272 272
273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); 273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) );
274 274
275 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); 275 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) );
276 276
277 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); 277 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) );
278 278
279 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 279 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
284 this,SLOT( playIt( QListViewItem *)) ); 284 this,SLOT( playIt( QListViewItem *)) );
285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
289 this,SLOT( playIt( QListViewItem *)) ); 289 this,SLOT( playIt( QListViewItem *)) );
290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
298 298
299 setCentralWidget( vbox5 ); 299 setCentralWidget( vbox5 );
300 300
301 readConfig( cfg ); 301 readConfig( cfg );
302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
303 loadList(DocLnk( currentPlaylist)); 303 loadList(DocLnk( currentPlaylist));
304 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 304 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
305 305
306 initializeStates(); 306 initializeStates();
307} 307}
308 308
309 309
310PlayListWidget::~PlayListWidget() { 310PlayListWidget::~PlayListWidget() {
311 Config cfg( "OpiePlayer" ); 311 Config cfg( "OpiePlayer" );
312 writeConfig( cfg ); 312 writeConfig( cfg );
313 313
314 if ( d->current ) { 314 if ( d->current ) {
315 delete d->current; 315 delete d->current;
316 } 316 }
317 delete d; 317 delete d;
318} 318}
319 319
320 320
321void PlayListWidget::initializeStates() { 321void PlayListWidget::initializeStates() {
322 322
323 d->tbPlay->setOn( mediaPlayerState->playing() ); 323 d->tbPlay->setOn( mediaPlayerState->playing() );
324 d->tbLoop->setOn( mediaPlayerState->looping() ); 324 d->tbLoop->setOn( mediaPlayerState->looping() );
325 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 325 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
326 setPlaylist( true); 326 setPlaylist( true);
327} 327}
328 328
329 329
330void PlayListWidget::readConfig( Config& cfg ) { 330void PlayListWidget::readConfig( Config& cfg ) {
331 cfg.setGroup("PlayList"); 331 cfg.setGroup("PlayList");
332 QString currentString = cfg.readEntry("current", "" ); 332 QString currentString = cfg.readEntry("current", "" );
333 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 333 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
334 for ( int i = 0; i < noOfFiles; i++ ) { 334 for ( int i = 0; i < noOfFiles; i++ ) {
335 QString entryName; 335 QString entryName;
336 entryName.sprintf( "File%i", i + 1 ); 336 entryName.sprintf( "File%i", i + 1 );
337 QString linkFile = cfg.readEntry( entryName ); 337 QString linkFile = cfg.readEntry( entryName );
338 if(QFileInfo( linkFile).exists() ) { 338 if(QFileInfo( linkFile).exists() ) {
339 DocLnk lnk( linkFile ); 339 DocLnk lnk( linkFile );
340 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { 340 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) {
341 d->selectedFiles->addToSelection( lnk ); 341 d->selectedFiles->addToSelection( lnk );
342 } 342 }
343 } 343 }
344 } 344 }
345 d->selectedFiles->setSelectedItem( currentString); 345 d->selectedFiles->setSelectedItem( currentString);
346} 346}
347 347
348 348
349void PlayListWidget::writeConfig( Config& cfg ) const { 349void PlayListWidget::writeConfig( Config& cfg ) const {
350 350
351 d->selectedFiles->writeCurrent( cfg); 351 d->selectedFiles->writeCurrent( cfg);
352 cfg.setGroup("PlayList"); 352 cfg.setGroup("PlayList");
353 int noOfFiles = 0; 353 int noOfFiles = 0;
354 d->selectedFiles->first(); 354 d->selectedFiles->first();
355 do { 355 do {
356 const DocLnk *lnk = d->selectedFiles->current(); 356 const DocLnk *lnk = d->selectedFiles->current();
357 if ( lnk ) { 357 if ( lnk ) {
358 QString entryName; 358 QString entryName;
359 entryName.sprintf( "File%i", noOfFiles + 1 ); 359 entryName.sprintf( "File%i", noOfFiles + 1 );
360 cfg.writeEntry( entryName, lnk->linkFile() ); 360 cfg.writeEntry( entryName, lnk->linkFile() );
361 // if this link does exist, add it so we have the file 361 // if this link does exist, add it so we have the file
362 // next time... 362 // next time...
363 if ( !QFile::exists( lnk->linkFile() ) ) { 363 if ( !QFile::exists( lnk->linkFile() ) ) {
364 // the way writing lnks doesn't really check for out 364 // the way writing lnks doesn't really check for out
365 // of disk space, but check it anyway. 365 // of disk space, but check it anyway.
366 if ( !lnk->writeLink() ) { 366 if ( !lnk->writeLink() ) {
367 QMessageBox::critical( 0, tr("Out of space"), 367 QMessageBox::critical( 0, tr("Out of space"),
368 tr( "There was a problem saving " 368 tr( "There was a problem saving "
369 "the playlist.\n" 369 "the playlist.\n"
370 "Your playlist " 370 "Your playlist "
371 "may be missing some entries\n" 371 "may be missing some entries\n"
372 "the next time you start it." ) 372 "the next time you start it." )
373 ); 373 );
374 } 374 }
375 } 375 }
376 noOfFiles++; 376 noOfFiles++;
377 } 377 }
378 } 378 }
379 while ( d->selectedFiles->next() ); 379 while ( d->selectedFiles->next() );
380 cfg.writeEntry("NumberOfFiles", noOfFiles ); 380 cfg.writeEntry("NumberOfFiles", noOfFiles );
381} 381}
382 382
383 383
384void PlayListWidget::addToSelection( const DocLnk& lnk ) { 384void PlayListWidget::addToSelection( const DocLnk& lnk ) {
385 d->setDocumentUsed = FALSE; 385 d->setDocumentUsed = FALSE;
386 if ( mediaPlayerState->playlist() ) { 386 if ( mediaPlayerState->playlist() ) {
387 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 387 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
388 d->selectedFiles->addToSelection( lnk ); 388 d->selectedFiles->addToSelection( lnk );
389 } 389 }
390 else 390 else
391 mediaPlayerState->setPlaying( TRUE ); 391 mediaPlayerState->setPlaying( TRUE );
392} 392}
393 393
394 394
395void PlayListWidget::clearList() { 395void PlayListWidget::clearList() {
396 while ( first() ) { 396 while ( first() ) {
397 d->selectedFiles->removeSelected(); 397 d->selectedFiles->removeSelected();
398 } 398 }
399} 399}
400 400
401 401
402void PlayListWidget::addAllToList() { 402void PlayListWidget::addAllToList() {
403 DocLnkSet filesAll; 403 DocLnkSet filesAll;
404 Global::findDocuments(&filesAll, "video/*;audio/*"); 404 Global::findDocuments(&filesAll, "video/*;audio/*");
405 QListIterator<DocLnk> Adit( filesAll.children() ); 405 QListIterator<DocLnk> Adit( filesAll.children() );
406 for ( ; Adit.current(); ++Adit ) { 406 for ( ; Adit.current(); ++Adit ) {
407 if(QFileInfo(Adit.current()->file()).exists()) { 407 if(QFileInfo(Adit.current()->file()).exists()) {
408 d->selectedFiles->addToSelection( **Adit ); 408 d->selectedFiles->addToSelection( **Adit );
409 } 409 }
410 } 410 }
411} 411}
412 412
413 413
414void PlayListWidget::addAllMusicToList() { 414void PlayListWidget::addAllMusicToList() {
415 QListIterator<DocLnk> dit( files.children() ); 415 QListIterator<DocLnk> dit( files.children() );
416 for ( ; dit.current(); ++dit ) { 416 for ( ; dit.current(); ++dit ) {
417 if(QFileInfo(dit.current()->file()).exists()) { 417 if(QFileInfo(dit.current()->file()).exists()) {
418 d->selectedFiles->addToSelection( **dit ); 418 d->selectedFiles->addToSelection( **dit );
419 } 419 }
420 } 420 }
421} 421}
422 422
423 423
424void PlayListWidget::addAllVideoToList() { 424void PlayListWidget::addAllVideoToList() {
425 QListIterator<DocLnk> dit( vFiles.children() ); 425 QListIterator<DocLnk> dit( vFiles.children() );
426 for ( ; dit.current(); ++dit ) 426 for ( ; dit.current(); ++dit )
427 if(QFileInfo( dit.current()->file()).exists()) 427 if(QFileInfo( dit.current()->file()).exists())
428 d->selectedFiles->addToSelection( **dit ); 428 d->selectedFiles->addToSelection( **dit );
429} 429}
430 430
431 431
432void PlayListWidget::setDocument(const QString& fileref) { 432void PlayListWidget::setDocument(const QString& fileref) {
433 qDebug(fileref); 433 qDebug(fileref);
434 fromSetDocument = TRUE; 434 fromSetDocument = TRUE;
435 if ( fileref.isNull() ) { 435 if ( fileref.isNull() ) {
436 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 436 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
437 return; 437 return;
438 } 438 }
439 439
440 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 440 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
441 readm3u( fileref); 441 readm3u( fileref);
442 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls 442 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls
443 readPls( fileref); 443 readPls( fileref);
444 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 444 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
445 clearList(); 445 clearList();
446 loadList(DocLnk(fileref)); 446 loadList(DocLnk(fileref));
447 d->selectedFiles->first(); 447 d->selectedFiles->first();
448 } else { 448 } else {
449 clearList(); 449 clearList();
450 addToSelection( DocLnk( fileref ) ); 450 addToSelection( DocLnk( fileref ) );
451 d->setDocumentUsed = TRUE; 451 d->setDocumentUsed = TRUE;
452 mediaPlayerState->setPlaying( FALSE ); 452 mediaPlayerState->setPlaying( FALSE );
453 qApp->processEvents(); 453 qApp->processEvents();
454 mediaPlayerState->setPlaying( TRUE ); 454 mediaPlayerState->setPlaying( TRUE );
455 qApp->processEvents(); 455 qApp->processEvents();
456 setCaption(tr("OpiePlayer")); 456 setCaption(tr("OpiePlayer"));
457 } 457 }
458} 458}
459 459
460 460
461void PlayListWidget::setActiveWindow() { 461void PlayListWidget::setActiveWindow() {
462 qDebug("SETTING active window"); 462 qDebug("SETTING active window");
463 // When we get raised we need to ensure that it switches views 463 // When we get raised we need to ensure that it switches views
464 char origView = mediaPlayerState->view(); 464 char origView = mediaPlayerState->view();
465 mediaPlayerState->setView( 'l' ); // invalidate 465 mediaPlayerState->setView( 'l' ); // invalidate
466 mediaPlayerState->setView( origView ); // now switch back 466 mediaPlayerState->setView( origView ); // now switch back
467} 467}
468 468
469 469
470void PlayListWidget::useSelectedDocument() { 470void PlayListWidget::useSelectedDocument() {
471 d->setDocumentUsed = FALSE; 471 d->setDocumentUsed = FALSE;
472} 472}
473 473
474 474
475const DocLnk *PlayListWidget::current() { // this is fugly 475const DocLnk *PlayListWidget::current() { // this is fugly
476 476
477 switch (tabWidget->currentPageIndex()) { 477 switch (tabWidget->currentPageIndex()) {
478 case 0: //playlist 478 case 0: //playlist
479 { 479 {
480 qDebug("playlist"); 480 qDebug("playlist");
481 if ( mediaPlayerState->playlist() ) { 481 if ( mediaPlayerState->playlist() ) {
482 return d->selectedFiles->current(); 482 return d->selectedFiles->current();
483 } else if ( d->setDocumentUsed && d->current ) { 483 } else if ( d->setDocumentUsed && d->current ) {
484 return d->current; 484 return d->current;
485 } else { 485 } else {
486 return d->files->selected(); 486 return d->files->selected();
487 } 487 }
488 } 488 }
489 break; 489 break;
490 case 1://audio 490 case 1://audio
491 { 491 {
492 qDebug("audioView"); 492 qDebug("audioView");
493 QListIterator<DocLnk> dit( files.children() ); 493 QListIterator<DocLnk> dit( files.children() );
494 for ( ; dit.current(); ++dit ) { 494 for ( ; dit.current(); ++dit ) {
495 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 495 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
496 qDebug("here"); 496 qDebug("here");
497 insanityBool=TRUE; 497 insanityBool=TRUE;
498 return dit; 498 return dit;
499 } 499 }
500 } 500 }
501 } 501 }
502 break; 502 break;
503 case 2: // video 503 case 2: // video
504 { 504 {
505 qDebug("videoView"); 505 qDebug("videoView");
506 QListIterator<DocLnk> Vdit( vFiles.children() ); 506 QListIterator<DocLnk> Vdit( vFiles.children() );
507 for ( ; Vdit.current(); ++Vdit ) { 507 for ( ; Vdit.current(); ++Vdit ) {
508 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 508 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
509 insanityBool=TRUE; 509 insanityBool=TRUE;
510 return Vdit; 510 return Vdit;
511 } 511 }
512 } 512 }
513 } 513 }
514 break; 514 break;
515 }; 515 };
516 return 0; 516 return 0;
517} 517}
518 518
519bool PlayListWidget::prev() { 519bool PlayListWidget::prev() {
520 if ( mediaPlayerState->playlist() ) { 520 if ( mediaPlayerState->playlist() ) {
521 if ( mediaPlayerState->shuffled() ) { 521 if ( mediaPlayerState->shuffled() ) {
522 const DocLnk *cur = current(); 522 const DocLnk *cur = current();
523 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 523 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
524 for ( int i = 0; i < j; i++ ) { 524 for ( int i = 0; i < j; i++ ) {
525 if ( !d->selectedFiles->next() ) 525 if ( !d->selectedFiles->next() )
526 d->selectedFiles->first(); 526 d->selectedFiles->first();
527 } 527 }
528 if ( cur == current() ) 528 if ( cur == current() )
529 if ( !d->selectedFiles->next() ) 529 if ( !d->selectedFiles->next() )
530 d->selectedFiles->first(); 530 d->selectedFiles->first();
531 return TRUE; 531 return TRUE;
532 } else { 532 } else {
533 if ( !d->selectedFiles->prev() ) { 533 if ( !d->selectedFiles->prev() ) {
534 if ( mediaPlayerState->looping() ) { 534 if ( mediaPlayerState->looping() ) {
535 return d->selectedFiles->last(); 535 return d->selectedFiles->last();
536 } else { 536 } else {
537 return FALSE; 537 return FALSE;
538 } 538 }
539 } 539 }
540 return TRUE; 540 return TRUE;
541 } 541 }
542 } else { 542 } else {
543 return mediaPlayerState->looping(); 543 return mediaPlayerState->looping();
544 } 544 }
545} 545}
546 546
547 547
548bool PlayListWidget::next() { 548bool PlayListWidget::next() {
549 if ( mediaPlayerState->playlist() ) { 549 if ( mediaPlayerState->playlist() ) {
550 if ( mediaPlayerState->shuffled() ) { 550 if ( mediaPlayerState->shuffled() ) {
551 return prev(); 551 return prev();
552 } else { 552 } else {
553 if ( !d->selectedFiles->next() ) { 553 if ( !d->selectedFiles->next() ) {
554 if ( mediaPlayerState->looping() ) { 554 if ( mediaPlayerState->looping() ) {
555 return d->selectedFiles->first(); 555 return d->selectedFiles->first();
556 } else { 556 } else {
557 return FALSE; 557 return FALSE;
558 } 558 }
559 } 559 }
560 return TRUE; 560 return TRUE;
561 } 561 }
562 } else { 562 } else {
563 return mediaPlayerState->looping(); 563 return mediaPlayerState->looping();
564 } 564 }
565} 565}
566 566
567 567
568bool PlayListWidget::first() { 568bool PlayListWidget::first() {
569 if ( mediaPlayerState->playlist() ) 569 if ( mediaPlayerState->playlist() )
570 return d->selectedFiles->first(); 570 return d->selectedFiles->first();
571 else 571 else
572 return mediaPlayerState->looping(); 572 return mediaPlayerState->looping();
573} 573}
574 574
575 575
576bool PlayListWidget::last() { 576bool PlayListWidget::last() {
577 if ( mediaPlayerState->playlist() ) 577 if ( mediaPlayerState->playlist() )
578 return d->selectedFiles->last(); 578 return d->selectedFiles->last();
579 else 579 else
580 return mediaPlayerState->looping(); 580 return mediaPlayerState->looping();
581} 581}
582 582
583 583
584void PlayListWidget::saveList() { 584void PlayListWidget::saveList() {
585 585
586 QString filename; 586 QString filename;
587 InputDialog *fileDlg; 587 InputDialog *fileDlg;
588 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 588 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
589 fileDlg->exec(); 589 fileDlg->exec();
590 if( fileDlg->result() == 1 ) { 590 if( fileDlg->result() == 1 ) {
591 if ( d->current ) 591 if ( d->current )
592 delete d->current; 592 delete d->current;
593 filename = fileDlg->LineEdit1->text();//+".playlist"; 593 filename = fileDlg->LineEdit1->text();//+".playlist";
594 // qDebug("saving playlist "+filename+".playlist"); 594 // qDebug("saving playlist "+filename+".playlist");
595 Config cfg( filename +".playlist"); 595 Config cfg( filename +".playlist");
596 writeConfig( cfg ); 596 writeConfig( cfg );
597 597
598 DocLnk lnk; 598 DocLnk lnk;
599 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 599 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
600 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 600 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
601 lnk.setIcon("opieplayer2/playlist2"); 601 lnk.setIcon("opieplayer2/playlist2");
602 lnk.setName( filename); //sets file name 602 lnk.setName( filename); //sets file name
603 // qDebug(filename); 603 // qDebug(filename);
604 if(!lnk.writeLink()) { 604 if(!lnk.writeLink()) {
605 qDebug("Writing doclink did not work"); 605 qDebug("Writing doclink did not work");
606 } 606 }
607 } 607 }
608 Config config( "OpiePlayer" ); 608 Config config( "OpiePlayer" );
609 config.writeEntry("CurrentPlaylist",filename); 609 config.writeEntry("CurrentPlaylist",filename);
610 setCaption(tr("OpiePlayer: ")+filename); 610 setCaption(tr("OpiePlayer: ")+filename);
611 d->selectedFiles->first(); 611 d->selectedFiles->first();
612 if(fileDlg) { 612 if(fileDlg) {
613 delete fileDlg; 613 delete fileDlg;
614 } 614 }
615} 615}
616 616
617void PlayListWidget::loadList( const DocLnk & lnk) { 617void PlayListWidget::loadList( const DocLnk & lnk) {
618 QString name= lnk.name(); 618 QString name= lnk.name();
619 // qDebug("currentList is "+name); 619 // qDebug("currentList is "+name);
620 if( name.length()>1) { 620 if( name.length()>1) {
621 setCaption("OpiePlayer: "+name); 621 setCaption("OpiePlayer: "+name);
622 // qDebug("load list "+ name+".playlist"); 622 // qDebug("load list "+ name+".playlist");
623 clearList(); 623 clearList();
624 Config cfg( name+".playlist"); 624 Config cfg( name+".playlist");
625 readConfig(cfg); 625 readConfig(cfg);
626 626
627 tabWidget->setCurrentPage(0); 627 tabWidget->setCurrentPage(0);
628 628
629 Config config( "OpiePlayer" ); 629 Config config( "OpiePlayer" );
630 config.writeEntry("CurrentPlaylist", name); 630 config.writeEntry("CurrentPlaylist", name);
631 // d->selectedFiles->first(); 631 // d->selectedFiles->first();
632 } 632 }
633 633
634} 634}
635 635
636void PlayListWidget::setPlaylist( bool shown ) { 636void PlayListWidget::setPlaylist( bool shown ) {
637 if ( shown ) { 637 if ( shown ) {
638 d->playListFrame->show(); 638 d->playListFrame->show();
639 } else { 639 } else {
640 d->playListFrame->hide(); 640 d->playListFrame->hide();
641 } 641 }
642} 642}
643 643
644void PlayListWidget::setView( char view ) { 644void PlayListWidget::setView( char view ) {
645 if ( view == 'l' ) 645 if ( view == 'l' )
646 showMaximized(); 646 showMaximized();
647 else 647 else
648 hide(); 648 hide();
649} 649}
650 650
651void PlayListWidget::addSelected() { 651void PlayListWidget::addSelected() {
652 652
653 Config cfg( "OpiePlayer" ); 653 Config cfg( "OpiePlayer" );
654 cfg.setGroup("PlayList"); 654 cfg.setGroup("PlayList");
655 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 655 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
656 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 656 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
657 657
658 switch (tabWidget->currentPageIndex()) { 658 switch (tabWidget->currentPageIndex()) {
659 case 0: //playlist 659 case 0: //playlist
660 break; 660 break;
661 case 1: { //audio 661 case 1: { //audio
662 QListViewItemIterator it( audioView ); 662 QListViewItemIterator it( audioView );
663 // iterate through all items of the listview 663 // iterate through all items of the listview
664 for ( ; it.current(); ++it ) { 664 for ( ; it.current(); ++it ) {
665 if ( it.current()->isSelected() ) { 665 if ( it.current()->isSelected() ) {
666 QListIterator<DocLnk> dit( files.children() ); 666 QListIterator<DocLnk> dit( files.children() );
667 for ( ; dit.current(); ++dit ) { 667 for ( ; dit.current(); ++dit ) {
668 if( dit.current()->name() == it.current()->text(0) ) { 668 if( dit.current()->name() == it.current()->text(0) ) {
669 if(QFileInfo( dit.current()->file()).exists()) 669 if(QFileInfo( dit.current()->file()).exists())
670 d->selectedFiles->addToSelection( **dit ); 670 d->selectedFiles->addToSelection( **dit );
671 } 671 }
672 } 672 }
673 audioView->setSelected( it.current(),FALSE); 673 audioView->setSelected( it.current(),FALSE);
674 } 674 }
675 } 675 }
676 tabWidget->setCurrentPage(0); 676 tabWidget->setCurrentPage(0);
677 } 677 }
678 break; 678 break;
679 case 2: { // video 679 case 2: { // video
680 QListViewItemIterator it( videoView ); 680 QListViewItemIterator it( videoView );
681 // iterate through all items of the listview 681 // iterate through all items of the listview
682 for ( ; it.current(); ++it ) { 682 for ( ; it.current(); ++it ) {
683 if ( it.current()->isSelected() ) { 683 if ( it.current()->isSelected() ) {
684 QListIterator<DocLnk> dit( vFiles.children() ); 684 QListIterator<DocLnk> dit( vFiles.children() );
685 for ( ; dit.current(); ++dit ) { 685 for ( ; dit.current(); ++dit ) {
686 if( dit.current()->name() == it.current()->text(0) ) { 686 if( dit.current()->name() == it.current()->text(0) ) {
687 if(QFileInfo( dit.current()->file()).exists()) 687 if(QFileInfo( dit.current()->file()).exists())
688 d->selectedFiles->addToSelection( **dit ); 688 d->selectedFiles->addToSelection( **dit );
689 } 689 }
690 } 690 }
691 videoView->setSelected( it.current(),FALSE); 691 videoView->setSelected( it.current(),FALSE);
692 } 692 }
693 } 693 }
694 tabWidget->setCurrentPage(0); 694 tabWidget->setCurrentPage(0);
695 } 695 }
696 break; 696 break;
697 }; 697 };
698} 698}
699 699
700void PlayListWidget::removeSelected() { 700void PlayListWidget::removeSelected() {
701 d->selectedFiles->removeSelected( ); 701 d->selectedFiles->removeSelected( );
702} 702}
703 703
704void PlayListWidget::playIt( QListViewItem *it) { 704void PlayListWidget::playIt( QListViewItem *it) {
705 if(!it) return; 705 if(!it) return;
706 mediaPlayerState->setPlaying(FALSE); 706 mediaPlayerState->setPlaying(FALSE);
707 mediaPlayerState->setPlaying(TRUE); 707 mediaPlayerState->setPlaying(TRUE);
708 d->selectedFiles->unSelect(); 708 d->selectedFiles->unSelect();
709} 709}
710 710
711void PlayListWidget::addToSelection( QListViewItem *it) { 711void PlayListWidget::addToSelection( QListViewItem *it) {
712 d->setDocumentUsed = FALSE; 712 d->setDocumentUsed = FALSE;
713 713
714 if(it) { 714 if(it) {
715 switch (tabWidget->currentPageIndex()) { 715 switch (tabWidget->currentPageIndex()) {
716 case 1: { 716 case 1: {
717 QListIterator<DocLnk> dit( files.children() ); 717 QListIterator<DocLnk> dit( files.children() );
718 for ( ; dit.current(); ++dit ) { 718 for ( ; dit.current(); ++dit ) {
719 if( dit.current()->name() == it->text(0)) { 719 if( dit.current()->name() == it->text(0)) {
720 if(QFileInfo( dit.current()->file()).exists()) 720 if(QFileInfo( dit.current()->file()).exists())
721 d->selectedFiles->addToSelection( **dit ); 721 d->selectedFiles->addToSelection( **dit );
722 } 722 }
723 } 723 }
724 } 724 }
725 break; 725 break;
726 case 2: { 726 case 2: {
727 QListIterator<DocLnk> dit( vFiles.children() ); 727 QListIterator<DocLnk> dit( vFiles.children() );
728 for ( ; dit.current(); ++dit ) { 728 for ( ; dit.current(); ++dit ) {
729 if( dit.current()->name() == it->text(0)) { 729 if( dit.current()->name() == it->text(0)) {
730 if(QFileInfo( dit.current()->file()).exists()) 730 if(QFileInfo( dit.current()->file()).exists())
731 d->selectedFiles->addToSelection( **dit ); 731 d->selectedFiles->addToSelection( **dit );
732 } 732 }
733 } 733 }
734 } 734 }
735 break; 735 break;
736 case 0: 736 case 0:
737 break; 737 break;
738 }; 738 };
739 tabWidget->setCurrentPage(0); 739 tabWidget->setCurrentPage(0);
740 } 740 }
741} 741}
742 742
743void PlayListWidget::tabChanged(QWidget *) { 743void PlayListWidget::tabChanged(QWidget *) {
744 744
745 switch ( tabWidget->currentPageIndex()) { 745 switch ( tabWidget->currentPageIndex()) {
746 case 0: 746 case 0:
747 { 747 {
748 if( !tbDeletePlaylist->isHidden()) 748 if( !tbDeletePlaylist->isHidden())
749 tbDeletePlaylist->hide(); 749 tbDeletePlaylist->hide();
750 d->tbRemoveFromList->setEnabled(TRUE); 750 d->tbRemoveFromList->setEnabled(TRUE);
751 d->tbAddToList->setEnabled(FALSE); 751 d->tbAddToList->setEnabled(FALSE);
752 } 752 }
753 break; 753 break;
754 case 1: 754 case 1:
755 { 755 {
756 audioView->clear(); 756 audioView->clear();
757 populateAudioView(); 757 populateAudioView();
758 758
759 if( !tbDeletePlaylist->isHidden()) 759 if( !tbDeletePlaylist->isHidden())
760 tbDeletePlaylist->hide(); 760 tbDeletePlaylist->hide();
761 d->tbRemoveFromList->setEnabled(FALSE); 761 d->tbRemoveFromList->setEnabled(FALSE);
762 d->tbAddToList->setEnabled(TRUE); 762 d->tbAddToList->setEnabled(TRUE);
763 } 763 }
764 break; 764 break;
765 case 2: 765 case 2:
766 { 766 {
767 videoView->clear(); 767 videoView->clear();
768 populateVideoView(); 768 populateVideoView();
769 if( !tbDeletePlaylist->isHidden()) 769 if( !tbDeletePlaylist->isHidden())
770 tbDeletePlaylist->hide(); 770 tbDeletePlaylist->hide();
771 d->tbRemoveFromList->setEnabled(FALSE); 771 d->tbRemoveFromList->setEnabled(FALSE);
772 d->tbAddToList->setEnabled(TRUE); 772 d->tbAddToList->setEnabled(TRUE);
773 } 773 }
774 break; 774 break;
775 case 3: 775 case 3:
776 { 776 {
777 if( tbDeletePlaylist->isHidden()) 777 if( tbDeletePlaylist->isHidden())
778 tbDeletePlaylist->show(); 778 tbDeletePlaylist->show();
779 playLists->reread(); 779 playLists->reread();
780 } 780 }
781 break; 781 break;
782 }; 782 };
783} 783}
784 784
785void PlayListWidget::btnPlay(bool b) { 785void PlayListWidget::btnPlay(bool b) {
786 786
787 // mediaPlayerState->setPlaying(b); 787 // mediaPlayerState->setPlaying(b);
788 switch ( tabWidget->currentPageIndex()) { 788 switch ( tabWidget->currentPageIndex()) {
789 case 0: 789 case 0:
790 { 790 {
791 mediaPlayerState->setPlaying(b); 791 mediaPlayerState->setPlaying(b);
792 } 792 }
793 break; 793 break;
794 case 1: 794 case 1:
795 { 795 {
796 addToSelection( audioView->currentItem() ); 796 addToSelection( audioView->currentItem() );
797 mediaPlayerState->setPlaying(b); 797 mediaPlayerState->setPlaying(b);
798 d->selectedFiles->removeSelected( ); 798 d->selectedFiles->removeSelected( );
799 tabWidget->setCurrentPage(1); 799 tabWidget->setCurrentPage(1);
800 d->selectedFiles->unSelect(); 800 d->selectedFiles->unSelect();
801 insanityBool=FALSE; 801 insanityBool=FALSE;
802 }// audioView->clearSelection(); 802 }// audioView->clearSelection();
803 break; 803 break;
804 case 2: 804 case 2:
805 { 805 {
806 addToSelection( videoView->currentItem() ); 806 addToSelection( videoView->currentItem() );
807 mediaPlayerState->setPlaying(b); 807 mediaPlayerState->setPlaying(b);
808 qApp->processEvents(); 808 qApp->processEvents();
809 d->selectedFiles->removeSelected( ); 809 d->selectedFiles->removeSelected( );
810 tabWidget->setCurrentPage(2); 810 tabWidget->setCurrentPage(2);
811 d->selectedFiles->unSelect(); 811 d->selectedFiles->unSelect();
812 insanityBool=FALSE; 812 insanityBool=FALSE;
813 }// videoView->clearSelection(); 813 }// videoView->clearSelection();
814 break; 814 break;
815 }; 815 };
816 816
817} 817}
818 818
819void PlayListWidget::deletePlaylist() { 819void PlayListWidget::deletePlaylist() {
820 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 820 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
821 (tr("You really want to delete\nthis playlist?")), 821 (tr("You really want to delete\nthis playlist?")),
822 (tr("Yes")), (tr("No")), 0 )){ 822 (tr("Yes")), (tr("No")), 0 )){
823 case 0: // Yes clicked, 823 case 0: // Yes clicked,
824 QFile().remove(playLists->selected()->file()); 824 QFile().remove(playLists->selected()->file());
825 QFile().remove(playLists->selected()->linkFile()); 825 QFile().remove(playLists->selected()->linkFile());
826 playLists->reread(); 826 playLists->reread();
827 break; 827 break;
828 case 1: // Cancel 828 case 1: // Cancel
829 break; 829 break;
830 }; 830 };
831} 831}
832 832
833void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 833void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
834 switch (mouse) { 834 switch (mouse) {
835 case 1: 835 case 1:
836 break; 836 break;
837 case 2:{ 837 case 2:{
838 QPopupMenu m; 838 QPopupMenu m;
839 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 839 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
840 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 840 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
841 m.insertSeparator(); 841 m.insertSeparator();
842 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 842 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
843 m.exec( QCursor::pos() ); 843 m.exec( QCursor::pos() );
844 } 844 }
845 break; 845 break;
846 }; 846 };
847} 847}
848 848
849void PlayListWidget::playSelected() { 849void PlayListWidget::playSelected() {
850 btnPlay( TRUE); 850 btnPlay( TRUE);
851} 851}
852 852
853void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 853void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
854 switch (mouse) { 854 switch (mouse) {
855 case 1: 855 case 1:
856 856
857 break; 857 break;
858 case 2: 858 case 2:
859 { 859 {
860 QPopupMenu m; 860 QPopupMenu m;
861 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 861 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
862 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 862 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
863 m.exec( QCursor::pos() ); 863 m.exec( QCursor::pos() );
864 } 864 }
865 break; 865 break;
866 }; 866 };
867} 867}
868 868
869void PlayListWidget::listDelete() { 869void PlayListWidget::listDelete() {
870 Config cfg( "OpiePlayer" ); 870 Config cfg( "OpiePlayer" );
871 cfg.setGroup("PlayList"); 871 cfg.setGroup("PlayList");
872 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 872 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
873 QString file; 873 QString file;
874 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 874 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
875 switch ( tabWidget->currentPageIndex()) { 875 switch ( tabWidget->currentPageIndex()) {
876 case 0: 876 case 0:
877 break; 877 break;
878 case 1: 878 case 1:
879 { 879 {
880 file = audioView->currentItem()->text(0); 880 file = audioView->currentItem()->text(0);
881 QListIterator<DocLnk> Pdit( files.children() ); 881 QListIterator<DocLnk> Pdit( files.children() );
882 for ( ; Pdit.current(); ++Pdit ) { 882 for ( ; Pdit.current(); ++Pdit ) {
883 if( Pdit.current()->name() == file) { 883 if( Pdit.current()->name() == file) {
884 LnkProperties prop( Pdit.current() ); 884 LnkProperties prop( Pdit.current() );
885 prop.showMaximized(); 885 prop.showMaximized();
886 prop.exec(); 886 prop.exec();
887 } 887 }
888 } 888 }
889 populateAudioView(); 889 populateAudioView();
890 } 890 }
891 break; 891 break;
892 case 2: 892 case 2:
893 { 893 {
894 894
895 } 895 }
896 break; 896 break;
897 }; 897 };
898} 898}
899 899
900void PlayListWidget::scanForAudio() { 900void PlayListWidget::scanForAudio() {
901 qDebug("scan for audio"); 901 qDebug("scan for audio");
902 files.detachChildren(); 902 files.detachChildren();
903 QListIterator<DocLnk> sdit( files.children() ); 903 QListIterator<DocLnk> sdit( files.children() );
904 for ( ; sdit.current(); ++sdit ) { 904 for ( ; sdit.current(); ++sdit ) {
905 delete sdit.current(); 905 delete sdit.current();
906 } 906 }
907 Global::findDocuments(&files, "audio/*"); 907 Global::findDocuments(&files, "audio/*");
908 audioScan = TRUE; 908 audioScan = TRUE;
909} 909}
910 910
911void PlayListWidget::scanForVideo() { 911void PlayListWidget::scanForVideo() {
912 qDebug("scan for video"); 912 qDebug("scan for video");
913 vFiles.detachChildren(); 913 vFiles.detachChildren();
914 QListIterator<DocLnk> sdit( vFiles.children() ); 914 QListIterator<DocLnk> sdit( vFiles.children() );
915 for ( ; sdit.current(); ++sdit ) { 915 for ( ; sdit.current(); ++sdit ) {
916 delete sdit.current(); 916 delete sdit.current();
917 } 917 }
918 Global::findDocuments(&vFiles, "video/*"); 918 Global::findDocuments(&vFiles, "video/*");
919 videoScan = TRUE; 919 videoScan = TRUE;
920} 920}
921 921
922void PlayListWidget::populateAudioView() { 922void PlayListWidget::populateAudioView() {
923 923
924 audioView->clear(); 924 audioView->clear();
925 StorageInfo storageInfo; 925 StorageInfo storageInfo;
926 const QList<FileSystem> &fs = storageInfo.fileSystems(); 926 const QList<FileSystem> &fs = storageInfo.fileSystems();
927 if(!audioScan) scanForAudio(); 927 if(!audioScan) scanForAudio();
928 928
929 QListIterator<DocLnk> dit( files.children() ); 929 QListIterator<DocLnk> dit( files.children() );
930 QListIterator<FileSystem> it ( fs ); 930 QListIterator<FileSystem> it ( fs );
931 931
932 QString storage; 932 QString storage;
933 for ( ; dit.current(); ++dit ) { 933 for ( ; dit.current(); ++dit ) {
934 for( ; it.current(); ++it ){ 934 for( ; it.current(); ++it ){
935 const QString name = (*it)->name(); 935 const QString name = (*it)->name();
936 const QString path = (*it)->path(); 936 const QString path = (*it)->path();
937 if(dit.current()->file().find(path) != -1 ) storage=name; 937 if(dit.current()->file().find(path) != -1 ) storage=name;
938 } 938 }
939 939
940 QListViewItem * newItem; 940 QListViewItem * newItem;
941 if ( QFile( dit.current()->file()).exists() ) { 941 if ( QFile( dit.current()->file()).exists() ) {
942 // qDebug(dit.current()->name()); 942 // qDebug(dit.current()->name());
943 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 943 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
944 QString::number( QFile( dit.current()->file()).size() ), storage); 944 QString::number( QFile( dit.current()->file()).size() ), storage);
945 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); 945 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" ));
946 } 946 }
947 } 947 }
948 948
949} 949}
950 950
951void PlayListWidget::populateVideoView() { 951void PlayListWidget::populateVideoView() {
952 videoView->clear(); 952 videoView->clear();
953 StorageInfo storageInfo; 953 StorageInfo storageInfo;
954 const QList<FileSystem> &fs = storageInfo.fileSystems(); 954 const QList<FileSystem> &fs = storageInfo.fileSystems();
955 955
956 if(!videoScan ) scanForVideo(); 956 if(!videoScan ) scanForVideo();
957 957
958 QListIterator<DocLnk> Vdit( vFiles.children() ); 958 QListIterator<DocLnk> Vdit( vFiles.children() );
959 QListIterator<FileSystem> it ( fs ); 959 QListIterator<FileSystem> it ( fs );
960 videoView->clear(); 960 videoView->clear();
961 QString storage; 961 QString storage;
962 for ( ; Vdit.current(); ++Vdit ) { 962 for ( ; Vdit.current(); ++Vdit ) {
963 for( ; it.current(); ++it ){ 963 for( ; it.current(); ++it ){
964 const QString name = (*it)->name(); 964 const QString name = (*it)->name();
965 const QString path = (*it)->path(); 965 const QString path = (*it)->path();
966 if( Vdit.current()->file().find(path) != -1 ) storage=name; 966 if( Vdit.current()->file().find(path) != -1 ) storage=name;
967 } 967 }
968 968
969 QListViewItem * newItem; 969 QListViewItem * newItem;
970 if ( QFile( Vdit.current()->file()).exists() ) { 970 if ( QFile( Vdit.current()->file()).exists() ) {
971 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 971 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
972 QString::number( QFile( Vdit.current()->file()).size() ), storage); 972 QString::number( QFile( Vdit.current()->file()).size() ), storage);
973 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); 973 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ));
974 } 974 }
975 } 975 }
976} 976}
977 977
978void PlayListWidget::openFile() { 978void PlayListWidget::openFile() {
979 QString filename, name; 979 QString filename, name;
980 InputDialog *fileDlg; 980 InputDialog *fileDlg;
981 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 981 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
982 fileDlg->exec(); 982 fileDlg->exec();
983 if( fileDlg->result() == 1 ) { 983 if( fileDlg->result() == 1 ) {
984 filename = fileDlg->LineEdit1->text(); 984 filename = fileDlg->LineEdit1->text();
985 985
986 qDebug("Selected filename is "+filename); 986 qDebug("Selected filename is "+filename);
987 if(filename.right(3) == "m3u") { 987 if(filename.right(3) == "m3u") {
988 readm3u( filename ); 988 readm3u( filename );
989 } else if(filename.right(3) == "pls") { 989 } else if(filename.right(3) == "pls") {
990 readPls( filename ); 990 readPls( filename );
991 } else { 991 } else {
992 DocLnk lnk; 992 DocLnk lnk;
993 993
994 lnk.setName(filename); //sets file name 994 lnk.setName(filename); //sets file name
995 lnk.setFile(filename); //sets File property 995 lnk.setFile(filename); //sets File property
996 lnk.setType("audio/x-mpegurl"); 996 lnk.setType("audio/x-mpegurl");
997 lnk.setExec("opieplayer"); 997 lnk.setExec("opieplayer");
998 lnk.setIcon("opieplayer2/MPEGPlayer"); 998 lnk.setIcon("opieplayer2/MPEGPlayer");
999 999
1000 if(!lnk.writeLink()) { 1000 if(!lnk.writeLink()) {
1001 qDebug("Writing doclink did not work"); 1001 qDebug("Writing doclink did not work");
1002 } 1002 }
1003 d->selectedFiles->addToSelection( lnk); 1003 d->selectedFiles->addToSelection( lnk);
1004 } 1004 }
1005 } 1005 }
1006 if(fileDlg) { 1006 if(fileDlg) {
1007 delete fileDlg; 1007 delete fileDlg;
1008 } 1008 }
1009} 1009}
1010 1010
1011void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1011void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1012{ 1012{
1013 switch ( e->key() ) { 1013 switch ( e->key() ) {
1014 ////////////////////////////// Zaurus keys 1014 ////////////////////////////// Zaurus keys
1015 case Key_F9: //activity 1015 case Key_F9: //activity
1016 // if(audioUI->isHidden()) 1016 // if(audioUI->isHidden())
1017 // audioUI->showMaximized(); 1017 // audioUI->showMaximized();
1018 break; 1018 break;
1019 case Key_F10: //contacts 1019 case Key_F10: //contacts
1020 // if( videoUI->isHidden()) 1020 // if( videoUI->isHidden())
1021 // videoUI->showMaximized(); 1021 // videoUI->showMaximized();
1022 break; 1022 break;
1023 case Key_F11: //menu 1023 case Key_F11: //menu
1024 break; 1024 break;
1025 case Key_F12: //home 1025 case Key_F12: //home
1026 // doBlank(); 1026 // doBlank();
1027 break; 1027 break;
1028 case Key_F13: //mail 1028 case Key_F13: //mail
1029 // doUnblank(); 1029 // doUnblank();
1030 break; 1030 break;
1031 case Key_Q: //add to playlist 1031 case Key_Q: //add to playlist
1032 qDebug("Add"); 1032 qDebug("Add");
1033 addSelected(); 1033 addSelected();
1034 break; 1034 break;
1035 case Key_R: //remove from playlist 1035 case Key_R: //remove from playlist
1036 removeSelected(); 1036 removeSelected();
1037 break; 1037 break;
1038 // case Key_P: //play 1038 // case Key_P: //play
1039 // qDebug("Play"); 1039 // qDebug("Play");
1040 // playSelected(); 1040 // playSelected();
1041 // break; 1041 // break;
1042 case Key_Space: 1042 case Key_Space:
1043 qDebug("Play"); 1043 qDebug("Play");
1044 // playSelected(); puh 1044 // playSelected(); puh
1045 break; 1045 break;
1046 case Key_1: 1046 case Key_1:
1047 tabWidget->setCurrentPage(0); 1047 tabWidget->setCurrentPage(0);
1048 break; 1048 break;
1049 case Key_2: 1049 case Key_2:
1050 tabWidget->setCurrentPage(1); 1050 tabWidget->setCurrentPage(1);
1051 break; 1051 break;
1052 case Key_3: 1052 case Key_3:
1053 tabWidget->setCurrentPage(2); 1053 tabWidget->setCurrentPage(2);
1054 break; 1054 break;
1055 case Key_4: 1055 case Key_4:
1056 tabWidget->setCurrentPage(3); 1056 tabWidget->setCurrentPage(3);
1057 break; 1057 break;
1058 case Key_Down: 1058 case Key_Down:
1059 if ( !d->selectedFiles->next() ) 1059 if ( !d->selectedFiles->next() )
1060 d->selectedFiles->first(); 1060 d->selectedFiles->first();
1061 1061
1062 break; 1062 break;
1063 case Key_Up: 1063 case Key_Up:
1064 if ( !d->selectedFiles->prev() ) 1064 if ( !d->selectedFiles->prev() )
1065 // d->selectedFiles->last(); 1065 // d->selectedFiles->last();
1066 1066
1067 break; 1067 break;
1068 1068
1069 } 1069 }
1070} 1070}
1071 1071
1072void PlayListWidget::keyPressEvent( QKeyEvent *) 1072void PlayListWidget::keyPressEvent( QKeyEvent *)
1073{ 1073{
1074 // qDebug("Key press"); 1074 // qDebug("Key press");
1075 // switch ( e->key() ) { 1075 // switch ( e->key() ) {
1076 // ////////////////////////////// Zaurus keys 1076 // ////////////////////////////// Zaurus keys
1077 // case Key_A: //add to playlist 1077 // case Key_A: //add to playlist
1078 // qDebug("Add"); 1078 // qDebug("Add");
1079 // addSelected(); 1079 // addSelected();
1080 // break; 1080 // break;
1081 // case Key_R: //remove from playlist 1081 // case Key_R: //remove from playlist
1082 // removeSelected(); 1082 // removeSelected();
1083 // break; 1083 // break;
1084 // case Key_P: //play 1084 // case Key_P: //play
1085 // qDebug("Play"); 1085 // qDebug("Play");
1086 // playSelected(); 1086 // playSelected();
1087 // break; 1087 // break;
1088 // case Key_Space: 1088 // case Key_Space:
1089 // qDebug("Play"); 1089 // qDebug("Play");
1090 // playSelected(); 1090 // playSelected();
1091 // break; 1091 // break;
1092 // } 1092 // }
1093} 1093}
1094 1094
1095 1095
1096 1096
1097void PlayListWidget::readm3u(const QString &filename) { 1097void PlayListWidget::readm3u(const QString &filename) {
1098 1098
1099 qDebug("m3u filename is "+filename); 1099 qDebug("m3u filename is "+filename);
1100 QFile f(filename); 1100 QFile f(filename);
1101 1101
1102 if(f.open(IO_ReadOnly)) { 1102 if(f.open(IO_ReadOnly)) {
1103 QTextStream t(&f); 1103 QTextStream t(&f);
1104 QString s;//, first, second; 1104 QString s;//, first, second;
1105 int i=0; 1105 int i=0;
1106 while ( !t.atEnd()) { 1106 while ( !t.atEnd()) {
1107 s=t.readLine(); 1107 s=t.readLine();
1108 1108
1109 if(s.find("#",0,TRUE) == -1) { 1109 if(s.find("#",0,TRUE) == -1) {
1110 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1110 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1111 if(s.left(2) == "E:" || s.left(2) == "P:") { 1111 if(s.left(2) == "E:" || s.left(2) == "P:") {
1112 s=s.right(s.length()-2); 1112 s=s.right(s.length()-2);
1113 // if(QFile(s).exists()) { 1113 // if(QFile(s).exists()) {
1114 DocLnk lnk( s ); 1114 DocLnk lnk( s );
1115 QFileInfo f(s); 1115 QFileInfo f(s);
1116 QString name = f.baseName(); 1116 QString name = f.baseName();
1117 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); 1117 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 );
1118 lnk.setName( name ); 1118 lnk.setName( name );
1119 s=s.replace( QRegExp("\\"),"/"); 1119 s=s.replace( QRegExp("\\"),"/");
1120 lnk.setFile( s ); 1120 lnk.setFile( s );
1121 lnk.writeLink(); 1121 lnk.writeLink();
1122 qDebug("add "+name); 1122 qDebug("add "+name);
1123 d->selectedFiles->addToSelection( lnk); 1123 d->selectedFiles->addToSelection( lnk);
1124 // } 1124 // }
1125 } else { // is url 1125 } else { // is url
1126 s.replace(QRegExp("%20")," "); 1126 s.replace(QRegExp("%20")," ");
1127 DocLnk lnk( s ); 1127 DocLnk lnk( s );
1128 QString name; 1128 QString name;
1129 if(name.left(4)=="http") { 1129 if(name.left(4)=="http") {
1130 name = s.right( s.length() - 7); 1130 name = s.right( s.length() - 7);
1131 } else { 1131 } else {
1132 name = s; 1132 name = s;
1133 } 1133 }
1134 lnk.setName(name); 1134 lnk.setName(name);
1135 if(s.at(s.length()-4) == '.') { 1135 if(s.at(s.length()-4) == '.') {
1136 lnk.setFile( s); 1136 lnk.setFile( s);
1137 } else { 1137 } else {
1138 lnk.setFile( s+"/"); 1138 lnk.setFile( s+"/");
1139 } 1139 }
1140 lnk.setType("audio/x-mpegurl"); 1140 lnk.setType("audio/x-mpegurl");
1141 lnk.writeLink(); 1141 lnk.writeLink();
1142 d->selectedFiles->addToSelection( lnk); 1142 d->selectedFiles->addToSelection( lnk);
1143 } 1143 }
1144 i++; 1144 i++;
1145 } 1145 }
1146 } 1146 }
1147 } 1147 }
1148 } 1148 }
1149 f.close(); 1149 f.close();
1150} 1150}
1151 1151
1152void PlayListWidget::writem3u() { 1152void PlayListWidget::writem3u() {
1153 1153
1154 InputDialog *fileDlg; 1154 InputDialog *fileDlg;
1155 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); 1155 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1156 fileDlg->exec(); 1156 fileDlg->exec();
1157 QString filename,list; 1157 QString filename,list;
1158 if( fileDlg->result() == 1 ) { 1158 if( fileDlg->result() == 1 ) {
1159 filename = fileDlg->LineEdit1->text(); 1159 filename = fileDlg->LineEdit1->text();
1160 qDebug(filename); 1160 qDebug(filename);
1161 int noOfFiles = 0; 1161 int noOfFiles = 0;
1162 d->selectedFiles->first(); 1162 d->selectedFiles->first();
1163 do { 1163 do {
1164 // we dont check for existance because of url's 1164 // we dont check for existance because of url's
1165 // qDebug(d->selectedFiles->current()->file()); 1165 // qDebug(d->selectedFiles->current()->file());
1166 list += d->selectedFiles->current()->file()+"\n"; 1166 list += d->selectedFiles->current()->file()+"\n";
1167 noOfFiles++; 1167 noOfFiles++;
1168 } 1168 }
1169 while ( d->selectedFiles->next() ); 1169 while ( d->selectedFiles->next() );
1170 qDebug(list); 1170 qDebug(list);
1171 if(filename.left(1) != "/") 1171 if(filename.left(1) != "/")
1172 filename=QPEApplication::documentDir()+"/"+filename; 1172 filename=QPEApplication::documentDir()+"/"+filename;
1173 if(filename.right(3) != "m3u") 1173 if(filename.right(3) != "m3u")
1174 filename=filename+".m3u"; 1174 filename=filename+".m3u";
1175 1175
1176 QFile f(filename); 1176 QFile f(filename);
1177 f.open(IO_WriteOnly); 1177 f.open(IO_WriteOnly);
1178 f.writeBlock(list, list.length()); 1178 f.writeBlock(list, list.length());
1179 f.close(); 1179 f.close();
1180 } 1180 }
1181 if(fileDlg) delete fileDlg; 1181 if(fileDlg) delete fileDlg;
1182} 1182}
1183 1183
1184void PlayListWidget::readPls(const QString &filename) { 1184void PlayListWidget::readPls(const QString &filename) {
1185 1185
1186 qDebug("pls filename is "+filename); 1186 qDebug("pls filename is "+filename);
1187 QFile f(filename); 1187 QFile f(filename);
1188 1188
1189 if(f.open(IO_ReadOnly)) { 1189 if(f.open(IO_ReadOnly)) {
1190 QTextStream t(&f); 1190 QTextStream t(&f);
1191 QString s;//, first, second; 1191 QString s;//, first, second;
1192 int i=0; 1192 int i=0;
1193 while ( !t.atEnd()) { 1193 while ( !t.atEnd()) {
1194 s=t.readLine(); 1194 s=t.readLine();
1195 if(s.left(4) == "File") { 1195 if(s.left(4) == "File") {
1196 s=s.right(s.length() - 6); 1196 s=s.right(s.length() - 6);
1197 s.replace(QRegExp("%20")," "); 1197 s.replace(QRegExp("%20")," ");
1198 qDebug("adding "+s+" to playlist"); 1198 qDebug("adding "+s+" to playlist");
1199 // numberofentries=2 1199 // numberofentries=2
1200 // File1=http 1200 // File1=http
1201 // Title 1201 // Title
1202 // Length 1202 // Length
1203 // Version 1203 // Version
1204 // File2=http 1204 // File2=http
1205 s=s.replace( QRegExp("\\"),"/"); 1205 s=s.replace( QRegExp("\\"),"/");
1206 DocLnk lnk( s ); 1206 DocLnk lnk( s );
1207 QFileInfo f(s); 1207 QFileInfo f(s);
1208 QString name = f.baseName(); 1208 QString name = f.baseName();
1209 if(name.left(4)=="http") 1209 if(name.left(4)=="http")
1210 name = s.right( s.length() - 7); 1210 name = s.right( s.length() - 7);
1211 else 1211 else
1212 name=s; 1212 name=s;
1213 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1213 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1214 lnk.setName( name); 1214 lnk.setName( name);
1215 if(s.at(s.length()-4) == '.') // if this is probably a file 1215 if(s.at(s.length()-4) == '.') // if this is probably a file
1216 lnk.setFile( s); 1216 lnk.setFile( s);
1217 else { //if its a url 1217 else { //if its a url
1218 if( name.right(1).find('/') == -1) 1218 if( name.right(1).find('/') == -1)
1219 s+="/"; 1219 s+="/";
1220 lnk.setFile( s); 1220 lnk.setFile( s);
1221 } 1221 }
1222 lnk.setType("audio/x-mpegurl"); 1222 lnk.setType("audio/x-mpegurl");
1223 1223
1224 qDebug("DocLnk add "+name); 1224 qDebug("DocLnk add "+name);
1225 d->selectedFiles->addToSelection( lnk); 1225 d->selectedFiles->addToSelection( lnk);
1226 } 1226 }
1227 } 1227 }
1228 i++; 1228 i++;
1229 } 1229 }
1230} 1230}
1231 1231
1232void PlayListWidget::pmViewActivated(int index) { 1232void PlayListWidget::pmViewActivated(int index) {
1233 qDebug("%d", index); 1233 qDebug("%d", index);
1234 switch(index) { 1234 switch(index) {
1235 case -16: 1235 case -16:
1236 { 1236 {
1237 1237
1238 mediaPlayerState->toggleFullscreen(); 1238 mediaPlayerState->toggleFullscreen();
1239 bool b=mediaPlayerState->fullscreen(); 1239 bool b=mediaPlayerState->fullscreen();
1240 pmView->setItemChecked( index,b); 1240 pmView->setItemChecked( index,b);
1241 Config cfg( "OpiePlayer" ); 1241 Config cfg( "OpiePlayer" );
1242 cfg.writeEntry("FullScreen", b); 1242 cfg.writeEntry("FullScreen", b);
1243 1243
1244 } 1244 }
1245 break; 1245 break;
1246 }; 1246 };
1247} 1247}
1248 1248
1249void PlayListWidget::populateSkinsMenu() { 1249void PlayListWidget::populateSkinsMenu() {
1250 int item=0; 1250 int item=0;
1251 defaultSkinIndex=0; 1251 defaultSkinIndex=0;
1252 QString skinName; 1252 QString skinName;
1253 Config cfg( "OpiePlayer" ); 1253 Config cfg( "OpiePlayer" );
1254 cfg.setGroup("Options"); 1254 cfg.setGroup("Options");
1255 QString skin = cfg.readEntry("Skin","default"); 1255 QString skin = cfg.readEntry("Skin","default");
1256 1256
1257 QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); 1257 QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins");
1258 skinsDir.setFilter( QDir::Dirs); 1258 skinsDir.setFilter( QDir::Dirs);
1259 skinsDir.setSorting(QDir::Name); 1259 skinsDir.setSorting(QDir::Name);
1260 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1260 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1261 QFileInfoListIterator it( *skinslist ); 1261 QFileInfoListIterator it( *skinslist );
1262 QFileInfo *fi; 1262 QFileInfo *fi;
1263 while ( (fi=it.current()) ) { 1263 while ( (fi=it.current()) ) {
1264 skinName = fi->fileName(); 1264 skinName = fi->fileName();
1265 qDebug( fi->fileName()); 1265 qDebug( fi->fileName());
1266 if( skinName != "." && skinName != ".." && skinName !="CVS") 1266 if( skinName != "." && skinName != ".." && skinName !="CVS")
1267 item = skinsMenu->insertItem( fi->fileName()); 1267 item = skinsMenu->insertItem( fi->fileName());
1268 if( skinName == "default") 1268 if( skinName == "default")
1269 defaultSkinIndex = item; 1269 defaultSkinIndex = item;
1270 if( skinName == skin) 1270 if( skinName == skin)
1271 skinsMenu->setItemChecked( item, TRUE); 1271 skinsMenu->setItemChecked( item, TRUE);
1272 1272
1273 ++it; 1273 ++it;
1274 } 1274 }
1275} 1275}
1276 1276
1277void PlayListWidget::skinsMenuActivated(int item) { 1277void PlayListWidget::skinsMenuActivated(int item) {
1278 for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { 1278 for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) {
1279 skinsMenu->setItemChecked( i, FALSE); 1279 skinsMenu->setItemChecked( i, FALSE);
1280 } 1280 }
1281 skinsMenu->setItemChecked( item, TRUE); 1281 skinsMenu->setItemChecked( item, TRUE);
1282 1282
1283 Config cfg( "OpiePlayer" ); 1283 Config cfg( "OpiePlayer" );
1284 cfg.setGroup("Options"); 1284 cfg.setGroup("Options");
1285 cfg.writeEntry("Skin", skinsMenu->text( item)); 1285 cfg.writeEntry("Skin", skinsMenu->text( item));
1286} 1286}
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index ddb4d74..60a3563 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,502 +1,505 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/mediaplayerplugininterface.h> 35#include <qpe/mediaplayerplugininterface.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38
38#include <qwidget.h> 39#include <qwidget.h>
39#include <qpainter.h> 40#include <qpainter.h>
40#include <qpixmap.h> 41#include <qpixmap.h>
41#include <qslider.h> 42#include <qslider.h>
42#include <qdrawutil.h> 43#include <qdrawutil.h>
43#include "videowidget.h" 44#include "videowidget.h"
44#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
45 46
46 47
47#ifdef Q_WS_QWS 48#ifdef Q_WS_QWS
48# define USE_DIRECT_PAINTER 49# define USE_DIRECT_PAINTER
49# include <qdirectpainter_qws.h> 50# include <qdirectpainter_qws.h>
50# include <qgfxraster_qws.h> 51# include <qgfxraster_qws.h>
51#endif 52#endif
52 53
53 54
54extern MediaPlayerState *mediaPlayerState; 55extern MediaPlayerState *mediaPlayerState;
55 56
56 57
57static const int xo = 2; // movable x offset 58static const int xo = 2; // movable x offset
58static const int yo = 0; // movable y offset 59static const int yo = 0; // movable y offset
59 60
60 61
61struct MediaButton { 62struct MediaButton {
62 bool isToggle, isHeld, isDown; 63 bool isToggle, isHeld, isDown;
63}; 64};
64 65
65MediaButton videoButtons[] = { 66MediaButton videoButtons[] = {
66 { FALSE, FALSE, FALSE }, // stop 67 { FALSE, FALSE, FALSE }, // stop
67 { TRUE, FALSE, FALSE }, // play 68 { TRUE, FALSE, FALSE }, // play
68 { FALSE, FALSE, FALSE }, // previous 69 { FALSE, FALSE, FALSE }, // previous
69 { FALSE, FALSE, FALSE }, // next 70 { FALSE, FALSE, FALSE }, // next
70 { FALSE, FALSE, FALSE }, // volUp 71 { FALSE, FALSE, FALSE }, // volUp
71 { FALSE, FALSE, FALSE }, // volDown 72 { FALSE, FALSE, FALSE }, // volDown
72 { TRUE, FALSE, FALSE } // fullscreen 73 { TRUE, FALSE, FALSE } // fullscreen
73}; 74};
74 75
75const char *skinV_mask_file_names[7] = { 76const char *skinV_mask_file_names[7] = {
76"stop","play","back","fwd","up","down","full" 77"stop","play","back","fwd","up","down","full"
77}; 78};
78 79
79static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 80static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
80 81
81 82
82VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
83QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 84QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
85
86
84 setCaption( tr("OpiePlayer - Video") ); 87 setCaption( tr("OpiePlayer - Video") );
85 88
86 videoFrame = new XineVideoWidget ( this, "Video frame" ); 89 videoFrame = new XineVideoWidget ( this, "Video frame" );
87 90
88 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 91 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
89 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 92 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
90 93
91 Config cfg("OpiePlayer"); 94 Config cfg("OpiePlayer");
92 cfg.setGroup("Options"); 95 cfg.setGroup("Options");
93 skin = cfg.readEntry("Skin","default"); 96 skin = cfg.readEntry("Skin","default");
94 97
95 QString skinPath = "opieplayer2/skins/" + skin; 98 QString skinPath = "opieplayer2/skins/" + skin;
96 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 99 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
97 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 100 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
98 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 101 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
99 102
100 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 103 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
101 imgButtonMask->fill( 0 ); 104 imgButtonMask->fill( 0 );
102 105
103 for ( int i = 0; i < 7; i++ ) { 106 for ( int i = 0; i < 7; i++ ) {
104 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; 107 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png";
105 masks[i] = new QBitmap( filename ); 108 masks[i] = new QBitmap( filename );
106 109
107 if ( !masks[i]->isNull() ) { 110 if ( !masks[i]->isNull() ) {
108 QImage imgMask = masks[i]->convertToImage(); 111 QImage imgMask = masks[i]->convertToImage();
109 uchar **dest = imgButtonMask->jumpTable(); 112 uchar **dest = imgButtonMask->jumpTable();
110 for ( int y = 0; y < imgUp->height(); y++ ) { 113 for ( int y = 0; y < imgUp->height(); y++ ) {
111 uchar *line = dest[y]; 114 uchar *line = dest[y];
112 for ( int x = 0; x < imgUp->width(); x++ ) { 115 for ( int x = 0; x < imgUp->width(); x++ ) {
113 if ( !qRed( imgMask.pixel( x, y ) ) ) 116 if ( !qRed( imgMask.pixel( x, y ) ) )
114 line[x] = i + 1; 117 line[x] = i + 1;
115 } 118 }
116 } 119 }
117 } 120 }
118 } 121 }
119 122
120 for ( int i = 0; i < 7; i++ ) { 123 for ( int i = 0; i < 7; i++ ) {
121 buttonPixUp[i] = NULL; 124 buttonPixUp[i] = NULL;
122 buttonPixDown[i] = NULL; 125 buttonPixDown[i] = NULL;
123 } 126 }
124 127
125 setBackgroundPixmap( *pixBg ); 128 setBackgroundPixmap( *pixBg );
126 129
127 slider = new QSlider( Qt::Horizontal, this ); 130 slider = new QSlider( Qt::Horizontal, this );
128 slider->setMinValue( 0 ); 131 slider->setMinValue( 0 );
129 slider->setMaxValue( 1 ); 132 slider->setMaxValue( 1 );
130 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 133 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
131 slider->setFocusPolicy( QWidget::NoFocus ); 134 slider->setFocusPolicy( QWidget::NoFocus );
132 135
133 resizeEvent( NULL ); 136 resizeEvent( NULL );
134 137
135 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 138 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
136 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 139 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
137 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 140 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
138 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 141 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
139 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 142 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
140 143
141 setLength( mediaPlayerState->length() ); 144 setLength( mediaPlayerState->length() );
142 setPosition( mediaPlayerState->position() ); 145 setPosition( mediaPlayerState->position() );
143 setFullscreen( mediaPlayerState->fullscreen() ); 146 setFullscreen( mediaPlayerState->fullscreen() );
144 setPlaying( mediaPlayerState->playing() ); 147 setPlaying( mediaPlayerState->playing() );
145} 148}
146 149
147 150
148VideoWidget::~VideoWidget() { 151VideoWidget::~VideoWidget() {
149 152
150 for ( int i = 0; i < 7; i++ ) { 153 for ( int i = 0; i < 7; i++ ) {
151 delete buttonPixUp[i]; 154 delete buttonPixUp[i];
152 delete buttonPixDown[i]; 155 delete buttonPixDown[i];
153 } 156 }
154 157
155 delete pixBg; 158 delete pixBg;
156 delete imgUp; 159 delete imgUp;
157 delete imgDn; 160 delete imgDn;
158 delete imgButtonMask; 161 delete imgButtonMask;
159 for ( int i = 0; i < 7; i++ ) { 162 for ( int i = 0; i < 7; i++ ) {
160 delete masks[i]; 163 delete masks[i];
161 } 164 }
162 165
163} 166}
164 167
165QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 168QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
166 QPixmap pix( img.width(), img.height() ); 169 QPixmap pix( img.width(), img.height() );
167 QPainter p( &pix ); 170 QPainter p( &pix );
168 p.drawTiledPixmap( pix.rect(), bg, offset ); 171 p.drawTiledPixmap( pix.rect(), bg, offset );
169 p.drawImage( 0, 0, img ); 172 p.drawImage( 0, 0, img );
170 return new QPixmap( pix ); 173 return new QPixmap( pix );
171} 174}
172 175
173QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 176QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
174 QPixmap *pixmap = new QPixmap( pix ); 177 QPixmap *pixmap = new QPixmap( pix );
175 pixmap->setMask( mask ); 178 pixmap->setMask( mask );
176 return pixmap; 179 return pixmap;
177} 180}
178 181
179void VideoWidget::resizeEvent( QResizeEvent * ) { 182void VideoWidget::resizeEvent( QResizeEvent * ) {
180 int h = height(); 183 int h = height();
181 int w = width(); 184 int w = width();
182 int Vh = 160; 185 int Vh = 160;
183 int Vw = 220; 186 int Vw = 220;
184 187
185 slider->setFixedWidth( w - 20 ); 188 slider->setFixedWidth( w - 20 );
186 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 189 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
187 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 190 slider->setBackgroundOrigin( QWidget::ParentOrigin );
188 slider->setFocusPolicy( QWidget::NoFocus ); 191 slider->setFocusPolicy( QWidget::NoFocus );
189 slider->setBackgroundPixmap( *pixBg ); 192 slider->setBackgroundPixmap( *pixBg );
190 193
191 xoff = 0;// ( imgUp->width() ) / 2; 194 xoff = 0;// ( imgUp->width() ) / 2;
192 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 195 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
193 QPoint p( xoff, yoff ); 196 QPoint p( xoff, yoff );
194 197
195 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 198 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
196 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 199 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
197 200
198 for ( int i = 0; i < 7; i++ ) { 201 for ( int i = 0; i < 7; i++ ) {
199 if ( !masks[i]->isNull() ) { 202 if ( !masks[i]->isNull() ) {
200 delete buttonPixUp[i]; 203 delete buttonPixUp[i];
201 delete buttonPixDown[i]; 204 delete buttonPixDown[i];
202 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 205 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
203 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 206 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
204 } 207 }
205 } 208 }
206 209
207 delete pixUp; 210 delete pixUp;
208 delete pixDn; 211 delete pixDn;
209} 212}
210 213
211static bool videoSliderBeingMoved = FALSE; 214static bool videoSliderBeingMoved = FALSE;
212 215
213void VideoWidget::sliderPressed() { 216void VideoWidget::sliderPressed() {
214 videoSliderBeingMoved = TRUE; 217 videoSliderBeingMoved = TRUE;
215} 218}
216 219
217void VideoWidget::sliderReleased() { 220void VideoWidget::sliderReleased() {
218 videoSliderBeingMoved = FALSE; 221 videoSliderBeingMoved = FALSE;
219 if ( slider->width() == 0 ) { 222 if ( slider->width() == 0 ) {
220 return; 223 return;
221 } 224 }
222 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 225 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
223 mediaPlayerState->setPosition( val ); 226 mediaPlayerState->setPosition( val );
224} 227}
225 228
226void VideoWidget::setPosition( long i ) { 229void VideoWidget::setPosition( long i ) {
227 updateSlider( i, mediaPlayerState->length() ); 230 updateSlider( i, mediaPlayerState->length() );
228} 231}
229 232
230 233
231void VideoWidget::setLength( long max ) { 234void VideoWidget::setLength( long max ) {
232 updateSlider( mediaPlayerState->position(), max ); 235 updateSlider( mediaPlayerState->position(), max );
233} 236}
234 237
235void VideoWidget::setView( char view ) { 238void VideoWidget::setView( char view ) {
236 239
237 if ( view == 'v' ) { 240 if ( view == 'v' ) {
238 makeVisible(); 241 makeVisible();
239 } else { 242 } else {
240 // Effectively blank the view next time we show it so it looks nicer 243 // Effectively blank the view next time we show it so it looks nicer
241 scaledWidth = 0; 244 scaledWidth = 0;
242 scaledHeight = 0; 245 scaledHeight = 0;
243 hide(); 246 hide();
244 } 247 }
245} 248}
246 249
247void VideoWidget::updateSlider( long i, long max ) { 250void VideoWidget::updateSlider( long i, long max ) {
248 // Will flicker too much if we don't do this 251 // Will flicker too much if we don't do this
249 if ( max == 0 ) { 252 if ( max == 0 ) {
250 return; 253 return;
251 } 254 }
252 int width = slider->width(); 255 int width = slider->width();
253 int val = int((double)i * width / max); 256 int val = int((double)i * width / max);
254 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 257 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
255 if ( slider->value() != val ) { 258 if ( slider->value() != val ) {
256 slider->setValue( val ); 259 slider->setValue( val );
257 } 260 }
258 if ( slider->maxValue() != width ) { 261 if ( slider->maxValue() != width ) {
259 slider->setMaxValue( width ); 262 slider->setMaxValue( width );
260 } 263 }
261 } 264 }
262} 265}
263 266
264void VideoWidget::setToggleButton( int i, bool down ) { 267void VideoWidget::setToggleButton( int i, bool down ) {
265 if ( down != videoButtons[i].isDown ) { 268 if ( down != videoButtons[i].isDown ) {
266 toggleButton( i ); 269 toggleButton( i );
267 } 270 }
268} 271}
269 272
270void VideoWidget::toggleButton( int i ) { 273void VideoWidget::toggleButton( int i ) {
271 videoButtons[i].isDown = !videoButtons[i].isDown; 274 videoButtons[i].isDown = !videoButtons[i].isDown;
272 QPainter p(this); 275 QPainter p(this);
273 paintButton ( &p, i ); 276 paintButton ( &p, i );
274} 277}
275 278
276void VideoWidget::paintButton( QPainter *p, int i ) { 279void VideoWidget::paintButton( QPainter *p, int i ) {
277 280
278 if ( videoButtons[i].isDown ) { 281 if ( videoButtons[i].isDown ) {
279 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 282 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
280 } else { 283 } else {
281 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 284 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
282 } 285 }
283} 286}
284 287
285void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 288void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
286 for ( int i = 0; i < numVButtons; i++ ) { 289 for ( int i = 0; i < numVButtons; i++ ) {
287 if ( event->state() == QMouseEvent::LeftButton ) { 290 if ( event->state() == QMouseEvent::LeftButton ) {
288 // The test to see if the mouse click is inside the button or not 291 // The test to see if the mouse click is inside the button or not
289 int x = event->pos().x() - xoff; 292 int x = event->pos().x() - xoff;
290 int y = event->pos().y() - yoff; 293 int y = event->pos().y() - yoff;
291 294
292 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 295 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
293 && y < imgButtonMask->height() 296 && y < imgButtonMask->height()
294 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 297 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
295 298
296 if ( isOnButton && !videoButtons[i].isHeld ) { 299 if ( isOnButton && !videoButtons[i].isHeld ) {
297 videoButtons[i].isHeld = TRUE; 300 videoButtons[i].isHeld = TRUE;
298 toggleButton(i); 301 toggleButton(i);
299 302
300 switch (i) { 303 switch (i) {
301 case VideoVolUp: 304 case VideoVolUp:
302 emit moreClicked(); 305 emit moreClicked();
303 return; 306 return;
304 case VideoVolDown: 307 case VideoVolDown:
305 emit lessClicked(); 308 emit lessClicked();
306 return; 309 return;
307 } 310 }
308 } else if ( !isOnButton && videoButtons[i].isHeld ) { 311 } else if ( !isOnButton && videoButtons[i].isHeld ) {
309 videoButtons[i].isHeld = FALSE; 312 videoButtons[i].isHeld = FALSE;
310 toggleButton(i); 313 toggleButton(i);
311 } 314 }
312 } else { 315 } else {
313 316
314 if ( videoButtons[i].isHeld ) { 317 if ( videoButtons[i].isHeld ) {
315 videoButtons[i].isHeld = FALSE; 318 videoButtons[i].isHeld = FALSE;
316 if ( !videoButtons[i].isToggle ) { 319 if ( !videoButtons[i].isToggle ) {
317 setToggleButton( i, FALSE ); 320 setToggleButton( i, FALSE );
318 } 321 }
319 322
320 switch(i) { 323 switch(i) {
321 324
322 case VideoPlay: { 325 case VideoPlay: {
323 if( mediaPlayerState->isPaused ) { 326 if( mediaPlayerState->isPaused ) {
324 setToggleButton( i, FALSE ); 327 setToggleButton( i, FALSE );
325 mediaPlayerState->setPaused( FALSE ); 328 mediaPlayerState->setPaused( FALSE );
326 return; 329 return;
327 } else if( !mediaPlayerState->isPaused ) { 330 } else if( !mediaPlayerState->isPaused ) {
328 setToggleButton( i, TRUE ); 331 setToggleButton( i, TRUE );
329 mediaPlayerState->setPaused( TRUE ); 332 mediaPlayerState->setPaused( TRUE );
330 return; 333 return;
331 } else { 334 } else {
332 return; 335 return;
333 } 336 }
334 } 337 }
335 338
336 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 339 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
337 case VideoNext: mediaPlayerState->setNext(); return; 340 case VideoNext: mediaPlayerState->setNext(); return;
338 case VideoPrevious: mediaPlayerState->setPrev(); return; 341 case VideoPrevious: mediaPlayerState->setPrev(); return;
339 case VideoVolUp: emit moreReleased(); return; 342 case VideoVolUp: emit moreReleased(); return;
340 case VideoVolDown: emit lessReleased(); return; 343 case VideoVolDown: emit lessReleased(); return;
341 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 344 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
342 } 345 }
343 } 346 }
344 } 347 }
345 } 348 }
346} 349}
347 350
348void VideoWidget::mousePressEvent( QMouseEvent *event ) { 351void VideoWidget::mousePressEvent( QMouseEvent *event ) {
349 mouseMoveEvent( event ); 352 mouseMoveEvent( event );
350} 353}
351 354
352void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 355void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
353 if ( mediaPlayerState->fullscreen() ) { 356 if ( mediaPlayerState->fullscreen() ) {
354 mediaPlayerState->setFullscreen( FALSE ); 357 mediaPlayerState->setFullscreen( FALSE );
355 makeVisible(); 358 makeVisible();
356 } 359 }
357 mouseMoveEvent( event ); 360 mouseMoveEvent( event );
358} 361}
359 362
360void VideoWidget::showEvent( QShowEvent* ) { 363void VideoWidget::showEvent( QShowEvent* ) {
361 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 364 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
362 mouseMoveEvent( &event ); 365 mouseMoveEvent( &event );
363} 366}
364 367
365 368
366 void VideoWidget::backToNormal() { 369 void VideoWidget::backToNormal() {
367 mediaPlayerState->setFullscreen( FALSE ); 370 mediaPlayerState->setFullscreen( FALSE );
368 makeVisible(); 371 makeVisible();
369 } 372 }
370 373
371void VideoWidget::makeVisible() { 374void VideoWidget::makeVisible() {
372 if ( mediaPlayerState->fullscreen() ) { 375 if ( mediaPlayerState->fullscreen() ) {
373 setBackgroundMode( QWidget::NoBackground ); 376 setBackgroundMode( QWidget::NoBackground );
374 showFullScreen(); 377 showFullScreen();
375 resize( qApp->desktop()->size() ); 378 resize( qApp->desktop()->size() );
376 slider->hide(); 379 slider->hide();
377 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 380 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
378 381
379 } else { 382 } else {
380 showNormal(); 383 showNormal();
381 showMaximized(); 384 showMaximized();
382 setBackgroundPixmap( *pixBg ); 385 setBackgroundPixmap( *pixBg );
383 if ( mediaPlayerState->streaming() ) { 386 if ( mediaPlayerState->streaming() ) {
384 slider->hide(); 387 slider->hide();
385 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 388 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
386 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 389 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
387 } else { 390 } else {
388 slider->show(); 391 slider->show();
389 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 392 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
390 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 393 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
391 } 394 }
392 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 395 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
393 qApp->processEvents(); 396 qApp->processEvents();
394 } 397 }
395} 398}
396 399
397 400
398void VideoWidget::paintEvent( QPaintEvent * pe) { 401void VideoWidget::paintEvent( QPaintEvent * pe) {
399 QPainter p( this ); 402 QPainter p( this );
400 403
401 if ( mediaPlayerState->fullscreen() ) { 404 if ( mediaPlayerState->fullscreen() ) {
402 // Clear the background 405 // Clear the background
403 p.setBrush( QBrush( Qt::black ) ); 406 p.setBrush( QBrush( Qt::black ) );
404 } else { 407 } else {
405 if ( !pe->erased() ) { 408 if ( !pe->erased() ) {
406 // Combine with background and double buffer 409 // Combine with background and double buffer
407 QPixmap pix( pe->rect().size() ); 410 QPixmap pix( pe->rect().size() );
408 QPainter p( &pix ); 411 QPainter p( &pix );
409 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 412 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
410 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 413 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
411 for ( int i = 0; i < numVButtons; i++ ) { 414 for ( int i = 0; i < numVButtons; i++ ) {
412 paintButton( &p, i ); 415 paintButton( &p, i );
413 } 416 }
414 QPainter p2( this ); 417 QPainter p2( this );
415 p2.drawPixmap( pe->rect().topLeft(), pix ); 418 p2.drawPixmap( pe->rect().topLeft(), pix );
416 } else { 419 } else {
417 QPainter p( this ); 420 QPainter p( this );
418 for ( int i = 0; i < numVButtons; i++ ) 421 for ( int i = 0; i < numVButtons; i++ )
419 paintButton( &p, i ); 422 paintButton( &p, i );
420 } 423 }
421 slider->repaint( TRUE ); 424 slider->repaint( TRUE );
422 } 425 }
423} 426}
424 427
425 428
426void VideoWidget::closeEvent( QCloseEvent* ) { 429void VideoWidget::closeEvent( QCloseEvent* ) {
427 mediaPlayerState->setList(); 430 mediaPlayerState->setList();
428} 431}
429 432
430 433
431 434
432void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 435void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
433 switch ( e->key() ) { 436 switch ( e->key() ) {
434////////////////////////////// Zaurus keys 437////////////////////////////// Zaurus keys
435 case Key_Home: 438 case Key_Home:
436 break; 439 break;
437 case Key_F9: //activity 440 case Key_F9: //activity
438 break; 441 break;
439 case Key_F10: //contacts 442 case Key_F10: //contacts
440// hide(); 443// hide();
441 break; 444 break;
442 case Key_F11: //menu 445 case Key_F11: //menu
443 break; 446 break;
444 case Key_F12: //home 447 case Key_F12: //home
445 break; 448 break;
446 case Key_F13: //mail 449 case Key_F13: //mail
447 break; 450 break;
448 case Key_Space: { 451 case Key_Space: {
449 if(mediaPlayerState->playing()) { 452 if(mediaPlayerState->playing()) {
450 mediaPlayerState->setPlaying(FALSE); 453 mediaPlayerState->setPlaying(FALSE);
451 } else { 454 } else {
452 mediaPlayerState->setPlaying(TRUE); 455 mediaPlayerState->setPlaying(TRUE);
453 } 456 }
454 } 457 }
455 break; 458 break;
456 case Key_Down: 459 case Key_Down:
457// toggleButton(6); 460// toggleButton(6);
458 emit lessClicked(); 461 emit lessClicked();
459 emit lessReleased(); 462 emit lessReleased();
460// toggleButton(6); 463// toggleButton(6);
461 break; 464 break;
462 case Key_Up: 465 case Key_Up:
463// toggleButton(5); 466// toggleButton(5);
464 emit moreClicked(); 467 emit moreClicked();
465 emit moreReleased(); 468 emit moreReleased();
466// toggleButton(5); 469// toggleButton(5);
467 break; 470 break;
468 case Key_Right: 471 case Key_Right:
469 mediaPlayerState->setNext(); 472 mediaPlayerState->setNext();
470 break; 473 break;
471 case Key_Left: 474 case Key_Left:
472 mediaPlayerState->setPrev(); 475 mediaPlayerState->setPrev();
473 break; 476 break;
474 case Key_Escape: 477 case Key_Escape:
475#if defined(QT_QWS_IPAQ) 478#if defined(QT_QWS_IPAQ)
476 if( mediaPlayerState->isPaused ) { 479 if( mediaPlayerState->isPaused ) {
477 setToggleButton( i, FALSE ); 480 setToggleButton( i, FALSE );
478 mediaPlayerState->setPaused( FALSE ); 481 mediaPlayerState->setPaused( FALSE );
479 } else if( !mediaPlayerState->isPaused ) { 482 } else if( !mediaPlayerState->isPaused ) {
480 setToggleButton( i, TRUE ); 483 setToggleButton( i, TRUE );
481 mediaPlayerState->setPaused( TRUE ); 484 mediaPlayerState->setPaused( TRUE );
482 } 485 }
483#endif 486#endif
484 break; 487 break;
485 488
486 }; 489 };
487} 490}
488 491
489XineVideoWidget* VideoWidget::vidWidget() { 492XineVideoWidget* VideoWidget::vidWidget() {
490 return videoFrame; 493 return videoFrame;
491} 494}
492 495
493 496
494void VideoWidget::setFullscreen ( bool b ) { 497void VideoWidget::setFullscreen ( bool b ) {
495 setToggleButton( VideoFullscreen, b ); 498 setToggleButton( VideoFullscreen, b );
496} 499}
497 500
498 501
499void VideoWidget::setPlaying( bool b) { 502void VideoWidget::setPlaying( bool b) {
500 setToggleButton( VideoPlay, b ); 503 setToggleButton( VideoPlay, b );
501} 504}
502 505