summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-21 00:20:22 (UTC)
committer harlekin <harlekin>2002-08-21 00:20:22 (UTC)
commitc198ae0217f761418f7170d08a94da3864e47583 (patch) (unidiff)
tree096790ff5389ea30f61912f72338e5642edaa667
parent491f95a2c6a5676f08520e494e125ba8b20e0eae (diff)
downloadopie-c198ae0217f761418f7170d08a94da3864e47583.zip
opie-c198ae0217f761418f7170d08a94da3864e47583.tar.gz
opie-c198ae0217f761418f7170d08a94da3864e47583.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp19
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp2
3 files changed, 17 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index c187f52..b2143a0 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,226 +1,227 @@
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 <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39 39
40#include <qfile.h> 40#include <qfile.h>
41 41
42#include <qgfx_qws.h> 42#include <qgfx_qws.h>
43#include <qdirectpainter_qws.h> 43#include <qdirectpainter_qws.h>
44 44
45#include "xinevideowidget.h" 45#include "xinevideowidget.h"
46#include "frame.h" 46#include "frame.h"
47#include "lib.h" 47#include "lib.h"
48 48
49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
50 int width, int height,int bytes ); 50 int width, int height,int bytes );
51 51
52extern "C" { 52extern "C" {
53 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); 53 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video);
54 int null_is_showing_video( vo_driver_t* self ); 54 int null_is_showing_video( vo_driver_t* self );
55 void null_set_show_video( vo_driver_t* self, int show ); 55 void null_set_show_video( vo_driver_t* self, int show );
56 int null_is_fullscreen( vo_driver_t* self ); 56 int null_is_fullscreen( vo_driver_t* self );
57 void null_set_fullscreen( vo_driver_t* self, int screen ); 57 void null_set_fullscreen( vo_driver_t* self, int screen );
58 int null_is_scaling( vo_driver_t* self ); 58 int null_is_scaling( vo_driver_t* self );
59 void null_set_scaling( vo_driver_t* self, int scale ); 59 void null_set_scaling( vo_driver_t* self, int scale );
60 void null_set_gui_width( vo_driver_t* self, int width ); 60 void null_set_gui_width( vo_driver_t* self, int width );
61 void null_set_gui_height( vo_driver_t* self, int height ); 61 void null_set_gui_height( vo_driver_t* self, int height );
62 void null_set_mode( vo_driver_t* self, int depth, int rgb ); 62 void null_set_mode( vo_driver_t* self, int depth, int rgb );
63 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); 63 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data);
64} 64}
65 65
66using namespace XINE; 66using namespace XINE;
67 67
68Lib::Lib(XineVideoWidget* widget) { 68Lib::Lib(XineVideoWidget* widget) {
69 m_video = false; 69 m_video = false;
70 m_wid = widget; 70 m_wid = widget;
71 printf("Lib"); 71 printf("Lib");
72 QCString str( getenv("HOME") ); 72 QCString str( getenv("HOME") );
73 str += "/Settings/opiexine.cf"; 73 str += "/Settings/opiexine.cf";
74 // get the configuration 74 // get the configuration
75 75
76 // not really OO, should be an extra class, later 76 // not really OO, should be an extra class, later
77 if ( !QFile(str).exists() ) { 77 if ( !QFile(str).exists() ) {
78 QFile f(str); 78 QFile f(str);
79 f.open(IO_WriteOnly); 79 f.open(IO_WriteOnly);
80 QTextStream ts( &f ); 80 QTextStream ts( &f );
81 ts << "misc.memcpy_method:glibc\n"; 81 ts << "misc.memcpy_method:glibc\n";
82 f.close(); 82 f.close();
83 } 83 }
84 84
85 m_config = xine_config_file_init( str.data() ); 85 m_config = xine_config_file_init( str.data() );
86 86
87 // allocate oss for sound 87 // allocate oss for sound
88 // and fb for framebuffer 88 // and fb for framebuffer
89 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; 89 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ;
90 m_videoOutput = ::init_video_out_plugin( m_config, NULL ); 90 m_videoOutput = ::init_video_out_plugin( m_config, NULL );
91 if (m_wid != 0 ) { 91 if (m_wid != 0 ) {
92 printf("!0\n" ); 92 printf("!0\n" );
93 resize ( m_wid-> size ( )); 93 resize ( m_wid-> size ( ));
94 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 94 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
95 m_wid-> setImage ( new QImage ( Resource::loadImage(""))); 95 m_wid-> setImage ( new QImage ( Resource::loadImage("")));
96 m_wid->repaint(); 96 m_wid->repaint();
97 } 97 }
98 null_display_handler( m_videoOutput, 98 null_display_handler( m_videoOutput,
99 xine_display_frame, 99 xine_display_frame,
100 this ); 100 this );
101 101
102 m_xine = xine_init( m_videoOutput, 102 m_xine = xine_init( m_videoOutput,
103 m_audioOutput, m_config ); 103 m_audioOutput, m_config );
104 // install the event handler 104 // install the event handler
105 xine_register_event_listener( m_xine, xine_event_handler, this ); 105 xine_register_event_listener( m_xine, xine_event_handler, this );
106} 106}
107 107
108Lib::~Lib() { 108Lib::~Lib() {
109 delete m_config; 109 free( m_config );
110 xine_remove_event_listener( m_xine, xine_event_handler ); 110 xine_remove_event_listener( m_xine, xine_event_handler );
111 xine_exit( m_xine ); 111 xine_exit( m_xine );
112 delete m_videoOutput; 112 /* FIXME either free or delete but valgrind bitches against both */
113 //free( m_videoOutput );
113 //delete m_audioOutput; 114 //delete m_audioOutput;
114 115
115} 116}
116 117
117void Lib::resize ( const QSize &s ) 118void Lib::resize ( const QSize &s )
118{ 119{
119 if ( s. width ( ) && s. height ( )) { 120 if ( s. width ( ) && s. height ( )) {
120 ::null_set_gui_width( m_videoOutput, s. width() ); 121 ::null_set_gui_width( m_videoOutput, s. width() );
121 ::null_set_gui_height(m_videoOutput, s. height() ); 122 ::null_set_gui_height(m_videoOutput, s. height() );
122 } 123 }
123} 124}
124 125
125QCString Lib::version() { 126QCString Lib::version() {
126 QCString str( xine_get_str_version() ); 127 QCString str( xine_get_str_version() );
127 return str; 128 return str;
128}; 129};
129 130
130int Lib::majorVersion() { 131int Lib::majorVersion() {
131 return xine_get_major_version(); 132 return xine_get_major_version();
132} 133}
133int Lib::minorVersion() { 134int Lib::minorVersion() {
134 return xine_get_minor_version(); 135 return xine_get_minor_version();
135}; 136};
136 137
137int Lib::subVersion() { 138int Lib::subVersion() {
138 return xine_get_sub_version(); 139 return xine_get_sub_version();
139} 140}
140int Lib::play( const QString& fileName, 141int Lib::play( const QString& fileName,
141 int startPos, 142 int startPos,
142 int start_time ) { 143 int start_time ) {
143 QString str = fileName.stripWhiteSpace(); 144 QString str = fileName.stripWhiteSpace();
144 //workaround OpiePlayer bug 145 //workaround OpiePlayer bug
145 //f (str.right(1) == QString::fromLatin1("/") ) 146 //f (str.right(1) == QString::fromLatin1("/") )
146 // str = str.mid( str.length() -1 ); 147 // str = str.mid( str.length() -1 );
147 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), 148 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(),
148 startPos, start_time); 149 startPos, start_time);
149} 150}
150void Lib::stop() { 151void Lib::stop() {
151 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 152 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
152 xine_stop(m_xine ); 153 xine_stop(m_xine );
153} 154}
154void Lib::pause(){ 155void Lib::pause(){
155 xine_set_speed( m_xine, SPEED_PAUSE ); 156 xine_set_speed( m_xine, SPEED_PAUSE );
156} 157}
157int Lib::speed() { 158int Lib::speed() {
158 return xine_get_speed( m_xine ); 159 return xine_get_speed( m_xine );
159} 160}
160void Lib::setSpeed( int speed ) { 161void Lib::setSpeed( int speed ) {
161 xine_set_speed( m_xine, speed ); 162 xine_set_speed( m_xine, speed );
162} 163}
163int Lib::status(){ 164int Lib::status(){
164 return xine_get_status( m_xine ); 165 return xine_get_status( m_xine );
165} 166}
166int Lib::currentPosition(){ 167int Lib::currentPosition(){
167 return xine_get_current_position( m_xine ); 168 return xine_get_current_position( m_xine );
168} 169}
169int Lib::currentTime() { 170int Lib::currentTime() {
170 return xine_get_current_time( m_xine ); 171 return xine_get_current_time( m_xine );
171}; 172};
172int Lib::length() { 173int Lib::length() {
173 return xine_get_stream_length( m_xine ); 174 return xine_get_stream_length( m_xine );
174} 175}
175bool Lib::isSeekable() { 176bool Lib::isSeekable() {
176 return xine_is_stream_seekable(m_xine); 177 return xine_is_stream_seekable(m_xine);
177} 178}
178Frame Lib::currentFrame() { 179Frame Lib::currentFrame() {
179 Frame frame; 180 Frame frame;
180 return frame; 181 return frame;
181}; 182};
182int Lib::error() { 183int Lib::error() {
183 return xine_get_error( m_xine ); 184 return xine_get_error( m_xine );
184}; 185};
185void Lib::handleXineEvent( xine_event_t* t ) { 186void Lib::handleXineEvent( xine_event_t* t ) {
186 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) 187 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED )
187 emit stopped(); 188 emit stopped();
188} 189}
189void Lib::setShowVideo( bool video ) { 190void Lib::setShowVideo( bool video ) {
190 m_video = video; 191 m_video = video;
191 ::null_set_show_video( m_videoOutput, video ); 192 ::null_set_show_video( m_videoOutput, video );
192} 193}
193bool Lib::isShowingVideo() { 194bool Lib::isShowingVideo() {
194 return ::null_is_showing_video( m_videoOutput ); 195 return ::null_is_showing_video( m_videoOutput );
195} 196}
196void Lib::showVideoFullScreen( bool fullScreen ) { 197void Lib::showVideoFullScreen( bool fullScreen ) {
197 ::null_set_fullscreen( m_videoOutput, fullScreen ); 198 ::null_set_fullscreen( m_videoOutput, fullScreen );
198} 199}
199bool Lib::isVideoFullScreen() { 200bool Lib::isVideoFullScreen() {
200 return ::null_is_fullscreen( m_videoOutput ); 201 return ::null_is_fullscreen( m_videoOutput );
201} 202}
202void Lib::setScaling( bool scale ) { 203void Lib::setScaling( bool scale ) {
203 ::null_set_scaling( m_videoOutput, scale ); 204 ::null_set_scaling( m_videoOutput, scale );
204} 205}
205bool Lib::isScaling() { 206bool Lib::isScaling() {
206 return ::null_is_scaling( m_videoOutput ); 207 return ::null_is_scaling( m_videoOutput );
207} 208}
208void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { 209void Lib::xine_event_handler( void* user_data, xine_event_t* t ) {
209 ((Lib*)user_data)->handleXineEvent( t ); 210 ((Lib*)user_data)->handleXineEvent( t );
210} 211}
211void Lib::xine_display_frame( void* user_data, uint8_t *frame, 212void Lib::xine_display_frame( void* user_data, uint8_t *frame,
212 int width, int height, int bytes ) { 213 int width, int height, int bytes ) {
213 214
214 ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); 215 ((Lib*)user_data)->drawFrame( frame, width, height, bytes );
215} 216}
216void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 217void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
217 if (!m_video ) { 218 if (!m_video ) {
218 qWarning("not showing video now"); 219 qWarning("not showing video now");
219 return; 220 return;
220 } 221 }
221// qWarning("called draw frame %d %d", width, height); 222// qWarning("called draw frame %d %d", width, height);
222 223
223 m_wid->setImage( frame, width, height, bytes ); 224 m_wid->setImage( frame, width, height, bytes );
224// m_wid->repaint(false); 225// m_wid->repaint(false);
225 226
226} 227}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 75e2979..098322b 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1247 +1,1254 @@
1 1
2#define QTOPIA_INTERNAL_FSLP 2#define QTOPIA_INTERNAL_FSLP
3#include <qpe/qpemenubar.h> 3#include <qpe/qpemenubar.h>
4#include <qpe/qpetoolbar.h> 4#include <qpe/qpetoolbar.h>
5#include <qpe/fileselector.h> 5#include <qpe/fileselector.h>
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7#include <qpe/lnkproperties.h> 7#include <qpe/lnkproperties.h>
8#include <qpe/storage.h> 8#include <qpe/storage.h>
9#include <qpe/mimetype.h>
9 10
10#include <qpe/applnk.h> 11#include <qpe/applnk.h>
11#include <qpopupmenu.h> 12#include <qpopupmenu.h>
12#include <qpe/config.h> 13#include <qpe/config.h>
13#include <qpe/global.h> 14#include <qpe/global.h>
14#include <qpe/resource.h> 15#include <qpe/resource.h>
15#include <qaction.h> 16#include <qaction.h>
16#include <qcursor.h> 17#include <qcursor.h>
17#include <qimage.h> 18#include <qimage.h>
18#include <qfile.h> 19#include <qfile.h>
19#include <qdir.h> 20#include <qdir.h>
20#include <qlayout.h> 21#include <qlayout.h>
21#include <qlabel.h> 22#include <qlabel.h>
22#include <qlist.h> 23#include <qlist.h>
23#include <qlistbox.h> 24#include <qlistbox.h>
24#include <qmainwindow.h> 25#include <qmainwindow.h>
25#include <qmessagebox.h> 26#include <qmessagebox.h>
26#include <qtoolbutton.h> 27#include <qtoolbutton.h>
27#include <qtabwidget.h> 28#include <qtabwidget.h>
28#include <qlistview.h> 29#include <qlistview.h>
29#include <qpoint.h> 30#include <qpoint.h>
30#include <qlineedit.h> 31#include <qlineedit.h>
31#include <qpushbutton.h> 32#include <qpushbutton.h>
32#include <qregexp.h> 33#include <qregexp.h>
33#include <qtextstream.h> 34#include <qtextstream.h>
34 35
35 36
36#include "playlistselection.h" 37#include "playlistselection.h"
37#include "playlistwidget.h" 38#include "playlistwidget.h"
38#include "mediaplayerstate.h" 39#include "mediaplayerstate.h"
39 40
40#include "inputDialog.h" 41#include "inputDialog.h"
41 42
42#include <stdlib.h> 43#include <stdlib.h>
43#include "audiowidget.h" 44#include "audiowidget.h"
44#include "videowidget.h" 45#include "videowidget.h"
45 46
46#define BUTTONS_ON_TOOLBAR 47#define BUTTONS_ON_TOOLBAR
47#define SIDE_BUTTONS 48#define SIDE_BUTTONS
48#define CAN_SAVE_LOAD_PLAYLISTS 49#define CAN_SAVE_LOAD_PLAYLISTS
49 50
50extern MediaPlayerState *mediaPlayerState; 51extern MediaPlayerState *mediaPlayerState;
51 52
52 53
53class PlayListWidgetPrivate { 54class PlayListWidgetPrivate {
54public: 55public:
55 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 56 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
56 QFrame *playListFrame; 57 QFrame *playListFrame;
57 FileSelector *files; 58 FileSelector *files;
58 PlayListSelection *selectedFiles; 59 PlayListSelection *selectedFiles;
59 bool setDocumentUsed; 60 bool setDocumentUsed;
60 DocLnk *current; 61 DocLnk *current;
61}; 62};
62 63
63 64
64class ToolButton : public QToolButton { 65class ToolButton : public QToolButton {
65public: 66public:
66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 67 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
67 : QToolButton( parent, name ) { 68 : QToolButton( parent, name ) {
68 setTextLabel( name ); 69 setTextLabel( name );
69 setPixmap( Resource::loadPixmap( icon ) ); 70 setPixmap( Resource::loadPixmap( icon ) );
70 setAutoRaise( TRUE ); 71 setAutoRaise( TRUE );
71 setFocusPolicy( QWidget::NoFocus ); 72 setFocusPolicy( QWidget::NoFocus );
72 setToggleButton( t ); 73 setToggleButton( t );
73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 74 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
74 QPEMenuToolFocusManager::manager()->addWidget( this ); 75 QPEMenuToolFocusManager::manager()->addWidget( this );
75 } 76 }
76}; 77};
77 78
78 79
79class MenuItem : public QAction { 80class MenuItem : public QAction {
80public: 81public:
81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 82 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
82 : QAction( text, QString::null, 0, 0 ) { 83 : QAction( text, QString::null, 0, 0 ) {
83 connect( this, SIGNAL( activated() ), handler, slot ); 84 connect( this, SIGNAL( activated() ), handler, slot );
84 addTo( parent ); 85 addTo( parent );
85 } 86 }
86}; 87};
87 88
88 89
89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 90PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
90 : QMainWindow( parent, name, fl ) { 91 : QMainWindow( parent, name, fl ) {
91 92
92 d = new PlayListWidgetPrivate; 93 d = new PlayListWidgetPrivate;
93 d->setDocumentUsed = FALSE; 94 d->setDocumentUsed = FALSE;
94 d->current = NULL; 95 d->current = NULL;
95 fromSetDocument = FALSE; 96 fromSetDocument = FALSE;
96 insanityBool=FALSE; 97 insanityBool=FALSE;
97 audioScan = FALSE; 98 audioScan = FALSE;
98 videoScan = FALSE; 99 videoScan = FALSE;
99 100
100 setBackgroundMode( PaletteButton ); 101 setBackgroundMode( PaletteButton );
101 102
102// setCaption( tr("OpiePlayer") ); 103// setCaption( tr("OpiePlayer") );
103// setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); 104// setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) );
104 105
105 setToolBarsMovable( FALSE ); 106 setToolBarsMovable( FALSE );
106 107
107 // Create Toolbar 108 // Create Toolbar
108 QPEToolBar *toolbar = new QPEToolBar( this ); 109 QPEToolBar *toolbar = new QPEToolBar( this );
109 toolbar->setHorizontalStretchable( TRUE ); 110 toolbar->setHorizontalStretchable( TRUE );
110 111
111 // Create Menubar 112 // Create Menubar
112 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 113 QPEMenuBar *menu = new QPEMenuBar( toolbar );
113 menu->setMargin( 0 ); 114 menu->setMargin( 0 );
114 115
115 QPEToolBar *bar = new QPEToolBar( this ); 116 QPEToolBar *bar = new QPEToolBar( this );
116 bar->setLabel( tr( "Play Operations" ) ); 117 bar->setLabel( tr( "Play Operations" ) );
117 118
118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 119 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
119 tbDeletePlaylist->setFlat(TRUE); 120 tbDeletePlaylist->setFlat(TRUE);
120 tbDeletePlaylist->setFixedSize(20,20); 121 tbDeletePlaylist->setFixedSize(20,20);
121 122
122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 123 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
123 this , SLOT(addSelected()) ); 124 this , SLOT(addSelected()) );
124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 125 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
125 this , SLOT(removeSelected()) ); 126 this , SLOT(removeSelected()) );
126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 127 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
127 this , SLOT( btnPlay(bool) ), TRUE ); 128 this , SLOT( btnPlay(bool) ), TRUE );
128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 129 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 130 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", 131 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop",
131 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 132 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
132 tbDeletePlaylist->hide(); 133 tbDeletePlaylist->hide();
133 134
134 QPopupMenu *pmPlayList = new QPopupMenu( this ); 135 QPopupMenu *pmPlayList = new QPopupMenu( this );
135 menu->insertItem( tr( "File" ), pmPlayList ); 136 menu->insertItem( tr( "File" ), pmPlayList );
136 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 137 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
137 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 138 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
138 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 139 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
139 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 140 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
140 pmPlayList->insertSeparator(-1); 141 pmPlayList->insertSeparator(-1);
141 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 142 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
142 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 143 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
143 pmPlayList->insertSeparator(-1); 144 pmPlayList->insertSeparator(-1);
144 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 145 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
145 pmPlayList->insertSeparator(-1); 146 pmPlayList->insertSeparator(-1);
146 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 147 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
147 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 148 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
148 149
149 pmView = new QPopupMenu( this ); 150 pmView = new QPopupMenu( this );
150 menu->insertItem( tr( "View" ), pmView ); 151 menu->insertItem( tr( "View" ), pmView );
151 pmView->isCheckable(); 152 pmView->isCheckable();
152 153
153 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
154 155
155 Config cfg( "OpiePlayer" ); 156 Config cfg( "OpiePlayer" );
156 bool b= cfg.readBoolEntry("FullScreen", 0); 157 bool b= cfg.readBoolEntry("FullScreen", 0);
157 mediaPlayerState->setFullscreen( b ); 158 mediaPlayerState->setFullscreen( b );
158 pmView->setItemChecked( -16, b ); 159 pmView->setItemChecked( -16, b );
159 160
160 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); 161 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) );
161 162
162 pmView->insertSeparator(-1); 163 pmView->insertSeparator(-1);
163 164
164 skinsMenu = new QPopupMenu( this ); 165 skinsMenu = new QPopupMenu( this );
165 pmView->insertItem( tr( "Skins" ), skinsMenu ); 166 pmView->insertItem( tr( "Skins" ), skinsMenu );
166 skinsMenu->isCheckable(); 167 skinsMenu->isCheckable();
167 populateSkinsMenu(); 168 populateSkinsMenu();
168 169
169 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
170 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
171 172
172 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
173 174
174 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 175 tabWidget = new QTabWidget( hbox6, "tabWidget" );
175 // tabWidget->setTabShape(QTabWidget::Triangular); 176 // tabWidget->setTabShape(QTabWidget::Triangular);
176 177
177 QWidget *pTab; 178 QWidget *pTab;
178 pTab = new QWidget( tabWidget, "pTab" ); 179 pTab = new QWidget( tabWidget, "pTab" );
179 tabWidget->insertTab( pTab,"Playlist"); 180 tabWidget->insertTab( pTab,"Playlist");
180 181
181 182
182 QGridLayout *Playout = new QGridLayout( pTab ); 183 QGridLayout *Playout = new QGridLayout( pTab );
183 Playout->setSpacing( 2); 184 Playout->setSpacing( 2);
184 Playout->setMargin( 2); 185 Playout->setMargin( 2);
185 186
186 // Add the playlist area 187 // Add the playlist area
187 188
188 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 189 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
189 d->playListFrame = vbox3; 190 d->playListFrame = vbox3;
190 191
191 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 192 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
192 193
193 d->selectedFiles = new PlayListSelection( hbox2); 194 d->selectedFiles = new PlayListSelection( hbox2);
194 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 195 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
195 196
196 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 197 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
197 198
198 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
199 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 200 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) );
200 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); 201 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) );
201 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 202 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) );
202 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
203 204
204 205
205 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 206 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
206 207
207 QWidget *aTab; 208 QWidget *aTab;
208 aTab = new QWidget( tabWidget, "aTab" ); 209 aTab = new QWidget( tabWidget, "aTab" );
209 210
210 QGridLayout *Alayout = new QGridLayout( aTab ); 211 QGridLayout *Alayout = new QGridLayout( aTab );
211 Alayout->setSpacing( 2); 212 Alayout->setSpacing( 2);
212 Alayout->setMargin( 2); 213 Alayout->setMargin( 2);
213 214
214 audioView = new QListView( aTab, "Audioview" ); 215 audioView = new QListView( aTab, "Audioview" );
215 audioView->addColumn( tr("Title"),140); 216 audioView->addColumn( tr("Title"),140);
216 audioView->addColumn(tr("Size"), -1); 217 audioView->addColumn(tr("Size"), -1);
217 audioView->addColumn(tr("Media"),-1); 218 audioView->addColumn(tr("Media"),-1);
218 audioView->setColumnAlignment(1, Qt::AlignRight); 219 audioView->setColumnAlignment(1, Qt::AlignRight);
219 audioView->setColumnAlignment(2, Qt::AlignRight); 220 audioView->setColumnAlignment(2, Qt::AlignRight);
220 audioView->setAllColumnsShowFocus(TRUE); 221 audioView->setAllColumnsShowFocus(TRUE);
221 audioView->setSorting(0,TRUE); 222 audioView->setSorting(0,TRUE);
222 223
223 audioView->setMultiSelection( TRUE ); 224 audioView->setMultiSelection( TRUE );
224 audioView->setSelectionMode( QListView::Extended); 225 audioView->setSelectionMode( QListView::Extended);
225 226
226 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 227 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
227 228
228 tabWidget->insertTab(aTab,tr("Audio")); 229 tabWidget->insertTab(aTab,tr("Audio"));
229 230
230 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 231 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
231 232
232 QWidget *vTab; 233 QWidget *vTab;
233 vTab = new QWidget( tabWidget, "vTab" ); 234 vTab = new QWidget( tabWidget, "vTab" );
234 235
235 QGridLayout *Vlayout = new QGridLayout( vTab ); 236 QGridLayout *Vlayout = new QGridLayout( vTab );
236 Vlayout->setSpacing( 2); 237 Vlayout->setSpacing( 2);
237 Vlayout->setMargin( 2); 238 Vlayout->setMargin( 2);
238 239
239 videoView = new QListView( vTab, "Videoview" ); 240 videoView = new QListView( vTab, "Videoview" );
240 241
241 videoView->addColumn(tr("Title"),140); 242 videoView->addColumn(tr("Title"),140);
242 videoView->addColumn(tr("Size"),-1); 243 videoView->addColumn(tr("Size"),-1);
243 videoView->addColumn(tr("Media"),-1); 244 videoView->addColumn(tr("Media"),-1);
244 videoView->setColumnAlignment(1, Qt::AlignRight); 245 videoView->setColumnAlignment(1, Qt::AlignRight);
245 videoView->setColumnAlignment(2, Qt::AlignRight); 246 videoView->setColumnAlignment(2, Qt::AlignRight);
246 videoView->setAllColumnsShowFocus(TRUE); 247 videoView->setAllColumnsShowFocus(TRUE);
247 videoView->setSorting(0,TRUE); 248 videoView->setSorting(0,TRUE);
248 249
249 videoView->setMultiSelection( TRUE ); 250 videoView->setMultiSelection( TRUE );
250 videoView->setSelectionMode( QListView::Extended); 251 videoView->setSelectionMode( QListView::Extended);
251 252
252 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 253 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
253 254
254 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 255 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
255 256
256 tabWidget->insertTab( vTab,tr("Video")); 257 tabWidget->insertTab( vTab,tr("Video"));
257 258
258 //playlists list 259 //playlists list
259 QWidget *LTab; 260 QWidget *LTab;
260 LTab = new QWidget( tabWidget, "LTab" ); 261 LTab = new QWidget( tabWidget, "LTab" );
261 QGridLayout *Llayout = new QGridLayout( LTab ); 262 QGridLayout *Llayout = new QGridLayout( LTab );
262 Llayout->setSpacing( 2); 263 Llayout->setSpacing( 2);
263 Llayout->setMargin( 2); 264 Llayout->setMargin( 2);
264 265
265 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 266 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
266 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 267 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
267 268
268 tabWidget->insertTab(LTab,tr("Lists")); 269 tabWidget->insertTab(LTab,tr("Lists"));
269 270
270 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
271 272
272 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); 273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) );
273 274
274 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); 275 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) );
275 276
276 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); 277 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) );
277 278
278 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 279 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
279 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
280 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
281 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
282 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
283 this,SLOT( playIt( QListViewItem *)) ); 284 this,SLOT( playIt( QListViewItem *)) );
284 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
285 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
286 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
287 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
288 this,SLOT( playIt( QListViewItem *)) ); 289 this,SLOT( playIt( QListViewItem *)) );
289 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
290 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
291 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
292 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
293 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
294 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
295 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
296 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
297 298
298 setCentralWidget( vbox5 ); 299 setCentralWidget( vbox5 );
299 300
300 readConfig( cfg ); 301 readConfig( cfg );
301 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
302 loadList(DocLnk( currentPlaylist)); 303 loadList(DocLnk( currentPlaylist));
303 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 304 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
304 305
305 initializeStates(); 306 initializeStates();
306} 307}
307 308
308 309
309PlayListWidget::~PlayListWidget() { 310PlayListWidget::~PlayListWidget() {
310 if ( d->current ) { 311/* fixing symptoms and not sources is entirely stupid - zecke */
311 delete d->current; 312// Config cfg( "OpiePlayer" );
312 } 313// writeConfig( cfg );
313 delete d; 314
315 if ( d->current ) {
316 delete d->current;
317 }
318 delete d;
314} 319}
315 320
316 321
317void PlayListWidget::initializeStates() { 322void PlayListWidget::initializeStates() {
318 323
319 d->tbPlay->setOn( mediaPlayerState->playing() ); 324 d->tbPlay->setOn( mediaPlayerState->playing() );
320 d->tbLoop->setOn( mediaPlayerState->looping() ); 325 d->tbLoop->setOn( mediaPlayerState->looping() );
321 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 326 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
322 setPlaylist( true); 327 setPlaylist( true);
323} 328}
324 329
325 330
326void PlayListWidget::readConfig( Config& cfg ) { 331void PlayListWidget::readConfig( Config& cfg ) {
327 cfg.setGroup("PlayList"); 332 cfg.setGroup("PlayList");
328 QString currentString = cfg.readEntry("current", "" ); 333 QString currentString = cfg.readEntry("current", "" );
329 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 334 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
330 for ( int i = 0; i < noOfFiles; i++ ) { 335 for ( int i = 0; i < noOfFiles; i++ ) {
331 QString entryName; 336 QString entryName;
332 entryName.sprintf( "File%i", i + 1 ); 337 entryName.sprintf( "File%i", i + 1 );
333 QString linkFile = cfg.readEntry( entryName ); 338 QString linkFile = cfg.readEntry( entryName );
334 if(QFileInfo( linkFile).exists() ) { 339 if(QFileInfo( linkFile).exists() ) {
335 DocLnk lnk( linkFile ); 340 DocLnk lnk( linkFile );
336 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { 341 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) {
337 d->selectedFiles->addToSelection( lnk ); 342 d->selectedFiles->addToSelection( lnk );
338 } 343 }
339 } 344 }
340 } 345 }
341 d->selectedFiles->setSelectedItem( currentString); 346 d->selectedFiles->setSelectedItem( currentString);
342} 347}
343 348
344 349
345void PlayListWidget::writeConfig( Config& cfg ) const { 350void PlayListWidget::writeConfig( Config& cfg ) const {
346 351
347 d->selectedFiles->writeCurrent( cfg); 352 d->selectedFiles->writeCurrent( cfg);
348 cfg.setGroup("PlayList"); 353 cfg.setGroup("PlayList");
349 int noOfFiles = 0; 354 int noOfFiles = 0;
350 d->selectedFiles->first(); 355 d->selectedFiles->first();
351 do { 356 do {
352 const DocLnk *lnk = d->selectedFiles->current(); 357 const DocLnk *lnk = d->selectedFiles->current();
353 if ( lnk ) { 358 if ( lnk ) {
354 QString entryName; 359 QString entryName;
355 entryName.sprintf( "File%i", noOfFiles + 1 ); 360 entryName.sprintf( "File%i", noOfFiles + 1 );
356 cfg.writeEntry( entryName, lnk->linkFile() ); 361 cfg.writeEntry( entryName, lnk->linkFile() );
357 // if this link does exist, add it so we have the file 362 // if this link does exist, add it so we have the file
358 // next time... 363 // next time...
359 if ( !QFile::exists( lnk->linkFile() ) ) { 364 if ( !QFile::exists( lnk->linkFile() ) ) {
360 // the way writing lnks doesn't really check for out 365 // the way writing lnks doesn't really check for out
361 // of disk space, but check it anyway. 366 // of disk space, but check it anyway.
362 if ( !lnk->writeLink() ) { 367 if ( !lnk->writeLink() ) {
363 QMessageBox::critical( 0, tr("Out of space"), 368 QMessageBox::critical( 0, tr("Out of space"),
364 tr( "There was a problem saving " 369 tr( "There was a problem saving "
365 "the playlist.\n" 370 "the playlist.\n"
366 "Your playlist " 371 "Your playlist "
367 "may be missing some entries\n" 372 "may be missing some entries\n"
368 "the next time you start it." ) 373 "the next time you start it." )
369 ); 374 );
370 } 375 }
371 } 376 }
372 noOfFiles++; 377 noOfFiles++;
373 } 378 }
374 } 379 }
375 while ( d->selectedFiles->next() ); 380 while ( d->selectedFiles->next() );
376 cfg.writeEntry("NumberOfFiles", noOfFiles ); 381 cfg.writeEntry("NumberOfFiles", noOfFiles );
377} 382}
378 383
379 384
380void PlayListWidget::addToSelection( const DocLnk& lnk ) { 385void PlayListWidget::addToSelection( const DocLnk& lnk ) {
381 d->setDocumentUsed = FALSE; 386 d->setDocumentUsed = FALSE;
382 if ( mediaPlayerState->playlist() ) { 387 if ( mediaPlayerState->playlist() ) {
383 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 388 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
384 d->selectedFiles->addToSelection( lnk ); 389 d->selectedFiles->addToSelection( lnk );
385 } 390 }
386 else 391 else
387 mediaPlayerState->setPlaying( TRUE ); 392 mediaPlayerState->setPlaying( TRUE );
388} 393}
389 394
390 395
391void PlayListWidget::clearList() { 396void PlayListWidget::clearList() {
392 while ( first() ) { 397 while ( first() ) {
393 d->selectedFiles->removeSelected(); 398 d->selectedFiles->removeSelected();
394 } 399 }
395} 400}
396 401
397 402
398void PlayListWidget::addAllToList() { 403void PlayListWidget::addAllToList() {
399 DocLnkSet filesAll; 404 DocLnkSet filesAll;
400 Global::findDocuments(&filesAll, "video/*;audio/*"); 405 Global::findDocuments(&filesAll, "video/*;audio/*");
401 QListIterator<DocLnk> Adit( filesAll.children() ); 406 QListIterator<DocLnk> Adit( filesAll.children() );
402 for ( ; Adit.current(); ++Adit ) { 407 for ( ; Adit.current(); ++Adit ) {
403 if(QFileInfo(Adit.current()->file()).exists()) { 408 if(QFileInfo(Adit.current()->file()).exists()) {
404 d->selectedFiles->addToSelection( **Adit ); 409 d->selectedFiles->addToSelection( **Adit );
405 } 410 }
406 } 411 }
407} 412}
408 413
409 414
410void PlayListWidget::addAllMusicToList() { 415void PlayListWidget::addAllMusicToList() {
411 QListIterator<DocLnk> dit( files.children() ); 416 QListIterator<DocLnk> dit( files.children() );
412 for ( ; dit.current(); ++dit ) { 417 for ( ; dit.current(); ++dit ) {
413 if(QFileInfo(dit.current()->file()).exists()) { 418 if(QFileInfo(dit.current()->file()).exists()) {
414 d->selectedFiles->addToSelection( **dit ); 419 d->selectedFiles->addToSelection( **dit );
415 } 420 }
416 } 421 }
417} 422}
418 423
419 424
420void PlayListWidget::addAllVideoToList() { 425void PlayListWidget::addAllVideoToList() {
421 QListIterator<DocLnk> dit( vFiles.children() ); 426 QListIterator<DocLnk> dit( vFiles.children() );
422 for ( ; dit.current(); ++dit ) 427 for ( ; dit.current(); ++dit )
423 if(QFileInfo( dit.current()->file()).exists()) 428 if(QFileInfo( dit.current()->file()).exists())
424 d->selectedFiles->addToSelection( **dit ); 429 d->selectedFiles->addToSelection( **dit );
425} 430}
426 431
427 432
428void PlayListWidget::setDocument(const QString& fileref) { 433void PlayListWidget::setDocument(const QString& fileref) {
429 qDebug(fileref); 434 qDebug(fileref);
430 fromSetDocument = TRUE; 435 fromSetDocument = TRUE;
431 if ( fileref.isNull() ) { 436 if ( fileref.isNull() ) {
432 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 437 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
433 return; 438 return;
434 } 439 }
435 440
436 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 441 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
437 readm3u( fileref); 442 readm3u( fileref);
438 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls 443 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls
439 readPls( fileref); 444 readPls( fileref);
440 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 445 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
441 clearList(); 446 clearList();
442 loadList(DocLnk(fileref)); 447 loadList(DocLnk(fileref));
443 d->selectedFiles->first(); 448 d->selectedFiles->first();
444 } else { 449 } else {
445 clearList(); 450 clearList();
446 addToSelection( DocLnk( fileref ) ); 451 addToSelection( DocLnk( fileref ) );
447 d->setDocumentUsed = TRUE; 452 d->setDocumentUsed = TRUE;
448 mediaPlayerState->setPlaying( FALSE ); 453 mediaPlayerState->setPlaying( FALSE );
449 qApp->processEvents(); 454 qApp->processEvents();
450 mediaPlayerState->setPlaying( TRUE ); 455 mediaPlayerState->setPlaying( TRUE );
451 qApp->processEvents(); 456 qApp->processEvents();
452 setCaption(tr("OpiePlayer")); 457 setCaption(tr("OpiePlayer"));
453 } 458 }
454} 459}
455 460
456 461
457void PlayListWidget::setActiveWindow() { 462void PlayListWidget::setActiveWindow() {
458// qDebug("SETTING active window"); 463// qDebug("SETTING active window");
459 // When we get raised we need to ensure that it switches views 464 // When we get raised we need to ensure that it switches views
460 char origView = mediaPlayerState->view(); 465 char origView = mediaPlayerState->view();
461 mediaPlayerState->setView( 'l' ); // invalidate 466 mediaPlayerState->setView( 'l' ); // invalidate
462 mediaPlayerState->setView( origView ); // now switch back 467 mediaPlayerState->setView( origView ); // now switch back
463} 468}
464 469
465 470
466void PlayListWidget::useSelectedDocument() { 471void PlayListWidget::useSelectedDocument() {
467 d->setDocumentUsed = FALSE; 472 d->setDocumentUsed = FALSE;
468} 473}
469 474
470 475
471const DocLnk *PlayListWidget::current() { // this is fugly 476const DocLnk *PlayListWidget::current() { // this is fugly
472 477
473 switch (tabWidget->currentPageIndex()) { 478 switch (tabWidget->currentPageIndex()) {
474 case 0: //playlist 479 case 0: //playlist
475 { 480 {
476// qDebug("playlist"); 481// qDebug("playlist");
477 if ( mediaPlayerState->playlist() ) { 482 if ( mediaPlayerState->playlist() ) {
478 return d->selectedFiles->current(); 483 return d->selectedFiles->current();
479 } else if ( d->setDocumentUsed && d->current ) { 484 } else if ( d->setDocumentUsed && d->current ) {
480 return d->current; 485 return d->current;
481 } else { 486 } else {
482 return d->files->selected(); 487 return d->files->selected();
483 } 488 }
484 } 489 }
485 break; 490 break;
486 case 1://audio 491 case 1://audio
487 { 492 {
488// qDebug("audioView"); 493// qDebug("audioView");
489 QListIterator<DocLnk> dit( files.children() ); 494 QListIterator<DocLnk> dit( files.children() );
490 for ( ; dit.current(); ++dit ) { 495 for ( ; dit.current(); ++dit ) {
491 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 496 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
492 insanityBool=TRUE; 497 insanityBool=TRUE;
493 return dit; 498 return dit;
494 } 499 }
495 } 500 }
496 } 501 }
497 break; 502 break;
498 case 2: // video 503 case 2: // video
499 { 504 {
500// qDebug("videoView"); 505// qDebug("videoView");
501 QListIterator<DocLnk> Vdit( vFiles.children() ); 506 QListIterator<DocLnk> Vdit( vFiles.children() );
502 for ( ; Vdit.current(); ++Vdit ) { 507 for ( ; Vdit.current(); ++Vdit ) {
503 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 508 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
504 insanityBool=TRUE; 509 insanityBool=TRUE;
505 return Vdit; 510 return Vdit;
506 } 511 }
507 } 512 }
508 } 513 }
509 break; 514 break;
510 }; 515 };
511 return 0; 516 return 0;
512} 517}
513 518
514bool PlayListWidget::prev() { 519bool PlayListWidget::prev() {
515 if ( mediaPlayerState->playlist() ) { 520 if ( mediaPlayerState->playlist() ) {
516 if ( mediaPlayerState->shuffled() ) { 521 if ( mediaPlayerState->shuffled() ) {
517 const DocLnk *cur = current(); 522 const DocLnk *cur = current();
518 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 523 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
519 for ( int i = 0; i < j; i++ ) { 524 for ( int i = 0; i < j; i++ ) {
520 if ( !d->selectedFiles->next() ) 525 if ( !d->selectedFiles->next() )
521 d->selectedFiles->first(); 526 d->selectedFiles->first();
522 } 527 }
523 if ( cur == current() ) 528 if ( cur == current() )
524 if ( !d->selectedFiles->next() ) 529 if ( !d->selectedFiles->next() )
525 d->selectedFiles->first(); 530 d->selectedFiles->first();
526 return TRUE; 531 return TRUE;
527 } else { 532 } else {
528 if ( !d->selectedFiles->prev() ) { 533 if ( !d->selectedFiles->prev() ) {
529 if ( mediaPlayerState->looping() ) { 534 if ( mediaPlayerState->looping() ) {
530 return d->selectedFiles->last(); 535 return d->selectedFiles->last();
531 } else { 536 } else {
532 return FALSE; 537 return FALSE;
533 } 538 }
534 } 539 }
535 return TRUE; 540 return TRUE;
536 } 541 }
537 } else { 542 } else {
538 return mediaPlayerState->looping(); 543 return mediaPlayerState->looping();
539 } 544 }
540} 545}
541 546
542 547
543bool PlayListWidget::next() { 548bool PlayListWidget::next() {
544 if ( mediaPlayerState->playlist() ) { 549 if ( mediaPlayerState->playlist() ) {
545 if ( mediaPlayerState->shuffled() ) { 550 if ( mediaPlayerState->shuffled() ) {
546 return prev(); 551 return prev();
547 } else { 552 } else {
548 if ( !d->selectedFiles->next() ) { 553 if ( !d->selectedFiles->next() ) {
549 if ( mediaPlayerState->looping() ) { 554 if ( mediaPlayerState->looping() ) {
550 return d->selectedFiles->first(); 555 return d->selectedFiles->first();
551 } else { 556 } else {
552 return FALSE; 557 return FALSE;
553 } 558 }
554 } 559 }
555 return TRUE; 560 return TRUE;
556 } 561 }
557 } else { 562 } else {
558 return mediaPlayerState->looping(); 563 return mediaPlayerState->looping();
559 } 564 }
560} 565}
561 566
562 567
563bool PlayListWidget::first() { 568bool PlayListWidget::first() {
564 if ( mediaPlayerState->playlist() ) 569 if ( mediaPlayerState->playlist() )
565 return d->selectedFiles->first(); 570 return d->selectedFiles->first();
566 else 571 else
567 return mediaPlayerState->looping(); 572 return mediaPlayerState->looping();
568} 573}
569 574
570 575
571bool PlayListWidget::last() { 576bool PlayListWidget::last() {
572 if ( mediaPlayerState->playlist() ) 577 if ( mediaPlayerState->playlist() )
573 return d->selectedFiles->last(); 578 return d->selectedFiles->last();
574 else 579 else
575 return mediaPlayerState->looping(); 580 return mediaPlayerState->looping();
576} 581}
577 582
578 583
579void PlayListWidget::saveList() { 584void PlayListWidget::saveList() {
580 585
581 QString filename; 586 QString filename;
582 InputDialog *fileDlg = 0l; 587 InputDialog *fileDlg = 0l;
583 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 588 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
584 fileDlg->exec(); 589 fileDlg->exec();
585 if( fileDlg->result() == 1 ) { 590 if( fileDlg->result() == 1 ) {
586 if ( d->current ) 591 if ( d->current )
587 delete d->current; 592 delete d->current;
588 filename = fileDlg->text();//+".playlist"; 593 filename = fileDlg->text();//+".playlist";
589 // qDebug("saving playlist "+filename+".playlist"); 594 // qDebug("saving playlist "+filename+".playlist");
590 Config cfg( filename +".playlist"); 595 Config cfg( filename +".playlist");
591 writeConfig( cfg ); 596 writeConfig( cfg );
592 597
593 DocLnk lnk; 598 DocLnk lnk;
594 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 599 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
595 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 600 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
596 lnk.setIcon("opieplayer2/playlist2"); 601 lnk.setIcon("opieplayer2/playlist2");
597 lnk.setName( filename); //sets file name 602 lnk.setName( filename); //sets file name
598 // qDebug(filename); 603 // qDebug(filename);
599 if(!lnk.writeLink()) { 604 if(!lnk.writeLink()) {
600 qDebug("Writing doclink did not work"); 605 qDebug("Writing doclink did not work");
601 } 606 }
602 } 607 }
603 Config config( "OpiePlayer" ); 608 Config config( "OpiePlayer" );
604 config.writeEntry("CurrentPlaylist",filename); 609 config.writeEntry("CurrentPlaylist",filename);
605 setCaption(tr("OpiePlayer: ")+filename); 610 setCaption(tr("OpiePlayer: ")+filename);
606 d->selectedFiles->first(); 611 d->selectedFiles->first();
607 if(fileDlg) { 612 if(fileDlg) {
608 delete fileDlg; 613 delete fileDlg;
609 } 614 }
610} 615}
611 616
612void PlayListWidget::loadList( const DocLnk & lnk) { 617void PlayListWidget::loadList( const DocLnk & lnk) {
613 QString name= lnk.name(); 618 QString name= lnk.name();
614 // qDebug("currentList is "+name); 619 // qDebug("currentList is "+name);
615 if( name.length()>1) { 620 if( name.length()>1) {
616 setCaption("OpiePlayer: "+name); 621 setCaption("OpiePlayer: "+name);
617 // qDebug("load list "+ name+".playlist"); 622 // qDebug("load list "+ name+".playlist");
618 clearList(); 623 clearList();
619 Config cfg( name+".playlist"); 624 Config cfg( name+".playlist");
620 readConfig(cfg); 625 readConfig(cfg);
621 626
622 tabWidget->setCurrentPage(0); 627 tabWidget->setCurrentPage(0);
623 628
624 Config config( "OpiePlayer" ); 629 Config config( "OpiePlayer" );
625 config.writeEntry("CurrentPlaylist", name); 630 config.writeEntry("CurrentPlaylist", name);
626 // d->selectedFiles->first(); 631 // d->selectedFiles->first();
627 } 632 }
628 633
629} 634}
630 635
631void PlayListWidget::setPlaylist( bool shown ) { 636void PlayListWidget::setPlaylist( bool shown ) {
632 if ( shown ) { 637 if ( shown ) {
633 d->playListFrame->show(); 638 d->playListFrame->show();
634 } else { 639 } else {
635 d->playListFrame->hide(); 640 d->playListFrame->hide();
636 } 641 }
637} 642}
638 643
639void PlayListWidget::setView( char view ) { 644void PlayListWidget::setView( char view ) {
640 if ( view == 'l' ) 645 if ( view == 'l' )
641 showMaximized(); 646 showMaximized();
642 else 647 else
643 hide(); 648 hide();
644} 649}
645 650
646void PlayListWidget::addSelected() { 651void PlayListWidget::addSelected() {
647 652
648 Config cfg( "OpiePlayer" ); 653 Config cfg( "OpiePlayer" );
649 cfg.setGroup("PlayList"); 654 cfg.setGroup("PlayList");
650 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 655 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
651 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 656 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
652 657
653 switch (tabWidget->currentPageIndex()) { 658 switch (tabWidget->currentPageIndex()) {
654 case 0: //playlist 659 case 0: //playlist
655 break; 660 break;
656 case 1: { //audio 661 case 1: { //audio
657 QListViewItemIterator it( audioView ); 662 QListViewItemIterator it( audioView );
658 // iterate through all items of the listview 663 // iterate through all items of the listview
659 for ( ; it.current(); ++it ) { 664 for ( ; it.current(); ++it ) {
660 if ( it.current()->isSelected() ) { 665 if ( it.current()->isSelected() ) {
661 QListIterator<DocLnk> dit( files.children() ); 666 QListIterator<DocLnk> dit( files.children() );
662 for ( ; dit.current(); ++dit ) { 667 for ( ; dit.current(); ++dit ) {
663 if( dit.current()->name() == it.current()->text(0) ) { 668 if( dit.current()->name() == it.current()->text(0) ) {
664 if(QFileInfo( dit.current()->file()).exists()) 669 if(QFileInfo( dit.current()->file()).exists())
665 d->selectedFiles->addToSelection( **dit ); 670 d->selectedFiles->addToSelection( **dit );
666 } 671 }
667 } 672 }
668 audioView->setSelected( it.current(),FALSE); 673 audioView->setSelected( it.current(),FALSE);
669 } 674 }
670 } 675 }
671 tabWidget->setCurrentPage(0); 676 tabWidget->setCurrentPage(0);
672 } 677 }
673 break; 678 break;
674 case 2: { // video 679 case 2: { // video
675 QListViewItemIterator it( videoView ); 680 QListViewItemIterator it( videoView );
676 // iterate through all items of the listview 681 // iterate through all items of the listview
677 for ( ; it.current(); ++it ) { 682 for ( ; it.current(); ++it ) {
678 if ( it.current()->isSelected() ) { 683 if ( it.current()->isSelected() ) {
679 QListIterator<DocLnk> dit( vFiles.children() ); 684 QListIterator<DocLnk> dit( vFiles.children() );
680 for ( ; dit.current(); ++dit ) { 685 for ( ; dit.current(); ++dit ) {
681 if( dit.current()->name() == it.current()->text(0) ) { 686 if( dit.current()->name() == it.current()->text(0) ) {
682 if(QFileInfo( dit.current()->file()).exists()) 687 if(QFileInfo( dit.current()->file()).exists())
683 d->selectedFiles->addToSelection( **dit ); 688 d->selectedFiles->addToSelection( **dit );
684 } 689 }
685 } 690 }
686 videoView->setSelected( it.current(),FALSE); 691 videoView->setSelected( it.current(),FALSE);
687 } 692 }
688 } 693 }
689 tabWidget->setCurrentPage(0); 694 tabWidget->setCurrentPage(0);
690 } 695 }
691 break; 696 break;
692 }; 697 };
693} 698}
694 699
695void PlayListWidget::removeSelected() { 700void PlayListWidget::removeSelected() {
696 d->selectedFiles->removeSelected( ); 701 d->selectedFiles->removeSelected( );
697} 702}
698 703
699void PlayListWidget::playIt( QListViewItem *it) { 704void PlayListWidget::playIt( QListViewItem *it) {
700 if(!it) return; 705 if(!it) return;
701 mediaPlayerState->setPlaying(FALSE); 706 mediaPlayerState->setPlaying(FALSE);
702 mediaPlayerState->setPlaying(TRUE); 707 mediaPlayerState->setPlaying(TRUE);
703 d->selectedFiles->unSelect(); 708 d->selectedFiles->unSelect();
704} 709}
705 710
706void PlayListWidget::addToSelection( QListViewItem *it) { 711void PlayListWidget::addToSelection( QListViewItem *it) {
707 d->setDocumentUsed = FALSE; 712 d->setDocumentUsed = FALSE;
708 713
709 if(it) { 714 if(it) {
710 switch (tabWidget->currentPageIndex()) { 715 switch (tabWidget->currentPageIndex()) {
711 case 1: { 716 case 1: {
712 QListIterator<DocLnk> dit( files.children() ); 717 QListIterator<DocLnk> dit( files.children() );
713 for ( ; dit.current(); ++dit ) { 718 for ( ; dit.current(); ++dit ) {
714 if( dit.current()->name() == it->text(0)) { 719 if( dit.current()->name() == it->text(0)) {
715 if(QFileInfo( dit.current()->file()).exists()) 720 if(QFileInfo( dit.current()->file()).exists())
716 d->selectedFiles->addToSelection( **dit ); 721 d->selectedFiles->addToSelection( **dit );
717 } 722 }
718 } 723 }
719 } 724 }
720 break; 725 break;
721 case 2: { 726 case 2: {
722 QListIterator<DocLnk> dit( vFiles.children() ); 727 QListIterator<DocLnk> dit( vFiles.children() );
723 for ( ; dit.current(); ++dit ) { 728 for ( ; dit.current(); ++dit ) {
724 if( dit.current()->name() == it->text(0)) { 729 if( dit.current()->name() == it->text(0)) {
725 if(QFileInfo( dit.current()->file()).exists()) 730 if(QFileInfo( dit.current()->file()).exists())
726 d->selectedFiles->addToSelection( **dit ); 731 d->selectedFiles->addToSelection( **dit );
727 } 732 }
728 } 733 }
729 } 734 }
730 break; 735 break;
731 case 0: 736 case 0:
732 break; 737 break;
733 }; 738 };
734 tabWidget->setCurrentPage(0); 739 tabWidget->setCurrentPage(0);
735 } 740 }
736} 741}
737 742
738void PlayListWidget::tabChanged(QWidget *) { 743void PlayListWidget::tabChanged(QWidget *) {
739 744
740 switch ( tabWidget->currentPageIndex()) { 745 switch ( tabWidget->currentPageIndex()) {
741 case 0: 746 case 0:
742 { 747 {
743 if( !tbDeletePlaylist->isHidden()) 748 if( !tbDeletePlaylist->isHidden())
744 tbDeletePlaylist->hide(); 749 tbDeletePlaylist->hide();
745 d->tbRemoveFromList->setEnabled(TRUE); 750 d->tbRemoveFromList->setEnabled(TRUE);
746 d->tbAddToList->setEnabled(FALSE); 751 d->tbAddToList->setEnabled(FALSE);
747 } 752 }
748 break; 753 break;
749 case 1: 754 case 1:
750 { 755 {
751 audioView->clear(); 756 audioView->clear();
752 populateAudioView(); 757 populateAudioView();
753 758
754 if( !tbDeletePlaylist->isHidden()) 759 if( !tbDeletePlaylist->isHidden())
755 tbDeletePlaylist->hide(); 760 tbDeletePlaylist->hide();
756 d->tbRemoveFromList->setEnabled(FALSE); 761 d->tbRemoveFromList->setEnabled(FALSE);
757 d->tbAddToList->setEnabled(TRUE); 762 d->tbAddToList->setEnabled(TRUE);
758 } 763 }
759 break; 764 break;
760 case 2: 765 case 2:
761 { 766 {
762 videoView->clear(); 767 videoView->clear();
763 populateVideoView(); 768 populateVideoView();
764 if( !tbDeletePlaylist->isHidden()) 769 if( !tbDeletePlaylist->isHidden())
765 tbDeletePlaylist->hide(); 770 tbDeletePlaylist->hide();
766 d->tbRemoveFromList->setEnabled(FALSE); 771 d->tbRemoveFromList->setEnabled(FALSE);
767 d->tbAddToList->setEnabled(TRUE); 772 d->tbAddToList->setEnabled(TRUE);
768 } 773 }
769 break; 774 break;
770 case 3: 775 case 3:
771 { 776 {
772 if( tbDeletePlaylist->isHidden()) 777 if( tbDeletePlaylist->isHidden())
773 tbDeletePlaylist->show(); 778 tbDeletePlaylist->show();
774 playLists->reread(); 779 playLists->reread();
775 } 780 }
776 break; 781 break;
777 }; 782 };
778} 783}
779 784
780void PlayListWidget::btnPlay(bool b) { 785void PlayListWidget::btnPlay(bool b) {
781 786
782 // mediaPlayerState->setPlaying(b); 787 // mediaPlayerState->setPlaying(b);
783 switch ( tabWidget->currentPageIndex()) { 788 switch ( tabWidget->currentPageIndex()) {
784 case 0: 789 case 0:
785 { 790 {
786 mediaPlayerState->setPlaying(b); 791 mediaPlayerState->setPlaying(b);
787 } 792 }
788 break; 793 break;
789 case 1: 794 case 1:
790 { 795 {
791 addToSelection( audioView->currentItem() ); 796 addToSelection( audioView->currentItem() );
792 mediaPlayerState->setPlaying(b); 797 mediaPlayerState->setPlaying(b);
793 d->selectedFiles->removeSelected( ); 798 d->selectedFiles->removeSelected( );
794 tabWidget->setCurrentPage(1); 799 tabWidget->setCurrentPage(1);
795 d->selectedFiles->unSelect(); 800 d->selectedFiles->unSelect();
796 insanityBool=FALSE; 801 insanityBool=FALSE;
797 }// audioView->clearSelection(); 802 }// audioView->clearSelection();
798 break; 803 break;
799 case 2: 804 case 2:
800 { 805 {
801 addToSelection( videoView->currentItem() ); 806 addToSelection( videoView->currentItem() );
802 mediaPlayerState->setPlaying(b); 807 mediaPlayerState->setPlaying(b);
803 qApp->processEvents(); 808 qApp->processEvents();
804 d->selectedFiles->removeSelected( ); 809 d->selectedFiles->removeSelected( );
805 tabWidget->setCurrentPage(2); 810 tabWidget->setCurrentPage(2);
806 d->selectedFiles->unSelect(); 811 d->selectedFiles->unSelect();
807 insanityBool=FALSE; 812 insanityBool=FALSE;
808 }// videoView->clearSelection(); 813 }// videoView->clearSelection();
809 break; 814 break;
810 }; 815 };
811 816
812} 817}
813 818
814void PlayListWidget::deletePlaylist() { 819void PlayListWidget::deletePlaylist() {
815 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 820 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
816 (tr("You really want to delete\nthis playlist?")), 821 (tr("You really want to delete\nthis playlist?")),
817 (tr("Yes")), (tr("No")), 0 )){ 822 (tr("Yes")), (tr("No")), 0 )){
818 case 0: // Yes clicked, 823 case 0: // Yes clicked,
819 QFile().remove(playLists->selected()->file()); 824 QFile().remove(playLists->selected()->file());
820 QFile().remove(playLists->selected()->linkFile()); 825 QFile().remove(playLists->selected()->linkFile());
821 playLists->reread(); 826 playLists->reread();
822 break; 827 break;
823 case 1: // Cancel 828 case 1: // Cancel
824 break; 829 break;
825 }; 830 };
826} 831}
827 832
828void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 833void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
829 switch (mouse) { 834 switch (mouse) {
830 case 1: 835 case 1:
831 break; 836 break;
832 case 2:{ 837 case 2:{
833 QPopupMenu m; 838 QPopupMenu m;
834 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 839 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
835 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 840 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
836 m.exec( QCursor::pos() ); 841 m.exec( QCursor::pos() );
837 } 842 }
838 break; 843 break;
839 }; 844 };
840} 845}
841 846
842void PlayListWidget::playSelected() { 847void PlayListWidget::playSelected() {
843 btnPlay( TRUE); 848 btnPlay( TRUE);
844} 849}
845 850
846void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 851void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
847 switch (mouse) { 852 switch (mouse) {
848 case 1: 853 case 1:
849 854
850 break; 855 break;
851 case 2: 856 case 2:
852 { 857 {
853 QPopupMenu m; 858 QPopupMenu m;
854 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 859 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
855 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 860 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
856 m.exec( QCursor::pos() ); 861 m.exec( QCursor::pos() );
857 } 862 }
858 break; 863 break;
859 }; 864 };
860} 865}
861 866
862 867
863void PlayListWidget::scanForAudio() { 868void PlayListWidget::scanForAudio() {
864// qDebug("scan for audio"); 869// qDebug("scan for audio");
865 files.detachChildren(); 870 files.detachChildren();
866 QListIterator<DocLnk> sdit( files.children() ); 871 QListIterator<DocLnk> sdit( files.children() );
867 for ( ; sdit.current(); ++sdit ) { 872 for ( ; sdit.current(); ++sdit ) {
868 delete sdit.current(); 873 delete sdit.current();
869 } 874 }
870 Global::findDocuments(&files, "audio/*"); 875 Global::findDocuments(&files, "audio/*");
871 audioScan = TRUE; 876 audioScan = TRUE;
872} 877}
873 878
874void PlayListWidget::scanForVideo() { 879void PlayListWidget::scanForVideo() {
875// qDebug("scan for video"); 880// qDebug("scan for video");
876 vFiles.detachChildren(); 881 vFiles.detachChildren();
877 QListIterator<DocLnk> sdit( vFiles.children() ); 882 QListIterator<DocLnk> sdit( vFiles.children() );
878 for ( ; sdit.current(); ++sdit ) { 883 for ( ; sdit.current(); ++sdit ) {
879 delete sdit.current(); 884 delete sdit.current();
880 } 885 }
881 Global::findDocuments(&vFiles, "video/*"); 886 Global::findDocuments(&vFiles, "video/*");
882 videoScan = TRUE; 887 videoScan = TRUE;
883} 888}
884 889
885void PlayListWidget::populateAudioView() { 890void PlayListWidget::populateAudioView() {
886 891
887 audioView->clear(); 892 audioView->clear();
888 StorageInfo storageInfo; 893 StorageInfo storageInfo;
889 const QList<FileSystem> &fs = storageInfo.fileSystems(); 894 const QList<FileSystem> &fs = storageInfo.fileSystems();
890 if(!audioScan) scanForAudio(); 895 if(!audioScan) scanForAudio();
891 896
892 QListIterator<DocLnk> dit( files.children() ); 897 QListIterator<DocLnk> dit( files.children() );
893 QListIterator<FileSystem> it ( fs ); 898 QListIterator<FileSystem> it ( fs );
894 899
895 QString storage; 900 QString storage;
896 for ( ; dit.current(); ++dit ) { 901 for ( ; dit.current(); ++dit ) {
897 for( ; it.current(); ++it ){ 902 for( ; it.current(); ++it ){
898 const QString name = (*it)->name(); 903 const QString name = (*it)->name();
899 const QString path = (*it)->path(); 904 const QString path = (*it)->path();
900 if(dit.current()->file().find(path) != -1 ) storage=name; 905 if(dit.current()->file().find(path) != -1 ) storage=name;
901 } 906 }
902 907
903 QListViewItem * newItem; 908 QListViewItem * newItem;
904 if ( QFile( dit.current()->file()).exists() ) { 909 if ( QFile( dit.current()->file()).exists() ) {
905 // qDebug(dit.current()->name()); 910 // qDebug(dit.current()->name());
906 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 911 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
907 QString::number( QFile( dit.current()->file()).size() ), storage); 912 QString::number( QFile( dit.current()->file()).size() ), storage);
908 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); 913 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" ));
909 } 914 }
910 } 915 }
911 916
912} 917}
913 918
914void PlayListWidget::populateVideoView() { 919void PlayListWidget::populateVideoView() {
915 videoView->clear(); 920 videoView->clear();
916 StorageInfo storageInfo; 921 StorageInfo storageInfo;
917 const QList<FileSystem> &fs = storageInfo.fileSystems(); 922 const QList<FileSystem> &fs = storageInfo.fileSystems();
918 923
919 if(!videoScan ) scanForVideo(); 924 if(!videoScan ) scanForVideo();
920 925
921 QListIterator<DocLnk> Vdit( vFiles.children() ); 926 QListIterator<DocLnk> Vdit( vFiles.children() );
922 QListIterator<FileSystem> it ( fs ); 927 QListIterator<FileSystem> it ( fs );
923 videoView->clear(); 928 videoView->clear();
924 QString storage; 929 QString storage;
925 for ( ; Vdit.current(); ++Vdit ) { 930 for ( ; Vdit.current(); ++Vdit ) {
926 for( ; it.current(); ++it ){ 931 for( ; it.current(); ++it ){
927 const QString name = (*it)->name(); 932 const QString name = (*it)->name();
928 const QString path = (*it)->path(); 933 const QString path = (*it)->path();
929 if( Vdit.current()->file().find(path) != -1 ) storage=name; 934 if( Vdit.current()->file().find(path) != -1 ) storage=name;
930 } 935 }
931 936
932 QListViewItem * newItem; 937 QListViewItem * newItem;
933 if ( QFile( Vdit.current()->file()).exists() ) { 938 if ( QFile( Vdit.current()->file()).exists() ) {
934 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 939 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
935 QString::number( QFile( Vdit.current()->file()).size() ), storage); 940 QString::number( QFile( Vdit.current()->file()).size() ), storage);
936 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); 941 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ));
937 } 942 }
938 } 943 }
939} 944}
940 945
941void PlayListWidget::openFile() { 946void PlayListWidget::openFile() {
942 QString filename, name; 947 QString filename, name;
943 InputDialog *fileDlg; 948 InputDialog *fileDlg;
944 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 949 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
945 fileDlg->exec(); 950 fileDlg->exec();
946 if( fileDlg->result() == 1 ) { 951 if( fileDlg->result() == 1 ) {
947 filename = fileDlg->text(); 952 filename = fileDlg->text();
948 953
949 qDebug("Selected filename is "+filename); 954 qDebug("Selected filename is "+filename);
950 if(filename.right(3) == "m3u") { 955 if(filename.right(3) == "m3u") {
951 readm3u( filename ); 956 readm3u( filename );
952 } else if(filename.right(3) == "pls") { 957 } else if(filename.right(3) == "pls") {
953 readPls( filename ); 958 readPls( filename );
954 } else { 959 } else {
960 /* FIXME ....... AUDIO/X-MPEGURL is bad*/
955 DocLnk lnk; 961 DocLnk lnk;
956 962
957 lnk.setName(filename); //sets file name 963 lnk.setName(filename); //sets file name
958 lnk.setFile(filename); //sets File property 964 lnk.setFile(filename); //sets File property
959 lnk.setType("audio/x-mpegurl"); 965 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
966 lnk.setType( MimeType( QFile::encodeName(filename) ).id() );
960 lnk.setExec("opieplayer"); 967 lnk.setExec("opieplayer");
961 lnk.setIcon("opieplayer2/MPEGPlayer"); 968 lnk.setIcon("opieplayer2/MPEGPlayer");
962 969
963 if(!lnk.writeLink()) { 970 if(!lnk.writeLink()) {
964 qDebug("Writing doclink did not work"); 971 qDebug("Writing doclink did not work");
965 } 972 }
966 d->selectedFiles->addToSelection( lnk); 973 d->selectedFiles->addToSelection( lnk);
967 } 974 }
968 } 975 }
969 if(fileDlg) { 976 if(fileDlg) {
970 delete fileDlg; 977 delete fileDlg;
971 } 978 }
972} 979}
973 980
974void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 981void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
975{ 982{
976 switch ( e->key() ) { 983 switch ( e->key() ) {
977 ////////////////////////////// Zaurus keys 984 ////////////////////////////// Zaurus keys
978 case Key_F9: //activity 985 case Key_F9: //activity
979 // if(audioUI->isHidden()) 986 // if(audioUI->isHidden())
980 // audioUI->showMaximized(); 987 // audioUI->showMaximized();
981 break; 988 break;
982 case Key_F10: //contacts 989 case Key_F10: //contacts
983 // if( videoUI->isHidden()) 990 // if( videoUI->isHidden())
984 // videoUI->showMaximized(); 991 // videoUI->showMaximized();
985 break; 992 break;
986 case Key_F11: //menu 993 case Key_F11: //menu
987 break; 994 break;
988 case Key_F12: //home 995 case Key_F12: //home
989 // doBlank(); 996 // doBlank();
990 break; 997 break;
991 case Key_F13: //mail 998 case Key_F13: //mail
992 // doUnblank(); 999 // doUnblank();
993 break; 1000 break;
994 case Key_Q: //add to playlist 1001 case Key_Q: //add to playlist
995 addSelected(); 1002 addSelected();
996 break; 1003 break;
997 case Key_R: //remove from playlist 1004 case Key_R: //remove from playlist
998 removeSelected(); 1005 removeSelected();
999 break; 1006 break;
1000 // case Key_P: //play 1007 // case Key_P: //play
1001 // qDebug("Play"); 1008 // qDebug("Play");
1002 // playSelected(); 1009 // playSelected();
1003 // break; 1010 // break;
1004 case Key_Space: 1011 case Key_Space:
1005 // playSelected(); puh 1012 // playSelected(); puh
1006 break; 1013 break;
1007 case Key_1: 1014 case Key_1:
1008 tabWidget->setCurrentPage(0); 1015 tabWidget->setCurrentPage(0);
1009 break; 1016 break;
1010 case Key_2: 1017 case Key_2:
1011 tabWidget->setCurrentPage(1); 1018 tabWidget->setCurrentPage(1);
1012 break; 1019 break;
1013 case Key_3: 1020 case Key_3:
1014 tabWidget->setCurrentPage(2); 1021 tabWidget->setCurrentPage(2);
1015 break; 1022 break;
1016 case Key_4: 1023 case Key_4:
1017 tabWidget->setCurrentPage(3); 1024 tabWidget->setCurrentPage(3);
1018 break; 1025 break;
1019 case Key_Down: 1026 case Key_Down:
1020 if ( !d->selectedFiles->next() ) 1027 if ( !d->selectedFiles->next() )
1021 d->selectedFiles->first(); 1028 d->selectedFiles->first();
1022 1029
1023 break; 1030 break;
1024 case Key_Up: 1031 case Key_Up:
1025 if ( !d->selectedFiles->prev() ) 1032 if ( !d->selectedFiles->prev() )
1026 // d->selectedFiles->last(); 1033 // d->selectedFiles->last();
1027 1034
1028 break; 1035 break;
1029 1036
1030 } 1037 }
1031} 1038}
1032 1039
1033void PlayListWidget::keyPressEvent( QKeyEvent *) 1040void PlayListWidget::keyPressEvent( QKeyEvent *)
1034{ 1041{
1035 // qDebug("Key press"); 1042 // qDebug("Key press");
1036 // switch ( e->key() ) { 1043 // switch ( e->key() ) {
1037 // ////////////////////////////// Zaurus keys 1044 // ////////////////////////////// Zaurus keys
1038 // case Key_A: //add to playlist 1045 // case Key_A: //add to playlist
1039 // qDebug("Add"); 1046 // qDebug("Add");
1040 // addSelected(); 1047 // addSelected();
1041 // break; 1048 // break;
1042 // case Key_R: //remove from playlist 1049 // case Key_R: //remove from playlist
1043 // removeSelected(); 1050 // removeSelected();
1044 // break; 1051 // break;
1045 // case Key_P: //play 1052 // case Key_P: //play
1046 // qDebug("Play"); 1053 // qDebug("Play");
1047 // playSelected(); 1054 // playSelected();
1048 // break; 1055 // break;
1049 // case Key_Space: 1056 // case Key_Space:
1050 // qDebug("Play"); 1057 // qDebug("Play");
1051 // playSelected(); 1058 // playSelected();
1052 // break; 1059 // break;
1053 // } 1060 // }
1054} 1061}
1055 1062
1056 1063
1057 1064
1058void PlayListWidget::readm3u(const QString &filename) { 1065void PlayListWidget::readm3u(const QString &filename) {
1059 1066
1060 qDebug("m3u filename is "+filename); 1067 qDebug("m3u filename is "+filename);
1061 QFile f(filename); 1068 QFile f(filename);
1062 1069
1063 if(f.open(IO_ReadOnly)) { 1070 if(f.open(IO_ReadOnly)) {
1064 QTextStream t(&f); 1071 QTextStream t(&f);
1065 QString s;//, first, second; 1072 QString s;//, first, second;
1066 int i=0; 1073 int i=0;
1067 while ( !t.atEnd()) { 1074 while ( !t.atEnd()) {
1068 s=t.readLine(); 1075 s=t.readLine();
1069 1076
1070 if(s.find("#",0,TRUE) == -1) { 1077 if(s.find("#",0,TRUE) == -1) {
1071 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1078 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1072 if(s.left(2) == "E:" || s.left(2) == "P:") { 1079 if(s.left(2) == "E:" || s.left(2) == "P:") {
1073 s=s.right(s.length()-2); 1080 s=s.right(s.length()-2);
1074 // if(QFile(s).exists()) { 1081 // if(QFile(s).exists()) {
1075 DocLnk lnk( s ); 1082 DocLnk lnk( s );
1076 QFileInfo f(s); 1083 QFileInfo f(s);
1077 QString name = f.baseName(); 1084 QString name = f.baseName();
1078 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); 1085 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 );
1079 lnk.setName( name ); 1086 lnk.setName( name );
1080 s=s.replace( QRegExp("\\"),"/"); 1087 s=s.replace( QRegExp("\\"),"/");
1081 lnk.setFile( s ); 1088 lnk.setFile( s );
1082 lnk.writeLink(); 1089 lnk.writeLink();
1083 qDebug("add "+name); 1090 qDebug("add "+name);
1084 d->selectedFiles->addToSelection( lnk); 1091 d->selectedFiles->addToSelection( lnk);
1085 // } 1092 // }
1086 } else { // is url 1093 } else { // is url
1087 s.replace(QRegExp("%20")," "); 1094 s.replace(QRegExp("%20")," ");
1088 DocLnk lnk( s ); 1095 DocLnk lnk( s );
1089 QString name; 1096 QString name;
1090 if(name.left(4)=="http") { 1097 if(name.left(4)=="http") {
1091 name = s.right( s.length() - 7); 1098 name = s.right( s.length() - 7);
1092 } else { 1099 } else {
1093 name = s; 1100 name = s;
1094 } 1101 }
1095 lnk.setName(name); 1102 lnk.setName(name);
1096 if(s.at(s.length()-4) == '.') { 1103 if(s.at(s.length()-4) == '.') {
1097 lnk.setFile( s); 1104 lnk.setFile( s);
1098 } else { 1105 } else {
1099 lnk.setFile( s+"/"); 1106 lnk.setFile( s+"/");
1100 } 1107 }
1101 lnk.setType("audio/x-mpegurl"); 1108 lnk.setType("audio/x-mpegurl");
1102 lnk.writeLink(); 1109 lnk.writeLink();
1103 d->selectedFiles->addToSelection( lnk); 1110 d->selectedFiles->addToSelection( lnk);
1104 } 1111 }
1105 i++; 1112 i++;
1106 } 1113 }
1107 } 1114 }
1108 } 1115 }
1109 } 1116 }
1110 f.close(); 1117 f.close();
1111} 1118}
1112 1119
1113void PlayListWidget::writem3u() { 1120void PlayListWidget::writem3u() {
1114 1121
1115 InputDialog *fileDlg; 1122 InputDialog *fileDlg;
1116 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); 1123 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1117 fileDlg->exec(); 1124 fileDlg->exec();
1118 QString filename,list; 1125 QString filename,list;
1119 if( fileDlg->result() == 1 ) { 1126 if( fileDlg->result() == 1 ) {
1120 filename = fileDlg->text(); 1127 filename = fileDlg->text();
1121 qDebug(filename); 1128 qDebug(filename);
1122 int noOfFiles = 0; 1129 int noOfFiles = 0;
1123 d->selectedFiles->first(); 1130 d->selectedFiles->first();
1124 do { 1131 do {
1125 // we dont check for existance because of url's 1132 // we dont check for existance because of url's
1126 // qDebug(d->selectedFiles->current()->file()); 1133 // qDebug(d->selectedFiles->current()->file());
1127 list += d->selectedFiles->current()->file()+"\n"; 1134 list += d->selectedFiles->current()->file()+"\n";
1128 noOfFiles++; 1135 noOfFiles++;
1129 } 1136 }
1130 while ( d->selectedFiles->next() ); 1137 while ( d->selectedFiles->next() );
1131 qDebug(list); 1138 qDebug(list);
1132 if(filename.left(1) != "/") 1139 if(filename.left(1) != "/")
1133 filename=QPEApplication::documentDir()+"/"+filename; 1140 filename=QPEApplication::documentDir()+"/"+filename;
1134 if(filename.right(3) != "m3u") 1141 if(filename.right(3) != "m3u")
1135 filename=filename+".m3u"; 1142 filename=filename+".m3u";
1136 1143
1137 QFile f(filename); 1144 QFile f(filename);
1138 f.open(IO_WriteOnly); 1145 f.open(IO_WriteOnly);
1139 f.writeBlock(list, list.length()); 1146 f.writeBlock(list, list.length());
1140 f.close(); 1147 f.close();
1141 } 1148 }
1142 if(fileDlg) delete fileDlg; 1149 if(fileDlg) delete fileDlg;
1143} 1150}
1144 1151
1145void PlayListWidget::readPls(const QString &filename) { 1152void PlayListWidget::readPls(const QString &filename) {
1146 1153
1147 qDebug("pls filename is "+filename); 1154 qDebug("pls filename is "+filename);
1148 QFile f(filename); 1155 QFile f(filename);
1149 1156
1150 if(f.open(IO_ReadOnly)) { 1157 if(f.open(IO_ReadOnly)) {
1151 QTextStream t(&f); 1158 QTextStream t(&f);
1152 QString s;//, first, second; 1159 QString s;//, first, second;
1153 int i=0; 1160 int i=0;
1154 while ( !t.atEnd()) { 1161 while ( !t.atEnd()) {
1155 s=t.readLine(); 1162 s=t.readLine();
1156 if(s.left(4) == "File") { 1163 if(s.left(4) == "File") {
1157 s=s.right(s.length() - 6); 1164 s=s.right(s.length() - 6);
1158 s.replace(QRegExp("%20")," "); 1165 s.replace(QRegExp("%20")," ");
1159 qDebug("adding "+s+" to playlist"); 1166 qDebug("adding "+s+" to playlist");
1160 // numberofentries=2 1167 // numberofentries=2
1161 // File1=http 1168 // File1=http
1162 // Title 1169 // Title
1163 // Length 1170 // Length
1164 // Version 1171 // Version
1165 // File2=http 1172 // File2=http
1166 s=s.replace( QRegExp("\\"),"/"); 1173 s=s.replace( QRegExp("\\"),"/");
1167 DocLnk lnk( s ); 1174 DocLnk lnk( s );
1168 QFileInfo f(s); 1175 QFileInfo f(s);
1169 QString name = f.baseName(); 1176 QString name = f.baseName();
1170 if(name.left(4)=="http") 1177 if(name.left(4)=="http")
1171 name = s.right( s.length() - 7); 1178 name = s.right( s.length() - 7);
1172 else 1179 else
1173 name=s; 1180 name=s;
1174 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1181 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1175 lnk.setName( name); 1182 lnk.setName( name);
1176 if(s.at(s.length()-4) == '.') // if this is probably a file 1183 if(s.at(s.length()-4) == '.') // if this is probably a file
1177 lnk.setFile( s); 1184 lnk.setFile( s);
1178 else { //if its a url 1185 else { //if its a url
1179 if( name.right(1).find('/') == -1) 1186 if( name.right(1).find('/') == -1)
1180 s+="/"; 1187 s+="/";
1181 lnk.setFile( s); 1188 lnk.setFile( s);
1182 } 1189 }
1183 lnk.setType("audio/x-mpegurl"); 1190 lnk.setType("audio/x-mpegurl");
1184 1191
1185 qDebug("DocLnk add "+name); 1192 qDebug("DocLnk add "+name);
1186 d->selectedFiles->addToSelection( lnk); 1193 d->selectedFiles->addToSelection( lnk);
1187 } 1194 }
1188 } 1195 }
1189 i++; 1196 i++;
1190 } 1197 }
1191} 1198}
1192 1199
1193void PlayListWidget::pmViewActivated(int index) { 1200void PlayListWidget::pmViewActivated(int index) {
1194// qDebug("%d", index); 1201// qDebug("%d", index);
1195 switch(index) { 1202 switch(index) {
1196 case -16: 1203 case -16:
1197 { 1204 {
1198 1205
1199 mediaPlayerState->toggleFullscreen(); 1206 mediaPlayerState->toggleFullscreen();
1200 bool b=mediaPlayerState->fullscreen(); 1207 bool b=mediaPlayerState->fullscreen();
1201 pmView->setItemChecked( index,b); 1208 pmView->setItemChecked( index,b);
1202 Config cfg( "OpiePlayer" ); 1209 Config cfg( "OpiePlayer" );
1203 cfg.writeEntry("FullScreen", b); 1210 cfg.writeEntry("FullScreen", b);
1204 1211
1205 } 1212 }
1206 break; 1213 break;
1207 }; 1214 };
1208} 1215}
1209 1216
1210void PlayListWidget::populateSkinsMenu() { 1217void PlayListWidget::populateSkinsMenu() {
1211 int item=0; 1218 int item=0;
1212 defaultSkinIndex=0; 1219 defaultSkinIndex=0;
1213 QString skinName; 1220 QString skinName;
1214 Config cfg( "OpiePlayer" ); 1221 Config cfg( "OpiePlayer" );
1215 cfg.setGroup("Options"); 1222 cfg.setGroup("Options");
1216 QString skin = cfg.readEntry("Skin","default"); 1223 QString skin = cfg.readEntry("Skin","default");
1217 1224
1218 QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); 1225 QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins");
1219 skinsDir.setFilter( QDir::Dirs); 1226 skinsDir.setFilter( QDir::Dirs);
1220 skinsDir.setSorting(QDir::Name); 1227 skinsDir.setSorting(QDir::Name);
1221 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1228 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1222 QFileInfoListIterator it( *skinslist ); 1229 QFileInfoListIterator it( *skinslist );
1223 QFileInfo *fi; 1230 QFileInfo *fi;
1224 while ( (fi=it.current()) ) { 1231 while ( (fi=it.current()) ) {
1225 skinName = fi->fileName(); 1232 skinName = fi->fileName();
1226 qDebug( fi->fileName()); 1233 qDebug( fi->fileName());
1227 if( skinName != "." && skinName != ".." && skinName !="CVS") 1234 if( skinName != "." && skinName != ".." && skinName !="CVS")
1228 item = skinsMenu->insertItem( fi->fileName()); 1235 item = skinsMenu->insertItem( fi->fileName());
1229 if( skinName == "default") 1236 if( skinName == "default")
1230 defaultSkinIndex = item; 1237 defaultSkinIndex = item;
1231 if( skinName == skin) 1238 if( skinName == skin)
1232 skinsMenu->setItemChecked( item, TRUE); 1239 skinsMenu->setItemChecked( item, TRUE);
1233 1240
1234 ++it; 1241 ++it;
1235 } 1242 }
1236} 1243}
1237 1244
1238void PlayListWidget::skinsMenuActivated(int item) { 1245void PlayListWidget::skinsMenuActivated(int item) {
1239 for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { 1246 for(uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) {
1240 skinsMenu->setItemChecked( i, FALSE); 1247 skinsMenu->setItemChecked( i, FALSE);
1241 } 1248 }
1242 skinsMenu->setItemChecked( item, TRUE); 1249 skinsMenu->setItemChecked( item, TRUE);
1243 1250
1244 Config cfg( "OpiePlayer" ); 1251 Config cfg( "OpiePlayer" );
1245 cfg.setGroup("Options"); 1252 cfg.setGroup("Options");
1246 cfg.writeEntry("Skin", skinsMenu->text( item)); 1253 cfg.writeEntry("Skin", skinsMenu->text( item));
1247} 1254}
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 53837c7..ffda2e4 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,497 +1,497 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/mediaplayerplugininterface.h> 36#include <qpe/mediaplayerplugininterface.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38 38
39 39
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qpixmap.h> 42#include <qpixmap.h>
43#include <qslider.h> 43#include <qslider.h>
44#include <qdrawutil.h> 44#include <qdrawutil.h>
45#include "videowidget.h" 45#include "videowidget.h"
46#include "mediaplayerstate.h" 46#include "mediaplayerstate.h"
47 47
48 48
49#ifdef Q_WS_QWS 49#ifdef Q_WS_QWS
50# define USE_DIRECT_PAINTER 50# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 51# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 52# include <qgfxraster_qws.h>
53#endif 53#endif
54 54
55 55
56extern MediaPlayerState *mediaPlayerState; 56extern MediaPlayerState *mediaPlayerState;
57 57
58 58
59static const int xo = 2; // movable x offset 59static const int xo = 2; // movable x offset
60static const int yo = 0; // movable y offset 60static const int yo = 0; // movable y offset
61 61
62 62
63struct MediaButton { 63struct MediaButton {
64 bool isToggle, isHeld, isDown; 64 bool isToggle, isHeld, isDown;
65}; 65};
66 66
67MediaButton videoButtons[] = { 67MediaButton videoButtons[] = {
68 { FALSE, FALSE, FALSE }, // stop 68 { FALSE, FALSE, FALSE }, // stop
69 { TRUE, FALSE, FALSE }, // play 69 { TRUE, FALSE, FALSE }, // play
70 { FALSE, FALSE, FALSE }, // previous 70 { FALSE, FALSE, FALSE }, // previous
71 { FALSE, FALSE, FALSE }, // next 71 { FALSE, FALSE, FALSE }, // next
72 { FALSE, FALSE, FALSE }, // volUp 72 { FALSE, FALSE, FALSE }, // volUp
73 { FALSE, FALSE, FALSE }, // volDown 73 { FALSE, FALSE, FALSE }, // volDown
74 { TRUE, FALSE, FALSE } // fullscreen 74 { TRUE, FALSE, FALSE } // fullscreen
75}; 75};
76 76
77const char *skinV_mask_file_names[7] = { 77const char *skinV_mask_file_names[7] = {
78"stop","play","back","fwd","up","down","full" 78"stop","play","back","fwd","up","down","full"
79}; 79};
80 80
81static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 81static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
82 82
83 83
84VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 84VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
85QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 85QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
86 86
87 87
88 setCaption( tr("OpiePlayer - Video") ); 88 setCaption( tr("OpiePlayer - Video") );
89 89
90 videoFrame = new XineVideoWidget ( this, "Video frame" ); 90 videoFrame = new XineVideoWidget ( this, "Video frame" );
91 91
92 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 92 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
93 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 93 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
94 94
95 Config cfg("OpiePlayer"); 95 Config cfg("OpiePlayer");
96 cfg.setGroup("Options"); 96 cfg.setGroup("Options");
97 skin = cfg.readEntry("Skin","default"); 97 skin = cfg.readEntry("Skin","default");
98 98
99 QString skinPath = "opieplayer2/skins/" + skin; 99 QString skinPath = "opieplayer2/skins/" + skin;
100 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 100 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
101 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 101 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
102 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 102 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
103 103
104 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 104 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
105 imgButtonMask->fill( 0 ); 105 imgButtonMask->fill( 0 );
106 106
107 for ( int i = 0; i < 7; i++ ) { 107 for ( int i = 0; i < 7; i++ ) {
108 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 108 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
109 masks[i] = new QBitmap( filename ); 109 masks[i] = new QBitmap( filename );
110 110
111 if ( !masks[i]->isNull() ) { 111 if ( !masks[i]->isNull() ) {
112 QImage imgMask = masks[i]->convertToImage(); 112 QImage imgMask = masks[i]->convertToImage();
113 uchar **dest = imgButtonMask->jumpTable(); 113 uchar **dest = imgButtonMask->jumpTable();
114 for ( int y = 0; y < imgUp->height(); y++ ) { 114 for ( int y = 0; y < imgUp->height(); y++ ) {
115 uchar *line = dest[y]; 115 uchar *line = dest[y];
116 for ( int x = 0; x < imgUp->width(); x++ ) { 116 for ( int x = 0; x < imgUp->width(); x++ ) {
117 if ( !qRed( imgMask.pixel( x, y ) ) ) 117 if ( !qRed( imgMask.pixel( x, y ) ) )
118 line[x] = i + 1; 118 line[x] = i + 1;
119 } 119 }
120 } 120 }
121 } 121 }
122 } 122 }
123 123
124 for ( int i = 0; i < 7; i++ ) { 124 for ( int i = 0; i < 7; i++ ) {
125 buttonPixUp[i] = NULL; 125 buttonPixUp[i] = NULL;
126 buttonPixDown[i] = NULL; 126 buttonPixDown[i] = NULL;
127 } 127 }
128 128
129 setBackgroundPixmap( *pixBg ); 129 setBackgroundPixmap( *pixBg );
130 130
131 slider = new QSlider( Qt::Horizontal, this ); 131 slider = new QSlider( Qt::Horizontal, this );
132 slider->setMinValue( 0 ); 132 slider->setMinValue( 0 );
133 slider->setMaxValue( 1 ); 133 slider->setMaxValue( 1 );
134 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 134 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
135 slider->setFocusPolicy( QWidget::NoFocus ); 135 slider->setFocusPolicy( QWidget::NoFocus );
136 136
137 resizeEvent( NULL ); 137 resizeEvent( NULL );
138 138
139 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 139 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
140 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 140 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
141 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 141 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
142 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 142 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
143 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 143 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
144 144
145 setLength( mediaPlayerState->length() ); 145 setLength( mediaPlayerState->length() );
146 setPosition( mediaPlayerState->position() ); 146 setPosition( mediaPlayerState->position() );
147 setFullscreen( mediaPlayerState->fullscreen() ); 147 setFullscreen( mediaPlayerState->fullscreen() );
148 setPlaying( mediaPlayerState->playing() ); 148 setPlaying( mediaPlayerState->playing() );
149} 149}
150 150
151 151
152VideoWidget::~VideoWidget() { 152VideoWidget::~VideoWidget() {
153 153
154 for ( int i = 0; i < 7; i++ ) { 154 for ( int i = 0; i < 7; i++ ) {
155 delete buttonPixUp[i]; 155 delete buttonPixUp[i];
156 delete buttonPixDown[i]; 156 delete buttonPixDown[i];
157 } 157 }
158 158
159 delete pixBg; 159 delete pixBg;
160 delete imgUp; 160 delete imgUp;
161 delete imgDn; 161 delete imgDn;
162 delete imgButtonMask; 162 delete imgButtonMask;
163 for ( int i = 0; i < 7; i++ ) { 163 for ( int i = 0; i < 7; i++ ) {
164 delete masks[i]; 164 delete masks[i];
165 } 165 }
166 166
167} 167}
168 168
169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
170 QPixmap pix( img.width(), img.height() ); 170 QPixmap pix( img.width(), img.height() );
171 QPainter p( &pix ); 171 QPainter p( &pix );
172 p.drawTiledPixmap( pix.rect(), bg, offset ); 172 p.drawTiledPixmap( pix.rect(), bg, offset );
173 p.drawImage( 0, 0, img ); 173 p.drawImage( 0, 0, img );
174 return new QPixmap( pix ); 174 return new QPixmap( pix );
175} 175}
176 176
177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
178 QPixmap *pixmap = new QPixmap( pix ); 178 QPixmap *pixmap = new QPixmap( pix );
179 pixmap->setMask( mask ); 179 pixmap->setMask( mask );
180 return pixmap; 180 return pixmap;
181} 181}
182 182
183void VideoWidget::resizeEvent( QResizeEvent * ) { 183void VideoWidget::resizeEvent( QResizeEvent * ) {
184 int h = height(); 184 int h = height();
185 int w = width(); 185 int w = width();
186 //int Vh = 160; 186 //int Vh = 160;
187 //int Vw = 220; 187 //int Vw = 220;
188 188
189 slider->setFixedWidth( w - 20 ); 189 slider->setFixedWidth( w - 20 );
190 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 190 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
191 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 191 slider->setBackgroundOrigin( QWidget::ParentOrigin );
192 slider->setFocusPolicy( QWidget::NoFocus ); 192 slider->setFocusPolicy( QWidget::NoFocus );
193 slider->setBackgroundPixmap( *pixBg ); 193 slider->setBackgroundPixmap( *pixBg );
194 194
195 xoff = 0;// ( imgUp->width() ) / 2; 195 xoff = 0;// ( imgUp->width() ) / 2;
196 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 196 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
197 QPoint p( xoff, yoff ); 197 QPoint p( xoff, yoff );
198 198
199 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 199 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
200 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 200 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
201 201
202 for ( int i = 0; i < 7; i++ ) { 202 for ( int i = 0; i < 7; i++ ) {
203 if ( !masks[i]->isNull() ) { 203 if ( !masks[i]->isNull() ) {
204 delete buttonPixUp[i]; 204 delete buttonPixUp[i];
205 delete buttonPixDown[i]; 205 delete buttonPixDown[i];
206 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 206 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
207 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 207 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
208 } 208 }
209 } 209 }
210 210
211 delete pixUp; 211 delete pixUp;
212 delete pixDn; 212 delete pixDn;
213} 213}
214 214
215static bool videoSliderBeingMoved = FALSE; 215static bool videoSliderBeingMoved = FALSE;
216 216
217void VideoWidget::sliderPressed() { 217void VideoWidget::sliderPressed() {
218 videoSliderBeingMoved = TRUE; 218 videoSliderBeingMoved = TRUE;
219} 219}
220 220
221void VideoWidget::sliderReleased() { 221void VideoWidget::sliderReleased() {
222 videoSliderBeingMoved = FALSE; 222 videoSliderBeingMoved = FALSE;
223 if ( slider->width() == 0 ) { 223 if ( slider->width() == 0 ) {
224 return; 224 return;
225 } 225 }
226 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 226 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
227 mediaPlayerState->setPosition( val ); 227 mediaPlayerState->setPosition( val );
228} 228}
229 229
230void VideoWidget::setPosition( long i ) { 230void VideoWidget::setPosition( long i ) {
231 updateSlider( i, mediaPlayerState->length() ); 231 updateSlider( i, mediaPlayerState->length() );
232} 232}
233 233
234 234
235void VideoWidget::setLength( long max ) { 235void VideoWidget::setLength( long max ) {
236 updateSlider( mediaPlayerState->position(), max ); 236 updateSlider( mediaPlayerState->position(), max );
237} 237}
238 238
239void VideoWidget::setView( char view ) { 239void VideoWidget::setView( char view ) {
240 240
241 if ( view == 'v' ) { 241 if ( view == 'v' ) {
242 makeVisible(); 242 makeVisible();
243 } else { 243 } else {
244 // Effectively blank the view next time we show it so it looks nicer 244 // Effectively blank the view next time we show it so it looks nicer
245 scaledWidth = 0; 245 scaledWidth = 0;
246 scaledHeight = 0; 246 scaledHeight = 0;
247 hide(); 247 hide();
248 } 248 }
249} 249}
250 250
251void VideoWidget::updateSlider( long i, long max ) { 251void VideoWidget::updateSlider( long i, long max ) {
252 // Will flicker too much if we don't do this 252 // Will flicker too much if we don't do this
253 if ( max == 0 ) { 253 if ( max == 0 ) {
254 return; 254 return;
255 } 255 }
256 int width = slider->width(); 256 int width = slider->width();
257 int val = int((double)i * width / max); 257 int val = int((double)i * width / max);
258 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 258 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
259 if ( slider->value() != val ) { 259 if ( slider->value() != val ) {
260 slider->setValue( val ); 260 slider->setValue( val );
261 } 261 }
262 if ( slider->maxValue() != width ) { 262 if ( slider->maxValue() != width ) {
263 slider->setMaxValue( width ); 263 slider->setMaxValue( width );
264 } 264 }
265 } 265 }
266} 266}
267 267
268void VideoWidget::setToggleButton( int i, bool down ) { 268void VideoWidget::setToggleButton( int i, bool down ) {
269 if ( down != videoButtons[i].isDown ) { 269 if ( down != videoButtons[i].isDown ) {
270 toggleButton( i ); 270 toggleButton( i );
271 } 271 }
272} 272}
273 273
274void VideoWidget::toggleButton( int i ) { 274void VideoWidget::toggleButton( int i ) {
275 videoButtons[i].isDown = !videoButtons[i].isDown; 275 videoButtons[i].isDown = !videoButtons[i].isDown;
276 QPainter p(this); 276 QPainter p(this);
277 paintButton ( &p, i ); 277 paintButton ( &p, i );
278} 278}
279 279
280void VideoWidget::paintButton( QPainter *p, int i ) { 280void VideoWidget::paintButton( QPainter *p, int i ) {
281 281
282 if ( videoButtons[i].isDown ) { 282 if ( videoButtons[i].isDown ) {
283 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 283 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
284 } else { 284 } else {
285 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 285 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
286 } 286 }
287} 287}
288 288
289void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 289void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
290 for ( int i = 0; i < numVButtons; i++ ) { 290 for ( int i = 0; i < numVButtons; i++ ) {
291 if ( event->state() == QMouseEvent::LeftButton ) { 291 if ( event->state() == QMouseEvent::LeftButton ) {
292 // The test to see if the mouse click is inside the button or not 292 // The test to see if the mouse click is inside the button or not
293 int x = event->pos().x() - xoff; 293 int x = event->pos().x() - xoff;
294 int y = event->pos().y() - yoff; 294 int y = event->pos().y() - yoff;
295 295
296 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 296 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
297 && y < imgButtonMask->height() 297 && y < imgButtonMask->height()
298 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 298 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
299 299
300 if ( isOnButton && !videoButtons[i].isHeld ) { 300 if ( isOnButton && !videoButtons[i].isHeld ) {
301 videoButtons[i].isHeld = TRUE; 301 videoButtons[i].isHeld = TRUE;
302 toggleButton(i); 302 toggleButton(i);
303 303
304 switch (i) { 304 switch (i) {
305 case VideoVolUp: 305 case VideoVolUp:
306 emit moreClicked(); 306 emit moreClicked();
307 return; 307 return;
308 case VideoVolDown: 308 case VideoVolDown:
309 emit lessClicked(); 309 emit lessClicked();
310 return; 310 return;
311 } 311 }
312 } else if ( !isOnButton && videoButtons[i].isHeld ) { 312 } else if ( !isOnButton && videoButtons[i].isHeld ) {
313 videoButtons[i].isHeld = FALSE; 313 videoButtons[i].isHeld = FALSE;
314 toggleButton(i); 314 toggleButton(i);
315 } 315 }
316 } else { 316 } else {
317 317
318 if ( videoButtons[i].isHeld ) { 318 if ( videoButtons[i].isHeld ) {
319 videoButtons[i].isHeld = FALSE; 319 videoButtons[i].isHeld = FALSE;
320 if ( !videoButtons[i].isToggle ) { 320 if ( !videoButtons[i].isToggle ) {
321 setToggleButton( i, FALSE ); 321 setToggleButton( i, FALSE );
322 } 322 }
323 323
324 switch(i) { 324 switch(i) {
325 325
326 case VideoPlay: { 326 case VideoPlay: {
327 if( mediaPlayerState->isPaused ) { 327 if( mediaPlayerState->isPaused ) {
328 setToggleButton( i, FALSE ); 328 setToggleButton( i, FALSE );
329 mediaPlayerState->setPaused( FALSE ); 329 mediaPlayerState->setPaused( FALSE );
330 return; 330 return;
331 } else if( !mediaPlayerState->isPaused ) { 331 } else if( !mediaPlayerState->isPaused ) {
332 setToggleButton( i, TRUE ); 332 setToggleButton( i, TRUE );
333 mediaPlayerState->setPaused( TRUE ); 333 mediaPlayerState->setPaused( TRUE );
334 return; 334 return;
335 } else { 335 } else {
336 return; 336 return;
337 } 337 }
338 } 338 }
339 339
340 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 340 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
341 case VideoNext: mediaPlayerState->setNext(); return; 341 case VideoNext: mediaPlayerState->setNext(); return;
342 case VideoPrevious: mediaPlayerState->setPrev(); return; 342 case VideoPrevious: mediaPlayerState->setPrev(); return;
343 case VideoVolUp: emit moreReleased(); return; 343 case VideoVolUp: emit moreReleased(); return;
344 case VideoVolDown: emit lessReleased(); return; 344 case VideoVolDown: emit lessReleased(); return;
345 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 345 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
346 } 346 }
347 } 347 }
348 } 348 }
349 } 349 }
350} 350}
351 351
352void VideoWidget::mousePressEvent( QMouseEvent *event ) { 352void VideoWidget::mousePressEvent( QMouseEvent *event ) {
353 mouseMoveEvent( event ); 353 mouseMoveEvent( event );
354} 354}
355 355
356void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 356void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
357 if ( mediaPlayerState->fullscreen() ) { 357 if ( mediaPlayerState->fullscreen() ) {
358 mediaPlayerState->setFullscreen( FALSE ); 358 mediaPlayerState->setFullscreen( FALSE );
359 makeVisible(); 359 makeVisible();
360 } 360 }
361 mouseMoveEvent( event ); 361 mouseMoveEvent( event );
362} 362}
363 363
364void VideoWidget::showEvent( QShowEvent* ) { 364void VideoWidget::showEvent( QShowEvent* ) {
365 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 365 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
366 mouseMoveEvent( &event ); 366 mouseMoveEvent( &event );
367} 367}
368 368
369 369
370 void VideoWidget::backToNormal() { 370 void VideoWidget::backToNormal() {
371 mediaPlayerState->setFullscreen( FALSE ); 371 mediaPlayerState->setFullscreen( FALSE );
372 makeVisible(); 372 makeVisible();
373 } 373 }
374 374
375void VideoWidget::makeVisible() { 375void VideoWidget::makeVisible() {
376 if ( mediaPlayerState->fullscreen() ) { 376 if ( mediaPlayerState->fullscreen() ) {
377 setBackgroundMode( QWidget::NoBackground ); 377 setBackgroundMode( QWidget::NoBackground );
378 showFullScreen(); 378 showFullScreen();
379 resize( qApp->desktop()->size() ); 379 resize( qApp->desktop()->size() );
380 slider->hide(); 380 slider->hide();
381 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 381 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
382 382 qApp->processEvents();
383 } else { 383 } else {
384 showNormal(); 384 showNormal();
385 showMaximized(); 385 showMaximized();
386 setBackgroundPixmap( *pixBg ); 386 setBackgroundPixmap( *pixBg );
387 if ( mediaPlayerState->streaming() ) { 387 if ( mediaPlayerState->streaming() ) {
388 slider->hide(); 388 slider->hide();
389 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 389 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
390 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 390 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
391 } else { 391 } else {
392 slider->show(); 392 slider->show();
393 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 393 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
394 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 394 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
395 } 395 }
396 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 396 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
397 qApp->processEvents(); 397 qApp->processEvents();
398 } 398 }
399} 399}
400 400
401 401
402void VideoWidget::paintEvent( QPaintEvent * pe) { 402void VideoWidget::paintEvent( QPaintEvent * pe) {
403 QPainter p( this ); 403 QPainter p( this );
404 404
405 if ( mediaPlayerState->fullscreen() ) { 405 if ( mediaPlayerState->fullscreen() ) {
406 // Clear the background 406 // Clear the background
407 p.setBrush( QBrush( Qt::black ) ); 407 p.setBrush( QBrush( Qt::black ) );
408 } else { 408 } else {
409 if ( !pe->erased() ) { 409 if ( !pe->erased() ) {
410 // Combine with background and double buffer 410 // Combine with background and double buffer
411 QPixmap pix( pe->rect().size() ); 411 QPixmap pix( pe->rect().size() );
412 QPainter p( &pix ); 412 QPainter p( &pix );
413 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 413 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
414 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 414 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
415 for ( int i = 0; i < numVButtons; i++ ) { 415 for ( int i = 0; i < numVButtons; i++ ) {
416 paintButton( &p, i ); 416 paintButton( &p, i );
417 } 417 }
418 QPainter p2( this ); 418 QPainter p2( this );
419 p2.drawPixmap( pe->rect().topLeft(), pix ); 419 p2.drawPixmap( pe->rect().topLeft(), pix );
420 } else { 420 } else {
421 QPainter p( this ); 421 QPainter p( this );
422 for ( int i = 0; i < numVButtons; i++ ) 422 for ( int i = 0; i < numVButtons; i++ )
423 paintButton( &p, i ); 423 paintButton( &p, i );
424 } 424 }
425 slider->repaint( TRUE ); 425 slider->repaint( TRUE );
426 } 426 }
427} 427}
428 428
429 429
430void VideoWidget::closeEvent( QCloseEvent* ) { 430void VideoWidget::closeEvent( QCloseEvent* ) {
431 mediaPlayerState->setList(); 431 mediaPlayerState->setList();
432} 432}
433 433
434 434
435 435
436void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 436void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
437 switch ( e->key() ) { 437 switch ( e->key() ) {
438////////////////////////////// Zaurus keys 438////////////////////////////// Zaurus keys
439 case Key_Home: 439 case Key_Home:
440 break; 440 break;
441 case Key_F9: //activity 441 case Key_F9: //activity
442 break; 442 break;
443 case Key_F10: //contacts 443 case Key_F10: //contacts
444// hide(); 444// hide();
445 break; 445 break;
446 case Key_F11: //menu 446 case Key_F11: //menu
447 break; 447 break;
448 case Key_F12: //home 448 case Key_F12: //home
449 break; 449 break;
450 case Key_F13: //mail 450 case Key_F13: //mail
451 break; 451 break;
452 case Key_Space: { 452 case Key_Space: {
453 if(mediaPlayerState->playing()) { 453 if(mediaPlayerState->playing()) {
454 mediaPlayerState->setPlaying(FALSE); 454 mediaPlayerState->setPlaying(FALSE);
455 } else { 455 } else {
456 mediaPlayerState->setPlaying(TRUE); 456 mediaPlayerState->setPlaying(TRUE);
457 } 457 }
458 } 458 }
459 break; 459 break;
460 case Key_Down: 460 case Key_Down:
461// toggleButton(6); 461// toggleButton(6);
462 emit lessClicked(); 462 emit lessClicked();
463 emit lessReleased(); 463 emit lessReleased();
464// toggleButton(6); 464// toggleButton(6);
465 break; 465 break;
466 case Key_Up: 466 case Key_Up:
467// toggleButton(5); 467// toggleButton(5);
468 emit moreClicked(); 468 emit moreClicked();
469 emit moreReleased(); 469 emit moreReleased();
470// toggleButton(5); 470// toggleButton(5);
471 break; 471 break;
472 case Key_Right: 472 case Key_Right:
473 mediaPlayerState->setNext(); 473 mediaPlayerState->setNext();
474 break; 474 break;
475 case Key_Left: 475 case Key_Left:
476 mediaPlayerState->setPrev(); 476 mediaPlayerState->setPrev();
477 break; 477 break;
478 case Key_Escape: 478 case Key_Escape:
479 break; 479 break;
480 480
481 }; 481 };
482} 482}
483 483
484XineVideoWidget* VideoWidget::vidWidget() { 484XineVideoWidget* VideoWidget::vidWidget() {
485 return videoFrame; 485 return videoFrame;
486} 486}
487 487
488 488
489void VideoWidget::setFullscreen ( bool b ) { 489void VideoWidget::setFullscreen ( bool b ) {
490 setToggleButton( VideoFullscreen, b ); 490 setToggleButton( VideoFullscreen, b );
491} 491}
492 492
493 493
494void VideoWidget::setPlaying( bool b) { 494void VideoWidget::setPlaying( bool b) {
495 setToggleButton( VideoPlay, b ); 495 setToggleButton( VideoPlay, b );
496} 496}
497 497