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