summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 13:47:10 (UTC)
committer simon <simon>2002-12-02 13:47:10 (UTC)
commit1646c471d8a1f54df65c8d58402bc80af004f498 (patch) (unidiff)
treee6697a36c96e7d1c7295e46bea5a6847fe2e22ec
parentb992707037f3bbf4573c52b34b3d25cbbf07bad0 (diff)
downloadopie-1646c471d8a1f54df65c8d58402bc80af004f498.zip
opie-1646c471d8a1f54df65c8d58402bc80af004f498.tar.gz
opie-1646c471d8a1f54df65c8d58402bc80af004f498.tar.bz2
- paused() -> isPaused() and the like for all accessor functions in the
mediaplayerstate class
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp12
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp120
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h40
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp36
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp20
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp2
7 files changed, 120 insertions, 120 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index a52319b..7c2b007 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,554 +1,554 @@
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#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <opie/oticker.h> 37#include <opie/oticker.h>
38 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qbutton.h> 41#include <qbutton.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48 48
49#include "audiowidget.h" 49#include "audiowidget.h"
50#include "mediaplayerstate.h" 50#include "mediaplayerstate.h"
51#include "playlistwidget.h" 51#include "playlistwidget.h"
52 52
53extern MediaPlayerState *mediaPlayerState; 53extern MediaPlayerState *mediaPlayerState;
54extern PlayListWidget *playList; 54extern PlayListWidget *playList;
55 55
56static const int xo = -2; // movable x offset 56static const int xo = -2; // movable x offset
57static const int yo = 22; // movable y offset 57static const int yo = 22; // movable y offset
58 58
59struct MediaButton { 59struct MediaButton {
60 bool isToggle, isHeld, isDown; 60 bool isToggle, isHeld, isDown;
61}; 61};
62 62
63//Layout information for the audioButtons (and if it is a toggle button or not) 63//Layout information for the audioButtons (and if it is a toggle button or not)
64MediaButton audioButtons[] = { 64MediaButton audioButtons[] = {
65 { TRUE, FALSE, FALSE }, // play 65 { TRUE, FALSE, FALSE }, // play
66 { FALSE, FALSE, FALSE }, // stop 66 { FALSE, FALSE, FALSE }, // stop
67 { FALSE, FALSE, FALSE }, // next 67 { FALSE, FALSE, FALSE }, // next
68 { FALSE, FALSE, FALSE }, // previous 68 { FALSE, FALSE, FALSE }, // previous
69 { FALSE, FALSE, FALSE }, // volume up 69 { FALSE, FALSE, FALSE }, // volume up
70 { FALSE, FALSE, FALSE }, // volume down 70 { FALSE, FALSE, FALSE }, // volume down
71 { TRUE, FALSE, FALSE }, // repeat/loop 71 { TRUE, FALSE, FALSE }, // repeat/loop
72 { FALSE, FALSE, FALSE }, // playlist 72 { FALSE, FALSE, FALSE }, // playlist
73 { FALSE, FALSE, FALSE }, // forward 73 { FALSE, FALSE, FALSE }, // forward
74 { FALSE, FALSE, FALSE } // back 74 { FALSE, FALSE, FALSE } // back
75}; 75};
76 76
77const char *skin_mask_file_names[10] = { 77const char *skin_mask_file_names[10] = {
78 "play", "stop", "next", "prev", "up", 78 "play", "stop", "next", "prev", "up",
79 "down", "loop", "playlist", "forward", "back" 79 "down", "loop", "playlist", "forward", "back"
80}; 80};
81 81
82 82
83static void changeTextColor( QWidget *w ) { 83static void changeTextColor( QWidget *w ) {
84 QPalette p = w->palette(); 84 QPalette p = w->palette();
85 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 85 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
86 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 86 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
87 w->setPalette( p ); 87 w->setPalette( p );
88} 88}
89 89
90static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 90static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
91 91
92 92
93AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 93AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
94 94
95 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 95 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
96 96
97 setCaption( tr("OpiePlayer") ); 97 setCaption( tr("OpiePlayer") );
98 98
99 Config cfg("OpiePlayer"); 99 Config cfg("OpiePlayer");
100 cfg.setGroup("Options"); 100 cfg.setGroup("Options");
101 skin = cfg.readEntry("Skin","default"); 101 skin = cfg.readEntry("Skin","default");
102 //skin = "scaleTest"; 102 //skin = "scaleTest";
103 // color of background, frame, degree of transparency 103 // color of background, frame, degree of transparency
104 104
105 QString skinPath = "opieplayer2/skins/" + skin; 105 QString skinPath = "opieplayer2/skins/" + skin;
106 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 106 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
107 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 107 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
108 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 108 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
109 109
110 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 110 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
111 imgButtonMask->fill( 0 ); 111 imgButtonMask->fill( 0 );
112 112
113 for ( int i = 0; i < 10; i++ ) { 113 for ( int i = 0; i < 10; i++ ) {
114 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); 114 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
115 masks[i] = new QBitmap( filename ); 115 masks[i] = new QBitmap( filename );
116 116
117 if ( !masks[i]->isNull() ) { 117 if ( !masks[i]->isNull() ) {
118 QImage imgMask = masks[i]->convertToImage(); 118 QImage imgMask = masks[i]->convertToImage();
119 uchar **dest = imgButtonMask->jumpTable(); 119 uchar **dest = imgButtonMask->jumpTable();
120 for ( int y = 0; y < imgUp->height(); y++ ) { 120 for ( int y = 0; y < imgUp->height(); y++ ) {
121 uchar *line = dest[y]; 121 uchar *line = dest[y];
122 for ( int x = 0; x < imgUp->width(); x++ ) 122 for ( int x = 0; x < imgUp->width(); x++ )
123 if ( !qRed( imgMask.pixel( x, y ) ) ) 123 if ( !qRed( imgMask.pixel( x, y ) ) )
124 line[x] = i + 1; 124 line[x] = i + 1;
125 } 125 }
126 } 126 }
127 127
128 } 128 }
129 129
130 for ( int i = 0; i < 10; i++ ) { 130 for ( int i = 0; i < 10; i++ ) {
131 buttonPixUp[i] = 0l; 131 buttonPixUp[i] = 0l;
132 buttonPixDown[i] = 0l; 132 buttonPixDown[i] = 0l;
133 } 133 }
134 134
135 setBackgroundPixmap( *pixBg ); 135 setBackgroundPixmap( *pixBg );
136 136
137 songInfo.setFocusPolicy( QWidget::NoFocus ); 137 songInfo.setFocusPolicy( QWidget::NoFocus );
138// changeTextColor( &songInfo ); 138// changeTextColor( &songInfo );
139// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 139// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
140// songInfo.setFrameStyle( QFrame::NoFrame); 140// songInfo.setFrameStyle( QFrame::NoFrame);
141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
142// songInfo.setForegroundColor(Qt::white); 142// songInfo.setForegroundColor(Qt::white);
143 143
144 slider.setFixedHeight( 20 ); 144 slider.setFixedHeight( 20 );
145 slider.setMinValue( 0 ); 145 slider.setMinValue( 0 );
146 slider.setMaxValue( 1 ); 146 slider.setMaxValue( 1 );
147 slider.setFocusPolicy( QWidget::NoFocus ); 147 slider.setFocusPolicy( QWidget::NoFocus );
148 slider.setBackgroundPixmap( *pixBg ); 148 slider.setBackgroundPixmap( *pixBg );
149 149
150// Config cofg("qpe"); 150// Config cofg("qpe");
151// cofg.setGroup("Appearance"); 151// cofg.setGroup("Appearance");
152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
153 153
154 time.setFocusPolicy( QWidget::NoFocus ); 154 time.setFocusPolicy( QWidget::NoFocus );
155 time.setAlignment( Qt::AlignCenter ); 155 time.setAlignment( Qt::AlignCenter );
156 156
157// time.setFrame(FALSE); 157// time.setFrame(FALSE);
158// changeTextColor( &time ); 158// changeTextColor( &time );
159 159
160 resizeEvent( NULL ); 160 resizeEvent( NULL );
161 161
162 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 162 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
163 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 163 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
164 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 164 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
165 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 165 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
166 connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 166 connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
167 167
168 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 168 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
169 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 169 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
170 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 170 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
171 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 171 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
172 172
173 // Intialise state 173 // Intialise state
174 setLength( mediaPlayerState->length() ); 174 setLength( mediaPlayerState->length() );
175 setPosition( mediaPlayerState->position() ); 175 setPosition( mediaPlayerState->position() );
176 setLooping( mediaPlayerState->fullscreen() ); 176 setLooping( mediaPlayerState->isFullscreen() );
177 // setPaused( mediaPlayerState->paused() ); 177 // setPaused( mediaPlayerState->paused() );
178 setPlaying( mediaPlayerState->playing() ); 178 setPlaying( mediaPlayerState->isPlaying() );
179 179
180} 180}
181 181
182AudioWidget::~AudioWidget() { 182AudioWidget::~AudioWidget() {
183 183
184 for ( int i = 0; i < 10; i++ ) { 184 for ( int i = 0; i < 10; i++ ) {
185 delete buttonPixUp[i]; 185 delete buttonPixUp[i];
186 delete buttonPixDown[i]; 186 delete buttonPixDown[i];
187 } 187 }
188 delete pixBg; 188 delete pixBg;
189 delete imgUp; 189 delete imgUp;
190 delete imgDn; 190 delete imgDn;
191 delete imgButtonMask; 191 delete imgButtonMask;
192 for ( int i = 0; i < 10; i++ ) { 192 for ( int i = 0; i < 10; i++ ) {
193 delete masks[i]; 193 delete masks[i];
194 } 194 }
195// mediaPlayerState->setPlaying(false); 195// mediaPlayerState->setPlaying(false);
196} 196}
197 197
198namespace { 198namespace {
199 199
200QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 200QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
201 QPixmap pix( img.width(), img.height() ); 201 QPixmap pix( img.width(), img.height() );
202 QPainter p( &pix ); 202 QPainter p( &pix );
203 p.drawTiledPixmap( pix.rect(), bg, offset ); 203 p.drawTiledPixmap( pix.rect(), bg, offset );
204 p.drawImage( 0, 0, img ); 204 p.drawImage( 0, 0, img );
205 return new QPixmap( pix ); 205 return new QPixmap( pix );
206} 206}
207 207
208 208
209QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 209QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
210 QPixmap *pixmap = new QPixmap( pix ); 210 QPixmap *pixmap = new QPixmap( pix );
211 pixmap->setMask( mask ); 211 pixmap->setMask( mask );
212 return pixmap; 212 return pixmap;
213} 213}
214 214
215}; 215};
216 216
217void AudioWidget::resizeEvent( QResizeEvent * ) { 217void AudioWidget::resizeEvent( QResizeEvent * ) {
218 int h = height(); 218 int h = height();
219 int w = width(); 219 int w = width();
220 220
221 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 221 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
222 slider.setFixedWidth( w - 110 ); 222 slider.setFixedWidth( w - 110 );
223 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 223 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
224 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 224 slider.setBackgroundOrigin( QWidget::ParentOrigin );
225 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 225 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
226 226
227 xoff = ( w - imgUp->width() ) / 2; 227 xoff = ( w - imgUp->width() ) / 2;
228 yoff = (( h - imgUp->height() ) / 2) - 10; 228 yoff = (( h - imgUp->height() ) / 2) - 10;
229 QPoint p( xoff, yoff ); 229 QPoint p( xoff, yoff );
230 230
231 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 231 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
232 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 232 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
233 233
234 for ( int i = 0; i < 10; i++ ) { 234 for ( int i = 0; i < 10; i++ ) {
235 if ( !masks[i]->isNull() ) { 235 if ( !masks[i]->isNull() ) {
236 delete buttonPixUp[i]; 236 delete buttonPixUp[i];
237 delete buttonPixDown[i]; 237 delete buttonPixDown[i];
238 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 238 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
239 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 239 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
240 } 240 }
241 } 241 }
242 242
243 delete pixUp; 243 delete pixUp;
244 delete pixDn; 244 delete pixDn;
245} 245}
246 246
247static bool audioSliderBeingMoved = FALSE; 247static bool audioSliderBeingMoved = FALSE;
248 248
249 249
250void AudioWidget::sliderPressed() { 250void AudioWidget::sliderPressed() {
251 audioSliderBeingMoved = TRUE; 251 audioSliderBeingMoved = TRUE;
252} 252}
253 253
254 254
255void AudioWidget::sliderReleased() { 255void AudioWidget::sliderReleased() {
256 audioSliderBeingMoved = FALSE; 256 audioSliderBeingMoved = FALSE;
257 if ( slider.width() == 0 ) 257 if ( slider.width() == 0 )
258 return; 258 return;
259 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 259 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
260 mediaPlayerState->setPosition( val ); 260 mediaPlayerState->setPosition( val );
261} 261}
262 262
263void AudioWidget::setPosition( long i ) { 263void AudioWidget::setPosition( long i ) {
264 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 264 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
265 updateSlider( i, mediaPlayerState->length() ); 265 updateSlider( i, mediaPlayerState->length() );
266} 266}
267 267
268 268
269void AudioWidget::setLength( long max ) { 269void AudioWidget::setLength( long max ) {
270 updateSlider( mediaPlayerState->position(), max ); 270 updateSlider( mediaPlayerState->position(), max );
271} 271}
272 272
273 273
274void AudioWidget::setView( char view ) { 274void AudioWidget::setView( char view ) {
275 275
276if ( view == 'a' ) { 276if ( view == 'a' ) {
277 // startTimer( 150 ); 277 // startTimer( 150 );
278 showMaximized(); 278 showMaximized();
279 } else { 279 } else {
280 killTimers(); 280 killTimers();
281 hide(); 281 hide();
282 } 282 }
283 // qApp->processEvents(); 283 // qApp->processEvents();
284} 284}
285 285
286 286
287void AudioWidget::setSeekable( bool isSeekable ) { 287void AudioWidget::setSeekable( bool isSeekable ) {
288 288
289 if ( !isSeekable ) { 289 if ( !isSeekable ) {
290 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 290 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
291 if( !slider.isHidden()) { 291 if( !slider.isHidden()) {
292 slider.hide(); 292 slider.hide();
293 } 293 }
294 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 294 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
295 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 295 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
296 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 296 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
297 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 297 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
298 } else { 298 } else {
299 // this stops the slider from being moved, thus 299 // this stops the slider from being moved, thus
300 // does not stop stream when it reaches the end 300 // does not stop stream when it reaches the end
301 slider.show(); 301 slider.show();
302 qDebug( " CONNECT SET POSTION " ); 302 qDebug( " CONNECT SET POSTION " );
303 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 303 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
304 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 304 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
305 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 305 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
306 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 306 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
307 } 307 }
308} 308}
309 309
310 310
311static QString timeAsString( long length ) { 311static QString timeAsString( long length ) {
312 int minutes = length / 60; 312 int minutes = length / 60;
313 int seconds = length % 60; 313 int seconds = length % 60;
314 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 314 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
315} 315}
316 316
317void AudioWidget::updateSlider( long i, long max ) { 317void AudioWidget::updateSlider( long i, long max ) {
318 318
319 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 319 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
320// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 320// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
321 321
322 if ( max == 0 ) { 322 if ( max == 0 ) {
323 return; 323 return;
324 } 324 }
325 // Will flicker too much if we don't do this 325 // Will flicker too much if we don't do this
326 // Scale to something reasonable 326 // Scale to something reasonable
327 int width = slider.width(); 327 int width = slider.width();
328 int val = int((double)i * width / max); 328 int val = int((double)i * width / max);
329 if ( !audioSliderBeingMoved ) { 329 if ( !audioSliderBeingMoved ) {
330 if ( slider.value() != val ) { 330 if ( slider.value() != val ) {
331 slider.setValue( val ); 331 slider.setValue( val );
332 } 332 }
333 333
334 if ( slider.maxValue() != width ) { 334 if ( slider.maxValue() != width ) {
335 slider.setMaxValue( width ); 335 slider.setMaxValue( width );
336 } 336 }
337 } 337 }
338} 338}
339 339
340 340
341void AudioWidget::setToggleButton( int i, bool down ) { 341void AudioWidget::setToggleButton( int i, bool down ) {
342 qDebug("setToggleButton %d", i); 342 qDebug("setToggleButton %d", i);
343 if ( down != audioButtons[i].isDown ) { 343 if ( down != audioButtons[i].isDown ) {
344 toggleButton( i ); 344 toggleButton( i );
345 } 345 }
346} 346}
347 347
348 348
349void AudioWidget::toggleButton( int i ) { 349void AudioWidget::toggleButton( int i ) {
350 audioButtons[i].isDown = !audioButtons[i].isDown; 350 audioButtons[i].isDown = !audioButtons[i].isDown;
351 QPainter p(this); 351 QPainter p(this);
352 paintButton ( &p, i ); 352 paintButton ( &p, i );
353} 353}
354 354
355 355
356void AudioWidget::paintButton( QPainter *p, int i ) { 356void AudioWidget::paintButton( QPainter *p, int i ) {
357 if ( audioButtons[i].isDown ) { 357 if ( audioButtons[i].isDown ) {
358 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 358 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
359 } else { 359 } else {
360 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 360 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
361 } 361 }
362} 362}
363 363
364 364
365void AudioWidget::skipFor() { 365void AudioWidget::skipFor() {
366 skipDirection = +1; 366 skipDirection = +1;
367 startTimer( 50 ); 367 startTimer( 50 );
368 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 368 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
369} 369}
370 370
371void AudioWidget::skipBack() { 371void AudioWidget::skipBack() {
372 skipDirection = -1; 372 skipDirection = -1;
373 startTimer( 50 ); 373 startTimer( 50 );
374 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 374 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
375} 375}
376 376
377 377
378 378
379void AudioWidget::stopSkip() { 379void AudioWidget::stopSkip() {
380 killTimers(); 380 killTimers();
381} 381}
382 382
383 383
384void AudioWidget::timerEvent( QTimerEvent * ) { 384void AudioWidget::timerEvent( QTimerEvent * ) {
385 if ( skipDirection == +1 ) { 385 if ( skipDirection == +1 ) {
386 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 386 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
387 } else if ( skipDirection == -1 ) { 387 } else if ( skipDirection == -1 ) {
388 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 388 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
389 } 389 }
390} 390}
391 391
392 392
393void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 393void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
394 for ( int i = 0; i < numButtons; i++ ) { 394 for ( int i = 0; i < numButtons; i++ ) {
395 if ( event->state() == QMouseEvent::LeftButton ) { 395 if ( event->state() == QMouseEvent::LeftButton ) {
396 // The test to see if the mouse click is inside the button or not 396 // The test to see if the mouse click is inside the button or not
397 int x = event->pos().x() - xoff; 397 int x = event->pos().x() - xoff;
398 int y = event->pos().y() - yoff; 398 int y = event->pos().y() - yoff;
399 399
400 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 400 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
401 && y < imgButtonMask->height() 401 && y < imgButtonMask->height()
402 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 402 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
403 403
404 if ( isOnButton && !audioButtons[i].isHeld ) { 404 if ( isOnButton && !audioButtons[i].isHeld ) {
405 audioButtons[i].isHeld = TRUE; 405 audioButtons[i].isHeld = TRUE;
406 toggleButton(i); 406 toggleButton(i);
407 switch (i) { 407 switch (i) {
408 case AudioVolumeUp: 408 case AudioVolumeUp:
409 emit moreClicked(); 409 emit moreClicked();
410 return; 410 return;
411 case AudioVolumeDown: 411 case AudioVolumeDown:
412 emit lessClicked(); 412 emit lessClicked();
413 return; 413 return;
414 case AudioForward: 414 case AudioForward:
415 emit forwardClicked(); 415 emit forwardClicked();
416 return; 416 return;
417 case AudioBack: 417 case AudioBack:
418 emit backClicked(); 418 emit backClicked();
419 return; 419 return;
420 } 420 }
421 } else if ( !isOnButton && audioButtons[i].isHeld ) { 421 } else if ( !isOnButton && audioButtons[i].isHeld ) {
422 audioButtons[i].isHeld = FALSE; 422 audioButtons[i].isHeld = FALSE;
423 toggleButton(i); 423 toggleButton(i);
424 } 424 }
425 } else { 425 } else {
426 if ( audioButtons[i].isHeld ) { 426 if ( audioButtons[i].isHeld ) {
427 audioButtons[i].isHeld = FALSE; 427 audioButtons[i].isHeld = FALSE;
428 if ( !audioButtons[i].isToggle ) { 428 if ( !audioButtons[i].isToggle ) {
429 setToggleButton( i, FALSE ); 429 setToggleButton( i, FALSE );
430 } 430 }
431 qDebug("mouseEvent %d", i); 431 qDebug("mouseEvent %d", i);
432 switch (i) { 432 switch (i) {
433 case AudioPlay: 433 case AudioPlay:
434 if( mediaPlayerState->paused() ) { 434 if( mediaPlayerState->isPaused() ) {
435 mediaPlayerState->setPaused( FALSE ); 435 mediaPlayerState->setPaused( FALSE );
436 return; 436 return;
437 } else if( !mediaPlayerState->paused() ) { 437 } else if( !mediaPlayerState->isPaused() ) {
438 mediaPlayerState->setPaused( TRUE ); 438 mediaPlayerState->setPaused( TRUE );
439 return; 439 return;
440 } 440 }
441 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 441 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
442 case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return; 442 case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return;
443 case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return; 443 case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return;
444 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 444 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
445 case AudioVolumeUp: emit moreReleased(); return; 445 case AudioVolumeUp: emit moreReleased(); return;
446 case AudioVolumeDown: emit lessReleased(); return; 446 case AudioVolumeDown: emit lessReleased(); return;
447 case AudioPlayList: mediaPlayerState->setList(); return; 447 case AudioPlayList: mediaPlayerState->setList(); return;
448 case AudioForward: emit forwardReleased(); return; 448 case AudioForward: emit forwardReleased(); return;
449 case AudioBack: emit backReleased(); return; 449 case AudioBack: emit backReleased(); return;
450 } 450 }
451 } 451 }
452 } 452 }
453 } 453 }
454} 454}
455 455
456 456
457void AudioWidget::mousePressEvent( QMouseEvent *event ) { 457void AudioWidget::mousePressEvent( QMouseEvent *event ) {
458 mouseMoveEvent( event ); 458 mouseMoveEvent( event );
459} 459}
460 460
461 461
462void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 462void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
463 mouseMoveEvent( event ); 463 mouseMoveEvent( event );
464} 464}
465 465
466 466
467void AudioWidget::showEvent( QShowEvent* ) { 467void AudioWidget::showEvent( QShowEvent* ) {
468 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 468 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
469 mouseMoveEvent( &event ); 469 mouseMoveEvent( &event );
470} 470}
471 471
472 472
473void AudioWidget::closeEvent( QCloseEvent* ) { 473void AudioWidget::closeEvent( QCloseEvent* ) {
474 mediaPlayerState->setList(); 474 mediaPlayerState->setList();
475} 475}
476 476
477 477
478void AudioWidget::paintEvent( QPaintEvent * pe ) { 478void AudioWidget::paintEvent( QPaintEvent * pe ) {
479 if ( !pe->erased() ) { 479 if ( !pe->erased() ) {
480 // Combine with background and double buffer 480 // Combine with background and double buffer
481 QPixmap pix( pe->rect().size() ); 481 QPixmap pix( pe->rect().size() );
482 QPainter p( &pix ); 482 QPainter p( &pix );
483 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 483 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
484 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 484 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
485 for ( int i = 0; i < numButtons; i++ ) 485 for ( int i = 0; i < numButtons; i++ )
486 paintButton( &p, i ); 486 paintButton( &p, i );
487 QPainter p2( this ); 487 QPainter p2( this );
488 p2.drawPixmap( pe->rect().topLeft(), pix ); 488 p2.drawPixmap( pe->rect().topLeft(), pix );
489 } else { 489 } else {
490 QPainter p( this ); 490 QPainter p( this );
491 for ( int i = 0; i < numButtons; i++ ) 491 for ( int i = 0; i < numButtons; i++ )
492 paintButton( &p, i ); 492 paintButton( &p, i );
493 } 493 }
494} 494}
495 495
496void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 496void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
497 switch ( e->key() ) { 497 switch ( e->key() ) {
498 ////////////////////////////// Zaurus keys 498 ////////////////////////////// Zaurus keys
499 case Key_Home: 499 case Key_Home:
500 break; 500 break;
501 case Key_F9: //activity 501 case Key_F9: //activity
502 hide(); 502 hide();
503 // qDebug("Audio F9"); 503 // qDebug("Audio F9");
504 break; 504 break;
505 case Key_F10: //contacts 505 case Key_F10: //contacts
506 break; 506 break;
507 case Key_F11: //menu 507 case Key_F11: //menu
508 mediaPlayerState->toggleBlank(); 508 mediaPlayerState->toggleBlank();
509 break; 509 break;
510 case Key_F12: //home 510 case Key_F12: //home
511 break; 511 break;
512 case Key_F13: //mail 512 case Key_F13: //mail
513 mediaPlayerState->toggleBlank(); 513 mediaPlayerState->toggleBlank();
514 break; 514 break;
515 case Key_Space: { 515 case Key_Space: {
516 if(mediaPlayerState->playing()) { 516 if(mediaPlayerState->isPlaying()) {
517 // toggleButton(1); 517 // toggleButton(1);
518 mediaPlayerState->setPlaying(FALSE); 518 mediaPlayerState->setPlaying(FALSE);
519 // toggleButton(1); 519 // toggleButton(1);
520 } else { 520 } else {
521 // toggleButton(0); 521 // toggleButton(0);
522 mediaPlayerState->setPlaying(TRUE); 522 mediaPlayerState->setPlaying(TRUE);
523 // toggleButton(0); 523 // toggleButton(0);
524 } 524 }
525 } 525 }
526 break; 526 break;
527 case Key_Down: 527 case Key_Down:
528 // toggleButton(6); 528 // toggleButton(6);
529 emit lessClicked(); 529 emit lessClicked();
530 emit lessReleased(); 530 emit lessReleased();
531 // toggleButton(6); 531 // toggleButton(6);
532 break; 532 break;
533 case Key_Up: 533 case Key_Up:
534 // toggleButton(5); 534 // toggleButton(5);
535 emit moreClicked(); 535 emit moreClicked();
536 emit moreReleased(); 536 emit moreReleased();
537 // toggleButton(5); 537 // toggleButton(5);
538 break; 538 break;
539 case Key_Right: 539 case Key_Right:
540 // toggleButton(3); 540 // toggleButton(3);
541 mediaPlayerState->setNext(); 541 mediaPlayerState->setNext();
542 // toggleButton(3); 542 // toggleButton(3);
543 break; 543 break;
544 case Key_Left: 544 case Key_Left:
545 // toggleButton(4); 545 // toggleButton(4);
546 mediaPlayerState->setPrev(); 546 mediaPlayerState->setPrev();
547 // toggleButton(4); 547 // toggleButton(4);
548 break; 548 break;
549 case Key_Escape: { 549 case Key_Escape: {
550 } 550 }
551 break; 551 break;
552 552
553 }; 553 };
554} 554}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 1f19b30..8136ff1 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,367 +1,367 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6#include <qfileinfo.h> 6#include <qfileinfo.h>
7 7
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include <qwidgetstack.h> 10#include <qwidgetstack.h>
11#include <qfile.h> 11#include <qfile.h>
12 12
13#include "mediaplayer.h" 13#include "mediaplayer.h"
14#include "playlistwidget.h" 14#include "playlistwidget.h"
15#include "audiowidget.h" 15#include "audiowidget.h"
16#include "videowidget.h" 16#include "videowidget.h"
17#include "volumecontrol.h" 17#include "volumecontrol.h"
18 18
19#include "mediaplayerstate.h" 19#include "mediaplayerstate.h"
20 20
21// for setBacklight() 21// for setBacklight()
22#include <linux/fb.h> 22#include <linux/fb.h>
23#include <sys/file.h> 23#include <sys/file.h>
24#include <sys/ioctl.h> 24#include <sys/ioctl.h>
25 25
26 26
27extern AudioWidget *audioUI; 27extern AudioWidget *audioUI;
28extern VideoWidget *videoUI; 28extern VideoWidget *videoUI;
29extern PlayListWidget *playList; 29extern PlayListWidget *playList;
30extern MediaPlayerState *mediaPlayerState; 30extern MediaPlayerState *mediaPlayerState;
31 31
32 32
33#define FBIOBLANK 0x4611 33#define FBIOBLANK 0x4611
34 34
35MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 35MediaPlayer::MediaPlayer( QObject *parent, const char *name )
36 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 36 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
37 37
38 fd=-1;fl=-1; 38 fd=-1;fl=-1;
39 playList->setCaption( tr( "OpiePlayer: Initializating" ) ); 39 playList->setCaption( tr( "OpiePlayer: Initializating" ) );
40 40
41 qApp->processEvents(); 41 qApp->processEvents();
42 // QPEApplication::grabKeyboard(); // EVIL 42 // QPEApplication::grabKeyboard(); // EVIL
43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
44 44
45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
46 46
47 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 47 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
48 48
49 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 49 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
50 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 50 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
51 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
52 52
53 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 53 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
54 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 54 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
55 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 55 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
56 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 56 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
57 57
58 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 58 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
59 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 59 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
60 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 60 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
61 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 61 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
62 62
63 volControl = new VolumeControl; 63 volControl = new VolumeControl;
64 xineControl = new XineControl(); 64 xineControl = new XineControl();
65 Config cfg( "OpiePlayer" ); 65 Config cfg( "OpiePlayer" );
66 cfg.setGroup("PlayList"); 66 cfg.setGroup("PlayList");
67 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 67 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
68 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 68 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
69} 69}
70 70
71MediaPlayer::~MediaPlayer() { 71MediaPlayer::~MediaPlayer() {
72 delete xineControl; 72 delete xineControl;
73 delete volControl; 73 delete volControl;
74} 74}
75 75
76void MediaPlayer::pauseCheck( bool b ) { 76void MediaPlayer::pauseCheck( bool b ) {
77 if ( b && !mediaPlayerState->playing() ) { 77 if ( b && !mediaPlayerState->isPlaying() ) {
78 mediaPlayerState->setPaused( FALSE ); 78 mediaPlayerState->setPaused( FALSE );
79 } 79 }
80} 80}
81 81
82void MediaPlayer::play() { 82void MediaPlayer::play() {
83 mediaPlayerState->setPlaying( FALSE ); 83 mediaPlayerState->setPlaying( FALSE );
84 mediaPlayerState->setPlaying( TRUE ); 84 mediaPlayerState->setPlaying( TRUE );
85} 85}
86 86
87void MediaPlayer::setPlaying( bool play ) { 87void MediaPlayer::setPlaying( bool play ) {
88 if ( !play ) { 88 if ( !play ) {
89 return; 89 return;
90 } 90 }
91 91
92 if ( mediaPlayerState->paused() ) { 92 if ( mediaPlayerState->isPaused() ) {
93 mediaPlayerState->setPaused( FALSE ); 93 mediaPlayerState->setPaused( FALSE );
94 return; 94 return;
95 } 95 }
96 96
97 QString tickerText, time, fileName; 97 QString tickerText, time, fileName;
98 if( playList->whichList() == 0 ) { //check for filelist 98 if( playList->whichList() == 0 ) { //check for filelist
99 const DocLnk *playListCurrent = playList->current(); 99 const DocLnk *playListCurrent = playList->current();
100 if ( playListCurrent != NULL ) { 100 if ( playListCurrent != NULL ) {
101 currentFile = playListCurrent; 101 currentFile = playListCurrent;
102 } 102 }
103 xineControl->play( currentFile->file() ); 103 xineControl->play( currentFile->file() );
104 fileName = currentFile->name(); 104 fileName = currentFile->name();
105 long seconds = mediaPlayerState->length();// 105 long seconds = mediaPlayerState->length();//
106 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 106 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
107 //qDebug(time); 107 //qDebug(time);
108 108
109 } else { 109 } else {
110 //if playing in file list.. play in a different way 110 //if playing in file list.. play in a different way
111 // random and looping settings enabled causes problems here, 111 // random and looping settings enabled causes problems here,
112 // since there is no selected file in the playlist, but a selected file in the file list, 112 // since there is no selected file in the playlist, but a selected file in the file list,
113 // so we remember and shutoff 113 // so we remember and shutoff
114 l = mediaPlayerState->looping(); 114 l = mediaPlayerState->isLooping();
115 if(l) { 115 if(l) {
116 mediaPlayerState->setLooping( false ); 116 mediaPlayerState->setLooping( false );
117 } 117 }
118 r = mediaPlayerState->shuffled(); 118 r = mediaPlayerState->isShuffled();
119 mediaPlayerState->setShuffled( false ); 119 mediaPlayerState->setShuffled( false );
120 120
121 fileName = playList->currentFileListPathName(); 121 fileName = playList->currentFileListPathName();
122 xineControl->play( fileName ); 122 xineControl->play( fileName );
123 long seconds = mediaPlayerState->length(); 123 long seconds = mediaPlayerState->length();
124 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 124 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
125 //qDebug(time); 125 //qDebug(time);
126 if( fileName.left(4) != "http" ) { 126 if( fileName.left(4) != "http" ) {
127 fileName = QFileInfo( fileName ).baseName(); 127 fileName = QFileInfo( fileName ).baseName();
128 } 128 }
129 129
130 } 130 }
131 131
132 if( fileName.left(4) == "http" ) { 132 if( fileName.left(4) == "http" ) {
133 if ( xineControl->getMetaInfo().isEmpty() ) { 133 if ( xineControl->getMetaInfo().isEmpty() ) {
134 tickerText = tr( " File: " ) + fileName; 134 tickerText = tr( " File: " ) + fileName;
135 } else { 135 } else {
136 tickerText = xineControl->getMetaInfo(); 136 tickerText = xineControl->getMetaInfo();
137 } 137 }
138 } else { 138 } else {
139 if ( xineControl->getMetaInfo().isEmpty() ) { 139 if ( xineControl->getMetaInfo().isEmpty() ) {
140 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 140 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
141 } else { 141 } else {
142 tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; 142 tickerText = xineControl->getMetaInfo() + " Length: " + time + " ";
143 } 143 }
144 } 144 }
145 audioUI->setTickerText( tickerText ); 145 audioUI->setTickerText( tickerText );
146} 146}
147 147
148 148
149void MediaPlayer::prev() { 149void MediaPlayer::prev() {
150 if( playList->whichList() == 0 ) { //if using the playlist 150 if( playList->whichList() == 0 ) { //if using the playlist
151 if ( playList->prev() ) { 151 if ( playList->prev() ) {
152 play(); 152 play();
153 } else if ( mediaPlayerState->looping() ) { 153 } else if ( mediaPlayerState->isLooping() ) {
154 if ( playList->last() ) { 154 if ( playList->last() ) {
155 play(); 155 play();
156 } 156 }
157 } else { 157 } else {
158 mediaPlayerState->setList(); 158 mediaPlayerState->setList();
159 } 159 }
160 } 160 }
161} 161}
162 162
163 163
164void MediaPlayer::next() { 164void MediaPlayer::next() {
165 165
166 if(playList->whichList() == 0) { //if using the playlist 166 if(playList->whichList() == 0) { //if using the playlist
167 if ( playList->next() ) { 167 if ( playList->next() ) {
168 play(); 168 play();
169 } else if ( mediaPlayerState->looping() ) { 169 } else if ( mediaPlayerState->isLooping() ) {
170 if ( playList->first() ) { 170 if ( playList->first() ) {
171 play(); 171 play();
172 } 172 }
173 } else { 173 } else {
174 mediaPlayerState->setList(); 174 mediaPlayerState->setList();
175 } 175 }
176 } else { //if playing from file list, let's just stop 176 } else { //if playing from file list, let's just stop
177 qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); 177 qDebug("<<<<<<<<<<<<<<<<<stop for filelists");
178 mediaPlayerState->setPlaying(false); 178 mediaPlayerState->setPlaying(false);
179 mediaPlayerState->setView('l'); 179 mediaPlayerState->setView('l');
180 if(l) mediaPlayerState->setLooping(l); 180 if(l) mediaPlayerState->setLooping(l);
181 if(r) mediaPlayerState->setShuffled(r); 181 if(r) mediaPlayerState->setShuffled(r);
182 } 182 }
183 qApp->processEvents(); 183 qApp->processEvents();
184} 184}
185 185
186 186
187void MediaPlayer::startDecreasingVolume() { 187void MediaPlayer::startDecreasingVolume() {
188 volumeDirection = -1; 188 volumeDirection = -1;
189 startTimer( 100 ); 189 startTimer( 100 );
190 volControl->decVol(2); 190 volControl->decVol(2);
191} 191}
192 192
193 193
194void MediaPlayer::startIncreasingVolume() { 194void MediaPlayer::startIncreasingVolume() {
195 volumeDirection = +1; 195 volumeDirection = +1;
196 startTimer( 100 ); 196 startTimer( 100 );
197 volControl->incVol(2); 197 volControl->incVol(2);
198} 198}
199 199
200 200
201bool drawnOnScreenDisplay = FALSE; 201bool drawnOnScreenDisplay = FALSE;
202unsigned int onScreenDisplayVolume = 0; 202unsigned int onScreenDisplayVolume = 0;
203const int yoff = 110; 203const int yoff = 110;
204 204
205void MediaPlayer::stopChangingVolume() { 205void MediaPlayer::stopChangingVolume() {
206 killTimers(); 206 killTimers();
207 // Get rid of the on-screen display stuff 207 // Get rid of the on-screen display stuff
208 drawnOnScreenDisplay = FALSE; 208 drawnOnScreenDisplay = FALSE;
209 onScreenDisplayVolume = 0; 209 onScreenDisplayVolume = 0;
210 int w=0; 210 int w=0;
211 int h=0; 211 int h=0;
212 if( !xineControl->hasVideo() ) { 212 if( !xineControl->hasVideo() ) {
213 w = audioUI->width(); 213 w = audioUI->width();
214 h = audioUI->height(); 214 h = audioUI->height();
215 audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 215 audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
216 } else { 216 } else {
217 w = videoUI->width(); 217 w = videoUI->width();
218 h = videoUI->height(); 218 h = videoUI->height();
219 videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 219 videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
220 } 220 }
221} 221}
222 222
223 223
224void MediaPlayer::timerEvent( QTimerEvent * ) { 224void MediaPlayer::timerEvent( QTimerEvent * ) {
225 if ( volumeDirection == +1 ) { 225 if ( volumeDirection == +1 ) {
226 volControl->incVol( 2 ); 226 volControl->incVol( 2 );
227 } else if ( volumeDirection == -1 ) { 227 } else if ( volumeDirection == -1 ) {
228 volControl->decVol( 2 ); 228 volControl->decVol( 2 );
229 } 229 }
230 230
231 231
232 // TODO FIXME 232 // TODO FIXME
233 // huh?? 233 // huh??
234 unsigned int v= 0; 234 unsigned int v= 0;
235 v = volControl->volume(); 235 v = volControl->volume();
236 v = v / 10; 236 v = v / 10;
237 237
238 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 238 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
239 return; 239 return;
240 } 240 }
241 241
242 int w=0; int h=0; 242 int w=0; int h=0;
243 if( !xineControl->hasVideo() ) { 243 if( !xineControl->hasVideo() ) {
244 w = audioUI->width(); 244 w = audioUI->width();
245 h = audioUI->height(); 245 h = audioUI->height();
246 246
247 if ( drawnOnScreenDisplay ) { 247 if ( drawnOnScreenDisplay ) {
248 if ( onScreenDisplayVolume > v ) { 248 if ( onScreenDisplayVolume > v ) {
249 audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 249 audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
250 } 250 }
251 } 251 }
252 drawnOnScreenDisplay = TRUE; 252 drawnOnScreenDisplay = TRUE;
253 onScreenDisplayVolume = v; 253 onScreenDisplayVolume = v;
254 QPainter p( audioUI ); 254 QPainter p( audioUI );
255 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 255 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
256 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 256 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
257 257
258 QFont f; 258 QFont f;
259 f.setPixelSize( 20 ); 259 f.setPixelSize( 20 );
260 f.setBold( TRUE ); 260 f.setBold( TRUE );
261 p.setFont( f ); 261 p.setFont( f );
262 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 262 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
263 263
264 for ( unsigned int i = 0; i < 10; i++ ) { 264 for ( unsigned int i = 0; i < 10; i++ ) {
265 if ( v > i ) { 265 if ( v > i ) {
266 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 266 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
267 } else { 267 } else {
268 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 268 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
269 } 269 }
270 } 270 }
271 } else { 271 } else {
272 w = videoUI->width(); 272 w = videoUI->width();
273 h = videoUI->height(); 273 h = videoUI->height();
274 274
275 if ( drawnOnScreenDisplay ) { 275 if ( drawnOnScreenDisplay ) {
276 if ( onScreenDisplayVolume > v ) { 276 if ( onScreenDisplayVolume > v ) {
277 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 277 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
278 } 278 }
279 } 279 }
280 drawnOnScreenDisplay = TRUE; 280 drawnOnScreenDisplay = TRUE;
281 onScreenDisplayVolume = v; 281 onScreenDisplayVolume = v;
282 QPainter p( videoUI ); 282 QPainter p( videoUI );
283 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 283 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
284 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 284 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
285 285
286 QFont f; 286 QFont f;
287 f.setPixelSize( 20 ); 287 f.setPixelSize( 20 );
288 f.setBold( TRUE ); 288 f.setBold( TRUE );
289 p.setFont( f ); 289 p.setFont( f );
290 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 290 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
291 291
292 for ( unsigned int i = 0; i < 10; i++ ) { 292 for ( unsigned int i = 0; i < 10; i++ ) {
293 if ( v > i ) { 293 if ( v > i ) {
294 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 294 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
295 } else { 295 } else {
296 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 296 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
297 } 297 }
298 } 298 }
299 } 299 }
300} 300}
301 301
302 302
303void MediaPlayer::blank( bool b ) { 303void MediaPlayer::blank( bool b ) {
304 fd=open("/dev/fb0",O_RDWR); 304 fd=open("/dev/fb0",O_RDWR);
305#ifdef QT_QWS_EBX 305#ifdef QT_QWS_EBX
306 fl= open( "/dev/fl", O_RDWR ); 306 fl= open( "/dev/fl", O_RDWR );
307#endif 307#endif
308 if (fd != -1) { 308 if (fd != -1) {
309 if ( b ) { 309 if ( b ) {
310 qDebug("do blanking"); 310 qDebug("do blanking");
311#ifdef QT_QWS_EBX 311#ifdef QT_QWS_EBX
312 ioctl( fd, FBIOBLANK, 1 ); 312 ioctl( fd, FBIOBLANK, 1 );
313 if(fl !=-1) { 313 if(fl !=-1) {
314 ioctl( fl, 2 ); 314 ioctl( fl, 2 );
315 ::close(fl); 315 ::close(fl);
316 } 316 }
317#else 317#else
318 ioctl( fd, FBIOBLANK, 3 ); 318 ioctl( fd, FBIOBLANK, 3 );
319#endif 319#endif
320 isBlanked = TRUE; 320 isBlanked = TRUE;
321 } else { 321 } else {
322 qDebug("do unblanking"); 322 qDebug("do unblanking");
323 ioctl( fd, FBIOBLANK, 0); 323 ioctl( fd, FBIOBLANK, 0);
324#ifdef QT_QWS_EBX 324#ifdef QT_QWS_EBX
325 if(fl != -1) { 325 if(fl != -1) {
326 ioctl( fl, 1); 326 ioctl( fl, 1);
327 ::close(fl); 327 ::close(fl);
328 } 328 }
329#endif 329#endif
330 isBlanked = FALSE; 330 isBlanked = FALSE;
331 } 331 }
332 close( fd ); 332 close( fd );
333 } else { 333 } else {
334 qDebug("<< /dev/fb0 could not be opened >>"); 334 qDebug("<< /dev/fb0 could not be opened >>");
335 } 335 }
336} 336}
337 337
338void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 338void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
339 switch ( e->key() ) { 339 switch ( e->key() ) {
340////////////////////////////// Zaurus keys 340////////////////////////////// Zaurus keys
341 case Key_Home: 341 case Key_Home:
342 break; 342 break;
343 case Key_F9: //activity 343 case Key_F9: //activity
344 break; 344 break;
345 case Key_F10: //contacts 345 case Key_F10: //contacts
346 break; 346 break;
347 case Key_F11: //menu 347 case Key_F11: //menu
348 break; 348 break;
349 case Key_F12: //home 349 case Key_F12: //home
350 qDebug("Blank here"); 350 qDebug("Blank here");
351// mediaPlayerState->toggleBlank(); 351// mediaPlayerState->toggleBlank();
352 break; 352 break;
353 case Key_F13: //mail 353 case Key_F13: //mail
354 qDebug("Blank here"); 354 qDebug("Blank here");
355 // mediaPlayerState->toggleBlank(); 355 // mediaPlayerState->toggleBlank();
356 break; 356 break;
357 } 357 }
358} 358}
359 359
360void MediaPlayer::cleanUp() {// this happens on closing 360void MediaPlayer::cleanUp() {// this happens on closing
361 Config cfg( "OpiePlayer" ); 361 Config cfg( "OpiePlayer" );
362 mediaPlayerState->writeConfig( cfg ); 362 mediaPlayerState->writeConfig( cfg );
363 playList->writeDefaultPlaylist( ); 363 playList->writeDefaultPlaylist( );
364 364
365// QPEApplication::grabKeyboard(); 365// QPEApplication::grabKeyboard();
366// QPEApplication::ungrabKeyboard(); 366// QPEApplication::ungrabKeyboard();
367} 367}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index a80d8fd..85d9bac 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,338 +1,338 @@
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// this file is based on work by trolltech 34// this file is based on work by trolltech
35 35
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37#include <qpe/qlibrary.h> 37#include <qpe/qlibrary.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <qvaluelist.h> 39#include <qvaluelist.h>
40#include <qobject.h> 40#include <qobject.h>
41#include <qdir.h> 41#include <qdir.h>
42#include "mediaplayerstate.h" 42#include "mediaplayerstate.h"
43 43
44 44
45 45
46//#define MediaPlayerDebug(x) qDebug x 46//#define MediaPlayerDebug(x) qDebug x
47#define MediaPlayerDebug(x) 47#define MediaPlayerDebug(x)
48 48
49 49
50MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 50MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
51 : QObject( parent, name ) { 51 : QObject( parent, name ) {
52 Config cfg( "OpiePlayer" ); 52 Config cfg( "OpiePlayer" );
53 readConfig( cfg ); 53 readConfig( cfg );
54 isStreaming = false; 54 streaming = false;
55 isSeekable = true; 55 seekable = true;
56} 56}
57 57
58 58
59MediaPlayerState::~MediaPlayerState() { 59MediaPlayerState::~MediaPlayerState() {
60} 60}
61 61
62 62
63void MediaPlayerState::readConfig( Config& cfg ) { 63void MediaPlayerState::readConfig( Config& cfg ) {
64 cfg.setGroup("Options"); 64 cfg.setGroup("Options");
65 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 65 fullscreen = cfg.readBoolEntry( "FullScreen" );
66 isScaled = cfg.readBoolEntry( "Scaling" ); 66 scaled = cfg.readBoolEntry( "Scaling" );
67 isLooping = cfg.readBoolEntry( "Looping" ); 67 looping = cfg.readBoolEntry( "Looping" );
68 isShuffled = cfg.readBoolEntry( "Shuffle" ); 68 shuffled = cfg.readBoolEntry( "Shuffle" );
69 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 69 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
70 videoGamma = cfg.readNumEntry( "VideoGamma" ); 70 videoGamma = cfg.readNumEntry( "VideoGamma" );
71 usePlaylist = TRUE; 71 usePlaylist = TRUE;
72 isPlaying = FALSE; 72 playing = FALSE;
73 isStreaming = FALSE; 73 streaming = FALSE;
74 isPaused = FALSE; 74 paused = FALSE;
75 curPosition = 0; 75 curPosition = 0;
76 curLength = 0; 76 curLength = 0;
77 curView = 'l'; 77 curView = 'l';
78} 78}
79 79
80 80
81void MediaPlayerState::writeConfig( Config& cfg ) const { 81void MediaPlayerState::writeConfig( Config& cfg ) const {
82 cfg.setGroup( "Options" ); 82 cfg.setGroup( "Options" );
83 cfg.writeEntry( "FullScreen", isFullscreen ); 83 cfg.writeEntry( "FullScreen", fullscreen );
84 cfg.writeEntry( "Scaling", isScaled ); 84 cfg.writeEntry( "Scaling", scaled );
85 cfg.writeEntry( "Looping", isLooping ); 85 cfg.writeEntry( "Looping", looping );
86 cfg.writeEntry( "Shuffle", isShuffled ); 86 cfg.writeEntry( "Shuffle", shuffled );
87 cfg.writeEntry( "UsePlayList", usePlaylist ); 87 cfg.writeEntry( "UsePlayList", usePlaylist );
88 cfg.writeEntry( "VideoGamma", videoGamma ); 88 cfg.writeEntry( "VideoGamma", videoGamma );
89} 89}
90 90
91 91
92// public stuff 92// public stuff
93 93
94 94
95bool MediaPlayerState::streaming() const { 95bool MediaPlayerState::isStreaming() const {
96 return isStreaming; 96 return streaming;
97} 97}
98 98
99bool MediaPlayerState::seekable() const { 99bool MediaPlayerState::isSeekable() const {
100 return isSeekable; 100 return seekable;
101} 101}
102 102
103bool MediaPlayerState::fullscreen() const { 103bool MediaPlayerState::isFullscreen() const {
104 return isFullscreen; 104 return fullscreen;
105} 105}
106 106
107bool MediaPlayerState::scaled() const { 107bool MediaPlayerState::isScaled() const {
108 return isScaled; 108 return scaled;
109} 109}
110 110
111bool MediaPlayerState::looping() const { 111bool MediaPlayerState::isLooping() const {
112 return isLooping; 112 return looping;
113} 113}
114 114
115bool MediaPlayerState::shuffled() const { 115bool MediaPlayerState::isShuffled() const {
116 return isShuffled; 116 return shuffled;
117} 117}
118 118
119 119
120bool MediaPlayerState::playlist() const { 120bool MediaPlayerState::isUsingPlaylist() const {
121 return usePlaylist; 121 return usePlaylist;
122} 122}
123 123
124bool MediaPlayerState::paused() const { 124bool MediaPlayerState::isPaused() const {
125 return isPaused; 125 return paused;
126} 126}
127 127
128bool MediaPlayerState::playing() const { 128bool MediaPlayerState::isPlaying() const {
129 return isPlaying; 129 return playing;
130} 130}
131 131
132bool MediaPlayerState::stop() const { 132bool MediaPlayerState::isStop() const {
133 return isStoped; 133 return stoped;
134} 134}
135 135
136long MediaPlayerState::position() const { 136long MediaPlayerState::position() const {
137 return curPosition; 137 return curPosition;
138} 138}
139 139
140long MediaPlayerState::length() const { 140long MediaPlayerState::length() const {
141 return curLength; 141 return curLength;
142} 142}
143 143
144char MediaPlayerState::view() const { 144char MediaPlayerState::view() const {
145 return curView; 145 return curView;
146} 146}
147 147
148// slots 148// slots
149void MediaPlayerState::setIsStreaming( bool b ) { 149void MediaPlayerState::setIsStreaming( bool b ) {
150 150
151 if ( isStreaming == b ) { 151 if ( streaming == b ) {
152 return; 152 return;
153 } 153 }
154 isStreaming = b; 154 streaming = b;
155} 155}
156 156
157void MediaPlayerState::setIsSeekable( bool b ) { 157void MediaPlayerState::setIsSeekable( bool b ) {
158 158
159 //if ( isSeekable == b ) { 159 //if ( isSeekable == b ) {
160 // return; 160 // return;
161 // } 161 // }
162 isSeekable = b; 162 seekable = b;
163 emit isSeekableToggled(b); 163 emit isSeekableToggled(b);
164} 164}
165 165
166 166
167void MediaPlayerState::setFullscreen( bool b ) { 167void MediaPlayerState::setFullscreen( bool b ) {
168 if ( isFullscreen == b ) { 168 if ( fullscreen == b ) {
169 return; 169 return;
170 } 170 }
171 isFullscreen = b; 171 fullscreen = b;
172 emit fullscreenToggled(b); 172 emit fullscreenToggled(b);
173} 173}
174 174
175 175
176void MediaPlayerState::setBlanked( bool b ) { 176void MediaPlayerState::setBlanked( bool b ) {
177 if ( isBlanked == b ) { 177 if ( blanked == b ) {
178 return; 178 return;
179 } 179 }
180 isBlanked = b; 180 blanked = b;
181 emit blankToggled(b); 181 emit blankToggled(b);
182} 182}
183 183
184 184
185void MediaPlayerState::setScaled( bool b ) { 185void MediaPlayerState::setScaled( bool b ) {
186 if ( isScaled == b ) { 186 if ( scaled == b ) {
187 return; 187 return;
188 } 188 }
189 isScaled = b; 189 scaled = b;
190 emit scaledToggled(b); 190 emit scaledToggled(b);
191} 191}
192 192
193void MediaPlayerState::setLooping( bool b ) { 193void MediaPlayerState::setLooping( bool b ) {
194 if ( isLooping == b ) { 194 if ( looping == b ) {
195 return; 195 return;
196 } 196 }
197 isLooping = b; 197 looping = b;
198 emit loopingToggled(b); 198 emit loopingToggled(b);
199} 199}
200 200
201void MediaPlayerState::setShuffled( bool b ) { 201void MediaPlayerState::setShuffled( bool b ) {
202 if ( isShuffled == b ) { 202 if ( shuffled == b ) {
203 return; 203 return;
204 } 204 }
205 isShuffled = b; 205 shuffled = b;
206 emit shuffledToggled(b); 206 emit shuffledToggled(b);
207} 207}
208 208
209void MediaPlayerState::setPlaylist( bool b ) { 209void MediaPlayerState::setPlaylist( bool b ) {
210 if ( usePlaylist == b ) { 210 if ( usePlaylist == b ) {
211 return; 211 return;
212 } 212 }
213 usePlaylist = b; 213 usePlaylist = b;
214 emit playlistToggled(b); 214 emit playlistToggled(b);
215} 215}
216 216
217void MediaPlayerState::setPaused( bool b ) { 217void MediaPlayerState::setPaused( bool b ) {
218 if ( isPaused == b ) { 218 if ( paused == b ) {
219 isPaused = FALSE; 219 paused = FALSE;
220 emit pausedToggled(FALSE); 220 emit pausedToggled(FALSE);
221 return; 221 return;
222 } 222 }
223 isPaused = b; 223 paused = b;
224 emit pausedToggled(b); 224 emit pausedToggled(b);
225} 225}
226 226
227void MediaPlayerState::setPlaying( bool b ) { 227void MediaPlayerState::setPlaying( bool b ) {
228 if ( isPlaying == b ) { 228 if ( playing == b ) {
229 return; 229 return;
230 } 230 }
231 isPlaying = b; 231 playing = b;
232 isStoped = !b; 232 stoped = !b;
233 emit playingToggled(b); 233 emit playingToggled(b);
234} 234}
235 235
236void MediaPlayerState::setStop( bool b ) { 236void MediaPlayerState::setStop( bool b ) {
237 if ( isStoped == b ) { 237 if ( stoped == b ) {
238 return; 238 return;
239 } 239 }
240 isStoped = b; 240 stoped = b;
241 emit stopToggled(b); 241 emit stopToggled(b);
242} 242}
243 243
244void MediaPlayerState::setPosition( long p ) { 244void MediaPlayerState::setPosition( long p ) {
245 if ( curPosition == p ) { 245 if ( curPosition == p ) {
246 return; 246 return;
247 } 247 }
248 curPosition = p; 248 curPosition = p;
249 emit positionChanged(p); 249 emit positionChanged(p);
250} 250}
251 251
252void MediaPlayerState::updatePosition( long p ){ 252void MediaPlayerState::updatePosition( long p ){
253 if ( curPosition == p ) { 253 if ( curPosition == p ) {
254 return; 254 return;
255 } 255 }
256 curPosition = p; 256 curPosition = p;
257 emit positionUpdated(p); 257 emit positionUpdated(p);
258} 258}
259 259
260void MediaPlayerState::setVideoGamma( int v ){ 260void MediaPlayerState::setVideoGamma( int v ){
261 if ( videoGamma == v ) { 261 if ( videoGamma == v ) {
262 return; 262 return;
263 } 263 }
264 videoGamma = v; 264 videoGamma = v;
265 emit videoGammaChanged( v ); 265 emit videoGammaChanged( v );
266} 266}
267 267
268void MediaPlayerState::setLength( long l ) { 268void MediaPlayerState::setLength( long l ) {
269 if ( curLength == l ) { 269 if ( curLength == l ) {
270 return; 270 return;
271 } 271 }
272 curLength = l; 272 curLength = l;
273 emit lengthChanged(l); 273 emit lengthChanged(l);
274} 274}
275 275
276void MediaPlayerState::setView( char v ) { 276void MediaPlayerState::setView( char v ) {
277 if ( curView == v ) { 277 if ( curView == v ) {
278 return; 278 return;
279 } 279 }
280 curView = v; 280 curView = v;
281 emit viewChanged(v); 281 emit viewChanged(v);
282} 282}
283 283
284void MediaPlayerState::setPrev(){ 284void MediaPlayerState::setPrev(){
285 emit prev(); 285 emit prev();
286} 286}
287 287
288void MediaPlayerState::setNext() { 288void MediaPlayerState::setNext() {
289 emit next(); 289 emit next();
290} 290}
291 291
292void MediaPlayerState::setList() { 292void MediaPlayerState::setList() {
293 setPlaying( FALSE ); 293 setPlaying( FALSE );
294 setView('l'); 294 setView('l');
295} 295}
296 296
297void MediaPlayerState::setVideo() { 297void MediaPlayerState::setVideo() {
298 setView('v'); 298 setView('v');
299} 299}
300 300
301void MediaPlayerState::setAudio() { 301void MediaPlayerState::setAudio() {
302 setView('a'); 302 setView('a');
303} 303}
304 304
305void MediaPlayerState::toggleFullscreen() { 305void MediaPlayerState::toggleFullscreen() {
306 setFullscreen( !isFullscreen ); 306 setFullscreen( !fullscreen );
307} 307}
308 308
309void MediaPlayerState::toggleScaled() { 309void MediaPlayerState::toggleScaled() {
310 setScaled( !isScaled); 310 setScaled( !scaled);
311} 311}
312 312
313void MediaPlayerState::toggleLooping() { 313void MediaPlayerState::toggleLooping() {
314 setLooping( !isLooping); 314 setLooping( !looping);
315} 315}
316 316
317void MediaPlayerState::toggleShuffled() { 317void MediaPlayerState::toggleShuffled() {
318 setShuffled( !isShuffled); 318 setShuffled( !shuffled);
319} 319}
320 320
321void MediaPlayerState::togglePlaylist() { 321void MediaPlayerState::togglePlaylist() {
322 setPlaylist( !usePlaylist); 322 setPlaylist( !usePlaylist);
323} 323}
324 324
325void MediaPlayerState::togglePaused() { 325void MediaPlayerState::togglePaused() {
326 setPaused( !isPaused); 326 setPaused( !paused);
327} 327}
328 328
329void MediaPlayerState::togglePlaying() { 329void MediaPlayerState::togglePlaying() {
330 setPlaying( !isPlaying); 330 setPlaying( !playing);
331} 331}
332 332
333void MediaPlayerState::toggleBlank() { 333void MediaPlayerState::toggleBlank() {
334 setBlanked( !isBlanked); 334 setBlanked( !blanked);
335} 335}
336 336
337 337
338 338
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index f9c1eeb..4e837e3 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,143 +1,143 @@
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// this file is based on work by trolltech 34// this file is based on work by trolltech
35 35
36#ifndef MEDIA_PLAYER_STATE_H 36#ifndef MEDIA_PLAYER_STATE_H
37#define MEDIA_PLAYER_STATE_H 37#define MEDIA_PLAYER_STATE_H
38 38
39 39
40#include <qobject.h> 40#include <qobject.h>
41 41
42 42
43class MediaPlayerDecoder; 43class MediaPlayerDecoder;
44class Config; 44class Config;
45 45
46 46
47class MediaPlayerState : public QObject { 47class MediaPlayerState : public QObject {
48Q_OBJECT 48Q_OBJECT
49public: 49public:
50 MediaPlayerState( QObject *parent, const char *name ); 50 MediaPlayerState( QObject *parent, const char *name );
51 ~MediaPlayerState(); 51 ~MediaPlayerState();
52 52
53 bool streaming() const; 53 bool isStreaming() const;
54 bool seekable() const; 54 bool isSeekable() const;
55 bool fullscreen() const; 55 bool isFullscreen() const;
56 bool scaled() const; 56 bool isScaled() const;
57 bool looping() const; 57 bool isLooping() const;
58 bool shuffled() const; 58 bool isShuffled() const;
59 bool playlist() const; 59 bool isUsingPlaylist() const;
60 bool paused() const; 60 bool isPaused() const;
61 bool playing() const; 61 bool isPlaying() const;
62 bool stop() const; 62 bool isStop() const;
63 long position() const; 63 long position() const;
64 long length() const; 64 long length() const;
65 char view() const; 65 char view() const;
66 66
67public slots: 67public slots:
68 void setIsStreaming( bool b ); 68 void setIsStreaming( bool b );
69 void setIsSeekable( bool b ); 69 void setIsSeekable( bool b );
70 void setFullscreen( bool b ); 70 void setFullscreen( bool b );
71 void setScaled( bool b ); 71 void setScaled( bool b );
72 void setLooping( bool b ); 72 void setLooping( bool b );
73 void setShuffled( bool b ); 73 void setShuffled( bool b );
74 void setPlaylist( bool b ); 74 void setPlaylist( bool b );
75 void setPaused( bool b ); 75 void setPaused( bool b );
76 void setPlaying( bool b ); 76 void setPlaying( bool b );
77 void setStop( bool b ); 77 void setStop( bool b );
78 void setPosition( long p ); 78 void setPosition( long p );
79 void updatePosition( long p ); 79 void updatePosition( long p );
80 void setLength( long l ); 80 void setLength( long l );
81 void setView( char v ); 81 void setView( char v );
82 void setBlanked( bool b ); 82 void setBlanked( bool b );
83 void setVideoGamma( int v ); 83 void setVideoGamma( int v );
84 84
85 void setPrev(); 85 void setPrev();
86 void setNext(); 86 void setNext();
87 void setList(); 87 void setList();
88 void setVideo(); 88 void setVideo();
89 void setAudio(); 89 void setAudio();
90 90
91 void toggleFullscreen(); 91 void toggleFullscreen();
92 void toggleScaled(); 92 void toggleScaled();
93 void toggleLooping(); 93 void toggleLooping();
94 void toggleShuffled(); 94 void toggleShuffled();
95 void togglePlaylist(); 95 void togglePlaylist();
96 void togglePaused(); 96 void togglePaused();
97 void togglePlaying(); 97 void togglePlaying();
98 void toggleBlank(); 98 void toggleBlank();
99 void writeConfig( Config& cfg ) const; 99 void writeConfig( Config& cfg ) const;
100 100
101 101
102signals: 102signals:
103 void fullscreenToggled( bool ); 103 void fullscreenToggled( bool );
104 void scaledToggled( bool ); 104 void scaledToggled( bool );
105 void loopingToggled( bool ); 105 void loopingToggled( bool );
106 void shuffledToggled( bool ); 106 void shuffledToggled( bool );
107 void playlistToggled( bool ); 107 void playlistToggled( bool );
108 void pausedToggled( bool ); 108 void pausedToggled( bool );
109 void playingToggled( bool ); 109 void playingToggled( bool );
110 void stopToggled( bool ); 110 void stopToggled( bool );
111 void positionChanged( long ); // When the slider is moved 111 void positionChanged( long ); // When the slider is moved
112 void positionUpdated( long ); // When the media file progresses 112 void positionUpdated( long ); // When the media file progresses
113 void lengthChanged( long ); 113 void lengthChanged( long );
114 void viewChanged( char ); 114 void viewChanged( char );
115 void isSeekableToggled( bool ); 115 void isSeekableToggled( bool );
116 void blankToggled( bool ); 116 void blankToggled( bool );
117 void videoGammaChanged( int ); 117 void videoGammaChanged( int );
118 void prev(); 118 void prev();
119 void next(); 119 void next();
120 120
121private: 121private:
122 bool isStreaming; 122 bool streaming;
123 bool isSeekable; 123 bool seekable;
124 bool isFullscreen; 124 bool fullscreen;
125 bool isScaled; 125 bool scaled;
126 bool isBlanked; 126 bool blanked;
127 bool isLooping; 127 bool looping;
128 bool isShuffled; 128 bool shuffled;
129 bool usePlaylist; 129 bool usePlaylist;
130 bool isPaused; 130 bool paused;
131 bool isPlaying; 131 bool playing;
132 bool isStoped; 132 bool stoped;
133 long curPosition; 133 long curPosition;
134 long curLength; 134 long curLength;
135 char curView; 135 char curView;
136 int videoGamma; 136 int videoGamma;
137 void readConfig( Config& cfg ); 137 void readConfig( Config& cfg );
138 138
139}; 139};
140 140
141 141
142#endif // MEDIA_PLAYER_STATE_H 142#endif // MEDIA_PLAYER_STATE_H
143 143
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 593f072..d1506db 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1158 +1,1158 @@
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 <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdatetime.h> 41#include <qdatetime.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46 46
47#include "playlistselection.h" 47#include "playlistselection.h"
48#include "playlistwidget.h" 48#include "playlistwidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50#include "inputDialog.h" 50#include "inputDialog.h"
51#include "om3u.h" 51#include "om3u.h"
52 52
53//only needed for the random play 53//only needed for the random play
54#include <stdlib.h> 54#include <stdlib.h>
55 55
56#include "audiowidget.h" 56#include "audiowidget.h"
57#include "videowidget.h" 57#include "videowidget.h"
58 58
59extern MediaPlayerState *mediaPlayerState; 59extern MediaPlayerState *mediaPlayerState;
60// extern AudioWidget *audioUI; 60// extern AudioWidget *audioUI;
61// extern VideoWidget *videoUI; 61// extern VideoWidget *videoUI;
62 62
63QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; 63QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
64// no m3u's here please 64// no m3u's here please
65 65
66PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 66PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
67 : PlayListWidgetGui( parent, name, fl ) { 67 : PlayListWidgetGui( parent, name, fl ) {
68 68
69 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 69 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
70 "opieplayer2/add_to_playlist", 70 "opieplayer2/add_to_playlist",
71 this , SLOT(addSelected() ) ); 71 this , SLOT(addSelected() ) );
72 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 72 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
73 "opieplayer2/remove_from_playlist", 73 "opieplayer2/remove_from_playlist",
74 this , SLOT(removeSelected() ) ); 74 this , SLOT(removeSelected() ) );
75 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 75 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
76 this , SLOT( btnPlay( bool) ), TRUE ); 76 this , SLOT( btnPlay( bool) ), TRUE );
77 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 77 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
78 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 78 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
79 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 79 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
80 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 80 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
81 81
82 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 82 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
83 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 83 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
84 this, SLOT( addAllMusicToList() ) ); 84 this, SLOT( addAllMusicToList() ) );
85 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 85 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
86 this, SLOT( addAllVideoToList() ) ); 86 this, SLOT( addAllVideoToList() ) );
87 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 87 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
88 this, SLOT( addAllToList() ) ); 88 this, SLOT( addAllToList() ) );
89 pmPlayList->insertSeparator(-1); 89 pmPlayList->insertSeparator(-1);
90// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 90// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
91// this, SLOT( saveList() ) ); 91// this, SLOT( saveList() ) );
92 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 92 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
93 this, SLOT(writem3u() ) ); 93 this, SLOT(writem3u() ) );
94 pmPlayList->insertSeparator(-1); 94 pmPlayList->insertSeparator(-1);
95 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 95 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
96 this,SLOT( openFile() ) ); 96 this,SLOT( openFile() ) );
97 pmPlayList->insertSeparator(-1); 97 pmPlayList->insertSeparator(-1);
98 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 98 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
99 this,SLOT( scanForAudio() ) ); 99 this,SLOT( scanForAudio() ) );
100 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 100 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
101 this,SLOT( scanForVideo() ) ); 101 this,SLOT( scanForVideo() ) );
102 102
103 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 103 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
104 mediaPlayerState, SLOT( toggleFullscreen() ) ); 104 mediaPlayerState, SLOT( toggleFullscreen() ) );
105 105
106 Config cfg( "OpiePlayer" ); 106 Config cfg( "OpiePlayer" );
107 bool b= cfg.readBoolEntry("FullScreen", 0); 107 bool b= cfg.readBoolEntry("FullScreen", 0);
108 mediaPlayerState->setFullscreen( b ); 108 mediaPlayerState->setFullscreen( b );
109 pmView->setItemChecked( -16, b ); 109 pmView->setItemChecked( -16, b );
110 110
111 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 111 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
112 d->selectedFiles, SLOT(moveSelectedUp() ) ); 112 d->selectedFiles, SLOT(moveSelectedUp() ) );
113 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 113 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
114 d->selectedFiles, SLOT(removeSelected() ) ); 114 d->selectedFiles, SLOT(removeSelected() ) );
115 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 115 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
116 d->selectedFiles, SLOT(moveSelectedDown() ) ); 116 d->selectedFiles, SLOT(moveSelectedDown() ) );
117 // QVBox *stretch2 = new QVBox( vbox1 ); 117 // QVBox *stretch2 = new QVBox( vbox1 );
118 118
119 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 119 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
120 SLOT( deletePlaylist() ) ); 120 SLOT( deletePlaylist() ) );
121 connect( pmView, SIGNAL( activated( int ) ), 121 connect( pmView, SIGNAL( activated( int ) ),
122 this, SLOT( pmViewActivated( int ) ) ); 122 this, SLOT( pmViewActivated( int ) ) );
123 connect( skinsMenu, SIGNAL( activated( int ) ) , 123 connect( skinsMenu, SIGNAL( activated( int ) ) ,
124 this, SLOT( skinsMenuActivated( int ) ) ); 124 this, SLOT( skinsMenuActivated( int ) ) );
125 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 125 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
126 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 126 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
127 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 127 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
128 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 128 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
129 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 129 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
130 this,SLOT( playIt( QListViewItem *) ) ); 130 this,SLOT( playIt( QListViewItem *) ) );
131 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 131 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
132 this, SLOT( addToSelection( QListViewItem *) ) ); 132 this, SLOT( addToSelection( QListViewItem *) ) );
133 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 133 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
134 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 134 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
135 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 135 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
136 this,SLOT( playIt( QListViewItem *) ) ); 136 this,SLOT( playIt( QListViewItem *) ) );
137 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 137 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
138 this, SLOT( addToSelection( QListViewItem *) ) ); 138 this, SLOT( addToSelection( QListViewItem *) ) );
139 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 139 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
140 this, SLOT( loadList( const DocLnk & ) ) ); 140 this, SLOT( loadList( const DocLnk & ) ) );
141 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 141 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
142 this, SLOT( tabChanged( QWidget* ) ) ); 142 this, SLOT( tabChanged( QWidget* ) ) );
143 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), 143 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ),
144 d->tbPlay, SLOT( setOn( bool ) ) ); 144 d->tbPlay, SLOT( setOn( bool ) ) );
145 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 145 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
146 d->tbLoop, SLOT( setOn( bool ) ) ); 146 d->tbLoop, SLOT( setOn( bool ) ) );
147 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 147 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
148 d->tbShuffle, SLOT( setOn( bool ) ) ); 148 d->tbShuffle, SLOT( setOn( bool ) ) );
149 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), 149 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ),
150 this, SLOT( setPlaylist( bool ) ) ); 150 this, SLOT( setPlaylist( bool ) ) );
151 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 151 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
152 this, SLOT( playIt( QListViewItem *) ) ); 152 this, SLOT( playIt( QListViewItem *) ) );
153 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 153 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
154 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 154 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
155 155
156 // see which skins are installed 156 // see which skins are installed
157 videoScan=false; 157 videoScan=false;
158 audioScan=false; 158 audioScan=false;
159 audioPopulated=false; 159 audioPopulated=false;
160 videoPopulated=false; 160 videoPopulated=false;
161 populateSkinsMenu(); 161 populateSkinsMenu();
162 initializeStates(); 162 initializeStates();
163 163
164 cfg.setGroup("PlayList"); 164 cfg.setGroup("PlayList");
165 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 165 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
166 loadList(DocLnk( currentPlaylist ) ); 166 loadList(DocLnk( currentPlaylist ) );
167} 167}
168 168
169 169
170PlayListWidget::~PlayListWidget() { 170PlayListWidget::~PlayListWidget() {
171 if ( d->current ) { 171 if ( d->current ) {
172 delete d->current; 172 delete d->current;
173 } 173 }
174 delete d; 174 delete d;
175} 175}
176 176
177 177
178void PlayListWidget::initializeStates() { 178void PlayListWidget::initializeStates() {
179 d->tbPlay->setOn( mediaPlayerState->playing() ); 179 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
180 d->tbLoop->setOn( mediaPlayerState->looping() ); 180 d->tbLoop->setOn( mediaPlayerState->isLooping() );
181 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 181 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
182 setPlaylist( true ); 182 setPlaylist( true );
183} 183}
184 184
185void PlayListWidget::writeDefaultPlaylist() { 185void PlayListWidget::writeDefaultPlaylist() {
186 186
187 Config config( "OpiePlayer" ); 187 Config config( "OpiePlayer" );
188 config.setGroup( "PlayList" ); 188 config.setGroup( "PlayList" );
189 QString filename=QPEApplication::documentDir() + "/default.m3u"; 189 QString filename=QPEApplication::documentDir() + "/default.m3u";
190 QString currentString = config.readEntry( "CurrentPlaylist", filename); 190 QString currentString = config.readEntry( "CurrentPlaylist", filename);
191 if( currentString == filename) { 191 if( currentString == filename) {
192 Om3u *m3uList; 192 Om3u *m3uList;
193 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 193 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
194 if( d->selectedFiles->first() ) { 194 if( d->selectedFiles->first() ) {
195 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 195 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
196 do { 196 do {
197 // qDebug(d->selectedFiles->current()->file()); 197 // qDebug(d->selectedFiles->current()->file());
198 m3uList->add( d->selectedFiles->current()->file() ); 198 m3uList->add( d->selectedFiles->current()->file() );
199 } 199 }
200 while ( d->selectedFiles->next() ); 200 while ( d->selectedFiles->next() );
201 201
202 m3uList->write(); 202 m3uList->write();
203 m3uList->close(); 203 m3uList->close();
204 if(m3uList) delete m3uList; 204 if(m3uList) delete m3uList;
205 205
206 } 206 }
207 } 207 }
208} 208}
209 209
210void PlayListWidget::addToSelection( const DocLnk& lnk ) { 210void PlayListWidget::addToSelection( const DocLnk& lnk ) {
211 d->setDocumentUsed = FALSE; 211 d->setDocumentUsed = FALSE;
212 if ( mediaPlayerState->playlist() ) { 212 if ( mediaPlayerState->isUsingPlaylist() ) {
213 if( QFileInfo( lnk.file() ).exists() || 213 if( QFileInfo( lnk.file() ).exists() ||
214 lnk.file().left(4) == "http" ) { 214 lnk.file().left(4) == "http" ) {
215 d->selectedFiles->addToSelection( lnk ); 215 d->selectedFiles->addToSelection( lnk );
216 } 216 }
217// writeCurrentM3u(); 217// writeCurrentM3u();
218 } 218 }
219 else 219 else
220 mediaPlayerState->setPlaying( TRUE ); 220 mediaPlayerState->setPlaying( TRUE );
221} 221}
222 222
223 223
224void PlayListWidget::clearList() { 224void PlayListWidget::clearList() {
225 while ( first() ) { 225 while ( first() ) {
226 d->selectedFiles->removeSelected(); 226 d->selectedFiles->removeSelected();
227 } 227 }
228} 228}
229 229
230void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 230void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
231 switch (mouse) { 231 switch (mouse) {
232 case 1: 232 case 1:
233 break; 233 break;
234 case 2: 234 case 2:
235 { 235 {
236 QPopupMenu m; 236 QPopupMenu m;
237 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 237 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
238 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 238 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
239 m.exec( QCursor::pos() ); 239 m.exec( QCursor::pos() );
240 } 240 }
241 break; 241 break;
242 } 242 }
243} 243}
244 244
245 245
246void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 246void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
247 switch (mouse) { 247 switch (mouse) {
248 case 1: 248 case 1:
249 break; 249 break;
250 case 2: 250 case 2:
251 { 251 {
252 QPopupMenu m; 252 QPopupMenu m;
253 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 253 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
254 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 254 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
255 m.exec( QCursor::pos() ); 255 m.exec( QCursor::pos() );
256 } 256 }
257 break; 257 break;
258 } 258 }
259} 259}
260 260
261 261
262void PlayListWidget::addAllToList() { 262void PlayListWidget::addAllToList() {
263 263
264// QTime t; 264// QTime t;
265// t.start(); 265// t.start();
266 266
267 if(!audioScan) { 267 if(!audioScan) {
268 if(audioView->childCount() < 1) 268 if(audioView->childCount() < 1)
269 populateAudioView(); 269 populateAudioView();
270 } 270 }
271 271
272 QListViewItemIterator audioIt( audioView ); 272 QListViewItemIterator audioIt( audioView );
273 DocLnk lnk; 273 DocLnk lnk;
274 QString filename; 274 QString filename;
275 // iterate through all items of the listview 275 // iterate through all items of the listview
276 for ( ; audioIt.current(); ++audioIt ) { 276 for ( ; audioIt.current(); ++audioIt ) {
277 filename = audioIt.current()->text(3); 277 filename = audioIt.current()->text(3);
278 lnk.setName( QFileInfo(filename).baseName() ); //sets name 278 lnk.setName( QFileInfo(filename).baseName() ); //sets name
279 lnk.setFile( filename ); //sets file name 279 lnk.setFile( filename ); //sets file name
280 d->selectedFiles->addToSelection( lnk); 280 d->selectedFiles->addToSelection( lnk);
281 } 281 }
282 282
283 if(!videoScan) { 283 if(!videoScan) {
284 if(videoView->childCount() < 1) 284 if(videoView->childCount() < 1)
285 populateVideoView(); 285 populateVideoView();
286 } 286 }
287 287
288 QListViewItemIterator videoIt( videoView ); 288 QListViewItemIterator videoIt( videoView );
289 for ( ; videoIt.current(); ++videoIt ) { 289 for ( ; videoIt.current(); ++videoIt ) {
290 filename = videoIt.current()->text(3); 290 filename = videoIt.current()->text(3);
291 lnk.setName( QFileInfo(filename).baseName() ); //sets name 291 lnk.setName( QFileInfo(filename).baseName() ); //sets name
292 lnk.setFile( filename ); //sets file name 292 lnk.setFile( filename ); //sets file name
293 d->selectedFiles->addToSelection( lnk); 293 d->selectedFiles->addToSelection( lnk);
294 } 294 }
295 295
296 // d->selectedFiles->addToSelection( ); 296 // d->selectedFiles->addToSelection( );
297 // if ( it.current()->isSelected() ) 297 // if ( it.current()->isSelected() )
298 // lst->append( audioIt.current() ); 298 // lst->append( audioIt.current() );
299 // } 299 // }
300 300
301 301
302// if(!audioScan) 302// if(!audioScan)
303// scanForAudio(); 303// scanForAudio();
304// if(!videoScan) 304// if(!videoScan)
305// scanForVideo(); 305// scanForVideo();
306 306
307// DocLnkSet filesAll; 307// DocLnkSet filesAll;
308// Global::findDocuments(&filesAll, "video/*;"+audioMimes); 308// Global::findDocuments(&filesAll, "video/*;"+audioMimes);
309// QListIterator<DocLnk> Adit( filesAll.children() ); 309// QListIterator<DocLnk> Adit( filesAll.children() );
310// for ( ; Adit.current(); ++Adit ) { 310// for ( ; Adit.current(); ++Adit ) {
311// if( QFileInfo( Adit.current()->file() ).exists() ) { 311// if( QFileInfo( Adit.current()->file() ).exists() ) {
312// d->selectedFiles->addToSelection( **Adit ); 312// d->selectedFiles->addToSelection( **Adit );
313// } 313// }
314// } 314// }
315 315
316 // qDebug("elapsed time %d", t.elapsed() ); 316 // qDebug("elapsed time %d", t.elapsed() );
317 317
318 tabWidget->setCurrentPage(0); 318 tabWidget->setCurrentPage(0);
319 319
320 writeCurrentM3u(); 320 writeCurrentM3u();
321 d->selectedFiles->first(); 321 d->selectedFiles->first();
322} 322}
323 323
324 324
325void PlayListWidget::addAllMusicToList() { 325void PlayListWidget::addAllMusicToList() {
326 326
327 if(!audioScan) { 327 if(!audioScan) {
328 if(audioView->childCount() < 1) 328 if(audioView->childCount() < 1)
329 populateAudioView(); 329 populateAudioView();
330 } 330 }
331 331
332 QListViewItemIterator audioIt( audioView ); 332 QListViewItemIterator audioIt( audioView );
333 DocLnk lnk; 333 DocLnk lnk;
334 QString filename; 334 QString filename;
335 // iterate through all items of the listview 335 // iterate through all items of the listview
336 for ( ; audioIt.current(); ++audioIt ) { 336 for ( ; audioIt.current(); ++audioIt ) {
337 filename = audioIt.current()->text(3); 337 filename = audioIt.current()->text(3);
338 lnk.setName( QFileInfo(filename).baseName() ); //sets name 338 lnk.setName( QFileInfo(filename).baseName() ); //sets name
339 lnk.setFile( filename ); //sets file name 339 lnk.setFile( filename ); //sets file name
340 d->selectedFiles->addToSelection( lnk); 340 d->selectedFiles->addToSelection( lnk);
341 } 341 }
342 342
343 /* if(!audioScan) 343 /* if(!audioScan)
344 scanForAudio(); 344 scanForAudio();
345 QListIterator<DocLnk> dit( files.children() ); 345 QListIterator<DocLnk> dit( files.children() );
346 for ( ; dit.current(); ++dit ) { 346 for ( ; dit.current(); ++dit ) {
347 if( QFileInfo(dit.current()->file() ).exists() ) { 347 if( QFileInfo(dit.current()->file() ).exists() ) {
348 d->selectedFiles->addToSelection( **dit ); 348 d->selectedFiles->addToSelection( **dit );
349 } 349 }
350 } 350 }
351 */ 351 */
352 tabWidget->setCurrentPage(0); 352 tabWidget->setCurrentPage(0);
353 writeCurrentM3u(); 353 writeCurrentM3u();
354 d->selectedFiles->first(); 354 d->selectedFiles->first();
355} 355}
356 356
357 357
358void PlayListWidget::addAllVideoToList() { 358void PlayListWidget::addAllVideoToList() {
359 359
360 if(!videoScan) { 360 if(!videoScan) {
361 if(videoView->childCount() < 1) 361 if(videoView->childCount() < 1)
362 populateVideoView(); 362 populateVideoView();
363 } 363 }
364 364
365 QListViewItemIterator videoIt( videoView ); 365 QListViewItemIterator videoIt( videoView );
366 DocLnk lnk; 366 DocLnk lnk;
367 QString filename; 367 QString filename;
368 for ( ; videoIt.current(); ++videoIt ) { 368 for ( ; videoIt.current(); ++videoIt ) {
369 filename = videoIt.current()->text(3); 369 filename = videoIt.current()->text(3);
370 lnk.setName( QFileInfo(filename).baseName() ); //sets name 370 lnk.setName( QFileInfo(filename).baseName() ); //sets name
371 lnk.setFile( filename ); //sets file name 371 lnk.setFile( filename ); //sets file name
372 d->selectedFiles->addToSelection( lnk); 372 d->selectedFiles->addToSelection( lnk);
373 } 373 }
374 374
375 375
376 /* if(!videoScan) 376 /* if(!videoScan)
377 scanForVideo(); 377 scanForVideo();
378 QListIterator<DocLnk> dit( vFiles.children() ); 378 QListIterator<DocLnk> dit( vFiles.children() );
379 for ( ; dit.current(); ++dit ) { 379 for ( ; dit.current(); ++dit ) {
380 if( QFileInfo( dit.current()->file() ).exists() ) { 380 if( QFileInfo( dit.current()->file() ).exists() ) {
381 d->selectedFiles->addToSelection( **dit ); 381 d->selectedFiles->addToSelection( **dit );
382 } 382 }
383 } 383 }
384*/ 384*/
385 tabWidget->setCurrentPage(0); 385 tabWidget->setCurrentPage(0);
386 writeCurrentM3u(); 386 writeCurrentM3u();
387 d->selectedFiles->first(); 387 d->selectedFiles->first();
388} 388}
389 389
390 390
391void PlayListWidget::setDocument( const QString& fileref ) { 391void PlayListWidget::setDocument( const QString& fileref ) {
392 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 392 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
393 fromSetDocument = TRUE; 393 fromSetDocument = TRUE;
394 if ( fileref.isNull() ) { 394 if ( fileref.isNull() ) {
395 QMessageBox::warning( this, tr( "Invalid File" ), 395 QMessageBox::warning( this, tr( "Invalid File" ),
396 tr( "There was a problem in getting the file." ) ); 396 tr( "There was a problem in getting the file." ) );
397 return; 397 return;
398 } 398 }
399 399
400 clearList(); 400 clearList();
401 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 401 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
402 readm3u( fileref ); 402 readm3u( fileref );
403 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 403 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
404 readm3u( DocLnk( fileref).file() ); 404 readm3u( DocLnk( fileref).file() );
405 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 405 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
406 readPls( fileref ); 406 readPls( fileref );
407 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 407 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
408 readPls( DocLnk( fileref).file() ); 408 readPls( DocLnk( fileref).file() );
409 } else { 409 } else {
410 clearList(); 410 clearList();
411 addToSelection( DocLnk( fileref ) ); 411 addToSelection( DocLnk( fileref ) );
412 writeCurrentM3u(); 412 writeCurrentM3u();
413 413
414 d->setDocumentUsed = TRUE; 414 d->setDocumentUsed = TRUE;
415 mediaPlayerState->setPlaying( FALSE ); 415 mediaPlayerState->setPlaying( FALSE );
416 mediaPlayerState->setPlaying( TRUE ); 416 mediaPlayerState->setPlaying( TRUE );
417 } 417 }
418} 418}
419 419
420 420
421void PlayListWidget::useSelectedDocument() { 421void PlayListWidget::useSelectedDocument() {
422 d->setDocumentUsed = FALSE; 422 d->setDocumentUsed = FALSE;
423} 423}
424 424
425 425
426const DocLnk *PlayListWidget::current() { // this is fugly 426const DocLnk *PlayListWidget::current() { // this is fugly
427 switch ( whichList() ) { 427 switch ( whichList() ) {
428 case 0: //playlist 428 case 0: //playlist
429 { 429 {
430// qDebug("playlist"); 430// qDebug("playlist");
431 if ( mediaPlayerState->playlist() ) { 431 if ( mediaPlayerState->isUsingPlaylist() ) {
432 return d->selectedFiles->current(); 432 return d->selectedFiles->current();
433 } else if ( d->setDocumentUsed && d->current ) { 433 } else if ( d->setDocumentUsed && d->current ) {
434 return d->current; 434 return d->current;
435 } else { 435 } else {
436 return &(d->files->selectedDocument()); 436 return &(d->files->selectedDocument());
437 } 437 }
438 } 438 }
439 break; 439 break;
440 }; 440 };
441 return 0; 441 return 0;
442} 442}
443 443
444 444
445bool PlayListWidget::prev() { 445bool PlayListWidget::prev() {
446 if ( mediaPlayerState->playlist() ) { 446 if ( mediaPlayerState->isUsingPlaylist() ) {
447 if ( mediaPlayerState->shuffled() ) { 447 if ( mediaPlayerState->isShuffled() ) {
448 const DocLnk *cur = current(); 448 const DocLnk *cur = current();
449 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 449 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
450 for ( int i = 0; i < j; i++ ) { 450 for ( int i = 0; i < j; i++ ) {
451 if ( !d->selectedFiles->next() ) 451 if ( !d->selectedFiles->next() )
452 d->selectedFiles->first(); 452 d->selectedFiles->first();
453 } 453 }
454 if ( cur == current() ) 454 if ( cur == current() )
455 if ( !d->selectedFiles->next() ) { 455 if ( !d->selectedFiles->next() ) {
456 d->selectedFiles->first(); 456 d->selectedFiles->first();
457 } 457 }
458 return TRUE; 458 return TRUE;
459 } else { 459 } else {
460 if ( !d->selectedFiles->prev() ) { 460 if ( !d->selectedFiles->prev() ) {
461 if ( mediaPlayerState->looping() ) { 461 if ( mediaPlayerState->isLooping() ) {
462 return d->selectedFiles->last(); 462 return d->selectedFiles->last();
463 } else { 463 } else {
464 return FALSE; 464 return FALSE;
465 } 465 }
466 } 466 }
467 return TRUE; 467 return TRUE;
468 } 468 }
469 } else { 469 } else {
470 return mediaPlayerState->looping(); 470 return mediaPlayerState->isLooping();
471 } 471 }
472} 472}
473 473
474 474
475bool PlayListWidget::next() { 475bool PlayListWidget::next() {
476//qDebug("<<<<<<<<<<<<next()"); 476//qDebug("<<<<<<<<<<<<next()");
477 if ( mediaPlayerState->playlist() ) { 477 if ( mediaPlayerState->isUsingPlaylist() ) {
478 if ( mediaPlayerState->shuffled() ) { 478 if ( mediaPlayerState->isShuffled() ) {
479 return prev(); 479 return prev();
480 } else { 480 } else {
481 if ( !d->selectedFiles->next() ) { 481 if ( !d->selectedFiles->next() ) {
482 if ( mediaPlayerState->looping() ) { 482 if ( mediaPlayerState->isLooping() ) {
483 return d->selectedFiles->first(); 483 return d->selectedFiles->first();
484 } else { 484 } else {
485 return FALSE; 485 return FALSE;
486 } 486 }
487 } 487 }
488 return TRUE; 488 return TRUE;
489 } 489 }
490 } else { 490 } else {
491 return mediaPlayerState->looping(); 491 return mediaPlayerState->isLooping();
492 } 492 }
493} 493}
494 494
495 495
496bool PlayListWidget::first() { 496bool PlayListWidget::first() {
497 if ( mediaPlayerState->playlist() ) 497 if ( mediaPlayerState->isUsingPlaylist() )
498 return d->selectedFiles->first(); 498 return d->selectedFiles->first();
499 else 499 else
500 return mediaPlayerState->looping(); 500 return mediaPlayerState->isLooping();
501} 501}
502 502
503 503
504bool PlayListWidget::last() { 504bool PlayListWidget::last() {
505 if ( mediaPlayerState->playlist() ) 505 if ( mediaPlayerState->isUsingPlaylist() )
506 return d->selectedFiles->last(); 506 return d->selectedFiles->last();
507 else 507 else
508 return mediaPlayerState->looping(); 508 return mediaPlayerState->isLooping();
509} 509}
510 510
511 511
512 void PlayListWidget::saveList() { 512 void PlayListWidget::saveList() {
513 writem3u(); 513 writem3u();
514 } 514 }
515 515
516 516
517void PlayListWidget::loadList( const DocLnk & lnk) { 517void PlayListWidget::loadList( const DocLnk & lnk) {
518 QString name = lnk.name(); 518 QString name = lnk.name();
519 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 519 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
520 520
521 if( name.length()>0) { 521 if( name.length()>0) {
522 setCaption("OpiePlayer: "+name); 522 setCaption("OpiePlayer: "+name);
523// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 523// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
524 clearList(); 524 clearList();
525 readm3u(lnk.file()); 525 readm3u(lnk.file());
526 tabWidget->setCurrentPage(0); 526 tabWidget->setCurrentPage(0);
527 } 527 }
528} 528}
529 529
530 530
531void PlayListWidget::setPlaylist( bool shown ) { 531void PlayListWidget::setPlaylist( bool shown ) {
532 if ( shown ) { 532 if ( shown ) {
533 d->playListFrame->show(); 533 d->playListFrame->show();
534 } else { 534 } else {
535 d->playListFrame->hide(); 535 d->playListFrame->hide();
536 } 536 }
537} 537}
538 538
539 539
540void PlayListWidget::addSelected() { 540void PlayListWidget::addSelected() {
541 qDebug("addSelected"); 541 qDebug("addSelected");
542 DocLnk lnk; 542 DocLnk lnk;
543 QString filename; 543 QString filename;
544 switch (whichList()) { 544 switch (whichList()) {
545 545
546 case 0: //playlist 546 case 0: //playlist
547 return; 547 return;
548 break; 548 break;
549 case 1: { //audio 549 case 1: { //audio
550 QListViewItemIterator it( audioView ); 550 QListViewItemIterator it( audioView );
551 for ( ; it.current(); ++it ) { 551 for ( ; it.current(); ++it ) {
552 if ( it.current()->isSelected() ) { 552 if ( it.current()->isSelected() ) {
553 filename=it.current()->text(3); 553 filename=it.current()->text(3);
554 lnk.setName( QFileInfo(filename).baseName() ); //sets name 554 lnk.setName( QFileInfo(filename).baseName() ); //sets name
555 lnk.setFile( filename ); //sets file name 555 lnk.setFile( filename ); //sets file name
556 d->selectedFiles->addToSelection( lnk); 556 d->selectedFiles->addToSelection( lnk);
557 557
558 } 558 }
559 } 559 }
560 audioView->clearSelection(); 560 audioView->clearSelection();
561 } 561 }
562 break; 562 break;
563 563
564 case 2: { // video 564 case 2: { // video
565 QListViewItemIterator it( videoView ); 565 QListViewItemIterator it( videoView );
566 for ( ; it.current(); ++it ) { 566 for ( ; it.current(); ++it ) {
567 if ( it.current()->isSelected() ) { 567 if ( it.current()->isSelected() ) {
568 filename=it.current()->text(3); 568 filename=it.current()->text(3);
569 lnk.setName( QFileInfo(filename).baseName() ); //sets name 569 lnk.setName( QFileInfo(filename).baseName() ); //sets name
570 lnk.setFile( filename ); //sets file name 570 lnk.setFile( filename ); //sets file name
571 d->selectedFiles->addToSelection( lnk); 571 d->selectedFiles->addToSelection( lnk);
572 } 572 }
573 } 573 }
574 videoView->clearSelection(); 574 videoView->clearSelection();
575 } 575 }
576 break; 576 break;
577 }; 577 };
578 tabWidget->setCurrentPage(0); 578 tabWidget->setCurrentPage(0);
579 writeCurrentM3u(); 579 writeCurrentM3u();
580} 580}
581 581
582 582
583void PlayListWidget::removeSelected() { 583void PlayListWidget::removeSelected() {
584 d->selectedFiles->removeSelected( ); 584 d->selectedFiles->removeSelected( );
585 writeCurrentM3u(); 585 writeCurrentM3u();
586} 586}
587 587
588 588
589void PlayListWidget::playIt( QListViewItem *it) { 589void PlayListWidget::playIt( QListViewItem *it) {
590 if(!it) return; 590 if(!it) return;
591 mediaPlayerState->setPlaying(FALSE); 591 mediaPlayerState->setPlaying(FALSE);
592 mediaPlayerState->setPlaying(TRUE); 592 mediaPlayerState->setPlaying(TRUE);
593 d->selectedFiles->unSelect(); 593 d->selectedFiles->unSelect();
594} 594}
595 595
596 596
597void PlayListWidget::addToSelection( QListViewItem *it) { 597void PlayListWidget::addToSelection( QListViewItem *it) {
598 d->setDocumentUsed = FALSE; 598 d->setDocumentUsed = FALSE;
599 599
600 if(it) { 600 if(it) {
601 switch ( whichList()) { 601 switch ( whichList()) {
602 case 0: //playlist 602 case 0: //playlist
603 return; 603 return;
604 break; 604 break;
605 }; 605 };
606 // case 1: { 606 // case 1: {
607 DocLnk lnk; 607 DocLnk lnk;
608 QString filename; 608 QString filename;
609 609
610 filename=it->text(3); 610 filename=it->text(3);
611 lnk.setName( QFileInfo(filename).baseName() ); //sets name 611 lnk.setName( QFileInfo(filename).baseName() ); //sets name
612 lnk.setFile( filename ); //sets file name 612 lnk.setFile( filename ); //sets file name
613 d->selectedFiles->addToSelection( lnk); 613 d->selectedFiles->addToSelection( lnk);
614 614
615 writeCurrentM3u(); 615 writeCurrentM3u();
616 tabWidget->setCurrentPage(0); 616 tabWidget->setCurrentPage(0);
617 617
618 } 618 }
619} 619}
620 620
621 621
622void PlayListWidget::tabChanged(QWidget *) { 622void PlayListWidget::tabChanged(QWidget *) {
623 623
624 switch ( whichList()) { 624 switch ( whichList()) {
625 case 0: 625 case 0:
626 { 626 {
627 if( !tbDeletePlaylist->isHidden() ) { 627 if( !tbDeletePlaylist->isHidden() ) {
628 tbDeletePlaylist->hide(); 628 tbDeletePlaylist->hide();
629 } 629 }
630 d->tbRemoveFromList->setEnabled(TRUE); 630 d->tbRemoveFromList->setEnabled(TRUE);
631 d->tbAddToList->setEnabled(FALSE); 631 d->tbAddToList->setEnabled(FALSE);
632 } 632 }
633 break; 633 break;
634 case 1: 634 case 1:
635 { 635 {
636 // audioView->clear(); 636 // audioView->clear();
637 if(!audioPopulated) populateAudioView(); 637 if(!audioPopulated) populateAudioView();
638 638
639 if( !tbDeletePlaylist->isHidden() ) { 639 if( !tbDeletePlaylist->isHidden() ) {
640 tbDeletePlaylist->hide(); 640 tbDeletePlaylist->hide();
641 } 641 }
642 d->tbRemoveFromList->setEnabled(FALSE); 642 d->tbRemoveFromList->setEnabled(FALSE);
643 d->tbAddToList->setEnabled(TRUE); 643 d->tbAddToList->setEnabled(TRUE);
644 } 644 }
645 break; 645 break;
646 case 2: 646 case 2:
647 { 647 {
648 // videoView->clear(); 648 // videoView->clear();
649 if(!videoPopulated) populateVideoView(); 649 if(!videoPopulated) populateVideoView();
650 if( !tbDeletePlaylist->isHidden() ) { 650 if( !tbDeletePlaylist->isHidden() ) {
651 tbDeletePlaylist->hide(); 651 tbDeletePlaylist->hide();
652 } 652 }
653 d->tbRemoveFromList->setEnabled(FALSE); 653 d->tbRemoveFromList->setEnabled(FALSE);
654 d->tbAddToList->setEnabled(TRUE); 654 d->tbAddToList->setEnabled(TRUE);
655 } 655 }
656 break; 656 break;
657 case 3: 657 case 3:
658 { 658 {
659 if( tbDeletePlaylist->isHidden() ) { 659 if( tbDeletePlaylist->isHidden() ) {
660 tbDeletePlaylist->show(); 660 tbDeletePlaylist->show();
661 } 661 }
662 playLists->reread(); 662 playLists->reread();
663 } 663 }
664 break; 664 break;
665 }; 665 };
666} 666}
667 667
668 668
669void PlayListWidget::btnPlay(bool b) { 669void PlayListWidget::btnPlay(bool b) {
670// mediaPlayerState->setPlaying(false); 670// mediaPlayerState->setPlaying(false);
671 mediaPlayerState->setPlaying(b); 671 mediaPlayerState->setPlaying(b);
672 insanityBool=FALSE; 672 insanityBool=FALSE;
673} 673}
674 674
675void PlayListWidget::deletePlaylist() { 675void PlayListWidget::deletePlaylist() {
676 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 676 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
677 (tr("You really want to delete\nthis playlist?")), 677 (tr("You really want to delete\nthis playlist?")),
678 (tr("Yes")), (tr("No")), 0 )){ 678 (tr("Yes")), (tr("No")), 0 )){
679 case 0: // Yes clicked, 679 case 0: // Yes clicked,
680 QFile().remove(playLists->selectedDocument().file()); 680 QFile().remove(playLists->selectedDocument().file());
681 QFile().remove(playLists->selectedDocument().linkFile()); 681 QFile().remove(playLists->selectedDocument().linkFile());
682 playLists->reread(); 682 playLists->reread();
683 break; 683 break;
684 case 1: // Cancel 684 case 1: // Cancel
685 break; 685 break;
686 }; 686 };
687} 687}
688 688
689 689
690void PlayListWidget::playSelected() { 690void PlayListWidget::playSelected() {
691 btnPlay( TRUE); 691 btnPlay( TRUE);
692} 692}
693 693
694 694
695void PlayListWidget::scanForAudio() { 695void PlayListWidget::scanForAudio() {
696// qDebug("scan for audio"); 696// qDebug("scan for audio");
697 files.detachChildren(); 697 files.detachChildren();
698 QListIterator<DocLnk> sdit( files.children() ); 698 QListIterator<DocLnk> sdit( files.children() );
699 for ( ; sdit.current(); ++sdit ) { 699 for ( ; sdit.current(); ++sdit ) {
700 delete sdit.current(); 700 delete sdit.current();
701 } 701 }
702// Global::findDocuments( &files, "audio/*"); 702// Global::findDocuments( &files, "audio/*");
703 Global::findDocuments( &files, audioMimes); 703 Global::findDocuments( &files, audioMimes);
704 audioScan = true; 704 audioScan = true;
705 populateAudioView(); 705 populateAudioView();
706} 706}
707 707
708void PlayListWidget::scanForVideo() { 708void PlayListWidget::scanForVideo() {
709// qDebug("scan for video"); 709// qDebug("scan for video");
710 vFiles.detachChildren(); 710 vFiles.detachChildren();
711 QListIterator<DocLnk> sdit( vFiles.children() ); 711 QListIterator<DocLnk> sdit( vFiles.children() );
712 for ( ; sdit.current(); ++sdit ) { 712 for ( ; sdit.current(); ++sdit ) {
713 delete sdit.current(); 713 delete sdit.current();
714 } 714 }
715 Global::findDocuments(&vFiles, "video/*"); 715 Global::findDocuments(&vFiles, "video/*");
716 videoScan = true; 716 videoScan = true;
717 populateVideoView(); 717 populateVideoView();
718} 718}
719 719
720void PlayListWidget::populateAudioView() { 720void PlayListWidget::populateAudioView() {
721 audioView->clear(); 721 audioView->clear();
722 StorageInfo storageInfo; 722 StorageInfo storageInfo;
723 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 723 // const QList<FileSystem> &fs = storageInfo.fileSystems();
724 if(!audioScan) { 724 if(!audioScan) {
725 scanForAudio(); 725 scanForAudio();
726 } 726 }
727 727
728 QListIterator<DocLnk> dit( files.children() ); 728 QListIterator<DocLnk> dit( files.children() );
729 // QListIterator<FileSystem> it ( fs ); 729 // QListIterator<FileSystem> it ( fs );
730 audioView->clear(); 730 audioView->clear();
731 731
732 QString storage; 732 QString storage;
733 for ( ; dit.current(); ++dit ) { 733 for ( ; dit.current(); ++dit ) {
734// // for( ; it.current(); ++it ){ 734// // for( ; it.current(); ++it ){
735// const QString name = (*dit)->name(); 735// const QString name = (*dit)->name();
736// const QString path = (*dit)->path(); 736// const QString path = (*dit)->path();
737// if(dit.current()->file().find(path) != -1 ) { 737// if(dit.current()->file().find(path) != -1 ) {
738// storage = name; 738// storage = name;
739// // } 739// // }
740// } 740// }
741 741
742 QListViewItem * newItem; 742 QListViewItem * newItem;
743 if ( QFile( dit.current()->file()).exists() || 743 if ( QFile( dit.current()->file()).exists() ||
744 dit.current()->file().left(4) == "http" ) { 744 dit.current()->file().left(4) == "http" ) {
745 long size; 745 long size;
746 if( dit.current()->file().left(4) == "http" ) 746 if( dit.current()->file().left(4) == "http" )
747 size=0; 747 size=0;
748 else 748 else
749 size = QFile( dit.current()->file() ).size(); 749 size = QFile( dit.current()->file() ).size();
750 750
751 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 751 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
752 QString::number(size ), "" /*storage*/, 752 QString::number(size ), "" /*storage*/,
753 dit.current()->file() ); 753 dit.current()->file() );
754 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 754 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
755// qDebug("<<<< "+dit.current()->file()); 755// qDebug("<<<< "+dit.current()->file());
756 } 756 }
757 } 757 }
758 audioPopulated=true; 758 audioPopulated=true;
759} 759}
760 760
761 761
762void PlayListWidget::populateVideoView() { 762void PlayListWidget::populateVideoView() {
763 videoView->clear(); 763 videoView->clear();
764 StorageInfo storageInfo; 764 StorageInfo storageInfo;
765 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 765 // const QList<FileSystem> &fs = storageInfo.fileSystems();
766 766
767 if(!videoScan ) { 767 if(!videoScan ) {
768 scanForVideo(); 768 scanForVideo();
769 } 769 }
770 770
771 QListIterator<DocLnk> Vdit( vFiles.children() ); 771 QListIterator<DocLnk> Vdit( vFiles.children() );
772// QListIterator<FileSystem> it ( fs ); 772// QListIterator<FileSystem> it ( fs );
773 videoView->clear(); 773 videoView->clear();
774 QString storage, pathName; 774 QString storage, pathName;
775 for ( ; Vdit.current(); ++Vdit ) { 775 for ( ; Vdit.current(); ++Vdit ) {
776// // for( ; it.current(); ++it ) { 776// // for( ; it.current(); ++it ) {
777// const QString name = (*Vdit)->name(); 777// const QString name = (*Vdit)->name();
778// const QString path = (*Vdit)->path(); 778// const QString path = (*Vdit)->path();
779// if( Vdit.current()->file().find(path) != -1 ) { 779// if( Vdit.current()->file().find(path) != -1 ) {
780// storage=name; 780// storage=name;
781// pathName=path; 781// pathName=path;
782// // } 782// // }
783// } 783// }
784 784
785 QListViewItem * newItem; 785 QListViewItem * newItem;
786 if ( QFile( Vdit.current()->file() ).exists() ) { 786 if ( QFile( Vdit.current()->file() ).exists() ) {
787 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 787 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
788 QString::number( QFile( Vdit.current()->file() ).size() ), 788 QString::number( QFile( Vdit.current()->file() ).size() ),
789 ""/*storage*/, Vdit.current()->file()); 789 ""/*storage*/, Vdit.current()->file());
790 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 790 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
791 } 791 }
792 } 792 }
793 videoPopulated=true; 793 videoPopulated=true;
794} 794}
795 795
796 796
797void PlayListWidget::openFile() { 797void PlayListWidget::openFile() {
798 // http://66.28.164.33:2080 798 // http://66.28.164.33:2080
799 // http://somafm.com/star0242.m3u 799 // http://somafm.com/star0242.m3u
800 QString filename, name; 800 QString filename, name;
801 InputDialog *fileDlg; 801 InputDialog *fileDlg;
802 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 802 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
803 fileDlg->exec(); 803 fileDlg->exec();
804 if( fileDlg->result() == 1 ) { 804 if( fileDlg->result() == 1 ) {
805 filename = fileDlg->text(); 805 filename = fileDlg->text();
806 qDebug( "Selected filename is " + filename ); 806 qDebug( "Selected filename is " + filename );
807 // Om3u *m3uList; 807 // Om3u *m3uList;
808 DocLnk lnk; 808 DocLnk lnk;
809 Config cfg( "OpiePlayer" ); 809 Config cfg( "OpiePlayer" );
810 cfg.setGroup("PlayList"); 810 cfg.setGroup("PlayList");
811 811
812 if(filename.left(4) == "http") { 812 if(filename.left(4) == "http") {
813 QString m3uFile, m3uFilePath; 813 QString m3uFile, m3uFilePath;
814 if(filename.find(":",8,TRUE) != -1) { //found a port 814 if(filename.find(":",8,TRUE) != -1) { //found a port
815 m3uFile = filename.left( filename.find( ":",8,TRUE)); 815 m3uFile = filename.left( filename.find( ":",8,TRUE));
816 m3uFile = m3uFile.right( 7); 816 m3uFile = m3uFile.right( 7);
817 } else if(filename.left(4) == "http"){ 817 } else if(filename.left(4) == "http"){
818 m3uFile=filename; 818 m3uFile=filename;
819 m3uFile = m3uFile.right( m3uFile.length() - 7); 819 m3uFile = m3uFile.right( m3uFile.length() - 7);
820 } else{ 820 } else{
821 m3uFile=filename; 821 m3uFile=filename;
822 } 822 }
823 823
824// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 824// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
825 lnk.setName( filename ); //sets name 825 lnk.setName( filename ); //sets name
826 lnk.setFile( filename ); //sets file name 826 lnk.setFile( filename ); //sets file name
827 827
828// lnk.setIcon("opieplayer2/musicfile"); 828// lnk.setIcon("opieplayer2/musicfile");
829 829
830 d->selectedFiles->addToSelection( lnk ); 830 d->selectedFiles->addToSelection( lnk );
831 writeCurrentM3u(); 831 writeCurrentM3u();
832 d->selectedFiles->setSelectedItem( lnk.name()); 832 d->selectedFiles->setSelectedItem( lnk.name());
833 } 833 }
834 else if( filename.right( 3) == "m3u" ) { 834 else if( filename.right( 3) == "m3u" ) {
835 readm3u( filename ); 835 readm3u( filename );
836 836
837 } else if( filename.right(3) == "pls" ) { 837 } else if( filename.right(3) == "pls" ) {
838 readPls( filename ); 838 readPls( filename );
839 } else { 839 } else {
840 lnk.setName( QFileInfo(filename).baseName() ); //sets name 840 lnk.setName( QFileInfo(filename).baseName() ); //sets name
841 lnk.setFile( filename ); //sets file name 841 lnk.setFile( filename ); //sets file name
842 d->selectedFiles->addToSelection( lnk); 842 d->selectedFiles->addToSelection( lnk);
843 writeCurrentM3u(); 843 writeCurrentM3u();
844 d->selectedFiles->setSelectedItem( lnk.name()); 844 d->selectedFiles->setSelectedItem( lnk.name());
845 } 845 }
846 } 846 }
847 847
848 if( fileDlg ) { 848 if( fileDlg ) {
849 delete fileDlg; 849 delete fileDlg;
850 } 850 }
851} 851}
852 852
853/* 853/*
854reads m3u and shows files/urls to playlist widget */ 854reads m3u and shows files/urls to playlist widget */
855void PlayListWidget::readm3u( const QString &filename ) { 855void PlayListWidget::readm3u( const QString &filename ) {
856 qDebug( "read m3u filename " + filename ); 856 qDebug( "read m3u filename " + filename );
857 857
858 Om3u *m3uList; 858 Om3u *m3uList;
859 QString s, name; 859 QString s, name;
860 m3uList = new Om3u( filename, IO_ReadOnly ); 860 m3uList = new Om3u( filename, IO_ReadOnly );
861 m3uList->readM3u(); 861 m3uList->readM3u();
862 DocLnk lnk; 862 DocLnk lnk;
863 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 863 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
864 s = *it; 864 s = *it;
865// qDebug("reading "+ s); 865// qDebug("reading "+ s);
866 if(s.left(4)=="http") { 866 if(s.left(4)=="http") {
867 lnk.setName( s ); //sets file name 867 lnk.setName( s ); //sets file name
868 lnk.setIcon("opieplayer2/musicfile"); 868 lnk.setIcon("opieplayer2/musicfile");
869 lnk.setFile( s ); //sets file name 869 lnk.setFile( s ); //sets file name
870 870
871 } else { 871 } else {
872 // if( QFileInfo( s ).exists() ) { 872 // if( QFileInfo( s ).exists() ) {
873 lnk.setName( QFileInfo(s).baseName()); 873 lnk.setName( QFileInfo(s).baseName());
874 // if(s.right(4) == '.') {//if regular file 874 // if(s.right(4) == '.') {//if regular file
875 if(s.left(1) != "/") { 875 if(s.left(1) != "/") {
876 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 876 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
877 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 877 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
878// lnk.setIcon(MimeType(s).pixmap() ); 878// lnk.setIcon(MimeType(s).pixmap() );
879// lnk.setIcon("SoundPlayer"); 879// lnk.setIcon("SoundPlayer");
880 } else { 880 } else {
881 // qDebug("set link2 "+s); 881 // qDebug("set link2 "+s);
882 lnk.setFile( s); 882 lnk.setFile( s);
883// lnk.setIcon(MimeType(s).pixmap() ); 883// lnk.setIcon(MimeType(s).pixmap() );
884// lnk.setIcon("SoundPlayer"); 884// lnk.setIcon("SoundPlayer");
885 } 885 }
886 } 886 }
887 d->selectedFiles->addToSelection( lnk ); 887 d->selectedFiles->addToSelection( lnk );
888 } 888 }
889 Config config( "OpiePlayer" ); 889 Config config( "OpiePlayer" );
890 config.setGroup( "PlayList" ); 890 config.setGroup( "PlayList" );
891 891
892 config.writeEntry("CurrentPlaylist",filename); 892 config.writeEntry("CurrentPlaylist",filename);
893 config.write(); 893 config.write();
894 currentPlayList=filename; 894 currentPlayList=filename;
895 895
896// m3uList->write(); 896// m3uList->write();
897 m3uList->close(); 897 m3uList->close();
898 if(m3uList) delete m3uList; 898 if(m3uList) delete m3uList;
899 899
900 d->selectedFiles->setSelectedItem( s); 900 d->selectedFiles->setSelectedItem( s);
901 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 901 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
902 902
903} 903}
904 904
905/* 905/*
906reads pls and adds files/urls to playlist */ 906reads pls and adds files/urls to playlist */
907void PlayListWidget::readPls( const QString &filename ) { 907void PlayListWidget::readPls( const QString &filename ) {
908 908
909 qDebug( "pls filename is " + filename ); 909 qDebug( "pls filename is " + filename );
910 Om3u *m3uList; 910 Om3u *m3uList;
911 QString s, name; 911 QString s, name;
912 m3uList = new Om3u( filename, IO_ReadOnly ); 912 m3uList = new Om3u( filename, IO_ReadOnly );
913 m3uList->readPls(); 913 m3uList->readPls();
914 914
915 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 915 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
916 s = *it; 916 s = *it;
917 // s.replace( QRegExp( "%20" )," " ); 917 // s.replace( QRegExp( "%20" )," " );
918 DocLnk lnk( s ); 918 DocLnk lnk( s );
919 QFileInfo f( s ); 919 QFileInfo f( s );
920 QString name = f.baseName(); 920 QString name = f.baseName();
921 921
922 if( name.left( 4 ) == "http" ) { 922 if( name.left( 4 ) == "http" ) {
923 name = s.right( s.length() - 7); 923 name = s.right( s.length() - 7);
924 } else { 924 } else {
925 name = s; 925 name = s;
926 } 926 }
927 927
928 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 928 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
929 929
930 lnk.setName( name ); 930 lnk.setName( name );
931 if( s.at( s.length() - 4) == '.') {// if this is probably a file 931 if( s.at( s.length() - 4) == '.') {// if this is probably a file
932 lnk.setFile( s ); 932 lnk.setFile( s );
933 } else { //if its a url 933 } else { //if its a url
934// if( name.right( 1 ).find( '/' ) == -1) { 934// if( name.right( 1 ).find( '/' ) == -1) {
935// s += "/"; 935// s += "/";
936// } 936// }
937 lnk.setFile( s ); 937 lnk.setFile( s );
938 } 938 }
939 lnk.setType( "audio/x-mpegurl" ); 939 lnk.setType( "audio/x-mpegurl" );
940 940
941 lnk.writeLink(); 941 lnk.writeLink();
942 d->selectedFiles->addToSelection( lnk ); 942 d->selectedFiles->addToSelection( lnk );
943 } 943 }
944 944
945 m3uList->close(); 945 m3uList->close();
946 if(m3uList) delete m3uList; 946 if(m3uList) delete m3uList;
947} 947}
948 948
949/* 949/*
950 writes current playlist to current m3u file */ 950 writes current playlist to current m3u file */
951void PlayListWidget::writeCurrentM3u() { 951void PlayListWidget::writeCurrentM3u() {
952 qDebug("writing to current m3u"); 952 qDebug("writing to current m3u");
953 Config cfg( "OpiePlayer" ); 953 Config cfg( "OpiePlayer" );
954 cfg.setGroup("PlayList"); 954 cfg.setGroup("PlayList");
955 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 955 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
956 956
957 Om3u *m3uList; 957 Om3u *m3uList;
958 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 958 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
959 if( d->selectedFiles->first()) { 959 if( d->selectedFiles->first()) {
960 960
961 do { 961 do {
962 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 962 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
963 m3uList->add( d->selectedFiles->current()->file() ); 963 m3uList->add( d->selectedFiles->current()->file() );
964 } 964 }
965 while ( d->selectedFiles->next() ); 965 while ( d->selectedFiles->next() );
966 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 966 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
967 m3uList->write(); 967 m3uList->write();
968 m3uList->close(); 968 m3uList->close();
969 969
970 if(m3uList) delete m3uList; 970 if(m3uList) delete m3uList;
971 } 971 }
972 972
973} 973}
974 974
975 /* 975 /*
976 writes current playlist to m3u file */ 976 writes current playlist to m3u file */
977void PlayListWidget::writem3u() { 977void PlayListWidget::writem3u() {
978 InputDialog *fileDlg; 978 InputDialog *fileDlg;
979 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 979 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
980 fileDlg->exec(); 980 fileDlg->exec();
981 QString name, filename, list; 981 QString name, filename, list;
982 Om3u *m3uList; 982 Om3u *m3uList;
983 983
984 if( fileDlg->result() == 1 ) { 984 if( fileDlg->result() == 1 ) {
985 name = fileDlg->text(); 985 name = fileDlg->text();
986// qDebug( filename ); 986// qDebug( filename );
987 987
988 if( name.left( 1) != "/" ) { 988 if( name.left( 1) != "/" ) {
989 filename = QPEApplication::documentDir() + "/" + name; 989 filename = QPEApplication::documentDir() + "/" + name;
990 } 990 }
991 991
992 if( name.right( 3 ) != "m3u" ) { 992 if( name.right( 3 ) != "m3u" ) {
993 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 993 filename = QPEApplication::documentDir() + "/" +name+".m3u";
994 } 994 }
995 995
996 if( d->selectedFiles->first()) { 996 if( d->selectedFiles->first()) {
997 m3uList = new Om3u(filename, IO_ReadWrite); 997 m3uList = new Om3u(filename, IO_ReadWrite);
998 998
999 do { 999 do {
1000 m3uList->add( d->selectedFiles->current()->file()); 1000 m3uList->add( d->selectedFiles->current()->file());
1001 } 1001 }
1002 while ( d->selectedFiles->next() ); 1002 while ( d->selectedFiles->next() );
1003 // qDebug( list ); 1003 // qDebug( list );
1004 m3uList->write(); 1004 m3uList->write();
1005 m3uList->close(); 1005 m3uList->close();
1006 if(m3uList) delete m3uList; 1006 if(m3uList) delete m3uList;
1007 1007
1008 if(fileDlg) delete fileDlg; 1008 if(fileDlg) delete fileDlg;
1009 1009
1010 DocLnk lnk; 1010 DocLnk lnk;
1011 lnk.setFile( filename); 1011 lnk.setFile( filename);
1012 lnk.setIcon("opieplayer2/playlist2"); 1012 lnk.setIcon("opieplayer2/playlist2");
1013 lnk.setName( name); //sets file name 1013 lnk.setName( name); //sets file name
1014 1014
1015 // qDebug(filename); 1015 // qDebug(filename);
1016 Config config( "OpiePlayer" ); 1016 Config config( "OpiePlayer" );
1017 config.setGroup( "PlayList" ); 1017 config.setGroup( "PlayList" );
1018 1018
1019 config.writeEntry("CurrentPlaylist",filename); 1019 config.writeEntry("CurrentPlaylist",filename);
1020 currentPlayList=filename; 1020 currentPlayList=filename;
1021 1021
1022 if(!lnk.writeLink()) { 1022 if(!lnk.writeLink()) {
1023 qDebug("Writing doclink did not work"); 1023 qDebug("Writing doclink did not work");
1024 } 1024 }
1025 1025
1026 setCaption(tr("OpiePlayer: ") + name); 1026 setCaption(tr("OpiePlayer: ") + name);
1027 } 1027 }
1028 } 1028 }
1029} 1029}
1030 1030
1031void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 1031void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
1032 switch ( e->key() ) { 1032 switch ( e->key() ) {
1033 ////////////////////////////// Zaurus keys 1033 ////////////////////////////// Zaurus keys
1034 case Key_F9: //activity 1034 case Key_F9: //activity
1035 // if(audioUI->isHidden()) 1035 // if(audioUI->isHidden())
1036 // audioUI->showMaximized(); 1036 // audioUI->showMaximized();
1037 break; 1037 break;
1038 case Key_F10: //contacts 1038 case Key_F10: //contacts
1039 // if( videoUI->isHidden()) 1039 // if( videoUI->isHidden())
1040 // videoUI->showMaximized(); 1040 // videoUI->showMaximized();
1041 break; 1041 break;
1042 case Key_F11: //menu 1042 case Key_F11: //menu
1043 break; 1043 break;
1044 case Key_F12: //home 1044 case Key_F12: //home
1045 // doBlank(); 1045 // doBlank();
1046 break; 1046 break;
1047 case Key_F13: //mail 1047 case Key_F13: //mail
1048 // doUnblank(); 1048 // doUnblank();
1049 break; 1049 break;
1050 case Key_Q: //add to playlist 1050 case Key_Q: //add to playlist
1051 addSelected(); 1051 addSelected();
1052 break; 1052 break;
1053 case Key_R: //remove from playlist 1053 case Key_R: //remove from playlist
1054 removeSelected(); 1054 removeSelected();
1055 break; 1055 break;
1056 // case Key_P: //play 1056 // case Key_P: //play
1057 // qDebug("Play"); 1057 // qDebug("Play");
1058 // playSelected(); 1058 // playSelected();
1059 // break; 1059 // break;
1060 case Key_Space: 1060 case Key_Space:
1061 // playSelected(); puh 1061 // playSelected(); puh
1062 break; 1062 break;
1063 case Key_1: 1063 case Key_1:
1064 tabWidget->setCurrentPage( 0 ); 1064 tabWidget->setCurrentPage( 0 );
1065 break; 1065 break;
1066 case Key_2: 1066 case Key_2:
1067 tabWidget->setCurrentPage( 1 ); 1067 tabWidget->setCurrentPage( 1 );
1068 break; 1068 break;
1069 case Key_3: 1069 case Key_3:
1070 tabWidget->setCurrentPage( 2 ); 1070 tabWidget->setCurrentPage( 2 );
1071 break; 1071 break;
1072 case Key_4: 1072 case Key_4:
1073 tabWidget->setCurrentPage( 3 ); 1073 tabWidget->setCurrentPage( 3 );
1074 break; 1074 break;
1075 case Key_Down: 1075 case Key_Down:
1076 if ( !d->selectedFiles->next() ) 1076 if ( !d->selectedFiles->next() )
1077 d->selectedFiles->first(); 1077 d->selectedFiles->first();
1078 break; 1078 break;
1079 case Key_Up: 1079 case Key_Up:
1080 if ( !d->selectedFiles->prev() ) 1080 if ( !d->selectedFiles->prev() )
1081 // d->selectedFiles->last(); 1081 // d->selectedFiles->last();
1082 break; 1082 break;
1083 } 1083 }
1084} 1084}
1085 1085
1086void PlayListWidget::pmViewActivated(int index) { 1086void PlayListWidget::pmViewActivated(int index) {
1087// qDebug("%d", index); 1087// qDebug("%d", index);
1088 switch(index) { 1088 switch(index) {
1089 case -16: 1089 case -16:
1090 { 1090 {
1091 mediaPlayerState->toggleFullscreen(); 1091 mediaPlayerState->toggleFullscreen();
1092 bool b=mediaPlayerState->fullscreen(); 1092 bool b=mediaPlayerState->isFullscreen();
1093 pmView->setItemChecked( index, b); 1093 pmView->setItemChecked( index, b);
1094 Config cfg( "OpiePlayer" ); 1094 Config cfg( "OpiePlayer" );
1095 cfg.writeEntry( "FullScreen", b ); 1095 cfg.writeEntry( "FullScreen", b );
1096 } 1096 }
1097 break; 1097 break;
1098 }; 1098 };
1099} 1099}
1100 1100
1101void PlayListWidget::populateSkinsMenu() { 1101void PlayListWidget::populateSkinsMenu() {
1102 int item = 0; 1102 int item = 0;
1103 defaultSkinIndex = 0; 1103 defaultSkinIndex = 0;
1104 QString skinName; 1104 QString skinName;
1105 Config cfg( "OpiePlayer" ); 1105 Config cfg( "OpiePlayer" );
1106 cfg.setGroup("Options" ); 1106 cfg.setGroup("Options" );
1107 QString skin = cfg.readEntry( "Skin", "default" ); 1107 QString skin = cfg.readEntry( "Skin", "default" );
1108 1108
1109 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1109 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1110 skinsDir.setFilter( QDir::Dirs ); 1110 skinsDir.setFilter( QDir::Dirs );
1111 skinsDir.setSorting(QDir::Name ); 1111 skinsDir.setSorting(QDir::Name );
1112 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1112 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1113 QFileInfoListIterator it( *skinslist ); 1113 QFileInfoListIterator it( *skinslist );
1114 QFileInfo *fi; 1114 QFileInfo *fi;
1115 while ( ( fi = it.current() ) ) { 1115 while ( ( fi = it.current() ) ) {
1116 skinName = fi->fileName(); 1116 skinName = fi->fileName();
1117// qDebug( fi->fileName() ); 1117// qDebug( fi->fileName() );
1118 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1118 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1119 item = skinsMenu->insertItem( fi->fileName() ) ; 1119 item = skinsMenu->insertItem( fi->fileName() ) ;
1120 } 1120 }
1121 if( skinName == "default" ) { 1121 if( skinName == "default" ) {
1122 defaultSkinIndex = item; 1122 defaultSkinIndex = item;
1123 } 1123 }
1124 if( skinName == skin ) { 1124 if( skinName == skin ) {
1125 skinsMenu->setItemChecked( item, TRUE ); 1125 skinsMenu->setItemChecked( item, TRUE );
1126 } 1126 }
1127 ++it; 1127 ++it;
1128 } 1128 }
1129} 1129}
1130 1130
1131void PlayListWidget::skinsMenuActivated( int item ) { 1131void PlayListWidget::skinsMenuActivated( int item ) {
1132 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1132 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1133 skinsMenu->setItemChecked( i, FALSE ); 1133 skinsMenu->setItemChecked( i, FALSE );
1134 } 1134 }
1135 skinsMenu->setItemChecked( item, TRUE ); 1135 skinsMenu->setItemChecked( item, TRUE );
1136 1136
1137 Config cfg( "OpiePlayer" ); 1137 Config cfg( "OpiePlayer" );
1138 cfg.setGroup("Options"); 1138 cfg.setGroup("Options");
1139 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1139 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1140 QMessageBox::warning( this, tr( "OpiePlayer" ), 1140 QMessageBox::warning( this, tr( "OpiePlayer" ),
1141 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); 1141 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) );
1142} 1142}
1143 1143
1144int PlayListWidget::whichList() { 1144int PlayListWidget::whichList() {
1145 return tabWidget->currentPageIndex(); 1145 return tabWidget->currentPageIndex();
1146} 1146}
1147 1147
1148QString PlayListWidget::currentFileListPathName() { 1148QString PlayListWidget::currentFileListPathName() {
1149 switch (whichList()) { 1149 switch (whichList()) {
1150 case 1: 1150 case 1:
1151 return audioView->currentItem()->text(3); 1151 return audioView->currentItem()->text(3);
1152 break; 1152 break;
1153 case 2: 1153 case 2:
1154 return videoView->currentItem()->text(3); 1154 return videoView->currentItem()->text(3);
1155 break; 1155 break;
1156 }; 1156 };
1157 return ""; 1157 return "";
1158} 1158}
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 3a757f0..c435241 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,521 +1,521 @@
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#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/mediaplayerplugininterface.h> 36#include <qpe/mediaplayerplugininterface.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38 38
39 39
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qpixmap.h> 42#include <qpixmap.h>
43#include <qslider.h> 43#include <qslider.h>
44#include <qdrawutil.h> 44#include <qdrawutil.h>
45#include "videowidget.h" 45#include "videowidget.h"
46#include "mediaplayerstate.h" 46#include "mediaplayerstate.h"
47#include "playlistwidget.h" 47#include "playlistwidget.h"
48 48
49 49
50#ifdef Q_WS_QWS 50#ifdef Q_WS_QWS
51# define USE_DIRECT_PAINTER 51# define USE_DIRECT_PAINTER
52# include <qdirectpainter_qws.h> 52# include <qdirectpainter_qws.h>
53# include <qgfxraster_qws.h> 53# include <qgfxraster_qws.h>
54#endif 54#endif
55 55
56 56
57extern MediaPlayerState *mediaPlayerState; 57extern MediaPlayerState *mediaPlayerState;
58extern PlayListWidget *playList; 58extern PlayListWidget *playList;
59 59
60 60
61static const int xo = 2; // movable x offset 61static const int xo = 2; // movable x offset
62static const int yo = 0; // movable y offset 62static const int yo = 0; // movable y offset
63 63
64 64
65struct MediaButton { 65struct MediaButton {
66 bool isToggle, isHeld, isDown; 66 bool isToggle, isHeld, isDown;
67}; 67};
68 68
69MediaButton videoButtons[] = { 69MediaButton videoButtons[] = {
70 { FALSE, FALSE, FALSE }, // stop 70 { FALSE, FALSE, FALSE }, // stop
71 { TRUE, FALSE, FALSE }, // play 71 { TRUE, FALSE, FALSE }, // play
72 { FALSE, FALSE, FALSE }, // previous 72 { FALSE, FALSE, FALSE }, // previous
73 { FALSE, FALSE, FALSE }, // next 73 { FALSE, FALSE, FALSE }, // next
74 { FALSE, FALSE, FALSE }, // volUp 74 { FALSE, FALSE, FALSE }, // volUp
75 { FALSE, FALSE, FALSE }, // volDown 75 { FALSE, FALSE, FALSE }, // volDown
76 { TRUE, FALSE, FALSE } // fullscreen 76 { TRUE, FALSE, FALSE } // fullscreen
77}; 77};
78 78
79const char *skinV_mask_file_names[7] = { 79const char *skinV_mask_file_names[7] = {
80"stop","play","back","fwd","up","down","full" 80"stop","play","back","fwd","up","down","full"
81}; 81};
82 82
83static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 83static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
84 84
85 85
86VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 86VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
87QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 87QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
88 88
89 89
90 setCaption( tr("OpiePlayer - Video") ); 90 setCaption( tr("OpiePlayer - Video") );
91 91
92 videoFrame = new XineVideoWidget ( this, "Video frame" ); 92 videoFrame = new XineVideoWidget ( this, "Video frame" );
93 93
94 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 94 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
95 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 95 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
96 96
97 Config cfg("OpiePlayer"); 97 Config cfg("OpiePlayer");
98 cfg.setGroup("Options"); 98 cfg.setGroup("Options");
99 skin = cfg.readEntry("Skin","default"); 99 skin = cfg.readEntry("Skin","default");
100 100
101 QString skinPath = "opieplayer2/skins/" + skin; 101 QString skinPath = "opieplayer2/skins/" + skin;
102 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 102 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
103 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 103 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
104 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 104 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
105 105
106 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 106 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
107 imgButtonMask->fill( 0 ); 107 imgButtonMask->fill( 0 );
108 108
109 for ( int i = 0; i < 7; i++ ) { 109 for ( int i = 0; i < 7; i++ ) {
110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
111 masks[i] = new QBitmap( filename ); 111 masks[i] = new QBitmap( filename );
112 112
113 if ( !masks[i]->isNull() ) { 113 if ( !masks[i]->isNull() ) {
114 QImage imgMask = masks[i]->convertToImage(); 114 QImage imgMask = masks[i]->convertToImage();
115 uchar **dest = imgButtonMask->jumpTable(); 115 uchar **dest = imgButtonMask->jumpTable();
116 for ( int y = 0; y < imgUp->height(); y++ ) { 116 for ( int y = 0; y < imgUp->height(); y++ ) {
117 uchar *line = dest[y]; 117 uchar *line = dest[y];
118 for ( int x = 0; x < imgUp->width(); x++ ) { 118 for ( int x = 0; x < imgUp->width(); x++ ) {
119 if ( !qRed( imgMask.pixel( x, y ) ) ) 119 if ( !qRed( imgMask.pixel( x, y ) ) )
120 line[x] = i + 1; 120 line[x] = i + 1;
121 } 121 }
122 } 122 }
123 } 123 }
124 } 124 }
125 125
126 for ( int i = 0; i < 7; i++ ) { 126 for ( int i = 0; i < 7; i++ ) {
127 buttonPixUp[i] = NULL; 127 buttonPixUp[i] = NULL;
128 buttonPixDown[i] = NULL; 128 buttonPixDown[i] = NULL;
129 } 129 }
130 130
131 setBackgroundPixmap( *pixBg ); 131 setBackgroundPixmap( *pixBg );
132 132
133 slider = new QSlider( Qt::Horizontal, this ); 133 slider = new QSlider( Qt::Horizontal, this );
134 slider->setMinValue( 0 ); 134 slider->setMinValue( 0 );
135 slider->setMaxValue( 1 ); 135 slider->setMaxValue( 1 );
136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
137 //slider->setFocusPolicy( QWidget::NoFocus ); 137 //slider->setFocusPolicy( QWidget::NoFocus );
138 138
139 resizeEvent( NULL ); 139 resizeEvent( NULL );
140 140
141 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 141 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
142 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 142 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
143 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 143 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
144 144
145 setLength( mediaPlayerState->length() ); 145 setLength( mediaPlayerState->length() );
146 setPosition( mediaPlayerState->position() ); 146 setPosition( mediaPlayerState->position() );
147 setFullscreen( mediaPlayerState->fullscreen() ); 147 setFullscreen( mediaPlayerState->isFullscreen() );
148 setPlaying( mediaPlayerState->playing() ); 148 setPlaying( mediaPlayerState->isPlaying() );
149} 149}
150 150
151 151
152VideoWidget::~VideoWidget() { 152VideoWidget::~VideoWidget() {
153 153
154 for ( int i = 0; i < 7; i++ ) { 154 for ( int i = 0; i < 7; i++ ) {
155 delete buttonPixUp[i]; 155 delete buttonPixUp[i];
156 delete buttonPixDown[i]; 156 delete buttonPixDown[i];
157 } 157 }
158 158
159 delete pixBg; 159 delete pixBg;
160 delete imgUp; 160 delete imgUp;
161 delete imgDn; 161 delete imgDn;
162 delete imgButtonMask; 162 delete imgButtonMask;
163 for ( int i = 0; i < 7; i++ ) { 163 for ( int i = 0; i < 7; i++ ) {
164 delete masks[i]; 164 delete masks[i];
165 } 165 }
166 166
167} 167}
168 168
169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
170 QPixmap pix( img.width(), img.height() ); 170 QPixmap pix( img.width(), img.height() );
171 QPainter p( &pix ); 171 QPainter p( &pix );
172 p.drawTiledPixmap( pix.rect(), bg, offset ); 172 p.drawTiledPixmap( pix.rect(), bg, offset );
173 p.drawImage( 0, 0, img ); 173 p.drawImage( 0, 0, img );
174 return new QPixmap( pix ); 174 return new QPixmap( pix );
175} 175}
176 176
177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
178 QPixmap *pixmap = new QPixmap( pix ); 178 QPixmap *pixmap = new QPixmap( pix );
179 pixmap->setMask( mask ); 179 pixmap->setMask( mask );
180 return pixmap; 180 return pixmap;
181} 181}
182 182
183void VideoWidget::resizeEvent( QResizeEvent * ) { 183void VideoWidget::resizeEvent( QResizeEvent * ) {
184 int h = height(); 184 int h = height();
185 int w = width(); 185 int w = width();
186 //int Vh = 160; 186 //int Vh = 160;
187 //int Vw = 220; 187 //int Vw = 220;
188 188
189 slider->setFixedWidth( w - 20 ); 189 slider->setFixedWidth( w - 20 );
190 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 190 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
191 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 191 slider->setBackgroundOrigin( QWidget::ParentOrigin );
192 slider->setFocusPolicy( QWidget::NoFocus ); 192 slider->setFocusPolicy( QWidget::NoFocus );
193 slider->setBackgroundPixmap( *pixBg ); 193 slider->setBackgroundPixmap( *pixBg );
194 194
195 xoff = 0;// ( imgUp->width() ) / 2; 195 xoff = 0;// ( imgUp->width() ) / 2;
196 if(w>h) 196 if(w>h)
197 yoff = 0; 197 yoff = 0;
198 else 198 else
199 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 199 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
200 QPoint p( xoff, yoff ); 200 QPoint p( xoff, yoff );
201 201
202 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 202 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
203 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 203 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
204 204
205 for ( int i = 0; i < 7; i++ ) { 205 for ( int i = 0; i < 7; i++ ) {
206 if ( !masks[i]->isNull() ) { 206 if ( !masks[i]->isNull() ) {
207 delete buttonPixUp[i]; 207 delete buttonPixUp[i];
208 delete buttonPixDown[i]; 208 delete buttonPixDown[i];
209 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 209 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
210 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 210 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
211 } 211 }
212 } 212 }
213 213
214 delete pixUp; 214 delete pixUp;
215 delete pixDn; 215 delete pixDn;
216} 216}
217 217
218static bool videoSliderBeingMoved = FALSE; 218static bool videoSliderBeingMoved = FALSE;
219 219
220void VideoWidget::sliderPressed() { 220void VideoWidget::sliderPressed() {
221 videoSliderBeingMoved = TRUE; 221 videoSliderBeingMoved = TRUE;
222} 222}
223 223
224void VideoWidget::sliderReleased() { 224void VideoWidget::sliderReleased() {
225 videoSliderBeingMoved = FALSE; 225 videoSliderBeingMoved = FALSE;
226 if ( slider->width() == 0 ) { 226 if ( slider->width() == 0 ) {
227 return; 227 return;
228 } 228 }
229 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 229 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
230 mediaPlayerState->setPosition( val ); 230 mediaPlayerState->setPosition( val );
231} 231}
232 232
233void VideoWidget::setPosition( long i ) { 233void VideoWidget::setPosition( long i ) {
234 updateSlider( i, mediaPlayerState->length() ); 234 updateSlider( i, mediaPlayerState->length() );
235} 235}
236 236
237 237
238void VideoWidget::setLength( long max ) { 238void VideoWidget::setLength( long max ) {
239 updateSlider( mediaPlayerState->position(), max ); 239 updateSlider( mediaPlayerState->position(), max );
240} 240}
241 241
242void VideoWidget::setView( char view ) { 242void VideoWidget::setView( char view ) {
243 243
244 if ( view == 'v' ) { 244 if ( view == 'v' ) {
245 makeVisible(); 245 makeVisible();
246 } else { 246 } else {
247 // Effectively blank the view next time we show it so it looks nicer 247 // Effectively blank the view next time we show it so it looks nicer
248 scaledWidth = 0; 248 scaledWidth = 0;
249 scaledHeight = 0; 249 scaledHeight = 0;
250 hide(); 250 hide();
251 } 251 }
252} 252}
253 253
254void VideoWidget::updateSlider( long i, long max ) { 254void VideoWidget::updateSlider( long i, long max ) {
255 // Will flicker too much if we don't do this 255 // Will flicker too much if we don't do this
256 if ( max == 0 ) { 256 if ( max == 0 ) {
257 return; 257 return;
258 } 258 }
259 int width = slider->width(); 259 int width = slider->width();
260 int val = int((double)i * width / max); 260 int val = int((double)i * width / max);
261 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 261 if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) {
262 if ( slider->value() != val ) { 262 if ( slider->value() != val ) {
263 slider->setValue( val ); 263 slider->setValue( val );
264 } 264 }
265 if ( slider->maxValue() != width ) { 265 if ( slider->maxValue() != width ) {
266 slider->setMaxValue( width ); 266 slider->setMaxValue( width );
267 } 267 }
268 } 268 }
269} 269}
270 270
271void VideoWidget::setToggleButton( int i, bool down ) { 271void VideoWidget::setToggleButton( int i, bool down ) {
272 if ( down != videoButtons[i].isDown ) { 272 if ( down != videoButtons[i].isDown ) {
273 toggleButton( i ); 273 toggleButton( i );
274 } 274 }
275} 275}
276 276
277void VideoWidget::toggleButton( int i ) { 277void VideoWidget::toggleButton( int i ) {
278 videoButtons[i].isDown = !videoButtons[i].isDown; 278 videoButtons[i].isDown = !videoButtons[i].isDown;
279 QPainter p(this); 279 QPainter p(this);
280 paintButton ( &p, i ); 280 paintButton ( &p, i );
281} 281}
282 282
283void VideoWidget::paintButton( QPainter *p, int i ) { 283void VideoWidget::paintButton( QPainter *p, int i ) {
284 284
285 if ( videoButtons[i].isDown ) { 285 if ( videoButtons[i].isDown ) {
286 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 286 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
287 } else { 287 } else {
288 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 288 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
289 } 289 }
290} 290}
291 291
292void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 292void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
293 for ( int i = 0; i < numVButtons; i++ ) { 293 for ( int i = 0; i < numVButtons; i++ ) {
294 if ( event->state() == QMouseEvent::LeftButton ) { 294 if ( event->state() == QMouseEvent::LeftButton ) {
295 // The test to see if the mouse click is inside the button or not 295 // The test to see if the mouse click is inside the button or not
296 int x = event->pos().x() - xoff; 296 int x = event->pos().x() - xoff;
297 int y = event->pos().y() - yoff; 297 int y = event->pos().y() - yoff;
298 298
299 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 299 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
300 && y < imgButtonMask->height() 300 && y < imgButtonMask->height()
301 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 301 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
302 302
303 if ( isOnButton && !videoButtons[i].isHeld ) { 303 if ( isOnButton && !videoButtons[i].isHeld ) {
304 videoButtons[i].isHeld = TRUE; 304 videoButtons[i].isHeld = TRUE;
305 toggleButton(i); 305 toggleButton(i);
306 306
307 switch (i) { 307 switch (i) {
308 case VideoVolUp: 308 case VideoVolUp:
309 emit moreClicked(); 309 emit moreClicked();
310 return; 310 return;
311 case VideoVolDown: 311 case VideoVolDown:
312 emit lessClicked(); 312 emit lessClicked();
313 return; 313 return;
314 } 314 }
315 } else if ( !isOnButton && videoButtons[i].isHeld ) { 315 } else if ( !isOnButton && videoButtons[i].isHeld ) {
316 videoButtons[i].isHeld = FALSE; 316 videoButtons[i].isHeld = FALSE;
317 toggleButton(i); 317 toggleButton(i);
318 } 318 }
319 } else { 319 } else {
320 320
321 if ( videoButtons[i].isHeld ) { 321 if ( videoButtons[i].isHeld ) {
322 videoButtons[i].isHeld = FALSE; 322 videoButtons[i].isHeld = FALSE;
323 if ( !videoButtons[i].isToggle ) { 323 if ( !videoButtons[i].isToggle ) {
324 setToggleButton( i, FALSE ); 324 setToggleButton( i, FALSE );
325 } 325 }
326 326
327 switch(i) { 327 switch(i) {
328 328
329 case VideoPlay: { 329 case VideoPlay: {
330 if( mediaPlayerState->paused() ) { 330 if( mediaPlayerState->isPaused() ) {
331 setToggleButton( i, FALSE ); 331 setToggleButton( i, FALSE );
332 mediaPlayerState->setPaused( FALSE ); 332 mediaPlayerState->setPaused( FALSE );
333 return; 333 return;
334 } else if( !mediaPlayerState->paused() ) { 334 } else if( !mediaPlayerState->isPaused() ) {
335 setToggleButton( i, TRUE ); 335 setToggleButton( i, TRUE );
336 mediaPlayerState->setPaused( TRUE ); 336 mediaPlayerState->setPaused( TRUE );
337 return; 337 return;
338 } else { 338 } else {
339 return; 339 return;
340 } 340 }
341 } 341 }
342 342
343 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 343 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
344 case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; 344 case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return;
345 case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; 345 case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return;
346 case VideoVolUp: emit moreReleased(); return; 346 case VideoVolUp: emit moreReleased(); return;
347 case VideoVolDown: emit lessReleased(); return; 347 case VideoVolDown: emit lessReleased(); return;
348 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 348 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
349 } 349 }
350 } 350 }
351 } 351 }
352 } 352 }
353} 353}
354 354
355void VideoWidget::mousePressEvent( QMouseEvent *event ) { 355void VideoWidget::mousePressEvent( QMouseEvent *event ) {
356 mouseMoveEvent( event ); 356 mouseMoveEvent( event );
357} 357}
358 358
359void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 359void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
360 if ( mediaPlayerState->fullscreen() ) { 360 if ( mediaPlayerState->isFullscreen() ) {
361 mediaPlayerState->setFullscreen( FALSE ); 361 mediaPlayerState->setFullscreen( FALSE );
362 makeVisible(); 362 makeVisible();
363 } 363 }
364 mouseMoveEvent( event ); 364 mouseMoveEvent( event );
365} 365}
366 366
367void VideoWidget::showEvent( QShowEvent* ) { 367void VideoWidget::showEvent( QShowEvent* ) {
368 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 368 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
369 mouseMoveEvent( &event ); 369 mouseMoveEvent( &event );
370} 370}
371 371
372 372
373 void VideoWidget::backToNormal() { 373 void VideoWidget::backToNormal() {
374 mediaPlayerState->setFullscreen( FALSE ); 374 mediaPlayerState->setFullscreen( FALSE );
375 makeVisible(); 375 makeVisible();
376 } 376 }
377 377
378void VideoWidget::makeVisible() { 378void VideoWidget::makeVisible() {
379 if ( mediaPlayerState->fullscreen() ) { 379 if ( mediaPlayerState->isFullscreen() ) {
380 setBackgroundMode( QWidget::NoBackground ); 380 setBackgroundMode( QWidget::NoBackground );
381 showFullScreen(); 381 showFullScreen();
382 resize( qApp->desktop()->size() ); 382 resize( qApp->desktop()->size() );
383 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 383 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
384 384
385 slider->hide(); 385 slider->hide();
386 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 386 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
387 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 387 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
388 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 388 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
389 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 389 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
390 390
391 } else { 391 } else {
392 showNormal(); 392 showNormal();
393 showMaximized(); 393 showMaximized();
394 setBackgroundPixmap( *pixBg ); 394 setBackgroundPixmap( *pixBg );
395 QWidget *d = QApplication::desktop(); 395 QWidget *d = QApplication::desktop();
396 int w = d->width(); 396 int w = d->width();
397 int h = d->height(); 397 int h = d->height();
398 398
399 if(w>h) { 399 if(w>h) {
400 int newW=(w/2)-(246/2); //this will only work with 320x240 400 int newW=(w/2)-(246/2); //this will only work with 320x240
401 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 401 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
402 } else { 402 } else {
403 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 403 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
404 } 404 }
405 405
406 if ( !mediaPlayerState->seekable() ) { 406 if ( !mediaPlayerState->isSeekable() ) {
407 if( !slider->isHidden()) { 407 if( !slider->isHidden()) {
408 slider->hide(); 408 slider->hide();
409 } 409 }
410 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 410 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
411 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 411 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
412 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 412 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
413 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 413 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
414 } else { 414 } else {
415 slider->show(); 415 slider->show();
416 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 416 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
417 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 417 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
418 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 418 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
419 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 419 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
420 } 420 }
421 } 421 }
422} 422}
423 423
424 424
425 425
426 426
427void VideoWidget::paintEvent( QPaintEvent * pe) { 427void VideoWidget::paintEvent( QPaintEvent * pe) {
428 QPainter p( this ); 428 QPainter p( this );
429 429
430 if ( mediaPlayerState->fullscreen() ) { 430 if ( mediaPlayerState->isFullscreen() ) {
431 // Clear the background 431 // Clear the background
432 p.setBrush( QBrush( Qt::black ) ); 432 p.setBrush( QBrush( Qt::black ) );
433 } else { 433 } else {
434 if ( !pe->erased() ) { 434 if ( !pe->erased() ) {
435 // Combine with background and double buffer 435 // Combine with background and double buffer
436 QPixmap pix( pe->rect().size() ); 436 QPixmap pix( pe->rect().size() );
437 QPainter p( &pix ); 437 QPainter p( &pix );
438 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 438 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
439 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 439 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
440 for ( int i = 0; i < numVButtons; i++ ) { 440 for ( int i = 0; i < numVButtons; i++ ) {
441 paintButton( &p, i ); 441 paintButton( &p, i );
442 } 442 }
443 QPainter p2( this ); 443 QPainter p2( this );
444 p2.drawPixmap( pe->rect().topLeft(), pix ); 444 p2.drawPixmap( pe->rect().topLeft(), pix );
445 } else { 445 } else {
446 QPainter p( this ); 446 QPainter p( this );
447 for ( int i = 0; i < numVButtons; i++ ) 447 for ( int i = 0; i < numVButtons; i++ )
448 paintButton( &p, i ); 448 paintButton( &p, i );
449 } 449 }
450 //slider->repaint( TRUE ); 450 //slider->repaint( TRUE );
451 } 451 }
452} 452}
453 453
454 454
455void VideoWidget::closeEvent( QCloseEvent* ) { 455void VideoWidget::closeEvent( QCloseEvent* ) {
456 mediaPlayerState->setList(); 456 mediaPlayerState->setList();
457} 457}
458 458
459 459
460void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 460void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
461 switch ( e->key() ) { 461 switch ( e->key() ) {
462////////////////////////////// Zaurus keys 462////////////////////////////// Zaurus keys
463 case Key_Home: 463 case Key_Home:
464 break; 464 break;
465 case Key_F9: //activity 465 case Key_F9: //activity
466 break; 466 break;
467 case Key_F10: //contacts 467 case Key_F10: //contacts
468// hide(); 468// hide();
469 break; 469 break;
470 case Key_F11: //menu 470 case Key_F11: //menu
471 break; 471 break;
472 case Key_F12: //home 472 case Key_F12: //home
473 break; 473 break;
474 case Key_F13: //mail 474 case Key_F13: //mail
475 break; 475 break;
476 case Key_Space: { 476 case Key_Space: {
477 if(mediaPlayerState->playing()) { 477 if(mediaPlayerState->isPlaying()) {
478 mediaPlayerState->setPlaying(FALSE); 478 mediaPlayerState->setPlaying(FALSE);
479 } else { 479 } else {
480 mediaPlayerState->setPlaying(TRUE); 480 mediaPlayerState->setPlaying(TRUE);
481 } 481 }
482 } 482 }
483 break; 483 break;
484 case Key_Down: 484 case Key_Down:
485// toggleButton(6); 485// toggleButton(6);
486 emit lessClicked(); 486 emit lessClicked();
487 emit lessReleased(); 487 emit lessReleased();
488// toggleButton(6); 488// toggleButton(6);
489 break; 489 break;
490 case Key_Up: 490 case Key_Up:
491// toggleButton(5); 491// toggleButton(5);
492 emit moreClicked(); 492 emit moreClicked();
493 emit moreReleased(); 493 emit moreReleased();
494// toggleButton(5); 494// toggleButton(5);
495 break; 495 break;
496 case Key_Right: 496 case Key_Right:
497 mediaPlayerState->setNext(); 497 mediaPlayerState->setNext();
498 break; 498 break;
499 case Key_Left: 499 case Key_Left:
500 mediaPlayerState->setPrev(); 500 mediaPlayerState->setPrev();
501 break; 501 break;
502 case Key_Escape: 502 case Key_Escape:
503 break; 503 break;
504 504
505 }; 505 };
506} 506}
507 507
508XineVideoWidget* VideoWidget::vidWidget() { 508XineVideoWidget* VideoWidget::vidWidget() {
509 return videoFrame; 509 return videoFrame;
510} 510}
511 511
512 512
513void VideoWidget::setFullscreen ( bool b ) { 513void VideoWidget::setFullscreen ( bool b ) {
514 setToggleButton( VideoFullscreen, b ); 514 setToggleButton( VideoFullscreen, b );
515} 515}
516 516
517 517
518void VideoWidget::setPlaying( bool b) { 518void VideoWidget::setPlaying( bool b) {
519 setToggleButton( VideoPlay, b ); 519 setToggleButton( VideoPlay, b );
520} 520}
521 521
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index f6289d7..71e08a6 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,259 +1,259 @@
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 34
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include "xinecontrol.h" 39#include "xinecontrol.h"
40#include "mediaplayerstate.h" 40#include "mediaplayerstate.h"
41#include "videowidget.h" 41#include "videowidget.h"
42 42
43extern MediaPlayerState *mediaPlayerState; 43extern MediaPlayerState *mediaPlayerState;
44extern VideoWidget *videoUI; 44extern VideoWidget *videoUI;
45XineControl::XineControl( QObject *parent, const char *name ) 45XineControl::XineControl( QObject *parent, const char *name )
46 : QObject( parent, name ) { 46 : QObject( parent, name ) {
47 47
48 libXine = new XINE::Lib( videoUI->vidWidget() ); 48 libXine = new XINE::Lib( videoUI->vidWidget() );
49 49
50 connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); 50 connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) );
51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
52 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); 52 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
53 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 53 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
54 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 54 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
55 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 55 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
56 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 56 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
57 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 57 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
58 58
59 disabledSuspendScreenSaver = FALSE; 59 disabledSuspendScreenSaver = FALSE;
60} 60}
61 61
62XineControl::~XineControl() { 62XineControl::~XineControl() {
63#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 63#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
64 if ( disabledSuspendScreenSaver ) { 64 if ( disabledSuspendScreenSaver ) {
65 disabledSuspendScreenSaver = FALSE; 65 disabledSuspendScreenSaver = FALSE;
66 // Re-enable the suspend mode 66 // Re-enable the suspend mode
67 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 67 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
68 } 68 }
69#endif 69#endif
70 delete libXine; 70 delete libXine;
71} 71}
72 72
73void XineControl::play( const QString& fileName ) { 73void XineControl::play( const QString& fileName ) {
74 hasVideoChannel = FALSE; 74 hasVideoChannel = FALSE;
75 hasAudioChannel = FALSE; 75 hasAudioChannel = FALSE;
76 m_fileName = fileName; 76 m_fileName = fileName;
77 77
78 qDebug("<<FILENAME: " + fileName + ">>>>"); 78 qDebug("<<FILENAME: " + fileName + ">>>>");
79 79
80 if ( !libXine->play( fileName, 0, 0 ) ) { 80 if ( !libXine->play( fileName, 0, 0 ) ) {
81 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 81 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
82 // toggle stop so the the play button is reset 82 // toggle stop so the the play button is reset
83 mediaPlayerState->setPlaying( false ); 83 mediaPlayerState->setPlaying( false );
84 return; 84 return;
85 } 85 }
86 mediaPlayerState->setPlaying( true ); 86 mediaPlayerState->setPlaying( true );
87 87
88 char whichGui; 88 char whichGui;
89 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); 89 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
90 if ( !libXine->hasVideo() ) { 90 if ( !libXine->hasVideo() ) {
91 whichGui = 'a'; 91 whichGui = 'a';
92 qDebug("HAS AUDIO"); 92 qDebug("HAS AUDIO");
93 libXine->setShowVideo( false ); 93 libXine->setShowVideo( false );
94 hasAudioChannel = TRUE; 94 hasAudioChannel = TRUE;
95 } else { 95 } else {
96 whichGui = 'v'; 96 whichGui = 'v';
97 qDebug("HAS VIDEO"); 97 qDebug("HAS VIDEO");
98 libXine->setShowVideo( true ); 98 libXine->setShowVideo( true );
99 hasVideoChannel = TRUE; 99 hasVideoChannel = TRUE;
100 } 100 }
101 // determine if slider is shown 101 // determine if slider is shown
102 mediaPlayerState->setIsSeekable( libXine->isSeekable() ); 102 mediaPlayerState->setIsSeekable( libXine->isSeekable() );
103 103
104 // which gui (video / audio) 104 // which gui (video / audio)
105 mediaPlayerState->setView( whichGui ); 105 mediaPlayerState->setView( whichGui );
106 106
107#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 107#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
108 if ( !disabledSuspendScreenSaver ) { 108 if ( !disabledSuspendScreenSaver ) {
109 disabledSuspendScreenSaver = TRUE; 109 disabledSuspendScreenSaver = TRUE;
110 // Stop the screen from blanking and power saving state 110 // Stop the screen from blanking and power saving state
111 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 111 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
112 << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 112 << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend );
113 } 113 }
114#endif 114#endif
115 115
116 length(); 116 length();
117 position(); 117 position();
118} 118}
119 119
120void XineControl::nextMedia() { 120void XineControl::nextMedia() {
121 mediaPlayerState->setNext(); 121 mediaPlayerState->setNext();
122} 122}
123 123
124void XineControl::setGamma( int value ) { 124void XineControl::setGamma( int value ) {
125 libXine->setGamma( value ); 125 libXine->setGamma( value );
126} 126}
127 127
128void XineControl::stop( bool isSet ) { 128void XineControl::stop( bool isSet ) {
129 if ( !isSet ) { 129 if ( !isSet ) {
130 libXine->stop(); 130 libXine->stop();
131 131
132#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 132#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
133 if ( disabledSuspendScreenSaver ) { 133 if ( disabledSuspendScreenSaver ) {
134 disabledSuspendScreenSaver = FALSE; 134 disabledSuspendScreenSaver = FALSE;
135 // Re-enable the suspend mode 135 // Re-enable the suspend mode
136 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 136 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
137 } 137 }
138#endif 138#endif
139 } 139 }
140} 140}
141 141
142/** 142/**
143 * Pause playback 143 * Pause playback
144 * @isSet 144 * @isSet
145 */ 145 */
146void XineControl::pause( bool isSet) { 146void XineControl::pause( bool isSet) {
147 if ( isSet ) { 147 if ( isSet ) {
148 libXine->pause(); 148 libXine->pause();
149 } else { 149 } else {
150 libXine->play( m_fileName, 0, m_currentTime ); 150 libXine->play( m_fileName, 0, m_currentTime );
151 } 151 }
152} 152}
153 153
154 154
155/** 155/**
156 * get current time in playback 156 * get current time in playback
157 */ 157 */
158long XineControl::currentTime() { 158long XineControl::currentTime() {
159 // todo: jede sekunde überprüfen 159 // todo: jede sekunde überprüfen
160 m_currentTime = libXine->currentTime(); 160 m_currentTime = libXine->currentTime();
161 return m_currentTime; 161 return m_currentTime;
162 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 162 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
163} 163}
164 164
165/** 165/**
166 * Set the length of the media file 166 * Set the length of the media file
167 */ 167 */
168void XineControl::length() { 168void XineControl::length() {
169 m_length = libXine->length(); 169 m_length = libXine->length();
170 mediaPlayerState->setLength( m_length ); 170 mediaPlayerState->setLength( m_length );
171} 171}
172 172
173 173
174/** 174/**
175 * Reports the position the xine backend is at right now 175 * Reports the position the xine backend is at right now
176 * @return long the postion in seconds 176 * @return long the postion in seconds
177 */ 177 */
178long XineControl::position() { 178long XineControl::position() {
179 m_position = ( currentTime() ); 179 m_position = ( currentTime() );
180 mediaPlayerState->updatePosition( m_position ); 180 mediaPlayerState->updatePosition( m_position );
181 long emitPos = (long)m_position; 181 long emitPos = (long)m_position;
182 emit positionChanged( emitPos ); 182 emit positionChanged( emitPos );
183 if( mediaPlayerState->playing() ) { 183 if( mediaPlayerState->isPlaying() ) {
184 // needs to be stopped the media is stopped 184 // needs to be stopped the media is stopped
185 QTimer::singleShot( 1000, this, SLOT( position() ) ); 185 QTimer::singleShot( 1000, this, SLOT( position() ) );
186 } 186 }
187 // qDebug("POSITION : %d", m_position); 187 // qDebug("POSITION : %d", m_position);
188 return m_position; 188 return m_position;
189} 189}
190 190
191/** 191/**
192 * Set videoplayback to fullscreen 192 * Set videoplayback to fullscreen
193 * @param isSet 193 * @param isSet
194 */ 194 */
195void XineControl::setFullscreen( bool isSet ) { 195void XineControl::setFullscreen( bool isSet ) {
196 libXine->showVideoFullScreen( isSet ); 196 libXine->showVideoFullScreen( isSet );
197} 197}
198 198
199 199
200QString XineControl::getMetaInfo() { 200QString XineControl::getMetaInfo() {
201 201
202 QString returnString; 202 QString returnString;
203 203
204 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 204 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
205 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 205 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
206 } 206 }
207 207
208 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 208 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
209 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 209 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
210 } 210 }
211 211
212 if ( !libXine->metaInfo( 2 ).isEmpty() ) { 212 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
213 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); 213 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
214 } 214 }
215 215
216 if ( !libXine->metaInfo( 3 ).isEmpty() ) { 216 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
217 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); 217 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
218 } 218 }
219 219
220 if ( !libXine->metaInfo( 4 ).isEmpty() ) { 220 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
221 returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); 221 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
222 } 222 }
223 223
224 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 224 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
225 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 225 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
226 } 226 }
227 return returnString; 227 return returnString;
228} 228}
229 229
230QString XineControl::getErrorCode() { 230QString XineControl::getErrorCode() {
231 231
232 int errorCode = libXine->error(); 232 int errorCode = libXine->error();
233 233
234 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); 234 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) );
235 235
236 if ( errorCode == 1 ) { 236 if ( errorCode == 1 ) {
237 return tr( "No input plugin found for this media type" ); 237 return tr( "No input plugin found for this media type" );
238 } else if ( errorCode == 2 ) { 238 } else if ( errorCode == 2 ) {
239 return tr( "No demux plugin found for this media type" ); 239 return tr( "No demux plugin found for this media type" );
240 } else if ( errorCode == 3 ) { 240 } else if ( errorCode == 3 ) {
241 return tr( "Demuxing failed for this media type" ); 241 return tr( "Demuxing failed for this media type" );
242 } else if ( errorCode == 4 ) { 242 } else if ( errorCode == 4 ) {
243 return tr( "Malformed MRL" ); 243 return tr( "Malformed MRL" );
244 } else { 244 } else {
245 return tr( "Some other error" ); 245 return tr( "Some other error" );
246 } 246 }
247} 247}
248 248
249/** 249/**
250 * Seek to a position in the track 250 * Seek to a position in the track
251 * @param second the second to jump to 251 * @param second the second to jump to
252 */ 252 */
253void XineControl::seekTo( long second ) { 253void XineControl::seekTo( long second ) {
254 libXine->seekTo( (int)second ); 254 libXine->seekTo( (int)second );
255} 255}
256 256
257void XineControl::videoResized ( const QSize &s ) { 257void XineControl::videoResized ( const QSize &s ) {
258 libXine->resize( s ); 258 libXine->resize( s );
259} 259}