summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp326
-rw-r--r--core/multimedia/opieplayer/audiowidget.h73
-rw-r--r--core/multimedia/opieplayer/inputDialog.cpp31
-rw-r--r--core/multimedia/opieplayer/inputDialog.h17
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp51
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h4
-rw-r--r--core/multimedia/opieplayer/opie-mediaplayer.control2
-rw-r--r--core/multimedia/opieplayer/opieplayer.pro9
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp496
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h5
10 files changed, 564 insertions, 450 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index b96b1ef..896da91 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,367 +1,491 @@
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 <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpixmap.h> 25#include <qpixmap.h>
26#include <qbutton.h> 26#include <qbutton.h>
27#include <qpainter.h> 27#include <qpainter.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlayout.h> 29#include <qlayout.h>
30 30
31#include "audiowidget.h" 31#include "audiowidget.h"
32#include "mediaplayerstate.h" 32#include "mediaplayerstate.h"
33 33
34#include <stdlib.h>
35#include <stdio.h>
36
34extern MediaPlayerState *mediaPlayerState; 37extern MediaPlayerState *mediaPlayerState;
35 38
36 39
37static const int xo = -2; // movable x offset 40static const int xo = -2; // movable x offset
38static const int yo = 22; // movable y offset 41static const int yo = 22; // movable y offset
39 42
40
41struct MediaButton { 43struct MediaButton {
42 int xPos, yPos; 44 bool isToggle, isHeld, isDown;
43 int color;
44 bool isToggle, isBig, isHeld, isDown;
45}; 45};
46 46
47 47//Layout information for the audioButtons (and if it is a toggle button or not)
48// Layout information for the audioButtons (and if it is a toggle button or not)
49MediaButton audioButtons[] = { 48MediaButton audioButtons[] = {
50 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 49 { TRUE, FALSE, FALSE }, // play
51 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop 50 { FALSE, FALSE, FALSE }, // stop
52 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause 51 { TRUE, FALSE, FALSE }, // pause
53 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next 52 { FALSE, FALSE, FALSE }, // next
54 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous 53 { FALSE, FALSE, FALSE }, // previous
55 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up 54 { FALSE, FALSE, FALSE }, // volume up
56 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 55 { FALSE, FALSE, FALSE }, // volume down
57 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 56 { TRUE, FALSE, FALSE }, // repeat/loop
58 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 57 { FALSE, FALSE, FALSE }, // playlist
58 { FALSE, FALSE, FALSE }, // forward
59 { FALSE, FALSE, FALSE } // back
59}; 60};
60 61
62const char *skin_mask_file_names[11] = {
63 "play", "stop", "pause", "next", "prev", "up",
64 "down", "loop", "playlist", "forward", "back"
65};
61 66
62static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
63 67
68static void changeTextColor( QWidget *w ) {
69 QPalette p = w->palette();
70 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
71 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
72 w->setPalette( p );
73}
74
75static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
64 76
65AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 77AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
66 QWidget( parent, name, f ) 78 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
67{ 79{
68 setCaption( tr("OpiePlayer") ); 80 setCaption( tr("OpiePlayer") );
81 qDebug("<<<<<audioWidget");
82
69 Config cfg("OpiePlayer"); 83 Config cfg("OpiePlayer");
70 cfg.setGroup("AudioWidget"); 84 cfg.setGroup("AudioWidget");
71// QGridLayout *layout = new QGridLayout( this ); 85 skin = cfg.readEntry("Skin","default");
72// layout->setSpacing( 2); 86 //skin = "scaleTest";
73// layout->setMargin( 2); 87// color of background, frame, degree of transparency
74 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; 88
75 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); 89 QString skinPath = "opieplayer2/skins/" + skin;
76 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); 90 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
77 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); 91 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
78 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); 92 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
79// animatedPix=cfg.readEntry( "animatedPix", "opieplayer/animatedButton"); 93
80 94 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
81 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 95 imgButtonMask->fill( 0 );
82 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); 96
83 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); 97 for ( int i = 0; i < 11; i++ ) {
84 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); 98 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
85// pixmaps[3] = new QPixmap( Resource::loadPixmap( animatedPix) ); 99 masks[i] = new QBitmap( filename );
86 100
87 songInfo = new Ticker( this ); 101 if ( !masks[i]->isNull() ) {
88 songInfo->setFocusPolicy( QWidget::NoFocus ); 102 QImage imgMask = masks[i]->convertToImage();
89 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 103 uchar **dest = imgButtonMask->jumpTable();
90// layout->addMultiCellWidget( songInfo, 0, 0, 0, 2 ); 104 for ( int y = 0; y < imgUp->height(); y++ ) {
91 105 uchar *line = dest[y];
92 slider = new QSlider( Qt::Horizontal, this ); 106 for ( int x = 0; x < imgUp->width(); x++ )
93 slider->setFixedWidth( 220 ); 107 if ( !qRed( imgMask.pixel( x, y ) ) )
94 slider->setFixedHeight( 20 ); 108 line[x] = i + 1;
95 slider->setMinValue( 0 ); 109 }
96 slider->setMaxValue( 1 ); 110 }
97 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 111
98 slider->setFocusPolicy( QWidget::NoFocus ); 112 }
99 slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 113
100 // layout->addMultiCellWidget( slider, 4, 4, 0, 2 ); 114 for ( int i = 0; i < 11; i++ ) {
101 115 buttonPixUp[i] = NULL;
102 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 116 buttonPixDown[i] = NULL;
103 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 117 }
118
119 setBackgroundPixmap( *pixBg );
120
121 songInfo.setFocusPolicy( QWidget::NoFocus );
122
123 changeTextColor( &songInfo );
124 songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
125 songInfo.setFrameStyle( QFrame::NoFrame);
126// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
127 //NoFrame
128// songInfo.setForegroundColor(Qt::white);
129
130 slider.setFixedHeight( 20 );
131 slider.setMinValue( 0 );
132 slider.setMaxValue( 1 );
133 slider.setFocusPolicy( QWidget::NoFocus );
134 slider.setBackgroundPixmap( *pixBg );
135
136 time.setFocusPolicy( QWidget::NoFocus );
137 time.setAlignment( Qt::AlignCenter );
138 time.setFrame(FALSE);
139 changeTextColor( &time );
140
141 resizeEvent( NULL );
142
143 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
144 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
104 145
105 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 146 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
106 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 147 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
107 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
108 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 149 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
109 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
110 151
111 // Intialise state 152 // Intialise state
112 setLength( mediaPlayerState->length() ); 153 setLength( mediaPlayerState->length() );
113 setPosition( mediaPlayerState->position() ); 154 setPosition( mediaPlayerState->position() );
114 setLooping( mediaPlayerState->fullscreen() ); 155 setLooping( mediaPlayerState->fullscreen() );
115 setPaused( mediaPlayerState->paused() ); 156 setPaused( mediaPlayerState->paused() );
116 setPlaying( mediaPlayerState->playing() ); 157 setPlaying( mediaPlayerState->playing() );
117 158
118} 159}
119 160
120 161
121AudioWidget::~AudioWidget() { 162AudioWidget::~AudioWidget() {
122 mediaPlayerState->isStreaming = FALSE; 163
123 for ( int i = 0; i < 3; i++ ) 164 for ( int i = 0; i < 11; i++ ) {
124 delete pixmaps[i]; 165 delete buttonPixUp[i];
166 delete buttonPixDown[i];
167 }
168 delete pixBg;
169 delete imgUp;
170 delete imgDn;
171 delete imgButtonMask;
172 for ( int i = 0; i < 11; i++ ) {
173 delete masks[i];
174 }
125} 175}
126 176
127 177
128static bool audioSliderBeingMoved = FALSE; 178QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
179 QPixmap pix( img.width(), img.height() );
180 QPainter p( &pix );
181 p.drawTiledPixmap( pix.rect(), bg, offset );
182 p.drawImage( 0, 0, img );
183 return new QPixmap( pix );
184}
185
186
187QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
188{
189 QPixmap *pixmap = new QPixmap( pix );
190 pixmap->setMask( mask );
191 return pixmap;
192}
129 193
130 194
195
196void AudioWidget::resizeEvent( QResizeEvent * ) {
197 int h = height();
198 int w = width();
199
200 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
201 slider.setFixedWidth( w - 110 );
202 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
203 slider.setBackgroundOrigin( QWidget::ParentOrigin );
204 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
205
206 xoff = ( w - imgUp->width() ) / 2;
207 yoff = (( h - imgUp->height() ) / 2) - 10;
208 QPoint p( xoff, yoff );
209
210 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
211 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
212
213 for ( int i = 0; i < 11; i++ ) {
214 if ( !masks[i]->isNull() ) {
215 delete buttonPixUp[i];
216 delete buttonPixDown[i];
217 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
218 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
219 }
220 }
221
222 delete pixUp;
223 delete pixDn;
224}
225
226
227static bool audioSliderBeingMoved = FALSE;
228
131void AudioWidget::sliderPressed() { 229void AudioWidget::sliderPressed() {
132 audioSliderBeingMoved = TRUE; 230 audioSliderBeingMoved = TRUE;
133} 231}
134 232
135 233
136void AudioWidget::sliderReleased() { 234void AudioWidget::sliderReleased() {
137 audioSliderBeingMoved = FALSE; 235 audioSliderBeingMoved = FALSE;
138 if ( slider->width() == 0 ) 236 if ( slider.width() == 0 )
139 return; 237 return;
140 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 238 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
141 mediaPlayerState->setPosition( val ); 239 mediaPlayerState->setPosition( val );
142} 240}
143 241
144 242
145void AudioWidget::setPosition( long i ) { 243void AudioWidget::setPosition( long i ) {
146// qDebug("set position %d",i); 244// qDebug("set position %d",i);
147 updateSlider( i, mediaPlayerState->length() ); 245 long length = mediaPlayerState->length();
246 updateSlider( i, length );
148} 247}
149 248
150 249
151void AudioWidget::setLength( long max ) { 250void AudioWidget::setLength( long max ) {
152 updateSlider( mediaPlayerState->position(), max ); 251 updateSlider( mediaPlayerState->position(), max );
153} 252}
154 253
155 254
156void AudioWidget::setView( char view ) { 255void AudioWidget::setView( char view ) {
256
157 if (mediaPlayerState->isStreaming) { 257 if (mediaPlayerState->isStreaming) {
158 if( !slider->isHidden()) slider->hide(); 258 if( !slider.isHidden()) slider.hide();
159 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 259 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
160 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 260 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
161 } else { 261 } else {
162// this stops the slider from being moved, thus 262// this stops the slider from being moved, thus
163 // does not stop stream when it reaches the end 263 // does not stop stream when it reaches the end
164 slider->show(); 264 slider.show();
165 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 265 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
166 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 266 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
167 } 267 }
168 268
169 if ( view == 'a' ) { 269 if ( view == 'a' ) {
170 startTimer( 150 ); 270 startTimer( 150 );
171// show(); 271// show();
172 showMaximized(); 272 showMaximized();
173 } else { 273 } else {
174 killTimers(); 274 killTimers();
175 hide(); 275 hide();
176 } 276 }
177} 277}
178 278
179 279
280static QString timeAsString( long length ) {
281 length /= 44100;
282 int minutes = length / 60;
283 int seconds = length % 60;
284 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
285}
286
180void AudioWidget::updateSlider( long i, long max ) { 287void AudioWidget::updateSlider( long i, long max ) {
288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
289
181 if ( max == 0 ) 290 if ( max == 0 )
182 return; 291 return;
183 // Will flicker too much if we don't do this 292 // Will flicker too much if we don't do this
184 // Scale to something reasonable 293 // Scale to something reasonable
185 int width = slider->width(); 294 int width = slider.width();
186 int val = int((double)i * width / max); 295 int val = int((double)i * width / max);
187 if ( !audioSliderBeingMoved ) { 296 if ( !audioSliderBeingMoved ) {
188 if ( slider->value() != val ) 297 if ( slider.value() != val )
189 slider->setValue( val ); 298 slider.setValue( val );
190 if ( slider->maxValue() != width ) 299 if ( slider.maxValue() != width )
191 slider->setMaxValue( width ); 300 slider.setMaxValue( width );
192 } 301 }
193} 302}
194 303
195 304
196void AudioWidget::setToggleButton( int i, bool down ) { 305void AudioWidget::setToggleButton( int i, bool down ) {
197 if ( down != audioButtons[i].isDown ) 306 if ( down != audioButtons[i].isDown )
198 toggleButton( i ); 307 toggleButton( i );
199} 308}
200 309
201 310
202void AudioWidget::toggleButton( int i ) { 311void AudioWidget::toggleButton( int i ) {
203 audioButtons[i].isDown = !audioButtons[i].isDown; 312 audioButtons[i].isDown = !audioButtons[i].isDown;
204 QPainter p(this); 313 QPainter p(this);
205 paintButton ( &p, i ); 314 paintButton ( &p, i );
206} 315}
207 316
208 317
209void AudioWidget::paintButton( QPainter *p, int i ) { 318void AudioWidget::paintButton( QPainter *p, int i ) {
210 int x = audioButtons[i].xPos; 319 if ( audioButtons[i].isDown )
211 int y = audioButtons[i].yPos; 320 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
212 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 321 else
213 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 322 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
214 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize );
215 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
216} 323}
217 324
218 325
219void AudioWidget::timerEvent( QTimerEvent * ) { 326void AudioWidget::timerEvent( QTimerEvent * ) {
327/*
328 int x = audioButtons[AudioPlay].xPos;
329 int y = audioButtons[AudioPlay].yPos;
330 QPainter p( this );
331 // Optimize to only draw the little bit of the changing images which is different
332 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
333 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
334*/
335/*
220 static int frame = 0; 336 static int frame = 0;
221 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 337 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
222 frame = frame >= 7 ? 0 : frame + 1; 338 frame = frame >= 7 ? 0 : frame + 1;
223// int x = audioButtons[AudioPlay].xPos;
224// int y = audioButtons[AudioPlay].yPos;
225// QPainter p( this );
226// // Optimize to only draw the little bit of the changing images which is different
227// p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
228// p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
229 } 339 }
340 */
230} 341}
231 342
232 343
233void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 344void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
234 for ( int i = 0; i < numButtons; i++ ) { 345 for ( int i = 0; i < numButtons; i++ ) {
235 int size = audioButtons[i].isBig;
236 int x = audioButtons[i].xPos;
237 int y = audioButtons[i].yPos;
238 if ( event->state() == QMouseEvent::LeftButton ) { 346 if ( event->state() == QMouseEvent::LeftButton ) {
239 // The test to see if the mouse click is inside the circular button or not 347
240 // (compared with the radius squared to avoid a square-root of our distance) 348 // The test to see if the mouse click is inside the button or not
241 int radius = 32 + 13 * size; 349 int x = event->pos().x() - xoff;
242 QPoint center = QPoint( x + radius, y + radius ); 350 int y = event->pos().y() - yoff;
243 QPoint dXY = center - event->pos(); 351
244 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 352 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
245 bool isOnButton = dist <= (radius * radius); 353 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
246// QRect r( x, y, 64 + 22*size, 64 + 22*size ); 354
247// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 355 if ( isOnButton && i == AudioVolumeUp )
356 qDebug("on up");
357
248 if ( isOnButton && !audioButtons[i].isHeld ) { 358 if ( isOnButton && !audioButtons[i].isHeld ) {
249 audioButtons[i].isHeld = TRUE; 359 audioButtons[i].isHeld = TRUE;
250 toggleButton(i); 360 toggleButton(i);
251 qDebug("button toggled1 %d",i);
252 switch (i) { 361 switch (i) {
253 case AudioVolumeUp: emit moreClicked(); return; 362 case AudioVolumeUp:
363 qDebug("more clicked");
364 emit moreClicked();
365 return;
254 case AudioVolumeDown: emit lessClicked(); return; 366 case AudioVolumeDown: emit lessClicked(); return;
255 } 367 }
256 } else if ( !isOnButton && audioButtons[i].isHeld ) { 368 } else if ( !isOnButton && audioButtons[i].isHeld ) {
257 audioButtons[i].isHeld = FALSE; 369 audioButtons[i].isHeld = FALSE;
258 toggleButton(i); 370 toggleButton(i);
259 qDebug("button toggled2 %d",i);
260 } 371 }
261 } else { 372 } else {
262 if ( audioButtons[i].isHeld ) { 373 if ( audioButtons[i].isHeld ) {
263 audioButtons[i].isHeld = FALSE; 374 audioButtons[i].isHeld = FALSE;
264 if ( !audioButtons[i].isToggle ) 375 if ( !audioButtons[i].isToggle )
265 setToggleButton( i, FALSE ); 376 setToggleButton( i, FALSE );
266 qDebug("button toggled3 %d",i);
267 switch (i) { 377 switch (i) {
268 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 378 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
269 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 379 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
270 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 380 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
271 case AudioNext: mediaPlayerState->setNext(); return; 381 case AudioNext: mediaPlayerState->setNext(); return;
272 case AudioPrevious: mediaPlayerState->setPrev(); return; 382 case AudioPrevious: mediaPlayerState->setPrev(); return;
273 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 383 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
274 case AudioVolumeUp: emit moreReleased(); return; 384 case AudioVolumeUp: emit moreReleased(); return;
275 case AudioVolumeDown: emit lessReleased(); return; 385 case AudioVolumeDown: emit lessReleased(); return;
276 case AudioPlayList: mediaPlayerState->setList(); return; 386 case AudioPlayList: mediaPlayerState->setList(); return;
277 } 387 }
278 } 388 }
279 } 389 }
280 } 390 }
281} 391}
282 392
283 393
394
284void AudioWidget::mousePressEvent( QMouseEvent *event ) { 395void AudioWidget::mousePressEvent( QMouseEvent *event ) {
285 mouseMoveEvent( event ); 396 mouseMoveEvent( event );
286} 397}
287 398
288 399
289void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 400void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
290 mouseMoveEvent( event ); 401 mouseMoveEvent( event );
291} 402}
292 403
293 404
294void AudioWidget::showEvent( QShowEvent* ) { 405void AudioWidget::showEvent( QShowEvent* ) {
295 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 406 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
296 mouseMoveEvent( &event ); 407 mouseMoveEvent( &event );
297} 408}
298 409
299 410
300void AudioWidget::closeEvent( QCloseEvent* ) { 411void AudioWidget::closeEvent( QCloseEvent* ) {
301 mediaPlayerState->setList(); 412 mediaPlayerState->setList();
302} 413}
303 414
304 415
305void AudioWidget::paintEvent( QPaintEvent * ) { 416void AudioWidget::paintEvent( QPaintEvent * pe) {
306 QPainter p( this ); 417 if ( !pe->erased() ) {
307 for ( int i = 0; i < numButtons; i++ ) 418 // Combine with background and double buffer
308 paintButton( &p, i ); 419 QPixmap pix( pe->rect().size() );
420 QPainter p( &pix );
421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
423 for ( int i = 0; i < numButtons; i++ )
424 paintButton( &p, i );
425 QPainter p2( this );
426 p2.drawPixmap( pe->rect().topLeft(), pix );
427 } else {
428 QPainter p( this );
429 for ( int i = 0; i < numButtons; i++ )
430 paintButton( &p, i );
431 }
309} 432}
310 433
311void AudioWidget::keyReleaseEvent( QKeyEvent *e) 434void AudioWidget::keyReleaseEvent( QKeyEvent *e)
312{ 435{
313 switch ( e->key() ) { 436 switch ( e->key() ) {
314////////////////////////////// Zaurus keys 437////////////////////////////// Zaurus keys
315 case Key_Home: 438 case Key_Home:
316 break; 439 break;
317 case Key_F9: //activity 440 case Key_F9: //activity
318 hide(); 441 hide();
319// qDebug("Audio F9"); 442// qDebug("Audio F9");
320 break; 443 break;
321 case Key_F10: //contacts 444 case Key_F10: //contacts
322 break; 445 break;
323 case Key_F11: //menu 446 case Key_F11: //menu
324 break; 447 break;
325 case Key_F12: //home 448 case Key_F12: //home
326 break; 449 break;
327 case Key_F13: //mail 450 case Key_F13: //mail
328 break; 451 break;
329 case Key_Space: { 452 case Key_Space: {
453
330 if(mediaPlayerState->playing()) { 454 if(mediaPlayerState->playing()) {
331// toggleButton(1); 455// toggleButton(1);
332 mediaPlayerState->setPlaying(FALSE); 456 mediaPlayerState->setPlaying(FALSE);
333// toggleButton(1); 457// toggleButton(1);
334 } else { 458 } else {
335// toggleButton(0); 459// toggleButton(0);
336 mediaPlayerState->setPlaying(TRUE); 460 mediaPlayerState->setPlaying(TRUE);
337// toggleButton(0); 461// toggleButton(0);
338 } 462 }
339 } 463 }
340 break; 464 break;
341 case Key_Down: 465 case Key_Down: //volume
342 toggleButton(6); 466 toggleButton(6);
343 emit lessClicked(); 467 emit lessClicked();
344 emit lessReleased(); 468 emit lessReleased();
345 toggleButton(6); 469 toggleButton(6);
346 break; 470 break;
347 case Key_Up: 471 case Key_Up: //volume
348 toggleButton(5); 472 toggleButton(5);
349 emit moreClicked(); 473 emit moreClicked();
350 emit moreReleased(); 474 emit moreReleased();
351 toggleButton(5); 475 toggleButton(5);
352 break; 476 break;
353 case Key_Right: 477 case Key_Right: //next in playlist
354// toggleButton(3); 478// toggleButton(3);
355 mediaPlayerState->setNext(); 479 mediaPlayerState->setNext();
356// toggleButton(3); 480// toggleButton(3);
357 break; 481 break;
358 case Key_Left: 482 case Key_Left: // previous in playlist
359// toggleButton(4); 483// toggleButton(4);
360 mediaPlayerState->setPrev(); 484 mediaPlayerState->setPrev();
361// toggleButton(4); 485// toggleButton(4);
362 break; 486 break;
363 case Key_Escape: 487 case Key_Escape:
364 break; 488 break;
365 489
366 }; 490 };
367} 491}
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index b3d39bf..c686741 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -1,146 +1,113 @@
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#ifndef AUDIO_WIDGET_H 21#ifndef AUDIO_WIDGET_H
22#define AUDIO_WIDGET_H 22#define AUDIO_WIDGET_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qdrawutil.h> 26#include <qdrawutil.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qbitmap.h>
28#include <qstring.h> 29#include <qstring.h>
29#include <qslider.h> 30#include <qslider.h>
31#include <qlineedit.h>
30#include <qframe.h> 32#include <qframe.h>
31 33
34#include <opie/oticker.h>
32 35
33class QPixmap; 36class QPixmap;
34 37
35
36enum AudioButtons { 38enum AudioButtons {
37 AudioPlay, 39 AudioPlay,
38 AudioStop, 40 AudioStop,
39 AudioPause, 41 AudioPause,
40 AudioNext, 42 AudioNext,
41 AudioPrevious, 43 AudioPrevious,
42 AudioVolumeUp, 44 AudioVolumeUp,
43 AudioVolumeDown, 45 AudioVolumeDown,
44 AudioLoop, 46 AudioLoop,
45 AudioPlayList 47 AudioPlayList
46}; 48};
47 49
48 50
49#define USE_DBLBUF 51//#define USE_DBLBUF
50
51
52class Ticker : public QFrame {
53 Q_OBJECT
54public:
55 Ticker( QWidget* parent=0 ) : QFrame( parent ) {
56 setFrameStyle( WinPanel | Sunken );
57 setText( "No Song" );
58 }
59 ~Ticker() { }
60 void setText( const QString& text ) {
61 pos = 0; // reset it everytime the text is changed
62 scrollText = text;
63 pixelLen = fontMetrics().width( scrollText );
64 killTimers();
65 if ( pixelLen > width() )
66 startTimer( 50 );
67 update();
68 }
69protected:
70 void timerEvent( QTimerEvent * ) {
71 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
72#ifndef USE_DBLBUF
73 scroll( -1, 0, contentsRect() );
74#else
75 repaint( FALSE );
76#endif
77 }
78 void drawContents( QPainter *p ) {
79#ifndef USE_DBLBUF
80 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
81 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
82#else
83 // Double buffering code.
84 // Looks like qvfb makes it look like it flickers but I don't think it really is
85 QPixmap pm( width(), height() );
86 pm.fill( colorGroup().base() );
87 QPainter pmp( &pm );
88 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
89 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
90 p->drawPixmap( 0, 0, pm );
91#endif
92 }
93private:
94 QString scrollText;
95 int pos, pixelLen;
96};
97
98 52
99class AudioWidget : public QWidget { 53class AudioWidget : public QWidget {
100 Q_OBJECT 54 Q_OBJECT
101public: 55public:
102 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 56 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
103 ~AudioWidget(); 57 ~AudioWidget();
104 void setTickerText( const QString &text ) { songInfo->setText( text ); } 58 void setTickerText( const QString &text ) { songInfo.setText( text ); }
105 bool isStreaming; 59 bool isStreaming;
106public slots: 60public slots:
107 void updateSlider( long, long ); 61 void updateSlider( long, long );
108 void sliderPressed( ); 62 void sliderPressed( );
109 void sliderReleased( ); 63 void sliderReleased( );
110 void setPaused( bool b) { setToggleButton( AudioPause, b ); } 64 void setPaused( bool b) { setToggleButton( AudioPause, b ); }
111 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 65 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
112 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } 66 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
113 void setPosition( long ); 67 void setPosition( long );
114 void setLength( long ); 68 void setLength( long );
115 void setView( char ); 69 void setView( char );
116 70
117signals: 71signals:
118 void moreClicked(); 72 void moreClicked();
119 void lessClicked(); 73 void lessClicked();
120 void moreReleased(); 74 void moreReleased();
121 void lessReleased(); 75 void lessReleased();
122 void sliderMoved(long); 76 void sliderMoved(long);
123 77
124protected: 78protected:
125 void doBlank(); 79 void doBlank();
126 void doUnblank(); 80 void doUnblank();
127 void paintEvent( QPaintEvent *pe ); 81 void paintEvent( QPaintEvent *pe );
128 void showEvent( QShowEvent *se ); 82 void showEvent( QShowEvent *se );
83 void resizeEvent( QResizeEvent *re );
129 void mouseMoveEvent( QMouseEvent *event ); 84 void mouseMoveEvent( QMouseEvent *event );
130 void mousePressEvent( QMouseEvent *event ); 85 void mousePressEvent( QMouseEvent *event );
131 void mouseReleaseEvent( QMouseEvent *event ); 86 void mouseReleaseEvent( QMouseEvent *event );
132 void timerEvent( QTimerEvent *event ); 87 void timerEvent( QTimerEvent *event );
133 void closeEvent( QCloseEvent *event ); 88 void closeEvent( QCloseEvent *event );
134 void keyReleaseEvent( QKeyEvent *e); 89 void keyReleaseEvent( QKeyEvent *e);
135private: 90private:
136 void toggleButton( int ); 91 void toggleButton( int );
137 void setToggleButton( int, bool ); 92 void setToggleButton( int, bool );
138 void paintButton( QPainter *p, int i ); 93 void paintButton( QPainter *p, int i );
94 QString skin;
95 QPixmap *pixBg;
96 QImage *imgUp;
97 QImage *imgDn;
98 QImage *imgButtonMask;
99 QBitmap *masks[11];
100 QPixmap *buttonPixUp[11];
101 QPixmap *buttonPixDown[11];
102
139 QPixmap *pixmaps[4]; 103 QPixmap *pixmaps[4];
140 Ticker *songInfo; 104 OTicker songInfo;
141 QSlider *slider; 105 QSlider slider;
106 QLineEdit time;
107 int xoff, yoff;
108
142}; 109};
143 110
144 111
145#endif // AUDIO_WIDGET_H 112#endif // AUDIO_WIDGET_H
146 113
diff --git a/core/multimedia/opieplayer/inputDialog.cpp b/core/multimedia/opieplayer/inputDialog.cpp
index da8e276..62240b2 100644
--- a/core/multimedia/opieplayer/inputDialog.cpp
+++ b/core/multimedia/opieplayer/inputDialog.cpp
@@ -1,67 +1,62 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:55:03 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "inputDialog.h" 1#include "inputDialog.h"
10 2
11#include <qpe/resource.h> 3#include <qpe/resource.h>
12 4
13#include <opie/ofiledialog.h> 5#include <opie/ofiledialog.h>
14 6
15#include <qlineedit.h> 7#include <qlineedit.h>
16#include <qlayout.h> 8#include <qlayout.h>
17#include <qvariant.h> 9#include <qvariant.h>
18#include <qpushbutton.h> 10#include <qpushbutton.h>
19#include <qwhatsthis.h> 11#include <qwhatsthis.h>
20 12
21InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
22 : QDialog( parent, name, modal, fl ) 14 : QDialog( parent, name, modal, fl ) {
23{ 15 if ( !name ) {
24 if ( !name ) 16 setName( "InputDialog" );
25 setName( "InputDialog" ); 17 }
26 resize( 234, 115); 18 resize( 234, 115);
27 setMaximumSize( QSize( 240, 40)); 19 setMaximumSize( QSize( 240, 40));
28 setCaption( tr(name ) ); 20 setCaption( tr( name ) );
29 21
30 QPushButton *browserButton; 22 QPushButton *browserButton;
31 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 23 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
32 browserButton->setGeometry( QRect( 205, 10, 22, 22)); 24 browserButton->setGeometry( QRect( 205, 10, 22, 22));
33 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 25 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
34 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 26 LineEdit1 = new QLineEdit( this, "LineEdit1" );
35 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
28 LineEdit1->setFocus();
29}
30/*
31 * return the current text(input)
32 */
33QString InputDialog::text() const {
34 return LineEdit1->text();
36} 35}
37
38/* 36/*
39 * Destroys the object and frees any allocated resources 37 * Destroys the object and frees any allocated resources
40 */ 38 */
41InputDialog::~InputDialog() 39InputDialog::~InputDialog() {
42{
43 inputText= LineEdit1->text();
44
45} 40}
46 41
47void InputDialog::browse() { 42void InputDialog::browse() {
48 43
49 MimeTypes types; 44 MimeTypes types;
50 QStringList audio, video, all; 45 QStringList audio, video, all;
51 audio << "audio/*"; 46 audio << "audio/*";
52 audio << "playlist/plain"; 47 audio << "playlist/plain";
53 audio << "audio/x-mpegurl"; 48 audio << "audio/x-mpegurl";
54 49
55 video << "video/*"; 50 video << "video/*";
56 video << "playlist/plain"; 51 video << "playlist/plain";
57 52
58 all += audio; 53 all += audio;
59 all += video; 54 all += video;
60 types.insert("All Media Files", all ); 55 types.insert("All Media Files", all );
61 types.insert("Audio", audio ); 56 types.insert("Audio", audio );
62 types.insert("Video", video ); 57 types.insert("Video", video );
63 58
64 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 59 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
65 LineEdit1->setText(str); 60 LineEdit1->setText(str);
66} 61}
67 62
diff --git a/core/multimedia/opieplayer/inputDialog.h b/core/multimedia/opieplayer/inputDialog.h
index 3e3e36f..0f36ea4 100644
--- a/core/multimedia/opieplayer/inputDialog.h
+++ b/core/multimedia/opieplayer/inputDialog.h
@@ -1,30 +1,25 @@
1/**************************************************************************** 1
2** Form interface generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:54:46 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef INPUTDIALOG_H 2#ifndef INPUTDIALOG_H
10#define INPUTDIALOG_H 3#define INPUTDIALOG_H
11 4
12#include <qvariant.h> 5#include <qvariant.h>
13#include <qdialog.h> 6#include <qdialog.h>
14 7
15class QLineEdit; 8class QLineEdit;
16 9
17class InputDialog : public QDialog 10class InputDialog : public QDialog {
18{
19 Q_OBJECT 11 Q_OBJECT
20 12
21public: 13public:
22 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 14 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
23 ~InputDialog(); 15 ~InputDialog();
24 QString inputText; 16 QString text()const;
17
18private:
25 QLineEdit* LineEdit1; 19 QLineEdit* LineEdit1;
20
26protected slots: 21protected slots:
27 void browse(); 22 void browse();
28}; 23};
29 24
30#endif // INPUTDIALOG_H 25#endif // INPUTDIALOG_H
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index 64fdc01..b0963cf 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -1,220 +1,225 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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 <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/qlibrary.h> 22#include <qpe/qlibrary.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25 25
26#include <qmainwindow.h> 26#include <qmainwindow.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qfile.h> 29#include <qfile.h>
30 30
31#include "mediaplayer.h" 31#include "mediaplayer.h"
32#include "playlistwidget.h" 32#include "playlistwidget.h"
33#include "audiowidget.h" 33#include "audiowidget.h"
34#include "loopcontrol.h" 34#include "loopcontrol.h"
35#include "audiodevice.h" 35#include "audiodevice.h"
36 36
37#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
38 38
39 39
40extern AudioWidget *audioUI; 40extern AudioWidget *audioUI;
41extern PlayListWidget *playList; 41extern PlayListWidget *playList;
42extern LoopControl *loopControl; 42extern LoopControl *loopControl;
43extern MediaPlayerState *mediaPlayerState; 43extern MediaPlayerState *mediaPlayerState;
44 44
45 45
46MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 46MediaPlayer::MediaPlayer( QObject *parent, const char *name )
47 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 47 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
48 48
49// QPEApplication::grabKeyboard(); 49// QPEApplication::grabKeyboard();
50 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 50 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
51 51
52 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 52 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
53 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 53 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
54 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 54 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
55 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 55 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
56 56
57 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 57 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
58 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 58 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
59 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 59 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
60 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 60 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
61} 61}
62 62
63 63
64MediaPlayer::~MediaPlayer() { 64MediaPlayer::~MediaPlayer() {
65 65
66} 66}
67 67
68 68
69void MediaPlayer::pauseCheck( bool b ) { 69void MediaPlayer::pauseCheck( bool b ) {
70 // Only pause if playing 70 // Only pause if playing
71 if ( b && !mediaPlayerState->playing() ) 71 if ( b && !mediaPlayerState->playing() )
72 mediaPlayerState->setPaused( FALSE ); 72 mediaPlayerState->setPaused( FALSE );
73} 73}
74 74
75 75
76void MediaPlayer::play() { 76void MediaPlayer::play() {
77 mediaPlayerState->setPlaying( FALSE ); 77 mediaPlayerState->setPlaying( FALSE );
78 mediaPlayerState->setPlaying( TRUE ); 78 mediaPlayerState->setPlaying( TRUE );
79} 79}
80 80
81 81
82void MediaPlayer::setPlaying( bool play ) { 82void MediaPlayer::setPlaying( bool play ) {
83 qDebug("MediaPlayer setPlaying");
83 if ( !play ) { 84 if ( !play ) {
84 mediaPlayerState->setPaused( FALSE ); 85 mediaPlayerState->setPaused( FALSE );
85 loopControl->stop( FALSE ); 86 loopControl->stop( FALSE );
86 return; 87 return;
87 } 88 }
88 89
89 if ( mediaPlayerState->paused() ) { 90 if ( mediaPlayerState->paused() ) {
90 mediaPlayerState->setPaused( FALSE ); 91 mediaPlayerState->setPaused( FALSE );
91 return; 92 return;
92 } 93 }
93 94 qDebug("about to ctrash");
94 const DocLnk *playListCurrent = playList->current(); 95 const DocLnk *playListCurrent = playList->current();
96
95 if ( playListCurrent != NULL ) { 97 if ( playListCurrent != NULL ) {
96 loopControl->stop( TRUE ); 98 loopControl->stop( TRUE );
97 currentFile = playListCurrent; 99 currentFile = playListCurrent;
98 } 100 }
99 if ( currentFile == NULL ) { 101 if ( currentFile == NULL ) {
100 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); 102 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) );
101 mediaPlayerState->setPlaying( FALSE ); 103 mediaPlayerState->setPlaying( FALSE );
102 return; 104 return;
103 } 105 }
104 106
105 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { 107 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
106 QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); 108 QMessageBox::critical( 0, tr( "File not found"),
107 mediaPlayerState->setPlaying( FALSE ); 109 tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" );
108 return; 110 mediaPlayerState->setPlaying( FALSE );
111 return;
109 } 112 }
110 113
111 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { 114 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
112 QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); 115 QMessageBox::critical( 0, tr( "No decoder found"),
113 mediaPlayerState->setPlaying( FALSE ); 116 tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" );
114 return; 117 mediaPlayerState->setPlaying( FALSE );
118 return;
115 } 119 }
116 120
117 if ( !loopControl->init( currentFile->file() ) ) { 121 if ( !loopControl->init( currentFile->file() ) ) {
118 QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); 122 QMessageBox::critical( 0, tr( "Error opening file"),
119 mediaPlayerState->setPlaying( FALSE ); 123 tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" );
120 return; 124 mediaPlayerState->setPlaying( FALSE );
125 return;
121 } 126 }
122 long seconds = loopControl->totalPlaytime(); 127 long seconds = loopControl->totalPlaytime();
123 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 128 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
124 QString tickerText; 129 QString tickerText;
125 if( currentFile->file().left(4) == "http" ) 130 if( currentFile->file().left(4) == "http" )
126 tickerText= tr( " File: " ) + currentFile->name(); 131 tickerText= tr( " File: " ) + currentFile->name();
127 else 132 else
128 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 133 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
129 134
130 QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); 135 QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
131 if ( !fileInfo.isEmpty() ) 136 if ( !fileInfo.isEmpty() )
132 tickerText += ", " + fileInfo; 137 tickerText += ", " + fileInfo;
133 audioUI->setTickerText( tickerText + "." ); 138 audioUI->setTickerText( tickerText + "." );
134 139
135 loopControl->play(); 140 loopControl->play();
136 141
137 mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); 142 mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' );
138} 143}
139 144
140 145
141void MediaPlayer::prev() { 146void MediaPlayer::prev() {
142 if ( playList->prev() ) 147 if ( playList->prev() )
143 play(); 148 play();
144 else if ( mediaPlayerState->looping() ) { 149 else if ( mediaPlayerState->looping() ) {
145 if ( playList->last() ) 150 if ( playList->last() )
146 play(); 151 play();
147 } else 152 } else
148 mediaPlayerState->setList(); 153 mediaPlayerState->setList();
149} 154}
150 155
151 156
152void MediaPlayer::next() { 157void MediaPlayer::next() {
153 if ( playList->next() ) 158 if ( playList->next() )
154 play(); 159 play();
155 else if ( mediaPlayerState->looping() ) { 160 else if ( mediaPlayerState->looping() ) {
156 if ( playList->first() ) 161 if ( playList->first() )
157 play(); 162 play();
158 } else 163 } else
159 mediaPlayerState->setList(); 164 mediaPlayerState->setList();
160} 165}
161 166
162 167
163void MediaPlayer::startDecreasingVolume() { 168void MediaPlayer::startDecreasingVolume() {
164 volumeDirection = -1; 169 volumeDirection = -1;
165 startTimer( 100 ); 170 startTimer( 100 );
166 AudioDevice::decreaseVolume(); 171 AudioDevice::decreaseVolume();
167} 172}
168 173
169 174
170void MediaPlayer::startIncreasingVolume() { 175void MediaPlayer::startIncreasingVolume() {
171 volumeDirection = +1; 176 volumeDirection = +1;
172 startTimer( 100 ); 177 startTimer( 100 );
173 AudioDevice::increaseVolume(); 178 AudioDevice::increaseVolume();
174} 179}
175 180
176 181
177void MediaPlayer::stopChangingVolume() { 182void MediaPlayer::stopChangingVolume() {
178 killTimers(); 183 killTimers();
179} 184}
180 185
181 186
182void MediaPlayer::timerEvent( QTimerEvent * ) { 187void MediaPlayer::timerEvent( QTimerEvent * ) {
183 if ( volumeDirection == +1 ) 188 if ( volumeDirection == +1 )
184 AudioDevice::increaseVolume(); 189 AudioDevice::increaseVolume();
185 else if ( volumeDirection == -1 ) 190 else if ( volumeDirection == -1 )
186 AudioDevice::decreaseVolume(); 191 AudioDevice::decreaseVolume();
187} 192}
188 193
189void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 194void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
190 switch ( e->key() ) { 195 switch ( e->key() ) {
191////////////////////////////// Zaurus keys 196////////////////////////////// Zaurus keys
192 case Key_Home: 197 case Key_Home:
193 break; 198 break;
194 case Key_F9: //activity 199 case Key_F9: //activity
195 break; 200 break;
196 case Key_F10: //contacts 201 case Key_F10: //contacts
197 break; 202 break;
198 case Key_F11: //menu 203 case Key_F11: //menu
199 break; 204 break;
200 case Key_F12: //home 205 case Key_F12: //home
201 qDebug("Blank here"); 206 qDebug("Blank here");
202 break; 207 break;
203 case Key_F13: //mail 208 case Key_F13: //mail
204 break; 209 break;
205 } 210 }
206} 211}
207 212
208void MediaPlayer::doBlank() { 213void MediaPlayer::doBlank() {
209 214
210} 215}
211 216
212void MediaPlayer::doUnblank() { 217void MediaPlayer::doUnblank() {
213 218
214} 219}
215 220
216void MediaPlayer::cleanUp() { 221void MediaPlayer::cleanUp() {
217// QPEApplication::grabKeyboard(); 222// QPEApplication::grabKeyboard();
218// QPEApplication::ungrabKeyboard(); 223// QPEApplication::ungrabKeyboard();
219 224
220} 225}
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h
index 06c5556..26185c5 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.h
+++ b/core/multimedia/opieplayer/mediaplayerstate.h
@@ -1,119 +1,121 @@
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#ifndef MEDIA_PLAYER_STATE_H 20#ifndef MEDIA_PLAYER_STATE_H
21#define MEDIA_PLAYER_STATE_H 21#define MEDIA_PLAYER_STATE_H
22 22
23 23
24#include <qobject.h> 24#include <qobject.h>
25 25
26 26
27class MediaPlayerDecoder; 27class MediaPlayerDecoder;
28class Config; 28class Config;
29 29
30 30
31class MediaPlayerState : public QObject { 31class MediaPlayerState : public QObject {
32Q_OBJECT 32Q_OBJECT
33public: 33public:
34 MediaPlayerState( QObject *parent, const char *name ); 34 MediaPlayerState( QObject *parent, const char *name );
35 ~MediaPlayerState(); 35 ~MediaPlayerState();
36 36
37 bool isStreaming; 37 bool isStreaming;
38 bool fullscreen() { return isFullscreen; } 38 bool fullscreen() { return isFullscreen; }
39 bool scaled() { return isScaled; } 39 bool scaled() { return isScaled; }
40 bool looping() { return isLooping; } 40 bool looping() { return isLooping; }
41 bool shuffled() { return isShuffled; } 41 bool shuffled() { return isShuffled; }
42 bool playlist() { return usePlaylist; } 42 bool playlist() { return usePlaylist; }
43 bool paused() { return isPaused; } 43 bool paused() { return isPaused; }
44 bool playing() { return isPlaying; } 44 bool playing() { return isPlaying; }
45 long position() { return curPosition; } 45 long position() { return curPosition; }
46 long length() { return curLength; } 46 long length() { return curLength; }
47 char view() { return curView; } 47 char view() { return curView; }
48 48
49 MediaPlayerDecoder *newDecoder( const QString& file ); 49 MediaPlayerDecoder *newDecoder( const QString& file );
50 MediaPlayerDecoder *curDecoder(); 50 MediaPlayerDecoder *curDecoder();
51 MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the 51 MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the
52 // number of audio samples if we are using the libmad plugin 52 // number of audio samples if we are using the libmad plugin
53public slots: 53public slots:
54 void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } 54 void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); }
55 void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } 55 void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); }
56 void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } 56 void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); }
57 void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } 57 void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); }
58 void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } 58 void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); }
59 void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } 59 void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); }
60 void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } 60
61 void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); }
62
61 void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } 63 void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); }
62 void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } 64 void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); }
63 void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } 65 void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); }
64 void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } 66 void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); }
65 67
66 void setPrev() { emit prev(); } 68 void setPrev() { emit prev(); }
67 void setNext() { emit next(); } 69 void setNext() { emit next(); }
68 void setList() { setPlaying( FALSE ); setView('l'); } 70 void setList() { setPlaying( FALSE ); setView('l'); }
69 void setVideo() { setView('v'); } 71 void setVideo() { setView('v'); }
70 void setAudio() { setView('a'); } 72 void setAudio() { setView('a'); }
71 73
72 void toggleFullscreen() { setFullscreen( !isFullscreen ); } 74 void toggleFullscreen() { setFullscreen( !isFullscreen ); }
73 void toggleScaled() { setScaled( !isScaled); } 75 void toggleScaled() { setScaled( !isScaled); }
74 void toggleLooping() { setLooping( !isLooping); } 76 void toggleLooping() { setLooping( !isLooping); }
75 void toggleShuffled() { setShuffled( !isShuffled); } 77 void toggleShuffled() { setShuffled( !isShuffled); }
76 void togglePlaylist() { setPlaylist( !usePlaylist); } 78 void togglePlaylist() { setPlaylist( !usePlaylist); }
77 void togglePaused() { setPaused( !isPaused); } 79 void togglePaused() { setPaused( !isPaused); }
78 void togglePlaying() { setPlaying( !isPlaying); } 80 void togglePlaying() { setPlaying( !isPlaying); }
79 81
80signals: 82signals:
81 void fullscreenToggled( bool ); 83 void fullscreenToggled( bool );
82 void scaledToggled( bool ); 84 void scaledToggled( bool );
83 void loopingToggled( bool ); 85 void loopingToggled( bool );
84 void shuffledToggled( bool ); 86 void shuffledToggled( bool );
85 void playlistToggled( bool ); 87 void playlistToggled( bool );
86 void pausedToggled( bool ); 88 void pausedToggled( bool );
87 void playingToggled( bool ); 89 void playingToggled( bool );
88 void positionChanged( long ); // When the slider is moved 90 void positionChanged( long ); // When the slider is moved
89 void positionUpdated( long ); // When the media file progresses 91 void positionUpdated( long ); // When the media file progresses
90 void lengthChanged( long ); 92 void lengthChanged( long );
91 void viewChanged( char ); 93 void viewChanged( char );
92 94
93 void prev(); 95 void prev();
94 void next(); 96 void next();
95 97
96private: 98private:
97 bool isFullscreen; 99 bool isFullscreen;
98 bool isScaled; 100 bool isScaled;
99 bool isLooping; 101 bool isLooping;
100 bool isShuffled; 102 bool isShuffled;
101 bool usePlaylist; 103 bool usePlaylist;
102 bool isPaused; 104 bool isPaused;
103 bool isPlaying; 105 bool isPlaying;
104 long curPosition; 106 long curPosition;
105 long curLength; 107 long curLength;
106 char curView; 108 char curView;
107 109
108 MediaPlayerDecoder *decoder; 110 MediaPlayerDecoder *decoder;
109 MediaPlayerDecoder *libmpeg3decoder; 111 MediaPlayerDecoder *libmpeg3decoder;
110// MediaPlayerDecoder *libwavdecoder; 112// MediaPlayerDecoder *libwavdecoder;
111 113
112 void loadPlugins(); 114 void loadPlugins();
113 void readConfig( Config& cfg ); 115 void readConfig( Config& cfg );
114 void writeConfig( Config& cfg ) const; 116 void writeConfig( Config& cfg ) const;
115}; 117};
116 118
117 119
118#endif // MEDIA_PLAYER_STATE_H 120#endif // MEDIA_PLAYER_STATE_H
119 121
diff --git a/core/multimedia/opieplayer/opie-mediaplayer.control b/core/multimedia/opieplayer/opie-mediaplayer.control
index 3bfb911..da193c0 100644
--- a/core/multimedia/opieplayer/opie-mediaplayer.control
+++ b/core/multimedia/opieplayer/opie-mediaplayer.control
@@ -1,9 +1,9 @@
1Files: bin/opieplayer pics/opieplayer apps/Applications/opieplayer.desktop 1Files: bin/opieplayer pics/opieplayer apps/Applications/opieplayer.desktop pics/opieplayer2/skins/default
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: L.J.Potter <ljp@llornkcor.com> 4Maintainer: L.J.Potter <ljp@llornkcor.com>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION)
8Description: The Opie media player 8Description: The Opie media player
9 The mediaplayer for Opie. It plays mp3, mpeg, and wav. 9 The mediaplayer for Opie. It plays mp3, mpeg, and wav.
diff --git a/core/multimedia/opieplayer/opieplayer.pro b/core/multimedia/opieplayer/opieplayer.pro
index e111717..6f22280 100644
--- a/core/multimedia/opieplayer/opieplayer.pro
+++ b/core/multimedia/opieplayer/opieplayer.pro
@@ -1,31 +1,34 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3#release 3#release
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5HEADERS = loopcontrol.h mediaplayerplugininterface.h playlistselection.h mediaplayerstate.h \ 5HEADERS = loopcontrol.h mediaplayerplugininterface.h \
6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h 6 playlistselection.h mediaplayerstate.h \
7 videowidget.h audiowidget.h playlistwidget.h \
8 mediaplayer.h audiodevice.h inputDialog.h om3u.h
7SOURCES = main.cpp \ 9SOURCES = main.cpp \
8 loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ 10 loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \
9 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp 11 videowidget.cpp audiowidget.cpp playlistwidget.cpp \
12 mediaplayer.cpp audiodevice.cpp inputDialog.cpp om3u.cpp
10TARGET = opieplayer 13TARGET = opieplayer
11INCLUDEPATH += $(OPIEDIR)/include 14INCLUDEPATH += $(OPIEDIR)/include
12DEPENDPATH += $(OPIEDIR)/include 15DEPENDPATH += $(OPIEDIR)/include
13LIBS += -lqpe -lpthread -lopie 16LIBS += -lqpe -lpthread -lopie
14 17
15INCLUDEPATH += $(OPIEDIR)/include 18INCLUDEPATH += $(OPIEDIR)/include
16DEPENDPATH += $(OPIEDIR)/include 19DEPENDPATH += $(OPIEDIR)/include
17 20
18TRANSLATIONS = ../../../i18n/de/opieplayer.ts \ 21TRANSLATIONS = ../../../i18n/de/opieplayer.ts \
19 ../../../i18n/en/opieplayer.ts \ 22 ../../../i18n/en/opieplayer.ts \
20 ../../../i18n/es/opieplayer.ts \ 23 ../../../i18n/es/opieplayer.ts \
21 ../../../i18n/fr/opieplayer.ts \ 24 ../../../i18n/fr/opieplayer.ts \
22 ../../../i18n/hu/opieplayer.ts \ 25 ../../../i18n/hu/opieplayer.ts \
23 ../../../i18n/ja/opieplayer.ts \ 26 ../../../i18n/ja/opieplayer.ts \
24 ../../../i18n/ko/opieplayer.ts \ 27 ../../../i18n/ko/opieplayer.ts \
25 ../../../i18n/no/opieplayer.ts \ 28 ../../../i18n/no/opieplayer.ts \
26 ../../../i18n/pl/opieplayer.ts \ 29 ../../../i18n/pl/opieplayer.ts \
27 ../../../i18n/pt/opieplayer.ts \ 30 ../../../i18n/pt/opieplayer.ts \
28 ../../../i18n/pt_BR/opieplayer.ts \ 31 ../../../i18n/pt_BR/opieplayer.ts \
29 ../../../i18n/sl/opieplayer.ts \ 32 ../../../i18n/sl/opieplayer.ts \
30 ../../../i18n/zh_CN/opieplayer.ts \ 33 ../../../i18n/zh_CN/opieplayer.ts \
31 ../../../i18n/zh_TW/opieplayer.ts 34 ../../../i18n/zh_TW/opieplayer.ts
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 5be0d6d..6580a88 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1332 +1,1352 @@
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#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23 23
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/lnkproperties.h> 28#include <qpe/lnkproperties.h>
29#include <qpe/storage.h> 29#include <qpe/storage.h>
30 30
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/global.h> 33#include <qpe/global.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qaction.h> 35#include <qaction.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qimage.h> 37#include <qimage.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlist.h> 42#include <qlist.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qmainwindow.h> 44#include <qmainwindow.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qtoolbutton.h> 46#include <qtoolbutton.h>
47#include <qtabwidget.h> 47#include <qtabwidget.h>
48#include <qlistview.h> 48#include <qlistview.h>
49#include <qpoint.h> 49#include <qpoint.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qtextstream.h> 53#include <qtextstream.h>
54 54
55//#include <qtimer.h> 55//#include <qtimer.h>
56 56
57#include "playlistselection.h" 57#include "playlistselection.h"
58#include "playlistwidget.h" 58#include "playlistwidget.h"
59#include "mediaplayerstate.h" 59#include "mediaplayerstate.h"
60 60
61#include "inputDialog.h" 61#include "inputDialog.h"
62 62
63#include <stdlib.h> 63#include <stdlib.h>
64#include "audiowidget.h" 64#include "audiowidget.h"
65#include "videowidget.h" 65#include "videowidget.h"
66 66
67#include <unistd.h> 67#include <unistd.h>
68#include <sys/file.h> 68#include <sys/file.h>
69#include <sys/ioctl.h> 69#include <sys/ioctl.h>
70#include <sys/soundcard.h> 70#include <sys/soundcard.h>
71 71
72// for setBacklight() 72// for setBacklight()
73#include <linux/fb.h> 73#include <linux/fb.h>
74#include <sys/types.h> 74#include <sys/types.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <stdlib.h> 76#include <stdlib.h>
77 77
78#define BUTTONS_ON_TOOLBAR 78#define BUTTONS_ON_TOOLBAR
79#define SIDE_BUTTONS 79#define SIDE_BUTTONS
80#define CAN_SAVE_LOAD_PLAYLISTS 80#define CAN_SAVE_LOAD_PLAYLISTS
81 81
82extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
86// class myFileSelector { 87// class myFileSelector {
87 88
88// }; 89// };
89class PlayListWidgetPrivate { 90class PlayListWidgetPrivate {
90public: 91public:
91 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 92 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
92 QFrame *playListFrame; 93 QFrame *playListFrame;
93 FileSelector *files; 94 FileSelector *files;
94 PlayListSelection *selectedFiles; 95 PlayListSelection *selectedFiles;
95 bool setDocumentUsed; 96 bool setDocumentUsed;
96 DocLnk *current; 97 DocLnk *current;
97}; 98};
98 99
99 100
100class ToolButton : public QToolButton { 101class ToolButton : public QToolButton {
101public: 102public:
102 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 103 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
103 : QToolButton( parent, name ) { 104 : QToolButton( parent, name ) {
104 setTextLabel( name ); 105 setTextLabel( name );
105 setPixmap( Resource::loadPixmap( icon ) ); 106 setPixmap( Resource::loadPixmap( icon ) );
106 setAutoRaise( TRUE ); 107 setAutoRaise( TRUE );
107 setFocusPolicy( QWidget::NoFocus ); 108 setFocusPolicy( QWidget::NoFocus );
108 setToggleButton( t ); 109 setToggleButton( t );
109 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 110 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
110 QPEMenuToolFocusManager::manager()->addWidget( this ); 111 QPEMenuToolFocusManager::manager()->addWidget( this );
111 } 112 }
112}; 113};
113 114
114 115
115class MenuItem : public QAction { 116class MenuItem : public QAction {
116public: 117public:
117 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 118 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
118 : QAction( text, QString::null, 0, 0 ) { 119 : QAction( text, QString::null, 0, 0 ) {
119 connect( this, SIGNAL( activated() ), handler, slot ); 120 connect( this, SIGNAL( activated() ), handler, slot );
120 addTo( parent ); 121 addTo( parent );
121 } 122 }
122}; 123};
123 124
124 125
125PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 126PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
126 : QMainWindow( parent, name, fl ) { 127 : QMainWindow( parent, name, fl ) {
127 128
128 d = new PlayListWidgetPrivate; 129 d = new PlayListWidgetPrivate;
129 d->setDocumentUsed = FALSE; 130 d->setDocumentUsed = FALSE;
130 d->current = NULL; 131 d->current = NULL;
131 fromSetDocument = FALSE; 132 fromSetDocument = FALSE;
132 insanityBool=FALSE; 133 insanityBool=FALSE;
133 audioScan = FALSE; 134 audioScan = FALSE;
134 videoScan = FALSE; 135 videoScan = FALSE;
135// menuTimer = new QTimer( this ,"menu timer"), 136// menuTimer = new QTimer( this ,"menu timer"),
136// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 137// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
137 138
138 setBackgroundMode( PaletteButton ); 139 setBackgroundMode( PaletteButton );
139 140
140 setCaption( tr("OpiePlayer") ); 141 setCaption( tr("OpiePlayer") );
141 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 142 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
142 143
143 setToolBarsMovable( FALSE ); 144 setToolBarsMovable( FALSE );
144 145
145 // Create Toolbar 146 // Create Toolbar
146 QPEToolBar *toolbar = new QPEToolBar( this ); 147 QPEToolBar *toolbar = new QPEToolBar( this );
147 toolbar->setHorizontalStretchable( TRUE ); 148 toolbar->setHorizontalStretchable( TRUE );
148 149
149 // Create Menubar 150 // Create Menubar
150 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 151 QPEMenuBar *menu = new QPEMenuBar( toolbar );
151 menu->setMargin( 0 ); 152 menu->setMargin( 0 );
152 153
153 QPEToolBar *bar = new QPEToolBar( this ); 154 QPEToolBar *bar = new QPEToolBar( this );
154 bar->setLabel( tr( "Play Operations" ) ); 155 bar->setLabel( tr( "Play Operations" ) );
155// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 156// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
156// this , SLOT( addSelected()) ); 157// this , SLOT( addSelected()) );
157 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 158 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
158 tbDeletePlaylist->setFlat(TRUE); 159 tbDeletePlaylist->setFlat(TRUE);
159 tbDeletePlaylist->setFixedSize(20,20); 160 tbDeletePlaylist->setFixedSize(20,20);
160 161
161 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 162 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
162 this , SLOT(addSelected()) ); 163 this , SLOT(addSelected()) );
163 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 164 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
164 this , SLOT(removeSelected()) ); 165 this , SLOT(removeSelected()) );
165// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 166// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
166 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 167 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
167 this , SLOT( btnPlay(bool) ), TRUE ); 168 this , SLOT( btnPlay(bool) ), TRUE );
168 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 169 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
169 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 170 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
170 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 171 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
171 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 172 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
172 tbDeletePlaylist->hide(); 173 tbDeletePlaylist->hide();
173 174
174 QPopupMenu *pmPlayList = new QPopupMenu( this ); 175 QPopupMenu *pmPlayList = new QPopupMenu( this );
175 menu->insertItem( tr( "File" ), pmPlayList ); 176 menu->insertItem( tr( "File" ), pmPlayList );
176 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 177 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
177 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 178 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
178 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 179 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 180 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
180 pmPlayList->insertSeparator(-1); 181 pmPlayList->insertSeparator(-1);
181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 182 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
182 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
183 pmPlayList->insertSeparator(-1);
184 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 183 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
185 pmPlayList->insertSeparator(-1); 184 pmPlayList->insertSeparator(-1);
186 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 185 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
187 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 186 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
188 187
189 QPopupMenu *pmView = new QPopupMenu( this ); 188 QPopupMenu *pmView = new QPopupMenu( this );
190 menu->insertItem( tr( "View" ), pmView ); 189 menu->insertItem( tr( "View" ), pmView );
191 190
192 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 191 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
193 fullScreenButton->addTo(pmView); 192 fullScreenButton->addTo(pmView);
194 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 193 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
195 scaleButton->addTo(pmView); 194 scaleButton->addTo(pmView);
196 195
197 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 196 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
198 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 197 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
199 198
200 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 199 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
201 200
202 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 201 tabWidget = new QTabWidget( hbox6, "tabWidget" );
203 tabWidget->setTabShape(QTabWidget::Triangular); 202 tabWidget->setTabShape(QTabWidget::Triangular);
204 203
205 QWidget *pTab; 204 QWidget *pTab;
206 pTab = new QWidget( tabWidget, "pTab" ); 205 pTab = new QWidget( tabWidget, "pTab" );
207// playlistView = new QListView( pTab, "playlistview" ); 206// playlistView = new QListView( pTab, "playlistview" );
208// playlistView->setMinimumSize(236,260); 207// playlistView->setMinimumSize(236,260);
209 tabWidget->insertTab( pTab,"Playlist"); 208 tabWidget->insertTab( pTab,"Playlist");
210 209
211 210
212 // Add the playlist area 211 // Add the playlist area
213 212
214 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 213 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
215 d->playListFrame = vbox3; 214 d->playListFrame = vbox3;
216 d->playListFrame ->setMinimumSize(235,260); 215 d->playListFrame ->setMinimumSize(235,260);
217 216
218 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 217 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
219 218
220 d->selectedFiles = new PlayListSelection( hbox2); 219 d->selectedFiles = new PlayListSelection( hbox2);
221 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 220 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
222 221
223 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 222 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
224 223
225 224
226 225
227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 226 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 227 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 228 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 229 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 230 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
232 231
233 QWidget *aTab; 232 QWidget *aTab;
234 aTab = new QWidget( tabWidget, "aTab" ); 233 aTab = new QWidget( tabWidget, "aTab" );
235 audioView = new QListView( aTab, "Audioview" ); 234 audioView = new QListView( aTab, "Audioview" );
236 audioView->setMinimumSize(233,260); 235 audioView->setMinimumSize(233,260);
237 audioView->addColumn( tr("Title"),140); 236 audioView->addColumn( tr("Title"),140);
238 audioView->addColumn(tr("Size"), -1); 237 audioView->addColumn(tr("Size"), -1);
239 audioView->addColumn(tr("Media"),-1); 238 audioView->addColumn(tr("Media"),-1);
240 audioView->setColumnAlignment(1, Qt::AlignRight); 239 audioView->setColumnAlignment(1, Qt::AlignRight);
241 audioView->setColumnAlignment(2, Qt::AlignRight); 240 audioView->setColumnAlignment(2, Qt::AlignRight);
242 audioView->setAllColumnsShowFocus(TRUE); 241 audioView->setAllColumnsShowFocus(TRUE);
243 242
244 audioView->setMultiSelection( TRUE ); 243 audioView->setMultiSelection( TRUE );
245 audioView->setSelectionMode( QListView::Extended); 244 audioView->setSelectionMode( QListView::Extended);
246 245
247 tabWidget->insertTab(aTab,tr("Audio")); 246 tabWidget->insertTab(aTab,tr("Audio"));
248 247
249 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 248 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
250 249
251// audioView 250// audioView
252// populateAudioView(); 251// populateAudioView();
253// videowidget 252// videowidget
254 253
255 QWidget *vTab; 254 QWidget *vTab;
256 vTab = new QWidget( tabWidget, "vTab" ); 255 vTab = new QWidget( tabWidget, "vTab" );
257 videoView = new QListView( vTab, "Videoview" ); 256 videoView = new QListView( vTab, "Videoview" );
258 videoView->setMinimumSize(233,260); 257 videoView->setMinimumSize(233,260);
259 258
260 videoView->addColumn(tr("Title"),140); 259 videoView->addColumn(tr("Title"),140);
261 videoView->addColumn(tr("Size"),-1); 260 videoView->addColumn(tr("Size"),-1);
262 videoView->addColumn(tr("Media"),-1); 261 videoView->addColumn(tr("Media"),-1);
263 videoView->setColumnAlignment(1, Qt::AlignRight); 262 videoView->setColumnAlignment(1, Qt::AlignRight);
264 videoView->setColumnAlignment(2, Qt::AlignRight); 263 videoView->setColumnAlignment(2, Qt::AlignRight);
265 videoView->setAllColumnsShowFocus(TRUE); 264 videoView->setAllColumnsShowFocus(TRUE);
266 videoView->setMultiSelection( TRUE ); 265 videoView->setMultiSelection( TRUE );
267 videoView->setSelectionMode( QListView::Extended); 266 videoView->setSelectionMode( QListView::Extended);
268 267
269 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 268 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
270 269
271 tabWidget->insertTab( vTab,tr("Video")); 270 tabWidget->insertTab( vTab,tr("Video"));
272 271
273 QWidget *LTab; 272 QWidget *LTab;
274 LTab = new QWidget( tabWidget, "LTab" ); 273 LTab = new QWidget( tabWidget, "LTab" );
275 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 274 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
276 playLists->setMinimumSize(233,260); 275 playLists->setMinimumSize(233,260);
277 tabWidget->insertTab(LTab,tr("Lists")); 276 tabWidget->insertTab(LTab,tr("Lists"));
278 277
279 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 278 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
280 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 279 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
281 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 280 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
281
282 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 282 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
283 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 283 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
284 284
285 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 285 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
286 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 286 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
287 287
288 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 288 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
289 this,SLOT( playIt( QListViewItem *)) ); 289 this,SLOT( playIt( QListViewItem *)) );
290 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 290 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
291 291
292 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 292 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
293 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 293 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
294 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 294 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
295 this,SLOT( playIt( QListViewItem *)) ); 295 this,SLOT( playIt( QListViewItem *)) );
296 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 296 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
297 297
298 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 298 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
299 299
300 300
301 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 301 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
302 302
303 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 303// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
304 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 304 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
305 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 305 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
306 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 306 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
307 307
308 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 308 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
309 309
310 setCentralWidget( vbox5 ); 310 setCentralWidget( vbox5 );
311 311
312 Config cfg( "OpiePlayer" ); 312 Config cfg( "OpiePlayer" );
313 readConfig( cfg ); 313 readConfig( cfg );
314 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 314 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
315 loadList(DocLnk( currentPlaylist)); 315 loadList(DocLnk( currentPlaylist));
316 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 316 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
317 317
318 initializeStates(); 318 initializeStates();
319} 319}
320 320
321 321
322PlayListWidget::~PlayListWidget() { 322PlayListWidget::~PlayListWidget() {
323 Config cfg( "OpiePlayer" ); 323 Config cfg( "OpiePlayer" );
324 writeConfig( cfg ); 324 writeConfig( cfg );
325
326 325
327 if ( d->current ) 326 if ( d->current )
328 delete d->current; 327 delete d->current;
329 delete d; 328 delete d;
330} 329}
331 330
332 331
333void PlayListWidget::initializeStates() { 332void PlayListWidget::initializeStates() {
334 333
335 d->tbPlay->setOn( mediaPlayerState->playing() ); 334 d->tbPlay->setOn( mediaPlayerState->playing() );
336 d->tbLoop->setOn( mediaPlayerState->looping() ); 335 d->tbLoop->setOn( mediaPlayerState->looping() );
337 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 336 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
338 setPlaylist( true); 337 setPlaylist( true);
339} 338}
340 339
341 340
342void PlayListWidget::readConfig( Config& cfg ) { 341void PlayListWidget::readConfig( Config& cfg ) {
343 cfg.setGroup("PlayList"); 342 cfg.setGroup("PlayList");
344 QString currentString = cfg.readEntry("current", "" ); 343 QString currentString = cfg.readEntry("current", "" );
345 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 344 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
346 for ( int i = 0; i < noOfFiles; i++ ) { 345 for ( int i = 0; i < noOfFiles; i++ ) {
347 QString entryName; 346 QString entryName;
348 entryName.sprintf( "File%i", i + 1 ); 347 entryName.sprintf( "File%i", i + 1 );
349 QString linkFile = cfg.readEntry( entryName ); 348 QString linkFile = cfg.readEntry( entryName );
350 DocLnk lnk( linkFile ); 349 DocLnk lnk( linkFile );
351 if ( lnk.isValid() ) { 350 if ( lnk.isValid() ) {
352 d->selectedFiles->addToSelection( lnk ); 351 d->selectedFiles->addToSelection( lnk );
353 } 352 }
354 } 353 }
355 d->selectedFiles->setSelectedItem( currentString); 354 d->selectedFiles->setSelectedItem( currentString);
356} 355}
357 356
358 357
359void PlayListWidget::writeConfig( Config& cfg ) const { 358void PlayListWidget::writeConfig( Config& cfg ) const {
360 359
361 d->selectedFiles->writeCurrent( cfg); 360 d->selectedFiles->writeCurrent( cfg);
362 cfg.setGroup("PlayList"); 361 cfg.setGroup("PlayList");
363 int noOfFiles = 0; 362 int noOfFiles = 0;
364 d->selectedFiles->first(); 363 d->selectedFiles->first();
365 do { 364 do {
366 const DocLnk *lnk = d->selectedFiles->current(); 365 const DocLnk *lnk = d->selectedFiles->current();
367 if ( lnk ) { 366 if ( lnk ) {
368 QString entryName; 367 QString entryName;
369 entryName.sprintf( "File%i", noOfFiles + 1 ); 368 entryName.sprintf( "File%i", noOfFiles + 1 );
370// qDebug(entryName); 369// qDebug(entryName);
371 cfg.writeEntry( entryName, lnk->linkFile() ); 370 cfg.writeEntry( entryName, lnk->linkFile() );
372 // if this link does exist, add it so we have the file 371 // if this link does exist, add it so we have the file
373 // next time... 372 // next time...
374 if ( !QFile::exists( lnk->linkFile() ) ) { 373 if ( !QFile::exists( lnk->linkFile() ) ) {
375 // the way writing lnks doesn't really check for out 374 // the way writing lnks doesn't really check for out
376 // of disk space, but check it anyway. 375 // of disk space, but check it anyway.
377 if ( !lnk->writeLink() ) { 376 if ( !lnk->writeLink() ) {
378 QMessageBox::critical( 0, tr("Out of space"), 377 QMessageBox::critical( 0, tr("Out of space"),
379 tr( "There was a problem saving " 378 tr( "There was a problem saving "
380 "the playlist.\n" 379 "the playlist.\n"
381 "Your playlist " 380 "Your playlist "
382 "may be missing some entries\n" 381 "may be missing some entries\n"
383 "the next time you start it." ) 382 "the next time you start it." )
384 ); 383 );
385 } 384 }
386 } 385 }
387 noOfFiles++; 386 noOfFiles++;
388 } 387 }
389 } 388 }
390 while ( d->selectedFiles->next() ); 389 while ( d->selectedFiles->next() );
391 cfg.writeEntry("NumberOfFiles", noOfFiles ); 390 cfg.writeEntry("NumberOfFiles", noOfFiles );
392} 391}
393 392
394 393
395void PlayListWidget::addToSelection( const DocLnk& lnk ) { 394void PlayListWidget::addToSelection( const DocLnk& lnk ) {
396 d->setDocumentUsed = FALSE; 395 d->setDocumentUsed = false;
397 if ( mediaPlayerState->playlist() ) { 396 if ( mediaPlayerState->playlist() ) {
398 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 397 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
399 d->selectedFiles->addToSelection( lnk ); 398 d->selectedFiles->addToSelection( lnk );
400 } 399 }
401 else 400 else
402 mediaPlayerState->setPlaying( TRUE ); 401 mediaPlayerState->setPlaying( true);
403} 402}
404 403
405 404
406void PlayListWidget::clearList() { 405void PlayListWidget::clearList() {
407 while ( first() ) 406 while ( first() )
408 d->selectedFiles->removeSelected(); 407 d->selectedFiles->removeSelected();
409} 408}
410 409
411 410
412void PlayListWidget::addAllToList() { 411void PlayListWidget::addAllToList() {
413 DocLnkSet filesAll; 412 DocLnkSet filesAll;
414 Global::findDocuments(&filesAll, "video/*;audio/*"); 413 Global::findDocuments(&filesAll, "video/*;audio/*");
415 QListIterator<DocLnk> Adit( filesAll.children() ); 414 QListIterator<DocLnk> Adit( filesAll.children() );
416 for ( ; Adit.current(); ++Adit ) 415 for ( ; Adit.current(); ++Adit )
417 if(QFileInfo(Adit.current()->file()).exists()) 416 if(QFileInfo(Adit.current()->file()).exists())
418 d->selectedFiles->addToSelection( **Adit ); 417 d->selectedFiles->addToSelection( **Adit );
419} 418}
420 419
421 420
422void PlayListWidget::addAllMusicToList() { 421void PlayListWidget::addAllMusicToList() {
423 QListIterator<DocLnk> dit( files.children() ); 422 QListIterator<DocLnk> dit( files.children() );
424 for ( ; dit.current(); ++dit ) 423 for ( ; dit.current(); ++dit )
425 if(QFileInfo(dit.current()->file()).exists()) 424 if(QFileInfo(dit.current()->file()).exists())
426 d->selectedFiles->addToSelection( **dit ); 425 d->selectedFiles->addToSelection( **dit );
427} 426}
428 427
429 428
430void PlayListWidget::addAllVideoToList() { 429void PlayListWidget::addAllVideoToList() {
431 QListIterator<DocLnk> dit( vFiles.children() ); 430 QListIterator<DocLnk> dit( vFiles.children() );
432 for ( ; dit.current(); ++dit ) 431 for ( ; dit.current(); ++dit )
433 if(QFileInfo( dit.current()->file()).exists()) 432 if(QFileInfo( dit.current()->file()).exists())
434 d->selectedFiles->addToSelection( **dit ); 433 d->selectedFiles->addToSelection( **dit );
435} 434}
436 435
437 436
438void PlayListWidget::setDocument(const QString& fileref) { 437void PlayListWidget::setDocument(const QString& fileref) {
439 qDebug(fileref); 438 qDebug(fileref);
440 fromSetDocument = TRUE; 439 fromSetDocument = TRUE;
441 if ( fileref.isNull() ) { 440 if ( fileref.isNull() ) {
442 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 441 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
443 return; 442 return;
444 } 443 }
445// qDebug("setDocument "+fileref); 444// qDebug("setDocument "+fileref);
446 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 445 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
447 readm3u( fileref); 446 readm3u( fileref);
448 } 447 }
449 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 448 else if(fileref.find("pls",0,TRUE) != -1) { //is pls
450 readPls( fileref); 449 readPls( fileref);
451 } 450 }
452 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 451 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
453 clearList(); 452 clearList();
454 loadList(DocLnk(fileref)); 453 loadList(DocLnk(fileref));
455 d->selectedFiles->first(); 454 d->selectedFiles->first();
456 } else { 455 } else {
457 clearList(); 456 clearList();
458 addToSelection( DocLnk( fileref ) ); 457 addToSelection( DocLnk( fileref ) );
459 d->setDocumentUsed = TRUE; 458 d->setDocumentUsed = TRUE;
460 mediaPlayerState->setPlaying( FALSE ); 459 mediaPlayerState->setPlaying( FALSE );
461 qApp->processEvents(); 460 qApp->processEvents();
462 mediaPlayerState->setPlaying( TRUE ); 461 mediaPlayerState->setPlaying( TRUE );
463 qApp->processEvents(); 462 qApp->processEvents();
464 setCaption(tr("OpiePlayer")); 463 setCaption(tr("OpiePlayer"));
465 } 464 }
466} 465}
467 466
468 467
469void PlayListWidget::setActiveWindow() { 468void PlayListWidget::setActiveWindow() {
470 qDebug("SETTING active window"); 469 qDebug("SETTING active window");
471 470
472 // When we get raised we need to ensure that it switches views 471 // When we get raised we need to ensure that it switches views
473 char origView = mediaPlayerState->view(); 472 char origView = mediaPlayerState->view();
474 mediaPlayerState->setView( 'l' ); // invalidate 473 mediaPlayerState->setView( 'l' ); // invalidate
475 mediaPlayerState->setView( origView ); // now switch back 474 mediaPlayerState->setView( origView ); // now switch back
476} 475}
477 476
478 477
479void PlayListWidget::useSelectedDocument() { 478void PlayListWidget::useSelectedDocument() {
480 d->setDocumentUsed = FALSE; 479 d->setDocumentUsed = FALSE;
481} 480}
482 481
483 482
484const DocLnk *PlayListWidget::current() { // this is fugly 483const DocLnk *PlayListWidget::current() { // this is fugly
485 484
486// if( fromSetDocument) { 485// if( fromSetDocument) {
487// qDebug("from setDoc"); 486// qDebug("from setDoc");
488// DocLnkSet files; 487// DocLnkSet files;
489// Global::findDocuments(&files, "video/*;audio/*"); 488// Global::findDocuments(&files, "video/*;audio/*");
490// QListIterator<DocLnk> dit( files.children() ); 489// QListIterator<DocLnk> dit( files.children() );
491// for ( ; dit.current(); ++dit ) { 490// for ( ; dit.current(); ++dit ) {
492// if(dit.current()->linkFile() == setDocFileRef) { 491// if(dit.current()->linkFile() == setDocFileRef) {
493// qDebug(setDocFileRef); 492// qDebug(setDocFileRef);
494// return dit; 493// return dit;
495// } 494// }
496// } 495// }
497// } else 496// } else
498 497
498 qDebug("current");
499 499
500 switch (tabWidget->currentPageIndex()) { 500 switch (tabWidget->currentPageIndex()) {
501 case 0: //playlist 501 case 0: //playlist
502 { 502 {
503 qDebug("playlist"); 503 qDebug("playlist");
504 if ( mediaPlayerState->playlist() ) { 504 if ( mediaPlayerState->playlist() ) {
505 return d->selectedFiles->current(); 505 return d->selectedFiles->current();
506 } 506 }
507 else if ( d->setDocumentUsed && d->current ) { 507 else if ( d->setDocumentUsed && d->current ) {
508 return d->current; 508 return d->current;
509 } else { 509 } else {
510 return &(d->files->selectedDocument()); 510 return &(d->files->selectedDocument());
511 } 511 }
512 } 512 }
513 break; 513 break;
514 case 1://audio 514 case 1://audio
515 { 515 {
516 qDebug("audioView"); 516 qDebug("audioView");
517 QListIterator<DocLnk> dit( files.children() ); 517 QListIterator<DocLnk> dit( files.children() );
518 for ( ; dit.current(); ++dit ) { 518 for ( ; dit.current(); ++dit ) {
519 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 519 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
520 qDebug("here"); 520 qDebug("here");
521 insanityBool=TRUE; 521 insanityBool=TRUE;
522 return dit; 522 return dit;
523 } 523 }
524 } 524 }
525 } 525 }
526 break; 526 break;
527 case 2: // video 527 case 2: // video
528 { 528 {
529 qDebug("videoView"); 529 qDebug("videoView");
530 QListIterator<DocLnk> Vdit( vFiles.children() ); 530 QListIterator<DocLnk> Vdit( vFiles.children() );
531 for ( ; Vdit.current(); ++Vdit ) { 531 for ( ; Vdit.current(); ++Vdit ) {
532 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 532 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
533 insanityBool=TRUE; 533 insanityBool=TRUE;
534 return Vdit; 534 return Vdit;
535 } 535 }
536 } 536 }
537 } 537 }
538 break; 538 break;
539 }; 539 };
540 return 0; 540 return 0;
541} 541}
542 542
543bool PlayListWidget::prev() { 543bool PlayListWidget::prev() {
544 if ( mediaPlayerState->playlist() ) { 544 if ( mediaPlayerState->playlist() ) {
545 if ( mediaPlayerState->shuffled() ) { 545 if ( mediaPlayerState->shuffled() ) {
546 const DocLnk *cur = current(); 546 const DocLnk *cur = current();
547 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 547 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
548 for ( int i = 0; i < j; i++ ) { 548 for ( int i = 0; i < j; i++ ) {
549 if ( !d->selectedFiles->next() ) 549 if ( !d->selectedFiles->next() )
550 d->selectedFiles->first(); 550 d->selectedFiles->first();
551 } 551 }
552 if ( cur == current() ) 552 if ( cur == current() )
553 if ( !d->selectedFiles->next() ) 553 if ( !d->selectedFiles->next() )
554 d->selectedFiles->first(); 554 d->selectedFiles->first();
555 return TRUE; 555 return TRUE;
556 } else { 556 } else {
557 if ( !d->selectedFiles->prev() ) { 557 if ( !d->selectedFiles->prev() ) {
558 if ( mediaPlayerState->looping() ) { 558 if ( mediaPlayerState->looping() ) {
559 return d->selectedFiles->last(); 559 return d->selectedFiles->last();
560 } else { 560 } else {
561 return FALSE; 561 return FALSE;
562 } 562 }
563 } 563 }
564 return TRUE; 564 return TRUE;
565 } 565 }
566 } else { 566 } else {
567 return mediaPlayerState->looping(); 567 return mediaPlayerState->looping();
568 } 568 }
569} 569}
570 570
571 571
572bool PlayListWidget::next() { 572bool PlayListWidget::next() {
573 if ( mediaPlayerState->playlist() ) { 573 if ( mediaPlayerState->playlist() ) {
574 if ( mediaPlayerState->shuffled() ) { 574 if ( mediaPlayerState->shuffled() ) {
575 return prev(); 575 return prev();
576 } else { 576 } else {
577 if ( !d->selectedFiles->next() ) { 577 if ( !d->selectedFiles->next() ) {
578 if ( mediaPlayerState->looping() ) { 578 if ( mediaPlayerState->looping() ) {
579 return d->selectedFiles->first(); 579 return d->selectedFiles->first();
580 } else { 580 } else {
581 return FALSE; 581 return FALSE;
582 } 582 }
583 } 583 }
584 return TRUE; 584 return TRUE;
585 } 585 }
586 } else { 586 } else {
587 return mediaPlayerState->looping(); 587 return mediaPlayerState->looping();
588 } 588 }
589} 589}
590 590
591 591
592bool PlayListWidget::first() { 592bool PlayListWidget::first() {
593 if ( mediaPlayerState->playlist() ) 593 if ( mediaPlayerState->playlist() )
594 return d->selectedFiles->first(); 594 return d->selectedFiles->first();
595 else 595 else
596 return mediaPlayerState->looping(); 596 return mediaPlayerState->looping();
597} 597}
598 598
599 599
600bool PlayListWidget::last() { 600bool PlayListWidget::last() {
601 if ( mediaPlayerState->playlist() ) 601 if ( mediaPlayerState->playlist() )
602 return d->selectedFiles->last(); 602 return d->selectedFiles->last();
603 else 603 else
604 return mediaPlayerState->looping(); 604 return mediaPlayerState->looping();
605} 605}
606 606
607 607
608void PlayListWidget::saveList() { 608void PlayListWidget::saveList() {
609 609 writem3u();
610 QString filename;
611 InputDialog *fileDlg;
612 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
613 fileDlg->exec();
614 if( fileDlg->result() == 1 ) {
615 if ( d->current )
616 delete d->current;
617 filename = fileDlg->LineEdit1->text();//+".playlist";
618// qDebug("saving playlist "+filename+".playlist");
619 Config cfg( filename +".playlist");
620 writeConfig( cfg );
621
622 DocLnk lnk;
623// lnk.setComment( "");
624 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
625 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
626 lnk.setIcon("opieplayer/playlist2");
627 lnk.setName( filename); //sets file name
628// qDebug(filename);
629 if(!lnk.writeLink())
630 qDebug("Writing doclink did not work");
631 }
632 Config config( "OpiePlayer" );
633 config.writeEntry("CurrentPlaylist",filename);
634 setCaption(tr("OpiePlayer: ")+filename);
635 d->selectedFiles->first();
636 if(fileDlg)
637 delete fileDlg;
638} 610}
639 611
640void PlayListWidget::loadList( const DocLnk & lnk) { 612void PlayListWidget::loadList( const DocLnk & lnk) {
641 QString name= lnk.name(); 613 QString name = lnk.name();
642// qDebug("currentList is "+name); 614// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
643 if( name.length()>1) { 615
616 if( name.length()>0) {
644 setCaption("OpiePlayer: "+name); 617 setCaption("OpiePlayer: "+name);
645// qDebug("load list "+ name+".playlist"); 618// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
646 clearList(); 619 clearList();
647 Config cfg( name+".playlist"); 620 readm3u(lnk.file());
648 readConfig(cfg);
649
650 tabWidget->setCurrentPage(0); 621 tabWidget->setCurrentPage(0);
651
652 Config config( "OpiePlayer" );
653 config.writeEntry("CurrentPlaylist", name);
654// d->selectedFiles->first();
655 } 622 }
656
657} 623}
658 624
659void PlayListWidget::setPlaylist( bool shown ) { 625void PlayListWidget::setPlaylist( bool shown ) {
660 if ( shown ) 626 if ( shown )
661 d->playListFrame->show(); 627 d->playListFrame->show();
662 else 628 else
663 d->playListFrame->hide(); 629 d->playListFrame->hide();
664} 630}
665 631
666void PlayListWidget::setView( char view ) { 632void PlayListWidget::setView( char view ) {
667 if ( view == 'l' ) 633 if ( view == 'l' )
668 showMaximized(); 634 showMaximized();
669 else 635 else
670 hide(); 636 hide();
671} 637}
672 638
673void PlayListWidget::addSelected() { 639void PlayListWidget::addSelected() {
674 640
675 Config cfg( "OpiePlayer" ); 641 Config cfg( "OpiePlayer" );
676 cfg.setGroup("PlayList"); 642 cfg.setGroup("PlayList");
677 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 643 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
678 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 644// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
679 645
680 switch (tabWidget->currentPageIndex()) { 646 switch (tabWidget->currentPageIndex()) {
681 case 0: //playlist 647 case 0: //playlist
682 break; 648 break;
683 case 1: { //audio 649 case 1: { //audio
684// QString entryName; 650// QString entryName;
685// entryName.sprintf( "File%i", i + 1 ); 651// entryName.sprintf( "File%i", i + 1 );
686// QString linkFile = cfg.readEntry( entryName ); 652// QString linkFile = cfg.readEntry( entryName );
687 QListViewItemIterator it( audioView ); 653 QListViewItemIterator it( audioView );
688 // iterate through all items of the listview 654 // iterate through all items of the listview
689 for ( ; it.current(); ++it ) { 655 for ( ; it.current(); ++it ) {
690 if ( it.current()->isSelected() ) { 656 if ( it.current()->isSelected() ) {
691 QListIterator<DocLnk> dit( files.children() ); 657 QListIterator<DocLnk> dit( files.children() );
692 for ( ; dit.current(); ++dit ) { 658 for ( ; dit.current(); ++dit ) {
693 if( dit.current()->name() == it.current()->text(0) ) { 659 if( dit.current()->name() == it.current()->text(0) ) {
694 d->selectedFiles->addToSelection( **dit ); 660 d->selectedFiles->addToSelection( **dit );
695 } 661 }
696 } 662 }
697 audioView->setSelected( it.current(),FALSE); 663 audioView->setSelected( it.current(),FALSE);
698 } 664 }
699 } 665 }
700 tabWidget->setCurrentPage(0); 666 tabWidget->setCurrentPage(0);
701 } 667 }
702 break; 668 break;
703 case 2: { // video 669 case 2: { // video
704 QListViewItemIterator it( videoView ); 670 QListViewItemIterator it( videoView );
705 // iterate through all items of the listview 671 // iterate through all items of the listview
706 for ( ; it.current(); ++it ) { 672 for ( ; it.current(); ++it ) {
707 if ( it.current()->isSelected() ) { 673 if ( it.current()->isSelected() ) {
708 QListIterator<DocLnk> dit( vFiles.children() ); 674 QListIterator<DocLnk> dit( vFiles.children() );
709 for ( ; dit.current(); ++dit ) { 675 for ( ; dit.current(); ++dit ) {
710 if( dit.current()->name() == it.current()->text(0) ) { 676 if( dit.current()->name() == it.current()->text(0) ) {
711 d->selectedFiles->addToSelection( **dit ); 677 d->selectedFiles->addToSelection( **dit );
712 } 678 }
713 } 679 }
714 680
715 videoView->setSelected( it.current(),FALSE); 681 videoView->setSelected( it.current(),FALSE);
716 } 682 }
717 } 683 }
718// for ( int i = 0; i < noOfFiles; i++ ) { 684// for ( int i = 0; i < noOfFiles; i++ ) {
719// QString entryName; 685// QString entryName;
720// entryName.sprintf( "File%i", i + 1 ); 686// entryName.sprintf( "File%i", i + 1 );
721// QString linkFile = cfg.readEntry( entryName ); 687// QString linkFile = cfg.readEntry( entryName );
722// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 688// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
723// int result= QMessageBox::warning(this,tr("OpiePlayer"), 689// int result= QMessageBox::warning(this,tr("OpiePlayer"),
724// tr("This is all ready in your playlist.\nContinue?"), 690// tr("This is all ready in your playlist.\nContinue?"),
725// tr("Yes"),tr("No"),0,0,1); 691// tr("Yes"),tr("No"),0,0,1);
726// if (result !=0) 692// if (result !=0)
727// return; 693// return;
728// } 694// }
729// } 695// }
730// addToSelection( videoView->selectedItem() ); 696// addToSelection( videoView->selectedItem() );
731 tabWidget->setCurrentPage(0); 697 tabWidget->setCurrentPage(0);
732 } 698 }
733 break; 699 break;
734 }; 700 };
735} 701}
736 702
737void PlayListWidget::removeSelected() { 703void PlayListWidget::removeSelected() {
738 d->selectedFiles->removeSelected( ); 704 d->selectedFiles->removeSelected( );
739} 705}
740 706
741void PlayListWidget::playIt( QListViewItem *it) { 707void PlayListWidget::playIt( QListViewItem *) {
742// d->setDocumentUsed = FALSE; 708// d->setDocumentUsed = FALSE;
743// mediaPlayerState->curPosition =0; 709// mediaPlayerState->curPosition =0;
744 qDebug("playIt"); 710 qDebug("playIt");
745 mediaPlayerState->setPlaying(FALSE); 711 mediaPlayerState->setPlaying(FALSE);
746 mediaPlayerState->setPlaying(TRUE); 712 mediaPlayerState->setPlaying(TRUE);
747 d->selectedFiles->unSelect(); 713 d->selectedFiles->unSelect();
748} 714}
749 715
750void PlayListWidget::addToSelection( QListViewItem *it) { 716void PlayListWidget::addToSelection( QListViewItem *it) {
751 d->setDocumentUsed = FALSE; 717 d->setDocumentUsed = FALSE;
752 718
753 if(it) { 719 if(it) {
754 switch (tabWidget->currentPageIndex()) { 720 switch (tabWidget->currentPageIndex()) {
755 case 1: { 721 case 1: {
756 QListIterator<DocLnk> dit( files.children() ); 722 QListIterator<DocLnk> dit( files.children() );
757 for ( ; dit.current(); ++dit ) { 723 for ( ; dit.current(); ++dit ) {
758 if( dit.current()->name() == it->text(0)) { 724 if( dit.current()->name() == it->text(0)) {
759 d->selectedFiles->addToSelection( **dit ); 725 d->selectedFiles->addToSelection( **dit );
760 } 726 }
761 } 727 }
762 } 728 }
763 break; 729 break;
764 case 2: { 730 case 2: {
765 QListIterator<DocLnk> dit( vFiles.children() ); 731 QListIterator<DocLnk> dit( vFiles.children() );
766 for ( ; dit.current(); ++dit ) { 732 for ( ; dit.current(); ++dit ) {
767 if( dit.current()->name() == it->text(0)) { 733 if( dit.current()->name() == it->text(0)) {
768 d->selectedFiles->addToSelection( **dit ); 734 d->selectedFiles->addToSelection( **dit );
769 } 735 }
770 } 736 }
771 } 737 }
772 break; 738 break;
773 case 0: 739 case 0:
774 break; 740 break;
775 }; 741 };
776 tabWidget->setCurrentPage(0); 742 tabWidget->setCurrentPage(0);
777 } 743 }
778} 744}
779 745
780void PlayListWidget::tabChanged(QWidget *widg) { 746void PlayListWidget::tabChanged(QWidget *) {
781 747
782 switch ( tabWidget->currentPageIndex()) { 748 switch ( tabWidget->currentPageIndex()) {
783 case 0: 749 case 0:
784 { 750 {
785 if( !tbDeletePlaylist->isHidden()) 751 if( !tbDeletePlaylist->isHidden())
786 tbDeletePlaylist->hide(); 752 tbDeletePlaylist->hide();
787 d->tbRemoveFromList->setEnabled(TRUE); 753 d->tbRemoveFromList->setEnabled(TRUE);
788 d->tbAddToList->setEnabled(FALSE); 754 d->tbAddToList->setEnabled(FALSE);
789 } 755 }
790 break; 756 break;
791 case 1: 757 case 1:
792 { 758 {
793 audioView->clear(); 759 audioView->clear();
794 populateAudioView(); 760 populateAudioView();
795 761
796 if( !tbDeletePlaylist->isHidden()) 762 if( !tbDeletePlaylist->isHidden())
797 tbDeletePlaylist->hide(); 763 tbDeletePlaylist->hide();
798 d->tbRemoveFromList->setEnabled(FALSE); 764 d->tbRemoveFromList->setEnabled(FALSE);
799 d->tbAddToList->setEnabled(TRUE); 765 d->tbAddToList->setEnabled(TRUE);
800 } 766 }
801 break; 767 break;
802 case 2: 768 case 2:
803 { 769 {
804 videoView->clear(); 770 videoView->clear();
805 populateVideoView(); 771 populateVideoView();
806 if( !tbDeletePlaylist->isHidden()) 772 if( !tbDeletePlaylist->isHidden())
807 tbDeletePlaylist->hide(); 773 tbDeletePlaylist->hide();
808 d->tbRemoveFromList->setEnabled(FALSE); 774 d->tbRemoveFromList->setEnabled(FALSE);
809 d->tbAddToList->setEnabled(TRUE); 775 d->tbAddToList->setEnabled(TRUE);
810 } 776 }
811 break; 777 break;
812 case 3: 778 case 3:
813 { 779 {
814 if( tbDeletePlaylist->isHidden()) 780 if( tbDeletePlaylist->isHidden())
815 tbDeletePlaylist->show(); 781 tbDeletePlaylist->show();
816 playLists->reread(); 782 playLists->reread();
817 } 783 }
818 break; 784 break;
819 }; 785 };
820} 786}
821 787
822void PlayListWidget::btnPlay(bool b) { 788void PlayListWidget::btnPlay(bool b) {
823 789 qDebug("<<<<<<<<<<<<<<<BtnPlay");
824// mediaPlayerState->setPlaying(b); 790// mediaPlayerState->setPlaying(b);
825 switch ( tabWidget->currentPageIndex()) { 791 switch ( tabWidget->currentPageIndex()) {
826 case 0: 792 case 0:
827 { 793 {
794 qDebug("1");
828// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 795// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
829// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 796// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
830// QMessageBox::message("Note","You are trying to play\na malformed url."); 797// QMessageBox::message("Note","You are trying to play\na malformed url.");
831// } else { 798// } else {
832 mediaPlayerState->setPlaying(b); 799 mediaPlayerState->setPlaying(b);
800 insanityBool=FALSE;
801 qDebug("insanity");
833// } 802// }
834 } 803 }
835 break; 804 break;
836 case 1: 805 case 1:
837 { 806 {
807 qDebug("2");
838 addToSelection( audioView->currentItem() ); 808 addToSelection( audioView->currentItem() );
839 mediaPlayerState->setPlaying(b); 809 mediaPlayerState->setPlaying(b);
840 d->selectedFiles->removeSelected( ); 810 d->selectedFiles->removeSelected( );
841 tabWidget->setCurrentPage(1); 811 tabWidget->setCurrentPage(1);
842 d->selectedFiles->unSelect(); 812 d->selectedFiles->unSelect();
843 insanityBool=FALSE; 813 insanityBool=FALSE;
844 }// audioView->clearSelection(); 814 }// audioView->clearSelection();
845 break; 815 break;
846 case 2: 816 case 2:
847 { 817 {
818 qDebug("3");
819
848 addToSelection( videoView->currentItem() ); 820 addToSelection( videoView->currentItem() );
849 mediaPlayerState->setPlaying(b); 821 mediaPlayerState->setPlaying(b);
850 qApp->processEvents(); 822 qApp->processEvents();
851 d->selectedFiles->removeSelected( ); 823 d->selectedFiles->removeSelected( );
852 tabWidget->setCurrentPage(2); 824 tabWidget->setCurrentPage(2);
853 d->selectedFiles->unSelect(); 825 d->selectedFiles->unSelect();
854 insanityBool=FALSE; 826 insanityBool=FALSE;
855 }// videoView->clearSelection(); 827 }// videoView->clearSelection();
856 break; 828 break;
857 }; 829 };
858 830
859} 831}
860 832
861void PlayListWidget::deletePlaylist() { 833void PlayListWidget::deletePlaylist() {
862 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 834 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
863 (tr("You really want to delete\nthis playlist?")), 835 (tr("You really want to delete\nthis playlist?")),
864 (tr("Yes")), (tr("No")), 0 )){ 836 (tr("Yes")), (tr("No")), 0 )){
865 case 0: // Yes clicked, 837 case 0: // Yes clicked,
866// QFile().remove(playLists->selected()->file()); 838 QFile().remove(playLists->selectedDocument().file());
867// QFile().remove(playLists->selected()->linkFile()); 839 QFile().remove(playLists->selectedDocument().linkFile());
868// playLists->reread(); 840 playLists->reread();
869 break; 841 break;
870 case 1: // Cancel 842 case 1: // Cancel
871 break; 843 break;
872 }; 844 };
873} 845}
874 846
875void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 847void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
876{ 848{
877 switch (mouse) { 849 switch (mouse) {
878 case 1: 850 case 1:
879 break; 851 break;
880 case 2:{ 852 case 2:{
881 853
882 QPopupMenu m; 854 QPopupMenu m;
883 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 855 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
884 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 856 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
885 m.insertSeparator(); 857 m.insertSeparator();
886 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 858 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
887 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 859 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
888 860
889 m.exec( QCursor::pos() ); 861 m.exec( QCursor::pos() );
890 } 862 }
891 break; 863 break;
892 }; 864 };
893} 865}
894 866
895void PlayListWidget::playSelected() 867void PlayListWidget::playSelected()
896{ 868{
897 btnPlay( TRUE); 869 qDebug("playSelected");
870 btnPlay( true);
898// d->selectedFiles->unSelect(); 871// d->selectedFiles->unSelect();
899} 872}
900 873
901void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 874void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
902{ 875{
903 switch (mouse) { 876 switch (mouse) {
904 case 1: 877 case 1:
905 878
906 break; 879 break;
907 case 2:{ 880 case 2:{
908 QPopupMenu m; 881 QPopupMenu m;
909 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 882 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
910 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 883 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
911// m.insertSeparator(); 884// m.insertSeparator();
912// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 885// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
913 m.exec( QCursor::pos() ); 886 m.exec( QCursor::pos() );
914 } 887 }
915 break; 888 break;
916 }; 889 };
917 890
918} 891}
919 892
920void PlayListWidget::listDelete() { 893void PlayListWidget::listDelete() {
921 Config cfg( "OpiePlayer" ); 894 Config cfg( "OpiePlayer" );
922 cfg.setGroup("PlayList"); 895 cfg.setGroup("PlayList");
923 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 896 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
924 QString file; 897 QString file;
925 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 898// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
926 switch ( tabWidget->currentPageIndex()) { 899 switch ( tabWidget->currentPageIndex()) {
927 case 0: 900 case 0:
928 break; 901 break;
929 case 1: 902 case 1:
930 { 903 {
931 file = audioView->currentItem()->text(0); 904 file = audioView->currentItem()->text(0);
932 QListIterator<DocLnk> Pdit( files.children() ); 905 QListIterator<DocLnk> Pdit( files.children() );
933 for ( ; Pdit.current(); ++Pdit ) { 906 for ( ; Pdit.current(); ++Pdit ) {
934 if( Pdit.current()->name() == file) { 907 if( Pdit.current()->name() == file) {
935 LnkProperties prop( Pdit.current() ); 908 LnkProperties prop( Pdit.current() );
936 prop.showMaximized(); 909 prop.showMaximized();
937 prop.exec(); 910 prop.exec();
938 } 911 }
939 } 912 }
940 populateAudioView(); 913 populateAudioView();
941 } 914 }
942 break; 915 break;
943 case 2: 916 case 2:
944 { 917 {
945// file = videoView->selectedItem()->text(0); 918// file = videoView->selectedItem()->text(0);
946// for ( int i = 0; i < noOfFiles; i++ ) { 919// for ( int i = 0; i < noOfFiles; i++ ) {
947// QString entryName; 920// QString entryName;
948// entryName.sprintf( "File%i", i + 1 ); 921// entryName.sprintf( "File%i", i + 1 );
949// QString linkFile = cfg.readEntry( entryName ); 922// QString linkFile = cfg.readEntry( entryName );
950// AppLnk lnk( AppLnk(linkFile)); 923// AppLnk lnk( AppLnk(linkFile));
951// if( lnk.name() == file ) { 924// if( lnk.name() == file ) {
952// LnkProperties prop( &lnk); 925// LnkProperties prop( &lnk);
953// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 926// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
954// prop.showMaximized(); 927// prop.showMaximized();
955// prop.exec(); 928// prop.exec();
956// } 929// }
957// } 930// }
958 } 931 }
959 break; 932 break;
960 }; 933 };
961} 934}
962 935
963void PlayListWidget::scanForAudio() { 936void PlayListWidget::scanForAudio() {
964 qDebug("scan for audio"); 937// qDebug("scan for audio");
965 files.detachChildren(); 938 files.detachChildren();
966 QListIterator<DocLnk> sdit( files.children() ); 939 QListIterator<DocLnk> sdit( files.children() );
967 for ( ; sdit.current(); ++sdit ) { 940 for ( ; sdit.current(); ++sdit ) {
968 delete sdit.current(); 941 delete sdit.current();
969 } 942 }
970 Global::findDocuments(&files, "audio/*"); 943 Global::findDocuments( &files, audioMimes);
971 audioScan = TRUE; 944 audioScan = true;
972} 945}
973void PlayListWidget::scanForVideo() { 946void PlayListWidget::scanForVideo() {
974 qDebug("scan for video"); 947// qDebug("scan for video");
975 vFiles.detachChildren(); 948 vFiles.detachChildren();
976 QListIterator<DocLnk> sdit( vFiles.children() ); 949 QListIterator<DocLnk> sdit( vFiles.children() );
977 for ( ; sdit.current(); ++sdit ) { 950 for ( ; sdit.current(); ++sdit ) {
978 delete sdit.current(); 951 delete sdit.current();
979 } 952 }
980 Global::findDocuments(&vFiles, "video/*"); 953 Global::findDocuments(&vFiles, "video/*");
981 videoScan = TRUE; 954 videoScan = true;
982} 955}
983 956
984void PlayListWidget::populateAudioView() { 957void PlayListWidget::populateAudioView() {
985 958
986 audioView->clear(); 959 audioView->clear();
987 StorageInfo storageInfo; 960 StorageInfo storageInfo;
988 const QList<FileSystem> &fs = storageInfo.fileSystems(); 961 const QList<FileSystem> &fs = storageInfo.fileSystems();
989 if(!audioScan) scanForAudio(); 962 if(!audioScan) scanForAudio();
990 963
991 QListIterator<DocLnk> dit( files.children() ); 964 QListIterator<DocLnk> dit( files.children() );
992 QListIterator<FileSystem> it ( fs ); 965 QListIterator<FileSystem> it ( fs );
993 966
994 QString storage; 967 QString storage;
995 for ( ; dit.current(); ++dit ) { 968 for ( ; dit.current(); ++dit ) {
996 for( ; it.current(); ++it ){ 969 for( ; it.current(); ++it ){
997 const QString name = (*it)->name(); 970 const QString name = (*it)->name();
998 const QString path = (*it)->path(); 971 const QString path = (*it)->path();
999 if(dit.current()->file().find(path) != -1 ) storage=name; 972 if(dit.current()->file().find(path) != -1 ) storage=name;
1000 } 973 }
1001 974
1002 QListViewItem * newItem; 975 QListViewItem * newItem;
1003 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 976 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1004 long size; 977 long size;
1005 if( dit.current()->file().left(4) == "http" ) 978 if( dit.current()->file().left(4) == "http" )
1006 size=0; 979 size=0;
1007 else 980 else
1008 size = QFile( dit.current()->file() ).size(); 981 size = QFile( dit.current()->file() ).size();
1009 qDebug(dit.current()->name()); 982// qDebug(dit.current()->name());
1010 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 983 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1011 QString::number(size ), storage); 984 QString::number(size ), storage);
1012 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 985 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1013 } 986 }
1014 } 987 }
1015 988
1016} 989}
1017 990
1018void PlayListWidget::populateVideoView() { 991void PlayListWidget::populateVideoView() {
1019 videoView->clear(); 992 videoView->clear();
1020 StorageInfo storageInfo; 993 StorageInfo storageInfo;
1021 const QList<FileSystem> &fs = storageInfo.fileSystems(); 994 const QList<FileSystem> &fs = storageInfo.fileSystems();
1022 995
1023 if(!videoScan ) scanForVideo(); 996 if(!videoScan ) scanForVideo();
1024 997
1025 QListIterator<DocLnk> Vdit( vFiles.children() ); 998 QListIterator<DocLnk> Vdit( vFiles.children() );
1026 QListIterator<FileSystem> it ( fs ); 999 QListIterator<FileSystem> it ( fs );
1027 videoView->clear(); 1000 videoView->clear();
1028 QString storage; 1001 QString storage;
1029 for ( ; Vdit.current(); ++Vdit ) { 1002 for ( ; Vdit.current(); ++Vdit ) {
1030 for( ; it.current(); ++it ){ 1003 for( ; it.current(); ++it ){
1031 const QString name = (*it)->name(); 1004 const QString name = (*it)->name();
1032 const QString path = (*it)->path(); 1005 const QString path = (*it)->path();
1033 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1006 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1034 } 1007 }
1035 1008
1036 QListViewItem * newItem; 1009 QListViewItem * newItem;
1037 if ( QFile( Vdit.current()->file()).exists() ) { 1010 if ( QFile( Vdit.current()->file()).exists() ) {
1038 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1011 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1039 QString::number( QFile( Vdit.current()->file()).size() ), storage); 1012 QString::number( QFile( Vdit.current()->file()).size() ), storage);
1040 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1013 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1041 } 1014 }
1042 } 1015 }
1043} 1016}
1044 1017
1045void PlayListWidget::openFile() { 1018void PlayListWidget::openFile() {
1019 qDebug("<<<<<<<<<OPEN File");
1046 QString filename, name; 1020 QString filename, name;
1047 InputDialog *fileDlg; 1021 InputDialog *fileDlg;
1048 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1022 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1049 fileDlg->exec(); 1023 fileDlg->exec();
1050 if( fileDlg->result() == 1 ) { 1024 if( fileDlg->result() == 1 ) {
1051 filename = fileDlg->LineEdit1->text(); 1025 filename = fileDlg->text();
1052// http://205.188.234.129:8030 1026 qDebug( "Selected filename is " + filename );
1053// http://66.28.68.70:8000 1027// Om3u *m3uList;
1054// filename.replace(QRegExp("%20")," "); 1028 DocLnk lnk;
1055 qDebug("Selected filename is "+filename); 1029 Config cfg( "OpiePlayer" );
1056 if(filename.right(3) == "m3u") 1030 cfg.setGroup("PlayList");
1057 readm3u( filename); 1031
1058 else if(filename.right(3) == "pls") 1032 if(filename.left(4) == "http") {
1059 readPls( filename); 1033 QString m3uFile, m3uFilePath;
1060 else { 1034 if(filename.find(":",8,TRUE) != -1) { //found a port
1061 DocLnk lnk; 1035 m3uFile = filename.left( filename.find( ":",8,TRUE));
1062 1036 m3uFile = m3uFile.right( 7);
1063 lnk.setName(filename); //sets file name 1037 } else if(filename.left(4) == "http"){
1064 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1038 m3uFile=filename;
1065 filename += "/"; 1039 m3uFile = m3uFile.right( m3uFile.length() - 7);
1066 lnk.setFile(filename); //sets File property 1040 } else{
1067 1041 m3uFile=filename;
1068 lnk.setType("audio/x-mpegurl");
1069 lnk.setExec("opieplayer");
1070 lnk.setIcon("opieplayer/MPEGPlayer");
1071
1072 if(!lnk.writeLink())
1073 qDebug("Writing doclink did not work");
1074 d->selectedFiles->addToSelection( lnk);
1075// if(fileDlg2)
1076// delete fileDlg2;
1077 } 1042 }
1043
1044// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
1045 lnk.setName( filename ); //sets name
1046 lnk.setFile( filename ); //sets file name
1047 lnk.setIcon("opieplayer2/musicfile");
1048 d->selectedFiles->addToSelection( lnk );
1049 writeCurrentM3u();
1050 }
1051 else if( filename.right( 3) == "m3u" ) {
1052 readm3u( filename );
1053
1054 } else if( filename.right(3) == "pls" ) {
1055 readPls( filename );
1056 } else {
1057 d->selectedFiles->addToSelection( DocLnk(filename) );
1058 writeCurrentM3u();
1059 }
1078 } 1060 }
1079 if(fileDlg) 1061
1062 if( fileDlg ) {
1080 delete fileDlg; 1063 delete fileDlg;
1064 }
1065}
1066
1067
1068/*
1069reads m3u and shows files/urls to playlist widget */
1070void PlayListWidget::readm3u( const QString &filename ) {
1071 qDebug( "read m3u filename " + filename );
1072
1073 Om3u *m3uList;
1074 QString s, name;
1075 m3uList = new Om3u( filename, IO_ReadOnly );
1076 m3uList->readM3u();
1077 DocLnk lnk;
1078 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1079 s = *it;
1080// qDebug("reading "+ s);
1081 if(s.left(4)=="http") {
1082 lnk.setName( s ); //sets file name
1083 lnk.setIcon("opieplayer2/musicfile");
1084 if(s.right(4) != '.' || s.right(5) != '.')
1085 lnk.setFile( s+"/"); //if url with no extension
1086 else
1087 lnk.setFile( s ); //sets file name
1088
1089 } else {
1090 // if( QFileInfo( s ).exists() ) {
1091 lnk.setName( QFileInfo(s).baseName());
1092 // if(s.right(4) == '.') {//if regular file
1093 if(s.left(1) != "/") {
1094 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1095 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1096 lnk.setIcon("SoundPlayer");
1097 } else {
1098 // qDebug("set link2 "+s);
1099 lnk.setFile( s);
1100 lnk.setIcon("SoundPlayer");
1101 }
1102 }
1103 d->selectedFiles->addToSelection( lnk );
1104 }
1105 Config config( "OpiePlayer" );
1106 config.setGroup( "PlayList" );
1107
1108 config.writeEntry("CurrentPlaylist",filename);
1109 config.write();
1110 currentPlayList=filename;
1111
1112// m3uList->write();
1113 m3uList->close();
1114 if(m3uList) delete m3uList;
1115
1116 d->selectedFiles->setSelectedItem( s);
1117 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
1118
1119}
1120
1121/*
1122reads pls and adds files/urls to playlist */
1123void PlayListWidget::readPls( const QString &filename ) {
1124
1125 qDebug( "pls filename is " + filename );
1126 Om3u *m3uList;
1127 QString s, name;
1128 m3uList = new Om3u( filename, IO_ReadOnly );
1129 m3uList->readPls();
1130
1131 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1132 s = *it;
1133 // s.replace( QRegExp( "%20" )," " );
1134 DocLnk lnk( s );
1135 QFileInfo f( s );
1136 QString name = f.baseName();
1137
1138 if( name.left( 4 ) == "http" ) {
1139 name = s.right( s.length() - 7);
1140 } else {
1141 name = s;
1142 }
1143
1144 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1145
1146 lnk.setName( name );
1147 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1148 lnk.setFile( s );
1149 } else { //if its a url
1150 if( name.right( 1 ).find( '/' ) == -1) {
1151 s += "/";
1152 }
1153 lnk.setFile( s );
1154 }
1155 lnk.setType( "audio/x-mpegurl" );
1156
1157 lnk.writeLink();
1158 d->selectedFiles->addToSelection( lnk );
1159 }
1160
1161 m3uList->close();
1162 if(m3uList) delete m3uList;
1081} 1163}
1082 1164
1165/*
1166 writes current playlist to current m3u file */
1167void PlayListWidget::writeCurrentM3u() {
1168 qDebug("writing to current m3u");
1169 Config cfg( "OpiePlayer" );
1170 cfg.setGroup("PlayList");
1171 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
1172
1173 if( d->selectedFiles->first()) {
1174 Om3u *m3uList;
1175 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
1176
1177 do {
1178 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1179 m3uList->add( d->selectedFiles->current()->file() );
1180 }
1181 while ( d->selectedFiles->next() );
1182 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1183 m3uList->write();
1184 m3uList->close();
1185
1186 if(m3uList) delete m3uList;
1187 }
1188}
1189
1190 /*
1191 writes current playlist to m3u file */
1192void PlayListWidget::writem3u() {
1193 InputDialog *fileDlg;
1194 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1195 fileDlg->exec();
1196 QString name, filename, list;
1197 Om3u *m3uList;
1198
1199 if( fileDlg->result() == 1 ) {
1200 name = fileDlg->text();
1201// qDebug( filename );
1202
1203 if( name.left( 1) != "/" ) {
1204 filename = QPEApplication::documentDir() + "/" + name;
1205 }
1206
1207 if( name.right( 3 ) != "m3u" ) {
1208 filename = QPEApplication::documentDir() + "/" +name+".m3u";
1209 }
1210
1211 if( d->selectedFiles->first()) {
1212 m3uList = new Om3u(filename, IO_ReadWrite);
1213
1214 do {
1215 m3uList->add( d->selectedFiles->current()->file());
1216 }
1217 while ( d->selectedFiles->next() );
1218 // qDebug( list );
1219 m3uList->write();
1220 m3uList->close();
1221 if(m3uList) delete m3uList;
1222
1223 if(fileDlg) delete fileDlg;
1224
1225 DocLnk lnk;
1226 lnk.setFile( filename);
1227 lnk.setIcon("opieplayer2/playlist2");
1228 lnk.setName( name); //sets file name
1229
1230 // qDebug(filename);
1231 Config config( "OpiePlayer" );
1232 config.setGroup( "PlayList" );
1233
1234 config.writeEntry("CurrentPlaylist",filename);
1235 currentPlayList=filename;
1236
1237 if(!lnk.writeLink()) {
1238 qDebug("Writing doclink did not work");
1239 }
1240
1241 setCaption(tr("OpiePlayer: ") + name);
1242 }
1243 }
1244}
1245
1246
1083void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1247void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1084{ 1248{
1085 switch ( e->key() ) { 1249 switch ( e->key() ) {
1086////////////////////////////// Zaurus keys 1250////////////////////////////// Zaurus keys
1087 case Key_F9: //activity 1251 case Key_F9: //activity
1088// if(audioUI->isHidden()) 1252// if(audioUI->isHidden())
1089// audioUI->showMaximized(); 1253// audioUI->showMaximized();
1090 break; 1254 break;
1091 case Key_F10: //contacts 1255 case Key_F10: //contacts
1092// if( videoUI->isHidden()) 1256// if( videoUI->isHidden())
1093// videoUI->showMaximized(); 1257// videoUI->showMaximized();
1094 break; 1258 break;
1095 case Key_F11: //menu 1259 case Key_F11: //menu
1096 break; 1260 break;
1097 case Key_F12: //home 1261 case Key_F12: //home
1098// doBlank(); 1262// doBlank();
1099 break; 1263 break;
1100 case Key_F13: //mail 1264 case Key_F13: //mail
1101// doUnblank(); 1265// doUnblank();
1102 break; 1266 break;
1103 case Key_Q: //add to playlist 1267 case Key_Q: //add to playlist
1104 qDebug("Add"); 1268 qDebug("Add");
1105 addSelected(); 1269 addSelected();
1106 break; 1270 break;
1107 case Key_R: //remove from playlist 1271 case Key_R: //remove from playlist
1108 removeSelected(); 1272 removeSelected();
1109 break; 1273 break;
1110// case Key_P: //play 1274// case Key_P: //play
1111// qDebug("Play"); 1275// qDebug("Play");
1112// playSelected(); 1276// playSelected();
1113// break; 1277// break;
1114 case Key_Space: 1278 case Key_Space:
1115 qDebug("Play"); 1279 qDebug("Play");
1116// playSelected(); puh 1280// playSelected(); puh
1117 break; 1281 break;
1118 case Key_1: 1282 case Key_1:
1119 tabWidget->setCurrentPage(0); 1283 tabWidget->setCurrentPage(0);
1120 break; 1284 break;
1121 case Key_2: 1285 case Key_2:
1122 tabWidget->setCurrentPage(1); 1286 tabWidget->setCurrentPage(1);
1123 break; 1287 break;
1124 case Key_3: 1288 case Key_3:
1125 tabWidget->setCurrentPage(2); 1289 tabWidget->setCurrentPage(2);
1126 break; 1290 break;
1127 case Key_4: 1291 case Key_4:
1128 tabWidget->setCurrentPage(3); 1292 tabWidget->setCurrentPage(3);
1129 break; 1293 break;
1130 case Key_Down: 1294 case Key_Down:
1131 if ( !d->selectedFiles->next() ) 1295 if ( !d->selectedFiles->next() )
1132 d->selectedFiles->first(); 1296 d->selectedFiles->first();
1133 1297
1134 break; 1298 break;
1135 case Key_Up: 1299 case Key_Up:
1136 if ( !d->selectedFiles->prev() ) 1300 if ( !d->selectedFiles->prev() )
1137 // d->selectedFiles->last(); 1301 // d->selectedFiles->last();
1138 1302
1139 break; 1303 break;
1140 1304
1141 } 1305 }
1142} 1306}
1143 1307
1144void PlayListWidget::keyPressEvent( QKeyEvent *e) 1308void PlayListWidget::keyPressEvent( QKeyEvent *)
1145{ 1309{
1146// qDebug("Key press"); 1310// qDebug("Key press");
1147// switch ( e->key() ) { 1311// switch ( e->key() ) {
1148// ////////////////////////////// Zaurus keys 1312// ////////////////////////////// Zaurus keys
1149// case Key_A: //add to playlist 1313// case Key_A: //add to playlist
1150// qDebug("Add"); 1314// qDebug("Add");
1151// addSelected(); 1315// addSelected();
1152// break; 1316// break;
1153// case Key_R: //remove from playlist 1317// case Key_R: //remove from playlist
1154// removeSelected(); 1318// removeSelected();
1155// break; 1319// break;
1156// case Key_P: //play 1320// case Key_P: //play
1157// qDebug("Play"); 1321// qDebug("Play");
1158// playSelected(); 1322// playSelected();
1159// break; 1323// break;
1160// case Key_Space: 1324// case Key_Space:
1161// qDebug("Play"); 1325// qDebug("Play");
1162// playSelected(); 1326// playSelected();
1163// break; 1327// break;
1164// } 1328// }
1165} 1329}
1166 1330
1167void PlayListWidget::doBlank() { 1331void PlayListWidget::doBlank() {
1168 qDebug("do blanking"); 1332 qDebug("do blanking");
1169 fd=open("/dev/fb0",O_RDWR); 1333 fd=open("/dev/fb0",O_RDWR);
1170 if (fd != -1) { 1334 if (fd != -1) {
1171 ioctl(fd,FBIOBLANK,1); 1335 ioctl(fd,FBIOBLANK,1);
1172// close(fd); 1336// close(fd);
1173 } 1337 }
1174} 1338}
1175 1339
1176void PlayListWidget::doUnblank() { 1340void PlayListWidget::doUnblank() {
1177 // this crashes opieplayer with a segfault 1341 // this crashes opieplayer with a segfault
1178// int fd; 1342// int fd;
1179// fd=open("/dev/fb0",O_RDWR); 1343// fd=open("/dev/fb0",O_RDWR);
1180 qDebug("do unblanking"); 1344 qDebug("do unblanking");
1181 if (fd != -1) { 1345 if (fd != -1) {
1182 ioctl(fd,FBIOBLANK,0); 1346 ioctl(fd,FBIOBLANK,0);
1183 close(fd); 1347 close(fd);
1184 } 1348 }
1185 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1349 QCopEnvelope h("QPE/System", "setBacklight(int)");
1186 h <<-3;// v[1]; // -3 Force on 1350 h <<-3;// v[1]; // -3 Force on
1187} 1351}
1188 1352
1189void PlayListWidget::readm3u(const QString &filename) {
1190
1191 qDebug("m3u filename is "+filename);
1192 QFile f(filename);
1193
1194 if(f.open(IO_ReadOnly)) {
1195 QTextStream t(&f);
1196 QString s;//, first, second;
1197 int i=0;
1198 while ( !t.atEnd()) {
1199// Lview->insertLine(t.readLine(),-1);
1200 s=t.readLine();
1201
1202 if(s.find("#",0,TRUE) == -1) {
1203 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1204 if(s.left(2) == "E:" || s.left(2) == "P:") {
1205 s=s.right(s.length()-2);
1206 DocLnk lnk( s );
1207 QFileInfo f(s);
1208 QString name = f.baseName();
1209 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1210 lnk.setName( name);
1211 s=s.replace( QRegExp("\\"),"/");
1212 lnk.setFile( s);
1213 lnk.writeLink();
1214// lnk.setIcon(opieplayer/MPEGPlayer);
1215 qDebug("add "+name);
1216 d->selectedFiles->addToSelection( lnk);
1217 } else { // is url
1218
1219 s.replace(QRegExp("%20")," ");
1220 DocLnk lnk( s);
1221 QString name;
1222 if(name.left(4)=="http")
1223 name = s.right( s.length() - 7);
1224 else
1225 name=s;
1226// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1227 lnk.setName(name);
1228 if(s.at(s.length()-4) == '.')
1229 lnk.setFile( s);
1230 else
1231 lnk.setFile( s+"/");
1232// lnk.setFile( filename);
1233// lnk.setComment( s+"/");
1234 lnk.setType("audio/x-mpegurl");
1235 lnk.writeLink();
1236// lnk.setIcon( "opieplayer/MPEGPlayer");
1237// qDebug("add "+s);
1238 d->selectedFiles->addToSelection( lnk);
1239 }
1240 i++;
1241 }
1242 }
1243 }
1244 }
1245 f.close();
1246}
1247
1248void PlayListWidget::writem3u() {
1249
1250 InputDialog *fileDlg;
1251 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1252 fileDlg->exec();
1253 QString filename,list;
1254 if( fileDlg->result() == 1 ) {
1255 filename = fileDlg->LineEdit1->text();
1256 qDebug(filename);
1257 int noOfFiles = 0;
1258 d->selectedFiles->first();
1259 do {
1260// we dont check for existance because of url's
1261// qDebug(d->selectedFiles->current()->file());
1262 list += d->selectedFiles->current()->file()+"\n";
1263 noOfFiles++;
1264 }
1265 while ( d->selectedFiles->next() );
1266 qDebug(list);
1267 if(filename.left(1) != "/")
1268 filename=QPEApplication::documentDir()+"/"+filename;
1269 if(filename.right(3) != "m3u")
1270 filename=filename+".m3u";
1271
1272 QFile f(filename);
1273 f.open(IO_WriteOnly);
1274 f.writeBlock(list, list.length());
1275 f.close();
1276 }
1277 if(fileDlg) delete fileDlg;
1278}
1279
1280void PlayListWidget::readPls(const QString &filename) {
1281
1282 qDebug("pls filename is "+filename);
1283 QFile f(filename);
1284
1285 if(f.open(IO_ReadOnly)) {
1286 QTextStream t(&f);
1287 QString s;//, first, second;
1288 int i=0;
1289 while ( !t.atEnd()) {
1290 s=t.readLine();
1291 if(s.left(4) == "File") {
1292 s=s.right(s.length() - 6);
1293 s.replace(QRegExp("%20")," ");
1294 qDebug("adding "+s+" to playlist");
1295// numberofentries=2
1296// File1=http
1297// Title
1298// Length
1299// Version
1300// File2=http
1301
1302 s=s.replace( QRegExp("\\"),"/");
1303 DocLnk lnk( s );
1304 QFileInfo f(s);
1305 QString name = f.baseName();
1306 if(name.left(4)=="http")
1307 name = s.right( s.length() - 7);
1308 else
1309 name=s;
1310 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1311// QFileInfo f(s);
1312// QString name = f.baseName();
1313// name = name.left(name.length()-4);
1314// name = name.right(name.findRev("/",0,TRUE));
1315 lnk.setName( name);
1316 if(s.at(s.length()-4) == '.') // if this is probably a file
1317 lnk.setFile( s);
1318 else { //if its a url
1319 if( name.right(1).find('/') == -1)
1320 s+="/";
1321 lnk.setFile( s);
1322 }
1323 lnk.setType("audio/x-mpegurl");
1324
1325 qDebug("DocLnk add "+name);
1326 d->selectedFiles->addToSelection( lnk);
1327 }
1328 }
1329 i++;
1330 }
1331}
1332
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 7718a8c..1be5a15 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,125 +1,128 @@
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#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qtabwidget.h> 25#include <qtabwidget.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29#include "om3u.h"
29/* #include <qtimer.h> */ 30/* #include <qtimer.h> */
30 31
31 32
32class PlayListWidgetPrivate; 33class PlayListWidgetPrivate;
33class Config; 34class Config;
34class QListViewItem; 35class QListViewItem;
35class QListView; 36class QListView;
36class QPoint; 37class QPoint;
37class QAction; 38class QAction;
38class QLabel; 39class QLabel;
39 40
40class PlayListWidget : public QMainWindow { 41class PlayListWidget : public QMainWindow {
41 Q_OBJECT 42 Q_OBJECT
42public: 43public:
43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 44 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
44 ~PlayListWidget(); 45 ~PlayListWidget();
45 QTabWidget * tabWidget; 46 QTabWidget * tabWidget;
46 QAction *fullScreenButton, *scaleButton; 47 QAction *fullScreenButton, *scaleButton;
47 DocLnkSet files; 48 DocLnkSet files;
48 DocLnkSet vFiles; 49 DocLnkSet vFiles;
49 QListView *audioView, *videoView, *playlistView; 50 QListView *audioView, *videoView, *playlistView;
50 QLabel *libString; 51 QLabel *libString;
51 bool fromSetDocument; 52 bool fromSetDocument;
52 bool insanityBool; 53 bool insanityBool;
53 QString setDocFileRef; 54 QString setDocFileRef, currentPlayList;
54 // retrieve the current playlist entry (media file link) 55 // retrieve the current playlist entry (media file link)
55 const DocLnk *current(); 56 const DocLnk *current();
56 void useSelectedDocument(); 57 void useSelectedDocument();
57/* QTimer * menuTimer; */ 58/* QTimer * menuTimer; */
58 FileSelector* playLists; 59 FileSelector* playLists;
59 QPushButton *tbDeletePlaylist; 60 QPushButton *tbDeletePlaylist;
60 int fd, selected; 61 int fd, selected;
61public slots: 62public slots:
62 bool first(); 63 bool first();
63 bool last(); 64 bool last();
64 bool next(); 65 bool next();
65 bool prev(); 66 bool prev();
66/* void setFullScreen(); */ 67/* void setFullScreen(); */
67/* void setScaled(); */ 68/* void setScaled(); */
68protected: 69protected:
69/* void contentsMousePressEvent( QMouseEvent * e ); */ 70/* void contentsMousePressEvent( QMouseEvent * e ); */
70/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 71/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
71void keyReleaseEvent( QKeyEvent *e); 72void keyReleaseEvent( QKeyEvent *e);
72void keyPressEvent( QKeyEvent *e); 73void keyPressEvent( QKeyEvent *e);
73private: 74private:
74 bool audioScan, videoScan; 75 bool audioScan, videoScan;
75 void doBlank(); 76 void doBlank();
76 void doUnblank(); 77 void doUnblank();
77 void readm3u(const QString &); 78 void readm3u(const QString &);
78 void readPls(const QString &); 79 void readPls(const QString &);
79 80
80 81
81 void initializeStates(); 82 void initializeStates();
82 void readConfig( Config& cfg ); 83 void readConfig( Config& cfg );
83 void writeConfig( Config& cfg ) const; 84 void writeConfig( Config& cfg ) const;
84 PlayListWidgetPrivate *d; // Private implementation data 85 PlayListWidgetPrivate *d; // Private implementation data
85 void populateAudioView(); 86 void populateAudioView();
86 void populateVideoView(); 87 void populateVideoView();
87private slots: 88private slots:
89
88 void writem3u(); 90 void writem3u();
91 void writeCurrentM3u();
89 void scanForAudio(); 92 void scanForAudio();
90 void scanForVideo(); 93 void scanForVideo();
91 void openFile(); 94 void openFile();
92 void setDocument( const QString& fileref ); 95 void setDocument( const QString& fileref );
93 void addToSelection( const DocLnk& ); // Add a media file to the playlist 96 void addToSelection( const DocLnk& ); // Add a media file to the playlist
94 void addToSelection( QListViewItem* ); // Add a media file to the playlist 97 void addToSelection( QListViewItem* ); // Add a media file to the playlist
95 void setActiveWindow(); // need to handle this to show the right view 98 void setActiveWindow(); // need to handle this to show the right view
96 void setPlaylist( bool ); // Show/Hide the playlist 99 void setPlaylist( bool ); // Show/Hide the playlist
97 void setView( char ); 100 void setView( char );
98 void clearList(); 101 void clearList();
99 void addAllToList(); 102 void addAllToList();
100 void addAllMusicToList(); 103 void addAllMusicToList();
101 void addAllVideoToList(); 104 void addAllVideoToList();
102 void saveList(); // Save the playlist 105 void saveList(); // Save the playlist
103 void loadList( const DocLnk &); // Load a playlist 106 void loadList( const DocLnk &); // Load a playlist
104 void playIt( QListViewItem *); 107 void playIt( QListViewItem *);
105 108
106 void btnPlay(bool); 109 void btnPlay(bool);
107 void deletePlaylist(); 110 void deletePlaylist();
108 void addSelected(); 111 void addSelected();
109 void removeSelected(); 112 void removeSelected();
110 void tabChanged(QWidget*); 113 void tabChanged(QWidget*);
111 void viewPressed( int, QListViewItem *, const QPoint&, int); 114 void viewPressed( int, QListViewItem *, const QPoint&, int);
112 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 115 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
113 void playSelected(); 116 void playSelected();
114 void listDelete(); 117 void listDelete();
115 118
116protected slots: 119protected slots:
117/* void cancelMenuTimer(); */ 120/* void cancelMenuTimer(); */
118/* void showFileMenu(); */ 121/* void showFileMenu(); */
119 122
120 123
121}; 124};
122 125
123 126
124#endif // PLAY_LIST_WIDGET_H 127#endif // PLAY_LIST_WIDGET_H
125 128