summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-20 18:53:33 (UTC)
committer llornkcor <llornkcor>2002-04-20 18:53:33 (UTC)
commitb8bdd6ceaab890f8b35492a11e13bcdb101b1220 (patch) (unidiff)
tree1ba128f600c5b0e5f2b0dce459b77270287e59ca
parent703c9c483b5e3fa6d2090398d6ee3a5638326b02 (diff)
downloadopie-b8bdd6ceaab890f8b35492a11e13bcdb101b1220.zip
opie-b8bdd6ceaab890f8b35492a11e13bcdb101b1220.tar.gz
opie-b8bdd6ceaab890f8b35492a11e13bcdb101b1220.tar.bz2
changed MediaPlayer to OpiePlayer in config stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp4
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp12
2 files changed, 8 insertions, 8 deletions
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp
index a960c49..4e14436 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.cpp
+++ b/core/multimedia/opieplayer/mediaplayerstate.cpp
@@ -1,191 +1,191 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qlibrary.h> 21#include <qpe/qlibrary.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qvaluelist.h> 23#include <qvaluelist.h>
24#include <qobject.h> 24#include <qobject.h>
25#include <qdir.h> 25#include <qdir.h>
26#include <qpe/mediaplayerplugininterface.h> 26#include <qpe/mediaplayerplugininterface.h>
27#include "mediaplayerstate.h" 27#include "mediaplayerstate.h"
28 28
29 29
30 30
31#ifdef QT_NO_COMPONENT 31#ifdef QT_NO_COMPONENT
32// Plugins which are compiled in when no plugin architecture available 32// Plugins which are compiled in when no plugin architecture available
33#include "libmad/libmadpluginimpl.h" 33#include "libmad/libmadpluginimpl.h"
34#include "libmpeg3/libmpeg3pluginimpl.h" 34#include "libmpeg3/libmpeg3pluginimpl.h"
35#include "wavplugin/wavpluginimpl.h" 35#include "wavplugin/wavpluginimpl.h"
36#endif 36#endif
37 37
38 38
39//#define MediaPlayerDebug(x) qDebug x 39//#define MediaPlayerDebug(x) qDebug x
40#define MediaPlayerDebug(x) 40#define MediaPlayerDebug(x)
41 41
42 42
43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
45 Config cfg( "MediaPlayer" ); 45 Config cfg( "OpiePlayer" );
46 readConfig( cfg ); 46 readConfig( cfg );
47 loadPlugins(); 47 loadPlugins();
48} 48}
49 49
50 50
51MediaPlayerState::~MediaPlayerState() { 51MediaPlayerState::~MediaPlayerState() {
52 Config cfg( "MediaPlayer" ); 52 Config cfg( "OpiePlayer" );
53 writeConfig( cfg ); 53 writeConfig( cfg );
54} 54}
55 55
56 56
57void MediaPlayerState::readConfig( Config& cfg ) { 57void MediaPlayerState::readConfig( Config& cfg ) {
58 cfg.setGroup("Options"); 58 cfg.setGroup("Options");
59 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 59 isFullscreen = cfg.readBoolEntry( "FullScreen" );
60 isScaled = cfg.readBoolEntry( "Scaling" ); 60 isScaled = cfg.readBoolEntry( "Scaling" );
61 isLooping = cfg.readBoolEntry( "Looping" ); 61 isLooping = cfg.readBoolEntry( "Looping" );
62 isShuffled = cfg.readBoolEntry( "Shuffle" ); 62 isShuffled = cfg.readBoolEntry( "Shuffle" );
63 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 63 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
64 usePlaylist = TRUE; 64 usePlaylist = TRUE;
65 isPlaying = FALSE; 65 isPlaying = FALSE;
66 isPaused = FALSE; 66 isPaused = FALSE;
67 curPosition = 0; 67 curPosition = 0;
68 curLength = 0; 68 curLength = 0;
69 curView = 'l'; 69 curView = 'l';
70} 70}
71 71
72 72
73void MediaPlayerState::writeConfig( Config& cfg ) const { 73void MediaPlayerState::writeConfig( Config& cfg ) const {
74 cfg.setGroup("Options"); 74 cfg.setGroup("Options");
75 cfg.writeEntry("FullScreen", isFullscreen ); 75 cfg.writeEntry("FullScreen", isFullscreen );
76 cfg.writeEntry("Scaling", isScaled ); 76 cfg.writeEntry("Scaling", isScaled );
77 cfg.writeEntry("Looping", isLooping ); 77 cfg.writeEntry("Looping", isLooping );
78 cfg.writeEntry("Shuffle", isShuffled ); 78 cfg.writeEntry("Shuffle", isShuffled );
79 cfg.writeEntry("UsePlayList", usePlaylist ); 79 cfg.writeEntry("UsePlayList", usePlaylist );
80} 80}
81 81
82 82
83struct MediaPlayerPlugin { 83struct MediaPlayerPlugin {
84#ifndef QT_NO_COMPONENT 84#ifndef QT_NO_COMPONENT
85 QLibrary *library; 85 QLibrary *library;
86#endif 86#endif
87 MediaPlayerPluginInterface *iface; 87 MediaPlayerPluginInterface *iface;
88 MediaPlayerDecoder *decoder; 88 MediaPlayerDecoder *decoder;
89 MediaPlayerEncoder *encoder; 89 MediaPlayerEncoder *encoder;
90}; 90};
91 91
92 92
93static QValueList<MediaPlayerPlugin> pluginList; 93static QValueList<MediaPlayerPlugin> pluginList;
94 94
95 95
96// Find the first decoder which supports this type of file 96// Find the first decoder which supports this type of file
97MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { 97MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) {
98 MediaPlayerDecoder *tmpDecoder = NULL; 98 MediaPlayerDecoder *tmpDecoder = NULL;
99 QValueList<MediaPlayerPlugin>::Iterator it; 99 QValueList<MediaPlayerPlugin>::Iterator it;
100 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 100 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
101 if ( (*it).decoder->isFileSupported( file ) ) { 101 if ( (*it).decoder->isFileSupported( file ) ) {
102 tmpDecoder = (*it).decoder; 102 tmpDecoder = (*it).decoder;
103 break; 103 break;
104 } 104 }
105 } 105 }
106 return decoder = tmpDecoder; 106 return decoder = tmpDecoder;
107} 107}
108 108
109 109
110MediaPlayerDecoder *MediaPlayerState::curDecoder() { 110MediaPlayerDecoder *MediaPlayerState::curDecoder() {
111 return decoder; 111 return decoder;
112} 112}
113 113
114 114
115// ### hack to get true sample count 115// ### hack to get true sample count
116MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { 116MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() {
117 return libmpeg3decoder; 117 return libmpeg3decoder;
118} 118}
119 119
120// ### hack to get true sample count 120// ### hack to get true sample count
121// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { 121// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() {
122// return libwavdecoder; 122// return libwavdecoder;
123// } 123// }
124 124
125void MediaPlayerState::loadPlugins() { 125void MediaPlayerState::loadPlugins() {
126 qDebug("load plugins"); 126 qDebug("load plugins");
127#ifndef QT_NO_COMPONENT 127#ifndef QT_NO_COMPONENT
128 QValueList<MediaPlayerPlugin>::Iterator mit; 128 QValueList<MediaPlayerPlugin>::Iterator mit;
129 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { 129 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) {
130 (*mit).iface->release(); 130 (*mit).iface->release();
131 (*mit).library->unload(); 131 (*mit).library->unload();
132 delete (*mit).library; 132 delete (*mit).library;
133 } 133 }
134 pluginList.clear(); 134 pluginList.clear();
135 135
136 QString path = QPEApplication::qpeDir() + "/plugins/codecs"; 136 QString path = QPEApplication::qpeDir() + "/plugins/codecs";
137 QDir dir( path, "lib*.so" ); 137 QDir dir( path, "lib*.so" );
138 QStringList list = dir.entryList(); 138 QStringList list = dir.entryList();
139 QStringList::Iterator it; 139 QStringList::Iterator it;
140 for ( it = list.begin(); it != list.end(); ++it ) { 140 for ( it = list.begin(); it != list.end(); ++it ) {
141 MediaPlayerPluginInterface *iface = 0; 141 MediaPlayerPluginInterface *iface = 0;
142 QLibrary *lib = new QLibrary( path + "/" + *it ); 142 QLibrary *lib = new QLibrary( path + "/" + *it );
143// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 143// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
144 144
145 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { 145 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) {
146 146
147// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); 147// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() );
148 148
149 MediaPlayerPlugin plugin; 149 MediaPlayerPlugin plugin;
150 plugin.library = lib; 150 plugin.library = lib;
151 plugin.iface = iface; 151 plugin.iface = iface;
152 plugin.decoder = plugin.iface->decoder(); 152 plugin.decoder = plugin.iface->decoder();
153 plugin.encoder = plugin.iface->encoder(); 153 plugin.encoder = plugin.iface->encoder();
154 pluginList.append( plugin ); 154 pluginList.append( plugin );
155 155
156 // ### hack to get true sample count 156 // ### hack to get true sample count
157 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) 157 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") )
158 libmpeg3decoder = plugin.decoder; 158 libmpeg3decoder = plugin.decoder;
159 159
160 } else { 160 } else {
161 delete lib; 161 delete lib;
162 } 162 }
163 } 163 }
164#else 164#else
165 pluginList.clear(); 165 pluginList.clear();
166 166
167 MediaPlayerPlugin plugin0; 167 MediaPlayerPlugin plugin0;
168 plugin0.iface = new LibMpeg3PluginImpl; 168 plugin0.iface = new LibMpeg3PluginImpl;
169 plugin0.decoder = plugin0.iface->decoder(); 169 plugin0.decoder = plugin0.iface->decoder();
170 plugin0.encoder = plugin0.iface->encoder(); 170 plugin0.encoder = plugin0.iface->encoder();
171 pluginList.append( plugin0 ); 171 pluginList.append( plugin0 );
172 172
173 MediaPlayerPlugin plugin1; 173 MediaPlayerPlugin plugin1;
174 plugin1.iface = new LibMadPluginImpl; 174 plugin1.iface = new LibMadPluginImpl;
175 plugin1.decoder = plugin1.iface->decoder(); 175 plugin1.decoder = plugin1.iface->decoder();
176 plugin1.encoder = plugin1.iface->encoder(); 176 plugin1.encoder = plugin1.iface->encoder();
177 pluginList.append( plugin1 ); 177 pluginList.append( plugin1 );
178 178
179 MediaPlayerPlugin plugin2; 179 MediaPlayerPlugin plugin2;
180 plugin2.iface = new WavPluginImpl; 180 plugin2.iface = new WavPluginImpl;
181 plugin2.decoder = plugin2.iface->decoder(); 181 plugin2.decoder = plugin2.iface->decoder();
182 plugin2.encoder = plugin2.iface->encoder(); 182 plugin2.encoder = plugin2.iface->encoder();
183 pluginList.append( plugin2 ); 183 pluginList.append( plugin2 );
184#endif 184#endif
185 185
186 if ( pluginList.count() ) 186 if ( pluginList.count() )
187 MediaPlayerDebug(( "%i decoders found", pluginList.count() )); 187 MediaPlayerDebug(( "%i decoders found", pluginList.count() ));
188 else 188 else
189 MediaPlayerDebug(( "No decoders found" )); 189 MediaPlayerDebug(( "No decoders found" ));
190} 190}
191 191
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 4b1ff22..218fd49 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1003 +1,1003 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22 22
23#include <qpe/qpemenubar.h> 23#include <qpe/qpemenubar.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/fileselector.h> 25#include <qpe/fileselector.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/lnkproperties.h> 27#include <qpe/lnkproperties.h>
28#include <qpe/storage.h> 28#include <qpe/storage.h>
29 29
30#include <qpe/applnk.h> 30#include <qpe/applnk.h>
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/global.h> 32#include <qpe/global.h>
33#include <qpe/resource.h> 33#include <qpe/resource.h>
34#include <qaction.h> 34#include <qaction.h>
35#include <qimage.h> 35#include <qimage.h>
36#include <qfile.h> 36#include <qfile.h>
37#include <qdir.h> 37#include <qdir.h>
38#include <qlayout.h> 38#include <qlayout.h>
39#include <qlabel.h> 39#include <qlabel.h>
40#include <qlist.h> 40#include <qlist.h>
41#include <qlistbox.h> 41#include <qlistbox.h>
42#include <qmainwindow.h> 42#include <qmainwindow.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qtoolbutton.h> 44#include <qtoolbutton.h>
45#include <qtabwidget.h> 45#include <qtabwidget.h>
46#include <qlistview.h> 46#include <qlistview.h>
47#include <qpoint.h> 47#include <qpoint.h>
48#include <qlineedit.h> 48#include <qlineedit.h>
49#include <qpushbutton.h> 49#include <qpushbutton.h>
50 50
51//#include <qtimer.h> 51//#include <qtimer.h>
52 52
53#include "playlistselection.h" 53#include "playlistselection.h"
54#include "playlistwidget.h" 54#include "playlistwidget.h"
55#include "mediaplayerstate.h" 55#include "mediaplayerstate.h"
56 56
57#include "inputDialog.h" 57#include "inputDialog.h"
58 58
59#include <stdlib.h> 59#include <stdlib.h>
60 60
61#define BUTTONS_ON_TOOLBAR 61#define BUTTONS_ON_TOOLBAR
62#define SIDE_BUTTONS 62#define SIDE_BUTTONS
63#define CAN_SAVE_LOAD_PLAYLISTS 63#define CAN_SAVE_LOAD_PLAYLISTS
64 64
65extern MediaPlayerState *mediaPlayerState; 65extern MediaPlayerState *mediaPlayerState;
66 66
67// class myFileSelector { 67// class myFileSelector {
68 68
69// }; 69// };
70class PlayListWidgetPrivate { 70class PlayListWidgetPrivate {
71public: 71public:
72 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 72 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
73 QFrame *playListFrame; 73 QFrame *playListFrame;
74 FileSelector *files; 74 FileSelector *files;
75 PlayListSelection *selectedFiles; 75 PlayListSelection *selectedFiles;
76 bool setDocumentUsed; 76 bool setDocumentUsed;
77 DocLnk *current; 77 DocLnk *current;
78}; 78};
79 79
80 80
81class ToolButton : public QToolButton { 81class ToolButton : public QToolButton {
82public: 82public:
83 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 83 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
84 : QToolButton( parent, name ) { 84 : QToolButton( parent, name ) {
85 setTextLabel( name ); 85 setTextLabel( name );
86 setPixmap( Resource::loadPixmap( icon ) ); 86 setPixmap( Resource::loadPixmap( icon ) );
87 setAutoRaise( TRUE ); 87 setAutoRaise( TRUE );
88 setFocusPolicy( QWidget::NoFocus ); 88 setFocusPolicy( QWidget::NoFocus );
89 setToggleButton( t ); 89 setToggleButton( t );
90 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 90 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
91 QPEMenuToolFocusManager::manager()->addWidget( this ); 91 QPEMenuToolFocusManager::manager()->addWidget( this );
92 } 92 }
93}; 93};
94 94
95 95
96class MenuItem : public QAction { 96class MenuItem : public QAction {
97public: 97public:
98 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 98 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
99 : QAction( text, QString::null, 0, 0 ) { 99 : QAction( text, QString::null, 0, 0 ) {
100 connect( this, SIGNAL( activated() ), handler, slot ); 100 connect( this, SIGNAL( activated() ), handler, slot );
101 addTo( parent ); 101 addTo( parent );
102 } 102 }
103}; 103};
104 104
105 105
106PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 106PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
107 : QMainWindow( parent, name, fl ) { 107 : QMainWindow( parent, name, fl ) {
108 108
109 d = new PlayListWidgetPrivate; 109 d = new PlayListWidgetPrivate;
110 d->setDocumentUsed = FALSE; 110 d->setDocumentUsed = FALSE;
111 d->current = NULL; 111 d->current = NULL;
112 fromSetDocument = FALSE; 112 fromSetDocument = FALSE;
113 insanityBool=FALSE; 113 insanityBool=FALSE;
114// menuTimer = new QTimer( this ,"menu timer"), 114// menuTimer = new QTimer( this ,"menu timer"),
115// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 115// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
116 116
117 setBackgroundMode( PaletteButton ); 117 setBackgroundMode( PaletteButton );
118 118
119 setCaption( tr("OpiePlayer") ); 119 setCaption( tr("OpiePlayer") );
120 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 120 setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
121 121
122 setToolBarsMovable( FALSE ); 122 setToolBarsMovable( FALSE );
123 123
124 // Create Toolbar 124 // Create Toolbar
125 QPEToolBar *toolbar = new QPEToolBar( this ); 125 QPEToolBar *toolbar = new QPEToolBar( this );
126 toolbar->setHorizontalStretchable( TRUE ); 126 toolbar->setHorizontalStretchable( TRUE );
127 127
128 // Create Menubar 128 // Create Menubar
129 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 129 QPEMenuBar *menu = new QPEMenuBar( toolbar );
130 menu->setMargin( 0 ); 130 menu->setMargin( 0 );
131 131
132 QPEToolBar *bar = new QPEToolBar( this ); 132 QPEToolBar *bar = new QPEToolBar( this );
133 bar->setLabel( tr( "Play Operations" ) ); 133 bar->setLabel( tr( "Play Operations" ) );
134// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", 134// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list",
135// this , SLOT( addSelected()) ); 135// this , SLOT( addSelected()) );
136 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 136 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
137 tbDeletePlaylist->setFlat(TRUE); 137 tbDeletePlaylist->setFlat(TRUE);
138 tbDeletePlaylist->setFixedSize(20,20); 138 tbDeletePlaylist->setFixedSize(20,20);
139 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 139 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
140 140
141 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", 141 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist",
142 this , SLOT(addSelected()) ); 142 this , SLOT(addSelected()) );
143 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", 143 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist",
144 this , SLOT(removeSelected()) ); 144 this , SLOT(removeSelected()) );
145// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 145// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
146 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", 146 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play",
147 this , SLOT( btnPlay(bool) ), TRUE ); 147 this , SLOT( btnPlay(bool) ), TRUE );
148 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", 148 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle",
149 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 149 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
150 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", 150 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop",
151 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 151 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
152 tbDeletePlaylist->hide(); 152 tbDeletePlaylist->hide();
153 153
154 QPopupMenu *pmPlayList = new QPopupMenu( this ); 154 QPopupMenu *pmPlayList = new QPopupMenu( this );
155 menu->insertItem( tr( "File" ), pmPlayList ); 155 menu->insertItem( tr( "File" ), pmPlayList );
156 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 156 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
157 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 157 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
158 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 158 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
159 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 159 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
160// pmPlayList->insertSeparator(-1); 160// pmPlayList->insertSeparator(-1);
161 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 161 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
162 pmPlayList->insertSeparator(-1); 162 pmPlayList->insertSeparator(-1);
163 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 163 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
164 164
165 QPopupMenu *pmView = new QPopupMenu( this ); 165 QPopupMenu *pmView = new QPopupMenu( this );
166 menu->insertItem( tr( "View" ), pmView ); 166 menu->insertItem( tr( "View" ), pmView );
167 167
168 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 168 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
169 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 169 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
170 fullScreenButton->addTo(pmView); 170 fullScreenButton->addTo(pmView);
171 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); 171 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0);
172 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 172 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
173 scaleButton->addTo(pmView); 173 scaleButton->addTo(pmView);
174 174
175 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 175 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
176 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 176 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
177 177
178 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 178 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
179 179
180 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 180 tabWidget = new QTabWidget( hbox6, "tabWidget" );
181 tabWidget->setTabShape(QTabWidget::Triangular); 181 tabWidget->setTabShape(QTabWidget::Triangular);
182 182
183 QWidget *pTab; 183 QWidget *pTab;
184 pTab = new QWidget( tabWidget, "pTab" ); 184 pTab = new QWidget( tabWidget, "pTab" );
185// playlistView = new QListView( pTab, "playlistview" ); 185// playlistView = new QListView( pTab, "playlistview" );
186// playlistView->setMinimumSize(236,260); 186// playlistView->setMinimumSize(236,260);
187 tabWidget->insertTab( pTab,"Playlist"); 187 tabWidget->insertTab( pTab,"Playlist");
188 188
189 189
190 // Add the playlist area 190 // Add the playlist area
191 191
192 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 192 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
193 d->playListFrame = vbox3; 193 d->playListFrame = vbox3;
194 d->playListFrame ->setMinimumSize(235,260); 194 d->playListFrame ->setMinimumSize(235,260);
195 195
196 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 196 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
197 197
198 d->selectedFiles = new PlayListSelection( hbox2); 198 d->selectedFiles = new PlayListSelection( hbox2);
199 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 199 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
200 200
201 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 201 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
202 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 202 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
203 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 203 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
204 204
205 205
206 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 206 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
207 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 207 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
208 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 208 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
209 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 209 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
210 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 210 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
211 211
212 QWidget *aTab; 212 QWidget *aTab;
213 aTab = new QWidget( tabWidget, "aTab" ); 213 aTab = new QWidget( tabWidget, "aTab" );
214 audioView = new QListView( aTab, "Audioview" ); 214 audioView = new QListView( aTab, "Audioview" );
215 audioView->setMinimumSize(233,260); 215 audioView->setMinimumSize(233,260);
216 audioView->addColumn( tr("Title"),140); 216 audioView->addColumn( tr("Title"),140);
217 audioView->addColumn(tr("Size"), -1); 217 audioView->addColumn(tr("Size"), -1);
218 audioView->addColumn(tr("Media"),-1); 218 audioView->addColumn(tr("Media"),-1);
219 audioView->setColumnAlignment(1, Qt::AlignRight); 219 audioView->setColumnAlignment(1, Qt::AlignRight);
220 audioView->setColumnAlignment(2, Qt::AlignRight); 220 audioView->setColumnAlignment(2, Qt::AlignRight);
221 audioView->setAllColumnsShowFocus(TRUE); 221 audioView->setAllColumnsShowFocus(TRUE);
222// audioView->setMultiSelection( TRUE ); 222// audioView->setMultiSelection( TRUE );
223// audioView->setSelectionMode( QListView::Extended); 223// audioView->setSelectionMode( QListView::Extended);
224 224
225 tabWidget->insertTab(aTab,tr("Audio")); 225 tabWidget->insertTab(aTab,tr("Audio"));
226 226
227 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 227 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
228 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 228 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
229 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 229 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
230 230
231 231
232// audioView 232// audioView
233 populateAudioView(); 233 populateAudioView();
234// videowidget 234// videowidget
235 235
236 QWidget *vTab; 236 QWidget *vTab;
237 vTab = new QWidget( tabWidget, "vTab" ); 237 vTab = new QWidget( tabWidget, "vTab" );
238 videoView = new QListView( vTab, "Videoview" ); 238 videoView = new QListView( vTab, "Videoview" );
239 videoView->setMinimumSize(233,260); 239 videoView->setMinimumSize(233,260);
240 240
241 videoView->addColumn(tr("Title"),140); 241 videoView->addColumn(tr("Title"),140);
242 videoView->addColumn(tr("Size"),-1); 242 videoView->addColumn(tr("Size"),-1);
243 videoView->addColumn(tr("Media"),-1); 243 videoView->addColumn(tr("Media"),-1);
244 videoView->setColumnAlignment(1, Qt::AlignRight); 244 videoView->setColumnAlignment(1, Qt::AlignRight);
245 videoView->setColumnAlignment(2, Qt::AlignRight); 245 videoView->setColumnAlignment(2, Qt::AlignRight);
246 videoView->setAllColumnsShowFocus(TRUE); 246 videoView->setAllColumnsShowFocus(TRUE);
247// videoView->setMultiSelection( TRUE ); 247// videoView->setMultiSelection( TRUE );
248// videoView->setSelectionMode( QListView::Extended); 248// videoView->setSelectionMode( QListView::Extended);
249 249
250 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 250 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
251 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 251 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
252 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 252 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
253 253
254 tabWidget->insertTab( vTab,tr("Video")); 254 tabWidget->insertTab( vTab,tr("Video"));
255populateVideoView(); 255populateVideoView();
256 256
257//playlists list 257//playlists list
258 QWidget *LTab; 258 QWidget *LTab;
259 LTab = new QWidget( tabWidget, "LTab" ); 259 LTab = new QWidget( tabWidget, "LTab" );
260 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 260 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
261 playLists->setMinimumSize(233,260);; 261 playLists->setMinimumSize(233,260);;
262 tabWidget->insertTab(LTab,tr("Lists")); 262 tabWidget->insertTab(LTab,tr("Lists"));
263 263
264 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 264 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
265// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 265// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
266 266
267 267
268// add the library area 268// add the library area
269 269
270// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 270// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
271// this, SLOT( fauxPlay( QListViewItem *) ) ); 271// this, SLOT( fauxPlay( QListViewItem *) ) );
272// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 272// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
273// this, SLOT( fauxPlay( QListViewItem *)) ); 273// this, SLOT( fauxPlay( QListViewItem *)) );
274 274
275// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 275// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
276// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 276// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
277 277
278 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 278 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
279 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 279 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
280 280
281 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 281 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
282 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 282 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
283 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 283 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
284 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 284 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
285 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 285 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
286 286
287 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 287 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
288// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 288// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
289 289
290 setCentralWidget( vbox5 ); 290 setCentralWidget( vbox5 );
291 291
292 Config cfg( "MediaPlayer" ); 292 Config cfg( "OpiePlayer" );
293 readConfig( cfg ); 293 readConfig( cfg );
294 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 294 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
295// qDebug("currentList is "+currentPlaylist); 295// qDebug("currentList is "+currentPlaylist);
296 loadList(DocLnk( currentPlaylist)); 296 loadList(DocLnk( currentPlaylist));
297 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 297 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
298 298
299 initializeStates(); 299 initializeStates();
300} 300}
301 301
302 302
303PlayListWidget::~PlayListWidget() { 303PlayListWidget::~PlayListWidget() {
304 Config cfg( "MediaPlayer" ); 304 Config cfg( "OpiePlayer" );
305 writeConfig( cfg ); 305 writeConfig( cfg );
306 306
307 307
308 if ( d->current ) 308 if ( d->current )
309 delete d->current; 309 delete d->current;
310 delete d; 310 delete d;
311} 311}
312 312
313 313
314void PlayListWidget::initializeStates() { 314void PlayListWidget::initializeStates() {
315 315
316 d->tbPlay->setOn( mediaPlayerState->playing() ); 316 d->tbPlay->setOn( mediaPlayerState->playing() );
317 d->tbLoop->setOn( mediaPlayerState->looping() ); 317 d->tbLoop->setOn( mediaPlayerState->looping() );
318 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 318 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
319// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 319// d->tbFull->setOn( mediaPlayerState->fullscreen() );
320// d->tbScale->setOn( mediaPlayerState->scaled() ); 320// d->tbScale->setOn( mediaPlayerState->scaled() );
321// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 321// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
322// setPlaylist( mediaPlayerState->playlist() ); 322// setPlaylist( mediaPlayerState->playlist() );
323 setPlaylist( true); 323 setPlaylist( true);
324// d->selectedFiles->first(); 324// d->selectedFiles->first();
325 325
326} 326}
327 327
328 328
329void PlayListWidget::readConfig( Config& cfg ) { 329void PlayListWidget::readConfig( Config& cfg ) {
330 cfg.setGroup("PlayList"); 330 cfg.setGroup("PlayList");
331 QString currentString = cfg.readEntry("current", "" ); 331 QString currentString = cfg.readEntry("current", "" );
332 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 332 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
333 for ( int i = 0; i < noOfFiles; i++ ) { 333 for ( int i = 0; i < noOfFiles; i++ ) {
334 QString entryName; 334 QString entryName;
335 entryName.sprintf( "File%i", i + 1 ); 335 entryName.sprintf( "File%i", i + 1 );
336 QString linkFile = cfg.readEntry( entryName ); 336 QString linkFile = cfg.readEntry( entryName );
337 DocLnk lnk( linkFile ); 337 DocLnk lnk( linkFile );
338 if ( lnk.isValid() ) { 338 if ( lnk.isValid() ) {
339 d->selectedFiles->addToSelection( lnk ); 339 d->selectedFiles->addToSelection( lnk );
340 } 340 }
341 } 341 }
342 d->selectedFiles->setSelectedItem( currentString); 342 d->selectedFiles->setSelectedItem( currentString);
343// d->selectedFiles->setSelectedItem( (const QString &)currentString); 343// d->selectedFiles->setSelectedItem( (const QString &)currentString);
344} 344}
345 345
346 346
347void PlayListWidget::writeConfig( Config& cfg ) const { 347void PlayListWidget::writeConfig( Config& cfg ) const {
348 348
349 d->selectedFiles->writeCurrent( cfg); 349 d->selectedFiles->writeCurrent( cfg);
350 cfg.setGroup("PlayList"); 350 cfg.setGroup("PlayList");
351 int noOfFiles = 0; 351 int noOfFiles = 0;
352 d->selectedFiles->first(); 352 d->selectedFiles->first();
353 do { 353 do {
354 const DocLnk *lnk = d->selectedFiles->current(); 354 const DocLnk *lnk = d->selectedFiles->current();
355 if ( lnk ) { 355 if ( lnk ) {
356 QString entryName; 356 QString entryName;
357 entryName.sprintf( "File%i", noOfFiles + 1 ); 357 entryName.sprintf( "File%i", noOfFiles + 1 );
358// qDebug(entryName); 358// qDebug(entryName);
359 cfg.writeEntry( entryName, lnk->linkFile() ); 359 cfg.writeEntry( entryName, lnk->linkFile() );
360 // if this link does exist, add it so we have the file 360 // if this link does exist, add it so we have the file
361 // next time... 361 // next time...
362 if ( !QFile::exists( lnk->linkFile() ) ) { 362 if ( !QFile::exists( lnk->linkFile() ) ) {
363 // the way writing lnks doesn't really check for out 363 // the way writing lnks doesn't really check for out
364 // of disk space, but check it anyway. 364 // of disk space, but check it anyway.
365 if ( !lnk->writeLink() ) { 365 if ( !lnk->writeLink() ) {
366 QMessageBox::critical( 0, tr("Out of space"), 366 QMessageBox::critical( 0, tr("Out of space"),
367 tr( "There was a problem saving " 367 tr( "There was a problem saving "
368 "the playlist.\n" 368 "the playlist.\n"
369 "Your playlist " 369 "Your playlist "
370 "may be missing some entries\n" 370 "may be missing some entries\n"
371 "the next time you start it." ) 371 "the next time you start it." )
372 ); 372 );
373 } 373 }
374 } 374 }
375 noOfFiles++; 375 noOfFiles++;
376 } 376 }
377 } 377 }
378 while ( d->selectedFiles->next() ); 378 while ( d->selectedFiles->next() );
379 cfg.writeEntry("NumberOfFiles", noOfFiles ); 379 cfg.writeEntry("NumberOfFiles", noOfFiles );
380} 380}
381 381
382 382
383void PlayListWidget::addToSelection( const DocLnk& lnk ) { 383void PlayListWidget::addToSelection( const DocLnk& lnk ) {
384// qDebug("add"); 384// qDebug("add");
385 d->setDocumentUsed = FALSE; 385 d->setDocumentUsed = FALSE;
386 if ( mediaPlayerState->playlist() ) 386 if ( mediaPlayerState->playlist() )
387 d->selectedFiles->addToSelection( lnk ); 387 d->selectedFiles->addToSelection( lnk );
388 else 388 else
389 mediaPlayerState->setPlaying( TRUE ); 389 mediaPlayerState->setPlaying( TRUE );
390} 390}
391 391
392 392
393void PlayListWidget::clearList() { 393void PlayListWidget::clearList() {
394 while ( first() ) 394 while ( first() )
395 d->selectedFiles->removeSelected(); 395 d->selectedFiles->removeSelected();
396} 396}
397 397
398 398
399void PlayListWidget::addAllToList() { 399void PlayListWidget::addAllToList() {
400 DocLnkSet filesAll; 400 DocLnkSet filesAll;
401 Global::findDocuments(&filesAll, "video/*;audio/*"); 401 Global::findDocuments(&filesAll, "video/*;audio/*");
402 QListIterator<DocLnk> Adit( filesAll.children() ); 402 QListIterator<DocLnk> Adit( filesAll.children() );
403 for ( ; Adit.current(); ++Adit ) 403 for ( ; Adit.current(); ++Adit )
404 d->selectedFiles->addToSelection( **Adit ); 404 d->selectedFiles->addToSelection( **Adit );
405} 405}
406 406
407 407
408void PlayListWidget::addAllMusicToList() { 408void PlayListWidget::addAllMusicToList() {
409// DocLnkSet files; 409// DocLnkSet files;
410// Global::findDocuments(&files, "audio/*"); 410// Global::findDocuments(&files, "audio/*");
411 QListIterator<DocLnk> dit( files.children() ); 411 QListIterator<DocLnk> dit( files.children() );
412 for ( ; dit.current(); ++dit ) 412 for ( ; dit.current(); ++dit )
413 d->selectedFiles->addToSelection( **dit ); 413 d->selectedFiles->addToSelection( **dit );
414} 414}
415 415
416 416
417void PlayListWidget::addAllVideoToList() { 417void PlayListWidget::addAllVideoToList() {
418 QListIterator<DocLnk> dit( vFiles.children() ); 418 QListIterator<DocLnk> dit( vFiles.children() );
419 for ( ; dit.current(); ++dit ) 419 for ( ; dit.current(); ++dit )
420 d->selectedFiles->addToSelection( **dit ); 420 d->selectedFiles->addToSelection( **dit );
421} 421}
422 422
423 423
424void PlayListWidget::setDocument(const QString& fileref) { 424void PlayListWidget::setDocument(const QString& fileref) {
425 qDebug(fileref); 425 qDebug(fileref);
426 fromSetDocument = TRUE; 426 fromSetDocument = TRUE;
427 if ( fileref.isNull() ) { 427 if ( fileref.isNull() ) {
428 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 428 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
429 return; 429 return;
430 } 430 }
431// qDebug("setDocument "+fileref); 431// qDebug("setDocument "+fileref);
432 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 432 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
433 clearList(); 433 clearList();
434 addToSelection( DocLnk( fileref ) ); 434 addToSelection( DocLnk( fileref ) );
435 d->setDocumentUsed = TRUE; 435 d->setDocumentUsed = TRUE;
436 d->selectedFiles->first(); 436 d->selectedFiles->first();
437 qApp->processEvents(); 437 qApp->processEvents();
438 } 438 }
439 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 439 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
440 clearList(); 440 clearList();
441 loadList(DocLnk(fileref)); 441 loadList(DocLnk(fileref));
442 d->selectedFiles->first(); 442 d->selectedFiles->first();
443 } else { 443 } else {
444 clearList(); 444 clearList();
445 addToSelection( DocLnk( fileref ) ); 445 addToSelection( DocLnk( fileref ) );
446 d->setDocumentUsed = TRUE; 446 d->setDocumentUsed = TRUE;
447 mediaPlayerState->setPlaying( FALSE ); 447 mediaPlayerState->setPlaying( FALSE );
448 qApp->processEvents(); 448 qApp->processEvents();
449 mediaPlayerState->setPlaying( TRUE ); 449 mediaPlayerState->setPlaying( TRUE );
450 qApp->processEvents(); 450 qApp->processEvents();
451 setCaption(tr("OpiePlayer")); 451 setCaption(tr("OpiePlayer"));
452 } 452 }
453} 453}
454 454
455 455
456void PlayListWidget::setActiveWindow() { 456void PlayListWidget::setActiveWindow() {
457 // When we get raised we need to ensure that it switches views 457 // When we get raised we need to ensure that it switches views
458 char origView = mediaPlayerState->view(); 458 char origView = mediaPlayerState->view();
459 mediaPlayerState->setView( 'l' ); // invalidate 459 mediaPlayerState->setView( 'l' ); // invalidate
460 mediaPlayerState->setView( origView ); // now switch back 460 mediaPlayerState->setView( origView ); // now switch back
461} 461}
462 462
463 463
464void PlayListWidget::useSelectedDocument() { 464void PlayListWidget::useSelectedDocument() {
465 d->setDocumentUsed = FALSE; 465 d->setDocumentUsed = FALSE;
466} 466}
467 467
468 468
469const DocLnk *PlayListWidget::current() { // this is fugly 469const DocLnk *PlayListWidget::current() { // this is fugly
470 470
471// if( fromSetDocument) { 471// if( fromSetDocument) {
472// qDebug("from setDoc"); 472// qDebug("from setDoc");
473// DocLnkSet files; 473// DocLnkSet files;
474// Global::findDocuments(&files, "video/*;audio/*"); 474// Global::findDocuments(&files, "video/*;audio/*");
475// QListIterator<DocLnk> dit( files.children() ); 475// QListIterator<DocLnk> dit( files.children() );
476// for ( ; dit.current(); ++dit ) { 476// for ( ; dit.current(); ++dit ) {
477// if(dit.current()->linkFile() == setDocFileRef) { 477// if(dit.current()->linkFile() == setDocFileRef) {
478// qDebug(setDocFileRef); 478// qDebug(setDocFileRef);
479// return dit; 479// return dit;
480// } 480// }
481// } 481// }
482// } else 482// } else
483 483
484 484
485 switch (tabWidget->currentPageIndex()) { 485 switch (tabWidget->currentPageIndex()) {
486 case 0: //playlist 486 case 0: //playlist
487 { 487 {
488 qDebug("playlist"); 488 qDebug("playlist");
489 if ( mediaPlayerState->playlist() ) { 489 if ( mediaPlayerState->playlist() ) {
490 return d->selectedFiles->current(); 490 return d->selectedFiles->current();
491 } 491 }
492 else if ( d->setDocumentUsed && d->current ) { 492 else if ( d->setDocumentUsed && d->current ) {
493 return d->current; 493 return d->current;
494 } else { 494 } else {
495 return d->files->selected(); 495 return d->files->selected();
496 } 496 }
497 } 497 }
498 break; 498 break;
499 case 1://audio 499 case 1://audio
500 { 500 {
501 qDebug("audioView"); 501 qDebug("audioView");
502// Global::findDocuments(&files, "audio/*"); 502// Global::findDocuments(&files, "audio/*");
503 QListIterator<DocLnk> dit( files.children() ); 503 QListIterator<DocLnk> dit( files.children() );
504 for ( ; dit.current(); ++dit ) { 504 for ( ; dit.current(); ++dit ) {
505 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 505 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
506 qDebug("here"); 506 qDebug("here");
507 insanityBool=TRUE; 507 insanityBool=TRUE;
508 return dit; 508 return dit;
509 } 509 }
510 } 510 }
511 } 511 }
512 break; 512 break;
513 case 2: // video 513 case 2: // video
514 { 514 {
515 qDebug("videoView"); 515 qDebug("videoView");
516// Global::findDocuments(&vFiles, "video/*"); 516// Global::findDocuments(&vFiles, "video/*");
517 QListIterator<DocLnk> Vdit( vFiles.children() ); 517 QListIterator<DocLnk> Vdit( vFiles.children() );
518 for ( ; Vdit.current(); ++Vdit ) { 518 for ( ; Vdit.current(); ++Vdit ) {
519 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 519 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
520 insanityBool=TRUE; 520 insanityBool=TRUE;
521 return Vdit; 521 return Vdit;
522 } 522 }
523 } 523 }
524 } 524 }
525 break; 525 break;
526 }; 526 };
527 return 0; 527 return 0;
528} 528}
529 529
530bool PlayListWidget::prev() { 530bool PlayListWidget::prev() {
531 if ( mediaPlayerState->playlist() ) { 531 if ( mediaPlayerState->playlist() ) {
532 if ( mediaPlayerState->shuffled() ) { 532 if ( mediaPlayerState->shuffled() ) {
533 const DocLnk *cur = current(); 533 const DocLnk *cur = current();
534 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 534 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
535 for ( int i = 0; i < j; i++ ) { 535 for ( int i = 0; i < j; i++ ) {
536 if ( !d->selectedFiles->next() ) 536 if ( !d->selectedFiles->next() )
537 d->selectedFiles->first(); 537 d->selectedFiles->first();
538 } 538 }
539 if ( cur == current() ) 539 if ( cur == current() )
540 if ( !d->selectedFiles->next() ) 540 if ( !d->selectedFiles->next() )
541 d->selectedFiles->first(); 541 d->selectedFiles->first();
542 return TRUE; 542 return TRUE;
543 } else { 543 } else {
544 if ( !d->selectedFiles->prev() ) { 544 if ( !d->selectedFiles->prev() ) {
545 if ( mediaPlayerState->looping() ) { 545 if ( mediaPlayerState->looping() ) {
546 return d->selectedFiles->last(); 546 return d->selectedFiles->last();
547 } else { 547 } else {
548 return FALSE; 548 return FALSE;
549 } 549 }
550 } 550 }
551 return TRUE; 551 return TRUE;
552 } 552 }
553 } else { 553 } else {
554 return mediaPlayerState->looping(); 554 return mediaPlayerState->looping();
555 } 555 }
556} 556}
557 557
558 558
559bool PlayListWidget::next() { 559bool PlayListWidget::next() {
560 if ( mediaPlayerState->playlist() ) { 560 if ( mediaPlayerState->playlist() ) {
561 if ( mediaPlayerState->shuffled() ) { 561 if ( mediaPlayerState->shuffled() ) {
562 return prev(); 562 return prev();
563 } else { 563 } else {
564 if ( !d->selectedFiles->next() ) { 564 if ( !d->selectedFiles->next() ) {
565 if ( mediaPlayerState->looping() ) { 565 if ( mediaPlayerState->looping() ) {
566 return d->selectedFiles->first(); 566 return d->selectedFiles->first();
567 } else { 567 } else {
568 return FALSE; 568 return FALSE;
569 } 569 }
570 } 570 }
571 return TRUE; 571 return TRUE;
572 } 572 }
573 } else { 573 } else {
574 return mediaPlayerState->looping(); 574 return mediaPlayerState->looping();
575 } 575 }
576} 576}
577 577
578 578
579bool PlayListWidget::first() { 579bool PlayListWidget::first() {
580 if ( mediaPlayerState->playlist() ) 580 if ( mediaPlayerState->playlist() )
581 return d->selectedFiles->first(); 581 return d->selectedFiles->first();
582 else 582 else
583 return mediaPlayerState->looping(); 583 return mediaPlayerState->looping();
584} 584}
585 585
586 586
587bool PlayListWidget::last() { 587bool PlayListWidget::last() {
588 if ( mediaPlayerState->playlist() ) 588 if ( mediaPlayerState->playlist() )
589 return d->selectedFiles->last(); 589 return d->selectedFiles->last();
590 else 590 else
591 return mediaPlayerState->looping(); 591 return mediaPlayerState->looping();
592} 592}
593 593
594 594
595void PlayListWidget::saveList() { 595void PlayListWidget::saveList() {
596 596
597 QString filename; 597 QString filename;
598 InputDialog *fileDlg; 598 InputDialog *fileDlg;
599 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 599 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
600 fileDlg->exec(); 600 fileDlg->exec();
601 if( fileDlg->result() == 1 ) { 601 if( fileDlg->result() == 1 ) {
602 if ( d->current ) 602 if ( d->current )
603 delete d->current; 603 delete d->current;
604 filename = fileDlg->LineEdit1->text();//+".playlist"; 604 filename = fileDlg->LineEdit1->text();//+".playlist";
605// qDebug("saving playlist "+filename+".playlist"); 605// qDebug("saving playlist "+filename+".playlist");
606 Config cfg( filename +".playlist"); 606 Config cfg( filename +".playlist");
607 writeConfig( cfg ); 607 writeConfig( cfg );
608 608
609// qDebug("same name so delete lnk??"); 609// qDebug("same name so delete lnk??");
610// if( playLists->selected()->name() == filename) { 610// if( playLists->selected()->name() == filename) {
611 611
612// qDebug("same name so delete lnk"); 612// qDebug("same name so delete lnk");
613// QFile().remove(playLists->selected()->file()); 613// QFile().remove(playLists->selected()->file());
614// QFile().remove(playLists->selected()->linkFile()); 614// QFile().remove(playLists->selected()->linkFile());
615// playLists->reread(); 615// playLists->reread();
616// } 616// }
617// qDebug("new doclnk"); 617// qDebug("new doclnk");
618 DocLnk lnk; 618 DocLnk lnk;
619// lnk.setComment( ""); 619// lnk.setComment( "");
620 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 620 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
621 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 621 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
622 lnk.setIcon("mpegplayer/playlist2"); 622 lnk.setIcon("mpegplayer/playlist2");
623 lnk.setName( filename); //sets file name 623 lnk.setName( filename); //sets file name
624// qDebug(filename); 624// qDebug(filename);
625 if(!lnk.writeLink()) 625 if(!lnk.writeLink())
626 qDebug("Writing doclink did not work"); 626 qDebug("Writing doclink did not work");
627 } 627 }
628 Config config( "MediaPlayer" ); 628 Config config( "OpiePlayer" );
629 config.writeEntry("CurrentPlaylist",filename); 629 config.writeEntry("CurrentPlaylist",filename);
630 setCaption(tr("OpiePlayer: ")+filename); 630 setCaption(tr("OpiePlayer: ")+filename);
631 d->selectedFiles->first(); 631 d->selectedFiles->first();
632 if(fileDlg) 632 if(fileDlg)
633 delete fileDlg; 633 delete fileDlg;
634} 634}
635 635
636void PlayListWidget::loadList( const DocLnk & lnk) { 636void PlayListWidget::loadList( const DocLnk & lnk) {
637 QString name= lnk.name(); 637 QString name= lnk.name();
638// qDebug("currentList is "+name); 638// qDebug("currentList is "+name);
639 if( name.length()>1) { 639 if( name.length()>1) {
640 setCaption("OpiePlayer: "+name); 640 setCaption("OpiePlayer: "+name);
641// qDebug("load list "+ name+".playlist"); 641// qDebug("load list "+ name+".playlist");
642 clearList(); 642 clearList();
643 Config cfg( name+".playlist"); 643 Config cfg( name+".playlist");
644 readConfig(cfg); 644 readConfig(cfg);
645 645
646 tabWidget->setCurrentPage(0); 646 tabWidget->setCurrentPage(0);
647 647
648 Config config( "MediaPlayer" ); 648 Config config( "OpiePlayer" );
649 config.writeEntry("CurrentPlaylist", name); 649 config.writeEntry("CurrentPlaylist", name);
650// d->selectedFiles->first(); 650// d->selectedFiles->first();
651 } 651 }
652 652
653} 653}
654 654
655void PlayListWidget::setPlaylist( bool shown ) { 655void PlayListWidget::setPlaylist( bool shown ) {
656 if ( shown ) 656 if ( shown )
657 d->playListFrame->show(); 657 d->playListFrame->show();
658 else 658 else
659 d->playListFrame->hide(); 659 d->playListFrame->hide();
660} 660}
661 661
662void PlayListWidget::setView( char view ) { 662void PlayListWidget::setView( char view ) {
663 if ( view == 'l' ) 663 if ( view == 'l' )
664 showMaximized(); 664 showMaximized();
665 else 665 else
666 hide(); 666 hide();
667} 667}
668 668
669void PlayListWidget::addSelected() { 669void PlayListWidget::addSelected() {
670 670
671 Config cfg( "MediaPlayer" ); 671 Config cfg( "OpiePlayer" );
672 cfg.setGroup("PlayList"); 672 cfg.setGroup("PlayList");
673 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 673 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
674 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 674 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
675 675
676 switch (tabWidget->currentPageIndex()) { 676 switch (tabWidget->currentPageIndex()) {
677 case 0: //playlist 677 case 0: //playlist
678 break; 678 break;
679 case 1: { //audio 679 case 1: { //audio
680 for ( int i = 0; i < noOfFiles; i++ ) { 680 for ( int i = 0; i < noOfFiles; i++ ) {
681 QString entryName; 681 QString entryName;
682 entryName.sprintf( "File%i", i + 1 ); 682 entryName.sprintf( "File%i", i + 1 );
683 QString linkFile = cfg.readEntry( entryName ); 683 QString linkFile = cfg.readEntry( entryName );
684 if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { 684 if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) {
685 int result= QMessageBox::warning(this,tr("OpiePlayer"), 685 int result= QMessageBox::warning(this,tr("OpiePlayer"),
686 tr("This is all ready in your playlist.\nContinue?"), 686 tr("This is all ready in your playlist.\nContinue?"),
687 tr("Yes"),tr("No"),0,0,1); 687 tr("Yes"),tr("No"),0,0,1);
688 if (result !=0) 688 if (result !=0)
689 return; 689 return;
690 } 690 }
691 } 691 }
692 addToSelection( audioView->selectedItem() ); 692 addToSelection( audioView->selectedItem() );
693 tabWidget->setCurrentPage(1); 693 tabWidget->setCurrentPage(1);
694 } 694 }
695 break; 695 break;
696 case 2: { // video 696 case 2: { // video
697 for ( int i = 0; i < noOfFiles; i++ ) { 697 for ( int i = 0; i < noOfFiles; i++ ) {
698 QString entryName; 698 QString entryName;
699 entryName.sprintf( "File%i", i + 1 ); 699 entryName.sprintf( "File%i", i + 1 );
700 QString linkFile = cfg.readEntry( entryName ); 700 QString linkFile = cfg.readEntry( entryName );
701 if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 701 if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
702 int result= QMessageBox::warning(this,tr("OpiePlayer"), 702 int result= QMessageBox::warning(this,tr("OpiePlayer"),
703 tr("This is all ready in your playlist.\nContinue?"), 703 tr("This is all ready in your playlist.\nContinue?"),
704 tr("Yes"),tr("No"),0,0,1); 704 tr("Yes"),tr("No"),0,0,1);
705 if (result !=0) 705 if (result !=0)
706 return; 706 return;
707 } 707 }
708 } 708 }
709 addToSelection( videoView->selectedItem() ); 709 addToSelection( videoView->selectedItem() );
710 tabWidget->setCurrentPage(2); 710 tabWidget->setCurrentPage(2);
711 } 711 }
712 break; 712 break;
713 }; 713 };
714} 714}
715 715
716void PlayListWidget::removeSelected() { 716void PlayListWidget::removeSelected() {
717 d->selectedFiles->removeSelected( ); 717 d->selectedFiles->removeSelected( );
718} 718}
719 719
720void PlayListWidget::playIt( QListViewItem *it) { 720void PlayListWidget::playIt( QListViewItem *it) {
721// d->setDocumentUsed = FALSE; 721// d->setDocumentUsed = FALSE;
722 mediaPlayerState->setPlaying(TRUE); 722 mediaPlayerState->setPlaying(TRUE);
723} 723}
724 724
725void PlayListWidget::addToSelection( QListViewItem *it) { 725void PlayListWidget::addToSelection( QListViewItem *it) {
726 d->setDocumentUsed = FALSE; 726 d->setDocumentUsed = FALSE;
727 727
728 if(it) { 728 if(it) {
729 switch (tabWidget->currentPageIndex()) { 729 switch (tabWidget->currentPageIndex()) {
730 case 1: { 730 case 1: {
731 QListIterator<DocLnk> dit( files.children() ); 731 QListIterator<DocLnk> dit( files.children() );
732 for ( ; dit.current(); ++dit ) { 732 for ( ; dit.current(); ++dit ) {
733 if( dit.current()->name() == it->text(0)) { 733 if( dit.current()->name() == it->text(0)) {
734 d->selectedFiles->addToSelection( **dit ); 734 d->selectedFiles->addToSelection( **dit );
735 } 735 }
736 } 736 }
737 } 737 }
738 break; 738 break;
739 case 2: { 739 case 2: {
740 QListIterator<DocLnk> dit( vFiles.children() ); 740 QListIterator<DocLnk> dit( vFiles.children() );
741 for ( ; dit.current(); ++dit ) { 741 for ( ; dit.current(); ++dit ) {
742 if( dit.current()->name() == it->text(0)) { 742 if( dit.current()->name() == it->text(0)) {
743 d->selectedFiles->addToSelection( **dit ); 743 d->selectedFiles->addToSelection( **dit );
744 } 744 }
745 } 745 }
746 } 746 }
747 break; 747 break;
748 case 0: 748 case 0:
749 break; 749 break;
750 }; 750 };
751 tabWidget->setCurrentPage(0); 751 tabWidget->setCurrentPage(0);
752 } 752 }
753} 753}
754 754
755void PlayListWidget::tabChanged(QWidget *widg) { 755void PlayListWidget::tabChanged(QWidget *widg) {
756 756
757 switch ( tabWidget->currentPageIndex()) { 757 switch ( tabWidget->currentPageIndex()) {
758 case 0: 758 case 0:
759 { 759 {
760 if( !tbDeletePlaylist->isHidden()) 760 if( !tbDeletePlaylist->isHidden())
761 tbDeletePlaylist->hide(); 761 tbDeletePlaylist->hide();
762 d->tbRemoveFromList->setEnabled(TRUE); 762 d->tbRemoveFromList->setEnabled(TRUE);
763 d->tbAddToList->setEnabled(FALSE); 763 d->tbAddToList->setEnabled(FALSE);
764 } 764 }
765 break; 765 break;
766 case 1: 766 case 1:
767 { 767 {
768 if( !tbDeletePlaylist->isHidden()) 768 if( !tbDeletePlaylist->isHidden())
769 tbDeletePlaylist->hide(); 769 tbDeletePlaylist->hide();
770 d->tbRemoveFromList->setEnabled(FALSE); 770 d->tbRemoveFromList->setEnabled(FALSE);
771 d->tbAddToList->setEnabled(TRUE); 771 d->tbAddToList->setEnabled(TRUE);
772 } 772 }
773 break; 773 break;
774 case 2: 774 case 2:
775 { 775 {
776 if( !tbDeletePlaylist->isHidden()) 776 if( !tbDeletePlaylist->isHidden())
777 tbDeletePlaylist->hide(); 777 tbDeletePlaylist->hide();
778 d->tbRemoveFromList->setEnabled(FALSE); 778 d->tbRemoveFromList->setEnabled(FALSE);
779 d->tbAddToList->setEnabled(TRUE); 779 d->tbAddToList->setEnabled(TRUE);
780 } 780 }
781 break; 781 break;
782 case 3: 782 case 3:
783 { 783 {
784 if( tbDeletePlaylist->isHidden()) 784 if( tbDeletePlaylist->isHidden())
785 tbDeletePlaylist->show(); 785 tbDeletePlaylist->show();
786 playLists->reread(); 786 playLists->reread();
787 } 787 }
788 break; 788 break;
789 }; 789 };
790} 790}
791 791
792 792
793 793
794void PlayListWidget::btnPlay(bool b) { 794void PlayListWidget::btnPlay(bool b) {
795 795
796// mediaPlayerState->setPlaying(b); 796// mediaPlayerState->setPlaying(b);
797 switch ( tabWidget->currentPageIndex()) { 797 switch ( tabWidget->currentPageIndex()) {
798 case 0: 798 case 0:
799 { 799 {
800 mediaPlayerState->setPlaying(b); 800 mediaPlayerState->setPlaying(b);
801 } 801 }
802 break; 802 break;
803 case 1: 803 case 1:
804 { 804 {
805 addToSelection( audioView->selectedItem() ); 805 addToSelection( audioView->selectedItem() );
806 mediaPlayerState->setPlaying(b); 806 mediaPlayerState->setPlaying(b);
807 d->selectedFiles->removeSelected( ); 807 d->selectedFiles->removeSelected( );
808 tabWidget->setCurrentPage(1); 808 tabWidget->setCurrentPage(1);
809 d->selectedFiles->unSelect(); 809 d->selectedFiles->unSelect();
810// audioView->clearSelection(); 810// audioView->clearSelection();
811 } 811 }
812 break; 812 break;
813 case 2: 813 case 2:
814 { 814 {
815 addToSelection( videoView->selectedItem() ); 815 addToSelection( videoView->selectedItem() );
816 mediaPlayerState->setPlaying(b); 816 mediaPlayerState->setPlaying(b);
817 qApp->processEvents(); 817 qApp->processEvents();
818 d->selectedFiles->removeSelected( ); 818 d->selectedFiles->removeSelected( );
819 tabWidget->setCurrentPage(2); 819 tabWidget->setCurrentPage(2);
820 d->selectedFiles->unSelect(); 820 d->selectedFiles->unSelect();
821// videoView->clearSelection(); 821// videoView->clearSelection();
822 } 822 }
823 break; 823 break;
824 }; 824 };
825} 825}
826 826
827void PlayListWidget::deletePlaylist() { 827void PlayListWidget::deletePlaylist() {
828 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 828 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
829 (tr("You really want to delete\nthis playlist?")), 829 (tr("You really want to delete\nthis playlist?")),
830 (tr("Yes")), (tr("No")), 0 )){ 830 (tr("Yes")), (tr("No")), 0 )){
831 case 0: // Yes clicked, 831 case 0: // Yes clicked,
832 QFile().remove(playLists->selected()->file()); 832 QFile().remove(playLists->selected()->file());
833 QFile().remove(playLists->selected()->linkFile()); 833 QFile().remove(playLists->selected()->linkFile());
834 playLists->reread(); 834 playLists->reread();
835 break; 835 break;
836 case 1: // Cancel 836 case 1: // Cancel
837 break; 837 break;
838 }; 838 };
839 839
840} 840}
841 841
842void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 842void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
843{ 843{
844 switch (mouse) { 844 switch (mouse) {
845 case 1: 845 case 1:
846 break; 846 break;
847 case 2:{ 847 case 2:{
848 QPopupMenu m; 848 QPopupMenu m;
849 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 849 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
850 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 850 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
851 m.insertSeparator(); 851 m.insertSeparator();
852 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 852 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
853 m.exec( QCursor::pos() ); 853 m.exec( QCursor::pos() );
854 } 854 }
855 break; 855 break;
856 }; 856 };
857} 857}
858 858
859void PlayListWidget::playSelected() 859void PlayListWidget::playSelected()
860{ 860{
861 btnPlay( TRUE); 861 btnPlay( TRUE);
862} 862}
863 863
864void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 864void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
865{ 865{
866 switch (mouse) { 866 switch (mouse) {
867 case 1: 867 case 1:
868 break; 868 break;
869 case 2:{ 869 case 2:{
870 QPopupMenu m; 870 QPopupMenu m;
871 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 871 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
872 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 872 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
873// m.insertSeparator(); 873// m.insertSeparator();
874 m.exec( QCursor::pos() ); 874 m.exec( QCursor::pos() );
875 } 875 }
876 break; 876 break;
877 }; 877 };
878 878
879} 879}
880 880
881void PlayListWidget::listDelete() { 881void PlayListWidget::listDelete() {
882 Config cfg( "MediaPlayer" ); 882 Config cfg( "OpiePlayer" );
883 cfg.setGroup("PlayList"); 883 cfg.setGroup("PlayList");
884 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 884 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
885 QString file; 885 QString file;
886 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 886 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
887 switch ( tabWidget->currentPageIndex()) { 887 switch ( tabWidget->currentPageIndex()) {
888 case 0: 888 case 0:
889 break; 889 break;
890 case 1: 890 case 1:
891 { 891 {
892 file = audioView->selectedItem()->text(0); 892 file = audioView->selectedItem()->text(0);
893// Global::findDocuments(&files, "audio/*"); 893// Global::findDocuments(&files, "audio/*");
894// AppLnkSet appFiles; 894// AppLnkSet appFiles;
895 QListIterator<DocLnk> dit( files.children() ); 895 QListIterator<DocLnk> dit( files.children() );
896 for ( ; dit.current(); ++dit ) { 896 for ( ; dit.current(); ++dit ) {
897 if( dit.current()->name() == file) { 897 if( dit.current()->name() == file) {
898// qDebug(file); 898// qDebug(file);
899 LnkProperties prop( dit.current() ); 899 LnkProperties prop( dit.current() );
900// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 900// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
901 prop.showMaximized(); 901 prop.showMaximized();
902 prop.exec(); 902 prop.exec();
903 } 903 }
904 } 904 }
905 populateAudioView(); 905 populateAudioView();
906 } 906 }
907 break; 907 break;
908 case 2: 908 case 2:
909 { 909 {
910// file = videoView->selectedItem()->text(0); 910// file = videoView->selectedItem()->text(0);
911// for ( int i = 0; i < noOfFiles; i++ ) { 911// for ( int i = 0; i < noOfFiles; i++ ) {
912// QString entryName; 912// QString entryName;
913// entryName.sprintf( "File%i", i + 1 ); 913// entryName.sprintf( "File%i", i + 1 );
914// QString linkFile = cfg.readEntry( entryName ); 914// QString linkFile = cfg.readEntry( entryName );
915// AppLnk lnk( AppLnk(linkFile)); 915// AppLnk lnk( AppLnk(linkFile));
916// if( lnk.name() == file ) { 916// if( lnk.name() == file ) {
917// LnkProperties prop( &lnk); 917// LnkProperties prop( &lnk);
918// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 918// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
919// prop.showMaximized(); 919// prop.showMaximized();
920// prop.exec(); 920// prop.exec();
921// } 921// }
922// } 922// }
923 } 923 }
924 break; 924 break;
925 }; 925 };
926} 926}
927 927
928void PlayListWidget::populateAudioView() { 928void PlayListWidget::populateAudioView() {
929// if(files) 929// if(files)
930// files.~DocLnkSet(); 930// files.~DocLnkSet();
931 StorageInfo storageInfo; 931 StorageInfo storageInfo;
932 const QList<FileSystem> &fs = storageInfo.fileSystems(); 932 const QList<FileSystem> &fs = storageInfo.fileSystems();
933 933
934 Global::findDocuments(&files, "audio/*"); 934 Global::findDocuments(&files, "audio/*");
935 QListIterator<DocLnk> dit( files.children() ); 935 QListIterator<DocLnk> dit( files.children() );
936 QListIterator<FileSystem> it ( fs ); 936 QListIterator<FileSystem> it ( fs );
937 audioView->clear(); 937 audioView->clear();
938 QString storage; 938 QString storage;
939 for ( ; dit.current(); ++dit ) { 939 for ( ; dit.current(); ++dit ) {
940 for( ; it.current(); ++it ){ 940 for( ; it.current(); ++it ){
941 const QString name = (*it)->name(); 941 const QString name = (*it)->name();
942 const QString path = (*it)->path(); 942 const QString path = (*it)->path();
943 if(dit.current()->file().find(path) != -1 ) storage=name; 943 if(dit.current()->file().find(path) != -1 ) storage=name;
944 } 944 }
945 945
946 QListViewItem * newItem; 946 QListViewItem * newItem;
947 if ( QFile( dit.current()->file()).exists() ) { 947 if ( QFile( dit.current()->file()).exists() ) {
948 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); 948 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
949 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); 949 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
950 } 950 }
951 } 951 }
952} 952}
953 953
954void PlayListWidget::populateVideoView() { 954void PlayListWidget::populateVideoView() {
955 StorageInfo storageInfo; 955 StorageInfo storageInfo;
956 const QList<FileSystem> &fs = storageInfo.fileSystems(); 956 const QList<FileSystem> &fs = storageInfo.fileSystems();
957 957
958 Global::findDocuments(&vFiles, "video/*"); 958 Global::findDocuments(&vFiles, "video/*");
959 QListIterator<DocLnk> Vdit( vFiles.children() ); 959 QListIterator<DocLnk> Vdit( vFiles.children() );
960 QListIterator<FileSystem> it ( fs ); 960 QListIterator<FileSystem> it ( fs );
961 videoView->clear(); 961 videoView->clear();
962 QString storage; 962 QString storage;
963 for ( ; Vdit.current(); ++Vdit ) { 963 for ( ; Vdit.current(); ++Vdit ) {
964 for( ; it.current(); ++it ){ 964 for( ; it.current(); ++it ){
965 const QString name = (*it)->name(); 965 const QString name = (*it)->name();
966 const QString path = (*it)->path(); 966 const QString path = (*it)->path();
967 if( Vdit.current()->file().find(path) != -1 ) storage=name; 967 if( Vdit.current()->file().find(path) != -1 ) storage=name;
968 } 968 }
969 969
970 QListViewItem * newItem; 970 QListViewItem * newItem;
971 if ( QFile( Vdit.current()->file()).exists() ) { 971 if ( QFile( Vdit.current()->file()).exists() ) {
972 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 972 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
973 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); 973 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
974 } 974 }
975 } 975 }
976} 976}
977 977
978void PlayListWidget::openFile() { 978void PlayListWidget::openFile() {
979 QString filename; 979 QString filename;
980 InputDialog *fileDlg; 980 InputDialog *fileDlg;
981 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 981 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
982 fileDlg->exec(); 982 fileDlg->exec();
983 if( fileDlg->result() == 1 ) { 983 if( fileDlg->result() == 1 ) {
984 filename = fileDlg->LineEdit1->text(); 984 filename = fileDlg->LineEdit1->text();
985 } 985 }
986 qDebug(filename); 986 qDebug(filename);
987 DocLnk lnk; 987 DocLnk lnk;
988 QString name = filename.right(filename.length()-filename.find("http://")-7); 988 QString name = filename.right(filename.length()-filename.find("http://")-7);
989 qDebug(name); 989 qDebug(name);
990 lnk.setName( name); //sets file name 990 lnk.setName( name); //sets file name
991// lnk.setComment(); 991// lnk.setComment();
992 lnk.setFile(filename); //sets File property 992 lnk.setFile(filename); //sets File property
993// problem is, the launcher sees this as a broken link and does not display it :( 993// problem is, the launcher sees this as a broken link and does not display it :(
994 lnk.setType("audio/x-mpegurl"); 994 lnk.setType("audio/x-mpegurl");
995 lnk.setExec("opieplayer"); 995 lnk.setExec("opieplayer");
996 lnk.setIcon("opieplayer/MPEGPlayer"); 996 lnk.setIcon("opieplayer/MPEGPlayer");
997 997
998 if(!lnk.writeLink()) 998 if(!lnk.writeLink())
999 qDebug("Writing doclink did not work"); 999 qDebug("Writing doclink did not work");
1000 d->selectedFiles->addToSelection( lnk); 1000 d->selectedFiles->addToSelection( lnk);
1001 if(fileDlg) 1001 if(fileDlg)
1002 delete fileDlg; 1002 delete fileDlg;
1003} 1003}