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