summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-04-04 17:38:26 (UTC)
committer mickeyl <mickeyl>2004-04-04 17:38:26 (UTC)
commit4588425855268ce88a80ddbac7e1c3d4b87b03f4 (patch) (unidiff)
treecc2ba17458cd68592093e6c1bb216df3582cb6f5
parentea3708cbc40ebc5f1db70546f0a93e8a23ba967c (diff)
downloadopie-4588425855268ce88a80ddbac7e1c3d4b87b03f4.zip
opie-4588425855268ce88a80ddbac7e1c3d4b87b03f4.tar.gz
opie-4588425855268ce88a80ddbac7e1c3d4b87b03f4.tar.bz2
use odebug classes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp16
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp16
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/playlistselection.cpp9
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp19
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp12
7 files changed, 51 insertions, 30 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 36def67..95a0f45 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,295 +1,298 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34 34
35#include "audiowidget.h" 35#include "audiowidget.h"
36 36
37/* OPIE */
38#include <opie2/odebug.h>
37#include <qpe/qpeapplication.h> 39#include <qpe/qpeapplication.h>
38 40using namespace Opie::Core;
39using namespace Opie::Ui; 41using namespace Opie::Ui;
42
40namespace 43namespace
41{ 44{
42 45
43const int xo = -2; // movable x offset 46const int xo = -2; // movable x offset
44const int yo = 22; // movable y offset 47const int yo = 22; // movable y offset
45 48
46const MediaWidget::SkinButtonInfo skinInfo[] = 49const MediaWidget::SkinButtonInfo skinInfo[] =
47{ 50{
48 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 51 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
49 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 52 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
50 { MediaWidget::Next, "next", MediaWidget::NormalButton }, 53 { MediaWidget::Next, "next", MediaWidget::NormalButton },
51 { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, 54 { MediaWidget::Previous, "prev", MediaWidget::NormalButton },
52 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 55 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
53 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 56 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
54 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, 57 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton },
55 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, 58 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton },
56 { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, 59 { MediaWidget::Forward, "forward", MediaWidget::NormalButton },
57 { MediaWidget::Back, "back", MediaWidget::NormalButton } 60 { MediaWidget::Back, "back", MediaWidget::NormalButton }
58}; 61};
59 62
60const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 63const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
61 64
62void changeTextColor( QWidget * w) { 65void changeTextColor( QWidget * w) {
63 QPalette p = w->palette(); 66 QPalette p = w->palette();
64 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 67 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
65 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 68 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
66 w->setPalette( p ); 69 w->setPalette( p );
67} 70}
68 71
69} 72}
70 73
71AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 74AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
72 75
73 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 76 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
74 audioSliderBeingMoved( false ) 77 audioSliderBeingMoved( false )
75{ 78{
76 setCaption( tr("OpiePlayer") ); 79 setCaption( tr("OpiePlayer") );
77 80
78 loadSkin(); 81 loadSkin();
79 82
80 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 83 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
81 connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); 84 connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) );
82 85
83 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 86 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
84 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 87 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
85 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 88 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
86 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 89 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
87 90
88 // Intialise state 91 // Intialise state
89 setLength( mediaPlayerState.length() ); 92 setLength( mediaPlayerState.length() );
90 setPosition( mediaPlayerState.position() ); 93 setPosition( mediaPlayerState.position() );
91 setLooping( mediaPlayerState.isFullscreen() ); 94 setLooping( mediaPlayerState.isFullscreen() );
92 // setPaused( mediaPlayerState->paused() ); 95 // setPaused( mediaPlayerState->paused() );
93 setPlaying( mediaPlayerState.isPlaying() ); 96 setPlaying( mediaPlayerState.isPlaying() );
94} 97}
95 98
96AudioWidget::~AudioWidget() { 99AudioWidget::~AudioWidget() {
97 100
98// mediaPlayerState->setPlaying(false); 101// mediaPlayerState->setPlaying(false);
99} 102}
100 103
101MediaWidget::GUIInfo AudioWidget::guiInfo() 104MediaWidget::GUIInfo AudioWidget::guiInfo()
102{ 105{
103 return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); 106 return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount );
104} 107}
105 108
106void AudioWidget::resizeEvent( QResizeEvent *e ) { 109void AudioWidget::resizeEvent( QResizeEvent *e ) {
107 int h = height(); 110 int h = height();
108 int w = width(); 111 int w = width();
109 112
110 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 113 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
111 slider.setFixedWidth( w - 110 ); 114 slider.setFixedWidth( w - 110 );
112 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 115 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
113 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 116 slider.setBackgroundOrigin( QWidget::ParentOrigin );
114 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 117 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
115 118
116 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; 119 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2;
117 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; 120 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10;
118 121
119 MediaWidget::resizeEvent( e ); 122 MediaWidget::resizeEvent( e );
120} 123}
121 124
122void AudioWidget::sliderPressed() { 125void AudioWidget::sliderPressed() {
123 audioSliderBeingMoved = TRUE; 126 audioSliderBeingMoved = TRUE;
124} 127}
125 128
126 129
127void AudioWidget::sliderReleased() { 130void AudioWidget::sliderReleased() {
128 audioSliderBeingMoved = FALSE; 131 audioSliderBeingMoved = FALSE;
129 if ( slider.width() == 0 ) 132 if ( slider.width() == 0 )
130 return; 133 return;
131 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 134 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
132 mediaPlayerState.setPosition( val ); 135 mediaPlayerState.setPosition( val );
133} 136}
134 137
135void AudioWidget::setPosition( long i ) { 138void AudioWidget::setPosition( long i ) {
136 // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<set position " << i << "" << oendl; 139 // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<set position " << i << "" << oendl;
137 updateSlider( i, mediaPlayerState.length() ); 140 updateSlider( i, mediaPlayerState.length() );
138} 141}
139 142
140 143
141void AudioWidget::setLength( long max ) { 144void AudioWidget::setLength( long max ) {
142 updateSlider( mediaPlayerState.position(), max ); 145 updateSlider( mediaPlayerState.position(), max );
143} 146}
144 147
145 148
146void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 149void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
147 if ( mediaType == MediaPlayerState::Audio ) { 150 if ( mediaType == MediaPlayerState::Audio ) {
148 // startTimer( 150 ); 151 // startTimer( 150 );
149 QPEApplication::showWidget( this ); 152 QPEApplication::showWidget( this );
150 return; 153 return;
151 } 154 }
152 155
153 killTimers(); 156 killTimers();
154 hide(); 157 hide();
155} 158}
156 159
157void AudioWidget::loadSkin() 160void AudioWidget::loadSkin()
158{ 161{
159 loadDefaultSkin( guiInfo() ); 162 loadDefaultSkin( guiInfo() );
160 163
161 songInfo.setFocusPolicy( QWidget::NoFocus ); 164 songInfo.setFocusPolicy( QWidget::NoFocus );
162// changeTextColor( &songInfo ); 165// changeTextColor( &songInfo );
163// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 166// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
164// songInfo.setFrameStyle( QFrame::NoFrame); 167// songInfo.setFrameStyle( QFrame::NoFrame);
165 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 168 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
166// songInfo.setForegroundColor(Qt::white); 169// songInfo.setForegroundColor(Qt::white);
167 170
168 slider.setFixedHeight( 20 ); 171 slider.setFixedHeight( 20 );
169 slider.setMinValue( 0 ); 172 slider.setMinValue( 0 );
170 slider.setMaxValue( 1 ); 173 slider.setMaxValue( 1 );
171 slider.setFocusPolicy( QWidget::NoFocus ); 174 slider.setFocusPolicy( QWidget::NoFocus );
172 slider.setBackgroundPixmap( backgroundPixmap ); 175 slider.setBackgroundPixmap( backgroundPixmap );
173 176
174// Config cofg("qpe"); 177// Config cofg("qpe");
175// cofg.setGroup("Appearance"); 178// cofg.setGroup("Appearance");
176// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 179// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
177 180
178 time.setFocusPolicy( QWidget::NoFocus ); 181 time.setFocusPolicy( QWidget::NoFocus );
179 time.setAlignment( Qt::AlignCenter ); 182 time.setAlignment( Qt::AlignCenter );
180 183
181// time.setFrame(FALSE); 184// time.setFrame(FALSE);
182// changeTextColor( &time ); 185// changeTextColor( &time );
183 186
184 resizeEvent( 0 ); 187 resizeEvent( 0 );
185} 188}
186 189
187void AudioWidget::setSeekable( bool isSeekable ) { 190void AudioWidget::setSeekable( bool isSeekable ) {
188 191
189 if ( !isSeekable ) { 192 if ( !isSeekable ) {
190 odebug << "<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>" << oendl; 193 odebug << "<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>" << oendl;
191 if( !slider.isHidden()) { 194 if( !slider.isHidden()) {
192 slider.hide(); 195 slider.hide();
193 } 196 }
194 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 197 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
195 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 198 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
196 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 199 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
197 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 200 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
198 } else { 201 } else {
199 // this stops the slider from being moved, thus 202 // this stops the slider from being moved, thus
200 // does not stop stream when it reaches the end 203 // does not stop stream when it reaches the end
201 slider.show(); 204 slider.show();
202 odebug << " CONNECT SET POSTION " << oendl; 205 odebug << " CONNECT SET POSTION " << oendl;
203 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 206 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
204 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 207 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
205 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 208 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
206 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 209 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
207 } 210 }
208} 211}
209 212
210 213
211static QString timeAsString( long length ) { 214static QString timeAsString( long length ) {
212 int minutes = length / 60; 215 int minutes = length / 60;
213 int seconds = length % 60; 216 int seconds = length % 60;
214 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 217 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
215} 218}
216 219
217void AudioWidget::updateSlider( long i, long max ) { 220void AudioWidget::updateSlider( long i, long max ) {
218 221
219 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 222 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
220// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 223// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
221 224
222 if ( max == 0 ) { 225 if ( max == 0 ) {
223 return; 226 return;
224 } 227 }
225 // Will flicker too much if we don't do this 228 // Will flicker too much if we don't do this
226 // Scale to something reasonable 229 // Scale to something reasonable
227 int width = slider.width(); 230 int width = slider.width();
228 int val = int((double)i * width / max); 231 int val = int((double)i * width / max);
229 if ( !audioSliderBeingMoved ) { 232 if ( !audioSliderBeingMoved ) {
230 if ( slider.value() != val ) { 233 if ( slider.value() != val ) {
231 slider.setValue( val ); 234 slider.setValue( val );
232 } 235 }
233 236
234 if ( slider.maxValue() != width ) { 237 if ( slider.maxValue() != width ) {
235 slider.setMaxValue( width ); 238 slider.setMaxValue( width );
236 } 239 }
237 } 240 }
238} 241}
239 242
240void AudioWidget::skipFor() { 243void AudioWidget::skipFor() {
241 skipDirection = +1; 244 skipDirection = +1;
242 startTimer( 50 ); 245 startTimer( 50 );
243 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 246 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
244} 247}
245 248
246void AudioWidget::skipBack() { 249void AudioWidget::skipBack() {
247 skipDirection = -1; 250 skipDirection = -1;
248 startTimer( 50 ); 251 startTimer( 50 );
249 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 252 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
250} 253}
251 254
252 255
253 256
254void AudioWidget::stopSkip() { 257void AudioWidget::stopSkip() {
255 killTimers(); 258 killTimers();
256} 259}
257 260
258 261
259void AudioWidget::timerEvent( QTimerEvent * ) { 262void AudioWidget::timerEvent( QTimerEvent * ) {
260 if ( skipDirection == +1 ) { 263 if ( skipDirection == +1 ) {
261 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 264 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
262 } else if ( skipDirection == -1 ) { 265 } else if ( skipDirection == -1 ) {
263 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 266 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
264 } 267 }
265} 268}
266 269
267void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 270void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
268 switch ( e->key() ) { 271 switch ( e->key() ) {
269 ////////////////////////////// Zaurus keys 272 ////////////////////////////// Zaurus keys
270 case Key_Home: 273 case Key_Home:
271 break; 274 break;
272 case Key_F9: //activity 275 case Key_F9: //activity
273 hide(); 276 hide();
274 // odebug << "Audio F9" << oendl; 277 // odebug << "Audio F9" << oendl;
275 e->accept(); 278 e->accept();
276 break; 279 break;
277 case Key_F10: //contacts 280 case Key_F10: //contacts
278 break; 281 break;
279 case Key_F11: //menu 282 case Key_F11: //menu
280 mediaPlayerState.toggleBlank(); 283 mediaPlayerState.toggleBlank();
281 e->accept(); 284 e->accept();
282 break; 285 break;
283 case Key_F12: //home 286 case Key_F12: //home
284 break; 287 break;
285 case Key_F13: //mail 288 case Key_F13: //mail
286 mediaPlayerState.toggleBlank(); 289 mediaPlayerState.toggleBlank();
287 e->accept(); 290 e->accept();
288 break; 291 break;
289 case Key_Space: { 292 case Key_Space: {
290 e->accept(); 293 e->accept();
291 mediaPlayerState.togglePaused(); 294 mediaPlayerState.togglePaused();
292 } 295 }
293 break; 296 break;
294 case Key_Down: 297 case Key_Down:
295 // toggleButton(6); 298 // toggleButton(6);
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 5c24dbe..1ab5c96 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,303 +1,305 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "xinevideowidget.h"
35#include "frame.h"
36#include "lib.h"
34 37
35#include <qtextstream.h> 38/* OPIE */
39#include <opie2/odebug.h>
40using namespace Opie::Core;
36 41
42/* QT */
43#include <qtextstream.h>
37#include <qdir.h> 44#include <qdir.h>
38
39#include <qgfx_qws.h> 45#include <qgfx_qws.h>
40 46
47/* STD */
41#include <assert.h> 48#include <assert.h>
42 49
43#include "xinevideowidget.h"
44#include "frame.h"
45#include "lib.h"
46
47
48typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 50typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
49 int width, int height,int bytes ); 51 int width, int height,int bytes );
50 52
51extern "C" { 53extern "C" {
52 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 54 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
53 int null_is_showing_video( const xine_vo_driver_t* self ); 55 int null_is_showing_video( const xine_vo_driver_t* self );
54 void null_set_show_video( const xine_vo_driver_t* self, int show ); 56 void null_set_show_video( const xine_vo_driver_t* self, int show );
55 int null_is_fullscreen( const xine_vo_driver_t* self ); 57 int null_is_fullscreen( const xine_vo_driver_t* self );
56 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 58 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
57 int null_is_scaling( const xine_vo_driver_t* self ); 59 int null_is_scaling( const xine_vo_driver_t* self );
58 void null_set_scaling( const xine_vo_driver_t* self, int scale ); 60 void null_set_scaling( const xine_vo_driver_t* self, int scale );
59 void null_set_gui_width( const xine_vo_driver_t* self, int width ); 61 void null_set_gui_width( const xine_vo_driver_t* self, int width );
60 void null_set_gui_height( const xine_vo_driver_t* self, int height ); 62 void null_set_gui_height( const xine_vo_driver_t* self, int height );
61 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); 63 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
62 void null_set_videoGamma( const xine_vo_driver_t* self , int value ); 64 void null_set_videoGamma( const xine_vo_driver_t* self , int value );
63 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); 65 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
64 66
65 void null_preload_decoders( xine_stream_t *stream ); 67 void null_preload_decoders( xine_stream_t *stream );
66} 68}
67 69
68using namespace XINE; 70using namespace XINE;
69 71
70Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) 72Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
71{ 73{
72 m_initialized = false; 74 m_initialized = false;
73 m_duringInitialization = false; 75 m_duringInitialization = false;
74 m_video = false; 76 m_video = false;
75 m_wid = widget; 77 m_wid = widget;
76 printf("Lib"); 78 printf("Lib");
77 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 79 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
78 // get the configuration 80 // get the configuration
79 81
80 // not really OO, should be an extra class, later 82 // not really OO, should be an extra class, later
81 if ( !QFile::exists(configPath) ) { 83 if ( !QFile::exists(configPath) ) {
82 QFile f(configPath); 84 QFile f(configPath);
83 f.open(IO_WriteOnly); 85 f.open(IO_WriteOnly);
84 QTextStream ts( &f ); 86 QTextStream ts( &f );
85 ts << "misc.memcpy_method:glibc\n"; 87 ts << "misc.memcpy_method:glibc\n";
86 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; 88 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n";
87 ts << "codec.ffmpeg_pp_quality:3\n"; 89 ts << "codec.ffmpeg_pp_quality:3\n";
88 ts << "audio.num_buffers:50\n"; 90 ts << "audio.num_buffers:50\n";
89 ts << "audio.size_buffers:4096\n"; 91 ts << "audio.size_buffers:4096\n";
90 ts << "video.num_buffers:20\n"; 92 ts << "video.num_buffers:20\n";
91 ts << "video.size_buffers:4096\n"; 93 ts << "video.size_buffers:4096\n";
92 ts << "audio.out_num_audio_buf:16\n"; 94 ts << "audio.out_num_audio_buf:16\n";
93 ts << "audio.out_size_audio_buf:8096\n"; 95 ts << "audio.out_size_audio_buf:8096\n";
94 ts << "audio.out_size_zero_buf:1024\n"; 96 ts << "audio.out_size_zero_buf:1024\n";
95 ts << "audio.passthrough_offset:0\n"; 97 ts << "audio.passthrough_offset:0\n";
96 f.close(); 98 f.close();
97 } 99 }
98 100
99 if ( initMode == InitializeImmediately ) { 101 if ( initMode == InitializeImmediately ) {
100 initialize(); 102 initialize();
101 m_initialized = true; 103 m_initialized = true;
102 } 104 }
103 else 105 else
104 start(); 106 start();
105} 107}
106 108
107void Lib::run() 109void Lib::run()
108{ 110{
109 odebug << "Lib::run() started" << oendl; 111 odebug << "Lib::run() started" << oendl;
110 initialize(); 112 initialize();
111 m_initialized = true; 113 m_initialized = true;
112 odebug << "Lib::run() finished" << oendl; 114 odebug << "Lib::run() finished" << oendl;
113} 115}
114 116
115void Lib::initialize() 117void Lib::initialize()
116{ 118{
117 m_duringInitialization = true; 119 m_duringInitialization = true;
118 m_xine = xine_new( ); 120 m_xine = xine_new( );
119 121
120 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 122 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
121 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 123 xine_config_load( m_xine, QFile::encodeName( configPath ) );
122 124
123 xine_init( m_xine ); 125 xine_init( m_xine );
124 126
125 // allocate oss for sound 127 // allocate oss for sound
126 // and fb for framebuffer 128 // and fb for framebuffer
127 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 129 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
128 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 130 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
129 131
130 132
131//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); 133//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
132 134
133 135
134// null_display_handler( m_videoOutput, xine_display_frame, this ); 136// null_display_handler( m_videoOutput, xine_display_frame, this );
135 137
136 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 138 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
137 139
138 if (m_wid != 0 ) { 140 if (m_wid != 0 ) {
139 printf( "!0\n" ); 141 printf( "!0\n" );
140 setWidget( m_wid ); 142 setWidget( m_wid );
141 } 143 }
142 144
143 m_queue = xine_event_new_queue (m_stream); 145 m_queue = xine_event_new_queue (m_stream);
144 146
145 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 147 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
146 148
147 ::null_preload_decoders( m_stream ); 149 ::null_preload_decoders( m_stream );
148 150
149 m_duringInitialization = false; 151 m_duringInitialization = false;
150} 152}
151 153
152Lib::~Lib() { 154Lib::~Lib() {
153 assert( isRunning() == false ); 155 assert( isRunning() == false );
154 assert( m_initialized ); 156 assert( m_initialized );
155 157
156// free( m_config ); 158// free( m_config );
157 159
158 xine_close( m_stream ); 160 xine_close( m_stream );
159 161
160 xine_event_dispose_queue( m_queue ); 162 xine_event_dispose_queue( m_queue );
161 163
162 xine_dispose( m_stream ); 164 xine_dispose( m_stream );
163 165
164 xine_exit( m_xine ); 166 xine_exit( m_xine );
165 /* FIXME either free or delete but valgrind bitches against both */ 167 /* FIXME either free or delete but valgrind bitches against both */
166 //free( m_videoOutput ); 168 //free( m_videoOutput );
167 //delete m_audioOutput; 169 //delete m_audioOutput;
168} 170}
169 171
170void Lib::resize ( const QSize &s ) { 172void Lib::resize ( const QSize &s ) {
171 assert( m_initialized || m_duringInitialization ); 173 assert( m_initialized || m_duringInitialization );
172 174
173 if ( s. width ( ) && s. height ( ) ) { 175 if ( s. width ( ) && s. height ( ) ) {
174 ::null_set_gui_width( m_videoOutput, s. width() ); 176 ::null_set_gui_width( m_videoOutput, s. width() );
175 ::null_set_gui_height( m_videoOutput, s. height() ); 177 ::null_set_gui_height( m_videoOutput, s. height() );
176 } 178 }
177} 179}
178 180
179int Lib::majorVersion() { 181int Lib::majorVersion() {
180 int major, minor, sub; 182 int major, minor, sub;
181 xine_get_version ( &major, &minor, &sub ); 183 xine_get_version ( &major, &minor, &sub );
182 return major; 184 return major;
183} 185}
184 186
185int Lib::minorVersion() { 187int Lib::minorVersion() {
186 int major, minor, sub; 188 int major, minor, sub;
187 xine_get_version ( &major, &minor, &sub ); 189 xine_get_version ( &major, &minor, &sub );
188 return minor; 190 return minor;
189} 191}
190 192
191int Lib::subVersion() { 193int Lib::subVersion() {
192 int major, minor, sub; 194 int major, minor, sub;
193 xine_get_version ( &major, &minor, &sub ); 195 xine_get_version ( &major, &minor, &sub );
194 return sub; 196 return sub;
195} 197}
196 198
197int Lib::play( const QString& fileName, int startPos, int start_time ) { 199int Lib::play( const QString& fileName, int startPos, int start_time ) {
198 assert( m_initialized ); 200 assert( m_initialized );
199 // FIXME actually a hack imho. Should not be needed to dispose the whole stream 201 // FIXME actually a hack imho. Should not be needed to dispose the whole stream
200 // but without we get wrong media length reads from libxine for the second media 202 // but without we get wrong media length reads from libxine for the second media
201 //xine_dispose ( m_stream ); 203 //xine_dispose ( m_stream );
202 204
203 QString str = fileName.stripWhiteSpace(); 205 QString str = fileName.stripWhiteSpace();
204 206
205 //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 207 //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
206 //m_queue = xine_event_new_queue (m_stream); 208 //m_queue = xine_event_new_queue (m_stream);
207 //xine_event_create_listener_thread (m_queue, xine_event_handler, this); 209 //xine_event_create_listener_thread (m_queue, xine_event_handler, this);
208 210
209 if ( !xine_open( m_stream, str.utf8().data() ) ) { 211 if ( !xine_open( m_stream, str.utf8().data() ) ) {
210 return 0; 212 return 0;
211 } 213 }
212 return xine_play( m_stream, startPos, start_time); 214 return xine_play( m_stream, startPos, start_time);
213} 215}
214 216
215void Lib::stop() { 217void Lib::stop() {
216 assert( m_initialized ); 218 assert( m_initialized );
217 219
218 odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl; 220 odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl;
219 xine_stop( m_stream ); 221 xine_stop( m_stream );
220} 222}
221 223
222void Lib::pause( bool toggle ) { 224void Lib::pause( bool toggle ) {
223 assert( m_initialized ); 225 assert( m_initialized );
224 226
225 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 227 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
226} 228}
227 229
228int Lib::speed() const { 230int Lib::speed() const {
229 assert( m_initialized ); 231 assert( m_initialized );
230 232
231 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 233 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
232} 234}
233 235
234void Lib::setSpeed( int speed ) { 236void Lib::setSpeed( int speed ) {
235 assert( m_initialized ); 237 assert( m_initialized );
236 238
237 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 239 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
238} 240}
239 241
240int Lib::status() const { 242int Lib::status() const {
241 assert( m_initialized ); 243 assert( m_initialized );
242 244
243 return xine_get_status( m_stream ); 245 return xine_get_status( m_stream );
244} 246}
245 247
246int Lib::currentPosition() const { 248int Lib::currentPosition() const {
247 assert( m_initialized ); 249 assert( m_initialized );
248 250
249 int pos, time, length; 251 int pos, time, length;
250 xine_get_pos_length( m_stream, &pos, &time, &length ); 252 xine_get_pos_length( m_stream, &pos, &time, &length );
251 return pos; 253 return pos;
252} 254}
253 255
254int Lib::currentTime() const { 256int Lib::currentTime() const {
255 assert( m_initialized ); 257 assert( m_initialized );
256 258
257 int pos, time, length; 259 int pos, time, length;
258 xine_get_pos_length( m_stream, &pos, &time, &length ); 260 xine_get_pos_length( m_stream, &pos, &time, &length );
259 if ( time > 0 ) { 261 if ( time > 0 ) {
260 return time/1000; 262 return time/1000;
261 } else { 263 } else {
262 return 0; 264 return 0;
263 } 265 }
264} 266}
265 267
266int Lib::length() const { 268int Lib::length() const {
267 assert( m_initialized ); 269 assert( m_initialized );
268 270
269 int pos, time, length; 271 int pos, time, length;
270/* dilb: patch to solve the wrong stream length reported to the GUI*/ 272/* dilb: patch to solve the wrong stream length reported to the GUI*/
271 int iRetVal=0, iTestLoop=0; 273 int iRetVal=0, iTestLoop=0;
272 274
273 do 275 do
274 { 276 {
275 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); 277 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length );
276 if (iRetVal) 278 if (iRetVal)
277 {/* if the function didn't return 0, then pos, time and length are valid.*/ 279 {/* if the function didn't return 0, then pos, time and length are valid.*/
278 return length/1000; 280 return length/1000;
279 } 281 }
280 /*don't poll too much*/ 282 /*don't poll too much*/
281 usleep(100000); 283 usleep(100000);
282 iTestLoop++; 284 iTestLoop++;
283 } 285 }
284 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any 286 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any
285valid stream, then return -1 (this value could be used to make the stream 287valid stream, then return -1 (this value could be used to make the stream
286unseekable, but it should never occur!! Mr. Murphy ? :) ) */ 288unseekable, but it should never occur!! Mr. Murphy ? :) ) */
287 289
288 return -1; 290 return -1;
289} 291}
290 292
291bool Lib::isSeekable() const { 293bool Lib::isSeekable() const {
292 assert( m_initialized ); 294 assert( m_initialized );
293 295
294 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 296 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
295} 297}
296 298
297void Lib::seekTo( int time ) { 299void Lib::seekTo( int time ) {
298 assert( m_initialized ); 300 assert( m_initialized );
299 301
300 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( 302 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
301 // since its now milliseconds we need *1000 303 // since its now milliseconds we need *1000
302 xine_play( m_stream, 0, time*1000 ); 304 xine_play( m_stream, 0, time*1000 );
303} 305}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 7e38fc7..7b4bfd9 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,273 +1,275 @@
1#include <qpe/qpeapplication.h>
2#include <qpe/config.h>
3#include <qfileinfo.h>
4
5#include "mediaplayer.h" 1#include "mediaplayer.h"
6#include "audiowidget.h" 2#include "audiowidget.h"
7#include "videowidget.h" 3#include "videowidget.h"
8#include "volumecontrol.h" 4#include "volumecontrol.h"
9 5
6/* OPIE */
7#include <opie2/odebug.h>
8#include <qpe/qpeapplication.h>
9#include <qpe/config.h>
10
11/* QT */
12#include <qfileinfo.h>
10 13
11 // for setBacklight() 14/* STD */
12#include <linux/fb.h> 15#include <linux/fb.h>
13#include <sys/file.h> 16#include <sys/file.h>
14#include <sys/ioctl.h> 17#include <sys/ioctl.h>
15 18
16 19#define FBIOBLANK 0x4611
17#define FBIOBLANK 0x4611
18 20
19MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 21MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
20 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 22 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
21 23
22 m_audioUI = 0; 24 m_audioUI = 0;
23 m_videoUI = 0; 25 m_videoUI = 0;
24 m_xineControl = 0; 26 m_xineControl = 0;
25 xine = new XINE::Lib( XINE::Lib::InitializeInThread ); 27 xine = new XINE::Lib( XINE::Lib::InitializeInThread );
26 28
27 fd=-1;fl=-1; 29 fd=-1;fl=-1;
28 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 30 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
29 31
30 qApp->processEvents(); 32 qApp->processEvents();
31 // QPEApplication::grabKeyboard(); // EVIL 33 // QPEApplication::grabKeyboard(); // EVIL
32 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 34 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
33 35
34 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 36 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
35 37
36// What is pauseCheck good for? (Simon) 38// What is pauseCheck good for? (Simon)
37// connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); 39// connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) );
38 40
39 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 41 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
40 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 42 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
41 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); 43 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) );
42 44
43 volControl = new VolumeControl; 45 volControl = new VolumeControl;
44 Config cfg( "OpiePlayer" ); 46 Config cfg( "OpiePlayer" );
45 cfg.setGroup("PlayList"); 47 cfg.setGroup("PlayList");
46 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 48 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
47 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 49 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
48 50
49 m_skinLoader = new SkinLoader; 51 m_skinLoader = new SkinLoader;
50 m_skinLoader->schedule( AudioWidget::guiInfo() ); 52 m_skinLoader->schedule( AudioWidget::guiInfo() );
51 m_skinLoader->schedule( VideoWidget::guiInfo() ); 53 m_skinLoader->schedule( VideoWidget::guiInfo() );
52 m_skinLoader->start(); 54 m_skinLoader->start();
53} 55}
54 56
55MediaPlayer::~MediaPlayer() { 57MediaPlayer::~MediaPlayer() {
56 // this shold never happen, but one never knows... 58 // this shold never happen, but one never knows...
57 if ( xine ) { 59 if ( xine ) {
58 xine->ensureInitialized(); 60 xine->ensureInitialized();
59 delete xine; 61 delete xine;
60 } 62 }
61 delete m_xineControl; 63 delete m_xineControl;
62 delete m_audioUI; 64 delete m_audioUI;
63 delete m_videoUI; 65 delete m_videoUI;
64 delete volControl; 66 delete volControl;
65} 67}
66 68
67void MediaPlayer::pauseCheck( bool b ) { 69void MediaPlayer::pauseCheck( bool b ) {
68 if ( b && !mediaPlayerState.isPlaying() ) { 70 if ( b && !mediaPlayerState.isPlaying() ) {
69 mediaPlayerState.setPaused( FALSE ); 71 mediaPlayerState.setPaused( FALSE );
70 } 72 }
71} 73}
72 74
73void MediaPlayer::play() { 75void MediaPlayer::play() {
74 mediaPlayerState.setPlaying( FALSE ); 76 mediaPlayerState.setPlaying( FALSE );
75 mediaPlayerState.setPlaying( TRUE ); 77 mediaPlayerState.setPlaying( TRUE );
76} 78}
77 79
78void MediaPlayer::setPlaying( bool play ) { 80void MediaPlayer::setPlaying( bool play ) {
79 if ( !play ) { 81 if ( !play ) {
80 return; 82 return;
81 } 83 }
82 84
83 if ( mediaPlayerState.isPaused() ) { 85 if ( mediaPlayerState.isPaused() ) {
84 mediaPlayerState.setPaused( FALSE ); 86 mediaPlayerState.setPaused( FALSE );
85 return; 87 return;
86 } 88 }
87 89
88 QString tickerText, time, fileName; 90 QString tickerText, time, fileName;
89 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 91 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
90 //if playing in file list.. play in a different way 92 //if playing in file list.. play in a different way
91 // random and looping settings enabled causes problems here, 93 // random and looping settings enabled causes problems here,
92 // since there is no selected file in the playlist, but a selected file in the file list, 94 // since there is no selected file in the playlist, but a selected file in the file list,
93 // so we remember and shutoff 95 // so we remember and shutoff
94 l = mediaPlayerState.isLooping(); 96 l = mediaPlayerState.isLooping();
95 if(l) { 97 if(l) {
96 mediaPlayerState.setLooping( false ); 98 mediaPlayerState.setLooping( false );
97 } 99 }
98 r = mediaPlayerState.isShuffled(); 100 r = mediaPlayerState.isShuffled();
99 mediaPlayerState.setShuffled( false ); 101 mediaPlayerState.setShuffled( false );
100 } 102 }
101 103
102 PlayListWidget::Entry playListEntry = playList.currentEntry(); 104 PlayListWidget::Entry playListEntry = playList.currentEntry();
103 fileName = playListEntry.name; 105 fileName = playListEntry.name;
104 xineControl()->play( playListEntry.file ); 106 xineControl()->play( playListEntry.file );
105 107
106 long seconds = mediaPlayerState.length(); 108 long seconds = mediaPlayerState.length();
107 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 109 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
108 110
109 if( fileName.left(4) == "http" ) { 111 if( fileName.left(4) == "http" ) {
110 fileName = QFileInfo( fileName ).baseName(); 112 fileName = QFileInfo( fileName ).baseName();
111 if ( xineControl()->getMetaInfo().isEmpty() ) { 113 if ( xineControl()->getMetaInfo().isEmpty() ) {
112 tickerText = tr( " File: " ) + fileName; 114 tickerText = tr( " File: " ) + fileName;
113 } else { 115 } else {
114 tickerText = xineControl()->getMetaInfo(); 116 tickerText = xineControl()->getMetaInfo();
115 } 117 }
116 } else { 118 } else {
117 if ( xineControl()->getMetaInfo().isEmpty() ) { 119 if ( xineControl()->getMetaInfo().isEmpty() ) {
118 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 120 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
119 } else { 121 } else {
120 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; 122 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " ";
121 } 123 }
122 } 124 }
123 audioUI()->setTickerText( tickerText ); 125 audioUI()->setTickerText( tickerText );
124} 126}
125 127
126 128
127void MediaPlayer::prev() { 129void MediaPlayer::prev() {
128 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 130 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
129 if ( playList.prev() ) { 131 if ( playList.prev() ) {
130 play(); 132 play();
131 } else if ( mediaPlayerState.isLooping() ) { 133 } else if ( mediaPlayerState.isLooping() ) {
132 if ( playList.last() ) { 134 if ( playList.last() ) {
133 play(); 135 play();
134 } 136 }
135 } else { 137 } else {
136 mediaPlayerState.setList(); 138 mediaPlayerState.setList();
137 } 139 }
138 } 140 }
139} 141}
140 142
141 143
142void MediaPlayer::next() { 144void MediaPlayer::next() {
143 145
144 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 146 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
145 if ( playList.next() ) { 147 if ( playList.next() ) {
146 play(); 148 play();
147 } else if ( mediaPlayerState.isLooping() ) { 149 } else if ( mediaPlayerState.isLooping() ) {
148 if ( playList.first() ) { 150 if ( playList.first() ) {
149 play(); 151 play();
150 } 152 }
151 } else { 153 } else {
152 mediaPlayerState.setList(); 154 mediaPlayerState.setList();
153 } 155 }
154 } else { //if playing from file list, let's just stop 156 } else { //if playing from file list, let's just stop
155 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; 157 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl;
156 mediaPlayerState.setPlaying(false); 158 mediaPlayerState.setPlaying(false);
157 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 159 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
158 if(l) mediaPlayerState.setLooping(l); 160 if(l) mediaPlayerState.setLooping(l);
159 if(r) mediaPlayerState.setShuffled(r); 161 if(r) mediaPlayerState.setShuffled(r);
160 } 162 }
161 qApp->processEvents(); 163 qApp->processEvents();
162} 164}
163 165
164 166
165void MediaPlayer::startDecreasingVolume() { 167void MediaPlayer::startDecreasingVolume() {
166 volumeDirection = -1; 168 volumeDirection = -1;
167 startTimer( 100 ); 169 startTimer( 100 );
168 volControl->decVol(2); 170 volControl->decVol(2);
169} 171}
170 172
171 173
172void MediaPlayer::startIncreasingVolume() { 174void MediaPlayer::startIncreasingVolume() {
173 volumeDirection = +1; 175 volumeDirection = +1;
174 startTimer( 100 ); 176 startTimer( 100 );
175 volControl->incVol(2); 177 volControl->incVol(2);
176} 178}
177 179
178 180
179bool drawnOnScreenDisplay = FALSE; 181bool drawnOnScreenDisplay = FALSE;
180unsigned int onScreenDisplayVolume = 0; 182unsigned int onScreenDisplayVolume = 0;
181const int yoff = 110; 183const int yoff = 110;
182 184
183void MediaPlayer::stopChangingVolume() { 185void MediaPlayer::stopChangingVolume() {
184 killTimers(); 186 killTimers();
185 // Get rid of the on-screen display stuff 187 // Get rid of the on-screen display stuff
186 drawnOnScreenDisplay = FALSE; 188 drawnOnScreenDisplay = FALSE;
187 onScreenDisplayVolume = 0; 189 onScreenDisplayVolume = 0;
188 int w=0; 190 int w=0;
189 int h=0; 191 int h=0;
190 if( !xineControl()->hasVideo() ) { 192 if( !xineControl()->hasVideo() ) {
191 w = audioUI()->width(); 193 w = audioUI()->width();
192 h = audioUI()->height(); 194 h = audioUI()->height();
193 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 195 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
194 } else { 196 } else {
195 w = videoUI()->width(); 197 w = videoUI()->width();
196 h = videoUI()->height(); 198 h = videoUI()->height();
197 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 199 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
198 } 200 }
199} 201}
200 202
201 203
202void MediaPlayer::timerEvent( QTimerEvent * ) { 204void MediaPlayer::timerEvent( QTimerEvent * ) {
203 if ( volumeDirection == +1 ) { 205 if ( volumeDirection == +1 ) {
204 volControl->incVol( 2 ); 206 volControl->incVol( 2 );
205 } else if ( volumeDirection == -1 ) { 207 } else if ( volumeDirection == -1 ) {
206 volControl->decVol( 2 ); 208 volControl->decVol( 2 );
207 } 209 }
208 210
209 211
210 // TODO FIXME 212 // TODO FIXME
211 // huh?? 213 // huh??
212 unsigned int v= 0; 214 unsigned int v= 0;
213 v = volControl->volume(); 215 v = volControl->volume();
214 v = v / 10; 216 v = v / 10;
215 217
216 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 218 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
217 return; 219 return;
218 } 220 }
219 221
220 int w=0; int h=0; 222 int w=0; int h=0;
221 if( !xineControl()->hasVideo() ) { 223 if( !xineControl()->hasVideo() ) {
222 w = audioUI()->width(); 224 w = audioUI()->width();
223 h = audioUI()->height(); 225 h = audioUI()->height();
224 226
225 if ( drawnOnScreenDisplay ) { 227 if ( drawnOnScreenDisplay ) {
226 if ( onScreenDisplayVolume > v ) { 228 if ( onScreenDisplayVolume > v ) {
227 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 229 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
228 } 230 }
229 } 231 }
230 drawnOnScreenDisplay = TRUE; 232 drawnOnScreenDisplay = TRUE;
231 onScreenDisplayVolume = v; 233 onScreenDisplayVolume = v;
232 QPainter p( audioUI() ); 234 QPainter p( audioUI() );
233 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 235 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
234 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 236 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
235 237
236 QFont f; 238 QFont f;
237 f.setPixelSize( 20 ); 239 f.setPixelSize( 20 );
238 f.setBold( TRUE ); 240 f.setBold( TRUE );
239 p.setFont( f ); 241 p.setFont( f );
240 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 242 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
241 243
242 for ( unsigned int i = 0; i < 10; i++ ) { 244 for ( unsigned int i = 0; i < 10; i++ ) {
243 if ( v > i ) { 245 if ( v > i ) {
244 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 246 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
245 } else { 247 } else {
246 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 248 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
247 } 249 }
248 } 250 }
249 } else { 251 } else {
250 w = videoUI()->width(); 252 w = videoUI()->width();
251 h = videoUI()->height(); 253 h = videoUI()->height();
252 254
253 if ( drawnOnScreenDisplay ) { 255 if ( drawnOnScreenDisplay ) {
254 if ( onScreenDisplayVolume > v ) { 256 if ( onScreenDisplayVolume > v ) {
255 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 257 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
256 } 258 }
257 } 259 }
258 drawnOnScreenDisplay = TRUE; 260 drawnOnScreenDisplay = TRUE;
259 onScreenDisplayVolume = v; 261 onScreenDisplayVolume = v;
260 QPainter p( videoUI() ); 262 QPainter p( videoUI() );
261 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 263 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
262 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 264 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
263 265
264 QFont f; 266 QFont f;
265 f.setPixelSize( 20 ); 267 f.setPixelSize( 20 );
266 f.setBold( TRUE ); 268 f.setBold( TRUE );
267 p.setFont( f ); 269 p.setFont( f );
268 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 270 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
269 271
270 for ( unsigned int i = 0; i < 10; i++ ) { 272 for ( unsigned int i = 0; i < 10; i++ ) {
271 if ( v > i ) { 273 if ( v > i ) {
272 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 274 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
273 } else { 275 } else {
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 95dbab5..790fa09 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -1,150 +1,152 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public 10:`=1 )Y*s>-.--   : the terms of the GNU General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more 20..}^=.=       =       ; General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with 24  -_. . .   )=.  = General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "om3u.h" 32#include "om3u.h"
33 33
34 34/* OPIE */
35#include <opie2/odebug.h>
36using namespace Opie::Core;
35 37
36//extern PlayListWidget *playList; 38//extern PlayListWidget *playList;
37 39
38Om3u::Om3u( const QString &filePath, int mode) 40Om3u::Om3u( const QString &filePath, int mode)
39 : QStringList (){ 41 : QStringList (){
40odebug << "<<<<<<<new m3u "+filePath << oendl; 42odebug << "<<<<<<<new m3u "+filePath << oendl;
41 f.setName(filePath); 43 f.setName(filePath);
42 f.open(mode); 44 f.open(mode);
43} 45}
44 46
45Om3u::~Om3u(){} 47Om3u::~Om3u(){}
46 48
47void Om3u::readM3u() { 49void Om3u::readM3u() {
48// odebug << "<<<<<<reading m3u "+f.name() << oendl; 50// odebug << "<<<<<<reading m3u "+f.name() << oendl;
49 QTextStream t(&f); 51 QTextStream t(&f);
50 t.setEncoding(QTextStream::UnicodeUTF8); 52 t.setEncoding(QTextStream::UnicodeUTF8);
51 QString s; 53 QString s;
52 while ( !t.atEnd() ) { 54 while ( !t.atEnd() ) {
53 s=t.readLine(); 55 s=t.readLine();
54// odebug << s << oendl; 56// odebug << s << oendl;
55 if( s.find( "#", 0, TRUE) == -1 ) { 57 if( s.find( "#", 0, TRUE) == -1 ) {
56 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 58 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
57 s = s.right( s.length() -2 ); 59 s = s.right( s.length() -2 );
58 QFileInfo f( s ); 60 QFileInfo f( s );
59 QString name = f.baseName(); 61 QString name = f.baseName();
60 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 62 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
61 s=s.replace( QRegExp( "\\" ), "/" ); 63 s=s.replace( QRegExp( "\\" ), "/" );
62 append(s); 64 append(s);
63// odebug << s << oendl; 65// odebug << s << oendl;
64 } else { // is url 66 } else { // is url
65 QString name; 67 QString name;
66 name = s; 68 name = s;
67 append(name); 69 append(name);
68 } 70 }
69 } 71 }
70 } 72 }
71} 73}
72 74
73void Om3u::readPls() { //it's a pls file 75void Om3u::readPls() { //it's a pls file
74 QTextStream t( &f ); 76 QTextStream t( &f );
75 t.setEncoding(QTextStream::UnicodeUTF8); 77 t.setEncoding(QTextStream::UnicodeUTF8);
76 QString s; 78 QString s;
77 while ( !t.atEnd() ) { 79 while ( !t.atEnd() ) {
78 s = t.readLine(); 80 s = t.readLine();
79 if( s.left(4) == "File" ) { 81 if( s.left(4) == "File" ) {
80 s = s.right( s.length() - s.find("=",0,true)-1 ); 82 s = s.right( s.length() - s.find("=",0,true)-1 );
81 s = s.stripWhiteSpace(); 83 s = s.stripWhiteSpace();
82 s.replace( QRegExp( "%20" )," "); 84 s.replace( QRegExp( "%20" )," ");
83// odebug << "adding " + s + " to playlist" << oendl; 85// odebug << "adding " + s + " to playlist" << oendl;
84 // numberofentries=2 86 // numberofentries=2
85 // File1=http 87 // File1=http
86 // Title 88 // Title
87 // Length 89 // Length
88 // Version 90 // Version
89 // File2=http 91 // File2=http
90 s = s.replace( QRegExp( "\\" ), "/" ); 92 s = s.replace( QRegExp( "\\" ), "/" );
91 QFileInfo f( s ); 93 QFileInfo f( s );
92 QString name = f.baseName(); 94 QString name = f.baseName();
93 if( name.left( 4 ) == "http" ) { 95 if( name.left( 4 ) == "http" ) {
94 name = s.right( s.length() - 7); 96 name = s.right( s.length() - 7);
95 } else { 97 } else {
96 name = s; 98 name = s;
97 } 99 }
98 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 100 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
99 if( s.at( s.length() - 4) == '.') // if this is probably a file 101 if( s.at( s.length() - 4) == '.') // if this is probably a file
100 append(s); 102 append(s);
101 else { //if its a url 103 else { //if its a url
102// if( name.right( 1 ).find( '/' ) == -1) { 104// if( name.right( 1 ).find( '/' ) == -1) {
103// s += "/"; 105// s += "/";
104// } 106// }
105 append(s); 107 append(s);
106 } 108 }
107 } 109 }
108 } 110 }
109} 111}
110 112
111void Om3u::write() { //writes list to m3u file 113void Om3u::write() { //writes list to m3u file
112 QString list; 114 QString list;
113 QTextStream t(&f); 115 QTextStream t(&f);
114 t.setEncoding(QTextStream::UnicodeUTF8); 116 t.setEncoding(QTextStream::UnicodeUTF8);
115 if(count()>0) { 117 if(count()>0) {
116 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 118 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
117// odebug << *it << oendl; 119// odebug << *it << oendl;
118 t << *it << "\n"; 120 t << *it << "\n";
119 } 121 }
120 } 122 }
121// f.close(); 123// f.close();
122} 124}
123 125
124void Om3u::add(const QString &filePath) { //adds to m3u file 126void Om3u::add(const QString &filePath) { //adds to m3u file
125 append(filePath); 127 append(filePath);
126} 128}
127 129
128void Om3u::remove(const QString &filePath) { //removes from m3u list 130void Om3u::remove(const QString &filePath) { //removes from m3u list
129 QString list, currentFile; 131 QString list, currentFile;
130 if(count()>0) { 132 if(count()>0) {
131 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 133 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
132 currentFile=*it; 134 currentFile=*it;
133 // odebug << *it << oendl; 135 // odebug << *it << oendl;
134 136
135 if( filePath != currentFile) 137 if( filePath != currentFile)
136 list += currentFile+"\n"; 138 list += currentFile+"\n";
137 } 139 }
138 f.writeBlock( list, list.length() ); 140 f.writeBlock( list, list.length() );
139 } 141 }
140} 142}
141 143
142void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file 144void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file
143 f.close(); 145 f.close();
144 f.remove(); 146 f.remove();
145 147
146} 148}
147 149
148void Om3u::close() { //closes m3u file 150void Om3u::close() { //closes m3u file
149 f.close(); 151 f.close();
150} 152}
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp
index 3499837..678ebdf 100644
--- a/noncore/multimedia/opieplayer2/playlistselection.cpp
+++ b/noncore/multimedia/opieplayer2/playlistselection.cpp
@@ -1,206 +1,211 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "playlistselection.h"
20 21
21#include <qheader.h> 22/* OPIE */
23#include <opie2/odebug.h>
24using namespace Opie::Core;
22 25
23#include "playlistselection.h" 26/* QT */
27#include <qheader.h>
24 28
29/* STD */
25#include <stdlib.h> 30#include <stdlib.h>
26 31
27class PlayListSelectionItem : public QListViewItem { 32class PlayListSelectionItem : public QListViewItem {
28public: 33public:
29 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { 34 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) {
30 setText( 0, f->name() ); 35 setText( 0, f->name() );
31 setPixmap( 0, f->pixmap() ); 36 setPixmap( 0, f->pixmap() );
32 } 37 }
33 38
34 ~PlayListSelectionItem() { 39 ~PlayListSelectionItem() {
35 }; 40 };
36 41
37 const DocLnk *file() const { return fl; } 42 const DocLnk *file() const { return fl; }
38 43
39private: 44private:
40 const DocLnk *fl; 45 const DocLnk *fl;
41}; 46};
42 47
43 48
44PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 49PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
45 : QListView( parent, name ) 50 : QListView( parent, name )
46{ 51{
47// odebug << "starting playlistselector" << oendl; 52// odebug << "starting playlistselector" << oendl;
48// #ifdef USE_PLAYLIST_BACKGROUND 53// #ifdef USE_PLAYLIST_BACKGROUND
49// setStaticBackground( TRUE ); 54// setStaticBackground( TRUE );
50// setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); 55// setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) );
51 56
52// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); 57// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) );
53// #endif 58// #endif
54// addColumn("Title",236); 59// addColumn("Title",236);
55// setAllColumnsShowFocus( TRUE ); 60// setAllColumnsShowFocus( TRUE );
56 addColumn( tr( "Playlist Selection" ) ); 61 addColumn( tr( "Playlist Selection" ) );
57 header()->hide(); 62 header()->hide();
58 setSorting( -1, FALSE ); 63 setSorting( -1, FALSE );
59} 64}
60 65
61 66
62PlayListSelection::~PlayListSelection() { 67PlayListSelection::~PlayListSelection() {
63} 68}
64 69
65 70
66// #ifdef USE_PLAYLIST_BACKGROUND 71// #ifdef USE_PLAYLIST_BACKGROUND
67void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 72void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) {
68// odebug << "drawBackground" << oendl; 73// odebug << "drawBackground" << oendl;
69 p->fillRect( r, QBrush( white ) ); 74 p->fillRect( r, QBrush( white ) );
70// QImage logo = Resource::loadImage( "launcher/opielogo" ); 75// QImage logo = Resource::loadImage( "launcher/opielogo" );
71// if ( !logo.isNull() ) 76// if ( !logo.isNull() )
72// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); 77// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
73} 78}
74// #endif 79// #endif
75 80
76 81
77void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 82void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
78 if ( event->state() == QMouseEvent::LeftButton ) { 83 if ( event->state() == QMouseEvent::LeftButton ) {
79 QListViewItem *currentItem = selectedItem(); 84 QListViewItem *currentItem = selectedItem();
80 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 85 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
81 if ( currentItem && currentItem->itemAbove() == itemUnder ) 86 if ( currentItem && currentItem->itemAbove() == itemUnder )
82 moveSelectedUp(); 87 moveSelectedUp();
83 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 88 else if ( currentItem && currentItem->itemBelow() == itemUnder )
84 moveSelectedDown(); 89 moveSelectedDown();
85 } 90 }
86} 91}
87 92
88 93
89const DocLnk *PlayListSelection::current() { 94const DocLnk *PlayListSelection::current() {
90 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 95 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
91 if ( item ) 96 if ( item )
92 return item->file(); 97 return item->file();
93 return NULL; 98 return NULL;
94} 99}
95 100
96 101
97void PlayListSelection::addToSelection( const DocLnk &lnk ) { 102void PlayListSelection::addToSelection( const DocLnk &lnk ) {
98 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); 103 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) );
99 QListViewItem *current = selectedItem(); 104 QListViewItem *current = selectedItem();
100 if ( current ) 105 if ( current )
101 item->moveItem( current ); 106 item->moveItem( current );
102 setSelected( item, TRUE ); 107 setSelected( item, TRUE );
103 ensureItemVisible( selectedItem() ); 108 ensureItemVisible( selectedItem() );
104} 109}
105 110
106 111
107void PlayListSelection::removeSelected() { 112void PlayListSelection::removeSelected() {
108 QListViewItem *item = selectedItem(); 113 QListViewItem *item = selectedItem();
109 delete item; 114 delete item;
110 setSelected( currentItem(), TRUE ); 115 setSelected( currentItem(), TRUE );
111 ensureItemVisible( selectedItem() ); 116 ensureItemVisible( selectedItem() );
112} 117}
113 118
114 119
115void PlayListSelection::moveSelectedUp() { 120void PlayListSelection::moveSelectedUp() {
116 QListViewItem *item = selectedItem(); 121 QListViewItem *item = selectedItem();
117 if ( item && item->itemAbove() ) 122 if ( item && item->itemAbove() )
118 item->itemAbove()->moveItem( item ); 123 item->itemAbove()->moveItem( item );
119 ensureItemVisible( selectedItem() ); 124 ensureItemVisible( selectedItem() );
120} 125}
121 126
122 127
123void PlayListSelection::moveSelectedDown() { 128void PlayListSelection::moveSelectedDown() {
124 QListViewItem *item = selectedItem(); 129 QListViewItem *item = selectedItem();
125 if ( item && item->itemBelow() ) 130 if ( item && item->itemBelow() )
126 item->moveItem( item->itemBelow() ); 131 item->moveItem( item->itemBelow() );
127 ensureItemVisible( selectedItem() ); 132 ensureItemVisible( selectedItem() );
128} 133}
129 134
130 135
131bool PlayListSelection::prev() { 136bool PlayListSelection::prev() {
132 QListViewItem *item = selectedItem(); 137 QListViewItem *item = selectedItem();
133 if ( item && item->itemAbove() ) 138 if ( item && item->itemAbove() )
134 setSelected( item->itemAbove(), TRUE ); 139 setSelected( item->itemAbove(), TRUE );
135 else 140 else
136 return FALSE; 141 return FALSE;
137 ensureItemVisible( selectedItem() ); 142 ensureItemVisible( selectedItem() );
138 return TRUE; 143 return TRUE;
139} 144}
140 145
141bool PlayListSelection::next() { 146bool PlayListSelection::next() {
142 QListViewItem *item = selectedItem(); 147 QListViewItem *item = selectedItem();
143 if ( item && item->itemBelow() ) 148 if ( item && item->itemBelow() )
144 setSelected( item->itemBelow(), TRUE ); 149 setSelected( item->itemBelow(), TRUE );
145 else 150 else
146 return FALSE; 151 return FALSE;
147 ensureItemVisible( selectedItem() ); 152 ensureItemVisible( selectedItem() );
148 return TRUE; 153 return TRUE;
149} 154}
150 155
151 156
152bool PlayListSelection::first() { 157bool PlayListSelection::first() {
153 QListViewItem *item = firstChild(); 158 QListViewItem *item = firstChild();
154 if ( item ) 159 if ( item )
155 setSelected( item, TRUE ); 160 setSelected( item, TRUE );
156 else 161 else
157 return FALSE; 162 return FALSE;
158 ensureItemVisible( selectedItem() ); 163 ensureItemVisible( selectedItem() );
159 return TRUE; 164 return TRUE;
160} 165}
161 166
162 167
163bool PlayListSelection::last() { 168bool PlayListSelection::last() {
164 QListViewItem *prevItem = NULL; 169 QListViewItem *prevItem = NULL;
165 QListViewItem *item = firstChild(); 170 QListViewItem *item = firstChild();
166 while ( ( item = item->nextSibling() ) ) 171 while ( ( item = item->nextSibling() ) )
167 prevItem = item; 172 prevItem = item;
168 if ( prevItem ) 173 if ( prevItem )
169 setSelected( prevItem, TRUE ); 174 setSelected( prevItem, TRUE );
170 else 175 else
171 return FALSE; 176 return FALSE;
172 ensureItemVisible( selectedItem() ); 177 ensureItemVisible( selectedItem() );
173 return TRUE; 178 return TRUE;
174} 179}
175 180
176void PlayListSelection::unSelect() 181void PlayListSelection::unSelect()
177{ 182{
178 //QListViewItem *item = selectedItem(); 183 //QListViewItem *item = selectedItem();
179 setSelected( currentItem(), FALSE); 184 setSelected( currentItem(), FALSE);
180} 185}
181 186
182void PlayListSelection::writeCurrent( Config& cfg ) { 187void PlayListSelection::writeCurrent( Config& cfg ) {
183 cfg.setGroup("PlayList"); 188 cfg.setGroup("PlayList");
184 QListViewItem *item = selectedItem(); 189 QListViewItem *item = selectedItem();
185 if ( item ) 190 if ( item )
186 cfg.writeEntry("current", item->text(0) ); 191 cfg.writeEntry("current", item->text(0) );
187 odebug << item->text(0) << oendl; 192 odebug << item->text(0) << oendl;
188 193
189} 194}
190 195
191void PlayListSelection::setSelectedItem(const QString &strk ) { 196void PlayListSelection::setSelectedItem(const QString &strk ) {
192 197
193 unSelect(); 198 unSelect();
194 QListViewItemIterator it( this ); 199 QListViewItemIterator it( this );
195 for ( ; it.current(); ++it ) { 200 for ( ; it.current(); ++it ) {
196// odebug << it.current()->text(0) << oendl; 201// odebug << it.current()->text(0) << oendl;
197 if( strk == it.current()->text(0)) { 202 if( strk == it.current()->text(0)) {
198// odebug << "We have a match "+strk << oendl; 203// odebug << "We have a match "+strk << oendl;
199 setSelected( it.current(), TRUE); 204 setSelected( it.current(), TRUE);
200 ensureItemVisible( it.current() ); 205 ensureItemVisible( it.current() );
201 return; 206 return;
202 } 207 }
203 } 208 }
204// setSelected( item, TRUE ); 209// setSelected( item, TRUE );
205// ensureItemVisible( selectedItem() ); 210// ensureItemVisible( selectedItem() );
206} 211}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 956d206..6a15134 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,306 +1,309 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qtoolbar.h>
35
36#include <opie2/ofiledialog.h>
37
38#include <qmessagebox.h>
39
40#include "playlistselection.h" 34#include "playlistselection.h"
41#include "playlistwidget.h" 35#include "playlistwidget.h"
42#include "mediaplayer.h" 36#include "mediaplayer.h"
43#include "inputDialog.h" 37#include "inputDialog.h"
44#include "om3u.h" 38#include "om3u.h"
45#include "playlistfileview.h" 39#include "playlistfileview.h"
46 40
47//only needed for the random play 41/* OPIE */
42#include <opie2/odebug.h>
43#include <opie2/ofiledialog.h>
44using namespace Opie::Core;
45using namespace Opie::Ui;
46
47/* QT */
48#include <qmessagebox.h>
49#include <qtoolbar.h>
50
51/* STD */
48#include <assert.h> 52#include <assert.h>
49 53
50using namespace Opie::Ui;
51PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) 54PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
52 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) 55 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 )
53{ 56{
54 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); 57 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" );
55 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); 58 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer");
56 59
57 60
58 61
59 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 62 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
60 "opieplayer2/add_to_playlist", 63 "opieplayer2/add_to_playlist",
61 this , SLOT(addSelected() ) ); 64 this , SLOT(addSelected() ) );
62 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
63 "opieplayer2/remove_from_playlist", 66 "opieplayer2/remove_from_playlist",
64 this , SLOT(removeSelected() ) ); 67 this , SLOT(removeSelected() ) );
65 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 68 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
66 this , SLOT( btnPlay(bool) ), TRUE ); 69 this , SLOT( btnPlay(bool) ), TRUE );
67 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 70 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
68 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); 71 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE );
69 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 72 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
70 mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); 73 mediaPlayerState, SLOT( setLooping(bool) ), TRUE );
71 74
72 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 75 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
73 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 76 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
74 this, SLOT( addAllMusicToList() ) ); 77 this, SLOT( addAllMusicToList() ) );
75 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 78 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
76 this, SLOT( addAllVideoToList() ) ); 79 this, SLOT( addAllVideoToList() ) );
77 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 80 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
78 this, SLOT( addAllToList() ) ); 81 this, SLOT( addAllToList() ) );
79 pmPlayList->insertSeparator(-1); 82 pmPlayList->insertSeparator(-1);
80 (void)new MenuItem( pmPlayList, tr( "Add File" ), 83 (void)new MenuItem( pmPlayList, tr( "Add File" ),
81 this,SLOT( openFile() ) ); 84 this,SLOT( openFile() ) );
82 (void)new MenuItem( pmPlayList, tr("Add URL"), 85 (void)new MenuItem( pmPlayList, tr("Add URL"),
83 this,SLOT( openURL() ) ); 86 this,SLOT( openURL() ) );
84 pmPlayList->insertSeparator(-1); 87 pmPlayList->insertSeparator(-1);
85 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 88 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
86 this, SLOT(writem3u() ) ); 89 this, SLOT(writem3u() ) );
87 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
88 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 91 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
89 audioView, SLOT( scanFiles() ) ); 92 audioView, SLOT( scanFiles() ) );
90 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 93 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
91 videoView, SLOT( scanFiles() ) ); 94 videoView, SLOT( scanFiles() ) );
92 95
93 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 96 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
94 mediaPlayerState, SLOT( toggleFullscreen() ) ); 97 mediaPlayerState, SLOT( toggleFullscreen() ) );
95 98
96 Config cfg( "OpiePlayer" ); 99 Config cfg( "OpiePlayer" );
97 bool b= cfg.readBoolEntry("FullScreen", 0); 100 bool b= cfg.readBoolEntry("FullScreen", 0);
98 mediaPlayerState->setFullscreen( b ); 101 mediaPlayerState->setFullscreen( b );
99 pmView->setItemChecked( -16, b ); 102 pmView->setItemChecked( -16, b );
100 103
101 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 104 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
102 d->selectedFiles, SLOT(moveSelectedUp() ) ); 105 d->selectedFiles, SLOT(moveSelectedUp() ) );
103 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 106 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
104 d->selectedFiles, SLOT(removeSelected() ) ); 107 d->selectedFiles, SLOT(removeSelected() ) );
105 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 108 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
106 d->selectedFiles, SLOT(moveSelectedDown() ) ); 109 d->selectedFiles, SLOT(moveSelectedDown() ) );
107 QVBox *stretch2 = new QVBox( vbox1 ); 110 QVBox *stretch2 = new QVBox( vbox1 );
108 111
109 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 112 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
110 SLOT( deletePlaylist() ) ); 113 SLOT( deletePlaylist() ) );
111 connect( pmView, SIGNAL( activated(int) ), 114 connect( pmView, SIGNAL( activated(int) ),
112 this, SLOT( pmViewActivated(int) ) ); 115 this, SLOT( pmViewActivated(int) ) );
113 connect( skinsMenu, SIGNAL( activated(int) ) , 116 connect( skinsMenu, SIGNAL( activated(int) ) ,
114 this, SLOT( skinsMenuActivated(int) ) ); 117 this, SLOT( skinsMenuActivated(int) ) );
115 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 118 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
116 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); 119 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) );
117 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 120 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
118 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 121 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
119 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), 122 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ),
120 this,SLOT( playIt(QListViewItem*) ) ); 123 this,SLOT( playIt(QListViewItem*) ) );
121 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), 124 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ),
122 this, SLOT( addToSelection(QListViewItem*) ) ); 125 this, SLOT( addToSelection(QListViewItem*) ) );
123 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 126 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
124 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 127 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
125 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), 128 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ),
126 this,SLOT( playIt(QListViewItem*) ) ); 129 this,SLOT( playIt(QListViewItem*) ) );
127 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), 130 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ),
128 this, SLOT( addToSelection(QListViewItem*) ) ); 131 this, SLOT( addToSelection(QListViewItem*) ) );
129 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), 132 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ),
130 this, SLOT( loadList(const DocLnk&) ) ); 133 this, SLOT( loadList(const DocLnk&) ) );
131 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 134 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
132 this, SLOT( tabChanged(QWidget*) ) ); 135 this, SLOT( tabChanged(QWidget*) ) );
133 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), 136 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ),
134 d->tbPlay, SLOT( setOn(bool) ) ); 137 d->tbPlay, SLOT( setOn(bool) ) );
135 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), 138 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ),
136 d->tbLoop, SLOT( setOn(bool) ) ); 139 d->tbLoop, SLOT( setOn(bool) ) );
137 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), 140 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ),
138 d->tbShuffle, SLOT( setOn(bool) ) ); 141 d->tbShuffle, SLOT( setOn(bool) ) );
139 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), 142 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ),
140 this, SLOT( playIt(QListViewItem*) ) ); 143 this, SLOT( playIt(QListViewItem*) ) );
141 connect ( gammaSlider, SIGNAL( valueChanged(int) ), 144 connect ( gammaSlider, SIGNAL( valueChanged(int) ),
142 mediaPlayerState, SLOT( setVideoGamma(int) ) ); 145 mediaPlayerState, SLOT( setVideoGamma(int) ) );
143 146
144 connect( this, SIGNAL(skinSelected() ), 147 connect( this, SIGNAL(skinSelected() ),
145 m_mp, SLOT( reloadSkins() ) ); 148 m_mp, SLOT( reloadSkins() ) );
146 149
147 // see which skins are installed 150 // see which skins are installed
148 populateSkinsMenu(); 151 populateSkinsMenu();
149 initializeStates(); 152 initializeStates();
150 153
151 channel = new QCopChannel( "QPE/Application/opieplayer2", this ); 154 channel = new QCopChannel( "QPE/Application/opieplayer2", this );
152 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 155 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
153 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 156 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
154 157
155 158
156 cfg.setGroup("PlayList"); 159 cfg.setGroup("PlayList");
157 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
158 loadList(DocLnk( currentPlaylist ) ); 161 loadList(DocLnk( currentPlaylist ) );
159 162
160 tabWidget->showPage( playListTab ); 163 tabWidget->showPage( playListTab );
161} 164}
162 165
163 166
164PlayListWidget::~PlayListWidget() { 167PlayListWidget::~PlayListWidget() {
165 delete d; 168 delete d;
166 delete m_mp; 169 delete m_mp;
167} 170}
168 171
169 172
170void PlayListWidget::initializeStates() { 173void PlayListWidget::initializeStates() {
171 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 174 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
172 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 175 d->tbLoop->setOn( mediaPlayerState->isLooping() );
173 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 176 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
174 d->playListFrame->show(); 177 d->playListFrame->show();
175} 178}
176 179
177void PlayListWidget::writeDefaultPlaylist() { 180void PlayListWidget::writeDefaultPlaylist() {
178 181
179 Config config( "OpiePlayer" ); 182 Config config( "OpiePlayer" );
180 config.setGroup( "PlayList" ); 183 config.setGroup( "PlayList" );
181 QString filename=QPEApplication::documentDir() + "/default.m3u"; 184 QString filename=QPEApplication::documentDir() + "/default.m3u";
182 QString currentString = config.readEntry( "CurrentPlaylist", filename); 185 QString currentString = config.readEntry( "CurrentPlaylist", filename);
183 if( currentString == filename) { 186 if( currentString == filename) {
184 Om3u *m3uList; 187 Om3u *m3uList;
185 // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl; 188 // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl;
186 if( d->selectedFiles->first() ) { 189 if( d->selectedFiles->first() ) {
187 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 190 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
188 do { 191 do {
189 // odebug << d->selectedFiles->current()->file() << oendl; 192 // odebug << d->selectedFiles->current()->file() << oendl;
190 m3uList->add( d->selectedFiles->current()->file() ); 193 m3uList->add( d->selectedFiles->current()->file() );
191 } 194 }
192 while ( d->selectedFiles->next() ); 195 while ( d->selectedFiles->next() );
193 196
194 m3uList->write(); 197 m3uList->write();
195 m3uList->close(); 198 m3uList->close();
196 delete m3uList; 199 delete m3uList;
197 200
198 } 201 }
199 } 202 }
200} 203}
201 204
202void PlayListWidget::addToSelection( const DocLnk& lnk ) { 205void PlayListWidget::addToSelection( const DocLnk& lnk ) {
203 d->setDocumentUsed = FALSE; 206 d->setDocumentUsed = FALSE;
204 if( QFileInfo( lnk.file() ).exists() || 207 if( QFileInfo( lnk.file() ).exists() ||
205 lnk.file().left(4) == "http" ) { 208 lnk.file().left(4) == "http" ) {
206 d->selectedFiles->addToSelection( lnk ); 209 d->selectedFiles->addToSelection( lnk );
207 } 210 }
208// writeCurrentM3u(); 211// writeCurrentM3u();
209} 212}
210 213
211 214
212void PlayListWidget::clearList() { 215void PlayListWidget::clearList() {
213 while ( first() ) { 216 while ( first() ) {
214 d->selectedFiles->removeSelected(); 217 d->selectedFiles->removeSelected();
215 } 218 }
216 Config cfg( "OpiePlayer" ); 219 Config cfg( "OpiePlayer" );
217 cfg.setGroup("PlayList"); 220 cfg.setGroup("PlayList");
218 cfg.writeEntry("CurrentPlaylist","default"); 221 cfg.writeEntry("CurrentPlaylist","default");
219 setCaption("OpiePlayer"); 222 setCaption("OpiePlayer");
220} 223}
221 224
222void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
223 switch (mouse) { 226 switch (mouse) {
224 case LeftButton: 227 case LeftButton:
225 break; 228 break;
226 case RightButton: 229 case RightButton:
227 { 230 {
228 QPopupMenu m; 231 QPopupMenu m;
229 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 232 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
230 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 233 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
231 m.exec( QCursor::pos() ); 234 m.exec( QCursor::pos() );
232 } 235 }
233 break; 236 break;
234 } 237 }
235} 238}
236 239
237 240
238void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 241void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
239 switch (mouse) { 242 switch (mouse) {
240 case LeftButton: 243 case LeftButton:
241 break; 244 break;
242 case RightButton: 245 case RightButton:
243 { 246 {
244 QPopupMenu m; 247 QPopupMenu m;
245 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 248 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
246 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 249 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
247 m.exec( QCursor::pos() ); 250 m.exec( QCursor::pos() );
248 } 251 }
249 break; 252 break;
250 } 253 }
251} 254}
252 255
253 256
254void PlayListWidget::addAllToList() { 257void PlayListWidget::addAllToList() {
255 258
256 259
257 audioView->populateView(); 260 audioView->populateView();
258 261
259 QListViewItemIterator audioIt( audioView ); 262 QListViewItemIterator audioIt( audioView );
260 DocLnk lnk; 263 DocLnk lnk;
261 QString filename; 264 QString filename;
262 // iterate through all items of the listview 265 // iterate through all items of the listview
263 for ( ; audioIt.current(); ++audioIt ) { 266 for ( ; audioIt.current(); ++audioIt ) {
264 filename = audioIt.current()->text(3); 267 filename = audioIt.current()->text(3);
265 lnk.setName( QFileInfo(filename).baseName() ); //sets name 268 lnk.setName( QFileInfo(filename).baseName() ); //sets name
266 lnk.setFile( filename ); //sets file name 269 lnk.setFile( filename ); //sets file name
267 d->selectedFiles->addToSelection( lnk); 270 d->selectedFiles->addToSelection( lnk);
268 } 271 }
269 272
270 videoView->populateView(); 273 videoView->populateView();
271 274
272 QListViewItemIterator videoIt( videoView ); 275 QListViewItemIterator videoIt( videoView );
273 for ( ; videoIt.current(); ++videoIt ) { 276 for ( ; videoIt.current(); ++videoIt ) {
274 filename = videoIt.current()->text(3); 277 filename = videoIt.current()->text(3);
275 lnk.setName( QFileInfo(filename).baseName() ); //sets name 278 lnk.setName( QFileInfo(filename).baseName() ); //sets name
276 lnk.setFile( filename ); //sets file name 279 lnk.setFile( filename ); //sets file name
277 d->selectedFiles->addToSelection( lnk); 280 d->selectedFiles->addToSelection( lnk);
278 } 281 }
279 282
280 tabWidget->setCurrentPage(0); 283 tabWidget->setCurrentPage(0);
281 284
282 writeCurrentM3u(); 285 writeCurrentM3u();
283 d->selectedFiles->first(); 286 d->selectedFiles->first();
284} 287}
285 288
286 289
287void PlayListWidget::addAllMusicToList() { 290void PlayListWidget::addAllMusicToList() {
288 291
289 audioView->populateView(); 292 audioView->populateView();
290 293
291 QListViewItemIterator audioIt( audioView ); 294 QListViewItemIterator audioIt( audioView );
292 DocLnk lnk; 295 DocLnk lnk;
293 QString filename; 296 QString filename;
294 // iterate through all items of the listview 297 // iterate through all items of the listview
295 for ( ; audioIt.current(); ++audioIt ) { 298 for ( ; audioIt.current(); ++audioIt ) {
296 filename = audioIt.current()->text(3); 299 filename = audioIt.current()->text(3);
297 lnk.setName( QFileInfo(filename).baseName() ); //sets name 300 lnk.setName( QFileInfo(filename).baseName() ); //sets name
298 lnk.setFile( filename ); //sets file name 301 lnk.setFile( filename ); //sets file name
299 d->selectedFiles->addToSelection( lnk); 302 d->selectedFiles->addToSelection( lnk);
300 } 303 }
301 304
302 tabWidget->setCurrentPage(0); 305 tabWidget->setCurrentPage(0);
303 writeCurrentM3u(); 306 writeCurrentM3u();
304 d->selectedFiles->first(); 307 d->selectedFiles->first();
305} 308}
306 309
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 94f99f8..9f944d7 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,271 +1,275 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "xinecontrol.h"
35#include "xinevideowidget.h"
34 36
35#include <qtimer.h> 37/* OPIE */
36#include <qmessagebox.h> 38#include <opie2/odebug.h>
37#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
41using namespace Opie::Core;
39 42
40#include "xinecontrol.h" 43/* QT */
41#include "xinevideowidget.h" 44#include <qtimer.h>
45#include <qmessagebox.h>
42 46
43XineControl::XineControl( XineVideoWidget *xineWidget, 47XineControl::XineControl( XineVideoWidget *xineWidget,
44 MediaPlayerState &_mediaPlayerState, 48 MediaPlayerState &_mediaPlayerState,
45 QObject *parent, const char *name ) 49 QObject *parent, const char *name )
46 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 50 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
47{ 51{
48 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); 52 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget );
49 53
50 init(); 54 init();
51} 55}
52 56
53XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, 57XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget,
54 MediaPlayerState &_mediaPlayerState, 58 MediaPlayerState &_mediaPlayerState,
55 QObject *parent, const char *name ) 59 QObject *parent, const char *name )
56 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 60 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
57{ 61{
58 xine->ensureInitialized(); 62 xine->ensureInitialized();
59 63
60 xine->setWidget( xineWidget ); 64 xine->setWidget( xineWidget );
61 65
62 init(); 66 init();
63} 67}
64 68
65void XineControl::init() 69void XineControl::init()
66{ 70{
67 connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 71 connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
68 connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); 72 connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) );
69 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); 73 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) );
70 connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); 74 connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) );
71 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); 75 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) );
72 connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); 76 connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) );
73 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 77 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
74 connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); 78 connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) );
75 79
76 disabledSuspendScreenSaver = FALSE; 80 disabledSuspendScreenSaver = FALSE;
77} 81}
78 82
79XineControl::~XineControl() { 83XineControl::~XineControl() {
80#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 84#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
81 if ( disabledSuspendScreenSaver ) { 85 if ( disabledSuspendScreenSaver ) {
82 disabledSuspendScreenSaver = FALSE; 86 disabledSuspendScreenSaver = FALSE;
83 // Re-enable the suspend mode 87 // Re-enable the suspend mode
84 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 88 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
85 } 89 }
86#endif 90#endif
87 delete libXine; 91 delete libXine;
88} 92}
89 93
90void XineControl::play( const QString& fileName ) { 94void XineControl::play( const QString& fileName ) {
91 95
92 hasVideoChannel = FALSE; 96 hasVideoChannel = FALSE;
93 hasAudioChannel = FALSE; 97 hasAudioChannel = FALSE;
94 m_fileName = fileName; 98 m_fileName = fileName;
95 99
96 odebug << "<<FILENAME: " + fileName + ">>>>" << oendl; 100 odebug << "<<FILENAME: " + fileName + ">>>>" << oendl;
97 101
98 if ( !libXine->play( fileName, 0, 0 ) ) { 102 if ( !libXine->play( fileName, 0, 0 ) ) {
99 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 103 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
100 // toggle stop so the the play button is reset 104 // toggle stop so the the play button is reset
101 mediaPlayerState.setPlaying( false ); 105 mediaPlayerState.setPlaying( false );
102 return; 106 return;
103 } 107 }
104 mediaPlayerState.setPlaying( true ); 108 mediaPlayerState.setPlaying( true );
105 109
106 MediaPlayerState::DisplayType displayType; 110 MediaPlayerState::DisplayType displayType;
107 if ( !libXine->hasVideo() ) { 111 if ( !libXine->hasVideo() ) {
108 displayType = MediaPlayerState::Audio; 112 displayType = MediaPlayerState::Audio;
109 odebug << "HAS AUDIO" << oendl; 113 odebug << "HAS AUDIO" << oendl;
110 libXine->setShowVideo( false ); 114 libXine->setShowVideo( false );
111 hasAudioChannel = TRUE; 115 hasAudioChannel = TRUE;
112 } else { 116 } else {
113 displayType = MediaPlayerState::Video; 117 displayType = MediaPlayerState::Video;
114 odebug << "HAS VIDEO" << oendl; 118 odebug << "HAS VIDEO" << oendl;
115 libXine->setShowVideo( true ); 119 libXine->setShowVideo( true );
116 hasVideoChannel = TRUE; 120 hasVideoChannel = TRUE;
117 } 121 }
118 // determine if slider is shown 122 // determine if slider is shown
119 mediaPlayerState.setIsSeekable( libXine->isSeekable() ); 123 mediaPlayerState.setIsSeekable( libXine->isSeekable() );
120 124
121 // which gui (video / audio) 125 // which gui (video / audio)
122 mediaPlayerState.setDisplayType( displayType ); 126 mediaPlayerState.setDisplayType( displayType );
123 127
124#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 128#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
125 if ( !disabledSuspendScreenSaver ) { 129 if ( !disabledSuspendScreenSaver ) {
126 disabledSuspendScreenSaver = TRUE; 130 disabledSuspendScreenSaver = TRUE;
127 // Stop the screen from blanking and power saving state 131 // Stop the screen from blanking and power saving state
128 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 132 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
129 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 133 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend );
130 } 134 }
131#endif 135#endif
132 136
133 length(); 137 length();
134 position(); 138 position();
135} 139}
136 140
137void XineControl::nextMedia() { 141void XineControl::nextMedia() {
138 mediaPlayerState.setNext(); 142 mediaPlayerState.setNext();
139} 143}
140 144
141void XineControl::setGamma( int value ) { 145void XineControl::setGamma( int value ) {
142 libXine->setGamma( value ); 146 libXine->setGamma( value );
143} 147}
144 148
145void XineControl::stop( bool isSet ) { 149void XineControl::stop( bool isSet ) {
146 if ( !isSet ) { 150 if ( !isSet ) {
147 libXine->stop(); 151 libXine->stop();
148 152
149#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 153#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
150 if ( disabledSuspendScreenSaver ) { 154 if ( disabledSuspendScreenSaver ) {
151 disabledSuspendScreenSaver = FALSE; 155 disabledSuspendScreenSaver = FALSE;
152 // Re-enable the suspend mode 156 // Re-enable the suspend mode
153 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 157 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
154 } 158 }
155#endif 159#endif
156 } 160 }
157} 161}
158 162
159/** 163/**
160 * Pause playback 164 * Pause playback
161 * @isSet 165 * @isSet
162 */ 166 */
163void XineControl::pause( bool isSet) { 167void XineControl::pause( bool isSet) {
164 libXine->pause( isSet ); 168 libXine->pause( isSet );
165} 169}
166 170
167 171
168/** 172/**
169 * get current time in playback 173 * get current time in playback
170 */ 174 */
171long XineControl::currentTime() { 175long XineControl::currentTime() {
172 // todo: jede sekunde überprüfen 176 // todo: jede sekunde überprüfen
173 m_currentTime = libXine->currentTime(); 177 m_currentTime = libXine->currentTime();
174 return m_currentTime; 178 return m_currentTime;
175 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 179 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
176} 180}
177 181
178/** 182/**
179 * Set the length of the media file 183 * Set the length of the media file
180 */ 184 */
181void XineControl::length() { 185void XineControl::length() {
182 m_length = libXine->length(); 186 m_length = libXine->length();
183 mediaPlayerState.setLength( m_length ); 187 mediaPlayerState.setLength( m_length );
184} 188}
185 189
186 190
187/** 191/**
188 * Reports the position the xine backend is at right now 192 * Reports the position the xine backend is at right now
189 * @return long the postion in seconds 193 * @return long the postion in seconds
190 */ 194 */
191long XineControl::position() { 195long XineControl::position() {
192 m_position = ( currentTime() ); 196 m_position = ( currentTime() );
193 mediaPlayerState.updatePosition( m_position ); 197 mediaPlayerState.updatePosition( m_position );
194 long emitPos = (long)m_position; 198 long emitPos = (long)m_position;
195 emit positionChanged( emitPos ); 199 emit positionChanged( emitPos );
196 if( mediaPlayerState.isPlaying() ) { 200 if( mediaPlayerState.isPlaying() ) {
197 // needs to be stopped the media is stopped 201 // needs to be stopped the media is stopped
198 QTimer::singleShot( 1000, this, SLOT( position() ) ); 202 QTimer::singleShot( 1000, this, SLOT( position() ) );
199 } 203 }
200 return m_position; 204 return m_position;
201} 205}
202 206
203/** 207/**
204 * Set videoplayback to fullscreen 208 * Set videoplayback to fullscreen
205 * @param isSet 209 * @param isSet
206 */ 210 */
207void XineControl::setFullscreen( bool isSet ) { 211void XineControl::setFullscreen( bool isSet ) {
208 libXine->showVideoFullScreen( isSet ); 212 libXine->showVideoFullScreen( isSet );
209} 213}
210 214
211 215
212QString XineControl::getMetaInfo() { 216QString XineControl::getMetaInfo() {
213 217
214 QString returnString; 218 QString returnString;
215 219
216 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 220 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
217 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 221 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
218 } 222 }
219 223
220 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 224 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
221 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 225 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
222 } 226 }
223 227
224 if ( !libXine->metaInfo( 2 ).isEmpty() ) { 228 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
225 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); 229 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
226 } 230 }
227 231
228 if ( !libXine->metaInfo( 3 ).isEmpty() ) { 232 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
229 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); 233 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
230 } 234 }
231 235
232 if ( !libXine->metaInfo( 4 ).isEmpty() ) { 236 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
233 returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); 237 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
234 } 238 }
235 239
236 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 240 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
237 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 241 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
238 } 242 }
239 return returnString; 243 return returnString;
240} 244}
241 245
242QString XineControl::getErrorCode() { 246QString XineControl::getErrorCode() {
243 247
244 int errorCode = libXine->error(); 248 int errorCode = libXine->error();
245 249
246 odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; 250 odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl;
247 251
248 if ( errorCode == 1 ) { 252 if ( errorCode == 1 ) {
249 return tr( "No input plugin found for this media type" ); 253 return tr( "No input plugin found for this media type" );
250 } else if ( errorCode == 2 ) { 254 } else if ( errorCode == 2 ) {
251 return tr( "No demux plugin found for this media type" ); 255 return tr( "No demux plugin found for this media type" );
252 } else if ( errorCode == 3 ) { 256 } else if ( errorCode == 3 ) {
253 return tr( "Demuxing failed for this media type" ); 257 return tr( "Demuxing failed for this media type" );
254 } else if ( errorCode == 4 ) { 258 } else if ( errorCode == 4 ) {
255 return tr( "Malformed MRL" ); 259 return tr( "Malformed MRL" );
256 } else { 260 } else {
257 return tr( "Some other error" ); 261 return tr( "Some other error" );
258 } 262 }
259} 263}
260 264
261/** 265/**
262 * Seek to a position in the track 266 * Seek to a position in the track
263 * @param second the second to jump to 267 * @param second the second to jump to
264 */ 268 */
265void XineControl::seekTo( long second ) { 269void XineControl::seekTo( long second ) {
266 libXine->seekTo( (int)second ); 270 libXine->seekTo( (int)second );
267} 271}
268 272
269void XineControl::videoResized ( const QSize &s ) { 273void XineControl::videoResized ( const QSize &s ) {
270 libXine->resize( s ); 274 libXine->resize( s );
271} 275}