summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp39
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp50
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp29
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp43
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp15
8 files changed, 55 insertions, 130 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 248221b..8afb318 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,435 +1,414 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "xinevideowidget.h" 34#include "xinevideowidget.h"
35#include "frame.h" 35#include "frame.h"
36#include "lib.h" 36#include "lib.h"
37 37
38/* OPIE */ 38/* OPIE */
39#include <opie2/odebug.h> 39#include <opie2/odebug.h>
40using namespace Opie::Core; 40using namespace Opie::Core;
41 41
42/* QT */ 42/* QT */
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qgfx_qws.h> 45#include <qgfx_qws.h>
46 46
47/* STD */ 47/* STD */
48#include <assert.h> 48#include <assert.h>
49#include <unistd.h> 49#include <unistd.h>
50 50
51typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 51typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
52 int width, int height,int bytes ); 52 int width, int height,int bytes );
53 53
54extern "C" { 54extern "C" {
55 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 55 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
56 int null_is_showing_video( const xine_vo_driver_t* self ); 56 int null_is_showing_video( const xine_vo_driver_t* self );
57 void null_set_show_video( const xine_vo_driver_t* self, int show ); 57 void null_set_show_video( const xine_vo_driver_t* self, int show );
58 int null_is_fullscreen( const xine_vo_driver_t* self ); 58 int null_is_fullscreen( const xine_vo_driver_t* self );
59 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 59 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
60 int null_is_scaling( const xine_vo_driver_t* self ); 60 int null_is_scaling( const xine_vo_driver_t* self );
61 void null_set_scaling( const xine_vo_driver_t* self, int scale ); 61 void null_set_scaling( const xine_vo_driver_t* self, int scale );
62 void null_set_gui_width( const xine_vo_driver_t* self, int width ); 62 void null_set_gui_width( const xine_vo_driver_t* self, int width );
63 void null_set_gui_height( const xine_vo_driver_t* self, int height ); 63 void null_set_gui_height( const xine_vo_driver_t* self, int height );
64 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); 64 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
65 void null_set_videoGamma( const xine_vo_driver_t* self , int value ); 65 void null_set_videoGamma( const xine_vo_driver_t* self , int value );
66 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); 66 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
67 67
68 void null_preload_decoders( xine_stream_t *stream ); 68 void null_preload_decoders( xine_stream_t *stream );
69} 69}
70 70
71using namespace XINE; 71using namespace XINE;
72 72
73Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) 73Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
74{ 74{
75 m_initialized = false; 75 m_initialized = false;
76 m_duringInitialization = false; 76 m_duringInitialization = false;
77 m_video = false; 77 m_video = false;
78 m_wid = widget; 78 m_wid = widget;
79 printf("Lib"); 79 printf("Lib");
80 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 80 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
81 // get the configuration 81 // get the configuration
82 82
83 // not really OO, should be an extra class, later 83 // not really OO, should be an extra class, later
84 if ( !QFile::exists(configPath) ) { 84 if ( !QFile::exists(configPath) ) {
85 QFile f(configPath); 85 QFile f(configPath);
86 f.open(IO_WriteOnly); 86 f.open(IO_WriteOnly);
87 QTextStream ts( &f ); 87 QTextStream ts( &f );
88 ts << "misc.memcpy_method:glibc\n"; 88 ts << "misc.memcpy_method:glibc\n";
89 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; 89 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n";
90 ts << "codec.ffmpeg_pp_quality:3\n"; 90 ts << "codec.ffmpeg_pp_quality:3\n";
91 ts << "audio.num_buffers:50\n"; 91 ts << "audio.num_buffers:50\n";
92 ts << "audio.size_buffers:4096\n"; 92 ts << "audio.size_buffers:4096\n";
93 ts << "video.num_buffers:20\n"; 93 ts << "video.num_buffers:20\n";
94 ts << "video.size_buffers:4096\n"; 94 ts << "video.size_buffers:4096\n";
95 ts << "audio.out_num_audio_buf:16\n"; 95 ts << "audio.out_num_audio_buf:16\n";
96 ts << "audio.out_size_audio_buf:8096\n"; 96 ts << "audio.out_size_audio_buf:8096\n";
97 ts << "audio.out_size_zero_buf:1024\n"; 97 ts << "audio.out_size_zero_buf:1024\n";
98 ts << "audio.passthrough_offset:0\n"; 98 ts << "audio.passthrough_offset:0\n";
99 f.close(); 99 f.close();
100 } 100 }
101 101
102 if ( initMode == InitializeImmediately ) { 102 if ( initMode == InitializeImmediately ) {
103 initialize(); 103 initialize();
104 m_initialized = true; 104 m_initialized = true;
105 } 105 }
106 else 106 else
107 start(); 107 start();
108} 108}
109 109
110void Lib::run() 110void Lib::run()
111{ 111{
112 odebug << "Lib::run() started" << oendl; 112 odebug << "Lib::run() started" << oendl;
113 initialize(); 113 initialize();
114 m_initialized = true; 114 m_initialized = true;
115 odebug << "Lib::run() finished" << oendl; 115 odebug << "Lib::run() finished" << oendl;
116} 116}
117 117
118void Lib::initialize() 118void Lib::initialize()
119{ 119{
120 m_duringInitialization = true; 120 m_duringInitialization = true;
121 m_xine = xine_new( ); 121 m_xine = xine_new( );
122 122
123 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 123 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
124 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 124 xine_config_load( m_xine, QFile::encodeName( configPath ) );
125 125
126 xine_init( m_xine ); 126 xine_init( m_xine );
127 127
128 // allocate oss for sound 128 // allocate oss for sound
129 // and fb for framebuffer 129 // and fb for framebuffer
130 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 130 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
131 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 131 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
132 132
133
134//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
135
136
137// null_display_handler( m_videoOutput, xine_display_frame, this );
138
139 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 133 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
140 134
141 if (m_wid != 0 ) { 135 if (m_wid != 0 )
142 printf( "!0\n" );
143 setWidget( m_wid ); 136 setWidget( m_wid );
144 }
145 137
146 m_queue = xine_event_new_queue (m_stream);
147 138
139 m_queue = xine_event_new_queue (m_stream);
148 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 140 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
149 141
150 ::null_preload_decoders( m_stream ); 142 ::null_preload_decoders( m_stream );
151 143
152 m_duringInitialization = false; 144 m_duringInitialization = false;
153} 145}
154 146
155Lib::~Lib() { 147Lib::~Lib() {
156 assert( isRunning() == false ); 148 assert( isRunning() == false );
157 assert( m_initialized ); 149 assert( m_initialized );
158 150
159// free( m_config ); 151// free( m_config );
160 152
161 xine_close( m_stream ); 153 xine_close( m_stream );
162
163 xine_event_dispose_queue( m_queue ); 154 xine_event_dispose_queue( m_queue );
164
165 xine_dispose( m_stream ); 155 xine_dispose( m_stream );
166
167 xine_exit( m_xine ); 156 xine_exit( m_xine );
157
168 /* FIXME either free or delete but valgrind bitches against both */ 158 /* FIXME either free or delete but valgrind bitches against both */
169 //free( m_videoOutput ); 159 //free( m_videoOutput );
170 //delete m_audioOutput; 160 //delete m_audioOutput;
171} 161}
172 162
173void Lib::resize ( const QSize &s ) { 163void Lib::resize ( const QSize &s ) {
174 assert( m_initialized || m_duringInitialization ); 164 assert( m_initialized || m_duringInitialization );
175 165
176 if ( s. width ( ) && s. height ( ) ) { 166 if ( s. width ( ) && s. height ( ) ) {
177 ::null_set_gui_width( m_videoOutput, s. width() ); 167 ::null_set_gui_width( m_videoOutput, s. width() );
178 ::null_set_gui_height( m_videoOutput, s. height() ); 168 ::null_set_gui_height( m_videoOutput, s. height() );
179 } 169 }
180} 170}
181 171
182int Lib::majorVersion() { 172int Lib::majorVersion() {
183 int major, minor, sub; 173 int major, minor, sub;
184 xine_get_version ( &major, &minor, &sub ); 174 xine_get_version ( &major, &minor, &sub );
185 return major; 175 return major;
186} 176}
187 177
188int Lib::minorVersion() { 178int Lib::minorVersion() {
189 int major, minor, sub; 179 int major, minor, sub;
190 xine_get_version ( &major, &minor, &sub ); 180 xine_get_version ( &major, &minor, &sub );
191 return minor; 181 return minor;
192} 182}
193 183
194int Lib::subVersion() { 184int Lib::subVersion() {
195 int major, minor, sub; 185 int major, minor, sub;
196 xine_get_version ( &major, &minor, &sub ); 186 xine_get_version ( &major, &minor, &sub );
197 return sub; 187 return sub;
198} 188}
199 189
200int Lib::play( const QString& fileName, int startPos, int start_time ) { 190int Lib::play( const QString& fileName, int startPos, int start_time ) {
201 assert( m_initialized ); 191 assert( m_initialized );
202 // FIXME actually a hack imho. Should not be needed to dispose the whole stream
203 // but without we get wrong media length reads from libxine for the second media
204 //xine_dispose ( m_stream );
205 192
206 QString str = fileName.stripWhiteSpace(); 193 QString str = fileName.stripWhiteSpace();
207 194
208 //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
209 //m_queue = xine_event_new_queue (m_stream);
210 //xine_event_create_listener_thread (m_queue, xine_event_handler, this);
211 195
212 if ( !xine_open( m_stream, str.utf8().data() ) ) { 196 if ( !xine_open( m_stream, str.utf8().data() ) ) {
213 return 0; 197 return 0;
214 } 198 }
215 return xine_play( m_stream, startPos, start_time); 199 return xine_play( m_stream, startPos, start_time);
216} 200}
217 201
218void Lib::stop() { 202void Lib::stop() {
219 assert( m_initialized ); 203 assert( m_initialized );
220
221 odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl;
222 xine_stop( m_stream ); 204 xine_stop( m_stream );
223} 205}
224 206
225void Lib::pause( bool toggle ) { 207void Lib::pause( bool toggle ) {
226 assert( m_initialized ); 208 assert( m_initialized );
227 209
228 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 210 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
229} 211}
230 212
231int Lib::speed() const { 213int Lib::speed() const {
232 assert( m_initialized ); 214 assert( m_initialized );
233 215
234 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 216 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
235} 217}
236 218
237void Lib::setSpeed( int speed ) { 219void Lib::setSpeed( int speed ) {
238 assert( m_initialized ); 220 assert( m_initialized );
239 221
240 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 222 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
241} 223}
242 224
243int Lib::status() const { 225int Lib::status() const {
244 assert( m_initialized ); 226 assert( m_initialized );
245 227
246 return xine_get_status( m_stream ); 228 return xine_get_status( m_stream );
247} 229}
248 230
249int Lib::currentPosition() const { 231int Lib::currentPosition() const {
250 assert( m_initialized ); 232 assert( m_initialized );
251 233
252 int pos, time, length; 234 int pos, time, length;
253 xine_get_pos_length( m_stream, &pos, &time, &length ); 235 xine_get_pos_length( m_stream, &pos, &time, &length );
254 return pos; 236 return pos;
255} 237}
256 238
257int Lib::currentTime() const { 239int Lib::currentTime() const {
258 assert( m_initialized ); 240 assert( m_initialized );
259 241
260 int pos, time, length; 242 int pos, time, length;
261 xine_get_pos_length( m_stream, &pos, &time, &length ); 243 pos = time = length = 0;
262 if ( time > 0 ) { 244
245 if ( xine_get_pos_length( m_stream, &pos, &time, &length ) )
263 return time/1000; 246 return time/1000;
264 } else { 247 else
265 return 0; 248 return 0;
266 }
267} 249}
268 250
269int Lib::length() const { 251int Lib::length() const {
270 assert( m_initialized ); 252 assert( m_initialized );
271 253
272 int pos, time, length; 254 int pos, time, length;
273/* dilb: patch to solve the wrong stream length reported to the GUI*/ 255/* dilb: patch to solve the wrong stream length reported to the GUI*/
274 int iRetVal=0, iTestLoop=0; 256 int iRetVal=0, iTestLoop=0;
275 257
276 do 258 do
277 { 259 {
278 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); 260 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length );
279 if (iRetVal) 261 if (iRetVal)
280 {/* if the function didn't return 0, then pos, time and length are valid.*/ 262 {/* if the function didn't return 0, then pos, time and length are valid.*/
281 return length/1000; 263 return length/1000;
282 } 264 }
283 /*don't poll too much*/ 265 /*don't poll too much*/
284 usleep(100000); 266 usleep(100000);
285 iTestLoop++; 267 iTestLoop++;
286 } 268 }
287 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any 269 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any
288valid stream, then return -1 (this value could be used to make the stream 270valid stream, then return -1 (this value could be used to make the stream
289unseekable, but it should never occur!! Mr. Murphy ? :) ) */ 271unseekable, but it should never occur!! Mr. Murphy ? :) ) */
290 272
291 return -1; 273 return -1;
292} 274}
293 275
294bool Lib::isSeekable() const { 276bool Lib::isSeekable() const {
295 assert( m_initialized ); 277 assert( m_initialized );
296 278
297 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 279 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
298} 280}
299 281
300void Lib::seekTo( int time ) { 282void Lib::seekTo( int time ) {
301 assert( m_initialized ); 283 assert( m_initialized );
302 284
303 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
304 // since its now milliseconds we need *1000
305 xine_play( m_stream, 0, time*1000 ); 285 xine_play( m_stream, 0, time*1000 );
306} 286}
307 287
308 288
309Frame Lib::currentFrame() const { 289Frame Lib::currentFrame() const {
310 assert( m_initialized ); 290 assert( m_initialized );
311 291
312 Frame frame; 292 Frame frame;
313 return frame; 293 return frame;
314}; 294};
315 295
316QString Lib::metaInfo( int number) const { 296QString Lib::metaInfo( int number) const {
317 assert( m_initialized ); 297 assert( m_initialized );
318 298
319 return xine_get_meta_info( m_stream, number ); 299 return xine_get_meta_info( m_stream, number );
320} 300}
321 301
322int Lib::error() const { 302int Lib::error() const {
323 assert( m_initialized ); 303 assert( m_initialized );
324 304
325 return xine_get_error( m_stream ); 305 return xine_get_error( m_stream );
326}; 306};
327 307
328void Lib::ensureInitialized() 308void Lib::ensureInitialized()
329{ 309{
330 if ( m_initialized ) 310 if ( m_initialized )
331 return; 311 return;
332 312
333 odebug << "waiting for initialization thread to finish" << oendl; 313 odebug << "waiting for initialization thread to finish" << oendl;
334 wait(); 314 wait();
335 odebug << "initialization thread finished!" << oendl; 315 odebug << "initialization thread finished!" << oendl;
336} 316}
337 317
338void Lib::setWidget( XineVideoWidget *widget ) 318void Lib::setWidget( XineVideoWidget *widget )
339{ 319{
340 m_wid = widget; 320 m_wid = widget;
341 resize ( m_wid-> size ( ) ); 321 resize ( m_wid-> size ( ) );
342 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 322 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
343 m_wid->repaint(); 323 m_wid->repaint();
344} 324}
345 325
346void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 326void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
347{ 327{
348 assert( sendType == ThreadUtil::Channel::OneWay ); 328 assert( sendType == ThreadUtil::Channel::OneWay );
349 handleXineEvent( msg->type() ); 329 handleXineEvent( msg->type() );
350 delete msg; 330 delete msg;
351} 331}
352 332
353void Lib::handleXineEvent( const xine_event_t* t ) { 333void Lib::handleXineEvent( const xine_event_t* t ) {
354 send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); 334 send( new ThreadUtil::ChannelMessage( t->type ), OneWay );
355} 335}
356 336
357void Lib::handleXineEvent( int type ) { 337void Lib::handleXineEvent( int type ) {
358 assert( m_initialized ); 338 assert( m_initialized );
359 339
360 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { 340 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
361 emit stopped(); 341 emit stopped();
362 } 342 }
363} 343}
364 344
365 345
366void Lib::setShowVideo( bool video ) { 346void Lib::setShowVideo( bool video ) {
367 assert( m_initialized ); 347 assert( m_initialized );
368 348
369 m_video = video; 349 m_video = video;
370 ::null_set_show_video( m_videoOutput, video ); 350 ::null_set_show_video( m_videoOutput, video );
371} 351}
372 352
373bool Lib::isShowingVideo() const { 353bool Lib::isShowingVideo() const {
374 assert( m_initialized ); 354 assert( m_initialized );
375 355
376 return ::null_is_showing_video( m_videoOutput ); 356 return ::null_is_showing_video( m_videoOutput );
377} 357}
378 358
379bool Lib::hasVideo() const { 359bool Lib::hasVideo() const {
380 assert( m_initialized ); 360 assert( m_initialized );
381 361
382 return xine_get_stream_info( m_stream, 18 ); 362 return xine_get_stream_info( m_stream, 18 );
383} 363}
384 364
385void Lib::showVideoFullScreen( bool fullScreen ) { 365void Lib::showVideoFullScreen( bool fullScreen ) {
386 assert( m_initialized ); 366 assert( m_initialized );
387 367
388 ::null_set_fullscreen( m_videoOutput, fullScreen ); 368 ::null_set_fullscreen( m_videoOutput, fullScreen );
389} 369}
390 370
391bool Lib::isVideoFullScreen() const { 371bool Lib::isVideoFullScreen() const {
392 assert( m_initialized ); 372 assert( m_initialized );
393 373
394 return ::null_is_fullscreen( m_videoOutput ); 374 return ::null_is_fullscreen( m_videoOutput );
395} 375}
396 376
397void Lib::setScaling( bool scale ) { 377void Lib::setScaling( bool scale ) {
398 assert( m_initialized ); 378 assert( m_initialized );
399 379
400 ::null_set_scaling( m_videoOutput, scale ); 380 ::null_set_scaling( m_videoOutput, scale );
401} 381}
402 382
403void Lib::setGamma( int value ) { 383void Lib::setGamma( int value ) {
404 assert( m_initialized ); 384 assert( m_initialized );
405 385
406 ::null_set_videoGamma( m_videoOutput, value ); 386 ::null_set_videoGamma( m_videoOutput, value );
407} 387}
408 388
409bool Lib::isScaling() const { 389bool Lib::isScaling() const {
410 assert( m_initialized ); 390 assert( m_initialized );
411 391
412 return ::null_is_scaling( m_videoOutput ); 392 return ::null_is_scaling( m_videoOutput );
413} 393}
414 394
415void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { 395void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
416 ( (Lib*)user_data)->handleXineEvent( t ); 396 ( (Lib*)user_data)->handleXineEvent( t );
417} 397}
418 398
419void Lib::xine_display_frame( void* user_data, uint8_t *frame, 399void Lib::xine_display_frame( void* user_data, uint8_t *frame,
420 int width, int height, int bytes ) { 400 int width, int height, int bytes ) {
421 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 401 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
422} 402}
423 403
424void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 404void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
425 assert( m_initialized ); 405 assert( m_initialized );
426 406
427 if ( !m_video ) { 407 if ( !m_video ) {
428 owarn << "not showing video now" << oendl;
429 return; 408 return;
430 } 409 }
431 410
432 assert( m_wid ); 411 assert( m_wid );
433 412
434 m_wid-> setVideoFrame ( frame, width, height, bytes ); 413 m_wid-> setVideoFrame ( frame, width, height, bytes );
435} 414}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index e6afbd8..b8023ca 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,407 +1,367 @@
1#include "mediaplayer.h" 1#include "mediaplayer.h"
2#include "audiowidget.h" 2#include "audiowidget.h"
3#include "videowidget.h" 3#include "videowidget.h"
4#include "volumecontrol.h" 4#include "volumecontrol.h"
5 5
6/* OPIE */ 6/* OPIE */
7#include <opie2/odebug.h> 7#include <opie2/odebug.h>
8#include <opie2/odevice.h>
8#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
9#include <qpe/config.h> 10#include <qpe/config.h>
10 11
11/* QT */ 12/* QT */
12#include <qfileinfo.h> 13#include <qfileinfo.h>
13 14
14/* STD */ 15/* STD */
15#include <linux/fb.h> 16#include <linux/fb.h>
16#include <sys/file.h> 17#include <sys/file.h>
17#include <sys/ioctl.h> 18#include <sys/ioctl.h>
18 19
19#define FBIOBLANK 0x4611 20#define FBIOBLANK 0x4611
20 21
21MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 22MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
22 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 23 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
23 24
24 m_audioUI = 0; 25 m_audioUI = 0;
25 m_videoUI = 0; 26 m_videoUI = 0;
26 m_xineControl = 0; 27 m_xineControl = 0;
27 xine = new XINE::Lib( XINE::Lib::InitializeInThread ); 28 xine = new XINE::Lib( XINE::Lib::InitializeInThread );
28 29
29 fd=-1;fl=-1; 30 fd=-1;fl=-1;
30 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 31 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
31 32
32 qApp->processEvents(); 33 qApp->processEvents();
33 // QPEApplication::grabKeyboard(); // EVIL 34 // QPEApplication::grabKeyboard(); // EVIL
34 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 35 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
35 36
36 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 37 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
37
38// What is pauseCheck good for? (Simon)
39// connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) );
40
41 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 38 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
42 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 39 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
43 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); 40 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) );
44 41
45 volControl = new VolumeControl; 42 volControl = new VolumeControl;
46 Config cfg( "OpiePlayer" ); 43 Config cfg( "OpiePlayer" );
47 cfg.setGroup("PlayList"); 44 cfg.setGroup("PlayList");
48 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 45 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
49 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 46 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
50 47
51 m_skinLoader = new SkinLoader; 48 m_skinLoader = new SkinLoader;
52 m_skinLoader->schedule( AudioWidget::guiInfo() ); 49 m_skinLoader->schedule( AudioWidget::guiInfo() );
53 m_skinLoader->schedule( VideoWidget::guiInfo() ); 50 m_skinLoader->schedule( VideoWidget::guiInfo() );
54 m_skinLoader->start(); 51 m_skinLoader->start();
55} 52}
56 53
57MediaPlayer::~MediaPlayer() { 54MediaPlayer::~MediaPlayer() {
58 // this shold never happen, but one never knows... 55 // this shold never happen, but one never knows...
59 if ( xine ) { 56 if ( xine ) {
60 xine->ensureInitialized(); 57 xine->ensureInitialized();
61 delete xine; 58 delete xine;
62 } 59 }
63 delete m_xineControl; 60 delete m_xineControl;
64 delete m_audioUI; 61 delete m_audioUI;
65 delete m_videoUI; 62 delete m_videoUI;
66 delete volControl; 63 delete volControl;
67} 64}
68 65
69void MediaPlayer::pauseCheck( bool b ) { 66void MediaPlayer::pauseCheck( bool b ) {
70 if ( b && !mediaPlayerState.isPlaying() ) { 67 if ( b && !mediaPlayerState.isPlaying() ) {
71 mediaPlayerState.setPaused( FALSE ); 68 mediaPlayerState.setPaused( FALSE );
72 } 69 }
73} 70}
74 71
75void MediaPlayer::play() { 72void MediaPlayer::play() {
76 mediaPlayerState.setPlaying( FALSE ); 73 mediaPlayerState.setPlaying( FALSE );
77 mediaPlayerState.setPlaying( TRUE ); 74 mediaPlayerState.setPlaying( TRUE );
78} 75}
79 76
80void MediaPlayer::setPlaying( bool play ) { 77void MediaPlayer::setPlaying( bool play ) {
81 if ( !play ) { 78 if ( !play ) {
82 return; 79 return;
83 } 80 }
84 81
85 if ( mediaPlayerState.isPaused() ) { 82 if ( mediaPlayerState.isPaused() ) {
86 mediaPlayerState.setPaused( FALSE ); 83 mediaPlayerState.setPaused( FALSE );
87 return; 84 return;
88 } 85 }
89 86
90 QString tickerText, time, fileName; 87 QString tickerText, time, fileName;
91 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 88 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
92 //if playing in file list.. play in a different way 89 //if playing in file list.. play in a different way
93 // random and looping settings enabled causes problems here, 90 // random and looping settings enabled causes problems here,
94 // since there is no selected file in the playlist, but a selected file in the file list, 91 // since there is no selected file in the playlist, but a selected file in the file list,
95 // so we remember and shutoff 92 // so we remember and shutoff
96 l = mediaPlayerState.isLooping(); 93 l = mediaPlayerState.isLooping();
97 if(l) { 94 if(l) {
98 mediaPlayerState.setLooping( false ); 95 mediaPlayerState.setLooping( false );
99 } 96 }
100 r = mediaPlayerState.isShuffled(); 97 r = mediaPlayerState.isShuffled();
101 mediaPlayerState.setShuffled( false ); 98 mediaPlayerState.setShuffled( false );
102 } 99 }
103 100
104 PlayListWidget::Entry playListEntry = playList.currentEntry(); 101 PlayListWidget::Entry playListEntry = playList.currentEntry();
105 fileName = playListEntry.name; 102 fileName = playListEntry.name;
106 xineControl()->play( playListEntry.file ); 103 xineControl()->play( playListEntry.file );
107 104
108 long seconds = mediaPlayerState.length(); 105 long seconds = mediaPlayerState.length();
109 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 106 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
110 107
111 if( fileName.left(4) == "http" ) { 108 if( fileName.left(4) == "http" ) {
112 fileName = QFileInfo( fileName ).baseName(); 109 fileName = QFileInfo( fileName ).baseName();
113 if ( xineControl()->getMetaInfo().isEmpty() ) { 110 if ( xineControl()->getMetaInfo().isEmpty() ) {
114 tickerText = tr( " File: " ) + fileName; 111 tickerText = tr( " File: " ) + fileName;
115 } else { 112 } else {
116 tickerText = xineControl()->getMetaInfo(); 113 tickerText = xineControl()->getMetaInfo();
117 } 114 }
118 } else { 115 } else {
119 if ( xineControl()->getMetaInfo().isEmpty() ) { 116 if ( xineControl()->getMetaInfo().isEmpty() ) {
120 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 117 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
121 } else { 118 } else {
122 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; 119 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " ";
123 } 120 }
124 } 121 }
125 audioUI()->setTickerText( tickerText ); 122 audioUI()->setTickerText( tickerText );
126} 123}
127 124
128 125
129void MediaPlayer::prev() { 126void MediaPlayer::prev() {
130 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 127 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
131 if ( playList.prev() ) { 128 if ( playList.prev() ) {
132 play(); 129 play();
133 } else if ( mediaPlayerState.isLooping() ) { 130 } else if ( mediaPlayerState.isLooping() ) {
134 if ( playList.last() ) { 131 if ( playList.last() ) {
135 play(); 132 play();
136 } 133 }
137 } else { 134 } else {
138 mediaPlayerState.setList(); 135 mediaPlayerState.setList();
139 } 136 }
140 } 137 }
141} 138}
142 139
143 140
144void MediaPlayer::next() { 141void MediaPlayer::next() {
145 142
146 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 143 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
147 if ( playList.next() ) { 144 if ( playList.next() ) {
148 play(); 145 play();
149 } else if ( mediaPlayerState.isLooping() ) { 146 } else if ( mediaPlayerState.isLooping() ) {
150 if ( playList.first() ) { 147 if ( playList.first() ) {
151 play(); 148 play();
152 } 149 }
153 } else { 150 } else {
154 mediaPlayerState.setList(); 151 mediaPlayerState.setList();
155 } 152 }
156 } else { //if playing from file list, let's just stop 153 } else { //if playing from file list, let's just stop
157 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; 154 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl;
158 mediaPlayerState.setPlaying(false); 155 mediaPlayerState.setPlaying(false);
159 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 156 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
160 if(l) mediaPlayerState.setLooping(l); 157 if(l) mediaPlayerState.setLooping(l);
161 if(r) mediaPlayerState.setShuffled(r); 158 if(r) mediaPlayerState.setShuffled(r);
162 } 159 }
163 qApp->processEvents(); 160 qApp->processEvents();
164} 161}
165 162
166 163
167void MediaPlayer::startDecreasingVolume() { 164void MediaPlayer::startDecreasingVolume() {
168 volumeDirection = -1; 165 volumeDirection = -1;
169 startTimer( 100 ); 166 startTimer( 100 );
170 volControl->decVol(2); 167 volControl->decVol(2);
171} 168}
172 169
173 170
174void MediaPlayer::startIncreasingVolume() { 171void MediaPlayer::startIncreasingVolume() {
175 volumeDirection = +1; 172 volumeDirection = +1;
176 startTimer( 100 ); 173 startTimer( 100 );
177 volControl->incVol(2); 174 volControl->incVol(2);
178} 175}
179 176
180 177
181bool drawnOnScreenDisplay = FALSE; 178bool drawnOnScreenDisplay = FALSE;
182unsigned int onScreenDisplayVolume = 0; 179unsigned int onScreenDisplayVolume = 0;
183const int yoff = 110; 180const int yoff = 110;
184 181
185void MediaPlayer::stopChangingVolume() { 182void MediaPlayer::stopChangingVolume() {
186 killTimers(); 183 killTimers();
187 // Get rid of the on-screen display stuff 184 // Get rid of the on-screen display stuff
188 drawnOnScreenDisplay = FALSE; 185 drawnOnScreenDisplay = FALSE;
189 onScreenDisplayVolume = 0; 186 onScreenDisplayVolume = 0;
190 int w=0; 187 int w=0;
191 int h=0; 188 int h=0;
192 if( !xineControl()->hasVideo() ) { 189 if( !xineControl()->hasVideo() ) {
193 w = audioUI()->width(); 190 w = audioUI()->width();
194 h = audioUI()->height(); 191 h = audioUI()->height();
195 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 192 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
196 } else { 193 } else {
197 w = videoUI()->width(); 194 w = videoUI()->width();
198 h = videoUI()->height(); 195 h = videoUI()->height();
199 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 196 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
200 } 197 }
201} 198}
202 199
203 200
204void MediaPlayer::timerEvent( QTimerEvent * ) { 201void MediaPlayer::timerEvent( QTimerEvent * ) {
205 if ( volumeDirection == +1 ) { 202 if ( volumeDirection == +1 ) {
206 volControl->incVol( 2 ); 203 volControl->incVol( 2 );
207 } else if ( volumeDirection == -1 ) { 204 } else if ( volumeDirection == -1 ) {
208 volControl->decVol( 2 ); 205 volControl->decVol( 2 );
209 } 206 }
210 207
211 208
212 // TODO FIXME 209 // TODO FIXME
213 // huh?? 210 // huh??
214 unsigned int v= 0; 211 unsigned int v= 0;
215 v = volControl->volume(); 212 v = volControl->volume();
216 v = v / 10; 213 v = v / 10;
217 214
218 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 215 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
219 return; 216 return;
220 } 217 }
221 218
222 int w=0; int h=0; 219 int w=0; int h=0;
223 if( !xineControl()->hasVideo() ) { 220 if( !xineControl()->hasVideo() ) {
224 w = audioUI()->width(); 221 w = audioUI()->width();
225 h = audioUI()->height(); 222 h = audioUI()->height();
226 223
227 if ( drawnOnScreenDisplay ) { 224 if ( drawnOnScreenDisplay ) {
228 if ( onScreenDisplayVolume > v ) { 225 if ( onScreenDisplayVolume > v ) {
229 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 226 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
230 } 227 }
231 } 228 }
232 drawnOnScreenDisplay = TRUE; 229 drawnOnScreenDisplay = TRUE;
233 onScreenDisplayVolume = v; 230 onScreenDisplayVolume = v;
234 QPainter p( audioUI() ); 231 QPainter p( audioUI() );
235 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 232 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
236 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 233 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
237 234
238 QFont f; 235 QFont f;
239 f.setPixelSize( 20 ); 236 f.setPixelSize( 20 );
240 f.setBold( TRUE ); 237 f.setBold( TRUE );
241 p.setFont( f ); 238 p.setFont( f );
242 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 239 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
243 240
244 for ( unsigned int i = 0; i < 10; i++ ) { 241 for ( unsigned int i = 0; i < 10; i++ ) {
245 if ( v > i ) { 242 if ( v > i ) {
246 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 243 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
247 } else { 244 } else {
248 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 245 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
249 } 246 }
250 } 247 }
251 } else { 248 } else {
252 w = videoUI()->width(); 249 w = videoUI()->width();
253 h = videoUI()->height(); 250 h = videoUI()->height();
254 251
255 if ( drawnOnScreenDisplay ) { 252 if ( drawnOnScreenDisplay ) {
256 if ( onScreenDisplayVolume > v ) { 253 if ( onScreenDisplayVolume > v ) {
257 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 254 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
258 } 255 }
259 } 256 }
260 drawnOnScreenDisplay = TRUE; 257 drawnOnScreenDisplay = TRUE;
261 onScreenDisplayVolume = v; 258 onScreenDisplayVolume = v;
262 QPainter p( videoUI() ); 259 QPainter p( videoUI() );
263 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 260 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
264 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 261 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
265 262
266 QFont f; 263 QFont f;
267 f.setPixelSize( 20 ); 264 f.setPixelSize( 20 );
268 f.setBold( TRUE ); 265 f.setBold( TRUE );
269 p.setFont( f ); 266 p.setFont( f );
270 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 267 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
271 268
272 for ( unsigned int i = 0; i < 10; i++ ) { 269 for ( unsigned int i = 0; i < 10; i++ ) {
273 if ( v > i ) { 270 if ( v > i ) {
274 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 271 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
275 } else { 272 } else {
276 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 273 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
277 } 274 }
278 } 275 }
279 } 276 }
280} 277}
281 278
282 279
283void MediaPlayer::blank( bool b ) { 280void MediaPlayer::blank( bool b ) {
284#ifdef QT_QWS_DEVFS 281 Opie::Core::ODevice::inst()->setDisplayStatus( b );
285 fd=open("/dev/fb/0",O_RDWR);
286#else
287 fd=open("/dev/fb0",O_RDWR);
288#endif
289#ifdef QT_QWS_SL5XXX
290 fl= open( "/dev/fl", O_RDWR );
291#endif
292 if (fd != -1) {
293 if ( b ) {
294 odebug << "do blanking" << oendl;
295#ifdef QT_QWS_SL5XXX
296 ioctl( fd, FBIOBLANK, 1 );
297 if(fl !=-1) {
298 ioctl( fl, 2 );
299 ::close(fl);
300 }
301#else
302 ioctl( fd, FBIOBLANK, 3 );
303#endif
304 isBlanked = TRUE;
305 } else {
306 odebug << "do unblanking" << oendl;
307 ioctl( fd, FBIOBLANK, 0);
308#ifdef QT_QWS_SL5XXX
309 if(fl != -1) {
310 ioctl( fl, 1);
311 ::close(fl);
312 }
313#endif
314 isBlanked = FALSE;
315 }
316 close( fd );
317 } else {
318 odebug << "<< /dev/fb0 could not be opened >>" << oendl;
319 }
320} 282}
321 283
322void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 284void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
323 switch ( e->key() ) { 285 switch ( e->key() ) {
324////////////////////////////// Zaurus keys 286////////////////////////////// Zaurus keys
325 case Key_Home: 287 case Key_Home:
326 break; 288 break;
327 case Key_F9: //activity 289 case Key_F9: //activity
328 break; 290 break;
329 case Key_F10: //contacts 291 case Key_F10: //contacts
330 break; 292 break;
331 case Key_F11: //menu 293 case Key_F11: //menu
332 break; 294 break;
333 case Key_F12: //home 295 case Key_F12: //home
334 odebug << "Blank here" << oendl; 296 odebug << "Blank here" << oendl;
335// mediaPlayerState->toggleBlank(); 297// mediaPlayerState->toggleBlank();
336 break; 298 break;
337 case Key_F13: //mail 299 case Key_F13: //mail
338 odebug << "Blank here" << oendl; 300 odebug << "Blank here" << oendl;
339 // mediaPlayerState->toggleBlank(); 301 // mediaPlayerState->toggleBlank();
340 break; 302 break;
341 } 303 }
342} 304}
343 305
344void MediaPlayer::cleanUp() {// this happens on closing 306void MediaPlayer::cleanUp() {// this happens on closing
345 Config cfg( "OpiePlayer" ); 307 Config cfg( "OpiePlayer" );
346 mediaPlayerState.writeConfig( cfg ); 308 mediaPlayerState.writeConfig( cfg );
347 playList.writeDefaultPlaylist( ); 309 playList.writeDefaultPlaylist( );
348 310
349// QPEApplication::grabKeyboard();
350// QPEApplication::ungrabKeyboard();
351} 311}
352 312
353void MediaPlayer::recreateAudioAndVideoWidgets() const 313void MediaPlayer::recreateAudioAndVideoWidgets() const
354{ 314{
355 delete m_skinLoader; 315 delete m_skinLoader;
356 316
357 delete m_xineControl; 317 delete m_xineControl;
358 delete m_audioUI; 318 delete m_audioUI;
359 delete m_videoUI; 319 delete m_videoUI;
360 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); 320 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
361 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); 321 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
362 322
363 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 323 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
364 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 324 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
365 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 325 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
366 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 326 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
367 327
368 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 328 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
369 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 329 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
370 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 330 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
371 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 331 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
372 332
373 if ( !xine ) 333 if ( !xine )
374 xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); 334 xine = new XINE::Lib( XINE::Lib::InitializeImmediately );
375 335
376 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); 336 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState );
377 337
378 xine = 0; 338 xine = 0;
379} 339}
380 340
381AudioWidget *MediaPlayer::audioUI() const 341AudioWidget *MediaPlayer::audioUI() const
382{ 342{
383 if ( !m_audioUI ) 343 if ( !m_audioUI )
384 recreateAudioAndVideoWidgets(); 344 recreateAudioAndVideoWidgets();
385 return m_audioUI; 345 return m_audioUI;
386} 346}
387 347
388VideoWidget *MediaPlayer::videoUI() const 348VideoWidget *MediaPlayer::videoUI() const
389{ 349{
390 if ( !m_videoUI ) 350 if ( !m_videoUI )
391 recreateAudioAndVideoWidgets(); 351 recreateAudioAndVideoWidgets();
392 return m_videoUI; 352 return m_videoUI;
393} 353}
394 354
395XineControl *MediaPlayer::xineControl() const 355XineControl *MediaPlayer::xineControl() const
396{ 356{
397 if ( !m_xineControl ) 357 if ( !m_xineControl )
398 recreateAudioAndVideoWidgets(); 358 recreateAudioAndVideoWidgets();
399 return m_xineControl; 359 return m_xineControl;
400} 360}
401 361
402void MediaPlayer::reloadSkins() 362void MediaPlayer::reloadSkins()
403{ 363{
404 audioUI()->loadSkin(); 364 audioUI()->loadSkin();
405 videoUI()->loadSkin(); 365 videoUI()->loadSkin();
406} 366}
407 367
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 563ccf5..880b295 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,262 +1,255 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <simon@lst.de> 2 Copyright (C) 2002 Simon Hausmann <simon@lst.de>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This program is free software; you can redistribute it and/or 7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details. 15 General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to 18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <assert.h> 23#include <assert.h>
24 24
25#include "mediawidget.h" 25#include "mediawidget.h"
26#include "skin.h" 26#include "skin.h"
27 27
28MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 28MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
29 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 29 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
30{ 30{
31 connect( &mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), 31 connect( &mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ),
32 this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); 32 this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) );
33 connect( &mediaPlayerState, SIGNAL( lengthChanged(long) ), 33 connect( &mediaPlayerState, SIGNAL( lengthChanged(long) ),
34 this, SLOT( setLength(long) ) ); 34 this, SLOT( setLength(long) ) );
35 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), 35 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ),
36 this, SLOT( setPlaying(bool) ) ); 36 this, SLOT( setPlaying(bool) ) );
37 37
38 setBackgroundMode( NoBackground ); 38 setBackgroundMode( NoBackground );
39} 39}
40 40
41MediaWidget::~MediaWidget() 41MediaWidget::~MediaWidget()
42{ 42{
43} 43}
44 44
45void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 45void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
46 const Skin &skin ) 46 const Skin &skin )
47{ 47{
48 buttonMask = skin.buttonMask( skinInfo, buttonCount ); 48 buttonMask = skin.buttonMask( skinInfo, buttonCount );
49 49
50 buttons.clear(); 50 buttons.clear();
51 buttons.reserve( buttonCount );
52 51
53 for ( uint i = 0; i < buttonCount; ++i ) { 52 for ( uint i = 0; i < buttonCount; ++i ) {
54 Button button = setupButton( skinInfo[ i ], skin ); 53 Button button = setupButton( skinInfo[ i ], skin );
55 buttons.push_back( button ); 54 buttons.append( button );
56 } 55 }
57} 56}
58 57
59MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) 58MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
60{ 59{
61 Button button; 60 Button button;
62 button.command = buttonInfo.command; 61 button.command = buttonInfo.command;
63 button.type = buttonInfo.type; 62 button.type = buttonInfo.type;
64 button.mask = skin.buttonMaskImage( buttonInfo.fileName ); 63 button.mask = skin.buttonMaskImage( buttonInfo.fileName );
65 64
66 return button; 65 return button;
67} 66}
68 67
69void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) 68void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo )
70{ 69{
71 Skin skin( guiInfo.fileNameInfix ); 70 Skin skin( guiInfo.fileNameInfix );
72 skin.setCachable( false ); 71 skin.setCachable( false );
73 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); 72 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin );
74} 73}
75 74
76void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) 75void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin )
77{ 76{
78 backgroundPixmap = skin.backgroundPixmap(); 77 backgroundPixmap = skin.backgroundPixmap();
79 buttonUpImage = skin.buttonUpImage(); 78 buttonUpImage = skin.buttonUpImage();
80 buttonDownImage = skin.buttonDownImage(); 79 buttonDownImage = skin.buttonDownImage();
81 80
82 setupButtons( skinInfo, buttonCount, skin ); 81 setupButtons( skinInfo, buttonCount, skin );
83} 82}
84 83
85void MediaWidget::closeEvent( QCloseEvent * ) 84void MediaWidget::closeEvent( QCloseEvent * )
86{ 85{
87 mediaPlayerState.setList(); 86 mediaPlayerState.setList();
88} 87}
89 88
90void MediaWidget::paintEvent( QPaintEvent *pe ) 89void MediaWidget::paintEvent( QPaintEvent * )
91{ 90{
92 QPainter p( this ); 91 QPainter p( this );
93 92
94 if ( mediaPlayerState.isFullscreen() ) {
95 // Clear the background
96 p.setBrush( QBrush( Qt::black ) );
97 return;
98 }
99
100 QPixmap buffer( size() ); 93 QPixmap buffer( size() );
101 QPainter bufferedPainter( &buffer ); 94 QPainter bufferedPainter( &buffer );
102 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); 95 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) );
103 paintAllButtons( bufferedPainter ); 96 paintAllButtons( bufferedPainter );
104 p.drawPixmap( 0, 0, buffer ); 97 p.drawPixmap( 0, 0, buffer );
105} 98}
106 99
107void MediaWidget::resizeEvent( QResizeEvent *e ) 100void MediaWidget::resizeEvent( QResizeEvent *e )
108{ 101{
109 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); 102 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
110 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); 103 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
111 104
112 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 105 for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it ) {
113 Button &button = *it; 106 Button &button = *it;
114 107
115 if ( button.mask.isNull() ) 108 if ( button.mask.isNull() )
116 continue; 109 continue;
117 button.pixUp = addMaskToPixmap( pixUp, button.mask ); 110 button.pixUp = addMaskToPixmap( pixUp, button.mask );
118 button.pixDown = addMaskToPixmap( pixDn, button.mask ); 111 button.pixDown = addMaskToPixmap( pixDn, button.mask );
119 } 112 }
120 113
121 QWidget::resizeEvent( e ); 114 QWidget::resizeEvent( e );
122} 115}
123 116
124MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 117MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
125{ 118{
126 if ( position.x() <= 0 || position.y() <= 0 || 119 if ( position.x() <= 0 || position.y() <= 0 ||
127 position.x() >= buttonMask.width() || 120 position.x() >= buttonMask.width() ||
128 position.y() >= buttonMask.height() ) 121 position.y() >= buttonMask.height() )
129 return 0; 122 return 0;
130 123
131 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 124 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
132 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 125 for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it )
133 if ( it->command + 1 == pixelIdx ) 126 if ( (*it).command + 1 == pixelIdx )
134 return &( *it ); 127 return &( *it );
135 128
136 return 0; 129 return 0;
137} 130}
138 131
139void MediaWidget::mousePressEvent( QMouseEvent *event ) 132void MediaWidget::mousePressEvent( QMouseEvent *event )
140{ 133{
141 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 134 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
142 135
143 if ( !button ) { 136 if ( !button ) {
144 QWidget::mousePressEvent( event ); 137 QWidget::mousePressEvent( event );
145 return; 138 return;
146 } 139 }
147 140
148 switch ( button->command ) { 141 switch ( button->command ) {
149 case VolumeUp: emit moreClicked(); return; 142 case VolumeUp: emit moreClicked(); return;
150 case VolumeDown: emit lessClicked(); return; 143 case VolumeDown: emit lessClicked(); return;
151 case Back: emit backClicked(); return; 144 case Back: emit backClicked(); return;
152 case Forward: emit forwardClicked(); return; 145 case Forward: emit forwardClicked(); return;
153 default: break; 146 default: break;
154 } 147 }
155} 148}
156 149
157void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) 150void MediaWidget::mouseReleaseEvent( QMouseEvent *event )
158{ 151{
159 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 152 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
160 153
161 if ( !button ) { 154 if ( !button ) {
162 QWidget::mouseReleaseEvent( event ); 155 QWidget::mouseReleaseEvent( event );
163 return; 156 return;
164 } 157 }
165 158
166 if ( button->type == ToggleButton ) 159 if ( button->type == ToggleButton )
167 toggleButton( *button ); 160 toggleButton( *button );
168 161
169 handleCommand( button->command, button->isDown ); 162 handleCommand( button->command, button->isDown );
170} 163}
171 164
172void MediaWidget::makeVisible() 165void MediaWidget::makeVisible()
173{ 166{
174} 167}
175 168
176void MediaWidget::handleCommand( Command command, bool buttonDown ) 169void MediaWidget::handleCommand( Command command, bool buttonDown )
177{ 170{
178 switch ( command ) { 171 switch ( command ) {
179 case Play: mediaPlayerState.togglePaused(); return; 172 case Play: mediaPlayerState.togglePaused(); return;
180 case Stop: mediaPlayerState.setPlaying(FALSE); return; 173 case Stop: mediaPlayerState.setPlaying(FALSE); return;
181 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 174 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
182 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 175 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
183 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 176 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
184 case VolumeUp: emit moreReleased(); return; 177 case VolumeUp: emit moreReleased(); return;
185 case VolumeDown: emit lessReleased(); return; 178 case VolumeDown: emit lessReleased(); return;
186 case PlayList: mediaPlayerState.setList(); return; 179 case PlayList: mediaPlayerState.setList(); return;
187 case Forward: emit forwardReleased(); return; 180 case Forward: emit forwardReleased(); return;
188 case Back: emit backReleased(); return; 181 case Back: emit backReleased(); return;
189 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; 182 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
190 default: assert( false ); 183 default: assert( false );
191 } 184 }
192} 185}
193 186
194bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 187bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
195{ 188{
196 return ( position.x() > 0 && position.y() > 0 && 189 return ( position.x() > 0 && position.y() > 0 &&
197 position.x() < buttonMask.width() && 190 position.x() < buttonMask.width() &&
198 position.y() < buttonMask.height() && 191 position.y() < buttonMask.height() &&
199 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 192 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
200} 193}
201 194
202void MediaWidget::paintAllButtons( QPainter &p ) 195void MediaWidget::paintAllButtons( QPainter &p )
203{ 196{
204 for ( ButtonVector::const_iterator it = buttons.begin(); 197 for ( ButtonVector::ConstIterator it = buttons.begin();
205 it != buttons.end(); ++it ) 198 it != buttons.end(); ++it )
206 paintButton( p, *it ); 199 paintButton( p, *it );
207} 200}
208 201
209void MediaWidget::paintButton( const Button &button ) 202void MediaWidget::paintButton( const Button &button )
210{ 203{
211 QPainter p( this ); 204 QPainter p( this );
212 paintButton( p, button ); 205 paintButton( p, button );
213} 206}
214 207
215void MediaWidget::paintButton( QPainter &p, const Button &button ) 208void MediaWidget::paintButton( QPainter &p, const Button &button )
216{ 209{
217 if ( button.isDown ) 210 if ( button.isDown )
218 p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); 211 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
219 else 212 else
220 p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); 213 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
221} 214}
222 215
223void MediaWidget::setToggleButton( Command command, bool down ) 216void MediaWidget::setToggleButton( Command command, bool down )
224{ 217{
225 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 218 for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it )
226 if ( it->command == command ) { 219 if ( (*it).command == command ) {
227 setToggleButton( *it, down ); 220 setToggleButton( *it, down );
228 return; 221 return;
229 } 222 }
230} 223}
231 224
232void MediaWidget::setToggleButton( Button &button, bool down ) 225void MediaWidget::setToggleButton( Button &button, bool down )
233{ 226{
234 if ( down != button.isDown ) 227 if ( down != button.isDown )
235 toggleButton( button ); 228 toggleButton( button );
236} 229}
237 230
238void MediaWidget::toggleButton( Button &button ) 231void MediaWidget::toggleButton( Button &button )
239{ 232{
240 button.isDown = !button.isDown; 233 button.isDown = !button.isDown;
241 234
242 paintButton( button ); 235 paintButton( button );
243} 236}
244 237
245QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) 238QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset )
246{ 239{
247 QPixmap pix( image.size() ); 240 QPixmap pix( image.size() );
248 QPainter p( &pix ); 241 QPainter p( &pix );
249 p.drawTiledPixmap( pix.rect(), background, offset ); 242 p.drawTiledPixmap( pix.rect(), background, offset );
250 p.drawImage( 0, 0, image ); 243 p.drawImage( 0, 0, image );
251 return pix; 244 return pix;
252} 245}
253 246
254QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) 247QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask )
255{ 248{
256 QPixmap result( pix ); 249 QPixmap result( pix );
257 result.setMask( mask ); 250 result.setMask( mask );
258 return result; 251 return result;
259} 252}
260 253
261/* vim: et sw=4 ts=4 254/* vim: et sw=4 ts=4
262 */ 255 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 8c3a467..d885150 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,151 +1,148 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <simon@lst.de> 2 Copyright (C) 2002 Simon Hausmann <simon@lst.de>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This program is free software; you can redistribute it and/or 7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details. 15 General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to 18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef MEDIAWIDGET_H 23#ifndef MEDIAWIDGET_H
24#define MEDIAWIDGET_H 24#define MEDIAWIDGET_H
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qmap.h> 27#include <qmap.h>
28 28
29#include "mediaplayerstate.h" 29#include "mediaplayerstate.h"
30#include "playlistwidget.h" 30#include "playlistwidget.h"
31 31
32#include <vector>
33#include <memory>
34
35class Skin; 32class Skin;
36 33
37class MediaWidget : public QWidget 34class MediaWidget : public QWidget
38{ 35{
39 Q_OBJECT 36 Q_OBJECT
40public: 37public:
41 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; 38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
42 enum ButtonType { NormalButton, ToggleButton }; 39 enum ButtonType { NormalButton, ToggleButton };
43 40
44 struct Button 41 struct Button
45 { 42 {
46 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {} 43 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {}
47 44
48 Command command; 45 Command command;
49 46
50 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( 47 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
51 bool isDown : 1; 48 bool isDown : 1;
52 49
53 QBitmap mask; 50 QBitmap mask;
54 QPixmap pixUp; 51 QPixmap pixUp;
55 QPixmap pixDown; 52 QPixmap pixDown;
56 }; 53 };
57 typedef std::vector<Button> ButtonVector; 54 typedef QValueList<Button> ButtonVector;
58 55
59 struct SkinButtonInfo 56 struct SkinButtonInfo
60 { 57 {
61 Command command; 58 Command command;
62 const char *fileName; 59 const char *fileName;
63 ButtonType type; 60 ButtonType type;
64 }; 61 };
65 62
66 struct GUIInfo 63 struct GUIInfo
67 { 64 {
68 GUIInfo() : buttonInfo( 0 ), buttonCount( 0 ) {} 65 GUIInfo() : buttonInfo( 0 ), buttonCount( 0 ) {}
69 GUIInfo( const QString &_fileNameInfix, const SkinButtonInfo *_buttonInfo, const uint _buttonCount ) 66 GUIInfo( const QString &_fileNameInfix, const SkinButtonInfo *_buttonInfo, const uint _buttonCount )
70 : fileNameInfix( _fileNameInfix ), buttonInfo( _buttonInfo ), buttonCount( _buttonCount ) 67 : fileNameInfix( _fileNameInfix ), buttonInfo( _buttonInfo ), buttonCount( _buttonCount )
71 {} 68 {}
72 69
73 QString fileNameInfix; 70 QString fileNameInfix;
74 const SkinButtonInfo *buttonInfo; 71 const SkinButtonInfo *buttonInfo;
75 const uint buttonCount; 72 const uint buttonCount;
76 }; 73 };
77 typedef QValueList<GUIInfo> GUIInfoList; 74 typedef QValueList<GUIInfo> GUIInfoList;
78 75
79 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 76 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
80 virtual ~MediaWidget(); 77 virtual ~MediaWidget();
81 78
82public slots: 79public slots:
83 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 80 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
84 virtual void setLength( long length ) = 0; 81 virtual void setLength( long length ) = 0;
85 virtual void setPlaying( bool playing ) = 0; 82 virtual void setPlaying( bool playing ) = 0;
86 83
87 virtual void loadSkin() = 0; 84 virtual void loadSkin() = 0;
88 85
89signals: 86signals:
90 void moreReleased(); 87 void moreReleased();
91 void lessReleased(); 88 void lessReleased();
92 void forwardReleased(); 89 void forwardReleased();
93 void backReleased(); 90 void backReleased();
94 void forwardClicked(); 91 void forwardClicked();
95 void backClicked(); 92 void backClicked();
96 void moreClicked(); 93 void moreClicked();
97 void lessClicked(); 94 void lessClicked();
98 95
99protected: 96protected:
100 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 97 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
101 const Skin &skin ); 98 const Skin &skin );
102 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ); 99 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin );
103 100
104 void loadDefaultSkin( const GUIInfo &guiInfo ); 101 void loadDefaultSkin( const GUIInfo &guiInfo );
105 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ); 102 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin );
106 103
107 virtual void closeEvent( QCloseEvent * ); 104 virtual void closeEvent( QCloseEvent * );
108 105
109 virtual void paintEvent( QPaintEvent *pe ); 106 virtual void paintEvent( QPaintEvent *pe );
110 107
111 virtual void resizeEvent( QResizeEvent *e ); 108 virtual void resizeEvent( QResizeEvent *e );
112 109
113 Button *buttonAt( const QPoint &position ); 110 Button *buttonAt( const QPoint &position );
114 111
115 virtual void mousePressEvent( QMouseEvent *event ); 112 virtual void mousePressEvent( QMouseEvent *event );
116 virtual void mouseReleaseEvent( QMouseEvent *event ); 113 virtual void mouseReleaseEvent( QMouseEvent *event );
117 114
118 virtual void makeVisible(); 115 virtual void makeVisible();
119 116
120 void handleCommand( Command command, bool buttonDown ); 117 void handleCommand( Command command, bool buttonDown );
121 118
122 bool isOverButton( const QPoint &position, int buttonId ) const; 119 bool isOverButton( const QPoint &position, int buttonId ) const;
123 120
124 void paintAllButtons( QPainter &p ); 121 void paintAllButtons( QPainter &p );
125 void paintButton( const Button &button ); 122 void paintButton( const Button &button );
126 void paintButton( QPainter &p, const Button &button ); 123 void paintButton( QPainter &p, const Button &button );
127 124
128 void setToggleButton( Button &button, bool down ); 125 void setToggleButton( Button &button, bool down );
129 void setToggleButton( Command command, bool down ); 126 void setToggleButton( Command command, bool down );
130 void toggleButton( Button &button ); 127 void toggleButton( Button &button );
131 128
132 MediaPlayerState &mediaPlayerState; 129 MediaPlayerState &mediaPlayerState;
133 PlayListWidget &playList; 130 PlayListWidget &playList;
134 131
135 ButtonVector buttons; 132 ButtonVector buttons;
136 133
137 QImage buttonMask; 134 QImage buttonMask;
138 135
139 QPoint upperLeftOfButtonMask; 136 QPoint upperLeftOfButtonMask;
140 137
141 QPixmap backgroundPixmap; 138 QPixmap backgroundPixmap;
142 QImage buttonUpImage; 139 QImage buttonUpImage;
143 QImage buttonDownImage; 140 QImage buttonDownImage;
144 141
145 static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset ); 142 static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset );
146 static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ); 143 static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask );
147}; 144};
148 145
149#endif // MEDIAWIDGET_H 146#endif // MEDIAWIDGET_H
150/* vim: et sw=4 ts=4 147/* vim: et sw=4 ts=4
151 */ 148 */
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 36f77be..d73f0cd 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1052 +1,1049 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "playlistselection.h" 34#include "playlistselection.h"
35#include "playlistwidget.h" 35#include "playlistwidget.h"
36#include "mediaplayer.h" 36#include "mediaplayer.h"
37#include "inputDialog.h" 37#include "inputDialog.h"
38#include "om3u.h" 38#include "om3u.h"
39#include "playlistfileview.h" 39#include "playlistfileview.h"
40 40
41/* OPIE */ 41/* OPIE */
42#include <opie2/odebug.h> 42#include <opie2/odebug.h>
43#include <opie2/ofiledialog.h> 43#include <opie2/ofiledialog.h>
44using namespace Opie::Core; 44using namespace Opie::Core;
45using namespace Opie::Ui; 45using namespace Opie::Ui;
46 46
47/* QT */ 47/* QT */
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qtoolbar.h> 49#include <qtoolbar.h>
50 50
51/* STD */ 51/* STD */
52#include <assert.h> 52#include <assert.h>
53 53
54PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) 54PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
55 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) 55 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 )
56{ 56{
57 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); 57 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" );
58 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); 58 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer");
59 59
60 60
61 61
62 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 62 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
63 "opieplayer2/add_to_playlist", 63 "opieplayer2/add_to_playlist",
64 this , SLOT(addSelected() ) ); 64 this , SLOT(addSelected() ) );
65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
66 "opieplayer2/remove_from_playlist", 66 "opieplayer2/remove_from_playlist",
67 this , SLOT(removeSelected() ) ); 67 this , SLOT(removeSelected() ) );
68 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 68 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
69 this , SLOT( btnPlay(bool) ), TRUE ); 69 this , SLOT( btnPlay(bool) ), TRUE );
70 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 70 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
71 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); 71 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE );
72 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 72 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
73 mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); 73 mediaPlayerState, SLOT( setLooping(bool) ), TRUE );
74 74
75 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 75 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
76 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 76 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
77 this, SLOT( addAllMusicToList() ) ); 77 this, SLOT( addAllMusicToList() ) );
78 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 78 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
79 this, SLOT( addAllVideoToList() ) ); 79 this, SLOT( addAllVideoToList() ) );
80 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 80 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
81 this, SLOT( addAllToList() ) ); 81 this, SLOT( addAllToList() ) );
82 pmPlayList->insertSeparator(-1); 82 pmPlayList->insertSeparator(-1);
83 (void)new MenuItem( pmPlayList, tr( "Add File" ), 83 (void)new MenuItem( pmPlayList, tr( "Add File" ),
84 this,SLOT( openFile() ) ); 84 this,SLOT( openFile() ) );
85 (void)new MenuItem( pmPlayList, tr("Add URL"), 85 (void)new MenuItem( pmPlayList, tr("Add URL"),
86 this,SLOT( openURL() ) ); 86 this,SLOT( openURL() ) );
87 pmPlayList->insertSeparator(-1); 87 pmPlayList->insertSeparator(-1);
88 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 88 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
89 this, SLOT(writem3u() ) ); 89 this, SLOT(writem3u() ) );
90 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
91 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 91 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
92 audioView, SLOT( scanFiles() ) ); 92 audioView, SLOT( scanFiles() ) );
93 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 93 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
94 videoView, SLOT( scanFiles() ) ); 94 videoView, SLOT( scanFiles() ) );
95 95
96 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 96 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
97 mediaPlayerState, SLOT( toggleFullscreen() ) ); 97 mediaPlayerState, SLOT( toggleFullscreen() ) );
98 98
99 Config cfg( "OpiePlayer" ); 99 Config cfg( "OpiePlayer" );
100 bool b= cfg.readBoolEntry("FullScreen", 0); 100 bool b= cfg.readBoolEntry("FullScreen", 0);
101 mediaPlayerState->setFullscreen( b ); 101 mediaPlayerState->setFullscreen( b );
102 pmView->setItemChecked( -16, b ); 102 pmView->setItemChecked( -16, b );
103 103
104 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 104 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
105 d->selectedFiles, SLOT(moveSelectedUp() ) ); 105 d->selectedFiles, SLOT(moveSelectedUp() ) );
106 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 106 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
107 d->selectedFiles, SLOT(removeSelected() ) ); 107 d->selectedFiles, SLOT(removeSelected() ) );
108 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 108 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
109 d->selectedFiles, SLOT(moveSelectedDown() ) ); 109 d->selectedFiles, SLOT(moveSelectedDown() ) );
110 QVBox *stretch2 = new QVBox( vbox1 ); 110 QVBox *stretch2 = new QVBox( vbox1 );
111 111
112 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 112 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
113 SLOT( deletePlaylist() ) ); 113 SLOT( deletePlaylist() ) );
114 connect( pmView, SIGNAL( activated(int) ), 114 connect( pmView, SIGNAL( activated(int) ),
115 this, SLOT( pmViewActivated(int) ) ); 115 this, SLOT( pmViewActivated(int) ) );
116 connect( skinsMenu, SIGNAL( activated(int) ) , 116 connect( skinsMenu, SIGNAL( activated(int) ) ,
117 this, SLOT( skinsMenuActivated(int) ) ); 117 this, SLOT( skinsMenuActivated(int) ) );
118 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 118 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
119 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); 119 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) );
120 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 120 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
121 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 121 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
122 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), 122 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ),
123 this,SLOT( playIt(QListViewItem*) ) ); 123 this,SLOT( playIt(QListViewItem*) ) );
124 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), 124 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ),
125 this, SLOT( addToSelection(QListViewItem*) ) ); 125 this, SLOT( addToSelection(QListViewItem*) ) );
126 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 126 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
127 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 127 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
128 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), 128 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ),
129 this,SLOT( playIt(QListViewItem*) ) ); 129 this,SLOT( playIt(QListViewItem*) ) );
130 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), 130 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ),
131 this, SLOT( addToSelection(QListViewItem*) ) ); 131 this, SLOT( addToSelection(QListViewItem*) ) );
132 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), 132 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ),
133 this, SLOT( loadList(const DocLnk&) ) ); 133 this, SLOT( loadList(const DocLnk&) ) );
134 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 134 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
135 this, SLOT( tabChanged(QWidget*) ) ); 135 this, SLOT( tabChanged(QWidget*) ) );
136 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), 136 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ),
137 d->tbPlay, SLOT( setOn(bool) ) ); 137 d->tbPlay, SLOT( setOn(bool) ) );
138 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), 138 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ),
139 d->tbLoop, SLOT( setOn(bool) ) ); 139 d->tbLoop, SLOT( setOn(bool) ) );
140 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), 140 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ),
141 d->tbShuffle, SLOT( setOn(bool) ) ); 141 d->tbShuffle, SLOT( setOn(bool) ) );
142 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), 142 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ),
143 this, SLOT( playIt(QListViewItem*) ) ); 143 this, SLOT( playIt(QListViewItem*) ) );
144 connect ( gammaSlider, SIGNAL( valueChanged(int) ), 144 connect ( gammaSlider, SIGNAL( valueChanged(int) ),
145 mediaPlayerState, SLOT( setVideoGamma(int) ) ); 145 mediaPlayerState, SLOT( setVideoGamma(int) ) );
146 146
147 connect( this, SIGNAL(skinSelected() ), 147 connect( this, SIGNAL(skinSelected() ),
148 m_mp, SLOT( reloadSkins() ) ); 148 m_mp, SLOT( reloadSkins() ) );
149 149
150 // see which skins are installed 150 // see which skins are installed
151 populateSkinsMenu(); 151 populateSkinsMenu();
152 initializeStates(); 152 initializeStates();
153 153
154 channel = new QCopChannel( "QPE/Application/opieplayer2", this ); 154 channel = new QCopChannel( "QPE/Application/opieplayer2", this );
155 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 155 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
156 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 156 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
157 157
158 158
159 cfg.setGroup("PlayList"); 159 cfg.setGroup("PlayList");
160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
161 loadList(DocLnk( currentPlaylist ) ); 161 loadList(DocLnk( currentPlaylist ) );
162 162
163 tabWidget->showPage( playListTab ); 163 tabWidget->showPage( playListTab );
164} 164}
165 165
166 166
167PlayListWidget::~PlayListWidget() { 167PlayListWidget::~PlayListWidget() {
168 delete d; 168 delete d;
169 delete m_mp; 169 delete m_mp;
170} 170}
171 171
172 172
173void PlayListWidget::initializeStates() { 173void PlayListWidget::initializeStates() {
174 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 174 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
175 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 175 d->tbLoop->setOn( mediaPlayerState->isLooping() );
176 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 176 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
177 d->playListFrame->show(); 177 d->playListFrame->show();
178} 178}
179 179
180void PlayListWidget::writeDefaultPlaylist() { 180void PlayListWidget::writeDefaultPlaylist() {
181 181
182 Config config( "OpiePlayer" ); 182 Config config( "OpiePlayer" );
183 config.setGroup( "PlayList" ); 183 config.setGroup( "PlayList" );
184 QString filename=QPEApplication::documentDir() + "/default.m3u"; 184 QString filename=QPEApplication::documentDir() + "/default.m3u";
185 QString currentString = config.readEntry( "CurrentPlaylist", filename); 185 QString currentString = config.readEntry( "CurrentPlaylist", filename);
186 if( currentString == filename) { 186 if( currentString == filename) {
187 Om3u *m3uList; 187 Om3u *m3uList;
188 // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl;
189 if( d->selectedFiles->first() ) { 188 if( d->selectedFiles->first() ) {
190 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 189 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
191 do { 190 do {
192 // odebug << d->selectedFiles->current()->file() << oendl;
193 m3uList->add( d->selectedFiles->current()->file() ); 191 m3uList->add( d->selectedFiles->current()->file() );
194 } 192 }
195 while ( d->selectedFiles->next() ); 193 while ( d->selectedFiles->next() );
196 194
197 m3uList->write(); 195 m3uList->write();
198 m3uList->close(); 196 m3uList->close();
199 delete m3uList; 197 delete m3uList;
200 198
201 } 199 }
202 } 200 }
203} 201}
204 202
205void PlayListWidget::addToSelection( const DocLnk& lnk ) { 203void PlayListWidget::addToSelection( const DocLnk& lnk ) {
206 d->setDocumentUsed = FALSE; 204 d->setDocumentUsed = FALSE;
207 if( QFileInfo( lnk.file() ).exists() || 205 if( QFileInfo( lnk.file() ).exists() ||
208 lnk.file().left(4) == "http" ) { 206 lnk.file().left(4) == "http" ) {
209 d->selectedFiles->addToSelection( lnk ); 207 d->selectedFiles->addToSelection( lnk );
210 } 208 }
211// writeCurrentM3u();
212} 209}
213 210
214 211
215void PlayListWidget::clearList() { 212void PlayListWidget::clearList() {
216 while ( first() ) { 213 while ( first() ) {
217 d->selectedFiles->removeSelected(); 214 d->selectedFiles->removeSelected();
218 } 215 }
219 Config cfg( "OpiePlayer" ); 216 Config cfg( "OpiePlayer" );
220 cfg.setGroup("PlayList"); 217 cfg.setGroup("PlayList");
221 cfg.writeEntry("CurrentPlaylist","default"); 218 cfg.writeEntry("CurrentPlaylist","default");
222 setCaption("OpiePlayer"); 219 setCaption("OpiePlayer");
223} 220}
224 221
225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 222void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
226 switch (mouse) { 223 switch (mouse) {
227 case LeftButton: 224 case LeftButton:
228 break; 225 break;
229 case RightButton: 226 case RightButton:
230 { 227 {
231 QPopupMenu m; 228 QPopupMenu m;
232 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 229 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
233 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 230 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
234 m.exec( QCursor::pos() ); 231 m.exec( QCursor::pos() );
235 } 232 }
236 break; 233 break;
237 } 234 }
238} 235}
239 236
240 237
241void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 238void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
242 switch (mouse) { 239 switch (mouse) {
243 case LeftButton: 240 case LeftButton:
244 break; 241 break;
245 case RightButton: 242 case RightButton:
246 { 243 {
247 QPopupMenu m; 244 QPopupMenu m;
248 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 245 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
249 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 246 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
250 m.exec( QCursor::pos() ); 247 m.exec( QCursor::pos() );
251 } 248 }
252 break; 249 break;
253 } 250 }
254} 251}
255 252
256 253
257void PlayListWidget::addAllToList() { 254void PlayListWidget::addAllToList() {
258 255
259 256
260 audioView->populateView(); 257 audioView->populateView();
261 258
262 QListViewItemIterator audioIt( audioView ); 259 QListViewItemIterator audioIt( audioView );
263 DocLnk lnk; 260 DocLnk lnk;
264 QString filename; 261 QString filename;
265 // iterate through all items of the listview 262 // iterate through all items of the listview
266 for ( ; audioIt.current(); ++audioIt ) { 263 for ( ; audioIt.current(); ++audioIt ) {
267 filename = audioIt.current()->text(3); 264 filename = audioIt.current()->text(3);
268 lnk.setName( QFileInfo(filename).baseName() ); //sets name 265 lnk.setName( QFileInfo(filename).baseName() ); //sets name
269 lnk.setFile( filename ); //sets file name 266 lnk.setFile( filename ); //sets file name
270 d->selectedFiles->addToSelection( lnk); 267 d->selectedFiles->addToSelection( lnk);
271 } 268 }
272 269
273 videoView->populateView(); 270 videoView->populateView();
274 271
275 QListViewItemIterator videoIt( videoView ); 272 QListViewItemIterator videoIt( videoView );
276 for ( ; videoIt.current(); ++videoIt ) { 273 for ( ; videoIt.current(); ++videoIt ) {
277 filename = videoIt.current()->text(3); 274 filename = videoIt.current()->text(3);
278 lnk.setName( QFileInfo(filename).baseName() ); //sets name 275 lnk.setName( QFileInfo(filename).baseName() ); //sets name
279 lnk.setFile( filename ); //sets file name 276 lnk.setFile( filename ); //sets file name
280 d->selectedFiles->addToSelection( lnk); 277 d->selectedFiles->addToSelection( lnk);
281 } 278 }
282 279
283 tabWidget->setCurrentPage(0); 280 tabWidget->setCurrentPage(0);
284 281
285 writeCurrentM3u(); 282 writeCurrentM3u();
286 d->selectedFiles->first(); 283 d->selectedFiles->first();
287} 284}
288 285
289 286
290void PlayListWidget::addAllMusicToList() { 287void PlayListWidget::addAllMusicToList() {
291 288
292 audioView->populateView(); 289 audioView->populateView();
293 290
294 QListViewItemIterator audioIt( audioView ); 291 QListViewItemIterator audioIt( audioView );
295 DocLnk lnk; 292 DocLnk lnk;
296 QString filename; 293 QString filename;
297 // iterate through all items of the listview 294 // iterate through all items of the listview
298 for ( ; audioIt.current(); ++audioIt ) { 295 for ( ; audioIt.current(); ++audioIt ) {
299 filename = audioIt.current()->text(3); 296 filename = audioIt.current()->text(3);
300 lnk.setName( QFileInfo(filename).baseName() ); //sets name 297 lnk.setName( QFileInfo(filename).baseName() ); //sets name
301 lnk.setFile( filename ); //sets file name 298 lnk.setFile( filename ); //sets file name
302 d->selectedFiles->addToSelection( lnk); 299 d->selectedFiles->addToSelection( lnk);
303 } 300 }
304 301
305 tabWidget->setCurrentPage(0); 302 tabWidget->setCurrentPage(0);
306 writeCurrentM3u(); 303 writeCurrentM3u();
307 d->selectedFiles->first(); 304 d->selectedFiles->first();
308} 305}
309 306
310 307
311void PlayListWidget::addAllVideoToList() { 308void PlayListWidget::addAllVideoToList() {
312 309
313 videoView->populateView(); 310 videoView->populateView();
314 311
315 QListViewItemIterator videoIt( videoView ); 312 QListViewItemIterator videoIt( videoView );
316 DocLnk lnk; 313 DocLnk lnk;
317 QString filename; 314 QString filename;
318 for ( ; videoIt.current(); ++videoIt ) { 315 for ( ; videoIt.current(); ++videoIt ) {
319 filename = videoIt.current()->text(3); 316 filename = videoIt.current()->text(3);
320 lnk.setName( QFileInfo(filename).baseName() ); //sets name 317 lnk.setName( QFileInfo(filename).baseName() ); //sets name
321 lnk.setFile( filename ); //sets file name 318 lnk.setFile( filename ); //sets file name
322 d->selectedFiles->addToSelection( lnk); 319 d->selectedFiles->addToSelection( lnk);
323 } 320 }
324 tabWidget->setCurrentPage(0); 321 tabWidget->setCurrentPage(0);
325 writeCurrentM3u(); 322 writeCurrentM3u();
326 d->selectedFiles->first(); 323 d->selectedFiles->first();
327} 324}
328 325
329 326
330void PlayListWidget::setDocument( const QString& _fileref ) { 327void PlayListWidget::setDocument( const QString& _fileref ) {
331 // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; 328 // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl;
332 QString fileref = _fileref; 329 QString fileref = _fileref;
333 fromSetDocument = TRUE; 330 fromSetDocument = TRUE;
334 331
335 DocLnk lnk(_fileref); 332 DocLnk lnk(_fileref);
336 if(lnk.isValid()) 333 if(lnk.isValid())
337 fileref = lnk.file(); 334 fileref = lnk.file();
338 335
339 QFileInfo fileInfo(fileref); 336 QFileInfo fileInfo(fileref);
340 337
341 if ( !fileInfo.exists() ) { 338 if ( !fileInfo.exists() ) {
342 QMessageBox::warning( this, tr( "Invalid File" ), 339 QMessageBox::warning( this, tr( "Invalid File" ),
343 tr( "There was a problem in getting the file." ) ); 340 tr( "There was a problem in getting the file." ) );
344 return; 341 return;
345 } 342 }
346 343
347 clearList(); 344 clearList();
348 QString extension = fileInfo.extension(false); 345 QString extension = fileInfo.extension(false);
349 346
350 if( extension.find( "m3u", 0, false) != -1 347 if( extension.find( "m3u", 0, false) != -1
351 || extension.find( "pls", 0, false) != -1 ) { 348 || extension.find( "pls", 0, false) != -1 ) {
352 readListFromFile( fileref ); 349 readListFromFile( fileref );
353 } else { 350 } else {
354 clearList(); 351 clearList();
355 DocLnk lnk; 352 DocLnk lnk;
356 lnk.setName( fileInfo.baseName() ); //sets name 353 lnk.setName( fileInfo.baseName() ); //sets name
357 lnk.setFile( fileref ); //sets file name 354 lnk.setFile( fileref ); //sets file name
358 addToSelection( lnk ); 355 addToSelection( lnk );
359 writeCurrentM3u(); 356 writeCurrentM3u();
360 357
361 d->setDocumentUsed = TRUE; 358 d->setDocumentUsed = TRUE;
362 mediaPlayerState->setPlaying( FALSE ); 359 mediaPlayerState->setPlaying( FALSE );
363 mediaPlayerState->setPlaying( TRUE ); 360 mediaPlayerState->setPlaying( TRUE );
364 } 361 }
365} 362}
366 363
367 364
368void PlayListWidget::useSelectedDocument() { 365void PlayListWidget::useSelectedDocument() {
369 d->setDocumentUsed = FALSE; 366 d->setDocumentUsed = FALSE;
370} 367}
371 368
372 369
373const DocLnk *PlayListWidget::current() const { // this is fugly 370const DocLnk *PlayListWidget::current() const { // this is fugly
374 assert( currentTab() == CurrentPlayList ); 371 assert( currentTab() == CurrentPlayList );
375 372
376 const DocLnk *lnk = d->selectedFiles->current(); 373 const DocLnk *lnk = d->selectedFiles->current();
377 if ( !lnk ) { 374 if ( !lnk ) {
378 d->selectedFiles->first(); 375 d->selectedFiles->first();
379 lnk = d->selectedFiles->current(); 376 lnk = d->selectedFiles->current();
380 } 377 }
381 assert( lnk ); 378 assert( lnk );
382 return lnk; 379 return lnk;
383} 380}
384 381
385 382
386bool PlayListWidget::prev() { 383bool PlayListWidget::prev() {
387 if ( mediaPlayerState->isShuffled() ) { 384 if ( mediaPlayerState->isShuffled() ) {
388 const DocLnk *cur = current(); 385 const DocLnk *cur = current();
389 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 386 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
390 for ( int i = 0; i < j; i++ ) { 387 for ( int i = 0; i < j; i++ ) {
391 if ( !d->selectedFiles->next() ) 388 if ( !d->selectedFiles->next() )
392 d->selectedFiles->first(); 389 d->selectedFiles->first();
393 } 390 }
394 if ( cur == current() ) 391 if ( cur == current() )
395 if ( !d->selectedFiles->next() ) { 392 if ( !d->selectedFiles->next() ) {
396 d->selectedFiles->first(); 393 d->selectedFiles->first();
397 } 394 }
398 return TRUE; 395 return TRUE;
399 } else { 396 } else {
400 if ( !d->selectedFiles->prev() ) { 397 if ( !d->selectedFiles->prev() ) {
401 if ( mediaPlayerState->isLooping() ) { 398 if ( mediaPlayerState->isLooping() ) {
402 return d->selectedFiles->last(); 399 return d->selectedFiles->last();
403 } else { 400 } else {
404 return FALSE; 401 return FALSE;
405 } 402 }
406 } 403 }
407 return TRUE; 404 return TRUE;
408 } 405 }
409} 406}
410 407
411 408
412bool PlayListWidget::next() { 409bool PlayListWidget::next() {
413//odebug << "<<<<<<<<<<<<next()" << oendl; 410//odebug << "<<<<<<<<<<<<next()" << oendl;
414 if ( mediaPlayerState->isShuffled() ) { 411 if ( mediaPlayerState->isShuffled() ) {
415 return prev(); 412 return prev();
416 } else { 413 } else {
417 if ( !d->selectedFiles->next() ) { 414 if ( !d->selectedFiles->next() ) {
418 if ( mediaPlayerState->isLooping() ) { 415 if ( mediaPlayerState->isLooping() ) {
419 return d->selectedFiles->first(); 416 return d->selectedFiles->first();
420 } else { 417 } else {
421 return FALSE; 418 return FALSE;
422 } 419 }
423 } 420 }
424 return TRUE; 421 return TRUE;
425 } 422 }
426} 423}
427 424
428 425
429bool PlayListWidget::first() { 426bool PlayListWidget::first() {
430 return d->selectedFiles->first(); 427 return d->selectedFiles->first();
431} 428}
432 429
433 430
434bool PlayListWidget::last() { 431bool PlayListWidget::last() {
435 return d->selectedFiles->last(); 432 return d->selectedFiles->last();
436} 433}
437 434
438 435
439 void PlayListWidget::saveList() { 436 void PlayListWidget::saveList() {
440 writem3u(); 437 writem3u();
441 } 438 }
442 439
443 440
444void PlayListWidget::loadList( const DocLnk & lnk) { 441void PlayListWidget::loadList( const DocLnk & lnk) {
445 QString name = lnk.name(); 442 QString name = lnk.name();
446 443
447 if( name.length()>0) { 444 if( name.length()>0) {
448 setCaption("OpiePlayer: "+name); 445 setCaption("OpiePlayer: "+name);
449 clearList(); 446 clearList();
450 readListFromFile(lnk.file()); 447 readListFromFile(lnk.file());
451 tabWidget->setCurrentPage(0); 448 tabWidget->setCurrentPage(0);
452 } 449 }
453} 450}
454 451
455void PlayListWidget::addSelected() { 452void PlayListWidget::addSelected() {
456 assert( inFileListMode() ); 453 assert( inFileListMode() );
457 454
458 QListViewItemIterator it( currentFileListView ); 455 QListViewItemIterator it( currentFileListView );
459 for ( ; it.current(); ++it ) 456 for ( ; it.current(); ++it )
460 if ( it.current()->isSelected() ) { 457 if ( it.current()->isSelected() ) {
461 QString filename = it.current()->text(3); 458 QString filename = it.current()->text(3);
462 459
463 DocLnk lnk; 460 DocLnk lnk;
464 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 461 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
465 lnk.setFile( filename ); //sets file name 462 lnk.setFile( filename ); //sets file name
466 463
467 d->selectedFiles->addToSelection( lnk ); 464 d->selectedFiles->addToSelection( lnk );
468 } 465 }
469 466
470 currentFileListView->clearSelection(); 467 currentFileListView->clearSelection();
471 468
472 writeCurrentM3u(); 469 writeCurrentM3u();
473} 470}
474 471
475 472
476void PlayListWidget::removeSelected() { 473void PlayListWidget::removeSelected() {
477 d->selectedFiles->removeSelected( ); 474 d->selectedFiles->removeSelected( );
478 writeCurrentM3u(); 475 writeCurrentM3u();
479} 476}
480 477
481 478
482void PlayListWidget::playIt( QListViewItem *it) { 479void PlayListWidget::playIt( QListViewItem *it) {
483 if(!it) return; 480 if(!it) return;
484 mediaPlayerState->setPlaying(FALSE); 481 mediaPlayerState->setPlaying(FALSE);
485 mediaPlayerState->setPlaying(TRUE); 482 mediaPlayerState->setPlaying(TRUE);
486 d->selectedFiles->unSelect(); 483 d->selectedFiles->unSelect();
487} 484}
488 485
489 486
490void PlayListWidget::addToSelection( QListViewItem *it) { 487void PlayListWidget::addToSelection( QListViewItem *it) {
491 d->setDocumentUsed = FALSE; 488 d->setDocumentUsed = FALSE;
492 489
493 if(it) { 490 if(it) {
494 if ( currentTab() == CurrentPlayList ) 491 if ( currentTab() == CurrentPlayList )
495 return; 492 return;
496 DocLnk lnk; 493 DocLnk lnk;
497 QString filename; 494 QString filename;
498 495
499 filename=it->text(3); 496 filename=it->text(3);
500 lnk.setName( QFileInfo(filename).baseName() ); //sets name 497 lnk.setName( QFileInfo(filename).baseName() ); //sets name
501 lnk.setFile( filename ); //sets file name 498 lnk.setFile( filename ); //sets file name
502 d->selectedFiles->addToSelection( lnk); 499 d->selectedFiles->addToSelection( lnk);
503 500
504 writeCurrentM3u(); 501 writeCurrentM3u();
505// tabWidget->setCurrentPage(0); 502// tabWidget->setCurrentPage(0);
506 503
507 } 504 }
508} 505}
509 506
510 507
511void PlayListWidget::tabChanged(QWidget *) { 508void PlayListWidget::tabChanged(QWidget *) {
512 509
513 d->tbPlay->setEnabled( true ); 510 d->tbPlay->setEnabled( true );
514 511
515 disconnect( audioView, SIGNAL( itemsSelected(bool) ), 512 disconnect( audioView, SIGNAL( itemsSelected(bool) ),
516 d->tbPlay, SLOT( setEnabled(bool) ) ); 513 d->tbPlay, SLOT( setEnabled(bool) ) );
517 disconnect( videoView, SIGNAL( itemsSelected(bool) ), 514 disconnect( videoView, SIGNAL( itemsSelected(bool) ),
518 d->tbPlay, SLOT( setEnabled(bool) ) ); 515 d->tbPlay, SLOT( setEnabled(bool) ) );
519 516
520 currentFileListView = 0; 517 currentFileListView = 0;
521 518
522 switch ( currentTab() ) { 519 switch ( currentTab() ) {
523 case CurrentPlayList: 520 case CurrentPlayList:
524 { 521 {
525 if( !tbDeletePlaylist->isHidden() ) { 522 if( !tbDeletePlaylist->isHidden() ) {
526 tbDeletePlaylist->hide(); 523 tbDeletePlaylist->hide();
527 } 524 }
528 d->tbRemoveFromList->setEnabled(TRUE); 525 d->tbRemoveFromList->setEnabled(TRUE);
529 d->tbAddToList->setEnabled(FALSE); 526 d->tbAddToList->setEnabled(FALSE);
530 527
531 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); 528 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
532 } 529 }
533 break; 530 break;
534 case AudioFiles: 531 case AudioFiles:
535 { 532 {
536 audioView->populateView(); 533 audioView->populateView();
537 534
538 if( !tbDeletePlaylist->isHidden() ) { 535 if( !tbDeletePlaylist->isHidden() ) {
539 tbDeletePlaylist->hide(); 536 tbDeletePlaylist->hide();
540 } 537 }
541 d->tbRemoveFromList->setEnabled(FALSE); 538 d->tbRemoveFromList->setEnabled(FALSE);
542 d->tbAddToList->setEnabled(TRUE); 539 d->tbAddToList->setEnabled(TRUE);
543 540
544 connect( audioView, SIGNAL( itemsSelected(bool) ), 541 connect( audioView, SIGNAL( itemsSelected(bool) ),
545 d->tbPlay, SLOT( setEnabled(bool) ) ); 542 d->tbPlay, SLOT( setEnabled(bool) ) );
546 543
547 d->tbPlay->setEnabled( audioView->hasSelection() ); 544 d->tbPlay->setEnabled( audioView->hasSelection() );
548 545
549 currentFileListView = audioView; 546 currentFileListView = audioView;
550 } 547 }
551 break; 548 break;
552 case VideoFiles: 549 case VideoFiles:
553 { 550 {
554 videoView->populateView(); 551 videoView->populateView();
555 if( !tbDeletePlaylist->isHidden() ) { 552 if( !tbDeletePlaylist->isHidden() ) {
556 tbDeletePlaylist->hide(); 553 tbDeletePlaylist->hide();
557 } 554 }
558 d->tbRemoveFromList->setEnabled(FALSE); 555 d->tbRemoveFromList->setEnabled(FALSE);
559 d->tbAddToList->setEnabled(TRUE); 556 d->tbAddToList->setEnabled(TRUE);
560 557
561 connect( videoView, SIGNAL( itemsSelected(bool) ), 558 connect( videoView, SIGNAL( itemsSelected(bool) ),
562 d->tbPlay, SLOT( setEnabled(bool) ) ); 559 d->tbPlay, SLOT( setEnabled(bool) ) );
563 560
564 d->tbPlay->setEnabled( videoView->hasSelection() ); 561 d->tbPlay->setEnabled( videoView->hasSelection() );
565 562
566 currentFileListView = videoView; 563 currentFileListView = videoView;
567 } 564 }
568 break; 565 break;
569 case PlayLists: 566 case PlayLists:
570 { 567 {
571 if( tbDeletePlaylist->isHidden() ) { 568 if( tbDeletePlaylist->isHidden() ) {
572 tbDeletePlaylist->show(); 569 tbDeletePlaylist->show();
573 } 570 }
574 playLists->reread(); 571 playLists->reread();
575 d->tbAddToList->setEnabled(FALSE); 572 d->tbAddToList->setEnabled(FALSE);
576 573
577 d->tbPlay->setEnabled( false ); 574 d->tbPlay->setEnabled( false );
578 } 575 }
579 break; 576 break;
580 }; 577 };
581} 578}
582 579
583 580
584void PlayListWidget::btnPlay(bool b) { 581void PlayListWidget::btnPlay(bool b) {
585// mediaPlayerState->setPlaying(false); 582// mediaPlayerState->setPlaying(false);
586 mediaPlayerState->setPlaying(b); 583 mediaPlayerState->setPlaying(b);
587 insanityBool=FALSE; 584 insanityBool=FALSE;
588} 585}
589 586
590void PlayListWidget::deletePlaylist() { 587void PlayListWidget::deletePlaylist() {
591 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 588 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
592 (tr("You really want to delete\nthis playlist?")), 589 (tr("You really want to delete\nthis playlist?")),
593 (tr("Yes")), (tr("No")), 0 )){ 590 (tr("Yes")), (tr("No")), 0 )){
594 case 0: // Yes clicked, 591 case 0: // Yes clicked,
595 QFile().remove(playLists->selectedDocument().file()); 592 QFile().remove(playLists->selectedDocument().file());
596 QFile().remove(playLists->selectedDocument().linkFile()); 593 QFile().remove(playLists->selectedDocument().linkFile());
597 playLists->reread(); 594 playLists->reread();
598 break; 595 break;
599 case 1: // Cancel 596 case 1: // Cancel
600 break; 597 break;
601 }; 598 };
602} 599}
603 600
604 601
605void PlayListWidget::playSelected() { 602void PlayListWidget::playSelected() {
606 btnPlay( TRUE); 603 btnPlay( TRUE);
607} 604}
608 605
609bool PlayListWidget::inFileListMode() const 606bool PlayListWidget::inFileListMode() const
610{ 607{
611 TabType tab = currentTab(); 608 TabType tab = currentTab();
612 return tab == AudioFiles || tab == VideoFiles; 609 return tab == AudioFiles || tab == VideoFiles;
613} 610}
614 611
615void PlayListWidget::openURL() { 612void PlayListWidget::openURL() {
616 // http://66.28.164.33:2080 613 // http://66.28.164.33:2080
617 // http://somafm.com/star0242.m3u 614 // http://somafm.com/star0242.m3u
618 QString filename, name; 615 QString filename, name;
619 InputDialog *fileDlg; 616 InputDialog *fileDlg;
620 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); 617 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0);
621 fileDlg->exec(); 618 fileDlg->exec();
622 if( fileDlg->result() == 1 ) { 619 if( fileDlg->result() == 1 ) {
623 filename = fileDlg->text(); 620 filename = fileDlg->text();
624 odebug << "Selected filename is " + filename << oendl; 621 odebug << "Selected filename is " + filename << oendl;
625 // Om3u *m3uList; 622 // Om3u *m3uList;
626 DocLnk lnk; 623 DocLnk lnk;
627 Config cfg( "OpiePlayer" ); 624 Config cfg( "OpiePlayer" );
628 cfg.setGroup("PlayList"); 625 cfg.setGroup("PlayList");
629 626
630 if(filename.left(4) == "http") { 627 if(filename.left(4) == "http") {
631 QString m3uFile, m3uFilePath; 628 QString m3uFile, m3uFilePath;
632 if(filename.find(":",8,TRUE) != -1) { //found a port 629 if(filename.find(":",8,TRUE) != -1) { //found a port
633 m3uFile = filename.left( filename.find( ":",8,TRUE)); 630 m3uFile = filename.left( filename.find( ":",8,TRUE));
634 m3uFile = m3uFile.right( 7); 631 m3uFile = m3uFile.right( 7);
635 } else if(filename.left(4) == "http"){ 632 } else if(filename.left(4) == "http"){
636 m3uFile=filename; 633 m3uFile=filename;
637 m3uFile = m3uFile.right( m3uFile.length() - 7); 634 m3uFile = m3uFile.right( m3uFile.length() - 7);
638 } else{ 635 } else{
639 m3uFile=filename; 636 m3uFile=filename;
640 } 637 }
641 638
642 lnk.setName( filename ); //sets name 639 lnk.setName( filename ); //sets name
643 lnk.setFile( filename ); //sets file name 640 lnk.setFile( filename ); //sets file name
644 641
645// lnk.setIcon("opieplayer2/musicfile"); 642// lnk.setIcon("opieplayer2/musicfile");
646 643
647 d->selectedFiles->addToSelection( lnk ); 644 d->selectedFiles->addToSelection( lnk );
648 writeCurrentM3u(); 645 writeCurrentM3u();
649 d->selectedFiles->setSelectedItem( lnk.name()); 646 d->selectedFiles->setSelectedItem( lnk.name());
650 } 647 }
651 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 648 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
652 readListFromFile( filename ); 649 readListFromFile( filename );
653 } else { 650 } else {
654 lnk.setName( QFileInfo(filename).baseName() ); //sets name 651 lnk.setName( QFileInfo(filename).baseName() ); //sets name
655 lnk.setFile( filename ); //sets file name 652 lnk.setFile( filename ); //sets file name
656 d->selectedFiles->addToSelection( lnk); 653 d->selectedFiles->addToSelection( lnk);
657 writeCurrentM3u(); 654 writeCurrentM3u();
658 d->selectedFiles->setSelectedItem( lnk.name()); 655 d->selectedFiles->setSelectedItem( lnk.name());
659 } 656 }
660 } 657 }
661 658
662 659
663 delete fileDlg; 660 delete fileDlg;
664} 661}
665 662
666 663
667void PlayListWidget::openFile() { 664void PlayListWidget::openFile() {
668 665
669 QString filename, name; 666 QString filename, name;
670 667
671 Config cfg( "OpiePlayer" ); 668 Config cfg( "OpiePlayer" );
672 cfg.setGroup("Dialog"); 669 cfg.setGroup("Dialog");
673 MimeTypes types; 670 MimeTypes types;
674 QStringList audio, video, all; 671 QStringList audio, video, all;
675 audio << "audio/*"; 672 audio << "audio/*";
676 audio << "playlist/plain"; 673 audio << "playlist/plain";
677 audio << "audio/x-ogg"; 674 audio << "audio/x-ogg";
678 audio << "audio/x-mpegurl"; 675 audio << "audio/x-mpegurl";
679 676
680 video << "video/*"; 677 video << "video/*";
681 video << "playlist/plain"; 678 video << "playlist/plain";
682 679
683 all += audio; 680 all += audio;
684 all += video; 681 all += video;
685 types.insert("All Media Files", all ); 682 types.insert("All Media Files", all );
686 types.insert("Audio", audio ); 683 types.insert("Audio", audio );
687 types.insert("Video", video ); 684 types.insert("Video", video );
688 685
689 QString str = OFileDialog::getOpenFileName( 1, 686 QString str = OFileDialog::getOpenFileName( 1,
690 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 687 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
691 types, 0 ); 688 types, 0 );
692 689
693 if(str.left(2) == "//") { 690 if(str.left(2) == "//") {
694 str=str.right(str.length()-1); 691 str=str.right(str.length()-1);
695 } 692 }
696 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); 693 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() );
697 694
698 if( !str.isEmpty() ) { 695 if( !str.isEmpty() ) {
699 696
700 odebug << "Selected filename is " + str << oendl; 697 odebug << "Selected filename is " + str << oendl;
701 filename = str; 698 filename = str;
702 DocLnk lnk; 699 DocLnk lnk;
703 700
704 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 701 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
705 readListFromFile( filename ); 702 readListFromFile( filename );
706 } else { 703 } else {
707 lnk.setName( QFileInfo(filename).baseName() ); //sets name 704 lnk.setName( QFileInfo(filename).baseName() ); //sets name
708 lnk.setFile( filename ); //sets file name 705 lnk.setFile( filename ); //sets file name
709 d->selectedFiles->addToSelection( lnk ); 706 d->selectedFiles->addToSelection( lnk );
710 writeCurrentM3u(); 707 writeCurrentM3u();
711 d->selectedFiles->setSelectedItem( lnk.name() ); 708 d->selectedFiles->setSelectedItem( lnk.name() );
712 } 709 }
713 } 710 }
714} 711}
715 712
716 713
717void PlayListWidget::readListFromFile( const QString &filename ) { 714void PlayListWidget::readListFromFile( const QString &filename ) {
718 odebug << "read list filename " + filename << oendl; 715 odebug << "read list filename " + filename << oendl;
719 QFileInfo fi(filename); 716 QFileInfo fi(filename);
720 Om3u *m3uList; 717 Om3u *m3uList;
721 QString s, name; 718 QString s, name;
722 m3uList = new Om3u( filename, IO_ReadOnly ); 719 m3uList = new Om3u( filename, IO_ReadOnly );
723 if(fi.extension(false).find("m3u",0,false) != -1 ) 720 if(fi.extension(false).find("m3u",0,false) != -1 )
724 m3uList->readM3u(); 721 m3uList->readM3u();
725 else if(fi.extension(false).find("pls",0,false) != -1 ) 722 else if(fi.extension(false).find("pls",0,false) != -1 )
726 m3uList->readPls(); 723 m3uList->readPls();
727 724
728 DocLnk lnk; 725 DocLnk lnk;
729 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 726 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
730 s = *it; 727 s = *it;
731 // odebug << s << oendl; 728 // odebug << s << oendl;
732 if(s.left(4)=="http") { 729 if(s.left(4)=="http") {
733 lnk.setName( s ); //sets file name 730 lnk.setName( s ); //sets file name
734 lnk.setIcon("opieplayer2/musicfile"); 731 lnk.setIcon("opieplayer2/musicfile");
735 lnk.setFile( s ); //sets file name 732 lnk.setFile( s ); //sets file name
736 733
737 } else { //is file 734 } else { //is file
738 lnk.setName( QFileInfo(s).baseName()); 735 lnk.setName( QFileInfo(s).baseName());
739 if(s.left(1) != "/") { 736 if(s.left(1) != "/") {
740 737
741 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 738 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
742 } else { 739 } else {
743 lnk.setFile( s); 740 lnk.setFile( s);
744 } 741 }
745 } 742 }
746 d->selectedFiles->addToSelection( lnk ); 743 d->selectedFiles->addToSelection( lnk );
747 } 744 }
748 Config config( "OpiePlayer" ); 745 Config config( "OpiePlayer" );
749 config.setGroup( "PlayList" ); 746 config.setGroup( "PlayList" );
750 747
751 config.writeEntry("CurrentPlaylist",filename); 748 config.writeEntry("CurrentPlaylist",filename);
752 config.write(); 749 config.write();
753 currentPlayList=filename; 750 currentPlayList=filename;
754 751
755 m3uList->close(); 752 m3uList->close();
756 delete m3uList; 753 delete m3uList;
757 754
758 d->selectedFiles->setSelectedItem( s); 755 d->selectedFiles->setSelectedItem( s);
759 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 756 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
760 757
761} 758}
762 759
763// writes current playlist to current m3u file */ 760// writes current playlist to current m3u file */
764 void PlayListWidget::writeCurrentM3u() { 761 void PlayListWidget::writeCurrentM3u() {
765 odebug << "writing to current m3u" << oendl; 762 odebug << "writing to current m3u" << oendl;
766 Config cfg( "OpiePlayer" ); 763 Config cfg( "OpiePlayer" );
767 cfg.setGroup("PlayList"); 764 cfg.setGroup("PlayList");
768 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 765 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
769 766
770 Om3u *m3uList; 767 Om3u *m3uList;
771 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 768 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
772 if( d->selectedFiles->first()) { 769 if( d->selectedFiles->first()) {
773 770
774 do { 771 do {
775 // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; 772 // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl;
776 m3uList->add( d->selectedFiles->current()->file() ); 773 m3uList->add( d->selectedFiles->current()->file() );
777 } 774 }
778 while ( d->selectedFiles->next() ); 775 while ( d->selectedFiles->next() );
779 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; 776 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl;
780 m3uList->write(); 777 m3uList->write();
781 m3uList->close(); 778 m3uList->close();
782 } 779 }
783 delete m3uList; 780 delete m3uList;
784 781
785 } 782 }
786 783
787 /* 784 /*
788 writes current playlist to m3u file */ 785 writes current playlist to m3u file */
789void PlayListWidget::writem3u() { 786void PlayListWidget::writem3u() {
790 //InputDilog *fileDlg; 787 //InputDilog *fileDlg;
791 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 788 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
792 //fileDlg->exec(); 789 //fileDlg->exec();
793 790
794 Config cfg( "OpiePlayer" ); 791 Config cfg( "OpiePlayer" );
795 cfg.setGroup("Dialog"); 792 cfg.setGroup("Dialog");
796 MimeTypes types; 793 MimeTypes types;
797 QStringList audio, video, all; 794 QStringList audio, video, all;
798 audio << "audio/*"; 795 audio << "audio/*";
799 audio << "playlist/plain"; 796 audio << "playlist/plain";
800 audio << "audio/x-mpegurl"; 797 audio << "audio/x-mpegurl";
801 798
802 video << "video/*"; 799 video << "video/*";
803 video << "playlist/plain"; 800 video << "playlist/plain";
804 801
805 all += audio; 802 all += audio;
806 all += video; 803 all += video;
807 types.insert("All Media Files", all ); 804 types.insert("All Media Files", all );
808 types.insert("Audio", audio ); 805 types.insert("Audio", audio );
809 types.insert("Video", video ); 806 types.insert("Video", video );
810 807
811 QString str = OFileDialog::getOpenFileName( 1, 808 QString str = OFileDialog::getOpenFileName( 1,
812 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 809 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
813 types, 0 ); 810 types, 0 );
814 if(str.left(2) == "//") str=str.right(str.length()-1); 811 if(str.left(2) == "//") str=str.right(str.length()-1);
815 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); 812 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
816 813
817 814
818 QString name, filename, list; 815 QString name, filename, list;
819 Om3u *m3uList; 816 Om3u *m3uList;
820 817
821 if( !str.isEmpty() ) { 818 if( !str.isEmpty() ) {
822 name = str; 819 name = str;
823 // name = fileDlg->text(); 820 // name = fileDlg->text();
824// odebug << filename << oendl; 821// odebug << filename << oendl;
825 if( name.find("/",0,true) != -1) {// assume they specify a file path 822 if( name.find("/",0,true) != -1) {// assume they specify a file path
826 filename = name; 823 filename = name;
827 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 824 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
828 } 825 }
829 else //otherwise dump it somewhere noticable 826 else //otherwise dump it somewhere noticable
830 filename = QPEApplication::documentDir() + "/" + name; 827 filename = QPEApplication::documentDir() + "/" + name;
831 828
832 if( filename.right( 3 ) != "m3u" ) //needs filename extension 829 if( filename.right( 3 ) != "m3u" ) //needs filename extension
833 filename += ".m3u"; 830 filename += ".m3u";
834 831
835 if( d->selectedFiles->first()) { //ramble through playlist view 832 if( d->selectedFiles->first()) { //ramble through playlist view
836 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); 833 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate);
837 834
838 do { 835 do {
839 m3uList->add( d->selectedFiles->current()->file()); 836 m3uList->add( d->selectedFiles->current()->file());
840 } 837 }
841 while ( d->selectedFiles->next() ); 838 while ( d->selectedFiles->next() );
842 // odebug << list << oendl; 839 // odebug << list << oendl;
843 m3uList->write(); 840 m3uList->write();
844 m3uList->close(); 841 m3uList->close();
845 delete m3uList; 842 delete m3uList;
846 843
847 //delete fileDlg; 844 //delete fileDlg;
848 845
849 DocLnk lnk; 846 DocLnk lnk;
850 lnk.setFile( filename); 847 lnk.setFile( filename);
851 lnk.setIcon("opieplayer2/playlist2"); 848 lnk.setIcon("opieplayer2/playlist2");
852 lnk.setName( name); //sets file name 849 lnk.setName( name); //sets file name
853 850
854 // odebug << filename << oendl; 851 // odebug << filename << oendl;
855 Config config( "OpiePlayer" ); 852 Config config( "OpiePlayer" );
856 config.setGroup( "PlayList" ); 853 config.setGroup( "PlayList" );
857 854
858 config.writeEntry("CurrentPlaylist",filename); 855 config.writeEntry("CurrentPlaylist",filename);
859 currentPlayList=filename; 856 currentPlayList=filename;
860 857
861 if(!lnk.writeLink()) { 858 if(!lnk.writeLink()) {
862 odebug << "Writing doclink did not work" << oendl; 859 odebug << "Writing doclink did not work" << oendl;
863 } 860 }
864 861
865 setCaption(tr("OpiePlayer: ") + name); 862 setCaption(tr("OpiePlayer: ") + name);
866 } 863 }
867 } 864 }
868} 865}
869 866
870void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 867void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
871 switch ( e->key() ) { 868 switch ( e->key() ) {
872 ////////////////////////////// Zaurus keys 869 ////////////////////////////// Zaurus keys
873 case Key_F9: //activity 870 case Key_F9: //activity
874 // if(audioUI->isHidden()) 871 // if(audioUI->isHidden())
875 // audioUI->showMaximized(); 872 // audioUI->showMaximized();
876 break; 873 break;
877 case Key_F10: //contacts 874 case Key_F10: //contacts
878 // if( videoUI->isHidden()) 875 // if( videoUI->isHidden())
879 // videoUI->showMaximized(); 876 // videoUI->showMaximized();
880 break; 877 break;
881 case Key_F11: //menu 878 case Key_F11: //menu
882 break; 879 break;
883 case Key_F12: //home 880 case Key_F12: //home
884 // doBlank(); 881 // doBlank();
885 break; 882 break;
886 case Key_F13: //mail 883 case Key_F13: //mail
887 // doUnblank(); 884 // doUnblank();
888 break; 885 break;
889 case Key_Q: //add to playlist 886 case Key_Q: //add to playlist
890 addSelected(); 887 addSelected();
891 break; 888 break;
892 case Key_R: //remove from playlist 889 case Key_R: //remove from playlist
893 removeSelected(); 890 removeSelected();
894 break; 891 break;
895 // case Key_P: //play 892 // case Key_P: //play
896 // odebug << "Play" << oendl; 893 // odebug << "Play" << oendl;
897 // playSelected(); 894 // playSelected();
898 // break; 895 // break;
899 case Key_Space: 896 case Key_Space:
900 // playSelected(); puh 897 // playSelected(); puh
901 break; 898 break;
902 case Key_1: 899 case Key_1:
903 tabWidget->setCurrentPage( 0 ); 900 tabWidget->setCurrentPage( 0 );
904 break; 901 break;
905 case Key_2: 902 case Key_2:
906 tabWidget->setCurrentPage( 1 ); 903 tabWidget->setCurrentPage( 1 );
907 break; 904 break;
908 case Key_3: 905 case Key_3:
909 tabWidget->setCurrentPage( 2 ); 906 tabWidget->setCurrentPage( 2 );
910 break; 907 break;
911 case Key_4: 908 case Key_4:
912 tabWidget->setCurrentPage( 3 ); 909 tabWidget->setCurrentPage( 3 );
913 break; 910 break;
914 case Key_Down: 911 case Key_Down:
915 if ( !d->selectedFiles->next() ) 912 if ( !d->selectedFiles->next() )
916 d->selectedFiles->first(); 913 d->selectedFiles->first();
917 break; 914 break;
918 case Key_Up: 915 case Key_Up:
919 if ( !d->selectedFiles->prev() ) 916 if ( !d->selectedFiles->prev() )
920 // d->selectedFiles->last(); 917 // d->selectedFiles->last();
921 break; 918 break;
922 } 919 }
923} 920}
924 921
925void PlayListWidget::pmViewActivated(int index) { 922void PlayListWidget::pmViewActivated(int index) {
926// odebug << "" << index << "" << oendl; 923// odebug << "" << index << "" << oendl;
927 switch(index) { 924 switch(index) {
928 case -16: 925 case -16:
929 { 926 {
930 mediaPlayerState->toggleFullscreen(); 927 mediaPlayerState->toggleFullscreen();
931 bool b=mediaPlayerState->isFullscreen(); 928 bool b=mediaPlayerState->isFullscreen();
932 pmView->setItemChecked( index, b); 929 pmView->setItemChecked( index, b);
933 Config cfg( "OpiePlayer" ); 930 Config cfg( "OpiePlayer" );
934 cfg.writeEntry( "FullScreen", b ); 931 cfg.writeEntry( "FullScreen", b );
935 } 932 }
936 break; 933 break;
937 }; 934 };
938} 935}
939 936
940void PlayListWidget::populateSkinsMenu() { 937void PlayListWidget::populateSkinsMenu() {
941 int item = 0; 938 int item = 0;
942 defaultSkinIndex = 0; 939 defaultSkinIndex = 0;
943 QString skinName; 940 QString skinName;
944 Config cfg( "OpiePlayer" ); 941 Config cfg( "OpiePlayer" );
945 cfg.setGroup("Options" ); 942 cfg.setGroup("Options" );
946 QString skin = cfg.readEntry( "Skin", "default" ); 943 QString skin = cfg.readEntry( "Skin", "default" );
947 944
948 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 945 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
949 skinsDir.setFilter( QDir::Dirs ); 946 skinsDir.setFilter( QDir::Dirs );
950 skinsDir.setSorting(QDir::Name ); 947 skinsDir.setSorting(QDir::Name );
951 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 948 const QFileInfoList *skinslist = skinsDir.entryInfoList();
952 QFileInfoListIterator it( *skinslist ); 949 QFileInfoListIterator it( *skinslist );
953 QFileInfo *fi; 950 QFileInfo *fi;
954 while ( ( fi = it.current() ) ) { 951 while ( ( fi = it.current() ) ) {
955 skinName = fi->fileName(); 952 skinName = fi->fileName();
956// odebug << fi->fileName() << oendl; 953// odebug << fi->fileName() << oendl;
957 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 954 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
958 item = skinsMenu->insertItem( fi->fileName() ) ; 955 item = skinsMenu->insertItem( fi->fileName() ) ;
959 } 956 }
960 if( skinName == "default" ) { 957 if( skinName == "default" ) {
961 defaultSkinIndex = item; 958 defaultSkinIndex = item;
962 } 959 }
963 if( skinName == skin ) { 960 if( skinName == skin ) {
964 skinsMenu->setItemChecked( item, TRUE ); 961 skinsMenu->setItemChecked( item, TRUE );
965 } 962 }
966 ++it; 963 ++it;
967 } 964 }
968} 965}
969 966
970void PlayListWidget::skinsMenuActivated( int item ) { 967void PlayListWidget::skinsMenuActivated( int item ) {
971 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 968 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
972 skinsMenu->setItemChecked( i, FALSE ); 969 skinsMenu->setItemChecked( i, FALSE );
973 } 970 }
974 skinsMenu->setItemChecked( item, TRUE ); 971 skinsMenu->setItemChecked( item, TRUE );
975 972
976 { 973 {
977 Config cfg( "OpiePlayer" ); 974 Config cfg( "OpiePlayer" );
978 cfg.setGroup("Options"); 975 cfg.setGroup("Options");
979 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 976 cfg.writeEntry("Skin", skinsMenu->text( item ) );
980 } 977 }
981 978
982 emit skinSelected(); 979 emit skinSelected();
983} 980}
984 981
985PlayListWidget::TabType PlayListWidget::currentTab() const 982PlayListWidget::TabType PlayListWidget::currentTab() const
986{ 983{
987 static const TabType indexToTabType[ TabTypeCount ] = 984 static const TabType indexToTabType[ TabTypeCount ] =
988 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 985 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
989 986
990 int index = tabWidget->currentPageIndex(); 987 int index = tabWidget->currentPageIndex();
991 assert( index < TabTypeCount && index >= 0 ); 988 assert( index < TabTypeCount && index >= 0 );
992 989
993 return indexToTabType[ index ]; 990 return indexToTabType[ index ];
994} 991}
995 992
996PlayListWidget::Entry PlayListWidget::currentEntry() const 993PlayListWidget::Entry PlayListWidget::currentEntry() const
997{ 994{
998 if ( currentTab() == CurrentPlayList ) { 995 if ( currentTab() == CurrentPlayList ) {
999 const DocLnk *lnk = current(); 996 const DocLnk *lnk = current();
1000 return Entry( lnk->name(), lnk->file() ); 997 return Entry( lnk->name(), lnk->file() );
1001 } 998 }
1002 999
1003 return Entry( currentFileListPathName() ); 1000 return Entry( currentFileListPathName() );
1004} 1001}
1005 1002
1006QString PlayListWidget::currentFileListPathName() const { 1003QString PlayListWidget::currentFileListPathName() const {
1007 return currentFileListView->currentItem()->text( 3 ); 1004 return currentFileListView->currentItem()->text( 3 );
1008} 1005}
1009 1006
1010 1007
1011void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1008void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1012 odebug << "qcop message "+msg << oendl; 1009 odebug << "qcop message "+msg << oendl;
1013 QDataStream stream ( data, IO_ReadOnly ); 1010 QDataStream stream ( data, IO_ReadOnly );
1014 if ( msg == "play()" ) { //plays current selection 1011 if ( msg == "play()" ) { //plays current selection
1015 btnPlay( true); 1012 btnPlay( true);
1016 } else if ( msg == "stop()" ) { 1013 } else if ( msg == "stop()" ) {
1017 mediaPlayerState->setPlaying( false); 1014 mediaPlayerState->setPlaying( false);
1018 } else if ( msg == "togglePause()" ) { 1015 } else if ( msg == "togglePause()" ) {
1019 mediaPlayerState->togglePaused(); 1016 mediaPlayerState->togglePaused();
1020 } else if ( msg == "next()" ) { //select next in list 1017 } else if ( msg == "next()" ) { //select next in list
1021 mediaPlayerState->setNext(); 1018 mediaPlayerState->setNext();
1022 } else if ( msg == "prev()" ) { //select previous in list 1019 } else if ( msg == "prev()" ) { //select previous in list
1023 mediaPlayerState->setPrev(); 1020 mediaPlayerState->setPrev();
1024 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1021 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1025 mediaPlayerState->toggleLooping(); 1022 mediaPlayerState->toggleLooping();
1026 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1023 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1027 mediaPlayerState->toggleShuffled(); 1024 mediaPlayerState->toggleShuffled();
1028 } else if ( msg == "volUp()" ) { //volume more 1025 } else if ( msg == "volUp()" ) { //volume more
1029// emit moreClicked(); 1026// emit moreClicked();
1030// emit moreReleased(); 1027// emit moreReleased();
1031 } else if ( msg == "volDown()" ) { //volume less 1028 } else if ( msg == "volDown()" ) { //volume less
1032// emit lessClicked(); 1029// emit lessClicked();
1033// emit lessReleased(); 1030// emit lessReleased();
1034 } else if ( msg == "play(QString)" ) { //play this now 1031 } else if ( msg == "play(QString)" ) { //play this now
1035 QString file; 1032 QString file;
1036 stream >> file; 1033 stream >> file;
1037 setDocument( (const QString &) file); 1034 setDocument( (const QString &) file);
1038 } else if ( msg == "add(QString)" ) { //add to playlist 1035 } else if ( msg == "add(QString)" ) { //add to playlist
1039 QString file; 1036 QString file;
1040 stream >> file; 1037 stream >> file;
1041 QFileInfo fileInfo(file); 1038 QFileInfo fileInfo(file);
1042 DocLnk lnk; 1039 DocLnk lnk;
1043 lnk.setName( fileInfo.baseName() ); //sets name 1040 lnk.setName( fileInfo.baseName() ); //sets name
1044 lnk.setFile( file ); //sets file name 1041 lnk.setFile( file ); //sets file name
1045 addToSelection( lnk ); 1042 addToSelection( lnk );
1046 } else if ( msg == "rem(QString)" ) { //remove from playlist 1043 } else if ( msg == "rem(QString)" ) { //remove from playlist
1047 QString file; 1044 QString file;
1048 stream >> file; 1045 stream >> file;
1049 1046
1050 } 1047 }
1051 1048
1052} 1049}
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
index 922f9d7..c3c1282 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
@@ -1,193 +1,192 @@
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 <qtoolbar.h> 35#include <qtoolbar.h>
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37 37
38#include <qlayout.h> 38#include <qlayout.h>
39#include <qmenubar.h> 39#include <qmenubar.h>
40 40
41#include "playlistselection.h" 41#include "playlistselection.h"
42#include "playlistwidget.h" 42#include "playlistwidget.h"
43#include "mediaplayerstate.h" 43#include "mediaplayerstate.h"
44#include "inputDialog.h" 44#include "inputDialog.h"
45#include "playlistfileview.h" 45#include "playlistfileview.h"
46 46
47 47
48PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name ) 48PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name )
49 : QMainWindow( parent, name ) { 49 : QMainWindow( parent, name ) {
50 50
51 d = new PlayListWidgetPrivate; 51 d = new PlayListWidgetPrivate;
52 d->setDocumentUsed = FALSE; 52 d->setDocumentUsed = FALSE;
53 53
54 setBackgroundMode( PaletteButton ); 54 setBackgroundMode( PaletteButton );
55 setToolBarsMovable( FALSE ); 55 setToolBarsMovable( FALSE );
56 56
57 // Create Toolbar 57 // Create Toolbar
58 QToolBar *toolbar = new QToolBar( this ); 58 QToolBar *toolbar = new QToolBar( this );
59 toolbar->setHorizontalStretchable( TRUE ); 59 toolbar->setHorizontalStretchable( TRUE );
60 60
61 // Create Menubar 61 // Create Menubar
62 QMenuBar *menu = new QMenuBar( toolbar ); 62 QMenuBar *menu = new QMenuBar( toolbar );
63 menu->setMargin( 0 ); 63 menu->setMargin( 0 );
64 64
65 bar = new QToolBar( this ); 65 bar = new QToolBar( this );
66 bar->setLabel( tr( "Play Operations" ) ); 66 bar->setLabel( tr( "Play Operations" ) );
67 67
68 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); 68 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" );
69 tbDeletePlaylist->setFlat( TRUE ); 69 tbDeletePlaylist->setFlat( TRUE );
70 tbDeletePlaylist->setFixedSize( 20, 20 ); 70 tbDeletePlaylist->setFixedSize( 20, 20 );
71 71
72 tbDeletePlaylist->hide(); 72 tbDeletePlaylist->hide();
73 73
74 pmPlayList = new QPopupMenu( this ); 74 pmPlayList = new QPopupMenu( this );
75 menu->insertItem( tr( "File" ), pmPlayList ); 75 menu->insertItem( tr( "File" ), pmPlayList );
76 76
77 pmView = new QPopupMenu( this ); 77 pmView = new QPopupMenu( this );
78 menu->insertItem( tr( "View" ), pmView ); 78 menu->insertItem( tr( "View" ), pmView );
79 pmView->isCheckable(); 79 pmView->isCheckable();
80 80
81 skinsMenu = new QPopupMenu( this ); 81 skinsMenu = new QPopupMenu( this );
82 pmView->insertItem( tr( "Skins" ), skinsMenu ); 82 pmView->insertItem( tr( "Skins" ), skinsMenu );
83 skinsMenu->isCheckable(); 83 skinsMenu->isCheckable();
84 84
85 gammaMenu = new QPopupMenu( this ); 85 gammaMenu = new QPopupMenu( this );
86 pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); 86 pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu );
87 87
88 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); 88 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu );
89 gammaSlider->setRange( -40, 40 ); 89 gammaSlider->setRange( -40, 40 );
90 gammaSlider->setTickmarks( QSlider::Left ); 90 gammaSlider->setTickmarks( QSlider::Left );
91 gammaSlider->setTickInterval( 20 ); 91 gammaSlider->setTickInterval( 20 );
92 gammaSlider->setFocusPolicy( QWidget::StrongFocus ); 92 gammaSlider->setFocusPolicy( QWidget::StrongFocus );
93 gammaSlider->setValue( 0 ); 93 gammaSlider->setValue( 0 );
94 gammaSlider->setMinimumHeight( 50 ); 94 gammaSlider->setMinimumHeight( 50 );
95 95
96 gammaLCD = new QLCDNumber( 3, gammaMenu ); 96 gammaLCD = new QLCDNumber( 3, gammaMenu );
97 gammaLCD-> setFrameShape ( QFrame::NoFrame ); 97 gammaLCD-> setFrameShape ( QFrame::NoFrame );
98 gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); 98 gammaLCD-> setSegmentStyle ( QLCDNumber::Flat );
99 99
100 gammaMenu->insertItem( gammaSlider ); 100 gammaMenu->insertItem( gammaSlider );
101 gammaMenu->insertItem( gammaLCD ); 101 gammaMenu->insertItem( gammaLCD );
102 102
103 connect( gammaSlider, SIGNAL( valueChanged(int) ), gammaLCD, SLOT( display(int) ) ); 103 connect( gammaSlider, SIGNAL( valueChanged(int) ), gammaLCD, SLOT( display(int) ) );
104 104
105 vbox5 = new QVBox( this ); 105 vbox5 = new QVBox( this );
106 QVBox *vbox4 = new QVBox( vbox5 ); 106 QVBox *vbox4 = new QVBox( vbox5 );
107 QHBox *hbox6 = new QHBox( vbox4 ); 107 QHBox *hbox6 = new QHBox( vbox4 );
108 108
109 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 109 tabWidget = new QTabWidget( hbox6, "tabWidget" );
110 110
111 playListTab = new QWidget( tabWidget, "PlayListTab" ); 111 playListTab = new QWidget( tabWidget, "PlayListTab" );
112 tabWidget->insertTab( playListTab, "Playlist"); 112 tabWidget->insertTab( playListTab, "Playlist");
113 113
114 QGridLayout *Playout = new QGridLayout( playListTab ); 114 QGridLayout *Playout = new QGridLayout( playListTab );
115 Playout->setSpacing( 2); 115 Playout->setSpacing( 2);
116 Playout->setMargin( 2); 116 Playout->setMargin( 2);
117 117
118 // Add the playlist area 118 // Add the playlist area
119 QVBox *vbox3 = new QVBox( playListTab ); 119 QVBox *vbox3 = new QVBox( playListTab );
120 d->playListFrame = vbox3; 120 d->playListFrame = vbox3;
121 121
122 QHBox *hbox2 = new QHBox( vbox3 ); 122 QHBox *hbox2 = new QHBox( vbox3 );
123 d->selectedFiles = new PlayListSelection( hbox2 ); 123 d->selectedFiles = new PlayListSelection( hbox2 );
124 124
125 vbox1 = new QVBox( hbox2 ); 125 vbox1 = new QVBox( hbox2 );
126 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); 126 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold );
127 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch 127 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch
128 128
129 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 129 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
130 130
131 QWidget *aTab; 131 QWidget *aTab;
132 aTab = new QWidget( tabWidget, "aTab" ); 132 aTab = new QWidget( tabWidget, "aTab" );
133 133
134 QGridLayout *Alayout = new QGridLayout( aTab ); 134 QGridLayout *Alayout = new QGridLayout( aTab );
135 Alayout->setSpacing( 2 ); 135 Alayout->setSpacing( 2 );
136 Alayout->setMargin( 2 ); 136 Alayout->setMargin( 2 );
137 // no m3u's here please 137 // no m3u's here please
138 audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" ); 138 audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" );
139 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 139 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
140 tabWidget->insertTab( aTab, tr( "Audio" ) ); 140 tabWidget->insertTab( aTab, tr( "Audio" ) );
141 141
142 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); 142 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold );
143 143
144 QWidget *vTab; 144 QWidget *vTab;
145 vTab = new QWidget( tabWidget, "vTab" ); 145 vTab = new QWidget( tabWidget, "vTab" );
146 146
147 QGridLayout *Vlayout = new QGridLayout( vTab ); 147 QGridLayout *Vlayout = new QGridLayout( vTab );
148 Vlayout->setSpacing( 2 ); 148 Vlayout->setSpacing( 2 );
149 Vlayout->setMargin( 2 ); 149 Vlayout->setMargin( 2 );
150 videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); 150 videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" );
151 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 151 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
152 152
153 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); 153 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold );
154 154
155 tabWidget->insertTab( vTab, tr( "Video" ) ); 155 tabWidget->insertTab( vTab, tr( "Video" ) );
156 156
157 //playlists list 157 //playlists list
158 QWidget *LTab; 158 QWidget *LTab;
159 LTab = new QWidget( tabWidget, "LTab" ); 159 LTab = new QWidget( tabWidget, "LTab" );
160 QGridLayout *Llayout = new QGridLayout( LTab ); 160 QGridLayout *Llayout = new QGridLayout( LTab );
161 Llayout->setSpacing( 2 ); 161 Llayout->setSpacing( 2 );
162 Llayout->setMargin( 2 ); 162 Llayout->setMargin( 2 );
163 163
164 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); 164 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE );
165 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 165 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
166 166
167 tabWidget->insertTab( LTab, tr( "Lists" ) ); 167 tabWidget->insertTab( LTab, tr( "Lists" ) );
168 168
169 setCentralWidget( vbox5 ); 169 setCentralWidget( vbox5 );
170} 170}
171 171
172 172
173 173
174PlayListWidgetGui::~PlayListWidgetGui() { 174PlayListWidgetGui::~PlayListWidgetGui() {
175} 175}
176 176
177void PlayListWidgetGui::setView( char view ) { 177void PlayListWidgetGui::setView( char view ) {
178 if ( view == 'l' ) 178 if ( view == 'l' )
179 showMaximized(); 179 showMaximized();
180 else 180 else
181 hide(); 181 hide();
182} 182}
183 183
184 184
185void PlayListWidgetGui::setActiveWindow() { 185void PlayListWidgetGui::setActiveWindow() {
186 // odebug << "SETTING active window" << oendl;
187 // When we get raised we need to ensure that it switches views 186 // When we get raised we need to ensure that it switches views
188 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); 187 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType();
189 mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate 188 mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate
190 mediaPlayerState->setDisplayType( origDisplayType ); // now switch back 189 mediaPlayerState->setDisplayType( origDisplayType ); // now switch back
191} 190}
192 191
193 192
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 0625376..2b44701 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,301 +1,302 @@
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 "videowidget.h" 34#include "videowidget.h"
35 35
36 36
37#ifdef Q_WS_QWS 37#ifdef Q_WS_QWS
38# define USE_DIRECT_PAINTER 38# define USE_DIRECT_PAINTER
39# include <qdirectpainter_qws.h> 39# include <qdirectpainter_qws.h>
40# include <qgfxraster_qws.h> 40# include <qgfxraster_qws.h>
41#endif 41#endif
42 42
43 43
44namespace 44namespace
45{ 45{
46 46
47const int xo = 2; // movable x offset 47const int xo = 2; // movable x offset
48const int yo = 0; // movable y offset 48const int yo = 0; // movable y offset
49 49
50const MediaWidget::SkinButtonInfo skinInfo[] = 50const MediaWidget::SkinButtonInfo skinInfo[] =
51{ 51{
52 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 52 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
53 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 53 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
54 { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, 54 { MediaWidget::Next, "fwd", MediaWidget::NormalButton },
55 { MediaWidget::Previous, "back", MediaWidget::NormalButton }, 55 { MediaWidget::Previous, "back", MediaWidget::NormalButton },
56 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 56 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
57 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 57 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
58 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } 58 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton }
59}; 59};
60 60
61const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 61const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
62 62
63} 63}
64 64
65VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 65VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
66 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) 66 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
67{ 67{
68 setCaption( tr("OpiePlayer - Video") ); 68 setCaption( tr("OpiePlayer - Video") );
69 69
70 videoFrame = new XineVideoWidget ( this, "Video frame" ); 70 videoFrame = new XineVideoWidget ( this, "Video frame" );
71 71
72 connect ( videoFrame, SIGNAL( videoResized(const QSize&)), this, SIGNAL( videoResized(const QSize&))); 72 connect ( videoFrame, SIGNAL( videoResized(const QSize&)), this, SIGNAL( videoResized(const QSize&)));
73 connect ( videoFrame, SIGNAL( clicked() ), this, SLOT ( backToNormal() ) ); 73 connect ( videoFrame, SIGNAL( clicked() ), this, SLOT ( backToNormal() ) );
74 74
75 slider = 0; 75 slider = 0;
76 76
77 loadSkin(); 77 loadSkin();
78 78
79 setLength( mediaPlayerState.length() ); 79 setLength( mediaPlayerState.length() );
80 setPosition( mediaPlayerState.position() ); 80 setPosition( mediaPlayerState.position() );
81 setFullscreen( mediaPlayerState.isFullscreen() ); 81 setFullscreen( mediaPlayerState.isFullscreen() );
82 setPlaying( mediaPlayerState.isPlaying() ); 82 setPlaying( mediaPlayerState.isPlaying() );
83} 83}
84 84
85 85
86VideoWidget::~VideoWidget() 86VideoWidget::~VideoWidget()
87{ 87{
88} 88}
89 89
90MediaWidget::GUIInfo VideoWidget::guiInfo() 90MediaWidget::GUIInfo VideoWidget::guiInfo()
91{ 91{
92 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); 92 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount );
93} 93}
94 94
95void VideoWidget::resizeEvent( QResizeEvent *e ) { 95void VideoWidget::resizeEvent( QResizeEvent *e ) {
96 int h = height(); 96 int h = height();
97 int w = width(); 97 int w = width();
98 //int Vh = 160; 98 //int Vh = 160;
99 //int Vw = 220; 99 //int Vw = 220;
100 100
101 slider->setFixedWidth( w - 20 ); 101 slider->setFixedWidth( w - 20 );
102 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 102 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
103 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 103 slider->setBackgroundOrigin( QWidget::ParentOrigin );
104 slider->setFocusPolicy( QWidget::NoFocus ); 104 slider->setFocusPolicy( QWidget::NoFocus );
105 slider->setBackgroundPixmap( backgroundPixmap ); 105 slider->setBackgroundPixmap( backgroundPixmap );
106 106
107 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 107 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
108 if(w>h) 108 if(w>h)
109 upperLeftOfButtonMask.ry() = 0; 109 upperLeftOfButtonMask.ry() = 0;
110 else 110 else
111 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 111 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
112 112
113 MediaWidget::resizeEvent( e ); 113 MediaWidget::resizeEvent( e );
114} 114}
115 115
116void VideoWidget::sliderPressed() { 116void VideoWidget::sliderPressed() {
117 videoSliderBeingMoved = TRUE; 117 videoSliderBeingMoved = TRUE;
118} 118}
119 119
120void VideoWidget::sliderReleased() { 120void VideoWidget::sliderReleased() {
121 videoSliderBeingMoved = FALSE; 121 videoSliderBeingMoved = FALSE;
122 if ( slider->width() == 0 ) { 122 if ( slider->width() == 0 ) {
123 return; 123 return;
124 } 124 }
125 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 125 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
126 mediaPlayerState.setPosition( val ); 126 mediaPlayerState.setPosition( val );
127} 127}
128 128
129void VideoWidget::setPosition( long i ) { 129void VideoWidget::setPosition( long i ) {
130 updateSlider( i, mediaPlayerState.length() ); 130 updateSlider( i, mediaPlayerState.length() );
131} 131}
132 132
133 133
134void VideoWidget::setLength( long max ) { 134void VideoWidget::setLength( long max ) {
135 updateSlider( mediaPlayerState.position(), max ); 135 updateSlider( mediaPlayerState.position(), max );
136} 136}
137 137
138void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 138void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
139{ 139{
140 if ( displayType == MediaPlayerState::Video ) { 140 if ( displayType == MediaPlayerState::Video ) {
141 makeVisible(); 141 makeVisible();
142 return; 142 return;
143 } 143 }
144 144
145 // Effectively blank the view next time we show it so it looks nicer 145 // Effectively blank the view next time we show it so it looks nicer
146 scaledWidth = 0; 146 scaledWidth = 0;
147 scaledHeight = 0; 147 scaledHeight = 0;
148 videoFrame->hide();
148 hide(); 149 hide();
149} 150}
150 151
151void VideoWidget::loadSkin() 152void VideoWidget::loadSkin()
152{ 153{
153 loadDefaultSkin( guiInfo() ); 154 loadDefaultSkin( guiInfo() );
154 155
155 delete slider; 156 delete slider;
156 slider = new QSlider( Qt::Horizontal, this ); 157 slider = new QSlider( Qt::Horizontal, this );
157 slider->setMinValue( 0 ); 158 slider->setMinValue( 0 );
158 slider->setMaxValue( 1 ); 159 slider->setMaxValue( 1 );
159 slider->setBackgroundPixmap( backgroundPixmap ); 160 slider->setBackgroundPixmap( backgroundPixmap );
160 //slider->setFocusPolicy( QWidget::NoFocus ); 161 //slider->setFocusPolicy( QWidget::NoFocus );
161 162
162 resizeEvent( 0 ); 163 resizeEvent( 0 );
163} 164}
164 165
165void VideoWidget::updateSlider( long i, long max ) { 166void VideoWidget::updateSlider( long i, long max ) {
166 // Will flicker too much if we don't do this 167 // Will flicker too much if we don't do this
167 if ( max == 0 ) { 168 if ( max == 0 ) {
168 return; 169 return;
169 } 170 }
170 int width = slider->width(); 171 int width = slider->width();
171 int val = int((double)i * width / max); 172 int val = int((double)i * width / max);
172 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 173 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
173 if ( slider->value() != val ) { 174 if ( slider->value() != val ) {
174 slider->setValue( val ); 175 slider->setValue( val );
175 } 176 }
176 if ( slider->maxValue() != width ) { 177 if ( slider->maxValue() != width ) {
177 slider->setMaxValue( width ); 178 slider->setMaxValue( width );
178 } 179 }
179 } 180 }
180} 181}
181 182
182void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 183void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
183 if ( mediaPlayerState.isFullscreen() ) { 184 if ( mediaPlayerState.isFullscreen() ) {
184 mediaPlayerState.setFullscreen( FALSE ); 185 mediaPlayerState.setFullscreen( FALSE );
185 makeVisible(); 186 makeVisible();
186 } 187 }
187 MediaWidget::mouseReleaseEvent( event ); 188 MediaWidget::mouseReleaseEvent( event );
188} 189}
189 190
190void VideoWidget::backToNormal() { 191void VideoWidget::backToNormal() {
191 mediaPlayerState.setFullscreen( FALSE ); 192 mediaPlayerState.setFullscreen( FALSE );
192 makeVisible(); 193 makeVisible();
193 setToggleButton( FullScreen, false ); 194 setToggleButton( FullScreen, false );
194} 195}
195 196
196void VideoWidget::makeVisible() { 197void VideoWidget::makeVisible() {
198 videoFrame->show();
197 if ( mediaPlayerState.isFullscreen() ) { 199 if ( mediaPlayerState.isFullscreen() ) {
198 showFullScreen(); 200 showFullScreen();
199 resize( qApp->desktop()->size() ); 201 resize( qApp->desktop()->size() );
200 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 202 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
201 203
202 slider->hide(); 204 slider->hide();
203 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 205 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
204 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 206 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
205 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 207 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
206 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 208 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
207
208 } else { 209 } else {
209 showNormal(); 210 showNormal();
210 showMaximized(); 211 showMaximized();
211 QWidget *d = QApplication::desktop(); 212 QWidget *d = QApplication::desktop();
212 int w = d->width(); 213 int w = d->width();
213 int h = d->height(); 214 int h = d->height();
214 215
215 if(w>h) { 216 if(w>h) {
216 int newW=(w/2)-(246/2); //this will only work with 320x240 217 int newW=(w/2)-(246/2); //this will only work with 320x240
217 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 218 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
218 } else { 219 } else {
219 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 220 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
220 } 221 }
221 222
222 if ( !mediaPlayerState.isSeekable() ) { 223 if ( !mediaPlayerState.isSeekable() ) {
223 if( !slider->isHidden()) { 224 if( !slider->isHidden()) {
224 slider->hide(); 225 slider->hide();
225 } 226 }
226 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 227 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
227 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 228 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
228 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 229 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
229 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 230 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
230 } else { 231 } else {
231 slider->show(); 232 slider->show();
232 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 233 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
233 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 234 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
234 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 235 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
235 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 236 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
236 } 237 }
237 } 238 }
238} 239}
239 240
240void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 241void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
241 switch ( e->key() ) { 242 switch ( e->key() ) {
242////////////////////////////// Zaurus keys 243////////////////////////////// Zaurus keys
243 case Key_Home: 244 case Key_Home:
244 break; 245 break;
245 case Key_F9: //activity 246 case Key_F9: //activity
246 break; 247 break;
247 case Key_F10: //contacts 248 case Key_F10: //contacts
248// hide(); 249// hide();
249 break; 250 break;
250 case Key_F11: //menu 251 case Key_F11: //menu
251 break; 252 break;
252 case Key_F12: //home 253 case Key_F12: //home
253 break; 254 break;
254 case Key_F13: //mail 255 case Key_F13: //mail
255 break; 256 break;
256 case Key_Space: { 257 case Key_Space: {
257 if(mediaPlayerState.isPlaying()) { 258 if(mediaPlayerState.isPlaying()) {
258 mediaPlayerState.setPlaying(FALSE); 259 mediaPlayerState.setPlaying(FALSE);
259 } else { 260 } else {
260 mediaPlayerState.setPlaying(TRUE); 261 mediaPlayerState.setPlaying(TRUE);
261 } 262 }
262 } 263 }
263 break; 264 break;
264 case Key_Down: 265 case Key_Down:
265// toggleButton(6); 266// toggleButton(6);
266 emit lessClicked(); 267 emit lessClicked();
267 emit lessReleased(); 268 emit lessReleased();
268// toggleButton(6); 269// toggleButton(6);
269 break; 270 break;
270 case Key_Up: 271 case Key_Up:
271// toggleButton(5); 272// toggleButton(5);
272 emit moreClicked(); 273 emit moreClicked();
273 emit moreReleased(); 274 emit moreReleased();
274// toggleButton(5); 275// toggleButton(5);
275 break; 276 break;
276 case Key_Right: 277 case Key_Right:
277 mediaPlayerState.setNext(); 278 mediaPlayerState.setNext();
278 break; 279 break;
279 case Key_Left: 280 case Key_Left:
280 mediaPlayerState.setPrev(); 281 mediaPlayerState.setPrev();
281 break; 282 break;
282 case Key_Escape: 283 case Key_Escape:
283 break; 284 break;
284 285
285 }; 286 };
286} 287}
287 288
288XineVideoWidget* VideoWidget::vidWidget() { 289XineVideoWidget* VideoWidget::vidWidget() {
289 return videoFrame; 290 return videoFrame;
290} 291}
291 292
292 293
293void VideoWidget::setFullscreen ( bool b ) { 294void VideoWidget::setFullscreen ( bool b ) {
294 setToggleButton( FullScreen, b ); 295 setToggleButton( FullScreen, b );
295} 296}
296 297
297 298
298void VideoWidget::setPlaying( bool b) { 299void VideoWidget::setPlaying( bool b) {
299 setToggleButton( Play, b ); 300 setToggleButton( Play, b );
300} 301}
301 302
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 9f944d7..e1816c8 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,275 +1,274 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "xinecontrol.h" 34#include "xinecontrol.h"
35#include "xinevideowidget.h" 35#include "xinevideowidget.h"
36 36
37/* OPIE */ 37/* OPIE */
38#include <opie2/odebug.h> 38#include <opie2/odebug.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
41using namespace Opie::Core; 41using namespace Opie::Core;
42 42
43/* QT */ 43/* QT */
44#include <qtimer.h> 44#include <qtimer.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46 46
47XineControl::XineControl( XineVideoWidget *xineWidget, 47XineControl::XineControl( XineVideoWidget *xineWidget,
48 MediaPlayerState &_mediaPlayerState, 48 MediaPlayerState &_mediaPlayerState,
49 QObject *parent, const char *name ) 49 QObject *parent, const char *name )
50 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 50 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
51{ 51{
52 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); 52 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget );
53 53
54 init(); 54 init();
55} 55}
56 56
57XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, 57XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget,
58 MediaPlayerState &_mediaPlayerState, 58 MediaPlayerState &_mediaPlayerState,
59 QObject *parent, const char *name ) 59 QObject *parent, const char *name )
60 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 60 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
61{ 61{
62 xine->ensureInitialized(); 62 xine->ensureInitialized();
63 63
64 xine->setWidget( xineWidget ); 64 xine->setWidget( xineWidget );
65 65
66 init(); 66 init();
67} 67}
68 68
69void XineControl::init() 69void XineControl::init()
70{ 70{
71 connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 71 connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
72 connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); 72 connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) );
73 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); 73 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) );
74 connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); 74 connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) );
75 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); 75 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) );
76 connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); 76 connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) );
77 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 77 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
78 connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); 78 connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) );
79 79
80 disabledSuspendScreenSaver = FALSE; 80 disabledSuspendScreenSaver = FALSE;
81} 81}
82 82
83XineControl::~XineControl() { 83XineControl::~XineControl() {
84#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 84#if !defined(QT_NO_COP)
85 if ( disabledSuspendScreenSaver ) { 85 if ( disabledSuspendScreenSaver ) {
86 disabledSuspendScreenSaver = FALSE; 86 disabledSuspendScreenSaver = FALSE;
87 // Re-enable the suspend mode 87 // Re-enable the suspend mode
88 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 88 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
89 } 89 }
90#endif 90#endif
91 delete libXine; 91 delete libXine;
92} 92}
93 93
94void XineControl::play( const QString& fileName ) { 94void XineControl::play( const QString& fileName ) {
95 95
96 hasVideoChannel = FALSE; 96 hasVideoChannel = FALSE;
97 hasAudioChannel = FALSE; 97 hasAudioChannel = FALSE;
98 m_fileName = fileName; 98 m_fileName = fileName;
99 99
100 odebug << "<<FILENAME: " + fileName + ">>>>" << oendl; 100 odebug << "<<FILENAME: " + fileName + ">>>>" << oendl;
101 101
102 if ( !libXine->play( fileName, 0, 0 ) ) { 102 if ( !libXine->play( fileName, 0, 0 ) ) {
103 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 103 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
104 // toggle stop so the the play button is reset 104 // toggle stop so the the play button is reset
105 mediaPlayerState.setPlaying( false ); 105 mediaPlayerState.setPlaying( false );
106 return; 106 return;
107 } 107 }
108 mediaPlayerState.setPlaying( true ); 108 mediaPlayerState.setPlaying( true );
109 109
110 MediaPlayerState::DisplayType displayType; 110 MediaPlayerState::DisplayType displayType;
111 if ( !libXine->hasVideo() ) { 111 if ( !libXine->hasVideo() ) {
112 displayType = MediaPlayerState::Audio; 112 displayType = MediaPlayerState::Audio;
113 odebug << "HAS AUDIO" << oendl;
114 libXine->setShowVideo( false ); 113 libXine->setShowVideo( false );
115 hasAudioChannel = TRUE; 114 hasAudioChannel = TRUE;
116 } else { 115 } else {
117 displayType = MediaPlayerState::Video; 116 displayType = MediaPlayerState::Video;
118 odebug << "HAS VIDEO" << oendl;
119 libXine->setShowVideo( true ); 117 libXine->setShowVideo( true );
120 hasVideoChannel = TRUE; 118 hasVideoChannel = TRUE;
121 } 119 }
122 // determine if slider is shown 120 // determine if slider is shown
123 mediaPlayerState.setIsSeekable( libXine->isSeekable() ); 121 mediaPlayerState.setIsSeekable( libXine->isSeekable() );
124 122
125 // which gui (video / audio) 123 // which gui (video / audio)
126 mediaPlayerState.setDisplayType( displayType ); 124 mediaPlayerState.setDisplayType( displayType );
127 125
128#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 126#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
129 if ( !disabledSuspendScreenSaver ) { 127 if ( !disabledSuspendScreenSaver ) {
130 disabledSuspendScreenSaver = TRUE; 128 disabledSuspendScreenSaver = TRUE;
131 // Stop the screen from blanking and power saving state 129 // Stop the screen from blanking and power saving state
132 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 130 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
133 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 131 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend );
134 } 132 }
135#endif 133#endif
136 134
137 length(); 135 length();
138 position(); 136 position();
139} 137}
140 138
141void XineControl::nextMedia() { 139void XineControl::nextMedia() {
142 mediaPlayerState.setNext(); 140 mediaPlayerState.setNext();
143} 141}
144 142
145void XineControl::setGamma( int value ) { 143void XineControl::setGamma( int value ) {
146 libXine->setGamma( value ); 144 libXine->setGamma( value );
147} 145}
148 146
149void XineControl::stop( bool isSet ) { 147void XineControl::stop( bool isSet ) {
150 if ( !isSet ) { 148 if ( !isSet ) {
151 libXine->stop(); 149 libXine->stop();
152 150
153#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 151#if !defined(QT_NO_COP)
154 if ( disabledSuspendScreenSaver ) { 152 if ( disabledSuspendScreenSaver ) {
155 disabledSuspendScreenSaver = FALSE; 153 disabledSuspendScreenSaver = FALSE;
156 // Re-enable the suspend mode 154 // Re-enable the suspend mode
157 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 155 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
158 } 156 }
159#endif 157#endif
160 } 158 }
161} 159}
162 160
163/** 161/**
164 * Pause playback 162 * Pause playback
165 * @isSet 163 * @isSet
166 */ 164 */
167void XineControl::pause( bool isSet) { 165void XineControl::pause( bool isSet) {
168 libXine->pause( isSet ); 166 libXine->pause( isSet );
169} 167}
170 168
171 169
172/** 170/**
173 * get current time in playback 171 * get current time in playback
174 */ 172 */
175long XineControl::currentTime() { 173long XineControl::currentTime() {
176 // todo: jede sekunde überprüfen 174 // todo: jede sekunde überprüfen
177 m_currentTime = libXine->currentTime(); 175 m_currentTime = libXine->currentTime();
178 return m_currentTime; 176 return m_currentTime;
179 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
180} 177}
181 178
182/** 179/**
183 * Set the length of the media file 180 * Set the length of the media file
184 */ 181 */
185void XineControl::length() { 182void XineControl::length() {
186 m_length = libXine->length(); 183 m_length = libXine->length();
187 mediaPlayerState.setLength( m_length ); 184 mediaPlayerState.setLength( m_length );
188} 185}
189 186
190 187
191/** 188/**
192 * Reports the position the xine backend is at right now 189 * Reports the position the xine backend is at right now
193 * @return long the postion in seconds 190 * @return long the postion in seconds
194 */ 191 */
195long XineControl::position() { 192long XineControl::position() {
196 m_position = ( currentTime() ); 193 m_position = ( currentTime() );
197 mediaPlayerState.updatePosition( m_position ); 194 mediaPlayerState.updatePosition( m_position );
198 long emitPos = (long)m_position; 195 long emitPos = (long)m_position;
199 emit positionChanged( emitPos ); 196 emit positionChanged( emitPos );
200 if( mediaPlayerState.isPlaying() ) { 197 if( mediaPlayerState.isPlaying() ) {
201 // needs to be stopped the media is stopped 198 // needs to be stopped the media is stopped
202 QTimer::singleShot( 1000, this, SLOT( position() ) ); 199 QTimer::singleShot( 1000, this, SLOT( position() ) );
203 } 200 }
204 return m_position; 201 return m_position;
205} 202}
206 203
207/** 204/**
208 * Set videoplayback to fullscreen 205 * Set videoplayback to fullscreen
209 * @param isSet 206 * @param isSet
210 */ 207 */
211void XineControl::setFullscreen( bool isSet ) { 208void XineControl::setFullscreen( bool isSet ) {
212 libXine->showVideoFullScreen( isSet ); 209 libXine->showVideoFullScreen( isSet );
213} 210}
214 211
215 212
216QString XineControl::getMetaInfo() { 213QString XineControl::getMetaInfo() {
217 214
218 QString returnString; 215 QString returnString;
219 216
220 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 217 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
221 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 218 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
222 } 219 }
223 220
224 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 221 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
225 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 222 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
226 } 223 }
227 224
228 if ( !libXine->metaInfo( 2 ).isEmpty() ) { 225 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
229 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); 226 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
230 } 227 }
231 228
232 if ( !libXine->metaInfo( 3 ).isEmpty() ) { 229 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
233 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); 230 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
234 } 231 }
235 232
236 if ( !libXine->metaInfo( 4 ).isEmpty() ) { 233 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
237 returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); 234 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
238 } 235 }
239 236
240 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 237 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
241 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 238 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
242 } 239 }
243 return returnString; 240 return returnString;
244} 241}
245 242
246QString XineControl::getErrorCode() { 243QString XineControl::getErrorCode() {
247 244
248 int errorCode = libXine->error(); 245 int errorCode = libXine->error();
249 246
250 odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; 247 odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl;
251 248
252 if ( errorCode == 1 ) { 249 if ( errorCode == 1 ) {
253 return tr( "No input plugin found for this media type" ); 250 return tr( "No input plugin found for this media type" );
254 } else if ( errorCode == 2 ) { 251 } else if ( errorCode == 2 ) {
255 return tr( "No demux plugin found for this media type" ); 252 return tr( "No demux plugin found for this media type" );
256 } else if ( errorCode == 3 ) { 253 } else if ( errorCode == 3 ) {
257 return tr( "Demuxing failed for this media type" ); 254 return tr( "Demuxing failed for this media type" );
258 } else if ( errorCode == 4 ) { 255 } else if ( errorCode == 4 ) {
259 return tr( "Malformed MRL" ); 256 return tr( "Malformed MRL" );
257 } else if ( errorCode == 5 ) {
258 return tr( "Input failed" );
260 } else { 259 } else {
261 return tr( "Some other error" ); 260 return tr( "Some other error" );
262 } 261 }
263} 262}
264 263
265/** 264/**
266 * Seek to a position in the track 265 * Seek to a position in the track
267 * @param second the second to jump to 266 * @param second the second to jump to
268 */ 267 */
269void XineControl::seekTo( long second ) { 268void XineControl::seekTo( long second ) {
270 libXine->seekTo( (int)second ); 269 libXine->seekTo( (int)second );
271} 270}
272 271
273void XineControl::videoResized ( const QSize &s ) { 272void XineControl::videoResized ( const QSize &s ) {
274 libXine->resize( s ); 273 libXine->resize( s );
275} 274}