summaryrefslogtreecommitdiff
authordrw <drw>2005-06-15 19:44:04 (UTC)
committer drw <drw>2005-06-15 19:44:04 (UTC)
commit1cc97c3b70f59b90dc4bf032a14198dc8bd07f2e (patch) (unidiff)
treecb873e7e3f7330368b857d8fe69826d6a9e4e68a
parentdfad70bb3964d6f7142660ea4349d4af0349b46d (diff)
downloadopie-1cc97c3b70f59b90dc4bf032a14198dc8bd07f2e.zip
opie-1cc97c3b70f59b90dc4bf032a14198dc8bd07f2e.tar.gz
opie-1cc97c3b70f59b90dc4bf032a14198dc8bd07f2e.tar.bz2
Resource -> OResource and fix doc headers
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp8
-rw-r--r--core/multimedia/opieplayer/inputDialog.cpp9
-rw-r--r--core/multimedia/opieplayer/om3u.cpp43
-rw-r--r--core/multimedia/opieplayer/om3u.h44
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp19
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp9
6 files changed, 68 insertions, 64 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index d135647..2918097 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,529 +1,529 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "audiowidget.h" 20#include "audiowidget.h"
21#include "mediaplayerstate.h" 21#include "mediaplayerstate.h"
22 22
23/* OPIE */ 23/* OPIE */
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/resource.h>
26#include <qpe/config.h> 25#include <qpe/config.h>
27#include <opie2/odebug.h> 26#include <opie2/odebug.h>
27#include <opie2/oresource.h>
28 28
29/* QT */ 29/* QT */
30#include <qdir.h> 30#include <qdir.h>
31 31
32/* STD */ 32/* STD */
33#include <stdlib.h> 33#include <stdlib.h>
34#include <stdio.h> 34#include <stdio.h>
35 35
36extern MediaPlayerState *mediaPlayerState; 36extern MediaPlayerState *mediaPlayerState;
37 37
38 38
39static const int xo = -2; // movable x offset 39static const int xo = -2; // movable x offset
40static const int yo = 22; // movable y offset 40static const int yo = 22; // movable y offset
41 41
42using namespace Opie::Ui; 42using namespace Opie::Ui;
43struct MediaButton { 43struct MediaButton {
44 bool isToggle, isHeld, isDown; 44 bool isToggle, isHeld, isDown;
45}; 45};
46 46
47//Layout information for the audioButtons (and if it is a toggle button or not) 47//Layout information for the audioButtons (and if it is a toggle button or not)
48MediaButton audioButtons[] = { 48MediaButton audioButtons[] = {
49 { TRUE, FALSE, FALSE }, // play 49 { TRUE, FALSE, FALSE }, // play
50 { FALSE, FALSE, FALSE }, // stop 50 { FALSE, FALSE, FALSE }, // stop
51 { FALSE, FALSE, FALSE }, // next 51 { FALSE, FALSE, FALSE }, // next
52 { FALSE, FALSE, FALSE }, // previous 52 { FALSE, FALSE, FALSE }, // previous
53 { FALSE, FALSE, FALSE }, // volume up 53 { FALSE, FALSE, FALSE }, // volume up
54 { FALSE, FALSE, FALSE }, // volume down 54 { FALSE, FALSE, FALSE }, // volume down
55 { TRUE, FALSE, FALSE }, // repeat/loop 55 { TRUE, FALSE, FALSE }, // repeat/loop
56 { FALSE, FALSE, FALSE }, // playlist 56 { FALSE, FALSE, FALSE }, // playlist
57 { FALSE, FALSE, FALSE }, // forward 57 { FALSE, FALSE, FALSE }, // forward
58 { FALSE, FALSE, FALSE } // back 58 { FALSE, FALSE, FALSE } // back
59}; 59};
60 60
61const char *skin_mask_file_names[10] = { 61const char *skin_mask_file_names[10] = {
62 "play", "stop", "next", "prev", "up", 62 "play", "stop", "next", "prev", "up",
63 "down", "loop", "playlist", "forward", "back" 63 "down", "loop", "playlist", "forward", "back"
64}; 64};
65 65
66static void changeTextColor( QWidget *w ) { 66static void changeTextColor( QWidget *w ) {
67 QPalette p = w->palette(); 67 QPalette p = w->palette();
68 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 68 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
69 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 69 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
70 w->setPalette( p ); 70 w->setPalette( p );
71} 71}
72 72
73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
74 74
75AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 75AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) 76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
77{ 77{
78 setCaption( tr("OpiePlayer") ); 78 setCaption( tr("OpiePlayer") );
79 // odebug << "<<<<<audioWidget" << oendl; 79 // odebug << "<<<<<audioWidget" << oendl;
80 80
81 Config cfg("OpiePlayer"); 81 Config cfg("OpiePlayer");
82 cfg.setGroup("Options"); 82 cfg.setGroup("Options");
83 skin = cfg.readEntry("Skin","default"); 83 skin = cfg.readEntry("Skin","default");
84 //skin = "scaleTest"; 84 //skin = "scaleTest";
85// color of background, frame, degree of transparency 85// color of background, frame, degree of transparency
86 86
87// QString skinPath = "opieplayer/skins/" + skin; 87// QString skinPath = "opieplayer/skins/" + skin;
88 QString skinPath; 88 QString skinPath;
89 skinPath = "opieplayer2/skins/" + skin; 89 skinPath = "opieplayer2/skins/" + skin;
90 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) 90 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
91 skinPath = "opieplayer2/skins/default"; 91 skinPath = "opieplayer2/skins/default";
92 92
93 // odebug << "skin path " + skinPath << oendl; 93 // odebug << "skin path " + skinPath << oendl;
94 94
95 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 95 pixBg = new QPixmap( Opie::Core::OResource::loadPixmap( QString("%1/background").arg(skinPath) ) );
96 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 96 imgUp = new QImage( Opie::Core::OResource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
97 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 97 imgDn = new QImage( Opie::Core::OResource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
98 98
99 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 99 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
100 imgButtonMask->fill( 0 ); 100 imgButtonMask->fill( 0 );
101 101
102 for ( int i = 0; i < 10; i++ ) { 102 for ( int i = 0; i < 10; i++ ) {
103 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 103 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
104 masks[i] = new QBitmap( filename ); 104 masks[i] = new QBitmap( filename );
105 105
106 if ( !masks[i]->isNull() ) { 106 if ( !masks[i]->isNull() ) {
107 QImage imgMask = masks[i]->convertToImage(); 107 QImage imgMask = masks[i]->convertToImage();
108 uchar **dest = imgButtonMask->jumpTable(); 108 uchar **dest = imgButtonMask->jumpTable();
109 for ( int y = 0; y < imgUp->height(); y++ ) { 109 for ( int y = 0; y < imgUp->height(); y++ ) {
110 uchar *line = dest[y]; 110 uchar *line = dest[y];
111 for ( int x = 0; x < imgUp->width(); x++ ) 111 for ( int x = 0; x < imgUp->width(); x++ )
112 if ( !qRed( imgMask.pixel( x, y ) ) ) 112 if ( !qRed( imgMask.pixel( x, y ) ) )
113 line[x] = i + 1; 113 line[x] = i + 1;
114 } 114 }
115 } 115 }
116 116
117 } 117 }
118 118
119 for ( int i = 0; i < 11; i++ ) { 119 for ( int i = 0; i < 11; i++ ) {
120 buttonPixUp[i] = NULL; 120 buttonPixUp[i] = NULL;
121 buttonPixDown[i] = NULL; 121 buttonPixDown[i] = NULL;
122 } 122 }
123 123
124 QWidget *d = QApplication::desktop(); 124 QWidget *d = QApplication::desktop();
125 int width = d->width(); 125 int width = d->width();
126 int height = d->height(); 126 int height = d->height();
127 127
128 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { 128 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) {
129// odebug << "<<<<<<<< scale image >>>>>>>>>>>>" << oendl; 129// odebug << "<<<<<<<< scale image >>>>>>>>>>>>" << oendl;
130 QImage img; 130 QImage img;
131 img = pixBg->convertToImage(); 131 img = pixBg->convertToImage();
132 pixBg->convertFromImage( img.smoothScale( width, height)); 132 pixBg->convertFromImage( img.smoothScale( width, height));
133 } 133 }
134 setBackgroundPixmap( *pixBg); 134 setBackgroundPixmap( *pixBg);
135 135
136 songInfo.setFocusPolicy( QWidget::NoFocus ); 136 songInfo.setFocusPolicy( QWidget::NoFocus );
137 137
138// changeTextColor( &songInfo ); 138// changeTextColor( &songInfo );
139// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 139// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
140// songInfo.setFrameStyle( QFrame::NoFrame); 140// songInfo.setFrameStyle( QFrame::NoFrame);
141// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 141// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
142 //NoFrame 142 //NoFrame
143// songInfo.setForegroundColor(Qt::white); 143// songInfo.setForegroundColor(Qt::white);
144 144
145 slider.setFixedHeight( 20 ); 145 slider.setFixedHeight( 20 );
146 slider.setMinValue( 0 ); 146 slider.setMinValue( 0 );
147 slider.setMaxValue( 1 ); 147 slider.setMaxValue( 1 );
148 slider.setFocusPolicy( QWidget::NoFocus ); 148 slider.setFocusPolicy( QWidget::NoFocus );
149 149
150 slider.setBackgroundPixmap( *pixBg ); 150 slider.setBackgroundPixmap( *pixBg );
151 151
152 time.setFocusPolicy( QWidget::NoFocus ); 152 time.setFocusPolicy( QWidget::NoFocus );
153 time.setAlignment( Qt::AlignCenter ); 153 time.setAlignment( Qt::AlignCenter );
154 time.setFrame(FALSE); 154 time.setFrame(FALSE);
155 changeTextColor( &time ); 155 changeTextColor( &time );
156 156
157 resizeEvent( NULL ); 157 resizeEvent( NULL );
158 158
159 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 159 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
160 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 160 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
161 161
162 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 162 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
163 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 163 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
164 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 164 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
165// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 165// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
166 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 166 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
167 167
168 // Intialise state 168 // Intialise state
169 setLength( mediaPlayerState->length() ); 169 setLength( mediaPlayerState->length() );
170 setPosition( mediaPlayerState->position() ); 170 setPosition( mediaPlayerState->position() );
171 setLooping( mediaPlayerState->fullscreen() ); 171 setLooping( mediaPlayerState->fullscreen() );
172// setPaused( mediaPlayerState->paused() ); 172// setPaused( mediaPlayerState->paused() );
173 setPlaying( mediaPlayerState->playing() ); 173 setPlaying( mediaPlayerState->playing() );
174 this->setFocus(); 174 this->setFocus();
175 if(this->x() < 0 || this->y() < 0) 175 if(this->x() < 0 || this->y() < 0)
176 this->move(0,0); 176 this->move(0,0);
177} 177}
178 178
179 179
180AudioWidget::~AudioWidget() { 180AudioWidget::~AudioWidget() {
181 // setPlaying( false); 181 // setPlaying( false);
182 182
183 for ( int i = 0; i < 10; i++ ) { 183 for ( int i = 0; i < 10; i++ ) {
184 if(buttonPixUp[i]) delete buttonPixUp[i]; 184 if(buttonPixUp[i]) delete buttonPixUp[i];
185 if(buttonPixDown[i]) delete buttonPixDown[i]; 185 if(buttonPixDown[i]) delete buttonPixDown[i];
186 } 186 }
187 if(pixBg) delete pixBg; 187 if(pixBg) delete pixBg;
188 if(imgUp) delete imgUp; 188 if(imgUp) delete imgUp;
189 if(imgDn) delete imgDn; 189 if(imgDn) delete imgDn;
190 if(imgButtonMask) delete imgButtonMask; 190 if(imgButtonMask) delete imgButtonMask;
191 for ( int i = 0; i < 10; i++ ) { 191 for ( int i = 0; i < 10; i++ ) {
192 if(masks[i]) delete masks[i]; 192 if(masks[i]) delete masks[i];
193 } 193 }
194} 194}
195 195
196 196
197QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 197QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
198 QPixmap pix( img.width(), img.height() ); 198 QPixmap pix( img.width(), img.height() );
199 QPainter p( &pix ); 199 QPainter p( &pix );
200 p.drawTiledPixmap( pix.rect(), bg, offset ); 200 p.drawTiledPixmap( pix.rect(), bg, offset );
201 p.drawImage( 0, 0, img ); 201 p.drawImage( 0, 0, img );
202 return new QPixmap( pix ); 202 return new QPixmap( pix );
203} 203}
204 204
205 205
206QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 206QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
207{ 207{
208 QPixmap *pixmap = new QPixmap( pix ); 208 QPixmap *pixmap = new QPixmap( pix );
209 pixmap->setMask( mask ); 209 pixmap->setMask( mask );
210 return pixmap; 210 return pixmap;
211} 211}
212 212
213 213
214 214
215void AudioWidget::resizeEvent( QResizeEvent * ) { 215void AudioWidget::resizeEvent( QResizeEvent * ) {
216 int h = height(); 216 int h = height();
217 int w = width(); 217 int w = width();
218 218
219 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 219 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
220 slider.setFixedWidth( w - 110 ); 220 slider.setFixedWidth( w - 110 );
221 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 221 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
222 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 222 slider.setBackgroundOrigin( QWidget::ParentOrigin );
223 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 223 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
224 224
225 xoff = ( w - imgUp->width() ) / 2; 225 xoff = ( w - imgUp->width() ) / 2;
226 yoff = (( h - imgUp->height() ) / 2) - 10; 226 yoff = (( h - imgUp->height() ) / 2) - 10;
227 QPoint p( xoff, yoff ); 227 QPoint p( xoff, yoff );
228 228
229 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 229 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
230 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 230 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
231 231
232 for ( int i = 0; i < 10; i++ ) { 232 for ( int i = 0; i < 10; i++ ) {
233 if ( !masks[i]->isNull() ) { 233 if ( !masks[i]->isNull() ) {
234 delete buttonPixUp[i]; 234 delete buttonPixUp[i];
235 delete buttonPixDown[i]; 235 delete buttonPixDown[i];
236 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 236 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
237 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 237 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
238 } 238 }
239 } 239 }
240 240
241 delete pixUp; 241 delete pixUp;
242 delete pixDn; 242 delete pixDn;
243} 243}
244 244
245 245
246static bool audioSliderBeingMoved = FALSE; 246static bool audioSliderBeingMoved = FALSE;
247 247
248void AudioWidget::sliderPressed() { 248void AudioWidget::sliderPressed() {
249 audioSliderBeingMoved = TRUE; 249 audioSliderBeingMoved = TRUE;
250} 250}
251 251
252 252
253void AudioWidget::sliderReleased() { 253void AudioWidget::sliderReleased() {
254 audioSliderBeingMoved = FALSE; 254 audioSliderBeingMoved = FALSE;
255 if ( slider.width() == 0 ) 255 if ( slider.width() == 0 )
256 return; 256 return;
257 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 257 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
258 mediaPlayerState->setPosition( val ); 258 mediaPlayerState->setPosition( val );
259} 259}
260 260
261 261
262void AudioWidget::setPosition( long i ) { 262void AudioWidget::setPosition( long i ) {
263// odebug << "set position " << i << "" << oendl; 263// odebug << "set position " << i << "" << oendl;
264 long length = mediaPlayerState->length(); 264 long length = mediaPlayerState->length();
265 updateSlider( i, length ); 265 updateSlider( i, length );
266} 266}
267 267
268 268
269void AudioWidget::setLength( long max ) { 269void AudioWidget::setLength( long max ) {
270 updateSlider( mediaPlayerState->position(), max ); 270 updateSlider( mediaPlayerState->position(), max );
271} 271}
272 272
273 273
274void AudioWidget::setView( char view ) { 274void AudioWidget::setView( char view ) {
275 275
276 if (mediaPlayerState->isStreaming) { 276 if (mediaPlayerState->isStreaming) {
277 if( !slider.isHidden()) slider.hide(); 277 if( !slider.isHidden()) slider.hide();
278 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 278 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
279 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 279 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
280 } else { 280 } else {
281// this stops the slider from being moved, thus 281// this stops the slider from being moved, thus
282 // does not stop stream when it reaches the end 282 // does not stop stream when it reaches the end
283 slider.show(); 283 slider.show();
284 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 284 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
285 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 285 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
286 } 286 }
287 287
288 if ( view == 'a' ) { 288 if ( view == 'a' ) {
289 startTimer( 150 ); 289 startTimer( 150 );
290// show(); 290// show();
291 QPEApplication::showWidget( this ); 291 QPEApplication::showWidget( this );
292 } else { 292 } else {
293 killTimers(); 293 killTimers();
294 hide(); 294 hide();
295 } 295 }
296 296
297} 297}
298 298
299 299
300static QString timeAsString( long length ) { 300static QString timeAsString( long length ) {
301 length /= 44100; 301 length /= 44100;
302 int minutes = length / 60; 302 int minutes = length / 60;
303 int seconds = length % 60; 303 int seconds = length % 60;
304 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 304 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
305} 305}
306 306
307void AudioWidget::updateSlider( long i, long max ) { 307void AudioWidget::updateSlider( long i, long max ) {
308this->setFocus(); 308this->setFocus();
309 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 309 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
310 310
311 if ( max == 0 ) 311 if ( max == 0 )
312 return; 312 return;
313 // Will flicker too much if we don't do this 313 // Will flicker too much if we don't do this
314 // Scale to something reasonable 314 // Scale to something reasonable
315 int width = slider.width(); 315 int width = slider.width();
316 int val = int((double)i * width / max); 316 int val = int((double)i * width / max);
317 if ( !audioSliderBeingMoved ) { 317 if ( !audioSliderBeingMoved ) {
318 if ( slider.value() != val ) 318 if ( slider.value() != val )
319 slider.setValue( val ); 319 slider.setValue( val );
320 if ( slider.maxValue() != width ) 320 if ( slider.maxValue() != width )
321 slider.setMaxValue( width ); 321 slider.setMaxValue( width );
322 } 322 }
323} 323}
324 324
325 325
326void AudioWidget::setToggleButton( int i, bool down ) { 326void AudioWidget::setToggleButton( int i, bool down ) {
327 if ( down != audioButtons[i].isDown ) 327 if ( down != audioButtons[i].isDown )
328 toggleButton( i ); 328 toggleButton( i );
329} 329}
330 330
331 331
332void AudioWidget::toggleButton( int i ) { 332void AudioWidget::toggleButton( int i ) {
333 audioButtons[i].isDown = !audioButtons[i].isDown; 333 audioButtons[i].isDown = !audioButtons[i].isDown;
334 QPainter p(this); 334 QPainter p(this);
335 paintButton ( &p, i ); 335 paintButton ( &p, i );
336} 336}
337 337
338 338
339void AudioWidget::paintButton( QPainter *p, int i ) { 339void AudioWidget::paintButton( QPainter *p, int i ) {
340 if ( audioButtons[i].isDown ) 340 if ( audioButtons[i].isDown )
341 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 341 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
342 else 342 else
343 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 343 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
344} 344}
345 345
346 346
347void AudioWidget::timerEvent( QTimerEvent * ) { 347void AudioWidget::timerEvent( QTimerEvent * ) {
348/* 348/*
349 int x = audioButtons[AudioPlay].xPos; 349 int x = audioButtons[AudioPlay].xPos;
350 int y = audioButtons[AudioPlay].yPos; 350 int y = audioButtons[AudioPlay].yPos;
351 QPainter p( this ); 351 QPainter p( this );
352 // Optimize to only draw the little bit of the changing images which is different 352 // Optimize to only draw the little bit of the changing images which is different
353 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); 353 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
354 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); 354 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
355*/ 355*/
356/* 356/*
357 static int frame = 0; 357 static int frame = 0;
358 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 358 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
359 frame = frame >= 7 ? 0 : frame + 1; 359 frame = frame >= 7 ? 0 : frame + 1;
360 } 360 }
361 */ 361 */
362} 362}
363 363
364 364
365void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 365void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
366 for ( int i = 0; i < numButtons; i++ ) { 366 for ( int i = 0; i < numButtons; i++ ) {
367 if ( event->state() == QMouseEvent::LeftButton ) { 367 if ( event->state() == QMouseEvent::LeftButton ) {
368 368
369 // The test to see if the mouse click is inside the button or not 369 // The test to see if the mouse click is inside the button or not
370 int x = event->pos().x() - xoff; 370 int x = event->pos().x() - xoff;
371 int y = event->pos().y() - yoff; 371 int y = event->pos().y() - yoff;
372 372
373 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 373 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
374 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 374 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
375 375
376// if ( isOnButton && i == AudioVolumeUp ) 376// if ( isOnButton && i == AudioVolumeUp )
377// odebug << "on up" << oendl; 377// odebug << "on up" << oendl;
378 378
379 if ( isOnButton && !audioButtons[i].isHeld ) { 379 if ( isOnButton && !audioButtons[i].isHeld ) {
380 audioButtons[i].isHeld = TRUE; 380 audioButtons[i].isHeld = TRUE;
381 toggleButton(i); 381 toggleButton(i);
382 switch (i) { 382 switch (i) {
383 case AudioVolumeUp: 383 case AudioVolumeUp:
384 // odebug << "more clicked" << oendl; 384 // odebug << "more clicked" << oendl;
385 emit moreClicked(); 385 emit moreClicked();
386 return; 386 return;
387 case AudioVolumeDown: 387 case AudioVolumeDown:
388 // odebug << "less clicked" << oendl; 388 // odebug << "less clicked" << oendl;
389 emit lessClicked(); 389 emit lessClicked();
390 return; 390 return;
391 case AudioForward: 391 case AudioForward:
392 emit forwardClicked(); 392 emit forwardClicked();
393 return; 393 return;
394 case AudioBack: 394 case AudioBack:
395 emit backClicked(); 395 emit backClicked();
396 return; 396 return;
397 } 397 }
398 } else if ( !isOnButton && audioButtons[i].isHeld ) { 398 } else if ( !isOnButton && audioButtons[i].isHeld ) {
399 audioButtons[i].isHeld = FALSE; 399 audioButtons[i].isHeld = FALSE;
400 toggleButton(i); 400 toggleButton(i);
401 } 401 }
402 } else { 402 } else {
403 if ( audioButtons[i].isHeld ) { 403 if ( audioButtons[i].isHeld ) {
404 audioButtons[i].isHeld = FALSE; 404 audioButtons[i].isHeld = FALSE;
405 if ( !audioButtons[i].isToggle ) 405 if ( !audioButtons[i].isToggle )
406 setToggleButton( i, FALSE ); 406 setToggleButton( i, FALSE );
407 switch (i) { 407 switch (i) {
408 case AudioPlay: 408 case AudioPlay:
409 if( mediaPlayerState->isPaused ) { 409 if( mediaPlayerState->isPaused ) {
410 mediaPlayerState->setPaused( FALSE ); 410 mediaPlayerState->setPaused( FALSE );
411 return; 411 return;
412 } else if( !mediaPlayerState->isPaused ) { 412 } else if( !mediaPlayerState->isPaused ) {
413 mediaPlayerState->setPaused( TRUE ); 413 mediaPlayerState->setPaused( TRUE );
414 return; 414 return;
415 } 415 }
416// case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 416// case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
417 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 417 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
418// case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 418// case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
419 case AudioNext: mediaPlayerState->setNext(); return; 419 case AudioNext: mediaPlayerState->setNext(); return;
420 case AudioPrevious: mediaPlayerState->setPrev(); return; 420 case AudioPrevious: mediaPlayerState->setPrev(); return;
421 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 421 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
422 case AudioVolumeUp: emit moreReleased(); return; 422 case AudioVolumeUp: emit moreReleased(); return;
423 case AudioVolumeDown: emit lessReleased(); return; 423 case AudioVolumeDown: emit lessReleased(); return;
424 case AudioPlayList: mediaPlayerState->setList(); return; 424 case AudioPlayList: mediaPlayerState->setList(); return;
425 } 425 }
426 } 426 }
427 } 427 }
428 } 428 }
429} 429}
430 430
431 431
432 432
433void AudioWidget::mousePressEvent( QMouseEvent *event ) { 433void AudioWidget::mousePressEvent( QMouseEvent *event ) {
434 mouseMoveEvent( event ); 434 mouseMoveEvent( event );
435} 435}
436 436
437 437
438void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 438void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
439 mouseMoveEvent( event ); 439 mouseMoveEvent( event );
440} 440}
441 441
442 442
443void AudioWidget::showEvent( QShowEvent* ) { 443void AudioWidget::showEvent( QShowEvent* ) {
444 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 444 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
445 mouseMoveEvent( &event ); 445 mouseMoveEvent( &event );
446} 446}
447 447
448 448
449void AudioWidget::closeEvent( QCloseEvent* ) { 449void AudioWidget::closeEvent( QCloseEvent* ) {
450 mediaPlayerState->setList(); 450 mediaPlayerState->setList();
451} 451}
452 452
453 453
454void AudioWidget::paintEvent( QPaintEvent * pe) { 454void AudioWidget::paintEvent( QPaintEvent * pe) {
455 if ( !pe->erased() ) { 455 if ( !pe->erased() ) {
456 // Combine with background and double buffer 456 // Combine with background and double buffer
457 QPixmap pix( pe->rect().size() ); 457 QPixmap pix( pe->rect().size() );
458 QPainter p( &pix ); 458 QPainter p( &pix );
459 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 459 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
460 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 460 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
461 for ( int i = 0; i < numButtons; i++ ) 461 for ( int i = 0; i < numButtons; i++ )
462 paintButton( &p, i ); 462 paintButton( &p, i );
463 QPainter p2( this ); 463 QPainter p2( this );
464 p2.drawPixmap( pe->rect().topLeft(), pix ); 464 p2.drawPixmap( pe->rect().topLeft(), pix );
465 } else { 465 } else {
466 QPainter p( this ); 466 QPainter p( this );
467 for ( int i = 0; i < numButtons; i++ ) 467 for ( int i = 0; i < numButtons; i++ )
468 paintButton( &p, i ); 468 paintButton( &p, i );
469 } 469 }
470} 470}
471 471
472void AudioWidget::keyReleaseEvent( QKeyEvent *e) 472void AudioWidget::keyReleaseEvent( QKeyEvent *e)
473{ 473{
474 switch ( e->key() ) { 474 switch ( e->key() ) {
475////////////////////////////// Zaurus keys 475////////////////////////////// Zaurus keys
476 case Key_Home: 476 case Key_Home:
477 break; 477 break;
478 case Key_F9: //activity 478 case Key_F9: //activity
479 hide(); 479 hide();
480// odebug << "Audio F9" << oendl; 480// odebug << "Audio F9" << oendl;
481 break; 481 break;
482 case Key_F10: //contacts 482 case Key_F10: //contacts
483 break; 483 break;
484 case Key_F11: //menu 484 case Key_F11: //menu
485 break; 485 break;
486 case Key_F12: //home 486 case Key_F12: //home
487 break; 487 break;
488 case Key_F13: //mail 488 case Key_F13: //mail
489 break; 489 break;
490 case Key_Space: { 490 case Key_Space: {
491 491
492 if(mediaPlayerState->playing()) { 492 if(mediaPlayerState->playing()) {
493// toggleButton(1); 493// toggleButton(1);
494 mediaPlayerState->setPlaying(FALSE); 494 mediaPlayerState->setPlaying(FALSE);
495// toggleButton(1); 495// toggleButton(1);
496 } else { 496 } else {
497// toggleButton(0); 497// toggleButton(0);
498 mediaPlayerState->setPlaying(TRUE); 498 mediaPlayerState->setPlaying(TRUE);
499// toggleButton(0); 499// toggleButton(0);
500 } 500 }
501 } 501 }
502 break; 502 break;
503 case Key_Down: //volume 503 case Key_Down: //volume
504// toggleButton(6); 504// toggleButton(6);
505 emit lessClicked(); 505 emit lessClicked();
506 emit lessReleased(); 506 emit lessReleased();
507// toggleButton(6); 507// toggleButton(6);
508 break; 508 break;
509 case Key_Up: //volume 509 case Key_Up: //volume
510// toggleButton(5); 510// toggleButton(5);
511 emit moreClicked(); 511 emit moreClicked();
512 emit moreReleased(); 512 emit moreReleased();
513// toggleButton(5); 513// toggleButton(5);
514 break; 514 break;
515 case Key_Right: //next in playlist 515 case Key_Right: //next in playlist
516// toggleButton(3); 516// toggleButton(3);
517 mediaPlayerState->setNext(); 517 mediaPlayerState->setNext();
518// toggleButton(3); 518// toggleButton(3);
519 break; 519 break;
520 case Key_Left: // previous in playlist 520 case Key_Left: // previous in playlist
521// toggleButton(4); 521// toggleButton(4);
522 mediaPlayerState->setPrev(); 522 mediaPlayerState->setPrev();
523// toggleButton(4); 523// toggleButton(4);
524 break; 524 break;
525 case Key_Escape: 525 case Key_Escape:
526 break; 526 break;
527 527
528 }; 528 };
529} 529}
diff --git a/core/multimedia/opieplayer/inputDialog.cpp b/core/multimedia/opieplayer/inputDialog.cpp
index 44a1cdd..b76004e 100644
--- a/core/multimedia/opieplayer/inputDialog.cpp
+++ b/core/multimedia/opieplayer/inputDialog.cpp
@@ -1,60 +1,61 @@
1#include "inputDialog.h" 1#include "inputDialog.h"
2 2
3#include <qpe/resource.h>
4
5#include <opie2/ofiledialog.h> 3#include <opie2/ofiledialog.h>
4#include <opie2/oresource.h>
5
6#include <qpe/applnk.h>
6 7
7#include <qlineedit.h> 8#include <qlineedit.h>
8#include <qpushbutton.h> 9#include <qpushbutton.h>
9 10
10using namespace Opie::Ui; 11using namespace Opie::Ui;
11InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 12InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
12 : QDialog( parent, name, modal, fl ) { 13 : QDialog( parent, name, modal, fl ) {
13 if ( !name ) { 14 if ( !name ) {
14 setName( "InputDialog" ); 15 setName( "InputDialog" );
15 } 16 }
16 resize( 234, 115); 17 resize( 234, 115);
17 setMaximumSize( QSize( 240, 40)); 18 setMaximumSize( QSize( 240, 40));
18 setCaption( tr( name ) ); 19 setCaption( tr( name ) );
19 20
20 QPushButton *browserButton; 21 QPushButton *browserButton;
21 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 22 browserButton = new QPushButton( Opie::Core::OResource::loadPixmap("fileopen", Opie::Core::OResource::SmallIcon),"",this,"BrowseButton");
22 browserButton->setGeometry( QRect( 205, 10, 22, 22)); 23 browserButton->setGeometry( QRect( 205, 10, AppLnk::smallIconSize(), AppLnk::smallIconSize()));
23 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 24 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
24 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 25 LineEdit1 = new QLineEdit( this, "LineEdit1" );
25 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 26 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
26 LineEdit1->setFocus(); 27 LineEdit1->setFocus();
27} 28}
28/* 29/*
29 * return the current text(input) 30 * return the current text(input)
30 */ 31 */
31QString InputDialog::text() const { 32QString InputDialog::text() const {
32 return LineEdit1->text(); 33 return LineEdit1->text();
33} 34}
34/* 35/*
35 * Destroys the object and frees any allocated resources 36 * Destroys the object and frees any allocated resources
36 */ 37 */
37InputDialog::~InputDialog() { 38InputDialog::~InputDialog() {
38} 39}
39 40
40void InputDialog::browse() { 41void InputDialog::browse() {
41 42
42 MimeTypes types; 43 MimeTypes types;
43 QStringList audio, video, all; 44 QStringList audio, video, all;
44 audio << "audio/*"; 45 audio << "audio/*";
45 audio << "playlist/plain"; 46 audio << "playlist/plain";
46 audio << "audio/x-mpegurl"; 47 audio << "audio/x-mpegurl";
47 48
48 video << "video/*"; 49 video << "video/*";
49 video << "playlist/plain"; 50 video << "playlist/plain";
50 51
51 all += audio; 52 all += audio;
52 all += video; 53 all += video;
53 types.insert("All Media Files", all ); 54 types.insert("All Media Files", all );
54 types.insert("Audio", audio ); 55 types.insert("Audio", audio );
55 types.insert("Video", video ); 56 types.insert("Video", video );
56 57
57 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 58 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
58 LineEdit1->setText(str); 59 LineEdit1->setText(str);
59} 60}
60 61
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp
index 7149a8e..48aa47e 100644
--- a/core/multimedia/opieplayer/om3u.cpp
+++ b/core/multimedia/opieplayer/om3u.cpp
@@ -1,164 +1,163 @@
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 L. Potter <ljp@llornkcor.com> 4 Copyright (C) 2002 L. Potter <ljp@llornkcor.com>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29
30*/ 29*/
31 30
32#include "om3u.h" 31#include "om3u.h"
33 32
34/* OPIE */ 33/* OPIE */
35#include <opie2/odebug.h> 34#include <opie2/odebug.h>
36 35
37 36
38static inline QString fullBaseName ( const QFileInfo &fi ) 37static inline QString fullBaseName ( const QFileInfo &fi )
39{ 38{
40 QString str = fi. fileName ( ); 39 QString str = fi. fileName ( );
41 return str. left ( str. findRev ( '.' )); 40 return str. left ( str. findRev ( '.' ));
42} 41}
43 42
44 43
45//extern PlayListWidget *playList; 44//extern PlayListWidget *playList;
46 45
47Om3u::Om3u( const QString &filePath, int mode) 46Om3u::Om3u( const QString &filePath, int mode)
48 : QStringList (){ 47 : QStringList (){
49//odebug << "<<<<<<<new m3u "+filePath << oendl; 48//odebug << "<<<<<<<new m3u "+filePath << oendl;
50 f.setName(filePath); 49 f.setName(filePath);
51 f.open(mode); 50 f.open(mode);
52} 51}
53 52
54Om3u::~Om3u(){} 53Om3u::~Om3u(){}
55 54
56void Om3u::readM3u() { 55void Om3u::readM3u() {
57// odebug << "<<<<<<reading m3u "+f.name() << oendl; 56// odebug << "<<<<<<reading m3u "+f.name() << oendl;
58 QTextStream t(&f); 57 QTextStream t(&f);
59 t.setEncoding(QTextStream::UnicodeUTF8); 58 t.setEncoding(QTextStream::UnicodeUTF8);
60 QString s; 59 QString s;
61 while ( !t.atEnd() ) { 60 while ( !t.atEnd() ) {
62 s=t.readLine(); 61 s=t.readLine();
63 // odebug << s << oendl; 62 // odebug << s << oendl;
64 if( s.find( "#", 0, TRUE) == -1 ) { 63 if( s.find( "#", 0, TRUE) == -1 ) {
65 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 64 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
66 s = s.right( s.length() -2 ); 65 s = s.right( s.length() -2 );
67 QFileInfo f( s ); 66 QFileInfo f( s );
68 QString name = fullBaseName ( f ); 67 QString name = fullBaseName ( f );
69 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 68 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
70 s=s.replace( QRegExp( "\\" ), "/" ); 69 s=s.replace( QRegExp( "\\" ), "/" );
71 append(s); 70 append(s);
72 // odebug << s << oendl; 71 // odebug << s << oendl;
73 } else { // is url 72 } else { // is url
74 s.replace( QRegExp( "%20" )," " ); 73 s.replace( QRegExp( "%20" )," " );
75 QString name; 74 QString name;
76 // if( name.left( 4 ) == "http" ) { 75 // if( name.left( 4 ) == "http" ) {
77 // name = s.right( s.length() - 7 ); 76 // name = s.right( s.length() - 7 );
78 // } else { 77 // } else {
79 name = s; 78 name = s;
80 // } 79 // }
81 append(name); 80 append(name);
82 // odebug << name << oendl; 81 // odebug << name << oendl;
83 } 82 }
84 } 83 }
85 } 84 }
86} 85}
87 86
88void Om3u::readPls() { //it's a pls file 87void Om3u::readPls() { //it's a pls file
89 QTextStream t( &f ); 88 QTextStream t( &f );
90 t.setEncoding(QTextStream::UnicodeUTF8); 89 t.setEncoding(QTextStream::UnicodeUTF8);
91 QString s; 90 QString s;
92 while ( !t.atEnd() ) { 91 while ( !t.atEnd() ) {
93 s = t.readLine(); 92 s = t.readLine();
94 if( s.left(4) == "File" ) { 93 if( s.left(4) == "File" ) {
95 s = s.right( s.length() - 6 ); 94 s = s.right( s.length() - 6 );
96 s.replace( QRegExp( "%20" )," "); 95 s.replace( QRegExp( "%20" )," ");
97// odebug << "adding " + s + " to playlist" << oendl; 96// odebug << "adding " + s + " to playlist" << oendl;
98 // numberofentries=2 97 // numberofentries=2
99 // File1=http 98 // File1=http
100 // Title 99 // Title
101 // Length 100 // Length
102 // Version 101 // Version
103 // File2=http 102 // File2=http
104 s = s.replace( QRegExp( "\\" ), "/" ); 103 s = s.replace( QRegExp( "\\" ), "/" );
105 QFileInfo f( s ); 104 QFileInfo f( s );
106 QString name = fullBaseName ( f ); 105 QString name = fullBaseName ( f );
107 if( name.left( 4 ) == "http" ) { 106 if( name.left( 4 ) == "http" ) {
108 name = s.right( s.length() - 7); 107 name = s.right( s.length() - 7);
109 } else { 108 } else {
110 name = s; 109 name = s;
111 } 110 }
112 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 111 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
113 if( s.at( s.length() - 4) == '.') // if this is probably a file 112 if( s.at( s.length() - 4) == '.') // if this is probably a file
114 append(s); 113 append(s);
115 else { //if its a url 114 else { //if its a url
116 if( name.right( 1 ).find( '/' ) == -1) { 115 if( name.right( 1 ).find( '/' ) == -1) {
117 s += "/"; 116 s += "/";
118 } 117 }
119 append(s); 118 append(s);
120 } 119 }
121 } 120 }
122 } 121 }
123} 122}
124 123
125void Om3u::write() { //writes list to m3u file 124void Om3u::write() { //writes list to m3u file
126 QString list; 125 QString list;
127 QTextStream t(&f); 126 QTextStream t(&f);
128 t.setEncoding(QTextStream::UnicodeUTF8); 127 t.setEncoding(QTextStream::UnicodeUTF8);
129 if(count()>0) { 128 if(count()>0) {
130 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 129 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
131 // odebug << *it << oendl; 130 // odebug << *it << oendl;
132 t << *it << "\n"; 131 t << *it << "\n";
133 } 132 }
134 } 133 }
135// f.close(); 134// f.close();
136} 135}
137 136
138void Om3u::add(const QString &filePath) { //adds to m3u file 137void Om3u::add(const QString &filePath) { //adds to m3u file
139 append(filePath); 138 append(filePath);
140} 139}
141 140
142void Om3u::remove(const QString &filePath) { //removes from m3u list 141void Om3u::remove(const QString &filePath) { //removes from m3u list
143 QString list, currentFile; 142 QString list, currentFile;
144 if(count()>0) { 143 if(count()>0) {
145 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 144 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
146 currentFile=*it; 145 currentFile=*it;
147 // odebug << *it << oendl; 146 // odebug << *it << oendl;
148 147
149 if( filePath != currentFile) 148 if( filePath != currentFile)
150 list += currentFile+"\n"; 149 list += currentFile+"\n";
151 } 150 }
152 f.writeBlock( list, list.length() ); 151 f.writeBlock( list, list.length() );
153 } 152 }
154} 153}
155 154
156void Om3u::deleteFile(const QString &) {//deletes m3u file 155void Om3u::deleteFile(const QString &) {//deletes m3u file
157 f.close(); 156 f.close();
158 f.remove(); 157 f.remove();
159 158
160} 159}
161 160
162void Om3u::close() { //closes m3u file 161void Om3u::close() { //closes m3u file
163 f.close(); 162 f.close();
164} 163}
diff --git a/core/multimedia/opieplayer/om3u.h b/core/multimedia/opieplayer/om3u.h
index 9c7cf9a..b944d6f 100644
--- a/core/multimedia/opieplayer/om3u.h
+++ b/core/multimedia/opieplayer/om3u.h
@@ -1,79 +1,77 @@
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 L. Potter <ljp@llornkcor.com> 4 Copyright (C) 2002 L. Potter <ljp@llornkcor.com>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29
30*/ 29*/
31 30
32#ifndef OM3U_H 31#ifndef OM3U_H
33#define OM3U_H 32#define OM3U_H
34 33
35#include "playlistwidget.h" 34#include "playlistwidget.h"
36 35
37#include <qpe/applnk.h> 36#include <qpe/applnk.h>
38#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
39#include <qpe/storage.h> 38#include <qpe/storage.h>
40#include <qpe/mimetype.h> 39#include <qpe/mimetype.h>
41#include <qpe/global.h> 40#include <qpe/global.h>
42#include <qpe/resource.h>
43 41
44#include <qdir.h> 42#include <qdir.h>
45#include <qregexp.h> 43#include <qregexp.h>
46#include <qstring.h> 44#include <qstring.h>
47#include <qtextstream.h> 45#include <qtextstream.h>
48#include <qstringlist.h> 46#include <qstringlist.h>
49#include <qcstring.h> 47#include <qcstring.h>
50#include <qfile.h> 48#include <qfile.h>
51 49
52 50
53class Om3u : public QStringList { 51class Om3u : public QStringList {
54// Q_OBJECT 52// Q_OBJECT
55public: 53public:
56 Om3u( const QString &filePath, int mode); 54 Om3u( const QString &filePath, int mode);
57 ~Om3u(); 55 ~Om3u();
58 void readM3u(); 56 void readM3u();
59 void readPls(); 57 void readPls();
60 void write(); 58 void write();
61 void add(const QString &); 59 void add(const QString &);
62 void remove(const QString &); 60 void remove(const QString &);
63 void deleteFile(const QString &); 61 void deleteFile(const QString &);
64 void close(); 62 void close();
65 63
66public slots: 64public slots:
67 65
68protected: 66protected:
69 67
70private: 68private:
71 QFile f; 69 QFile f;
72private slots: 70private slots:
73 71
74 72
75}; 73};
76 74
77#endif// M3U_H 75#endif// M3U_H
78 76
79 77
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index db2bf1b..c0a0029 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1459 +1,1464 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22 22
23#include "playlistselection.h" 23#include "playlistselection.h"
24#include "playlistwidget.h" 24#include "playlistwidget.h"
25#include "mediaplayerstate.h" 25#include "mediaplayerstate.h"
26#include "inputDialog.h" 26#include "inputDialog.h"
27#include "audiowidget.h" 27#include "audiowidget.h"
28#include "videowidget.h" 28#include "videowidget.h"
29 29
30/* OPIE */ 30/* OPIE */
31#include <qpe/qpeapplication.h>
31#include <qpe/qpemenubar.h> 32#include <qpe/qpemenubar.h>
32#include <qpe/lnkproperties.h> 33#include <qpe/lnkproperties.h>
33#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/oresource.h>
34 36
35/* QT */ 37/* QT */
36#include <qtoolbar.h> 38#include <qtoolbar.h>
37#include <qaction.h> 39#include <qaction.h>
38#include <qlayout.h> 40#include <qlayout.h>
39#include <qmessagebox.h> 41#include <qmessagebox.h>
40//#include <qtimer.h> 42//#include <qtimer.h>
41 43
42/* STD */ 44/* STD */
43#include <stdlib.h> 45#include <stdlib.h>
44 46
45#include <unistd.h> 47#include <unistd.h>
46#include <sys/file.h> 48#include <sys/file.h>
47#include <sys/ioctl.h> 49#include <sys/ioctl.h>
48#include <sys/soundcard.h> 50#include <sys/soundcard.h>
49 51
50// for setBacklight() 52// for setBacklight()
51#include <linux/fb.h> 53#include <linux/fb.h>
52#include <sys/types.h> 54#include <sys/types.h>
53#include <sys/stat.h> 55#include <sys/stat.h>
54#include <stdlib.h> 56#include <stdlib.h>
55 57
56#define BUTTONS_ON_TOOLBAR 58#define BUTTONS_ON_TOOLBAR
57#define SIDE_BUTTONS 59#define SIDE_BUTTONS
58#define CAN_SAVE_LOAD_PLAYLISTS 60#define CAN_SAVE_LOAD_PLAYLISTS
59 61
60extern AudioWidget *audioUI; 62extern AudioWidget *audioUI;
61extern VideoWidget *videoUI; 63extern VideoWidget *videoUI;
62extern MediaPlayerState *mediaPlayerState; 64extern MediaPlayerState *mediaPlayerState;
63 65
64static inline QString fullBaseName ( const QFileInfo &fi ) 66static inline QString fullBaseName ( const QFileInfo &fi )
65{ 67{
66 QString str = fi. fileName ( ); 68 QString str = fi. fileName ( );
67 return str. left ( str. findRev ( '.' )); 69 return str. left ( str. findRev ( '.' ));
68} 70}
69 71
70 72
71QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; 73QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod";
72// class myFileSelector { 74// class myFileSelector {
73 75
74// }; 76// };
75class PlayListWidgetPrivate { 77class PlayListWidgetPrivate {
76public: 78public:
77 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 79 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
78 QFrame *playListFrame; 80 QFrame *playListFrame;
79 FileSelector *files; 81 FileSelector *files;
80 PlayListSelection *selectedFiles; 82 PlayListSelection *selectedFiles;
81 bool setDocumentUsed; 83 bool setDocumentUsed;
82 DocLnk *current; 84 DocLnk *current;
83}; 85};
84 86
85 87
86class ToolButton : public QToolButton { 88class ToolButton : public QToolButton {
87public: 89public:
88 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 90 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
89 : QToolButton( parent, name ) { 91 : QToolButton( parent, name ) {
90 setTextLabel( name ); 92 setTextLabel( name );
91 setPixmap( Resource::loadPixmap( icon ) ); 93 setPixmap( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) );
92 setAutoRaise( TRUE ); 94 setAutoRaise( TRUE );
95 setUsesBigPixmap( qApp->desktop()->size().width() > 330 );
93 setFocusPolicy( QWidget::NoFocus ); 96 setFocusPolicy( QWidget::NoFocus );
94 setToggleButton( t ); 97 setToggleButton( t );
95 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 98 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
96 QPEMenuToolFocusManager::manager()->addWidget( this ); 99 QPEMenuToolFocusManager::manager()->addWidget( this );
97 } 100 }
98}; 101};
99 102
100 103
101class MenuItem : public QAction { 104class MenuItem : public QAction {
102public: 105public:
103 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 106 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
104 : QAction( text, QString::null, 0, 0 ) { 107 : QAction( text, QString::null, 0, 0 ) {
105 connect( this, SIGNAL( activated() ), handler, slot ); 108 connect( this, SIGNAL( activated() ), handler, slot );
106 addTo( parent ); 109 addTo( parent );
107 } 110 }
108}; 111};
109 112
110 113
111PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 114PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
112 : QMainWindow( parent, name, fl ) { 115 : QMainWindow( parent, name, fl ) {
113 116
114 d = new PlayListWidgetPrivate; 117 d = new PlayListWidgetPrivate;
115 d->setDocumentUsed = FALSE; 118 d->setDocumentUsed = FALSE;
116 d->current = NULL; 119 d->current = NULL;
117 fromSetDocument = FALSE; 120 fromSetDocument = FALSE;
118 insanityBool=FALSE; 121 insanityBool=FALSE;
119 audioScan = FALSE; 122 audioScan = FALSE;
120 videoScan = FALSE; 123 videoScan = FALSE;
121// menuTimer = new QTimer( this ,"menu timer"), 124// menuTimer = new QTimer( this ,"menu timer"),
122// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 125// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
123 channel = new QCopChannel( "QPE/Application/opieplayer", this ); 126 channel = new QCopChannel( "QPE/Application/opieplayer", this );
124 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 127 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
125 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 128 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
126 129
127 setBackgroundMode( PaletteButton ); 130 setBackgroundMode( PaletteButton );
128 131
129 setCaption( tr("OpiePlayer") ); 132 setCaption( tr("OpiePlayer") );
130 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 133 setIcon( Opie::Core::OResource::loadPixmap( "opieplayer/MPEGPlayer", Opie::Core::OResource::SmallIcon ) );
131 134
132 setToolBarsMovable( FALSE ); 135 setToolBarsMovable( FALSE );
133 136
134 // Create Toolbar 137 // Create Toolbar
135 QToolBar *toolbar = new QToolBar( this ); 138 QToolBar *toolbar = new QToolBar( this );
136 toolbar->setHorizontalStretchable( TRUE ); 139 toolbar->setHorizontalStretchable( TRUE );
137 140
138 // Create Menubar 141 // Create Menubar
139 QMenuBar *menu = new QMenuBar( toolbar ); 142 QMenuBar *menu = new QMenuBar( toolbar );
140 menu->setMargin( 0 ); 143 menu->setMargin( 0 );
141 144
142 QToolBar *bar = new QToolBar( this ); 145 QToolBar *bar = new QToolBar( this );
143 bar->setLabel( tr( "Play Operations" ) ); 146 bar->setLabel( tr( "Play Operations" ) );
144// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 147// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
145// this , SLOT( addSelected()) ); 148// this , SLOT( addSelected()) );
146 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 149 tbDeletePlaylist = new QPushButton( Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon),"",bar,"close");
147 tbDeletePlaylist->setFlat(TRUE); 150 tbDeletePlaylist->setFlat(TRUE);
148 151
149 tbDeletePlaylist->setFixedSize(20,20); 152 tbDeletePlaylist->setFixedSize(20,20);
150 153
151 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 154 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
152 this , SLOT(addSelected()) ); 155 this , SLOT(addSelected()) );
153 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 156 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
154 this , SLOT(removeSelected()) ); 157 this , SLOT(removeSelected()) );
155// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); 158// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE );
156 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 159 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
157 this , SLOT( btnPlay(bool) ), TRUE ); 160 this , SLOT( btnPlay(bool) ), TRUE );
158 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 161 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
159 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 162 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
160 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 163 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
161 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 164 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
162 tbDeletePlaylist->hide(); 165 tbDeletePlaylist->hide();
163 166
164 QPopupMenu *pmPlayList = new QPopupMenu( this ); 167 QPopupMenu *pmPlayList = new QPopupMenu( this );
165 menu->insertItem( tr( "File" ), pmPlayList ); 168 menu->insertItem( tr( "File" ), pmPlayList );
166 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 169 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
167 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 170 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
168 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 171 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
169 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 172 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
170 pmPlayList->insertSeparator(-1); 173 pmPlayList->insertSeparator(-1);
171 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 174 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
172 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 175 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
173 pmPlayList->insertSeparator(-1); 176 pmPlayList->insertSeparator(-1);
174 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 177 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
175 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 178 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
176 179
177 QPopupMenu *pmView = new QPopupMenu( this ); 180 QPopupMenu *pmView = new QPopupMenu( this );
178 menu->insertItem( tr( "View" ), pmView ); 181 menu->insertItem( tr( "View" ), pmView );
179 182
180 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 183 fullScreenButton = new QAction(tr("Full Screen"), Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon),
184 QString::null, 0, this, 0);
181 fullScreenButton->addTo(pmView); 185 fullScreenButton->addTo(pmView);
182 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 186 scaleButton = new QAction(tr("Scale"), Opie::Core::OResource::loadPixmap("opieplayer/scale", Opie::Core::OResource::SmallIcon),
187 QString::null, 0, this, 0);
183 scaleButton->addTo(pmView); 188 scaleButton->addTo(pmView);
184 189
185 190
186 skinsMenu = new QPopupMenu( this ); 191 skinsMenu = new QPopupMenu( this );
187 menu->insertItem( tr( "Skins" ), skinsMenu ); 192 menu->insertItem( tr( "Skins" ), skinsMenu );
188 skinsMenu->isCheckable(); 193 skinsMenu->isCheckable();
189 connect( skinsMenu, SIGNAL( activated(int) ) , 194 connect( skinsMenu, SIGNAL( activated(int) ) ,
190 this, SLOT( skinsMenuActivated(int) ) ); 195 this, SLOT( skinsMenuActivated(int) ) );
191 populateSkinsMenu(); 196 populateSkinsMenu();
192 197
193 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 198 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
194 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 199 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
195 200
196 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 201 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
197 202
198 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 203 tabWidget = new QTabWidget( hbox6, "tabWidget" );
199// tabWidget->setTabShape(QTabWidget::Triangular); 204// tabWidget->setTabShape(QTabWidget::Triangular);
200 205
201 QWidget *pTab; 206 QWidget *pTab;
202 pTab = new QWidget( tabWidget, "pTab" ); 207 pTab = new QWidget( tabWidget, "pTab" );
203// playlistView = new QListView( pTab, "playlistview" ); 208// playlistView = new QListView( pTab, "playlistview" );
204// playlistView->setMinimumSize(236,260); 209// playlistView->setMinimumSize(236,260);
205 tabWidget->insertTab( pTab,"Playlist"); 210 tabWidget->insertTab( pTab,"Playlist");
206 211
207 212
208 // Add the playlist area 213 // Add the playlist area
209 214
210 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 215 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
211 d->playListFrame = vbox3; 216 d->playListFrame = vbox3;
212 217
213 QGridLayout *layoutF = new QGridLayout( pTab ); 218 QGridLayout *layoutF = new QGridLayout( pTab );
214 layoutF->setSpacing( 2); 219 layoutF->setSpacing( 2);
215 layoutF->setMargin( 2); 220 layoutF->setMargin( 2);
216 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); 221 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 );
217 222
218 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 223 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
219 224
220 d->selectedFiles = new PlayListSelection( hbox2); 225 d->selectedFiles = new PlayListSelection( hbox2);
221 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 226 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
222 227
223 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 228 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
224 229
225 230
226 231
227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 232 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 233 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 234 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 235 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 236 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
232 237
233 QWidget *aTab; 238 QWidget *aTab;
234 aTab = new QWidget( tabWidget, "aTab" ); 239 aTab = new QWidget( tabWidget, "aTab" );
235 audioView = new QListView( aTab, "Audioview" ); 240 audioView = new QListView( aTab, "Audioview" );
236 241
237 QGridLayout *layoutA = new QGridLayout( aTab ); 242 QGridLayout *layoutA = new QGridLayout( aTab );
238 layoutA->setSpacing( 2); 243 layoutA->setSpacing( 2);
239 layoutA->setMargin( 2); 244 layoutA->setMargin( 2);
240 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 245 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 );
241 246
242 audioView->addColumn( tr("Title"),-1); 247 audioView->addColumn( tr("Title"),-1);
243 audioView->addColumn(tr("Size"), -1); 248 audioView->addColumn(tr("Size"), -1);
244 audioView->addColumn(tr("Media"),-1); 249 audioView->addColumn(tr("Media"),-1);
245 audioView->addColumn( tr( "Path" ), -1 ); 250 audioView->addColumn( tr( "Path" ), -1 );
246 251
247 audioView->setColumnAlignment(1, Qt::AlignRight); 252 audioView->setColumnAlignment(1, Qt::AlignRight);
248 audioView->setColumnAlignment(2, Qt::AlignRight); 253 audioView->setColumnAlignment(2, Qt::AlignRight);
249 audioView->setAllColumnsShowFocus(TRUE); 254 audioView->setAllColumnsShowFocus(TRUE);
250 255
251 audioView->setMultiSelection( TRUE ); 256 audioView->setMultiSelection( TRUE );
252 audioView->setSelectionMode( QListView::Extended); 257 audioView->setSelectionMode( QListView::Extended);
253 audioView->setSorting( 3, TRUE ); 258 audioView->setSorting( 3, TRUE );
254 259
255 tabWidget->insertTab(aTab,tr("Audio")); 260 tabWidget->insertTab(aTab,tr("Audio"));
256 261
257 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 262 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
258 263
259// audioView 264// audioView
260// populateAudioView(); 265// populateAudioView();
261// videowidget 266// videowidget
262 267
263 QWidget *vTab; 268 QWidget *vTab;
264 vTab = new QWidget( tabWidget, "vTab" ); 269 vTab = new QWidget( tabWidget, "vTab" );
265 videoView = new QListView( vTab, "Videoview" ); 270 videoView = new QListView( vTab, "Videoview" );
266 271
267 QGridLayout *layoutV = new QGridLayout( vTab ); 272 QGridLayout *layoutV = new QGridLayout( vTab );
268 layoutV->setSpacing( 2); 273 layoutV->setSpacing( 2);
269 layoutV->setMargin( 2); 274 layoutV->setMargin( 2);
270 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 275 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 );
271 276
272 videoView->addColumn(tr("Title"),-1); 277 videoView->addColumn(tr("Title"),-1);
273 videoView->addColumn(tr("Size"),-1); 278 videoView->addColumn(tr("Size"),-1);
274 videoView->addColumn(tr("Media"),-1); 279 videoView->addColumn(tr("Media"),-1);
275 videoView->addColumn(tr( "Path" ), -1 ); 280 videoView->addColumn(tr( "Path" ), -1 );
276 videoView->setColumnAlignment(1, Qt::AlignRight); 281 videoView->setColumnAlignment(1, Qt::AlignRight);
277 videoView->setColumnAlignment(2, Qt::AlignRight); 282 videoView->setColumnAlignment(2, Qt::AlignRight);
278 videoView->setAllColumnsShowFocus(TRUE); 283 videoView->setAllColumnsShowFocus(TRUE);
279 videoView->setMultiSelection( TRUE ); 284 videoView->setMultiSelection( TRUE );
280 videoView->setSelectionMode( QListView::Extended); 285 videoView->setSelectionMode( QListView::Extended);
281 286
282 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 287 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
283 288
284 tabWidget->insertTab( vTab,tr("Video")); 289 tabWidget->insertTab( vTab,tr("Video"));
285 290
286 QWidget *LTab; 291 QWidget *LTab;
287 LTab = new QWidget( tabWidget, "LTab" ); 292 LTab = new QWidget( tabWidget, "LTab" );
288 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); 293 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE);
289 294
290 QGridLayout *layoutL = new QGridLayout( LTab ); 295 QGridLayout *layoutL = new QGridLayout( LTab );
291 layoutL->setSpacing( 2); 296 layoutL->setSpacing( 2);
292 layoutL->setMargin( 2); 297 layoutL->setMargin( 2);
293 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 298 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 );
294 299
295 tabWidget->insertTab(LTab,tr("Lists")); 300 tabWidget->insertTab(LTab,tr("Lists"));
296 301
297 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 302 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
298 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 303 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
299 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 304 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
300 305
301 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 306 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
302 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) ); 307 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) );
303 308
304 309
305///audioView 310///audioView
306 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 311 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
307 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); 312 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) );
308 313
309 connect( audioView, SIGNAL( returnPressed(QListViewItem*)), 314 connect( audioView, SIGNAL( returnPressed(QListViewItem*)),
310 this,SLOT( playIt(QListViewItem*)) ); 315 this,SLOT( playIt(QListViewItem*)) );
311 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); 316 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) );
312 317
313 318
314//videoView 319//videoView
315 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 320 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
316 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); 321 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) );
317 connect( videoView, SIGNAL( returnPressed(QListViewItem*)), 322 connect( videoView, SIGNAL( returnPressed(QListViewItem*)),
318 this,SLOT( playIt(QListViewItem*)) ); 323 this,SLOT( playIt(QListViewItem*)) );
319 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); 324 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) );
320 325
321//playlists 326//playlists
322 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) ); 327 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) );
323 328
324 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 329 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
325 330
326 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) ); 331 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) );
327 332
328 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) ); 333 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) );
329 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) ); 334 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) );
330 connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) ); 335 connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) );
331 336
332 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) ); 337 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) );
333 338
334 setCentralWidget( vbox5 ); 339 setCentralWidget( vbox5 );
335 340
336 Config cfg( "OpiePlayer" ); 341 Config cfg( "OpiePlayer" );
337 readConfig( cfg ); 342 readConfig( cfg );
338 343
339 currentPlayList = cfg.readEntry("CurrentPlaylist","default"); 344 currentPlayList = cfg.readEntry("CurrentPlaylist","default");
340 loadList(DocLnk( currentPlayList)); 345 loadList(DocLnk( currentPlayList));
341 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); 346 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList)));
342 347
343 initializeStates(); 348 initializeStates();
344} 349}
345 350
346 351
347PlayListWidget::~PlayListWidget() { 352PlayListWidget::~PlayListWidget() {
348 Config cfg( "OpiePlayer" ); 353 Config cfg( "OpiePlayer" );
349 writeConfig( cfg ); 354 writeConfig( cfg );
350 355
351 if ( d->current ) 356 if ( d->current )
352 delete d->current; 357 delete d->current;
353 if(d) delete d; 358 if(d) delete d;
354} 359}
355 360
356 361
357void PlayListWidget::initializeStates() { 362void PlayListWidget::initializeStates() {
358 363
359 d->tbPlay->setOn( mediaPlayerState->playing() ); 364 d->tbPlay->setOn( mediaPlayerState->playing() );
360 d->tbLoop->setOn( mediaPlayerState->looping() ); 365 d->tbLoop->setOn( mediaPlayerState->looping() );
361 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 366 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
362 setPlaylist( true); 367 setPlaylist( true);
363} 368}
364 369
365 370
366void PlayListWidget::readConfig( Config& cfg ) { 371void PlayListWidget::readConfig( Config& cfg ) {
367 cfg.setGroup("PlayList"); 372 cfg.setGroup("PlayList");
368 QString currentString = cfg.readEntry("current", "" ); 373 QString currentString = cfg.readEntry("current", "" );
369 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 374 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
370 for ( int i = 0; i < noOfFiles; i++ ) { 375 for ( int i = 0; i < noOfFiles; i++ ) {
371 QString entryName; 376 QString entryName;
372 entryName.sprintf( "File%i", i + 1 ); 377 entryName.sprintf( "File%i", i + 1 );
373 QString linkFile = cfg.readEntry( entryName ); 378 QString linkFile = cfg.readEntry( entryName );
374 DocLnk lnk( linkFile ); 379 DocLnk lnk( linkFile );
375 if ( lnk.isValid() ) { 380 if ( lnk.isValid() ) {
376 d->selectedFiles->addToSelection( lnk ); 381 d->selectedFiles->addToSelection( lnk );
377 } 382 }
378 } 383 }
379 d->selectedFiles->setSelectedItem( currentString); 384 d->selectedFiles->setSelectedItem( currentString);
380} 385}
381 386
382 387
383void PlayListWidget::writeConfig( Config& cfg ) const { 388void PlayListWidget::writeConfig( Config& cfg ) const {
384 389
385 d->selectedFiles->writeCurrent( cfg); 390 d->selectedFiles->writeCurrent( cfg);
386 cfg.setGroup("PlayList"); 391 cfg.setGroup("PlayList");
387 int noOfFiles = 0; 392 int noOfFiles = 0;
388 d->selectedFiles->first(); 393 d->selectedFiles->first();
389 do { 394 do {
390 const DocLnk *lnk = d->selectedFiles->current(); 395 const DocLnk *lnk = d->selectedFiles->current();
391 if ( lnk ) { 396 if ( lnk ) {
392 QString entryName; 397 QString entryName;
393 entryName.sprintf( "File%i", noOfFiles + 1 ); 398 entryName.sprintf( "File%i", noOfFiles + 1 );
394// odebug << entryName << oendl; 399// odebug << entryName << oendl;
395 cfg.writeEntry( entryName, lnk->linkFile() ); 400 cfg.writeEntry( entryName, lnk->linkFile() );
396 // if this link does exist, add it so we have the file 401 // if this link does exist, add it so we have the file
397 // next time... 402 // next time...
398 if ( !QFile::exists( lnk->linkFile() ) ) { 403 if ( !QFile::exists( lnk->linkFile() ) ) {
399 // the way writing lnks doesn't really check for out 404 // the way writing lnks doesn't really check for out
400 // of disk space, but check it anyway. 405 // of disk space, but check it anyway.
401// if ( !lnk->writeLink() ) { 406// if ( !lnk->writeLink() ) {
402// QMessageBox::critical( 0, tr("Out of space"), 407// QMessageBox::critical( 0, tr("Out of space"),
403// tr( "There was a problem saving " 408// tr( "There was a problem saving "
404// "the playlist.\n" 409// "the playlist.\n"
405// "Your playlist " 410// "Your playlist "
406// "may be missing some entries\n" 411// "may be missing some entries\n"
407// "the next time you start it." ) 412// "the next time you start it." )
408// ); 413// );
409// } 414// }
410 415
411 } 416 }
412 noOfFiles++; 417 noOfFiles++;
413 } 418 }
414 } 419 }
415 while ( d->selectedFiles->next() ); 420 while ( d->selectedFiles->next() );
416 cfg.writeEntry("NumberOfFiles", noOfFiles ); 421 cfg.writeEntry("NumberOfFiles", noOfFiles );
417} 422}
418 423
419 424
420void PlayListWidget::addToSelection( const DocLnk& lnk ) { 425void PlayListWidget::addToSelection( const DocLnk& lnk ) {
421 d->setDocumentUsed = false; 426 d->setDocumentUsed = false;
422 if ( mediaPlayerState->playlist() ) { 427 if ( mediaPlayerState->playlist() ) {
423 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 428 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
424 d->selectedFiles->addToSelection( lnk ); 429 d->selectedFiles->addToSelection( lnk );
425 } 430 }
426 else 431 else
427 mediaPlayerState->setPlaying( true); 432 mediaPlayerState->setPlaying( true);
428 433
429} 434}
430 435
431 436
432void PlayListWidget::clearList() { 437void PlayListWidget::clearList() {
433 while ( first() ) 438 while ( first() )
434 d->selectedFiles->removeSelected(); 439 d->selectedFiles->removeSelected();
435 Config cfg( "OpiePlayer" ); 440 Config cfg( "OpiePlayer" );
436 cfg.setGroup("PlayList"); 441 cfg.setGroup("PlayList");
437 cfg.writeEntry("CurrentPlaylist",""); 442 cfg.writeEntry("CurrentPlaylist","");
438 currentPlayList=""; 443 currentPlayList="";
439 444
440} 445}
441 446
442 447
443void PlayListWidget::addAllToList() { 448void PlayListWidget::addAllToList() {
444 DocLnkSet filesAll; 449 DocLnkSet filesAll;
445 Global::findDocuments(&filesAll, "video/*;audio/*"); 450 Global::findDocuments(&filesAll, "video/*;audio/*");
446 QListIterator<DocLnk> Adit( filesAll.children() ); 451 QListIterator<DocLnk> Adit( filesAll.children() );
447 for ( ; Adit.current(); ++Adit ) 452 for ( ; Adit.current(); ++Adit )
448 if(QFileInfo(Adit.current()->file()).exists()) 453 if(QFileInfo(Adit.current()->file()).exists())
449 d->selectedFiles->addToSelection( **Adit ); 454 d->selectedFiles->addToSelection( **Adit );
450 tabWidget->setCurrentPage(0); 455 tabWidget->setCurrentPage(0);
451 456
452 writeCurrentM3u(); 457 writeCurrentM3u();
453 d->selectedFiles->first(); 458 d->selectedFiles->first();
454} 459}
455 460
456 461
457void PlayListWidget::addAllMusicToList() { 462void PlayListWidget::addAllMusicToList() {
458 QListIterator<DocLnk> dit( files.children() ); 463 QListIterator<DocLnk> dit( files.children() );
459 for ( ; dit.current(); ++dit ) 464 for ( ; dit.current(); ++dit )
460 if(QFileInfo(dit.current()->file()).exists()) 465 if(QFileInfo(dit.current()->file()).exists())
461 d->selectedFiles->addToSelection( **dit ); 466 d->selectedFiles->addToSelection( **dit );
462 tabWidget->setCurrentPage(0); 467 tabWidget->setCurrentPage(0);
463 468
464 writeCurrentM3u(); 469 writeCurrentM3u();
465 d->selectedFiles->first(); 470 d->selectedFiles->first();
466} 471}
467 472
468 473
469void PlayListWidget::addAllVideoToList() { 474void PlayListWidget::addAllVideoToList() {
470 QListIterator<DocLnk> dit( vFiles.children() ); 475 QListIterator<DocLnk> dit( vFiles.children() );
471 for ( ; dit.current(); ++dit ) 476 for ( ; dit.current(); ++dit )
472 if(QFileInfo( dit.current()->file()).exists()) 477 if(QFileInfo( dit.current()->file()).exists())
473 d->selectedFiles->addToSelection( **dit ); 478 d->selectedFiles->addToSelection( **dit );
474 tabWidget->setCurrentPage(0); 479 tabWidget->setCurrentPage(0);
475 480
476 writeCurrentM3u(); 481 writeCurrentM3u();
477 d->selectedFiles->first(); 482 d->selectedFiles->first();
478} 483}
479 484
480 485
481void PlayListWidget::setDocument(const QString& fileref) { 486void PlayListWidget::setDocument(const QString& fileref) {
482 fromSetDocument = true; 487 fromSetDocument = true;
483 d->setDocumentUsed = TRUE; 488 d->setDocumentUsed = TRUE;
484 setDocumentEx(fileref); 489 setDocumentEx(fileref);
485} 490}
486 491
487void PlayListWidget::setDocumentEx(const QString& fileref) { 492void PlayListWidget::setDocumentEx(const QString& fileref) {
488 odebug << "opieplayer receive "+fileref << oendl; 493 odebug << "opieplayer receive "+fileref << oendl;
489 clearList(); 494 clearList();
490 DocLnk lnk; 495 DocLnk lnk;
491 QFileInfo fileInfo(fileref); 496 QFileInfo fileInfo(fileref);
492 if ( !fileInfo.exists() ) { 497 if ( !fileInfo.exists() ) {
493 QMessageBox::critical( 0, tr( "Invalid File" ), 498 QMessageBox::critical( 0, tr( "Invalid File" ),
494 tr( "There was a problem in getting the file." ) ); 499 tr( "There was a problem in getting the file." ) );
495 return; 500 return;
496 } 501 }
497 // odebug << "<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref << oendl; 502 // odebug << "<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref << oendl;
498 QString extension = fileInfo.extension(false); 503 QString extension = fileInfo.extension(false);
499 if( extension.find( "m3u", 0, false) != -1) { //is m3u 504 if( extension.find( "m3u", 0, false) != -1) { //is m3u
500 readm3u( fileref); 505 readm3u( fileref);
501 } 506 }
502 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 507 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
503 readPls( fileref); 508 readPls( fileref);
504 } 509 }
505 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 510 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
506 clearList(); 511 clearList();
507 lnk.setName( fileInfo.baseName() ); //sets name 512 lnk.setName( fileInfo.baseName() ); //sets name
508 lnk.setFile( fileref ); //sets file name 513 lnk.setFile( fileref ); //sets file name
509 lnk.setIcon("Sound"); 514 lnk.setIcon("Sound");
510 //addToSelection( lnk ); 515 //addToSelection( lnk );
511 516
512 loadList( lnk); 517 loadList( lnk);
513 d->selectedFiles->first(); 518 d->selectedFiles->first();
514 } else { 519 } else {
515 if( fileref.find(".desktop",0,TRUE) != -1) { 520 if( fileref.find(".desktop",0,TRUE) != -1) {
516 lnk = DocLnk(fileref); 521 lnk = DocLnk(fileref);
517 } else { 522 } else {
518 lnk.setName( fileInfo.baseName() ); //sets name 523 lnk.setName( fileInfo.baseName() ); //sets name
519 lnk.setFile( fileref ); //sets file name 524 lnk.setFile( fileref ); //sets file name
520 lnk.setIcon("Sound"); 525 lnk.setIcon("Sound");
521 } 526 }
522 527
523 addToSelection( lnk ); 528 addToSelection( lnk );
524 // addToSelection( DocLnk( fileref ) ); 529 // addToSelection( DocLnk( fileref ) );
525 lnk.removeLinkFile(); 530 lnk.removeLinkFile();
526 // qApp->processEvents(); 531 // qApp->processEvents();
527 } 532 }
528 setCaption(tr("OpiePlayer")); 533 setCaption(tr("OpiePlayer"));
529 d->setDocumentUsed = TRUE; 534 d->setDocumentUsed = TRUE;
530 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); 535 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true );
531 mediaPlayerState->setPlaying( FALSE ); 536 mediaPlayerState->setPlaying( FALSE );
532 qApp->processEvents(); 537 qApp->processEvents();
533 mediaPlayerState->setPlaying( TRUE ); 538 mediaPlayerState->setPlaying( TRUE );
534 539
535} 540}
536 541
537 542
538void PlayListWidget::setActiveWindow() { 543void PlayListWidget::setActiveWindow() {
539 // odebug << "SETTING active window" << oendl; 544 // odebug << "SETTING active window" << oendl;
540 // When we get raised we need to ensure that it switches views 545 // When we get raised we need to ensure that it switches views
541 char origView = mediaPlayerState->view(); 546 char origView = mediaPlayerState->view();
542 mediaPlayerState->setView( 'l' ); // invalidate 547 mediaPlayerState->setView( 'l' ); // invalidate
543 mediaPlayerState->setView( origView ); // now switch back 548 mediaPlayerState->setView( origView ); // now switch back
544} 549}
545 550
546 551
547void PlayListWidget::useSelectedDocument() { 552void PlayListWidget::useSelectedDocument() {
548 d->setDocumentUsed = FALSE; 553 d->setDocumentUsed = FALSE;
549} 554}
550 555
551 556
552const DocLnk *PlayListWidget::current() { // this is fugly 557const DocLnk *PlayListWidget::current() { // this is fugly
553 switch (tabWidget->currentPageIndex()) { 558 switch (tabWidget->currentPageIndex()) {
554 case 0: //playlist 559 case 0: //playlist
555 { 560 {
556 // odebug << "playlist" << oendl; 561 // odebug << "playlist" << oendl;
557 if ( mediaPlayerState->playlist() ) { 562 if ( mediaPlayerState->playlist() ) {
558 return d->selectedFiles->current(); 563 return d->selectedFiles->current();
559 } 564 }
560 else if ( d->setDocumentUsed && d->current ) { 565 else if ( d->setDocumentUsed && d->current ) {
561 return d->current; 566 return d->current;
562 } else { 567 } else {
563 return &(d->files->selectedDocument()); 568 return &(d->files->selectedDocument());
564 } 569 }
565 } 570 }
566 break; 571 break;
567 case 1://audio 572 case 1://audio
568 { 573 {
569 // odebug << "audioView" << oendl; 574 // odebug << "audioView" << oendl;
570 QListIterator<DocLnk> dit( files.children() ); 575 QListIterator<DocLnk> dit( files.children() );
571 for ( ; dit.current(); ++dit ) { 576 for ( ; dit.current(); ++dit ) {
572 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 577 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
573 insanityBool=TRUE; 578 insanityBool=TRUE;
574 return dit; 579 return dit;
575 } 580 }
576 } 581 }
577 } 582 }
578 break; 583 break;
579 case 2: // video 584 case 2: // video
580 { 585 {
581 QListIterator<DocLnk> Vdit( vFiles.children() ); 586 QListIterator<DocLnk> Vdit( vFiles.children() );
582 for ( ; Vdit.current(); ++Vdit ) { 587 for ( ; Vdit.current(); ++Vdit ) {
583 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 588 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
584 insanityBool=TRUE; 589 insanityBool=TRUE;
585 return Vdit; 590 return Vdit;
586 } 591 }
587 } 592 }
588 } 593 }
589 break; 594 break;
590 }; 595 };
591 return 0; 596 return 0;
592} 597}
593 598
594bool PlayListWidget::prev() { 599bool PlayListWidget::prev() {
595 if ( mediaPlayerState->playlist() ) { 600 if ( mediaPlayerState->playlist() ) {
596 if ( mediaPlayerState->shuffled() ) { 601 if ( mediaPlayerState->shuffled() ) {
597 const DocLnk *cur = current(); 602 const DocLnk *cur = current();
598 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 603 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
599 for ( int i = 0; i < j; i++ ) { 604 for ( int i = 0; i < j; i++ ) {
600 if ( !d->selectedFiles->next() ) 605 if ( !d->selectedFiles->next() )
601 d->selectedFiles->first(); 606 d->selectedFiles->first();
602 } 607 }
603 if ( cur == current() ) 608 if ( cur == current() )
604 if ( !d->selectedFiles->next() ) 609 if ( !d->selectedFiles->next() )
605 d->selectedFiles->first(); 610 d->selectedFiles->first();
606 return TRUE; 611 return TRUE;
607 } else { 612 } else {
608 if ( !d->selectedFiles->prev() ) { 613 if ( !d->selectedFiles->prev() ) {
609 if ( mediaPlayerState->looping() ) { 614 if ( mediaPlayerState->looping() ) {
610 return d->selectedFiles->last(); 615 return d->selectedFiles->last();
611 } else { 616 } else {
612 return FALSE; 617 return FALSE;
613 } 618 }
614 } 619 }
615 return TRUE; 620 return TRUE;
616 } 621 }
617 } else { 622 } else {
618 return mediaPlayerState->looping(); 623 return mediaPlayerState->looping();
619 } 624 }
620} 625}
621 626
622 627
623bool PlayListWidget::next() { 628bool PlayListWidget::next() {
624 if ( mediaPlayerState->playlist() ) { 629 if ( mediaPlayerState->playlist() ) {
625 if ( mediaPlayerState->shuffled() ) { 630 if ( mediaPlayerState->shuffled() ) {
626 return prev(); 631 return prev();
627 } else { 632 } else {
628 if ( !d->selectedFiles->next() ) { 633 if ( !d->selectedFiles->next() ) {
629 if ( mediaPlayerState->looping() ) { 634 if ( mediaPlayerState->looping() ) {
630 return d->selectedFiles->first(); 635 return d->selectedFiles->first();
631 } else { 636 } else {
632 return FALSE; 637 return FALSE;
633 } 638 }
634 } 639 }
635 return TRUE; 640 return TRUE;
636 } 641 }
637 } else { 642 } else {
638 return mediaPlayerState->looping(); 643 return mediaPlayerState->looping();
639 } 644 }
640} 645}
641 646
642 647
643bool PlayListWidget::first() { 648bool PlayListWidget::first() {
644 if ( mediaPlayerState->playlist() ) 649 if ( mediaPlayerState->playlist() )
645 return d->selectedFiles->first(); 650 return d->selectedFiles->first();
646 else 651 else
647 return mediaPlayerState->looping(); 652 return mediaPlayerState->looping();
648} 653}
649 654
650 655
651bool PlayListWidget::last() { 656bool PlayListWidget::last() {
652 if ( mediaPlayerState->playlist() ) 657 if ( mediaPlayerState->playlist() )
653 return d->selectedFiles->last(); 658 return d->selectedFiles->last();
654 else 659 else
655 return mediaPlayerState->looping(); 660 return mediaPlayerState->looping();
656} 661}
657 662
658 663
659void PlayListWidget::saveList() { 664void PlayListWidget::saveList() {
660 writem3u(); 665 writem3u();
661} 666}
662 667
663void PlayListWidget::loadList( const DocLnk & lnk) { 668void PlayListWidget::loadList( const DocLnk & lnk) {
664 QString name = lnk.name(); 669 QString name = lnk.name();
665 // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl; 670 // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl;
666 671
667 if( name.length()>0) { 672 if( name.length()>0) {
668 setCaption("OpiePlayer: "+name); 673 setCaption("OpiePlayer: "+name);
669 // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl; 674 // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl;
670 clearList(); 675 clearList();
671 readm3u(lnk.file()); 676 readm3u(lnk.file());
672 tabWidget->setCurrentPage(0); 677 tabWidget->setCurrentPage(0);
673 } 678 }
674} 679}
675 680
676void PlayListWidget::setPlaylist( bool shown ) { 681void PlayListWidget::setPlaylist( bool shown ) {
677 if ( shown ) 682 if ( shown )
678 d->playListFrame->show(); 683 d->playListFrame->show();
679 else 684 else
680 d->playListFrame->hide(); 685 d->playListFrame->hide();
681} 686}
682 687
683void PlayListWidget::setView( char view ) { 688void PlayListWidget::setView( char view ) {
684 if ( view == 'l' ) 689 if ( view == 'l' )
685 QPEApplication::showWidget( this ); 690 QPEApplication::showWidget( this );
686 else 691 else
687 hide(); 692 hide();
688} 693}
689 694
690void PlayListWidget::addSelected() { 695void PlayListWidget::addSelected() {
691 DocLnk lnk; 696 DocLnk lnk;
692 QString filename; 697 QString filename;
693 switch (tabWidget->currentPageIndex()) { 698 switch (tabWidget->currentPageIndex()) {
694 699
695 case 0: //playlist 700 case 0: //playlist
696 return; 701 return;
697 break; 702 break;
698 case 1: { //audio 703 case 1: { //audio
699 QListViewItemIterator it( audioView ); 704 QListViewItemIterator it( audioView );
700 for ( ; it.current(); ++it ) { 705 for ( ; it.current(); ++it ) {
701 if ( it.current()->isSelected() ) { 706 if ( it.current()->isSelected() ) {
702 filename = it.current()->text(3); 707 filename = it.current()->text(3);
703 lnk.setName( QFileInfo(filename).baseName() ); //sets name 708 lnk.setName( QFileInfo(filename).baseName() ); //sets name
704 lnk.setFile( filename ); //sets file name 709 lnk.setFile( filename ); //sets file name
705 d->selectedFiles->addToSelection( lnk); 710 d->selectedFiles->addToSelection( lnk);
706 } 711 }
707 } 712 }
708 audioView->clearSelection(); 713 audioView->clearSelection();
709 // d->selectedFiles->next(); 714 // d->selectedFiles->next();
710 } 715 }
711 break; 716 break;
712 717
713 case 2: { // video 718 case 2: { // video
714 QListViewItemIterator it( videoView ); 719 QListViewItemIterator it( videoView );
715 for ( ; it.current(); ++it ) { 720 for ( ; it.current(); ++it ) {
716 if ( it.current()->isSelected() ) { 721 if ( it.current()->isSelected() ) {
717 722
718 filename = it.current()->text(3); 723 filename = it.current()->text(3);
719 lnk.setName( QFileInfo(filename).baseName() ); //sets name 724 lnk.setName( QFileInfo(filename).baseName() ); //sets name
720 lnk.setFile( filename ); //sets file name 725 lnk.setFile( filename ); //sets file name
721 d->selectedFiles->addToSelection( lnk); 726 d->selectedFiles->addToSelection( lnk);
722 } 727 }
723 } 728 }
724 videoView->clearSelection(); 729 videoView->clearSelection();
725 } 730 }
726 break; 731 break;
727 }; 732 };
728 // tabWidget->setCurrentPage(0); 733 // tabWidget->setCurrentPage(0);
729 writeCurrentM3u(); 734 writeCurrentM3u();
730 735
731} 736}
732 737
733void PlayListWidget::removeSelected() { 738void PlayListWidget::removeSelected() {
734 d->selectedFiles->removeSelected( ); 739 d->selectedFiles->removeSelected( );
735} 740}
736 741
737void PlayListWidget::playIt( QListViewItem *) { 742void PlayListWidget::playIt( QListViewItem *) {
738 // d->setDocumentUsed = FALSE; 743 // d->setDocumentUsed = FALSE;
739 // mediaPlayerState->curPosition =0; 744 // mediaPlayerState->curPosition =0;
740 // mediaPlayerState->setPlaying(FALSE); 745 // mediaPlayerState->setPlaying(FALSE);
741 mediaPlayerState->setPlaying(TRUE); 746 mediaPlayerState->setPlaying(TRUE);
742 d->selectedFiles->unSelect(); 747 d->selectedFiles->unSelect();
743} 748}
744 749
745void PlayListWidget::addToSelection( QListViewItem *it) { 750void PlayListWidget::addToSelection( QListViewItem *it) {
746 d->setDocumentUsed = FALSE; 751 d->setDocumentUsed = FALSE;
747 752
748 if(it) { 753 if(it) {
749 switch ( tabWidget->currentPageIndex()) { 754 switch ( tabWidget->currentPageIndex()) {
750 case 0: //playlist 755 case 0: //playlist
751 return; 756 return;
752 break; 757 break;
753 }; 758 };
754 // case 1: { 759 // case 1: {
755 DocLnk lnk; 760 DocLnk lnk;
756 QString filename; 761 QString filename;
757 762
758 filename=it->text(3); 763 filename=it->text(3);
759 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 764 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
760 lnk.setFile( filename ); //sets file name 765 lnk.setFile( filename ); //sets file name
761 d->selectedFiles->addToSelection( lnk); 766 d->selectedFiles->addToSelection( lnk);
762 767
763 if(tabWidget->currentPageIndex() == 0) 768 if(tabWidget->currentPageIndex() == 0)
764 writeCurrentM3u(); 769 writeCurrentM3u();
765 // tabWidget->setCurrentPage(0); 770 // tabWidget->setCurrentPage(0);
766 771
767 } 772 }
768} 773}
769 774
770void PlayListWidget::tabChanged(QWidget *) { 775void PlayListWidget::tabChanged(QWidget *) {
771 776
772 switch ( tabWidget->currentPageIndex()) { 777 switch ( tabWidget->currentPageIndex()) {
773 case 0: 778 case 0:
774 { 779 {
775 if( !tbDeletePlaylist->isHidden()) 780 if( !tbDeletePlaylist->isHidden())
776 tbDeletePlaylist->hide(); 781 tbDeletePlaylist->hide();
777 d->tbRemoveFromList->setEnabled(TRUE); 782 d->tbRemoveFromList->setEnabled(TRUE);
778 d->tbAddToList->setEnabled(FALSE); 783 d->tbAddToList->setEnabled(FALSE);
779 } 784 }
780 break; 785 break;
781 case 1: 786 case 1:
782 { 787 {
783 audioView->clear(); 788 audioView->clear();
784 populateAudioView(); 789 populateAudioView();
785 790
786 if( !tbDeletePlaylist->isHidden()) 791 if( !tbDeletePlaylist->isHidden())
787 tbDeletePlaylist->hide(); 792 tbDeletePlaylist->hide();
788 d->tbRemoveFromList->setEnabled(FALSE); 793 d->tbRemoveFromList->setEnabled(FALSE);
789 d->tbAddToList->setEnabled(TRUE); 794 d->tbAddToList->setEnabled(TRUE);
790 } 795 }
791 break; 796 break;
792 case 2: 797 case 2:
793 { 798 {
794 videoView->clear(); 799 videoView->clear();
795 populateVideoView(); 800 populateVideoView();
796 if( !tbDeletePlaylist->isHidden()) 801 if( !tbDeletePlaylist->isHidden())
797 tbDeletePlaylist->hide(); 802 tbDeletePlaylist->hide();
798 d->tbRemoveFromList->setEnabled(FALSE); 803 d->tbRemoveFromList->setEnabled(FALSE);
799 d->tbAddToList->setEnabled(TRUE); 804 d->tbAddToList->setEnabled(TRUE);
800 } 805 }
801 break; 806 break;
802 case 3: 807 case 3:
803 { 808 {
804 if( tbDeletePlaylist->isHidden()) 809 if( tbDeletePlaylist->isHidden())
805 tbDeletePlaylist->show(); 810 tbDeletePlaylist->show();
806 playLists->reread(); 811 playLists->reread();
807 } 812 }
808 break; 813 break;
809 }; 814 };
810} 815}
811 816
812void PlayListWidget::btnPlay(bool b) { 817void PlayListWidget::btnPlay(bool b) {
813 // mediaPlayerState->setPlaying(b); 818 // mediaPlayerState->setPlaying(b);
814 switch ( tabWidget->currentPageIndex()) { 819 switch ( tabWidget->currentPageIndex()) {
815 case 0: 820 case 0:
816 { 821 {
817 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 822 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
818 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 823 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
819 // QMessageBox::message("Note","You are trying to play\na malformed url."); 824 // QMessageBox::message("Note","You are trying to play\na malformed url.");
820 // } else { 825 // } else {
821 mediaPlayerState->setPlaying(b); 826 mediaPlayerState->setPlaying(b);
822 insanityBool=FALSE; 827 insanityBool=FALSE;
823 odebug << "insanity" << oendl; 828 odebug << "insanity" << oendl;
824 // } 829 // }
825 } 830 }
826 break; 831 break;
827 case 1: 832 case 1:
828 { 833 {
829 // d->selectedFiles->unSelect(); 834 // d->selectedFiles->unSelect();
830 addToSelection( audioView->currentItem() ); 835 addToSelection( audioView->currentItem() );
831 mediaPlayerState->setPlaying( b); 836 mediaPlayerState->setPlaying( b);
832 d->selectedFiles->removeSelected( ); 837 d->selectedFiles->removeSelected( );
833 d->selectedFiles->unSelect(); 838 d->selectedFiles->unSelect();
834 tabWidget->setCurrentPage(1); 839 tabWidget->setCurrentPage(1);
835 insanityBool=FALSE; 840 insanityBool=FALSE;
836 }// audioView->clearSelection(); 841 }// audioView->clearSelection();
837 break; 842 break;
838 case 2: 843 case 2:
839 { 844 {
840 845
841 addToSelection( videoView->currentItem() ); 846 addToSelection( videoView->currentItem() );
842 mediaPlayerState->setPlaying( b); 847 mediaPlayerState->setPlaying( b);
843 // qApp->processEvents(); 848 // qApp->processEvents();
844 d->selectedFiles->removeSelected( ); 849 d->selectedFiles->removeSelected( );
845 d->selectedFiles->unSelect(); 850 d->selectedFiles->unSelect();
846 tabWidget->setCurrentPage(2); 851 tabWidget->setCurrentPage(2);
847 insanityBool=FALSE; 852 insanityBool=FALSE;
848 }// videoView->clearSelection(); 853 }// videoView->clearSelection();
849 break; 854 break;
850 }; 855 };
851 856
852} 857}
853 858
854void PlayListWidget::deletePlaylist() { 859void PlayListWidget::deletePlaylist() {
855 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 860 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
856 (tr("You really want to delete\nthis playlist?")), 861 (tr("You really want to delete\nthis playlist?")),
857 (tr("Yes")), (tr("No")), 0 )){ 862 (tr("Yes")), (tr("No")), 0 )){
858 case 0: // Yes clicked, 863 case 0: // Yes clicked,
859 QFile().remove(playLists->selectedDocument().file()); 864 QFile().remove(playLists->selectedDocument().file());
860 QFile().remove(playLists->selectedDocument().linkFile()); 865 QFile().remove(playLists->selectedDocument().linkFile());
861 playLists->reread(); 866 playLists->reread();
862 break; 867 break;
863 case 1: // Cancel 868 case 1: // Cancel
864 break; 869 break;
865 }; 870 };
866} 871}
867 872
868void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 873void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
869{ 874{
870 switch (mouse) { 875 switch (mouse) {
871 case 1: 876 case 1:
872 break; 877 break;
873 case 2:{ 878 case 2:{
874 879
875 QPopupMenu m; 880 QPopupMenu m;
876 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 881 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
877 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 882 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
878 m.insertSeparator(); 883 m.insertSeparator();
879 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 884 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
880 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 885 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
881 886
882 m.exec( QCursor::pos() ); 887 m.exec( QCursor::pos() );
883 } 888 }
884 break; 889 break;
885 }; 890 };
886} 891}
887 892
888void PlayListWidget::playSelected() 893void PlayListWidget::playSelected()
889{ 894{
890 btnPlay( true); 895 btnPlay( true);
891// d->selectedFiles->unSelect(); 896// d->selectedFiles->unSelect();
892} 897}
893 898
894void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 899void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
895{ 900{
896 switch (mouse) { 901 switch (mouse) {
897 case 1: 902 case 1:
898 903
899 break; 904 break;
900 case 2:{ 905 case 2:{
901 QPopupMenu m; 906 QPopupMenu m;
902 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 907 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
903 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 908 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
904 // m.insertSeparator(); 909 // m.insertSeparator();
905 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 910 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
906 m.exec( QCursor::pos() ); 911 m.exec( QCursor::pos() );
907 } 912 }
908 break; 913 break;
909 }; 914 };
910 915
911} 916}
912 917
913void PlayListWidget::listDelete() { 918void PlayListWidget::listDelete() {
914 Config cfg( "OpiePlayer" ); 919 Config cfg( "OpiePlayer" );
915 cfg.setGroup("PlayList"); 920 cfg.setGroup("PlayList");
916 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 921 currentPlayList = cfg.readEntry("CurrentPlaylist","");
917 QString file; 922 QString file;
918 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 923 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
919 switch ( tabWidget->currentPageIndex()) { 924 switch ( tabWidget->currentPageIndex()) {
920 case 0: 925 case 0:
921 break; 926 break;
922 case 1: 927 case 1:
923 { 928 {
924 file = audioView->currentItem()->text(0); 929 file = audioView->currentItem()->text(0);
925 QListIterator<DocLnk> Pdit( files.children() ); 930 QListIterator<DocLnk> Pdit( files.children() );
926 for ( ; Pdit.current(); ++Pdit ) { 931 for ( ; Pdit.current(); ++Pdit ) {
927 if( Pdit.current()->name() == file) { 932 if( Pdit.current()->name() == file) {
928 LnkProperties prop( Pdit.current() ); 933 LnkProperties prop( Pdit.current() );
929 QPEApplication::execDialog( &prop ); 934 QPEApplication::execDialog( &prop );
930 } 935 }
931 } 936 }
932 populateAudioView(); 937 populateAudioView();
933 } 938 }
934 break; 939 break;
935 case 2: 940 case 2:
936 { 941 {
937 // file = videoView->selectedItem()->text(0); 942 // file = videoView->selectedItem()->text(0);
938 // for ( int i = 0; i < noOfFiles; i++ ) { 943 // for ( int i = 0; i < noOfFiles; i++ ) {
939 // QString entryName; 944 // QString entryName;
940 // entryName.sprintf( "File%i", i + 1 ); 945 // entryName.sprintf( "File%i", i + 1 );
941 // QString linkFile = cfg.readEntry( entryName ); 946 // QString linkFile = cfg.readEntry( entryName );
942 // AppLnk lnk( AppLnk(linkFile)); 947 // AppLnk lnk( AppLnk(linkFile));
943 // if( lnk.name() == file ) { 948 // if( lnk.name() == file ) {
944 // LnkProperties prop( &lnk); 949 // LnkProperties prop( &lnk);
945 // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*))); 950 // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*)));
946 // prop.showMaximized(); 951 // prop.showMaximized();
947 // prop.exec(); 952 // prop.exec();
948 // } 953 // }
949 // } 954 // }
950 } 955 }
951 break; 956 break;
952 }; 957 };
953} 958}
954 959
955void PlayListWidget::scanForAudio() { 960void PlayListWidget::scanForAudio() {
956 // odebug << "scan for audio" << oendl; 961 // odebug << "scan for audio" << oendl;
957 files.detachChildren(); 962 files.detachChildren();
958 QListIterator<DocLnk> sdit( files.children() ); 963 QListIterator<DocLnk> sdit( files.children() );
959 for ( ; sdit.current(); ++sdit ) { 964 for ( ; sdit.current(); ++sdit ) {
960 delete sdit.current(); 965 delete sdit.current();
961 } 966 }
962 Global::findDocuments( &files, audioMimes); 967 Global::findDocuments( &files, audioMimes);
963 audioScan = true; 968 audioScan = true;
964} 969}
965void PlayListWidget::scanForVideo() { 970void PlayListWidget::scanForVideo() {
966 // odebug << "scan for video" << oendl; 971 // odebug << "scan for video" << oendl;
967 vFiles.detachChildren(); 972 vFiles.detachChildren();
968 QListIterator<DocLnk> sdit( vFiles.children() ); 973 QListIterator<DocLnk> sdit( vFiles.children() );
969 for ( ; sdit.current(); ++sdit ) { 974 for ( ; sdit.current(); ++sdit ) {
970 delete sdit.current(); 975 delete sdit.current();
971 } 976 }
972 Global::findDocuments(&vFiles, "video/*"); 977 Global::findDocuments(&vFiles, "video/*");
973 videoScan = true; 978 videoScan = true;
974} 979}
975 980
976void PlayListWidget::populateAudioView() { 981void PlayListWidget::populateAudioView() {
977 982
978 audioView->clear(); 983 audioView->clear();
979 StorageInfo storageInfo; 984 StorageInfo storageInfo;
980 const QList<FileSystem> &fs = storageInfo.fileSystems(); 985 const QList<FileSystem> &fs = storageInfo.fileSystems();
981 if(!audioScan) scanForAudio(); 986 if(!audioScan) scanForAudio();
982 987
983 QListIterator<DocLnk> dit( files.children() ); 988 QListIterator<DocLnk> dit( files.children() );
984 QListIterator<FileSystem> it ( fs ); 989 QListIterator<FileSystem> it ( fs );
985 990
986 QString storage; 991 QString storage;
987 for ( ; dit.current(); ++dit ) { 992 for ( ; dit.current(); ++dit ) {
988 for( ; it.current(); ++it ){ 993 for( ; it.current(); ++it ){
989 const QString name = (*it)->name(); 994 const QString name = (*it)->name();
990 const QString path = (*it)->path(); 995 const QString path = (*it)->path();
991 if(dit.current()->file().find(path) != -1 ) storage=name; 996 if(dit.current()->file().find(path) != -1 ) storage=name;
992 } 997 }
993 998
994 QListViewItem * newItem; 999 QListViewItem * newItem;
995 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 1000 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
996 long size; 1001 long size;
997 if( dit.current()->file().left(4) == "http" ) 1002 if( dit.current()->file().left(4) == "http" )
998 size=0; 1003 size=0;
999 else 1004 else
1000 size = QFile( dit.current()->file() ).size(); 1005 size = QFile( dit.current()->file() ).size();
1001 // odebug << dit.current()->name() << oendl; 1006 // odebug << dit.current()->name() << oendl;
1002 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1007 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1003 QString::number(size ), storage, dit.current()->file()); 1008 QString::number(size ), storage, dit.current()->file());
1004 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1009 newItem->setPixmap(0, Opie::Core::OResource::loadPixmap( "opieplayer/musicfile", Opie::Core::OResource::SmallIcon ));
1005 } 1010 }
1006 } 1011 }
1007 1012
1008} 1013}
1009 1014
1010void PlayListWidget::populateVideoView() { 1015void PlayListWidget::populateVideoView() {
1011 videoView->clear(); 1016 videoView->clear();
1012 StorageInfo storageInfo; 1017 StorageInfo storageInfo;
1013 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1018 const QList<FileSystem> &fs = storageInfo.fileSystems();
1014 1019
1015 if(!videoScan ) scanForVideo(); 1020 if(!videoScan ) scanForVideo();
1016 1021
1017 QListIterator<DocLnk> Vdit( vFiles.children() ); 1022 QListIterator<DocLnk> Vdit( vFiles.children() );
1018 QListIterator<FileSystem> it ( fs ); 1023 QListIterator<FileSystem> it ( fs );
1019 videoView->clear(); 1024 videoView->clear();
1020 QString storage; 1025 QString storage;
1021 for ( ; Vdit.current(); ++Vdit ) { 1026 for ( ; Vdit.current(); ++Vdit ) {
1022 for( ; it.current(); ++it ){ 1027 for( ; it.current(); ++it ){
1023 const QString name = (*it)->name(); 1028 const QString name = (*it)->name();
1024 const QString path = (*it)->path(); 1029 const QString path = (*it)->path();
1025 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1030 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1026 } 1031 }
1027 1032
1028 QListViewItem * newItem; 1033 QListViewItem * newItem;
1029 if ( QFile( Vdit.current()->file()).exists() ) { 1034 if ( QFile( Vdit.current()->file()).exists() ) {
1030 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1035 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1031 QString::number( QFile( Vdit.current()->file() ).size() ), 1036 QString::number( QFile( Vdit.current()->file() ).size() ),
1032 storage, Vdit.current()->file()); 1037 storage, Vdit.current()->file());
1033 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1038 newItem->setPixmap(0, Opie::Core::OResource::loadPixmap( "opieplayer/videofile", Opie::Core::OResource::SmallIcon ));
1034 } 1039 }
1035 } 1040 }
1036} 1041}
1037 1042
1038void PlayListWidget::openFile() { 1043void PlayListWidget::openFile() {
1039 QString filename, name; 1044 QString filename, name;
1040 InputDialog *fileDlg; 1045 InputDialog *fileDlg;
1041 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1046 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1042 fileDlg->exec(); 1047 fileDlg->exec();
1043 if( fileDlg->result() == 1 ) { 1048 if( fileDlg->result() == 1 ) {
1044 filename = fileDlg->text(); 1049 filename = fileDlg->text();
1045 // odebug << "Selected filename is " + filename << oendl; 1050 // odebug << "Selected filename is " + filename << oendl;
1046 DocLnk lnk; 1051 DocLnk lnk;
1047 Config cfg( "OpiePlayer" ); 1052 Config cfg( "OpiePlayer" );
1048 cfg.setGroup("PlayList"); 1053 cfg.setGroup("PlayList");
1049 1054
1050 QString m3uFile; 1055 QString m3uFile;
1051 m3uFile = filename; 1056 m3uFile = filename;
1052 if(filename.left(4) == "http") { 1057 if(filename.left(4) == "http") {
1053 if(filename.find(":",8,TRUE) != -1) { //found a port 1058 if(filename.find(":",8,TRUE) != -1) { //found a port
1054 1059
1055 m3uFile = filename; 1060 m3uFile = filename;
1056 if( m3uFile.right( 1 ).find( '/' ) == -1) { 1061 if( m3uFile.right( 1 ).find( '/' ) == -1) {
1057 m3uFile += "/"; 1062 m3uFile += "/";
1058 } 1063 }
1059 filename = m3uFile; 1064 filename = m3uFile;
1060 } 1065 }
1061 lnk.setName( m3uFile ); //sets name 1066 lnk.setName( m3uFile ); //sets name
1062 lnk.setFile( filename ); //sets file name 1067 lnk.setFile( filename ); //sets file name
1063 lnk.setIcon("opieplayer2/musicfile"); 1068 lnk.setIcon("opieplayer2/musicfile");
1064 d->selectedFiles->addToSelection( lnk ); 1069 d->selectedFiles->addToSelection( lnk );
1065 writeCurrentM3u(); 1070 writeCurrentM3u();
1066 } 1071 }
1067 else if( filename.right( 3) == "m3u" ) { 1072 else if( filename.right( 3) == "m3u" ) {
1068 readm3u( filename ); 1073 readm3u( filename );
1069 1074
1070 } else if( filename.right(3) == "pls" ) { 1075 } else if( filename.right(3) == "pls" ) {
1071 readPls( filename ); 1076 readPls( filename );
1072 } else { 1077 } else {
1073 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1078 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1074 lnk.setFile( filename ); //sets file name 1079 lnk.setFile( filename ); //sets file name
1075 d->selectedFiles->addToSelection( lnk); 1080 d->selectedFiles->addToSelection( lnk);
1076 lnk.removeLinkFile(); 1081 lnk.removeLinkFile();
1077 writeCurrentM3u(); 1082 writeCurrentM3u();
1078 } 1083 }
1079 } 1084 }
1080 1085
1081 if( fileDlg ) { 1086 if( fileDlg ) {
1082 delete fileDlg; 1087 delete fileDlg;
1083 } 1088 }
1084} 1089}
1085 1090
1086 1091
1087/* 1092/*
1088reads m3u and shows files/urls to playlist widget */ 1093reads m3u and shows files/urls to playlist widget */
1089void PlayListWidget::readm3u( const QString &filename ) { 1094void PlayListWidget::readm3u( const QString &filename ) {
1090 // odebug << "read m3u filename " + filename << oendl; 1095 // odebug << "read m3u filename " + filename << oendl;
1091 1096
1092 Om3u *m3uList; 1097 Om3u *m3uList;
1093 QString s, name; 1098 QString s, name;
1094 m3uList = new Om3u( filename, IO_ReadOnly ); 1099 m3uList = new Om3u( filename, IO_ReadOnly );
1095 m3uList->readM3u(); 1100 m3uList->readM3u();
1096 DocLnk lnk; 1101 DocLnk lnk;
1097 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1102 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1098 s = *it; 1103 s = *it;
1099 // odebug << "reading "+ s << oendl; 1104 // odebug << "reading "+ s << oendl;
1100 if(s.left(4)=="http") { 1105 if(s.left(4)=="http") {
1101 lnk.setName( s ); //sets file name 1106 lnk.setName( s ); //sets file name
1102 lnk.setIcon("opieplayer2/musicfile"); 1107 lnk.setIcon("opieplayer2/musicfile");
1103 1108
1104 // if(s.right(4) != '.' || s.right(5) != '.') 1109 // if(s.right(4) != '.' || s.right(5) != '.')
1105 if(s.right(4) != '.' || s.right(5) != '.' ) 1110 if(s.right(4) != '.' || s.right(5) != '.' )
1106 if( s.right(1) != "/") 1111 if( s.right(1) != "/")
1107 lnk.setFile( s+"/"); //if url with no extension 1112 lnk.setFile( s+"/"); //if url with no extension
1108 else 1113 else
1109 lnk.setFile( s ); //sets file name 1114 lnk.setFile( s ); //sets file name
1110 1115
1111 } else { 1116 } else {
1112 // if( QFileInfo( s ).exists() ) { 1117 // if( QFileInfo( s ).exists() ) {
1113 lnk.setName( fullBaseName ( QFileInfo(s))); 1118 lnk.setName( fullBaseName ( QFileInfo(s)));
1114 // if(s.right(4) == '.') {//if regular file 1119 // if(s.right(4) == '.') {//if regular file
1115 if(s.left(1) != "/") { 1120 if(s.left(1) != "/") {
1116 // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl; 1121 // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl;
1117 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1122 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1118 lnk.setIcon("SoundPlayer"); 1123 lnk.setIcon("SoundPlayer");
1119 } else { 1124 } else {
1120 // odebug << "set link2 "+s << oendl; 1125 // odebug << "set link2 "+s << oendl;
1121 lnk.setFile( s); 1126 lnk.setFile( s);
1122 lnk.setIcon("SoundPlayer"); 1127 lnk.setIcon("SoundPlayer");
1123 } 1128 }
1124 } 1129 }
1125 d->selectedFiles->addToSelection( lnk ); 1130 d->selectedFiles->addToSelection( lnk );
1126 } 1131 }
1127 Config config( "OpiePlayer" ); 1132 Config config( "OpiePlayer" );
1128 config.setGroup( "PlayList" ); 1133 config.setGroup( "PlayList" );
1129 1134
1130 config.writeEntry("CurrentPlaylist",filename); 1135 config.writeEntry("CurrentPlaylist",filename);
1131 config.write(); 1136 config.write();
1132 currentPlayList=filename; 1137 currentPlayList=filename;
1133 1138
1134// m3uList->write(); 1139// m3uList->write();
1135 m3uList->close(); 1140 m3uList->close();
1136 if(m3uList) delete m3uList; 1141 if(m3uList) delete m3uList;
1137 1142
1138 d->selectedFiles->setSelectedItem( s); 1143 d->selectedFiles->setSelectedItem( s);
1139 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); 1144 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1140 1145
1141} 1146}
1142 1147
1143/* 1148/*
1144reads pls and adds files/urls to playlist */ 1149reads pls and adds files/urls to playlist */
1145void PlayListWidget::readPls( const QString &filename ) { 1150void PlayListWidget::readPls( const QString &filename ) {
1146 1151
1147 // odebug << "pls filename is " + filename << oendl; 1152 // odebug << "pls filename is " + filename << oendl;
1148 Om3u *m3uList; 1153 Om3u *m3uList;
1149 QString s, name; 1154 QString s, name;
1150 m3uList = new Om3u( filename, IO_ReadOnly ); 1155 m3uList = new Om3u( filename, IO_ReadOnly );
1151 m3uList->readPls(); 1156 m3uList->readPls();
1152 1157
1153 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1158 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1154 s = *it; 1159 s = *it;
1155 // s.replace( QRegExp( "%20" )," " ); 1160 // s.replace( QRegExp( "%20" )," " );
1156 DocLnk lnk( s ); 1161 DocLnk lnk( s );
1157 QFileInfo f( s ); 1162 QFileInfo f( s );
1158 QString name = fullBaseName ( f); 1163 QString name = fullBaseName ( f);
1159 1164
1160 if( name.left( 4 ) == "http" ) { 1165 if( name.left( 4 ) == "http" ) {
1161 name = s.right( s.length() - 7); 1166 name = s.right( s.length() - 7);
1162 } else { 1167 } else {
1163 name = s; 1168 name = s;
1164 } 1169 }
1165 1170
1166 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1171 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1167 1172
1168 lnk.setName( name ); 1173 lnk.setName( name );
1169 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1174 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1170 lnk.setFile( s ); 1175 lnk.setFile( s );
1171 } else { //if its a url 1176 } else { //if its a url
1172 if( name.right( 1 ).find( '/' ) == -1) { 1177 if( name.right( 1 ).find( '/' ) == -1) {
1173 s += "/"; 1178 s += "/";
1174 } 1179 }
1175 lnk.setFile( s ); 1180 lnk.setFile( s );
1176 } 1181 }
1177 lnk.setType( "audio/x-mpegurl" ); 1182 lnk.setType( "audio/x-mpegurl" );
1178 1183
1179 lnk.writeLink(); 1184 lnk.writeLink();
1180 d->selectedFiles->addToSelection( lnk ); 1185 d->selectedFiles->addToSelection( lnk );
1181 } 1186 }
1182 1187
1183 m3uList->close(); 1188 m3uList->close();
1184 if(m3uList) delete m3uList; 1189 if(m3uList) delete m3uList;
1185} 1190}
1186 1191
1187/* 1192/*
1188 writes current playlist to current m3u file */ 1193 writes current playlist to current m3u file */
1189void PlayListWidget::writeCurrentM3u() { 1194void PlayListWidget::writeCurrentM3u() {
1190 // odebug << "writing to current m3u" << oendl; 1195 // odebug << "writing to current m3u" << oendl;
1191 Config cfg( "OpiePlayer" ); 1196 Config cfg( "OpiePlayer" );
1192 cfg.setGroup("PlayList"); 1197 cfg.setGroup("PlayList");
1193 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 1198 currentPlayList = cfg.readEntry("CurrentPlaylist","");
1194 Om3u *m3uList; 1199 Om3u *m3uList;
1195 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); 1200 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate );
1196 1201
1197 if( d->selectedFiles->first()) { 1202 if( d->selectedFiles->first()) {
1198 do { 1203 do {
1199 // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; 1204 // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl;
1200 m3uList->add( d->selectedFiles->current()->file() ); 1205 m3uList->add( d->selectedFiles->current()->file() );
1201 } 1206 }
1202 while ( d->selectedFiles->next() ); 1207 while ( d->selectedFiles->next() );
1203 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; 1208 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl;
1204 m3uList->write(); 1209 m3uList->write();
1205 m3uList->close(); 1210 m3uList->close();
1206 1211
1207 if(m3uList) delete m3uList; 1212 if(m3uList) delete m3uList;
1208 } 1213 }
1209} 1214}
1210 1215
1211 /* 1216 /*
1212 writes current playlist to m3u file */ 1217 writes current playlist to m3u file */
1213void PlayListWidget::writem3u() { 1218void PlayListWidget::writem3u() {
1214 InputDialog *fileDlg; 1219 InputDialog *fileDlg;
1215 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1220 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1216 fileDlg->exec(); 1221 fileDlg->exec();
1217 QString name, filename, list; 1222 QString name, filename, list;
1218 Om3u *m3uList; 1223 Om3u *m3uList;
1219 1224
1220 if( fileDlg->result() == 1 ) { 1225 if( fileDlg->result() == 1 ) {
1221 name = fileDlg->text(); 1226 name = fileDlg->text();
1222 // odebug << filename << oendl; 1227 // odebug << filename << oendl;
1223 if( name.find("/",0,true) != -1) {// assume they specify a file path 1228 if( name.find("/",0,true) != -1) {// assume they specify a file path
1224 filename = name; 1229 filename = name;
1225 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 1230 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1226 } 1231 }
1227 else //otherwise dump it somewhere noticable 1232 else //otherwise dump it somewhere noticable
1228 filename = QPEApplication::documentDir() + "/" + name; 1233 filename = QPEApplication::documentDir() + "/" + name;
1229 1234
1230 if( filename.right( 3 ) != "m3u" ) //needs filename extension 1235 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1231 filename += ".m3u"; 1236 filename += ".m3u";
1232 1237
1233 if( d->selectedFiles->first()) { 1238 if( d->selectedFiles->first()) {
1234 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 1239 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
1235 1240
1236 do { 1241 do {
1237 m3uList->add( d->selectedFiles->current()->file()); 1242 m3uList->add( d->selectedFiles->current()->file());
1238 } 1243 }
1239 while ( d->selectedFiles->next() ); 1244 while ( d->selectedFiles->next() );
1240 // odebug << list << oendl; 1245 // odebug << list << oendl;
1241 m3uList->write(); 1246 m3uList->write();
1242 m3uList->close(); 1247 m3uList->close();
1243 if(m3uList) delete m3uList; 1248 if(m3uList) delete m3uList;
1244 1249
1245 if(fileDlg) delete fileDlg; 1250 if(fileDlg) delete fileDlg;
1246 1251
1247 DocLnk lnk; 1252 DocLnk lnk;
1248 lnk.setFile( filename); 1253 lnk.setFile( filename);
1249 lnk.setIcon("opieplayer2/playlist2"); 1254 lnk.setIcon("opieplayer2/playlist2");
1250 lnk.setName( name); //sets file name 1255 lnk.setName( name); //sets file name
1251 1256
1252 // odebug << filename << oendl; 1257 // odebug << filename << oendl;
1253 Config config( "OpiePlayer" ); 1258 Config config( "OpiePlayer" );
1254 config.setGroup( "PlayList" ); 1259 config.setGroup( "PlayList" );
1255 1260
1256 config.writeEntry("CurrentPlaylist",filename); 1261 config.writeEntry("CurrentPlaylist",filename);
1257 currentPlayList=filename; 1262 currentPlayList=filename;
1258 1263
1259 if(!lnk.writeLink()) { 1264 if(!lnk.writeLink()) {
1260 // odebug << "Writing doclink did not work" << oendl; 1265 // odebug << "Writing doclink did not work" << oendl;
1261 } 1266 }
1262 1267
1263 setCaption(tr("OpiePlayer: ") + name); 1268 setCaption(tr("OpiePlayer: ") + name);
1264 } 1269 }
1265 } 1270 }
1266} 1271}
1267 1272
1268 1273
1269void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1274void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1270{ 1275{
1271 switch ( e->key() ) { 1276 switch ( e->key() ) {
1272////////////////////////////// Zaurus keys 1277////////////////////////////// Zaurus keys
1273 case Key_F9: //activity 1278 case Key_F9: //activity
1274// if(audioUI->isHidden()) 1279// if(audioUI->isHidden())
1275// audioUI->showMaximized(); 1280// audioUI->showMaximized();
1276 break; 1281 break;
1277 case Key_F10: //contacts 1282 case Key_F10: //contacts
1278// if( videoUI->isHidden()) 1283// if( videoUI->isHidden())
1279// videoUI->showMaximized(); 1284// videoUI->showMaximized();
1280 break; 1285 break;
1281 case Key_F11: //menu 1286 case Key_F11: //menu
1282 break; 1287 break;
1283 case Key_F12: //home 1288 case Key_F12: //home
1284// doBlank(); 1289// doBlank();
1285 break; 1290 break;
1286 case Key_F13: //mail 1291 case Key_F13: //mail
1287// doUnblank(); 1292// doUnblank();
1288 break; 1293 break;
1289 case Key_Q: //add to playlist 1294 case Key_Q: //add to playlist
1290 addSelected(); 1295 addSelected();
1291 break; 1296 break;
1292 case Key_R: //remove from playlist 1297 case Key_R: //remove from playlist
1293 removeSelected(); 1298 removeSelected();
1294 break; 1299 break;
1295// case Key_P: //play 1300// case Key_P: //play
1296// odebug << "Play" << oendl; 1301// odebug << "Play" << oendl;
1297// playSelected(); 1302// playSelected();
1298// break; 1303// break;
1299 case Key_Space: 1304 case Key_Space:
1300// playSelected(); puh 1305// playSelected(); puh
1301 break; 1306 break;
1302 case Key_1: 1307 case Key_1:
1303 tabWidget->setCurrentPage(0); 1308 tabWidget->setCurrentPage(0);
1304 break; 1309 break;
1305 case Key_2: 1310 case Key_2:
1306 tabWidget->setCurrentPage(1); 1311 tabWidget->setCurrentPage(1);
1307 break; 1312 break;
1308 case Key_3: 1313 case Key_3:
1309 tabWidget->setCurrentPage(2); 1314 tabWidget->setCurrentPage(2);
1310 break; 1315 break;
1311 case Key_4: 1316 case Key_4:
1312 tabWidget->setCurrentPage(3); 1317 tabWidget->setCurrentPage(3);
1313 break; 1318 break;
1314 case Key_Down: 1319 case Key_Down:
1315 if ( !d->selectedFiles->next() ) 1320 if ( !d->selectedFiles->next() )
1316 d->selectedFiles->first(); 1321 d->selectedFiles->first();
1317 1322
1318 break; 1323 break;
1319 case Key_Up: 1324 case Key_Up:
1320 if ( !d->selectedFiles->prev() ) 1325 if ( !d->selectedFiles->prev() )
1321 // d->selectedFiles->last(); 1326 // d->selectedFiles->last();
1322 1327
1323 break; 1328 break;
1324 1329
1325 } 1330 }
1326} 1331}
1327 1332
1328void PlayListWidget::keyPressEvent( QKeyEvent *) 1333void PlayListWidget::keyPressEvent( QKeyEvent *)
1329{ 1334{
1330// odebug << "Key press" << oendl; 1335// odebug << "Key press" << oendl;
1331// switch ( e->key() ) { 1336// switch ( e->key() ) {
1332// ////////////////////////////// Zaurus keys 1337// ////////////////////////////// Zaurus keys
1333// case Key_A: //add to playlist 1338// case Key_A: //add to playlist
1334// odebug << "Add" << oendl; 1339// odebug << "Add" << oendl;
1335// addSelected(); 1340// addSelected();
1336// break; 1341// break;
1337// case Key_R: //remove from playlist 1342// case Key_R: //remove from playlist
1338// removeSelected(); 1343// removeSelected();
1339// break; 1344// break;
1340// case Key_P: //play 1345// case Key_P: //play
1341// odebug << "Play" << oendl; 1346// odebug << "Play" << oendl;
1342// playSelected(); 1347// playSelected();
1343// break; 1348// break;
1344// case Key_Space: 1349// case Key_Space:
1345// odebug << "Play" << oendl; 1350// odebug << "Play" << oendl;
1346// playSelected(); 1351// playSelected();
1347// break; 1352// break;
1348// } 1353// }
1349} 1354}
1350 1355
1351void PlayListWidget::doBlank() { 1356void PlayListWidget::doBlank() {
1352 // odebug << "do blanking" << oendl; 1357 // odebug << "do blanking" << oendl;
1353#ifdef QT_QWS_DEVFS 1358#ifdef QT_QWS_DEVFS
1354 fd=open("/dev/fb/0",O_RDWR); 1359 fd=open("/dev/fb/0",O_RDWR);
1355#else 1360#else
1356 fd=open("/dev/fb0",O_RDWR); 1361 fd=open("/dev/fb0",O_RDWR);
1357#endif 1362#endif
1358 if (fd != -1) { 1363 if (fd != -1) {
1359 ioctl(fd,FBIOBLANK,1); 1364 ioctl(fd,FBIOBLANK,1);
1360 // close(fd); 1365 // close(fd);
1361 } 1366 }
1362} 1367}
1363 1368
1364void PlayListWidget::doUnblank() { 1369void PlayListWidget::doUnblank() {
1365 // this crashes opieplayer with a segfault 1370 // this crashes opieplayer with a segfault
1366 // int fd; 1371 // int fd;
1367 // fd=open("/dev/fb0",O_RDWR); 1372 // fd=open("/dev/fb0",O_RDWR);
1368 // odebug << "do unblanking" << oendl; 1373 // odebug << "do unblanking" << oendl;
1369 if (fd != -1) { 1374 if (fd != -1) {
1370 ioctl(fd,FBIOBLANK,0); 1375 ioctl(fd,FBIOBLANK,0);
1371 close(fd); 1376 close(fd);
1372 } 1377 }
1373 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1378 QCopEnvelope h("QPE/System", "setBacklight(int)");
1374 h <<-3;// v[1]; // -3 Force on 1379 h <<-3;// v[1]; // -3 Force on
1375} 1380}
1376 1381
1377void PlayListWidget::populateSkinsMenu() { 1382void PlayListWidget::populateSkinsMenu() {
1378 int item = 0; 1383 int item = 0;
1379 defaultSkinIndex = 0; 1384 defaultSkinIndex = 0;
1380 QString skinName; 1385 QString skinName;
1381 Config cfg( "OpiePlayer" ); 1386 Config cfg( "OpiePlayer" );
1382 cfg.setGroup("Options" ); 1387 cfg.setGroup("Options" );
1383 QString skin = cfg.readEntry( "Skin", "default" ); 1388 QString skin = cfg.readEntry( "Skin", "default" );
1384 1389
1385 QDir skinsDir( QPEApplication::qpeDir() + "pics/opieplayer2/skins" ); 1390 QDir skinsDir( QPEApplication::qpeDir() + "pics/opieplayer2/skins" );
1386 skinsDir.setFilter( QDir::Dirs ); 1391 skinsDir.setFilter( QDir::Dirs );
1387 skinsDir.setSorting(QDir::Name ); 1392 skinsDir.setSorting(QDir::Name );
1388 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1393 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1389 QFileInfoListIterator it( *skinslist ); 1394 QFileInfoListIterator it( *skinslist );
1390 QFileInfo *fi; 1395 QFileInfo *fi;
1391 while ( ( fi = it.current() ) ) { 1396 while ( ( fi = it.current() ) ) {
1392 skinName = fi->fileName(); 1397 skinName = fi->fileName();
1393 // odebug << fi->fileName() << oendl; 1398 // odebug << fi->fileName() << oendl;
1394 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1399 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1395 item = skinsMenu->insertItem( fi->fileName() ) ; 1400 item = skinsMenu->insertItem( fi->fileName() ) ;
1396 } 1401 }
1397 if( skinName == "default" ) { 1402 if( skinName == "default" ) {
1398 defaultSkinIndex = item; 1403 defaultSkinIndex = item;
1399 } 1404 }
1400 if( skinName == skin ) { 1405 if( skinName == skin ) {
1401 skinsMenu->setItemChecked( item, TRUE ); 1406 skinsMenu->setItemChecked( item, TRUE );
1402 } 1407 }
1403 ++it; 1408 ++it;
1404 } 1409 }
1405} 1410}
1406 1411
1407void PlayListWidget::skinsMenuActivated( int item ) { 1412void PlayListWidget::skinsMenuActivated( int item ) {
1408 for( int i = defaultSkinIndex; i > defaultSkinIndex - static_cast<int>(skinsMenu->count()); i-- ) { 1413 for( int i = defaultSkinIndex; i > defaultSkinIndex - static_cast<int>(skinsMenu->count()); i-- ) {
1409 skinsMenu->setItemChecked( i, FALSE ); 1414 skinsMenu->setItemChecked( i, FALSE );
1410 } 1415 }
1411 skinsMenu->setItemChecked( item, TRUE ); 1416 skinsMenu->setItemChecked( item, TRUE );
1412 1417
1413 Config cfg( "OpiePlayer" ); 1418 Config cfg( "OpiePlayer" );
1414 cfg.setGroup("Options"); 1419 cfg.setGroup("Options");
1415 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1420 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1416} 1421}
1417 1422
1418void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1423void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1419 // odebug << "qcop message "+msg << oendl; 1424 // odebug << "qcop message "+msg << oendl;
1420 QDataStream stream ( data, IO_ReadOnly ); 1425 QDataStream stream ( data, IO_ReadOnly );
1421 if ( msg == "play()" ) { //plays current selection 1426 if ( msg == "play()" ) { //plays current selection
1422 btnPlay( true); 1427 btnPlay( true);
1423 } else if ( msg == "stop()" ) { 1428 } else if ( msg == "stop()" ) {
1424 mediaPlayerState->setPlaying( false); 1429 mediaPlayerState->setPlaying( false);
1425 } else if ( msg == "togglePause()" ) { 1430 } else if ( msg == "togglePause()" ) {
1426 mediaPlayerState->togglePaused(); 1431 mediaPlayerState->togglePaused();
1427 } else if ( msg == "next()" ) { //select next in lis 1432 } else if ( msg == "next()" ) { //select next in lis
1428 mediaPlayerState->setNext(); 1433 mediaPlayerState->setNext();
1429 } else if ( msg == "prev()" ) { //select previous in list 1434 } else if ( msg == "prev()" ) { //select previous in list
1430 mediaPlayerState->setPrev(); 1435 mediaPlayerState->setPrev();
1431 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1436 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1432 mediaPlayerState->toggleLooping(); 1437 mediaPlayerState->toggleLooping();
1433 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1438 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1434 mediaPlayerState->toggleShuffled(); 1439 mediaPlayerState->toggleShuffled();
1435 } else if ( msg == "volUp()" ) { //volume more 1440 } else if ( msg == "volUp()" ) { //volume more
1436 // emit moreClicked(); 1441 // emit moreClicked();
1437 // emit moreReleased(); 1442 // emit moreReleased();
1438 } else if ( msg == "volDown()" ) { //volume less 1443 } else if ( msg == "volDown()" ) { //volume less
1439 // emit lessClicked(); 1444 // emit lessClicked();
1440 // emit lessReleased(); 1445 // emit lessReleased();
1441 } else if ( msg == "play(QString)" ) { //play this now 1446 } else if ( msg == "play(QString)" ) { //play this now
1442 QString file; 1447 QString file;
1443 stream >> file; 1448 stream >> file;
1444 setDocumentEx( (const QString &) file); 1449 setDocumentEx( (const QString &) file);
1445 } else if ( msg == "add(QString)" ) { //add to playlist 1450 } else if ( msg == "add(QString)" ) { //add to playlist
1446 QString file; 1451 QString file;
1447 stream >> file; 1452 stream >> file;
1448 QFileInfo fileInfo(file); 1453 QFileInfo fileInfo(file);
1449 DocLnk lnk; 1454 DocLnk lnk;
1450 lnk.setName( fileInfo.baseName() ); //sets name 1455 lnk.setName( fileInfo.baseName() ); //sets name
1451 lnk.setFile( file ); //sets file name 1456 lnk.setFile( file ); //sets file name
1452 addToSelection( lnk ); 1457 addToSelection( lnk );
1453 } else if ( msg == "rem(QString)" ) { //remove from playlist 1458 } else if ( msg == "rem(QString)" ) { //remove from playlist
1454 QString file; 1459 QString file;
1455 stream >> file; 1460 stream >> file;
1456 } else if ( msg == "setDocument(QString)" ) { //loop or not loop 1461 } else if ( msg == "setDocument(QString)" ) { //loop or not loop
1457 QCopEnvelope h("QPE/Application/opieplayer", "raise()"); 1462 QCopEnvelope h("QPE/Application/opieplayer", "raise()");
1458 } 1463 }
1459} 1464}
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index c545511..89dd89e 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,680 +1,681 @@
1/********************************************************************** 1/**********************************************************************
2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3 ** 3 **
4 ** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5 ** 5 **
6 ** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file. 9 ** packaging of this file.
10 ** 10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ** 13 **
14 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 14 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
15 ** 15 **
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
20 20
21#include "videowidget.h" 21#include "videowidget.h"
22#include "mediaplayerstate.h" 22#include "mediaplayerstate.h"
23 23
24/* OPIE */ 24/* OPIE */
25#include <qpe/resource.h>
26#include <qpe/mediaplayerplugininterface.h> 25#include <qpe/mediaplayerplugininterface.h>
27#include <qpe/config.h> 26#include <qpe/config.h>
28#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
29#include <opie2/odebug.h> 28#include <opie2/odebug.h>
29#include <opie2/oresource.h>
30 30
31/* QT */ 31/* QT */
32#include <qbitmap.h>
32#include <qdir.h> 33#include <qdir.h>
33#include <qslider.h> 34#include <qslider.h>
34 35
35 36
36#ifdef Q_WS_QWS 37#ifdef Q_WS_QWS
37# define USE_DIRECT_PAINTER 38# define USE_DIRECT_PAINTER
38# include <qdirectpainter_qws.h> 39# include <qdirectpainter_qws.h>
39# include <qgfxraster_qws.h> 40# include <qgfxraster_qws.h>
40#endif 41#endif
41 42
42 43
43extern MediaPlayerState *mediaPlayerState; 44extern MediaPlayerState *mediaPlayerState;
44 45
45 46
46static const int xo = 2; // movable x offset 47static const int xo = 2; // movable x offset
47static const int yo = 0; // movable y offset 48static const int yo = 0; // movable y offset
48 49
49 50
50struct MediaButton { 51struct MediaButton {
51// int xPos, yPos; 52// int xPos, yPos;
52 bool isToggle, isHeld, isDown; 53 bool isToggle, isHeld, isDown;
53// int controlType; 54// int controlType;
54}; 55};
55 56
56 57
57// Layout information for the videoButtons (and if it is a toggle button or not) 58// Layout information for the videoButtons (and if it is a toggle button or not)
58MediaButton videoButtons[] = { 59MediaButton videoButtons[] = {
59 { FALSE, FALSE, FALSE }, // stop 60 { FALSE, FALSE, FALSE }, // stop
60 { FALSE, FALSE, FALSE }, // play 61 { FALSE, FALSE, FALSE }, // play
61 { FALSE, FALSE, FALSE }, // previous 62 { FALSE, FALSE, FALSE }, // previous
62 { FALSE, FALSE, FALSE }, // next 63 { FALSE, FALSE, FALSE }, // next
63 { FALSE, FALSE, FALSE }, // volUp 64 { FALSE, FALSE, FALSE }, // volUp
64 { FALSE, FALSE, FALSE }, // volDown 65 { FALSE, FALSE, FALSE }, // volDown
65 { TRUE, FALSE, FALSE } // fullscreen 66 { TRUE, FALSE, FALSE } // fullscreen
66}; 67};
67 68
68//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 69//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
69 70
70const char *skinV_mask_file_names[7] = { 71const char *skinV_mask_file_names[7] = {
71 "stop","play","back","fwd","up","down","full" 72 "stop","play","back","fwd","up","down","full"
72}; 73};
73 74
74static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 75static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
75 76
76VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 77VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
77 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) 78 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 )
78{ 79{
79 setCaption( tr("OpiePlayer") ); 80 setCaption( tr("OpiePlayer") );
80 Config cfg("OpiePlayer"); 81 Config cfg("OpiePlayer");
81 82
82 cfg.setGroup("Options"); 83 cfg.setGroup("Options");
83 skin = cfg.readEntry("Skin","default"); 84 skin = cfg.readEntry("Skin","default");
84 85
85 QString skinPath; 86 QString skinPath;
86 skinPath = "opieplayer2/skins/" + skin; 87 skinPath = "opieplayer2/skins/" + skin;
87 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) 88 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
88 skinPath = "opieplayer2/skins/default"; 89 skinPath = "opieplayer2/skins/default";
89 90
90 91
91// QString skinPath = "opieplayer2/skins/" + skin; 92// QString skinPath = "opieplayer2/skins/" + skin;
92 93
93 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 94 pixBg = new QPixmap( Opie::Core::OResource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 95 imgUp = new QImage( Opie::Core::OResource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 96 imgDn = new QImage( Opie::Core::OResource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96 97
97 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 98 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
98 imgButtonMask->fill( 0 ); 99 imgButtonMask->fill( 0 );
99 100
100 for ( int i = 0; i < 7; i++ ) { 101 for ( int i = 0; i < 7; i++ ) {
101 QString filename = QString( QPEApplication::qpeDir() + "pics/" + skinPath + 102 QString filename = QString( QPEApplication::qpeDir() + "pics/" + skinPath +
102 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 103 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
103 // odebug << "loading "+filename << oendl; 104 // odebug << "loading "+filename << oendl;
104 masks[i] = new QBitmap( filename ); 105 masks[i] = new QBitmap( filename );
105 106
106 if ( !masks[i]->isNull() ) { 107 if ( !masks[i]->isNull() ) {
107 QImage imgMask = masks[i]->convertToImage(); 108 QImage imgMask = masks[i]->convertToImage();
108 uchar **dest = imgButtonMask->jumpTable(); 109 uchar **dest = imgButtonMask->jumpTable();
109 for ( int y = 0; y < imgUp->height(); y++ ) { 110 for ( int y = 0; y < imgUp->height(); y++ ) {
110 uchar *line = dest[y]; 111 uchar *line = dest[y];
111 for ( int x = 0; x < imgUp->width(); x++ ) { 112 for ( int x = 0; x < imgUp->width(); x++ ) {
112 if ( !qRed( imgMask.pixel( x, y ) ) ) 113 if ( !qRed( imgMask.pixel( x, y ) ) )
113 line[x] = i + 1; 114 line[x] = i + 1;
114 } 115 }
115 } 116 }
116 } 117 }
117 } 118 }
118 for ( int i = 0; i < 7; i++ ) { 119 for ( int i = 0; i < 7; i++ ) {
119 buttonPixUp[i] = NULL; 120 buttonPixUp[i] = NULL;
120 buttonPixDown[i] = NULL; 121 buttonPixDown[i] = NULL;
121 } 122 }
122 123
123 QWidget *d = QApplication::desktop(); 124 QWidget *d = QApplication::desktop();
124 int width = d->width(); 125 int width = d->width();
125 int height = d->height(); 126 int height = d->height();
126 127
127 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { 128 if( (width != pixBg->width() ) || (height != pixBg->height() ) ) {
128 QImage img; 129 QImage img;
129 img = pixBg->convertToImage(); 130 img = pixBg->convertToImage();
130 pixBg->convertFromImage( img.smoothScale( width, height)); 131 pixBg->convertFromImage( img.smoothScale( width, height));
131 } 132 }
132 133
133 setBackgroundPixmap( *pixBg ); 134 setBackgroundPixmap( *pixBg );
134 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 135 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
135 slider = new QSlider( Qt::Horizontal, this ); 136 slider = new QSlider( Qt::Horizontal, this );
136 slider->setMinValue( 0 ); 137 slider->setMinValue( 0 );
137 slider->setMaxValue( 1 ); 138 slider->setMaxValue( 1 );
138 139
139 slider->setBackgroundPixmap( *pixBg ); 140 slider->setBackgroundPixmap( *pixBg );
140 slider->setFocusPolicy( QWidget::NoFocus ); 141 slider->setFocusPolicy( QWidget::NoFocus );
141// slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 142// slider->setGeometry( QRect( 7, 250, 220, 20 ) );
142 143
143 connect(slider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); 144 connect(slider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
144 connect(slider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); 145 connect(slider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
145 146
146 connect(mediaPlayerState,SIGNAL(lengthChanged(long)),this,SLOT(setLength(long))); 147 connect(mediaPlayerState,SIGNAL(lengthChanged(long)),this,SLOT(setLength(long)));
147 connect(mediaPlayerState,SIGNAL(positionChanged(long)),this,SLOT(setPosition(long))); 148 connect(mediaPlayerState,SIGNAL(positionChanged(long)),this,SLOT(setPosition(long)));
148 connect(mediaPlayerState,SIGNAL(positionUpdated(long)),this,SLOT(setPosition(long))); 149 connect(mediaPlayerState,SIGNAL(positionUpdated(long)),this,SLOT(setPosition(long)));
149 connect(mediaPlayerState,SIGNAL(viewChanged(char)),this,SLOT(setView(char))); 150 connect(mediaPlayerState,SIGNAL(viewChanged(char)),this,SLOT(setView(char)));
150// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 151// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
151 connect(mediaPlayerState,SIGNAL(playingToggled(bool)),this,SLOT(setPlaying(bool))); 152 connect(mediaPlayerState,SIGNAL(playingToggled(bool)),this,SLOT(setPlaying(bool)));
152 153
153 // Intialise state 154 // Intialise state
154 setLength( mediaPlayerState->length() ); 155 setLength( mediaPlayerState->length() );
155 setPosition( mediaPlayerState->position() ); 156 setPosition( mediaPlayerState->position() );
156 setFullscreen( mediaPlayerState->fullscreen() ); 157 setFullscreen( mediaPlayerState->fullscreen() );
157// setPlaying( mediaPlayerState->playing() ); 158// setPlaying( mediaPlayerState->playing() );
158 // if(this->x() < 0 || this->y() < 0) 159 // if(this->x() < 0 || this->y() < 0)
159 // this->move(0,0); 160 // this->move(0,0);
160} 161}
161 162
162 163
163VideoWidget::~VideoWidget() { 164VideoWidget::~VideoWidget() {
164 165
165 for ( int i = 0; i < 7; i++ ) 166 for ( int i = 0; i < 7; i++ )
166 { 167 {
167 delete buttonPixUp[i]; 168 delete buttonPixUp[i];
168 delete buttonPixDown[i]; 169 delete buttonPixDown[i];
169 } 170 }
170 171
171 delete pixBg; 172 delete pixBg;
172 delete imgUp; 173 delete imgUp;
173 delete imgDn; 174 delete imgDn;
174 delete imgButtonMask; 175 delete imgButtonMask;
175 for ( int i = 0; i < 7; i++ ) 176 for ( int i = 0; i < 7; i++ )
176 { 177 {
177 delete masks[i]; 178 delete masks[i];
178 } 179 }
179 180
180// for ( int i = 0; i < 3; i++ ) 181// for ( int i = 0; i < 3; i++ )
181// delete pixmaps[i]; 182// delete pixmaps[i];
182// delete currentFrame; 183// delete currentFrame;
183} 184}
184 185
185 186
186static bool videoSliderBeingMoved = FALSE; 187static bool videoSliderBeingMoved = FALSE;
187 188
188QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 189QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
189 QPixmap pix( img.width(), img.height() ); 190 QPixmap pix( img.width(), img.height() );
190 QPainter p( &pix ); 191 QPainter p( &pix );
191 p.drawTiledPixmap( pix.rect(), bg, offset ); 192 p.drawTiledPixmap( pix.rect(), bg, offset );
192 p.drawImage( 0, 0, img ); 193 p.drawImage( 0, 0, img );
193 return new QPixmap( pix ); 194 return new QPixmap( pix );
194} 195}
195 196
196QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 197QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
197 QPixmap *pixmap = new QPixmap( pix ); 198 QPixmap *pixmap = new QPixmap( pix );
198 pixmap->setMask( mask ); 199 pixmap->setMask( mask );
199 return pixmap; 200 return pixmap;
200} 201}
201 202
202void VideoWidget::resizeEvent( QResizeEvent * ) { 203void VideoWidget::resizeEvent( QResizeEvent * ) {
203 int h = height(); 204 int h = height();
204 int w = width(); 205 int w = width();
205 //int Vh = 160; 206 //int Vh = 160;
206 //int Vw = 220; 207 //int Vw = 220;
207 208
208 slider->setFixedWidth( w - 20 ); 209 slider->setFixedWidth( w - 20 );
209 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 210 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
210 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 211 slider->setBackgroundOrigin( QWidget::ParentOrigin );
211 slider->setFocusPolicy( QWidget::NoFocus ); 212 slider->setFocusPolicy( QWidget::NoFocus );
212 slider->setBackgroundPixmap( *pixBg ); 213 slider->setBackgroundPixmap( *pixBg );
213 214
214 xoff = 0;// ( imgUp->width() ) / 2; 215 xoff = 0;// ( imgUp->width() ) / 2;
215 if(w>h) 216 if(w>h)
216 yoff = 0; 217 yoff = 0;
217 else 218 else
218 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 219 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
219 QPoint p( xoff, yoff ); 220 QPoint p( xoff, yoff );
220 221
221 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 222 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
222 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 223 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
223 224
224 for ( int i = 0; i < 7; i++ ) 225 for ( int i = 0; i < 7; i++ )
225 { 226 {
226 if ( !masks[i]->isNull() ) 227 if ( !masks[i]->isNull() )
227 { 228 {
228 delete buttonPixUp[i]; 229 delete buttonPixUp[i];
229 delete buttonPixDown[i]; 230 delete buttonPixDown[i];
230 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 231 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
231 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 232 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
232 } 233 }
233 } 234 }
234 235
235 delete pixUp; 236 delete pixUp;
236 delete pixDn; 237 delete pixDn;
237} 238}
238 239
239 240
240void VideoWidget::sliderPressed() { 241void VideoWidget::sliderPressed() {
241 videoSliderBeingMoved = TRUE; 242 videoSliderBeingMoved = TRUE;
242} 243}
243 244
244 245
245void VideoWidget::sliderReleased() { 246void VideoWidget::sliderReleased() {
246 videoSliderBeingMoved = FALSE; 247 videoSliderBeingMoved = FALSE;
247 if ( slider->width() == 0 ) 248 if ( slider->width() == 0 )
248 return; 249 return;
249 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 250 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
250 mediaPlayerState->setPosition( val ); 251 mediaPlayerState->setPosition( val );
251} 252}
252 253
253 254
254void VideoWidget::setPosition( long i ) { 255void VideoWidget::setPosition( long i ) {
255 updateSlider( i, mediaPlayerState->length() ); 256 updateSlider( i, mediaPlayerState->length() );
256} 257}
257 258
258 259
259void VideoWidget::setLength( long max ) { 260void VideoWidget::setLength( long max ) {
260 updateSlider( mediaPlayerState->position(), max ); 261 updateSlider( mediaPlayerState->position(), max );
261} 262}
262 263
263 264
264void VideoWidget::setView( char view ) { 265void VideoWidget::setView( char view ) {
265 if ( view == 'v' ) 266 if ( view == 'v' )
266 { 267 {
267 makeVisible(); 268 makeVisible();
268 } 269 }
269 else 270 else
270 { 271 {
271 // Effectively blank the view next time we show it so it looks nicer 272 // Effectively blank the view next time we show it so it looks nicer
272 scaledWidth = 0; 273 scaledWidth = 0;
273 scaledHeight = 0; 274 scaledHeight = 0;
274 hide(); 275 hide();
275 } 276 }
276} 277}
277 278
278 279
279void VideoWidget::updateSlider( long i, long max ) { 280void VideoWidget::updateSlider( long i, long max ) {
280 // Will flicker too much if we don't do this 281 // Will flicker too much if we don't do this
281 if ( max == 0 ) 282 if ( max == 0 )
282 return; 283 return;
283 int width = slider->width(); 284 int width = slider->width();
284 int val = int((double)i * width / max); 285 int val = int((double)i * width / max);
285 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) 286 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved )
286 { 287 {
287 if ( slider->value() != val ) 288 if ( slider->value() != val )
288 slider->setValue( val ); 289 slider->setValue( val );
289 if ( slider->maxValue() != width ) 290 if ( slider->maxValue() != width )
290 slider->setMaxValue( width ); 291 slider->setMaxValue( width );
291 } 292 }
292} 293}
293 294
294 295
295void VideoWidget::setToggleButton( int i, bool down ) { 296void VideoWidget::setToggleButton( int i, bool down ) {
296 if ( down != videoButtons[i].isDown ) 297 if ( down != videoButtons[i].isDown )
297 toggleButton( i ); 298 toggleButton( i );
298} 299}
299 300
300 301
301void VideoWidget::toggleButton( int i ) { 302void VideoWidget::toggleButton( int i ) {
302 videoButtons[i].isDown = !videoButtons[i].isDown; 303 videoButtons[i].isDown = !videoButtons[i].isDown;
303 QPainter p(this); 304 QPainter p(this);
304 paintButton ( &p, i ); 305 paintButton ( &p, i );
305} 306}
306 307
307 308
308void VideoWidget::paintButton( QPainter *p, int i ) { 309void VideoWidget::paintButton( QPainter *p, int i ) {
309 if ( videoButtons[i].isDown ) 310 if ( videoButtons[i].isDown )
310 { 311 {
311 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 312 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
312 } 313 }
313 else 314 else
314 { 315 {
315 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 316 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
316 } 317 }
317} 318}
318 319
319 320
320void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 321void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
321 for ( int i = 0; i < numVButtons; i++ ) { 322 for ( int i = 0; i < numVButtons; i++ ) {
322 if ( event->state() == QMouseEvent::LeftButton ) { 323 if ( event->state() == QMouseEvent::LeftButton ) {
323 // The test to see if the mouse click is inside the button or not 324 // The test to see if the mouse click is inside the button or not
324 int x = event->pos().x() - xoff; 325 int x = event->pos().x() - xoff;
325 int y = event->pos().y() - yoff; 326 int y = event->pos().y() - yoff;
326 327
327 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 328 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
328 && y < imgButtonMask->height() 329 && y < imgButtonMask->height()
329 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 330 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
330 331
331 if ( isOnButton && !videoButtons[i].isHeld ) { 332 if ( isOnButton && !videoButtons[i].isHeld ) {
332 videoButtons[i].isHeld = TRUE; 333 videoButtons[i].isHeld = TRUE;
333 toggleButton(i); 334 toggleButton(i);
334 335
335 switch (i) { 336 switch (i) {
336 case VideoVolUp: 337 case VideoVolUp:
337 emit moreClicked(); 338 emit moreClicked();
338 return; 339 return;
339 case VideoVolDown: 340 case VideoVolDown:
340 emit lessClicked(); 341 emit lessClicked();
341 return; 342 return;
342 } 343 }
343 } else if ( !isOnButton && videoButtons[i].isHeld ) { 344 } else if ( !isOnButton && videoButtons[i].isHeld ) {
344 videoButtons[i].isHeld = FALSE; 345 videoButtons[i].isHeld = FALSE;
345 toggleButton(i); 346 toggleButton(i);
346 } 347 }
347 } else { 348 } else {
348 349
349 if ( videoButtons[i].isHeld ) { 350 if ( videoButtons[i].isHeld ) {
350 videoButtons[i].isHeld = FALSE; 351 videoButtons[i].isHeld = FALSE;
351 if ( !videoButtons[i].isToggle ) { 352 if ( !videoButtons[i].isToggle ) {
352 setToggleButton( i, FALSE ); 353 setToggleButton( i, FALSE );
353 } 354 }
354 355
355 switch(i) { 356 switch(i) {
356 357
357 case VideoPlay: { 358 case VideoPlay: {
358 // odebug << "play" << oendl; 359 // odebug << "play" << oendl;
359 if( !mediaPlayerState->playing()) { 360 if( !mediaPlayerState->playing()) {
360 mediaPlayerState->setPlaying( true); 361 mediaPlayerState->setPlaying( true);
361 setToggleButton( i-1, false ); 362 setToggleButton( i-1, false );
362 setToggleButton( i, false ); 363 setToggleButton( i, false );
363 return; 364 return;
364 } 365 }
365 if( mediaPlayerState->isPaused ) { 366 if( mediaPlayerState->isPaused ) {
366 // odebug << "isPaused" << oendl; 367 // odebug << "isPaused" << oendl;
367 setToggleButton( i, FALSE ); 368 setToggleButton( i, FALSE );
368 mediaPlayerState->setPaused( FALSE ); 369 mediaPlayerState->setPaused( FALSE );
369 return; 370 return;
370 } else if( !mediaPlayerState->isPaused ) { 371 } else if( !mediaPlayerState->isPaused ) {
371 // odebug << "is not paused" << oendl; 372 // odebug << "is not paused" << oendl;
372 setToggleButton( i, TRUE ); 373 setToggleButton( i, TRUE );
373 mediaPlayerState->setPaused( TRUE ); 374 mediaPlayerState->setPaused( TRUE );
374 return; 375 return;
375 } else { 376 } else {
376 return; 377 return;
377 } 378 }
378 } 379 }
379 380
380 case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; 381 case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return;
381 case VideoNext: mediaPlayerState->setNext(); return; 382 case VideoNext: mediaPlayerState->setNext(); return;
382 case VideoPrevious: mediaPlayerState->setPrev(); return; 383 case VideoPrevious: mediaPlayerState->setPrev(); return;
383 case VideoVolUp: emit moreReleased(); return; 384 case VideoVolUp: emit moreReleased(); return;
384 case VideoVolDown: emit lessReleased(); return; 385 case VideoVolDown: emit lessReleased(); return;
385 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 386 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
386 } 387 }
387 } 388 }
388 } 389 }
389 } 390 }
390} 391}
391 392
392 393
393void VideoWidget::mousePressEvent( QMouseEvent *event ) { 394void VideoWidget::mousePressEvent( QMouseEvent *event ) {
394 mouseMoveEvent( event ); 395 mouseMoveEvent( event );
395} 396}
396 397
397 398
398void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 399void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
399 if ( mediaPlayerState->fullscreen() ) 400 if ( mediaPlayerState->fullscreen() )
400 { 401 {
401 mediaPlayerState->setFullscreen( FALSE ); 402 mediaPlayerState->setFullscreen( FALSE );
402 makeVisible(); 403 makeVisible();
403 } 404 }
404 mouseMoveEvent( event ); 405 mouseMoveEvent( event );
405// } 406// }
406} 407}
407 408
408 409
409void VideoWidget::makeVisible() { 410void VideoWidget::makeVisible() {
410 if ( mediaPlayerState->fullscreen() ) 411 if ( mediaPlayerState->fullscreen() )
411 { 412 {
412 setBackgroundMode( QWidget::NoBackground ); 413 setBackgroundMode( QWidget::NoBackground );
413 showFullScreen(); 414 showFullScreen();
414 resize( qApp->desktop()->size() ); 415 resize( qApp->desktop()->size() );
415 slider->hide(); 416 slider->hide();
416 } 417 }
417 else 418 else
418 { 419 {
419 setBackgroundPixmap( *pixBg ); 420 setBackgroundPixmap( *pixBg );
420 showNormal(); 421 showNormal();
421 QPEApplication::showWidget( this ); 422 QPEApplication::showWidget( this );
422 slider->show(); 423 slider->show();
423 } 424 }
424} 425}
425 426
426 427
427void VideoWidget::paintEvent( QPaintEvent * pe) { 428void VideoWidget::paintEvent( QPaintEvent * pe) {
428 QPainter p( this ); 429 QPainter p( this );
429 430
430 if ( mediaPlayerState->fullscreen() ) { 431 if ( mediaPlayerState->fullscreen() ) {
431 // Clear the background 432 // Clear the background
432 p.setBrush( QBrush( Qt::black ) ); 433 p.setBrush( QBrush( Qt::black ) );
433 p.drawRect( rect() ); 434 p.drawRect( rect() );
434 } else { 435 } else {
435 if ( !pe->erased() ) { 436 if ( !pe->erased() ) {
436 // Combine with background and double buffer 437 // Combine with background and double buffer
437 QPixmap pix( pe->rect().size() ); 438 QPixmap pix( pe->rect().size() );
438 QPainter p( &pix ); 439 QPainter p( &pix );
439 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 440 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
440 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 441 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
441 for ( int i = 0; i < numVButtons; i++ ) { 442 for ( int i = 0; i < numVButtons; i++ ) {
442 paintButton( &p, i ); 443 paintButton( &p, i );
443 } 444 }
444 QPainter p2( this ); 445 QPainter p2( this );
445 p2.drawPixmap( pe->rect().topLeft(), pix ); 446 p2.drawPixmap( pe->rect().topLeft(), pix );
446 } else { 447 } else {
447 QPainter p( this ); 448 QPainter p( this );
448 for ( int i = 0; i < numVButtons; i++ ) 449 for ( int i = 0; i < numVButtons; i++ )
449 paintButton( &p, i ); 450 paintButton( &p, i );
450 } 451 }
451 slider->repaint( TRUE ); 452 slider->repaint( TRUE );
452 } 453 }
453} 454}
454 455
455 456
456void VideoWidget::closeEvent( QCloseEvent* ) { 457void VideoWidget::closeEvent( QCloseEvent* ) {
457 mediaPlayerState->setList(); 458 mediaPlayerState->setList();
458} 459}
459 460
460 461
461bool VideoWidget::playVideo() { 462bool VideoWidget::playVideo() {
462 bool result = FALSE; 463 bool result = FALSE;
463// odebug << "<<<<<<<<<<<<<<<< play video" << oendl; 464// odebug << "<<<<<<<<<<<<<<<< play video" << oendl;
464 int stream = 0; 465 int stream = 0;
465 466
466 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 467 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
467 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 468 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
468 int dd = QPixmap::defaultDepth(); 469 int dd = QPixmap::defaultDepth();
469 int w = height(); 470 int w = height();
470 int h = width(); 471 int h = width();
471 472
472 QWidget *d = QApplication::desktop(); 473 QWidget *d = QApplication::desktop();
473 int d_width = d->width(); 474 int d_width = d->width();
474 int d_height = d->height(); 475 int d_height = d->height();
475 476
476 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 477 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
477 478
478 if ( mediaPlayerState->fullscreen() ) 479 if ( mediaPlayerState->fullscreen() )
479 { 480 {
480#ifdef USE_DIRECT_PAINTER 481#ifdef USE_DIRECT_PAINTER
481 QDirectPainter p(this); 482 QDirectPainter p(this);
482 483
483 if ( ( qt_screen->transformOrientation() == 3 ) && 484 if ( ( qt_screen->transformOrientation() == 3 ) &&
484 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) 485 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) )
485 { 486 {
486 487
487 w = d_width; //320; 488 w = d_width; //320;
488 h = d_height; //240; 489 h = d_height; //240;
489 490
490 if ( mediaPlayerState->scaled() ) 491 if ( mediaPlayerState->scaled() )
491 { 492 {
492 // maintain aspect ratio 493 // maintain aspect ratio
493 if ( w * sh > sw * h ) 494 if ( w * sh > sw * h )
494 w = sw * h / sh; 495 w = sw * h / sh;
495 else 496 else
496 h = sh * w / sw; 497 h = sh * w / sw;
497 } 498 }
498 else 499 else
499 { 500 {
500 w = sw; 501 w = sw;
501 h = sh; 502 h = sh;
502 } 503 }
503 504
504 w--; // we can't allow libmpeg to overwrite. 505 w--; // we can't allow libmpeg to overwrite.
505 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); 506 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
506 507
507 int ox = roff.x() - height() + 2 + (height() - w) / 2; 508 int ox = roff.x() - height() + 2 + (height() - w) / 2;
508 int oy = roff.y() + (width() - h) / 2; 509 int oy = roff.y() + (width() - h) / 2;
509 int sx = 0, sy = 0; 510 int sx = 0, sy = 0;
510 511
511 uchar* fp = p.frameBuffer() + p.lineStep() * oy; 512 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
512 fp += dd * ox / 8; 513 fp += dd * ox / 8;
513 uchar **jt = new uchar*[h]; 514 uchar **jt = new uchar*[h];
514 515
515 for ( int i = h; i; i-- ) 516 for ( int i = h; i; i-- )
516 { 517 {
517 jt[h - i] = fp; 518 jt[h - i] = fp;
518 fp += p.lineStep(); 519 fp += p.lineStep();
519 } 520 }
520 521
521 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; 522 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
522 523
523 delete [] jt; 524 delete [] jt;
524 } 525 }
525 else 526 else
526 { 527 {
527#endif 528#endif
528 QPainter p(this); 529 QPainter p(this);
529 w = d_width; //320; 530 w = d_width; //320;
530 h = d_height; //240; 531 h = d_height; //240;
531 532
532 if ( mediaPlayerState->scaled() ) 533 if ( mediaPlayerState->scaled() )
533 { 534 {
534 // maintain aspect ratio 535 // maintain aspect ratio
535 if ( w * sh > sw * h ) 536 if ( w * sh > sw * h )
536 w = sw * h / sh; 537 w = sw * h / sh;
537 else 538 else
538 h = sh * w / sw; 539 h = sh * w / sw;
539 } 540 }
540 else 541 else
541 { 542 {
542 w = sw; 543 w = sw;
543 h = sh; 544 h = sh;
544 } 545 }
545 546
546 int bytes = ( dd == 16 ) ? 2 : 4; 547 int bytes = ( dd == 16 ) ? 2 : 4;
547 QImage tempFrame( w, h, bytes << 3 ); 548 QImage tempFrame( w, h, bytes << 3 );
548 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), 549 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
549 0, 0, sw, sh, w, h, format, 0) == 0; 550 0, 0, sw, sh, w, h, format, 0) == 0;
550 551
551 if ( result && mediaPlayerState->fullscreen() ) 552 if ( result && mediaPlayerState->fullscreen() )
552 { 553 {
553 554
554 int rw = h, rh = w; 555 int rw = h, rh = w;
555 QImage rotatedFrame( rw, rh, bytes << 3 ); 556 QImage rotatedFrame( rw, rh, bytes << 3 );
556 557
557 ushort* in = (ushort*)tempFrame.bits(); 558 ushort* in = (ushort*)tempFrame.bits();
558 ushort* out = (ushort*)rotatedFrame.bits(); 559 ushort* out = (ushort*)rotatedFrame.bits();
559 int spl = rotatedFrame.bytesPerLine() / bytes; 560 int spl = rotatedFrame.bytesPerLine() / bytes;
560 561
561 for (int x=0; x<h; x++) 562 for (int x=0; x<h; x++)
562 { 563 {
563 if ( bytes == 2 ) 564 if ( bytes == 2 )
564 { 565 {
565 ushort* lout = out++ + (w - 1)*spl; 566 ushort* lout = out++ + (w - 1)*spl;
566 for (int y=0; y<w; y++) { 567 for (int y=0; y<w; y++) {
567 *lout=*in++; 568 *lout=*in++;
568 lout-=spl; 569 lout-=spl;
569 } 570 }
570 } 571 }
571 else 572 else
572 { 573 {
573 ulong* _out = (ulong *)out; 574 ulong* _out = (ulong *)out;
574 ulong* lout = _out++ + (w - 1)*spl; 575 ulong* lout = _out++ + (w - 1)*spl;
575 for (int y=0; y<w; y++) 576 for (int y=0; y<w; y++)
576 { 577 {
577 ulong *_in = (ulong*)in; 578 ulong *_in = (ulong*)in;
578 *lout=*_in++; 579 *lout=*_in++;
579 lout-=spl; 580 lout-=spl;
580 } 581 }
581 } 582 }
582 } 583 }
583 584
584 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); 585 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
585 } 586 }
586#ifdef USE_DIRECT_PAINTER 587#ifdef USE_DIRECT_PAINTER
587 } 588 }
588#endif 589#endif
589 } 590 }
590 else 591 else
591 { 592 {
592 593
593 w = 220; 594 w = 220;
594 h = 160; 595 h = 160;
595 596
596 // maintain aspect ratio 597 // maintain aspect ratio
597 if ( w * sh > sw * h ) 598 if ( w * sh > sw * h )
598 w = sw * h / sh; 599 w = sw * h / sh;
599 else 600 else
600 h = sh * w / sw; 601 h = sh * w / sw;
601 602
602 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; 603 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0;
603 604
604 QPainter p( this ); 605 QPainter p( this );
605 int deskW = qApp->desktop()->width(); 606 int deskW = qApp->desktop()->width();
606 // Image changed size, therefore need to blank the possibly unpainted regions first 607 // Image changed size, therefore need to blank the possibly unpainted regions first
607 if ( scaledWidth != w || scaledHeight != h ) 608 if ( scaledWidth != w || scaledHeight != h )
608 { 609 {
609 p.setBrush( QBrush( Qt::black ) ); 610 p.setBrush( QBrush( Qt::black ) );
610 p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 ); 611 p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 );
611 } 612 }
612 613
613 scaledWidth = w; 614 scaledWidth = w;
614 scaledHeight = h; 615 scaledHeight = h;
615 616
616 if ( result ) 617 if ( result )
617 { 618 {
618 p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 619 p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
619 } 620 }
620 621
621 } 622 }
622 623
623 return result; 624 return result;
624} 625}
625 626
626 627
627 628
628void VideoWidget::keyReleaseEvent( QKeyEvent *e) 629void VideoWidget::keyReleaseEvent( QKeyEvent *e)
629{ 630{
630 switch ( e->key() ) 631 switch ( e->key() )
631 { 632 {
632////////////////////////////// Zaurus keys 633////////////////////////////// Zaurus keys
633 case Key_Home: 634 case Key_Home:
634 break; 635 break;
635 case Key_F9: //activity 636 case Key_F9: //activity
636 break; 637 break;
637 case Key_F10: //contacts 638 case Key_F10: //contacts
638// hide(); 639// hide();
639 break; 640 break;
640 case Key_F11: //menu 641 case Key_F11: //menu
641 break; 642 break;
642 case Key_F12: //home 643 case Key_F12: //home
643 break; 644 break;
644 case Key_F13: //mail 645 case Key_F13: //mail
645 break; 646 break;
646 case Key_Space: 647 case Key_Space:
647 { 648 {
648 if(mediaPlayerState->playing()) 649 if(mediaPlayerState->playing())
649 { 650 {
650 mediaPlayerState->setPlaying(FALSE); 651 mediaPlayerState->setPlaying(FALSE);
651 } 652 }
652 else 653 else
653 { 654 {
654 mediaPlayerState->setPlaying(TRUE); 655 mediaPlayerState->setPlaying(TRUE);
655 } 656 }
656 } 657 }
657 break; 658 break;
658 case Key_Down: 659 case Key_Down:
659// toggleButton(6); 660// toggleButton(6);
660// emit lessClicked(); 661// emit lessClicked();
661// emit lessReleased(); 662// emit lessReleased();
662// toggleButton(6); 663// toggleButton(6);
663 break; 664 break;
664 case Key_Up: 665 case Key_Up:
665// toggleButton(5); 666// toggleButton(5);
666// emit moreClicked(); 667// emit moreClicked();
667// emit moreReleased(); 668// emit moreReleased();
668// toggleButton(5); 669// toggleButton(5);
669 break; 670 break;
670 case Key_Right: 671 case Key_Right:
671 mediaPlayerState->setNext(); 672 mediaPlayerState->setNext();
672 break; 673 break;
673 case Key_Left: 674 case Key_Left:
674 mediaPlayerState->setPrev(); 675 mediaPlayerState->setPrev();
675 break; 676 break;
676 case Key_Escape: 677 case Key_Escape:
677 break; 678 break;
678 679
679 }; 680 };
680} 681}