-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 795feaf..c6de5e6 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,1494 +1,1494 @@ | |||
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 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/lnkproperties.h> | 28 | #include <qpe/lnkproperties.h> |
29 | #include <qpe/storage.h> | 29 | #include <qpe/storage.h> |
30 | 30 | ||
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qaction.h> | 35 | #include <qaction.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qimage.h> | 37 | #include <qimage.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qlist.h> | 42 | #include <qlist.h> |
43 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
44 | #include <qmainwindow.h> | 44 | #include <qmainwindow.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
47 | #include <qtabwidget.h> | 47 | #include <qtabwidget.h> |
48 | #include <qlistview.h> | 48 | #include <qlistview.h> |
49 | #include <qpoint.h> | 49 | #include <qpoint.h> |
50 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
51 | #include <qpushbutton.h> | 51 | #include <qpushbutton.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qtextstream.h> | 53 | #include <qtextstream.h> |
54 | 54 | ||
55 | //#include <qtimer.h> | 55 | //#include <qtimer.h> |
56 | 56 | ||
57 | #include "playlistselection.h" | 57 | #include "playlistselection.h" |
58 | #include "playlistwidget.h" | 58 | #include "playlistwidget.h" |
59 | #include "mediaplayerstate.h" | 59 | #include "mediaplayerstate.h" |
60 | 60 | ||
61 | #include "inputDialog.h" | 61 | #include "inputDialog.h" |
62 | 62 | ||
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | #include "audiowidget.h" | 64 | #include "audiowidget.h" |
65 | #include "videowidget.h" | 65 | #include "videowidget.h" |
66 | 66 | ||
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #include <sys/file.h> | 68 | #include <sys/file.h> |
69 | #include <sys/ioctl.h> | 69 | #include <sys/ioctl.h> |
70 | #include <sys/soundcard.h> | 70 | #include <sys/soundcard.h> |
71 | 71 | ||
72 | // for setBacklight() | 72 | // for setBacklight() |
73 | #include <linux/fb.h> | 73 | #include <linux/fb.h> |
74 | #include <sys/types.h> | 74 | #include <sys/types.h> |
75 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
76 | #include <stdlib.h> | 76 | #include <stdlib.h> |
77 | 77 | ||
78 | #define BUTTONS_ON_TOOLBAR | 78 | #define BUTTONS_ON_TOOLBAR |
79 | #define SIDE_BUTTONS | 79 | #define SIDE_BUTTONS |
80 | #define CAN_SAVE_LOAD_PLAYLISTS | 80 | #define CAN_SAVE_LOAD_PLAYLISTS |
81 | 81 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | static inline QString fullBaseName ( const QFileInfo &fi ) | 86 | static inline QString fullBaseName ( const QFileInfo &fi ) |
87 | { | 87 | { |
88 | QString str = fi. fileName ( ); | 88 | QString str = fi. fileName ( ); |
89 | return str. left ( str. findRev ( '.' )); | 89 | return str. left ( str. findRev ( '.' )); |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod;audio/x-ogg"; | 93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod;audio/x-ogg"; |
94 | // class myFileSelector { | 94 | // class myFileSelector { |
95 | 95 | ||
96 | // }; | 96 | // }; |
97 | class PlayListWidgetPrivate { | 97 | class PlayListWidgetPrivate { |
98 | public: | 98 | public: |
99 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 99 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
100 | QFrame *playListFrame; | 100 | QFrame *playListFrame; |
101 | FileSelector *files; | 101 | FileSelector *files; |
102 | PlayListSelection *selectedFiles; | 102 | PlayListSelection *selectedFiles; |
103 | bool setDocumentUsed; | 103 | bool setDocumentUsed; |
104 | DocLnk *current; | 104 | DocLnk *current; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
108 | class ToolButton : public QToolButton { | 108 | class ToolButton : public QToolButton { |
109 | public: | 109 | public: |
110 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 110 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
111 | : QToolButton( parent, name ) { | 111 | : QToolButton( parent, name ) { |
112 | setTextLabel( name ); | 112 | setTextLabel( name ); |
113 | setPixmap( Resource::loadPixmap( icon ) ); | 113 | setPixmap( Resource::loadPixmap( icon ) ); |
114 | setAutoRaise( TRUE ); | 114 | setAutoRaise( TRUE ); |
115 | setFocusPolicy( QWidget::NoFocus ); | 115 | setFocusPolicy( QWidget::NoFocus ); |
116 | setToggleButton( t ); | 116 | setToggleButton( t ); |
117 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 117 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
118 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 118 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
119 | } | 119 | } |
120 | }; | 120 | }; |
121 | 121 | ||
122 | 122 | ||
123 | class MenuItem : public QAction { | 123 | class MenuItem : public QAction { |
124 | public: | 124 | public: |
125 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 125 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
126 | : QAction( text, QString::null, 0, 0 ) { | 126 | : QAction( text, QString::null, 0, 0 ) { |
127 | connect( this, SIGNAL( activated() ), handler, slot ); | 127 | connect( this, SIGNAL( activated() ), handler, slot ); |
128 | addTo( parent ); | 128 | addTo( parent ); |
129 | } | 129 | } |
130 | }; | 130 | }; |
131 | 131 | ||
132 | 132 | ||
133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
134 | : QMainWindow( parent, name, fl ) { | 134 | : QMainWindow( parent, name, fl ) { |
135 | 135 | ||
136 | d = new PlayListWidgetPrivate; | 136 | d = new PlayListWidgetPrivate; |
137 | d->setDocumentUsed = FALSE; | 137 | d->setDocumentUsed = FALSE; |
138 | d->current = NULL; | 138 | d->current = NULL; |
139 | fromSetDocument = FALSE; | 139 | fromSetDocument = FALSE; |
140 | insanityBool=FALSE; | 140 | insanityBool=FALSE; |
141 | audioScan = FALSE; | 141 | audioScan = FALSE; |
142 | videoScan = FALSE; | 142 | videoScan = FALSE; |
143 | // menuTimer = new QTimer( this ,"menu timer"), | 143 | // menuTimer = new QTimer( this ,"menu timer"), |
144 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 144 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
145 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | 145 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); |
146 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 146 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
147 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 147 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); |
148 | 148 | ||
149 | setBackgroundMode( PaletteButton ); | 149 | setBackgroundMode( PaletteButton ); |
150 | 150 | ||
151 | setCaption( tr("OpiePlayer") ); | 151 | setCaption( tr("OpiePlayer") ); |
152 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 152 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
153 | 153 | ||
154 | setToolBarsMovable( FALSE ); | 154 | setToolBarsMovable( FALSE ); |
155 | 155 | ||
156 | // Create Toolbar | 156 | // Create Toolbar |
157 | QPEToolBar *toolbar = new QPEToolBar( this ); | 157 | QPEToolBar *toolbar = new QPEToolBar( this ); |
158 | toolbar->setHorizontalStretchable( TRUE ); | 158 | toolbar->setHorizontalStretchable( TRUE ); |
159 | 159 | ||
160 | // Create Menubar | 160 | // Create Menubar |
161 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 161 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
162 | menu->setMargin( 0 ); | 162 | menu->setMargin( 0 ); |
163 | 163 | ||
164 | QPEToolBar *bar = new QPEToolBar( this ); | 164 | QPEToolBar *bar = new QPEToolBar( this ); |
165 | bar->setLabel( tr( "Play Operations" ) ); | 165 | bar->setLabel( tr( "Play Operations" ) ); |
166 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 166 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
167 | // this , SLOT( addSelected()) ); | 167 | // this , SLOT( addSelected()) ); |
168 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 168 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
169 | tbDeletePlaylist->setFlat(TRUE); | 169 | tbDeletePlaylist->setFlat(TRUE); |
170 | 170 | ||
171 | tbDeletePlaylist->setFixedSize(20,20); | 171 | tbDeletePlaylist->setFixedSize(20,20); |
172 | 172 | ||
173 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 173 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
174 | this , SLOT(addSelected()) ); | 174 | this , SLOT(addSelected()) ); |
175 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 175 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
176 | this , SLOT(removeSelected()) ); | 176 | this , SLOT(removeSelected()) ); |
177 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 177 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
178 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 178 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
179 | this , SLOT( btnPlay(bool) ), TRUE ); | 179 | this , SLOT( btnPlay(bool) ), TRUE ); |
180 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 180 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
181 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 181 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
182 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 182 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
183 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 183 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
184 | tbDeletePlaylist->hide(); | 184 | tbDeletePlaylist->hide(); |
185 | 185 | ||
186 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 186 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
187 | menu->insertItem( tr( "File" ), pmPlayList ); | 187 | menu->insertItem( tr( "File" ), pmPlayList ); |
188 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 188 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
189 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 189 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
190 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 190 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
191 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 191 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
192 | pmPlayList->insertSeparator(-1); | 192 | pmPlayList->insertSeparator(-1); |
193 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 193 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
194 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 194 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
195 | pmPlayList->insertSeparator(-1); | 195 | pmPlayList->insertSeparator(-1); |
196 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 196 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
197 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 197 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
198 | 198 | ||
199 | QPopupMenu *pmView = new QPopupMenu( this ); | 199 | QPopupMenu *pmView = new QPopupMenu( this ); |
200 | menu->insertItem( tr( "View" ), pmView ); | 200 | menu->insertItem( tr( "View" ), pmView ); |
201 | 201 | ||
202 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 202 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
203 | fullScreenButton->addTo(pmView); | 203 | fullScreenButton->addTo(pmView); |
204 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 204 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
205 | scaleButton->addTo(pmView); | 205 | scaleButton->addTo(pmView); |
206 | 206 | ||
207 | 207 | ||
208 | skinsMenu = new QPopupMenu( this ); | 208 | skinsMenu = new QPopupMenu( this ); |
209 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 209 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
210 | skinsMenu->isCheckable(); | 210 | skinsMenu->isCheckable(); |
211 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 211 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
212 | this, SLOT( skinsMenuActivated( int ) ) ); | 212 | this, SLOT( skinsMenuActivated( int ) ) ); |
213 | populateSkinsMenu(); | 213 | populateSkinsMenu(); |
214 | 214 | ||
215 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 215 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
216 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 216 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
217 | 217 | ||
218 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 218 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
219 | 219 | ||
220 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 220 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
221 | // tabWidget->setTabShape(QTabWidget::Triangular); | 221 | // tabWidget->setTabShape(QTabWidget::Triangular); |
222 | 222 | ||
223 | QWidget *pTab; | 223 | QWidget *pTab; |
224 | pTab = new QWidget( tabWidget, "pTab" ); | 224 | pTab = new QWidget( tabWidget, "pTab" ); |
225 | // playlistView = new QListView( pTab, "playlistview" ); | 225 | // playlistView = new QListView( pTab, "playlistview" ); |
226 | // playlistView->setMinimumSize(236,260); | 226 | // playlistView->setMinimumSize(236,260); |
227 | tabWidget->insertTab( pTab,"Playlist"); | 227 | tabWidget->insertTab( pTab,"Playlist"); |
228 | 228 | ||
229 | 229 | ||
230 | // Add the playlist area | 230 | // Add the playlist area |
231 | 231 | ||
232 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 232 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
233 | d->playListFrame = vbox3; | 233 | d->playListFrame = vbox3; |
234 | 234 | ||
235 | QGridLayout *layoutF = new QGridLayout( pTab ); | 235 | QGridLayout *layoutF = new QGridLayout( pTab ); |
236 | layoutF->setSpacing( 2); | 236 | layoutF->setSpacing( 2); |
237 | layoutF->setMargin( 2); | 237 | layoutF->setMargin( 2); |
238 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); | 238 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); |
239 | 239 | ||
240 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 240 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
241 | 241 | ||
242 | d->selectedFiles = new PlayListSelection( hbox2); | 242 | d->selectedFiles = new PlayListSelection( hbox2); |
243 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 243 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
244 | 244 | ||
245 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 245 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
246 | 246 | ||
247 | 247 | ||
248 | 248 | ||
249 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 249 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
250 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 250 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
251 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 251 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
252 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 252 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
253 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 253 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
254 | 254 | ||
255 | QWidget *aTab; | 255 | QWidget *aTab; |
256 | aTab = new QWidget( tabWidget, "aTab" ); | 256 | aTab = new QWidget( tabWidget, "aTab" ); |
257 | audioView = new QListView( aTab, "Audioview" ); | 257 | audioView = new QListView( aTab, "Audioview" ); |
258 | 258 | ||
259 | QGridLayout *layoutA = new QGridLayout( aTab ); | 259 | QGridLayout *layoutA = new QGridLayout( aTab ); |
260 | layoutA->setSpacing( 2); | 260 | layoutA->setSpacing( 2); |
261 | layoutA->setMargin( 2); | 261 | layoutA->setMargin( 2); |
262 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 262 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
263 | 263 | ||
264 | audioView->addColumn( tr("Title"),-1); | 264 | audioView->addColumn( tr("Title"),-1); |
265 | audioView->addColumn(tr("Size"), -1); | 265 | audioView->addColumn(tr("Size"), -1); |
266 | audioView->addColumn(tr("Media"),-1); | 266 | audioView->addColumn(tr("Media"),-1); |
267 | audioView->addColumn( tr( "Path" ), -1 ); | 267 | audioView->addColumn( tr( "Path" ), -1 ); |
268 | 268 | ||
269 | audioView->setColumnAlignment(1, Qt::AlignRight); | 269 | audioView->setColumnAlignment(1, Qt::AlignRight); |
270 | audioView->setColumnAlignment(2, Qt::AlignRight); | 270 | audioView->setColumnAlignment(2, Qt::AlignRight); |
271 | audioView->setAllColumnsShowFocus(TRUE); | 271 | audioView->setAllColumnsShowFocus(TRUE); |
272 | 272 | ||
273 | audioView->setMultiSelection( TRUE ); | 273 | audioView->setMultiSelection( TRUE ); |
274 | audioView->setSelectionMode( QListView::Extended); | 274 | audioView->setSelectionMode( QListView::Extended); |
275 | audioView->setSorting( 3, TRUE ); | 275 | audioView->setSorting( 3, TRUE ); |
276 | 276 | ||
277 | tabWidget->insertTab(aTab,tr("Audio")); | 277 | tabWidget->insertTab(aTab,tr("Audio")); |
278 | 278 | ||
279 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 279 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
280 | 280 | ||
281 | // audioView | 281 | // audioView |
282 | // populateAudioView(); | 282 | // populateAudioView(); |
283 | // videowidget | 283 | // videowidget |
284 | 284 | ||
285 | QWidget *vTab; | 285 | QWidget *vTab; |
286 | vTab = new QWidget( tabWidget, "vTab" ); | 286 | vTab = new QWidget( tabWidget, "vTab" ); |
287 | videoView = new QListView( vTab, "Videoview" ); | 287 | videoView = new QListView( vTab, "Videoview" ); |
288 | 288 | ||
289 | QGridLayout *layoutV = new QGridLayout( vTab ); | 289 | QGridLayout *layoutV = new QGridLayout( vTab ); |
290 | layoutV->setSpacing( 2); | 290 | layoutV->setSpacing( 2); |
291 | layoutV->setMargin( 2); | 291 | layoutV->setMargin( 2); |
292 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 292 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
293 | 293 | ||
294 | videoView->addColumn(tr("Title"),-1); | 294 | videoView->addColumn(tr("Title"),-1); |
295 | videoView->addColumn(tr("Size"),-1); | 295 | videoView->addColumn(tr("Size"),-1); |
296 | videoView->addColumn(tr("Media"),-1); | 296 | videoView->addColumn(tr("Media"),-1); |
297 | videoView->addColumn(tr( "Path" ), -1 ); | 297 | videoView->addColumn(tr( "Path" ), -1 ); |
298 | videoView->setColumnAlignment(1, Qt::AlignRight); | 298 | videoView->setColumnAlignment(1, Qt::AlignRight); |
299 | videoView->setColumnAlignment(2, Qt::AlignRight); | 299 | videoView->setColumnAlignment(2, Qt::AlignRight); |
300 | videoView->setAllColumnsShowFocus(TRUE); | 300 | videoView->setAllColumnsShowFocus(TRUE); |
301 | videoView->setMultiSelection( TRUE ); | 301 | videoView->setMultiSelection( TRUE ); |
302 | videoView->setSelectionMode( QListView::Extended); | 302 | videoView->setSelectionMode( QListView::Extended); |
303 | 303 | ||
304 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 304 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
305 | 305 | ||
306 | tabWidget->insertTab( vTab,tr("Video")); | 306 | tabWidget->insertTab( vTab,tr("Video")); |
307 | 307 | ||
308 | QWidget *LTab; | 308 | QWidget *LTab; |
309 | LTab = new QWidget( tabWidget, "LTab" ); | 309 | LTab = new QWidget( tabWidget, "LTab" ); |
310 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 310 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
311 | 311 | ||
312 | QGridLayout *layoutL = new QGridLayout( LTab ); | 312 | QGridLayout *layoutL = new QGridLayout( LTab ); |
313 | layoutL->setSpacing( 2); | 313 | layoutL->setSpacing( 2); |
314 | layoutL->setMargin( 2); | 314 | layoutL->setMargin( 2); |
315 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 315 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
316 | // playLists->setMinimumSize(233,260); | 316 | // playLists->setMinimumSize(233,260); |
317 | 317 | ||
318 | tabWidget->insertTab(LTab,tr("Lists")); | 318 | tabWidget->insertTab(LTab,tr("Lists")); |
319 | 319 | ||
320 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 320 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
321 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 321 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
322 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 322 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
323 | 323 | ||
324 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 324 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
325 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 325 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
326 | 326 | ||
327 | 327 | ||
328 | ///audioView | 328 | ///audioView |
329 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 329 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
330 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 330 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
331 | 331 | ||
332 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 332 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
333 | this,SLOT( playIt( QListViewItem *)) ); | 333 | this,SLOT( playIt( QListViewItem *)) ); |
334 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 334 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
335 | 335 | ||
336 | 336 | ||
337 | //videoView | 337 | //videoView |
338 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 338 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
339 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 339 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
340 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 340 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
341 | this,SLOT( playIt( QListViewItem *)) ); | 341 | this,SLOT( playIt( QListViewItem *)) ); |
342 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 342 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
343 | 343 | ||
344 | //playlists | 344 | //playlists |
345 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 345 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
346 | 346 | ||
347 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 347 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
348 | 348 | ||
349 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 349 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
350 | 350 | ||
351 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 351 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
352 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 352 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
353 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 353 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
354 | 354 | ||
355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
356 | 356 | ||
357 | setCentralWidget( vbox5 ); | 357 | setCentralWidget( vbox5 ); |
358 | 358 | ||
359 | Config cfg( "OpiePlayer" ); | 359 | Config cfg( "OpiePlayer" ); |
360 | readConfig( cfg ); | 360 | readConfig( cfg ); |
361 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 361 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
362 | loadList(DocLnk( currentPlaylist)); | 362 | loadList(DocLnk( currentPlaylist)); |
363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); | 363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); |
364 | 364 | ||
365 | initializeStates(); | 365 | initializeStates(); |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | PlayListWidget::~PlayListWidget() { | 369 | PlayListWidget::~PlayListWidget() { |
370 | Config cfg( "OpiePlayer" ); | 370 | Config cfg( "OpiePlayer" ); |
371 | writeConfig( cfg ); | 371 | writeConfig( cfg ); |
372 | 372 | ||
373 | if ( d->current ) | 373 | if ( d->current ) |
374 | delete d->current; | 374 | delete d->current; |
375 | delete d; | 375 | delete d; |
376 | } | 376 | } |
377 | 377 | ||
378 | 378 | ||
379 | void PlayListWidget::initializeStates() { | 379 | void PlayListWidget::initializeStates() { |
380 | 380 | ||
381 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 381 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
382 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 382 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
383 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 383 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
384 | setPlaylist( true); | 384 | setPlaylist( true); |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | void PlayListWidget::readConfig( Config& cfg ) { | 388 | void PlayListWidget::readConfig( Config& cfg ) { |
389 | cfg.setGroup("PlayList"); | 389 | cfg.setGroup("PlayList"); |
390 | QString currentString = cfg.readEntry("current", "" ); | 390 | QString currentString = cfg.readEntry("current", "" ); |
391 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 391 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
392 | for ( int i = 0; i < noOfFiles; i++ ) { | 392 | for ( int i = 0; i < noOfFiles; i++ ) { |
393 | QString entryName; | 393 | QString entryName; |
394 | entryName.sprintf( "File%i", i + 1 ); | 394 | entryName.sprintf( "File%i", i + 1 ); |
395 | QString linkFile = cfg.readEntry( entryName ); | 395 | QString linkFile = cfg.readEntry( entryName ); |
396 | DocLnk lnk( linkFile ); | 396 | DocLnk lnk( linkFile ); |
397 | if ( lnk.isValid() ) { | 397 | if ( lnk.isValid() ) { |
398 | d->selectedFiles->addToSelection( lnk ); | 398 | d->selectedFiles->addToSelection( lnk ); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | d->selectedFiles->setSelectedItem( currentString); | 401 | d->selectedFiles->setSelectedItem( currentString); |
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | void PlayListWidget::writeConfig( Config& cfg ) const { | 405 | void PlayListWidget::writeConfig( Config& cfg ) const { |
406 | 406 | ||
407 | d->selectedFiles->writeCurrent( cfg); | 407 | d->selectedFiles->writeCurrent( cfg); |
408 | cfg.setGroup("PlayList"); | 408 | cfg.setGroup("PlayList"); |
409 | int noOfFiles = 0; | 409 | int noOfFiles = 0; |
410 | d->selectedFiles->first(); | 410 | d->selectedFiles->first(); |
411 | do { | 411 | do { |
412 | const DocLnk *lnk = d->selectedFiles->current(); | 412 | const DocLnk *lnk = d->selectedFiles->current(); |
413 | if ( lnk ) { | 413 | if ( lnk ) { |
414 | QString entryName; | 414 | QString entryName; |
415 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 415 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
416 | // qDebug(entryName); | 416 | // qDebug(entryName); |
417 | cfg.writeEntry( entryName, lnk->linkFile() ); | 417 | cfg.writeEntry( entryName, lnk->linkFile() ); |
418 | // if this link does exist, add it so we have the file | 418 | // if this link does exist, add it so we have the file |
419 | // next time... | 419 | // next time... |
420 | if ( !QFile::exists( lnk->linkFile() ) ) { | 420 | if ( !QFile::exists( lnk->linkFile() ) ) { |
421 | // the way writing lnks doesn't really check for out | 421 | // the way writing lnks doesn't really check for out |
422 | // of disk space, but check it anyway. | 422 | // of disk space, but check it anyway. |
423 | if ( !lnk->writeLink() ) { | 423 | if ( !lnk->writeLink() ) { |
424 | QMessageBox::critical( 0, tr("Out of space"), | 424 | QMessageBox::critical( 0, tr("Out of space"), |
425 | tr( "There was a problem saving " | 425 | tr( "There was a problem saving " |
426 | "the playlist.\n" | 426 | "the playlist.\n" |
427 | "Your playlist " | 427 | "Your playlist " |
428 | "may be missing some entries\n" | 428 | "may be missing some entries\n" |
429 | "the next time you start it." ) | 429 | "the next time you start it." ) |
430 | ); | 430 | ); |
431 | } | 431 | } |
432 | } | 432 | } |
433 | noOfFiles++; | 433 | noOfFiles++; |
434 | } | 434 | } |
435 | } | 435 | } |
436 | while ( d->selectedFiles->next() ); | 436 | while ( d->selectedFiles->next() ); |
437 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 437 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 441 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
442 | d->setDocumentUsed = false; | 442 | d->setDocumentUsed = false; |
443 | if ( mediaPlayerState->playlist() ) { | 443 | if ( mediaPlayerState->playlist() ) { |
444 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 444 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
445 | d->selectedFiles->addToSelection( lnk ); | 445 | d->selectedFiles->addToSelection( lnk ); |
446 | } | 446 | } |
447 | else | 447 | else |
448 | mediaPlayerState->setPlaying( true); | 448 | mediaPlayerState->setPlaying( true); |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | void PlayListWidget::clearList() { | 452 | void PlayListWidget::clearList() { |
453 | while ( first() ) | 453 | while ( first() ) |
454 | d->selectedFiles->removeSelected(); | 454 | d->selectedFiles->removeSelected(); |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | void PlayListWidget::addAllToList() { | 458 | void PlayListWidget::addAllToList() { |
459 | DocLnkSet filesAll; | 459 | DocLnkSet filesAll; |
460 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 460 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
461 | QListIterator<DocLnk> Adit( filesAll.children() ); | 461 | QListIterator<DocLnk> Adit( filesAll.children() ); |
462 | for ( ; Adit.current(); ++Adit ) | 462 | for ( ; Adit.current(); ++Adit ) |
463 | if(QFileInfo(Adit.current()->file()).exists()) | 463 | if(QFileInfo(Adit.current()->file()).exists()) |
464 | d->selectedFiles->addToSelection( **Adit ); | 464 | d->selectedFiles->addToSelection( **Adit ); |
465 | tabWidget->setCurrentPage(0); | 465 | tabWidget->setCurrentPage(0); |
466 | 466 | ||
467 | writeCurrentM3u(); | 467 | writeCurrentM3u(); |
468 | d->selectedFiles->first(); | 468 | d->selectedFiles->first(); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | void PlayListWidget::addAllMusicToList() { | 472 | void PlayListWidget::addAllMusicToList() { |
473 | QListIterator<DocLnk> dit( files.children() ); | 473 | QListIterator<DocLnk> dit( files.children() ); |
474 | for ( ; dit.current(); ++dit ) | 474 | for ( ; dit.current(); ++dit ) |
475 | if(QFileInfo(dit.current()->file()).exists()) | 475 | if(QFileInfo(dit.current()->file()).exists()) |
476 | d->selectedFiles->addToSelection( **dit ); | 476 | d->selectedFiles->addToSelection( **dit ); |
477 | tabWidget->setCurrentPage(0); | 477 | tabWidget->setCurrentPage(0); |
478 | 478 | ||
479 | writeCurrentM3u(); | 479 | writeCurrentM3u(); |
480 | d->selectedFiles->first(); | 480 | d->selectedFiles->first(); |
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | void PlayListWidget::addAllVideoToList() { | 484 | void PlayListWidget::addAllVideoToList() { |
485 | QListIterator<DocLnk> dit( vFiles.children() ); | 485 | QListIterator<DocLnk> dit( vFiles.children() ); |
486 | for ( ; dit.current(); ++dit ) | 486 | for ( ; dit.current(); ++dit ) |
487 | if(QFileInfo( dit.current()->file()).exists()) | 487 | if(QFileInfo( dit.current()->file()).exists()) |
488 | d->selectedFiles->addToSelection( **dit ); | 488 | d->selectedFiles->addToSelection( **dit ); |
489 | tabWidget->setCurrentPage(0); | 489 | tabWidget->setCurrentPage(0); |
490 | 490 | ||
491 | writeCurrentM3u(); | 491 | writeCurrentM3u(); |
492 | d->selectedFiles->first(); | 492 | d->selectedFiles->first(); |
493 | } | 493 | } |
494 | 494 | ||
495 | 495 | ||
496 | void PlayListWidget::setDocument(const QString& fileref) { | 496 | void PlayListWidget::setDocument(const QString& fileref) { |
497 | qDebug(fileref); | 497 | qDebug(fileref); |
498 | fromSetDocument = TRUE; | 498 | fromSetDocument = TRUE; |
499 | QFileInfo fileInfo(fileref); | 499 | QFileInfo fileInfo(fileref); |
500 | if ( !fileInfo.exists() ) { | 500 | if ( !fileInfo.exists() ) { |
501 | QMessageBox::critical( 0, tr( "Invalid File" ), | 501 | QMessageBox::critical( 0, tr( "Invalid File" ), |
502 | tr( "There was a problem in getting the file." ) ); | 502 | tr( "There was a problem in getting the file." ) ); |
503 | return; | 503 | return; |
504 | } | 504 | } |
505 | // qDebug("setDocument "+fileref); | 505 | // qDebug("setDocument "+fileref); |
506 | QString extension = fileInfo.extension(false); | 506 | QString extension = fileInfo.extension(false); |
507 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 507 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
508 | readm3u( fileref); | 508 | readm3u( fileref); |
509 | } | 509 | } |
510 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 510 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
511 | readPls( fileref); | 511 | readPls( fileref); |
512 | } | 512 | } |
513 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 513 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
514 | clearList(); | 514 | clearList(); |
515 | DocLnk lnk; | 515 | DocLnk lnk; |
516 | lnk.setName( fileInfo.baseName() ); //sets name | 516 | lnk.setName( fileInfo.baseName() ); //sets name |
517 | lnk.setFile( fileref ); //sets file name | 517 | lnk.setFile( fileref ); //sets file name |
518 | //addToSelection( lnk ); | 518 | //addToSelection( lnk ); |
519 | 519 | ||
520 | loadList( lnk); | 520 | loadList( lnk); |
521 | d->selectedFiles->first(); | 521 | d->selectedFiles->first(); |
522 | } else { | 522 | } else { |
523 | clearList(); | 523 | clearList(); |
524 | DocLnk lnk; | 524 | DocLnk lnk; |
525 | lnk.setName( fileInfo.baseName() ); //sets name | 525 | lnk.setName( fileInfo.baseName() ); //sets name |
526 | lnk.setFile( fileref ); //sets file name | 526 | lnk.setFile( fileref ); //sets file name |
527 | addToSelection( lnk ); | 527 | addToSelection( lnk ); |
528 | // addToSelection( DocLnk( fileref ) ); | 528 | // addToSelection( DocLnk( fileref ) ); |
529 | d->setDocumentUsed = TRUE; | 529 | d->setDocumentUsed = TRUE; |
530 | mediaPlayerState->setPlaying( FALSE ); | 530 | mediaPlayerState->setPlaying( FALSE ); |
531 | qApp->processEvents(); | 531 | qApp->processEvents(); |
532 | mediaPlayerState->setPlaying( TRUE ); | 532 | mediaPlayerState->setPlaying( TRUE ); |
533 | qApp->processEvents(); | 533 | qApp->processEvents(); |
534 | setCaption(tr("OpiePlayer")); | 534 | setCaption(tr("OpiePlayer")); |
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | 538 | ||
539 | void PlayListWidget::setActiveWindow() { | 539 | void PlayListWidget::setActiveWindow() { |
540 | qDebug("SETTING active window"); | 540 | qDebug("SETTING active window"); |
541 | 541 | ||
542 | // When we get raised we need to ensure that it switches views | 542 | // When we get raised we need to ensure that it switches views |
543 | char origView = mediaPlayerState->view(); | 543 | char origView = mediaPlayerState->view(); |
544 | mediaPlayerState->setView( 'l' ); // invalidate | 544 | mediaPlayerState->setView( 'l' ); // invalidate |
545 | mediaPlayerState->setView( origView ); // now switch back | 545 | mediaPlayerState->setView( origView ); // now switch back |
546 | } | 546 | } |
547 | 547 | ||
548 | 548 | ||
549 | void PlayListWidget::useSelectedDocument() { | 549 | void PlayListWidget::useSelectedDocument() { |
550 | d->setDocumentUsed = FALSE; | 550 | d->setDocumentUsed = FALSE; |
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | const DocLnk *PlayListWidget::current() { // this is fugly | 554 | const DocLnk *PlayListWidget::current() { // this is fugly |
555 | 555 | ||
556 | // if( fromSetDocument) { | 556 | // if( fromSetDocument) { |
557 | // qDebug("from setDoc"); | 557 | // qDebug("from setDoc"); |
558 | // DocLnkSet files; | 558 | // DocLnkSet files; |
559 | // Global::findDocuments(&files, "video/*;audio/*"); | 559 | // Global::findDocuments(&files, "video/*;audio/*"); |
560 | // QListIterator<DocLnk> dit( files.children() ); | 560 | // QListIterator<DocLnk> dit( files.children() ); |
561 | // for ( ; dit.current(); ++dit ) { | 561 | // for ( ; dit.current(); ++dit ) { |
562 | // if(dit.current()->linkFile() == setDocFileRef) { | 562 | // if(dit.current()->linkFile() == setDocFileRef) { |
563 | // qDebug(setDocFileRef); | 563 | // qDebug(setDocFileRef); |
564 | // return dit; | 564 | // return dit; |
565 | // } | 565 | // } |
566 | // } | 566 | // } |
567 | // } else | 567 | // } else |
568 | 568 | ||
569 | qDebug("current"); | 569 | qDebug("current"); |
570 | 570 | ||
571 | switch (tabWidget->currentPageIndex()) { | 571 | switch (tabWidget->currentPageIndex()) { |
572 | case 0: //playlist | 572 | case 0: //playlist |
573 | { | 573 | { |
574 | qDebug("playlist"); | 574 | qDebug("playlist"); |
575 | if ( mediaPlayerState->playlist() ) { | 575 | if ( mediaPlayerState->playlist() ) { |
576 | return d->selectedFiles->current(); | 576 | return d->selectedFiles->current(); |
577 | } | 577 | } |
578 | else if ( d->setDocumentUsed && d->current ) { | 578 | else if ( d->setDocumentUsed && d->current ) { |
579 | return d->current; | 579 | return d->current; |
580 | } else { | 580 | } else { |
581 | return &(d->files->selectedDocument()); | 581 | return &(d->files->selectedDocument()); |
582 | } | 582 | } |
583 | } | 583 | } |
584 | break; | 584 | break; |
585 | case 1://audio | 585 | case 1://audio |
586 | { | 586 | { |
587 | qDebug("audioView"); | 587 | qDebug("audioView"); |
588 | QListIterator<DocLnk> dit( files.children() ); | 588 | QListIterator<DocLnk> dit( files.children() ); |
589 | for ( ; dit.current(); ++dit ) { | 589 | for ( ; dit.current(); ++dit ) { |
590 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 590 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
591 | qDebug("here"); | 591 | qDebug("here"); |
592 | insanityBool=TRUE; | 592 | insanityBool=TRUE; |
593 | return dit; | 593 | return dit; |
594 | } | 594 | } |
595 | } | 595 | } |
596 | } | 596 | } |
597 | break; | 597 | break; |
598 | case 2: // video | 598 | case 2: // video |
599 | { | 599 | { |
600 | qDebug("videoView"); | 600 | qDebug("videoView"); |
601 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 601 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
602 | for ( ; Vdit.current(); ++Vdit ) { | 602 | for ( ; Vdit.current(); ++Vdit ) { |
603 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 603 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
604 | insanityBool=TRUE; | 604 | insanityBool=TRUE; |
605 | return Vdit; | 605 | return Vdit; |
606 | } | 606 | } |
607 | } | 607 | } |
608 | } | 608 | } |
609 | break; | 609 | break; |
610 | }; | 610 | }; |
611 | return 0; | 611 | return 0; |
612 | } | 612 | } |
613 | 613 | ||
614 | bool PlayListWidget::prev() { | 614 | bool PlayListWidget::prev() { |
615 | if ( mediaPlayerState->playlist() ) { | 615 | if ( mediaPlayerState->playlist() ) { |
616 | if ( mediaPlayerState->shuffled() ) { | 616 | if ( mediaPlayerState->shuffled() ) { |
617 | const DocLnk *cur = current(); | 617 | const DocLnk *cur = current(); |
618 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 618 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
619 | for ( int i = 0; i < j; i++ ) { | 619 | for ( int i = 0; i < j; i++ ) { |
620 | if ( !d->selectedFiles->next() ) | 620 | if ( !d->selectedFiles->next() ) |
621 | d->selectedFiles->first(); | 621 | d->selectedFiles->first(); |
622 | } | 622 | } |
623 | if ( cur == current() ) | 623 | if ( cur == current() ) |
624 | if ( !d->selectedFiles->next() ) | 624 | if ( !d->selectedFiles->next() ) |
625 | d->selectedFiles->first(); | 625 | d->selectedFiles->first(); |
626 | return TRUE; | 626 | return TRUE; |
627 | } else { | 627 | } else { |
628 | if ( !d->selectedFiles->prev() ) { | 628 | if ( !d->selectedFiles->prev() ) { |
629 | if ( mediaPlayerState->looping() ) { | 629 | if ( mediaPlayerState->looping() ) { |
630 | return d->selectedFiles->last(); | 630 | return d->selectedFiles->last(); |
631 | } else { | 631 | } else { |
632 | return FALSE; | 632 | return FALSE; |
633 | } | 633 | } |
634 | } | 634 | } |
635 | return TRUE; | 635 | return TRUE; |
636 | } | 636 | } |
637 | } else { | 637 | } else { |
638 | return mediaPlayerState->looping(); | 638 | return mediaPlayerState->looping(); |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | 642 | ||
643 | bool PlayListWidget::next() { | 643 | bool PlayListWidget::next() { |
644 | if ( mediaPlayerState->playlist() ) { | 644 | if ( mediaPlayerState->playlist() ) { |
645 | if ( mediaPlayerState->shuffled() ) { | 645 | if ( mediaPlayerState->shuffled() ) { |
646 | return prev(); | 646 | return prev(); |
647 | } else { | 647 | } else { |
648 | if ( !d->selectedFiles->next() ) { | 648 | if ( !d->selectedFiles->next() ) { |
649 | if ( mediaPlayerState->looping() ) { | 649 | if ( mediaPlayerState->looping() ) { |
650 | return d->selectedFiles->first(); | 650 | return d->selectedFiles->first(); |
651 | } else { | 651 | } else { |
652 | return FALSE; | 652 | return FALSE; |
653 | } | 653 | } |
654 | } | 654 | } |
655 | return TRUE; | 655 | return TRUE; |
656 | } | 656 | } |
657 | } else { | 657 | } else { |
658 | return mediaPlayerState->looping(); | 658 | return mediaPlayerState->looping(); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | 661 | ||
662 | 662 | ||
663 | bool PlayListWidget::first() { | 663 | bool PlayListWidget::first() { |
664 | if ( mediaPlayerState->playlist() ) | 664 | if ( mediaPlayerState->playlist() ) |
665 | return d->selectedFiles->first(); | 665 | return d->selectedFiles->first(); |
666 | else | 666 | else |
667 | return mediaPlayerState->looping(); | 667 | return mediaPlayerState->looping(); |
668 | } | 668 | } |
669 | 669 | ||
670 | 670 | ||
671 | bool PlayListWidget::last() { | 671 | bool PlayListWidget::last() { |
672 | if ( mediaPlayerState->playlist() ) | 672 | if ( mediaPlayerState->playlist() ) |
673 | return d->selectedFiles->last(); | 673 | return d->selectedFiles->last(); |
674 | else | 674 | else |
675 | return mediaPlayerState->looping(); | 675 | return mediaPlayerState->looping(); |
676 | } | 676 | } |
677 | 677 | ||
678 | 678 | ||
679 | void PlayListWidget::saveList() { | 679 | void PlayListWidget::saveList() { |
680 | writem3u(); | 680 | writem3u(); |
681 | } | 681 | } |
682 | 682 | ||
683 | void PlayListWidget::loadList( const DocLnk & lnk) { | 683 | void PlayListWidget::loadList( const DocLnk & lnk) { |
684 | QString name = lnk.name(); | 684 | QString name = lnk.name(); |
685 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 685 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
686 | 686 | ||
687 | if( name.length()>0) { | 687 | if( name.length()>0) { |
688 | setCaption("OpiePlayer: "+name); | 688 | setCaption("OpiePlayer: "+name); |
689 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 689 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
690 | clearList(); | 690 | clearList(); |
691 | readm3u(lnk.file()); | 691 | readm3u(lnk.file()); |
692 | tabWidget->setCurrentPage(0); | 692 | tabWidget->setCurrentPage(0); |
693 | } | 693 | } |
694 | } | 694 | } |
695 | 695 | ||
696 | void PlayListWidget::setPlaylist( bool shown ) { | 696 | void PlayListWidget::setPlaylist( bool shown ) { |
697 | if ( shown ) | 697 | if ( shown ) |
698 | d->playListFrame->show(); | 698 | d->playListFrame->show(); |
699 | else | 699 | else |
700 | d->playListFrame->hide(); | 700 | d->playListFrame->hide(); |
701 | } | 701 | } |
702 | 702 | ||
703 | void PlayListWidget::setView( char view ) { | 703 | void PlayListWidget::setView( char view ) { |
704 | if ( view == 'l' ) | 704 | if ( view == 'l' ) |
705 | showMaximized(); | 705 | showMaximized(); |
706 | else | 706 | else |
707 | hide(); | 707 | hide(); |
708 | } | 708 | } |
709 | 709 | ||
710 | void PlayListWidget::addSelected() { | 710 | void PlayListWidget::addSelected() { |
711 | qDebug("addSelected"); | 711 | qDebug("addSelected"); |
712 | DocLnk lnk; | 712 | DocLnk lnk; |
713 | QString filename; | 713 | QString filename; |
714 | switch (tabWidget->currentPageIndex()) { | 714 | switch (tabWidget->currentPageIndex()) { |
715 | 715 | ||
716 | case 0: //playlist | 716 | case 0: //playlist |
717 | return; | 717 | return; |
718 | break; | 718 | break; |
719 | case 1: { //audio | 719 | case 1: { //audio |
720 | QListViewItemIterator it( audioView ); | 720 | QListViewItemIterator it( audioView ); |
721 | for ( ; it.current(); ++it ) { | 721 | for ( ; it.current(); ++it ) { |
722 | if ( it.current()->isSelected() ) { | 722 | if ( it.current()->isSelected() ) { |
723 | filename = it.current()->text(3); | 723 | filename = it.current()->text(3); |
724 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 724 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
725 | lnk.setFile( filename ); //sets file name | 725 | lnk.setFile( filename ); //sets file name |
726 | d->selectedFiles->addToSelection( lnk); | 726 | d->selectedFiles->addToSelection( lnk); |
727 | } | 727 | } |
728 | } | 728 | } |
729 | audioView->clearSelection(); | 729 | audioView->clearSelection(); |
730 | // d->selectedFiles->next(); | 730 | // d->selectedFiles->next(); |
731 | } | 731 | } |
732 | break; | 732 | break; |
733 | 733 | ||
734 | case 2: { // video | 734 | case 2: { // video |
735 | QListViewItemIterator it( videoView ); | 735 | QListViewItemIterator it( videoView ); |
736 | for ( ; it.current(); ++it ) { | 736 | for ( ; it.current(); ++it ) { |
737 | if ( it.current()->isSelected() ) { | 737 | if ( it.current()->isSelected() ) { |
738 | 738 | ||
739 | filename = it.current()->text(3); | 739 | filename = it.current()->text(3); |
740 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 740 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
741 | lnk.setFile( filename ); //sets file name | 741 | lnk.setFile( filename ); //sets file name |
742 | d->selectedFiles->addToSelection( lnk); | 742 | d->selectedFiles->addToSelection( lnk); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | videoView->clearSelection(); | 745 | videoView->clearSelection(); |
746 | } | 746 | } |
747 | break; | 747 | break; |
748 | }; | 748 | }; |
749 | // tabWidget->setCurrentPage(0); | 749 | // tabWidget->setCurrentPage(0); |
750 | writeCurrentM3u(); | 750 | writeCurrentM3u(); |
751 | 751 | ||
752 | } | 752 | } |
753 | 753 | ||
754 | void PlayListWidget::removeSelected() { | 754 | void PlayListWidget::removeSelected() { |
755 | d->selectedFiles->removeSelected( ); | 755 | d->selectedFiles->removeSelected( ); |
756 | } | 756 | } |
757 | 757 | ||
758 | void PlayListWidget::playIt( QListViewItem *) { | 758 | void PlayListWidget::playIt( QListViewItem *) { |
759 | // d->setDocumentUsed = FALSE; | 759 | // d->setDocumentUsed = FALSE; |
760 | // mediaPlayerState->curPosition =0; | 760 | // mediaPlayerState->curPosition =0; |
761 | qDebug("playIt"); | 761 | qDebug("playIt"); |
762 | mediaPlayerState->setPlaying(FALSE); | 762 | mediaPlayerState->setPlaying(FALSE); |
763 | mediaPlayerState->setPlaying(TRUE); | 763 | mediaPlayerState->setPlaying(TRUE); |
764 | d->selectedFiles->unSelect(); | 764 | d->selectedFiles->unSelect(); |
765 | } | 765 | } |
766 | 766 | ||
767 | void PlayListWidget::addToSelection( QListViewItem *it) { | 767 | void PlayListWidget::addToSelection( QListViewItem *it) { |
768 | d->setDocumentUsed = FALSE; | 768 | d->setDocumentUsed = FALSE; |
769 | 769 | ||
770 | if(it) { | 770 | if(it) { |
771 | switch ( tabWidget->currentPageIndex()) { | 771 | switch ( tabWidget->currentPageIndex()) { |
772 | case 0: //playlist | 772 | case 0: //playlist |
773 | return; | 773 | return; |
774 | break; | 774 | break; |
775 | }; | 775 | }; |
776 | // case 1: { | 776 | // case 1: { |
777 | DocLnk lnk; | 777 | DocLnk lnk; |
778 | QString filename; | 778 | QString filename; |
779 | 779 | ||
780 | filename=it->text(3); | 780 | filename=it->text(3); |
781 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 781 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
782 | lnk.setFile( filename ); //sets file name | 782 | lnk.setFile( filename ); //sets file name |
783 | d->selectedFiles->addToSelection( lnk); | 783 | d->selectedFiles->addToSelection( lnk); |
784 | 784 | ||
785 | writeCurrentM3u(); | 785 | writeCurrentM3u(); |
786 | // tabWidget->setCurrentPage(0); | 786 | // tabWidget->setCurrentPage(0); |
787 | 787 | ||
788 | } | 788 | } |
789 | } | 789 | } |
790 | 790 | ||
791 | void PlayListWidget::tabChanged(QWidget *) { | 791 | void PlayListWidget::tabChanged(QWidget *) { |
792 | 792 | ||
793 | switch ( tabWidget->currentPageIndex()) { | 793 | switch ( tabWidget->currentPageIndex()) { |
794 | case 0: | 794 | case 0: |
795 | { | 795 | { |
796 | if( !tbDeletePlaylist->isHidden()) | 796 | if( !tbDeletePlaylist->isHidden()) |
797 | tbDeletePlaylist->hide(); | 797 | tbDeletePlaylist->hide(); |
798 | d->tbRemoveFromList->setEnabled(TRUE); | 798 | d->tbRemoveFromList->setEnabled(TRUE); |
799 | d->tbAddToList->setEnabled(FALSE); | 799 | d->tbAddToList->setEnabled(FALSE); |
800 | } | 800 | } |
801 | break; | 801 | break; |
802 | case 1: | 802 | case 1: |
803 | { | 803 | { |
804 | audioView->clear(); | 804 | audioView->clear(); |
805 | populateAudioView(); | 805 | populateAudioView(); |
806 | 806 | ||
807 | if( !tbDeletePlaylist->isHidden()) | 807 | if( !tbDeletePlaylist->isHidden()) |
808 | tbDeletePlaylist->hide(); | 808 | tbDeletePlaylist->hide(); |
809 | d->tbRemoveFromList->setEnabled(FALSE); | 809 | d->tbRemoveFromList->setEnabled(FALSE); |
810 | d->tbAddToList->setEnabled(TRUE); | 810 | d->tbAddToList->setEnabled(TRUE); |
811 | } | 811 | } |
812 | break; | 812 | break; |
813 | case 2: | 813 | case 2: |
814 | { | 814 | { |
815 | videoView->clear(); | 815 | videoView->clear(); |
816 | populateVideoView(); | 816 | populateVideoView(); |
817 | if( !tbDeletePlaylist->isHidden()) | 817 | if( !tbDeletePlaylist->isHidden()) |
818 | tbDeletePlaylist->hide(); | 818 | tbDeletePlaylist->hide(); |
819 | d->tbRemoveFromList->setEnabled(FALSE); | 819 | d->tbRemoveFromList->setEnabled(FALSE); |
820 | d->tbAddToList->setEnabled(TRUE); | 820 | d->tbAddToList->setEnabled(TRUE); |
821 | } | 821 | } |
822 | break; | 822 | break; |
823 | case 3: | 823 | case 3: |
824 | { | 824 | { |
825 | if( tbDeletePlaylist->isHidden()) | 825 | if( tbDeletePlaylist->isHidden()) |
826 | tbDeletePlaylist->show(); | 826 | tbDeletePlaylist->show(); |
827 | playLists->reread(); | 827 | playLists->reread(); |
828 | } | 828 | } |
829 | break; | 829 | break; |
830 | }; | 830 | }; |
831 | } | 831 | } |
832 | 832 | ||
833 | void PlayListWidget::btnPlay(bool b) { | 833 | void PlayListWidget::btnPlay(bool b) { |
834 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | 834 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); |
835 | // mediaPlayerState->setPlaying(b); | 835 | // mediaPlayerState->setPlaying(b); |
836 | switch ( tabWidget->currentPageIndex()) { | 836 | switch ( tabWidget->currentPageIndex()) { |
837 | case 0: | 837 | case 0: |
838 | { | 838 | { |
839 | qDebug("1"); | 839 | qDebug("1"); |
840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
843 | // } else { | 843 | // } else { |
844 | mediaPlayerState->setPlaying(b); | 844 | mediaPlayerState->setPlaying(b); |
845 | insanityBool=FALSE; | 845 | insanityBool=FALSE; |
846 | qDebug("insanity"); | 846 | qDebug("insanity"); |
847 | // } | 847 | // } |
848 | } | 848 | } |
849 | break; | 849 | break; |
850 | case 1: | 850 | case 1: |
851 | { | 851 | { |
852 | qDebug("2"); | 852 | qDebug("2"); |
853 | // d->selectedFiles->unSelect(); | 853 | // d->selectedFiles->unSelect(); |
854 | addToSelection( audioView->currentItem() ); | 854 | addToSelection( audioView->currentItem() ); |
855 | mediaPlayerState->setPlaying(true); | 855 | mediaPlayerState->setPlaying(true); |
856 | d->selectedFiles->removeSelected( ); | 856 | d->selectedFiles->removeSelected( ); |
857 | d->selectedFiles->unSelect(); | 857 | d->selectedFiles->unSelect(); |
858 | tabWidget->setCurrentPage(1); | 858 | tabWidget->setCurrentPage(1); |
859 | insanityBool=FALSE; | 859 | insanityBool=FALSE; |
860 | }// audioView->clearSelection(); | 860 | }// audioView->clearSelection(); |
861 | break; | 861 | break; |
862 | case 2: | 862 | case 2: |
863 | { | 863 | { |
864 | qDebug("3"); | 864 | qDebug("3"); |
865 | 865 | ||
866 | addToSelection( videoView->currentItem() ); | 866 | addToSelection( videoView->currentItem() ); |
867 | mediaPlayerState->setPlaying(true); | 867 | mediaPlayerState->setPlaying(true); |
868 | // qApp->processEvents(); | 868 | // qApp->processEvents(); |
869 | d->selectedFiles->removeSelected( ); | 869 | d->selectedFiles->removeSelected( ); |
870 | d->selectedFiles->unSelect(); | 870 | d->selectedFiles->unSelect(); |
871 | tabWidget->setCurrentPage(2); | 871 | tabWidget->setCurrentPage(2); |
872 | insanityBool=FALSE; | 872 | insanityBool=FALSE; |
873 | }// videoView->clearSelection(); | 873 | }// videoView->clearSelection(); |
874 | break; | 874 | break; |
875 | }; | 875 | }; |
876 | 876 | ||
877 | } | 877 | } |
878 | 878 | ||
879 | void PlayListWidget::deletePlaylist() { | 879 | void PlayListWidget::deletePlaylist() { |
880 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 880 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
881 | (tr("You really want to delete\nthis playlist?")), | 881 | (tr("You really want to delete\nthis playlist?")), |
882 | (tr("Yes")), (tr("No")), 0 )){ | 882 | (tr("Yes")), (tr("No")), 0 )){ |
883 | case 0: // Yes clicked, | 883 | case 0: // Yes clicked, |
884 | QFile().remove(playLists->selectedDocument().file()); | 884 | QFile().remove(playLists->selectedDocument().file()); |
885 | QFile().remove(playLists->selectedDocument().linkFile()); | 885 | QFile().remove(playLists->selectedDocument().linkFile()); |
886 | playLists->reread(); | 886 | playLists->reread(); |
887 | break; | 887 | break; |
888 | case 1: // Cancel | 888 | case 1: // Cancel |
889 | break; | 889 | break; |
890 | }; | 890 | }; |
891 | } | 891 | } |
892 | 892 | ||
893 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 893 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
894 | { | 894 | { |
895 | switch (mouse) { | 895 | switch (mouse) { |
896 | case 1: | 896 | case 1: |
897 | break; | 897 | break; |
898 | case 2:{ | 898 | case 2:{ |
899 | 899 | ||
900 | QPopupMenu m; | 900 | QPopupMenu m; |
901 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 901 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
902 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 902 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
903 | m.insertSeparator(); | 903 | m.insertSeparator(); |
904 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 904 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
905 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 905 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
906 | 906 | ||
907 | m.exec( QCursor::pos() ); | 907 | m.exec( QCursor::pos() ); |
908 | } | 908 | } |
909 | break; | 909 | break; |
910 | }; | 910 | }; |
911 | } | 911 | } |
912 | 912 | ||
913 | void PlayListWidget::playSelected() | 913 | void PlayListWidget::playSelected() |
914 | { | 914 | { |
915 | qDebug("playSelected"); | 915 | qDebug("playSelected"); |
916 | btnPlay( true); | 916 | btnPlay( true); |
917 | // d->selectedFiles->unSelect(); | 917 | // d->selectedFiles->unSelect(); |
918 | } | 918 | } |
919 | 919 | ||
920 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 920 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
921 | { | 921 | { |
922 | switch (mouse) { | 922 | switch (mouse) { |
923 | case 1: | 923 | case 1: |
924 | 924 | ||
925 | break; | 925 | break; |
926 | case 2:{ | 926 | case 2:{ |
927 | QPopupMenu m; | 927 | QPopupMenu m; |
928 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 928 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
929 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 929 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
930 | // m.insertSeparator(); | 930 | // m.insertSeparator(); |
931 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 931 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
932 | m.exec( QCursor::pos() ); | 932 | m.exec( QCursor::pos() ); |
933 | } | 933 | } |
934 | break; | 934 | break; |
935 | }; | 935 | }; |
936 | 936 | ||
937 | } | 937 | } |
938 | 938 | ||
939 | void PlayListWidget::listDelete() { | 939 | void PlayListWidget::listDelete() { |
940 | Config cfg( "OpiePlayer" ); | 940 | Config cfg( "OpiePlayer" ); |
941 | cfg.setGroup("PlayList"); | 941 | cfg.setGroup("PlayList"); |
942 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 942 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
943 | QString file; | 943 | QString file; |
944 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 944 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
945 | switch ( tabWidget->currentPageIndex()) { | 945 | switch ( tabWidget->currentPageIndex()) { |
946 | case 0: | 946 | case 0: |
947 | break; | 947 | break; |
948 | case 1: | 948 | case 1: |
949 | { | 949 | { |
950 | file = audioView->currentItem()->text(0); | 950 | file = audioView->currentItem()->text(0); |
951 | QListIterator<DocLnk> Pdit( files.children() ); | 951 | QListIterator<DocLnk> Pdit( files.children() ); |
952 | for ( ; Pdit.current(); ++Pdit ) { | 952 | for ( ; Pdit.current(); ++Pdit ) { |
953 | if( Pdit.current()->name() == file) { | 953 | if( Pdit.current()->name() == file) { |
954 | LnkProperties prop( Pdit.current() ); | 954 | LnkProperties prop( Pdit.current() ); |
955 | prop.showMaximized(); | 955 | prop.showMaximized(); |
956 | prop.exec(); | 956 | prop.exec(); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | populateAudioView(); | 959 | populateAudioView(); |
960 | } | 960 | } |
961 | break; | 961 | break; |
962 | case 2: | 962 | case 2: |
963 | { | 963 | { |
964 | // file = videoView->selectedItem()->text(0); | 964 | // file = videoView->selectedItem()->text(0); |
965 | // for ( int i = 0; i < noOfFiles; i++ ) { | 965 | // for ( int i = 0; i < noOfFiles; i++ ) { |
966 | // QString entryName; | 966 | // QString entryName; |
967 | // entryName.sprintf( "File%i", i + 1 ); | 967 | // entryName.sprintf( "File%i", i + 1 ); |
968 | // QString linkFile = cfg.readEntry( entryName ); | 968 | // QString linkFile = cfg.readEntry( entryName ); |
969 | // AppLnk lnk( AppLnk(linkFile)); | 969 | // AppLnk lnk( AppLnk(linkFile)); |
970 | // if( lnk.name() == file ) { | 970 | // if( lnk.name() == file ) { |
971 | // LnkProperties prop( &lnk); | 971 | // LnkProperties prop( &lnk); |
972 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 972 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
973 | // prop.showMaximized(); | 973 | // prop.showMaximized(); |
974 | // prop.exec(); | 974 | // prop.exec(); |
975 | // } | 975 | // } |
976 | // } | 976 | // } |
977 | } | 977 | } |
978 | break; | 978 | break; |
979 | }; | 979 | }; |
980 | } | 980 | } |
981 | 981 | ||
982 | void PlayListWidget::scanForAudio() { | 982 | void PlayListWidget::scanForAudio() { |
983 | // qDebug("scan for audio"); | 983 | // qDebug("scan for audio"); |
984 | files.detachChildren(); | 984 | files.detachChildren(); |
985 | QListIterator<DocLnk> sdit( files.children() ); | 985 | QListIterator<DocLnk> sdit( files.children() ); |
986 | for ( ; sdit.current(); ++sdit ) { | 986 | for ( ; sdit.current(); ++sdit ) { |
987 | delete sdit.current(); | 987 | delete sdit.current(); |
988 | } | 988 | } |
989 | Global::findDocuments( &files, audioMimes); | 989 | Global::findDocuments( &files, audioMimes); |
990 | audioScan = true; | 990 | audioScan = true; |
991 | } | 991 | } |
992 | void PlayListWidget::scanForVideo() { | 992 | void PlayListWidget::scanForVideo() { |
993 | // qDebug("scan for video"); | 993 | // qDebug("scan for video"); |
994 | vFiles.detachChildren(); | 994 | vFiles.detachChildren(); |
995 | QListIterator<DocLnk> sdit( vFiles.children() ); | 995 | QListIterator<DocLnk> sdit( vFiles.children() ); |
996 | for ( ; sdit.current(); ++sdit ) { | 996 | for ( ; sdit.current(); ++sdit ) { |
997 | delete sdit.current(); | 997 | delete sdit.current(); |
998 | } | 998 | } |
999 | Global::findDocuments(&vFiles, "video/*"); | 999 | Global::findDocuments(&vFiles, "video/*"); |
1000 | videoScan = true; | 1000 | videoScan = true; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void PlayListWidget::populateAudioView() { | 1003 | void PlayListWidget::populateAudioView() { |
1004 | 1004 | ||
1005 | audioView->clear(); | 1005 | audioView->clear(); |
1006 | StorageInfo storageInfo; | 1006 | StorageInfo storageInfo; |
1007 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1007 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1008 | if(!audioScan) scanForAudio(); | 1008 | if(!audioScan) scanForAudio(); |
1009 | 1009 | ||
1010 | QListIterator<DocLnk> dit( files.children() ); | 1010 | QListIterator<DocLnk> dit( files.children() ); |
1011 | QListIterator<FileSystem> it ( fs ); | 1011 | QListIterator<FileSystem> it ( fs ); |
1012 | 1012 | ||
1013 | QString storage; | 1013 | QString storage; |
1014 | for ( ; dit.current(); ++dit ) { | 1014 | for ( ; dit.current(); ++dit ) { |
1015 | for( ; it.current(); ++it ){ | 1015 | for( ; it.current(); ++it ){ |
1016 | const QString name = (*it)->name(); | 1016 | const QString name = (*it)->name(); |
1017 | const QString path = (*it)->path(); | 1017 | const QString path = (*it)->path(); |
1018 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1018 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | QListViewItem * newItem; | 1021 | QListViewItem * newItem; |
1022 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 1022 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1023 | long size; | 1023 | long size; |
1024 | if( dit.current()->file().left(4) == "http" ) | 1024 | if( dit.current()->file().left(4) == "http" ) |
1025 | size=0; | 1025 | size=0; |
1026 | else | 1026 | else |
1027 | size = QFile( dit.current()->file() ).size(); | 1027 | size = QFile( dit.current()->file() ).size(); |
1028 | // qDebug(dit.current()->name()); | 1028 | // qDebug(dit.current()->name()); |
1029 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1029 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1030 | QString::number(size ), storage, dit.current()->file()); | 1030 | QString::number(size ), storage, dit.current()->file()); |
1031 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1031 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1032 | } | 1032 | } |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | void PlayListWidget::populateVideoView() { | 1037 | void PlayListWidget::populateVideoView() { |
1038 | videoView->clear(); | 1038 | videoView->clear(); |
1039 | StorageInfo storageInfo; | 1039 | StorageInfo storageInfo; |
1040 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1040 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1041 | 1041 | ||
1042 | if(!videoScan ) scanForVideo(); | 1042 | if(!videoScan ) scanForVideo(); |
1043 | 1043 | ||
1044 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1044 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1045 | QListIterator<FileSystem> it ( fs ); | 1045 | QListIterator<FileSystem> it ( fs ); |
1046 | videoView->clear(); | 1046 | videoView->clear(); |
1047 | QString storage; | 1047 | QString storage; |
1048 | for ( ; Vdit.current(); ++Vdit ) { | 1048 | for ( ; Vdit.current(); ++Vdit ) { |
1049 | for( ; it.current(); ++it ){ | 1049 | for( ; it.current(); ++it ){ |
1050 | const QString name = (*it)->name(); | 1050 | const QString name = (*it)->name(); |
1051 | const QString path = (*it)->path(); | 1051 | const QString path = (*it)->path(); |
1052 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1052 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | QListViewItem * newItem; | 1055 | QListViewItem * newItem; |
1056 | if ( QFile( Vdit.current()->file()).exists() ) { | 1056 | if ( QFile( Vdit.current()->file()).exists() ) { |
1057 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1057 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1058 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1058 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1059 | storage, Vdit.current()->file()); | 1059 | storage, Vdit.current()->file()); |
1060 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1060 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1061 | } | 1061 | } |
1062 | } | 1062 | } |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | void PlayListWidget::openFile() { | 1065 | void PlayListWidget::openFile() { |
1066 | qDebug("<<<<<<<<<OPEN File"); | 1066 | qDebug("<<<<<<<<<OPEN File"); |
1067 | QString filename, name; | 1067 | QString filename, name; |
1068 | InputDialog *fileDlg; | 1068 | InputDialog *fileDlg; |
1069 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1069 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1070 | fileDlg->exec(); | 1070 | fileDlg->exec(); |
1071 | if( fileDlg->result() == 1 ) { | 1071 | if( fileDlg->result() == 1 ) { |
1072 | filename = fileDlg->text(); | 1072 | filename = fileDlg->text(); |
1073 | qDebug( "Selected filename is " + filename ); | 1073 | qDebug( "Selected filename is " + filename ); |
1074 | // Om3u *m3uList; | 1074 | // Om3u *m3uList; |
1075 | DocLnk lnk; | 1075 | DocLnk lnk; |
1076 | Config cfg( "OpiePlayer" ); | 1076 | Config cfg( "OpiePlayer" ); |
1077 | cfg.setGroup("PlayList"); | 1077 | cfg.setGroup("PlayList"); |
1078 | 1078 | ||
1079 | QString m3uFile; | 1079 | QString m3uFile; |
1080 | m3uFile = filename; | 1080 | m3uFile = filename; |
1081 | if(filename.left(4) == "http") { | 1081 | if(filename.left(4) == "http") { |
1082 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1082 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1083 | 1083 | ||
1084 | // m3uFile = filename.left( filename.find( ":",8,TRUE)); | 1084 | // m3uFile = filename.left( filename.find( ":",8,TRUE)); |
1085 | m3uFile = filename; | 1085 | m3uFile = filename; |
1086 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1086 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1087 | m3uFile += "/"; | 1087 | m3uFile += "/"; |
1088 | } | 1088 | } |
1089 | filename = m3uFile; | 1089 | filename = m3uFile; |
1090 | // qDebug("1 "+m3uFile); | 1090 | // qDebug("1 "+m3uFile); |
1091 | // } else if(filename.left(4) == "http"){ | 1091 | // } else if(filename.left(4) == "http"){ |
1092 | // m3uFile=filename; | 1092 | // m3uFile=filename; |
1093 | // m3uFile = m3uFile.right( m3uFile.length() - 7); | 1093 | // m3uFile = m3uFile.right( m3uFile.length() - 7); |
1094 | // qDebug("2 "+m3uFile); | 1094 | // qDebug("2 "+m3uFile); |
1095 | // } else{ | 1095 | // } else{ |
1096 | // m3uFile=filename; | 1096 | // m3uFile=filename; |
1097 | // qDebug("3 "+m3uFile); | 1097 | // qDebug("3 "+m3uFile); |
1098 | } | 1098 | } |
1099 | lnk.setName( m3uFile ); //sets name | 1099 | lnk.setName( m3uFile ); //sets name |
1100 | lnk.setFile( filename ); //sets file name | 1100 | lnk.setFile( filename ); //sets file name |
1101 | lnk.setIcon("opieplayer2/musicfile"); | 1101 | lnk.setIcon("opieplayer2/musicfile"); |
1102 | d->selectedFiles->addToSelection( lnk ); | 1102 | d->selectedFiles->addToSelection( lnk ); |
1103 | writeCurrentM3u(); | 1103 | writeCurrentM3u(); |
1104 | } | 1104 | } |
1105 | else if( filename.right( 3) == "m3u" ) { | 1105 | else if( filename.right( 3) == "m3u" ) { |
1106 | readm3u( filename ); | 1106 | readm3u( filename ); |
1107 | 1107 | ||
1108 | } else if( filename.right(3) == "pls" ) { | 1108 | } else if( filename.right(3) == "pls" ) { |
1109 | readPls( filename ); | 1109 | readPls( filename ); |
1110 | } else { | 1110 | } else { |
1111 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1111 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1112 | lnk.setFile( filename ); //sets file name | 1112 | lnk.setFile( filename ); //sets file name |
1113 | d->selectedFiles->addToSelection( lnk); | 1113 | d->selectedFiles->addToSelection( lnk); |
1114 | writeCurrentM3u(); | 1114 | writeCurrentM3u(); |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | if( fileDlg ) { | 1118 | if( fileDlg ) { |
1119 | delete fileDlg; | 1119 | delete fileDlg; |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | 1123 | ||
1124 | /* | 1124 | /* |
1125 | reads m3u and shows files/urls to playlist widget */ | 1125 | reads m3u and shows files/urls to playlist widget */ |
1126 | void PlayListWidget::readm3u( const QString &filename ) { | 1126 | void PlayListWidget::readm3u( const QString &filename ) { |
1127 | qDebug( "read m3u filename " + filename ); | 1127 | qDebug( "read m3u filename " + filename ); |
1128 | 1128 | ||
1129 | Om3u *m3uList; | 1129 | Om3u *m3uList; |
1130 | QString s, name; | 1130 | QString s, name; |
1131 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1131 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1132 | m3uList->readM3u(); | 1132 | m3uList->readM3u(); |
1133 | DocLnk lnk; | 1133 | DocLnk lnk; |
1134 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1134 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1135 | s = *it; | 1135 | s = *it; |
1136 | // qDebug("reading "+ s); | 1136 | // qDebug("reading "+ s); |
1137 | if(s.left(4)=="http") { | 1137 | if(s.left(4)=="http") { |
1138 | lnk.setName( s ); //sets file name | 1138 | lnk.setName( s ); //sets file name |
1139 | lnk.setIcon("opieplayer2/musicfile"); | 1139 | lnk.setIcon("opieplayer2/musicfile"); |
1140 | 1140 | ||
1141 | // if(s.right(4) != '.' || s.right(5) != '.') | 1141 | // if(s.right(4) != '.' || s.right(5) != '.') |
1142 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1142 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1143 | if( s.right(1) != "/") | 1143 | if( s.right(1) != "/") |
1144 | lnk.setFile( s+"/"); //if url with no extension | 1144 | lnk.setFile( s+"/"); //if url with no extension |
1145 | else | 1145 | else |
1146 | lnk.setFile( s ); //sets file name | 1146 | lnk.setFile( s ); //sets file name |
1147 | 1147 | ||
1148 | } else { | 1148 | } else { |
1149 | // if( QFileInfo( s ).exists() ) { | 1149 | // if( QFileInfo( s ).exists() ) { |
1150 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1150 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1151 | // if(s.right(4) == '.') {//if regular file | 1151 | // if(s.right(4) == '.') {//if regular file |
1152 | if(s.left(1) != "/") { | 1152 | if(s.left(1) != "/") { |
1153 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1153 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1154 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1154 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1155 | lnk.setIcon("SoundPlayer"); | 1155 | lnk.setIcon("SoundPlayer"); |
1156 | } else { | 1156 | } else { |
1157 | // qDebug("set link2 "+s); | 1157 | // qDebug("set link2 "+s); |
1158 | lnk.setFile( s); | 1158 | lnk.setFile( s); |
1159 | lnk.setIcon("SoundPlayer"); | 1159 | lnk.setIcon("SoundPlayer"); |
1160 | } | 1160 | } |
1161 | } | 1161 | } |
1162 | d->selectedFiles->addToSelection( lnk ); | 1162 | d->selectedFiles->addToSelection( lnk ); |
1163 | } | 1163 | } |
1164 | Config config( "OpiePlayer" ); | 1164 | Config config( "OpiePlayer" ); |
1165 | config.setGroup( "PlayList" ); | 1165 | config.setGroup( "PlayList" ); |
1166 | 1166 | ||
1167 | config.writeEntry("CurrentPlaylist",filename); | 1167 | config.writeEntry("CurrentPlaylist",filename); |
1168 | config.write(); | 1168 | config.write(); |
1169 | currentPlayList=filename; | 1169 | currentPlayList=filename; |
1170 | 1170 | ||
1171 | // m3uList->write(); | 1171 | // m3uList->write(); |
1172 | m3uList->close(); | 1172 | m3uList->close(); |
1173 | if(m3uList) delete m3uList; | 1173 | if(m3uList) delete m3uList; |
1174 | 1174 | ||
1175 | d->selectedFiles->setSelectedItem( s); | 1175 | d->selectedFiles->setSelectedItem( s); |
1176 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1176 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1177 | 1177 | ||
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | /* | 1180 | /* |
1181 | reads pls and adds files/urls to playlist */ | 1181 | reads pls and adds files/urls to playlist */ |
1182 | void PlayListWidget::readPls( const QString &filename ) { | 1182 | void PlayListWidget::readPls( const QString &filename ) { |
1183 | 1183 | ||
1184 | qDebug( "pls filename is " + filename ); | 1184 | qDebug( "pls filename is " + filename ); |
1185 | Om3u *m3uList; | 1185 | Om3u *m3uList; |
1186 | QString s, name; | 1186 | QString s, name; |
1187 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1187 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1188 | m3uList->readPls(); | 1188 | m3uList->readPls(); |
1189 | 1189 | ||
1190 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1190 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1191 | s = *it; | 1191 | s = *it; |
1192 | // s.replace( QRegExp( "%20" )," " ); | 1192 | // s.replace( QRegExp( "%20" )," " ); |
1193 | DocLnk lnk( s ); | 1193 | DocLnk lnk( s ); |
1194 | QFileInfo f( s ); | 1194 | QFileInfo f( s ); |
1195 | QString name = fullBaseName ( f); | 1195 | QString name = fullBaseName ( f); |
1196 | 1196 | ||
1197 | if( name.left( 4 ) == "http" ) { | 1197 | if( name.left( 4 ) == "http" ) { |
1198 | name = s.right( s.length() - 7); | 1198 | name = s.right( s.length() - 7); |
1199 | } else { | 1199 | } else { |
1200 | name = s; | 1200 | name = s; |
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1203 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1204 | 1204 | ||
1205 | lnk.setName( name ); | 1205 | lnk.setName( name ); |
1206 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1206 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1207 | lnk.setFile( s ); | 1207 | lnk.setFile( s ); |
1208 | } else { //if its a url | 1208 | } else { //if its a url |
1209 | if( name.right( 1 ).find( '/' ) == -1) { | 1209 | if( name.right( 1 ).find( '/' ) == -1) { |
1210 | s += "/"; | 1210 | s += "/"; |
1211 | } | 1211 | } |
1212 | lnk.setFile( s ); | 1212 | lnk.setFile( s ); |
1213 | } | 1213 | } |
1214 | lnk.setType( "audio/x-mpegurl" ); | 1214 | lnk.setType( "audio/x-mpegurl" ); |
1215 | 1215 | ||
1216 | lnk.writeLink(); | 1216 | lnk.writeLink(); |
1217 | d->selectedFiles->addToSelection( lnk ); | 1217 | d->selectedFiles->addToSelection( lnk ); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | m3uList->close(); | 1220 | m3uList->close(); |
1221 | if(m3uList) delete m3uList; | 1221 | if(m3uList) delete m3uList; |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | /* | 1224 | /* |
1225 | writes current playlist to current m3u file */ | 1225 | writes current playlist to current m3u file */ |
1226 | void PlayListWidget::writeCurrentM3u() { | 1226 | void PlayListWidget::writeCurrentM3u() { |
1227 | qDebug("writing to current m3u"); | 1227 | qDebug("writing to current m3u"); |
1228 | Config cfg( "OpiePlayer" ); | 1228 | Config cfg( "OpiePlayer" ); |
1229 | cfg.setGroup("PlayList"); | 1229 | cfg.setGroup("PlayList"); |
1230 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 1230 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
1231 | Om3u *m3uList; | 1231 | Om3u *m3uList; |
1232 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 1232 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
1233 | 1233 | ||
1234 | if( d->selectedFiles->first()) { | 1234 | if( d->selectedFiles->first()) { |
1235 | do { | 1235 | do { |
1236 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1236 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1237 | m3uList->add( d->selectedFiles->current()->file() ); | 1237 | m3uList->add( d->selectedFiles->current()->file() ); |
1238 | } | 1238 | } |
1239 | while ( d->selectedFiles->next() ); | 1239 | while ( d->selectedFiles->next() ); |
1240 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1240 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1241 | m3uList->write(); | 1241 | m3uList->write(); |
1242 | m3uList->close(); | 1242 | m3uList->close(); |
1243 | 1243 | ||
1244 | if(m3uList) delete m3uList; | 1244 | if(m3uList) delete m3uList; |
1245 | } | 1245 | } |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | /* | 1248 | /* |
1249 | writes current playlist to m3u file */ | 1249 | writes current playlist to m3u file */ |
1250 | void PlayListWidget::writem3u() { | 1250 | void PlayListWidget::writem3u() { |
1251 | InputDialog *fileDlg; | 1251 | InputDialog *fileDlg; |
1252 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1252 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1253 | fileDlg->exec(); | 1253 | fileDlg->exec(); |
1254 | QString name, filename, list; | 1254 | QString name, filename, list; |
1255 | Om3u *m3uList; | 1255 | Om3u *m3uList; |
1256 | 1256 | ||
1257 | if( fileDlg->result() == 1 ) { | 1257 | if( fileDlg->result() == 1 ) { |
1258 | name = fileDlg->text(); | 1258 | name = fileDlg->text(); |
1259 | // qDebug( filename ); | 1259 | // qDebug( filename ); |
1260 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1260 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1261 | filename = name; | 1261 | filename = name; |
1262 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1262 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1263 | } | 1263 | } |
1264 | else //otherwise dump it somewhere noticable | 1264 | else //otherwise dump it somewhere noticable |
1265 | filename = QPEApplication::documentDir() + "/" + name; | 1265 | filename = QPEApplication::documentDir() + "/" + name; |
1266 | 1266 | ||
1267 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1267 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1268 | filename += ".m3u"; | 1268 | filename += ".m3u"; |
1269 | 1269 | ||
1270 | if( d->selectedFiles->first()) { | 1270 | if( d->selectedFiles->first()) { |
1271 | m3uList = new Om3u(filename, IO_ReadWrite); | 1271 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1272 | 1272 | ||
1273 | do { | 1273 | do { |
1274 | m3uList->add( d->selectedFiles->current()->file()); | 1274 | m3uList->add( d->selectedFiles->current()->file()); |
1275 | } | 1275 | } |
1276 | while ( d->selectedFiles->next() ); | 1276 | while ( d->selectedFiles->next() ); |
1277 | // qDebug( list ); | 1277 | // qDebug( list ); |
1278 | m3uList->write(); | 1278 | m3uList->write(); |
1279 | m3uList->close(); | 1279 | m3uList->close(); |
1280 | if(m3uList) delete m3uList; | 1280 | if(m3uList) delete m3uList; |
1281 | 1281 | ||
1282 | if(fileDlg) delete fileDlg; | 1282 | if(fileDlg) delete fileDlg; |
1283 | 1283 | ||
1284 | DocLnk lnk; | 1284 | DocLnk lnk; |
1285 | lnk.setFile( filename); | 1285 | lnk.setFile( filename); |
1286 | lnk.setIcon("opieplayer2/playlist2"); | 1286 | lnk.setIcon("opieplayer2/playlist2"); |
1287 | lnk.setName( name); //sets file name | 1287 | lnk.setName( name); //sets file name |
1288 | 1288 | ||
1289 | // qDebug(filename); | 1289 | // qDebug(filename); |
1290 | Config config( "OpiePlayer" ); | 1290 | Config config( "OpiePlayer" ); |
1291 | config.setGroup( "PlayList" ); | 1291 | config.setGroup( "PlayList" ); |
1292 | 1292 | ||
1293 | config.writeEntry("CurrentPlaylist",filename); | 1293 | config.writeEntry("CurrentPlaylist",filename); |
1294 | currentPlayList=filename; | 1294 | currentPlayList=filename; |
1295 | 1295 | ||
1296 | if(!lnk.writeLink()) { | 1296 | if(!lnk.writeLink()) { |
1297 | qDebug("Writing doclink did not work"); | 1297 | qDebug("Writing doclink did not work"); |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | setCaption(tr("OpiePlayer: ") + name); | 1300 | setCaption(tr("OpiePlayer: ") + name); |
1301 | } | 1301 | } |
1302 | } | 1302 | } |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | 1305 | ||
1306 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1306 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1307 | { | 1307 | { |
1308 | switch ( e->key() ) { | 1308 | switch ( e->key() ) { |
1309 | ////////////////////////////// Zaurus keys | 1309 | ////////////////////////////// Zaurus keys |
1310 | case Key_F9: //activity | 1310 | case Key_F9: //activity |
1311 | // if(audioUI->isHidden()) | 1311 | // if(audioUI->isHidden()) |
1312 | // audioUI->showMaximized(); | 1312 | // audioUI->showMaximized(); |
1313 | break; | 1313 | break; |
1314 | case Key_F10: //contacts | 1314 | case Key_F10: //contacts |
1315 | // if( videoUI->isHidden()) | 1315 | // if( videoUI->isHidden()) |
1316 | // videoUI->showMaximized(); | 1316 | // videoUI->showMaximized(); |
1317 | break; | 1317 | break; |
1318 | case Key_F11: //menu | 1318 | case Key_F11: //menu |
1319 | break; | 1319 | break; |
1320 | case Key_F12: //home | 1320 | case Key_F12: //home |
1321 | // doBlank(); | 1321 | // doBlank(); |
1322 | break; | 1322 | break; |
1323 | case Key_F13: //mail | 1323 | case Key_F13: //mail |
1324 | // doUnblank(); | 1324 | // doUnblank(); |
1325 | break; | 1325 | break; |
1326 | case Key_Q: //add to playlist | 1326 | case Key_Q: //add to playlist |
1327 | qDebug("Add"); | 1327 | qDebug("Add"); |
1328 | addSelected(); | 1328 | addSelected(); |
1329 | break; | 1329 | break; |
1330 | case Key_R: //remove from playlist | 1330 | case Key_R: //remove from playlist |
1331 | removeSelected(); | 1331 | removeSelected(); |
1332 | break; | 1332 | break; |
1333 | // case Key_P: //play | 1333 | // case Key_P: //play |
1334 | // qDebug("Play"); | 1334 | // qDebug("Play"); |
1335 | // playSelected(); | 1335 | // playSelected(); |
1336 | // break; | 1336 | // break; |
1337 | case Key_Space: | 1337 | case Key_Space: |
1338 | qDebug("Play"); | 1338 | qDebug("Play"); |
1339 | // playSelected(); puh | 1339 | // playSelected(); puh |
1340 | break; | 1340 | break; |
1341 | case Key_1: | 1341 | case Key_1: |
1342 | tabWidget->setCurrentPage(0); | 1342 | tabWidget->setCurrentPage(0); |
1343 | break; | 1343 | break; |
1344 | case Key_2: | 1344 | case Key_2: |
1345 | tabWidget->setCurrentPage(1); | 1345 | tabWidget->setCurrentPage(1); |
1346 | break; | 1346 | break; |
1347 | case Key_3: | 1347 | case Key_3: |
1348 | tabWidget->setCurrentPage(2); | 1348 | tabWidget->setCurrentPage(2); |
1349 | break; | 1349 | break; |
1350 | case Key_4: | 1350 | case Key_4: |
1351 | tabWidget->setCurrentPage(3); | 1351 | tabWidget->setCurrentPage(3); |
1352 | break; | 1352 | break; |
1353 | case Key_Down: | 1353 | case Key_Down: |
1354 | if ( !d->selectedFiles->next() ) | 1354 | if ( !d->selectedFiles->next() ) |
1355 | d->selectedFiles->first(); | 1355 | d->selectedFiles->first(); |
1356 | 1356 | ||
1357 | break; | 1357 | break; |
1358 | case Key_Up: | 1358 | case Key_Up: |
1359 | if ( !d->selectedFiles->prev() ) | 1359 | if ( !d->selectedFiles->prev() ) |
1360 | // d->selectedFiles->last(); | 1360 | // d->selectedFiles->last(); |
1361 | 1361 | ||
1362 | break; | 1362 | break; |
1363 | 1363 | ||
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1367 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1368 | { | 1368 | { |
1369 | // qDebug("Key press"); | 1369 | // qDebug("Key press"); |
1370 | // switch ( e->key() ) { | 1370 | // switch ( e->key() ) { |
1371 | // ////////////////////////////// Zaurus keys | 1371 | // ////////////////////////////// Zaurus keys |
1372 | // case Key_A: //add to playlist | 1372 | // case Key_A: //add to playlist |
1373 | // qDebug("Add"); | 1373 | // qDebug("Add"); |
1374 | // addSelected(); | 1374 | // addSelected(); |
1375 | // break; | 1375 | // break; |
1376 | // case Key_R: //remove from playlist | 1376 | // case Key_R: //remove from playlist |
1377 | // removeSelected(); | 1377 | // removeSelected(); |
1378 | // break; | 1378 | // break; |
1379 | // case Key_P: //play | 1379 | // case Key_P: //play |
1380 | // qDebug("Play"); | 1380 | // qDebug("Play"); |
1381 | // playSelected(); | 1381 | // playSelected(); |
1382 | // break; | 1382 | // break; |
1383 | // case Key_Space: | 1383 | // case Key_Space: |
1384 | // qDebug("Play"); | 1384 | // qDebug("Play"); |
1385 | // playSelected(); | 1385 | // playSelected(); |
1386 | // break; | 1386 | // break; |
1387 | // } | 1387 | // } |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | void PlayListWidget::doBlank() { | 1390 | void PlayListWidget::doBlank() { |
1391 | qDebug("do blanking"); | 1391 | qDebug("do blanking"); |
1392 | fd=open("/dev/fb0",O_RDWR); | 1392 | fd=open("/dev/fb0",O_RDWR); |
1393 | if (fd != -1) { | 1393 | if (fd != -1) { |
1394 | ioctl(fd,FBIOBLANK,1); | 1394 | ioctl(fd,FBIOBLANK,1); |
1395 | // close(fd); | 1395 | // close(fd); |
1396 | } | 1396 | } |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | void PlayListWidget::doUnblank() { | 1399 | void PlayListWidget::doUnblank() { |
1400 | // this crashes opieplayer with a segfault | 1400 | // this crashes opieplayer with a segfault |
1401 | // int fd; | 1401 | // int fd; |
1402 | // fd=open("/dev/fb0",O_RDWR); | 1402 | // fd=open("/dev/fb0",O_RDWR); |
1403 | qDebug("do unblanking"); | 1403 | qDebug("do unblanking"); |
1404 | if (fd != -1) { | 1404 | if (fd != -1) { |
1405 | ioctl(fd,FBIOBLANK,0); | 1405 | ioctl(fd,FBIOBLANK,0); |
1406 | close(fd); | 1406 | close(fd); |
1407 | } | 1407 | } |
1408 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1408 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1409 | h <<-3;// v[1]; // -3 Force on | 1409 | h <<-3;// v[1]; // -3 Force on |
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | void PlayListWidget::populateSkinsMenu() { | 1412 | void PlayListWidget::populateSkinsMenu() { |
1413 | int item = 0; | 1413 | int item = 0; |
1414 | defaultSkinIndex = 0; | 1414 | defaultSkinIndex = 0; |
1415 | QString skinName; | 1415 | QString skinName; |
1416 | Config cfg( "OpiePlayer" ); | 1416 | Config cfg( "OpiePlayer" ); |
1417 | cfg.setGroup("Options" ); | 1417 | cfg.setGroup("Options" ); |
1418 | QString skin = cfg.readEntry( "Skin", "default" ); | 1418 | QString skin = cfg.readEntry( "Skin", "default" ); |
1419 | 1419 | ||
1420 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1420 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1421 | skinsDir.setFilter( QDir::Dirs ); | 1421 | skinsDir.setFilter( QDir::Dirs ); |
1422 | skinsDir.setSorting(QDir::Name ); | 1422 | skinsDir.setSorting(QDir::Name ); |
1423 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1423 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1424 | QFileInfoListIterator it( *skinslist ); | 1424 | QFileInfoListIterator it( *skinslist ); |
1425 | QFileInfo *fi; | 1425 | QFileInfo *fi; |
1426 | while ( ( fi = it.current() ) ) { | 1426 | while ( ( fi = it.current() ) ) { |
1427 | skinName = fi->fileName(); | 1427 | skinName = fi->fileName(); |
1428 | // qDebug( fi->fileName() ); | 1428 | // qDebug( fi->fileName() ); |
1429 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1429 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1430 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1430 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1431 | } | 1431 | } |
1432 | if( skinName == "default" ) { | 1432 | if( skinName == "default" ) { |
1433 | defaultSkinIndex = item; | 1433 | defaultSkinIndex = item; |
1434 | } | 1434 | } |
1435 | if( skinName == skin ) { | 1435 | if( skinName == skin ) { |
1436 | skinsMenu->setItemChecked( item, TRUE ); | 1436 | skinsMenu->setItemChecked( item, TRUE ); |
1437 | } | 1437 | } |
1438 | ++it; | 1438 | ++it; |
1439 | } | 1439 | } |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | void PlayListWidget::skinsMenuActivated( int item ) { | 1442 | void PlayListWidget::skinsMenuActivated( int item ) { |
1443 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1443 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1444 | skinsMenu->setItemChecked( i, FALSE ); | 1444 | skinsMenu->setItemChecked( i, FALSE ); |
1445 | } | 1445 | } |
1446 | skinsMenu->setItemChecked( item, TRUE ); | 1446 | skinsMenu->setItemChecked( item, TRUE ); |
1447 | 1447 | ||
1448 | Config cfg( "OpiePlayer" ); | 1448 | Config cfg( "OpiePlayer" ); |
1449 | cfg.setGroup("Options"); | 1449 | cfg.setGroup("Options"); |
1450 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1450 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1451 | } | 1451 | } |
1452 | 1452 | ||
1453 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1453 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1454 | qDebug("qcop message "+msg ); | 1454 | qDebug("qcop message "+msg ); |
1455 | QDataStream stream ( data, IO_ReadOnly ); | 1455 | QDataStream stream ( data, IO_ReadOnly ); |
1456 | if ( msg == "play()" ) { //plays current selection | 1456 | if ( msg == "play()" ) { //plays current selection |
1457 | btnPlay( true); | 1457 | btnPlay( true); |
1458 | } else if ( msg == "stop()" ) { | 1458 | } else if ( msg == "stop()" ) { |
1459 | mediaPlayerState->setPlaying( false); | 1459 | mediaPlayerState->setPlaying( false); |
1460 | } else if ( msg == "togglePause()" ) { | 1460 | } else if ( msg == "togglePause()" ) { |
1461 | mediaPlayerState->togglePaused(); | 1461 | mediaPlayerState->togglePaused(); |
1462 | } else if ( msg == "next()" ) { //select next in list | 1462 | } else if ( msg == "next()" ) { //select next in list |
1463 | mediaPlayerState->setNext(); | 1463 | mediaPlayerState->setNext(); |
1464 | } else if ( msg == "prev()" ) { //select previous in list | 1464 | } else if ( msg == "prev()" ) { //select previous in list |
1465 | mediaPlayerState->setPrev(); | 1465 | mediaPlayerState->setPrev(); |
1466 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1466 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1467 | mediaPlayerState->toggleLooping(); | 1467 | mediaPlayerState->toggleLooping(); |
1468 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1468 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1469 | mediaPlayerState->toggleShuffled(); | 1469 | mediaPlayerState->toggleShuffled(); |
1470 | } else if ( msg == "volUp()" ) { //volume more | 1470 | } else if ( msg == "volUp()" ) { //volume more |
1471 | // emit moreClicked(); | 1471 | // emit moreClicked(); |
1472 | // emit moreReleased(); | 1472 | // emit moreReleased(); |
1473 | } else if ( msg == "volDown()" ) { //volume less | 1473 | } else if ( msg == "volDown()" ) { //volume less |
1474 | // emit lessClicked(); | 1474 | // emit lessClicked(); |
1475 | // emit lessReleased(); | 1475 | // emit lessReleased(); |
1476 | } else if ( msg == "play(QString)" ) { //play this now | 1476 | } else if ( msg == "play(QString)" ) { //play this now |
1477 | QString file; | 1477 | QString file; |
1478 | stream >> file; | 1478 | stream >> file; |
1479 | setDocument( (const QString &) file); | 1479 | setDocument( (const QString &) file); |
1480 | } else if ( msg == "add(QString)" ) { //add to playlist | 1480 | } else if ( msg == "add(QString)" ) { //add to playlist |
1481 | QString file; | 1481 | QString file; |
1482 | stream >> file; | 1482 | stream >> file; |
1483 | QFileInfo fileInfo(file); | 1483 | QFileInfo fileInfo(file); |
1484 | DocLnk lnk; | 1484 | DocLnk lnk; |
1485 | lnk.setName( fileInfo.baseName() ); //sets name | 1485 | lnk.setName( fileInfo.baseName() ); //sets name |
1486 | lnk.setFile( file ); //sets file name | 1486 | lnk.setFile( file ); //sets file name |
1487 | addToSelection( lnk ); | 1487 | addToSelection( lnk ); |
1488 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1488 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1489 | QString file; | 1489 | QString file; |
1490 | stream >> file; | 1490 | stream >> file; |
1491 | 1491 | ||
1492 | } | 1492 | } |
1493 | 1493 | ||
1494 | } | 1494 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index e9615f1..580460e 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,916 +1,916 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdatetime.h> | 41 | #include <qdatetime.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | #include "playlistselection.h" | 47 | #include "playlistselection.h" |
48 | #include "playlistwidget.h" | 48 | #include "playlistwidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "inputDialog.h" | 50 | #include "inputDialog.h" |
51 | #include "om3u.h" | 51 | #include "om3u.h" |
52 | #include "playlistfileview.h" | 52 | #include "playlistfileview.h" |
53 | 53 | ||
54 | //only needed for the random play | 54 | //only needed for the random play |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <assert.h> | 56 | #include <assert.h> |
57 | 57 | ||
58 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 58 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) | 59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) |
60 | { | 60 | { |
61 | 61 | ||
62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
63 | "opieplayer2/add_to_playlist", | 63 | "opieplayer2/add_to_playlist", |
64 | this , SLOT(addSelected() ) ); | 64 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
66 | "opieplayer2/remove_from_playlist", | 66 | "opieplayer2/remove_from_playlist", |
67 | this , SLOT(removeSelected() ) ); | 67 | this , SLOT(removeSelected() ) ); |
68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
69 | this , SLOT( btnPlay( bool) ), TRUE ); | 69 | this , SLOT( btnPlay( bool) ), TRUE ); |
70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
73 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 73 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
74 | 74 | ||
75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
77 | this, SLOT( addAllMusicToList() ) ); | 77 | this, SLOT( addAllMusicToList() ) ); |
78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
79 | this, SLOT( addAllVideoToList() ) ); | 79 | this, SLOT( addAllVideoToList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
81 | this, SLOT( addAllToList() ) ); | 81 | this, SLOT( addAllToList() ) ); |
82 | pmPlayList->insertSeparator(-1); | 82 | pmPlayList->insertSeparator(-1); |
83 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 83 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
84 | // this, SLOT( saveList() ) ); | 84 | // this, SLOT( saveList() ) ); |
85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
86 | this, SLOT(writem3u() ) ); | 86 | this, SLOT(writem3u() ) ); |
87 | pmPlayList->insertSeparator(-1); | 87 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
89 | this,SLOT( openFile() ) ); | 89 | this,SLOT( openFile() ) ); |
90 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
92 | audioView, SLOT( scanFiles() ) ); | 92 | audioView, SLOT( scanFiles() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
94 | videoView, SLOT( scanFiles() ) ); | 94 | videoView, SLOT( scanFiles() ) ); |
95 | 95 | ||
96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
97 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 97 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
98 | 98 | ||
99 | Config cfg( "OpiePlayer" ); | 99 | Config cfg( "OpiePlayer" ); |
100 | bool b= cfg.readBoolEntry("FullScreen", 0); | 100 | bool b= cfg.readBoolEntry("FullScreen", 0); |
101 | mediaPlayerState.setFullscreen( b ); | 101 | mediaPlayerState.setFullscreen( b ); |
102 | pmView->setItemChecked( -16, b ); | 102 | pmView->setItemChecked( -16, b ); |
103 | 103 | ||
104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
107 | d->selectedFiles, SLOT(removeSelected() ) ); | 107 | d->selectedFiles, SLOT(removeSelected() ) ); |
108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
110 | // QVBox *stretch2 = new QVBox( vbox1 ); | 110 | // QVBox *stretch2 = new QVBox( vbox1 ); |
111 | 111 | ||
112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
113 | SLOT( deletePlaylist() ) ); | 113 | SLOT( deletePlaylist() ) ); |
114 | connect( pmView, SIGNAL( activated( int ) ), | 114 | connect( pmView, SIGNAL( activated( int ) ), |
115 | this, SLOT( pmViewActivated( int ) ) ); | 115 | this, SLOT( pmViewActivated( int ) ) ); |
116 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 116 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
117 | this, SLOT( skinsMenuActivated( int ) ) ); | 117 | this, SLOT( skinsMenuActivated( int ) ) ); |
118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
119 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 119 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
120 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 120 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
121 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 121 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
122 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 122 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
123 | this,SLOT( playIt( QListViewItem *) ) ); | 123 | this,SLOT( playIt( QListViewItem *) ) ); |
124 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 124 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
125 | this, SLOT( addToSelection( QListViewItem *) ) ); | 125 | this, SLOT( addToSelection( QListViewItem *) ) ); |
126 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 126 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
128 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 132 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
133 | this, SLOT( loadList( const DocLnk & ) ) ); | 133 | this, SLOT( loadList( const DocLnk & ) ) ); |
134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
135 | this, SLOT( tabChanged( QWidget* ) ) ); | 135 | this, SLOT( tabChanged( QWidget* ) ) ); |
136 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 136 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
137 | d->tbPlay, SLOT( setOn( bool ) ) ); | 137 | d->tbPlay, SLOT( setOn( bool ) ) ); |
138 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 138 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
139 | d->tbLoop, SLOT( setOn( bool ) ) ); | 139 | d->tbLoop, SLOT( setOn( bool ) ) ); |
140 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 140 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
141 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 141 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
142 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 142 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
143 | this, SLOT( playIt( QListViewItem *) ) ); | 143 | this, SLOT( playIt( QListViewItem *) ) ); |
144 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 144 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
145 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 145 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
146 | 146 | ||
147 | // see which skins are installed | 147 | // see which skins are installed |
148 | populateSkinsMenu(); | 148 | populateSkinsMenu(); |
149 | initializeStates(); | 149 | initializeStates(); |
150 | 150 | ||
151 | cfg.setGroup("PlayList"); | 151 | cfg.setGroup("PlayList"); |
152 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 152 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
153 | loadList(DocLnk( currentPlaylist ) ); | 153 | loadList(DocLnk( currentPlaylist ) ); |
154 | 154 | ||
155 | tabWidget->showPage( playListTab ); | 155 | tabWidget->showPage( playListTab ); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | PlayListWidget::~PlayListWidget() { | 159 | PlayListWidget::~PlayListWidget() { |
160 | delete d; | 160 | delete d; |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | void PlayListWidget::initializeStates() { | 164 | void PlayListWidget::initializeStates() { |
165 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 165 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
166 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 166 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
167 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 167 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
168 | d->playListFrame->show(); | 168 | d->playListFrame->show(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void PlayListWidget::writeDefaultPlaylist() { | 171 | void PlayListWidget::writeDefaultPlaylist() { |
172 | 172 | ||
173 | Config config( "OpiePlayer" ); | 173 | Config config( "OpiePlayer" ); |
174 | config.setGroup( "PlayList" ); | 174 | config.setGroup( "PlayList" ); |
175 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 175 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
176 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 176 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
177 | if( currentString == filename) { | 177 | if( currentString == filename) { |
178 | Om3u *m3uList; | 178 | Om3u *m3uList; |
179 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 179 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
180 | if( d->selectedFiles->first() ) { | 180 | if( d->selectedFiles->first() ) { |
181 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 181 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
182 | do { | 182 | do { |
183 | // qDebug(d->selectedFiles->current()->file()); | 183 | // qDebug(d->selectedFiles->current()->file()); |
184 | m3uList->add( d->selectedFiles->current()->file() ); | 184 | m3uList->add( d->selectedFiles->current()->file() ); |
185 | } | 185 | } |
186 | while ( d->selectedFiles->next() ); | 186 | while ( d->selectedFiles->next() ); |
187 | 187 | ||
188 | m3uList->write(); | 188 | m3uList->write(); |
189 | m3uList->close(); | 189 | m3uList->close(); |
190 | delete m3uList; | 190 | delete m3uList; |
191 | 191 | ||
192 | } | 192 | } |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 196 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
197 | d->setDocumentUsed = FALSE; | 197 | d->setDocumentUsed = FALSE; |
198 | if( QFileInfo( lnk.file() ).exists() || | 198 | if( QFileInfo( lnk.file() ).exists() || |
199 | lnk.file().left(4) == "http" ) { | 199 | lnk.file().left(4) == "http" ) { |
200 | d->selectedFiles->addToSelection( lnk ); | 200 | d->selectedFiles->addToSelection( lnk ); |
201 | } | 201 | } |
202 | // writeCurrentM3u(); | 202 | // writeCurrentM3u(); |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | void PlayListWidget::clearList() { | 206 | void PlayListWidget::clearList() { |
207 | while ( first() ) { | 207 | while ( first() ) { |
208 | d->selectedFiles->removeSelected(); | 208 | d->selectedFiles->removeSelected(); |
209 | } | 209 | } |
210 | Config cfg( "OpiePlayer" ); | 210 | Config cfg( "OpiePlayer" ); |
211 | cfg.setGroup("PlayList"); | 211 | cfg.setGroup("PlayList"); |
212 | cfg.writeEntry("CurrentPlaylist","default"); | 212 | cfg.writeEntry("CurrentPlaylist","default"); |
213 | setCaption("OpiePlayer"); | 213 | setCaption("OpiePlayer"); |
214 | } | 214 | } |
215 | 215 | ||
216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
217 | switch (mouse) { | 217 | switch (mouse) { |
218 | case LeftButton: | 218 | case LeftButton: |
219 | break; | 219 | break; |
220 | case RightButton: | 220 | case RightButton: |
221 | { | 221 | { |
222 | QPopupMenu m; | 222 | QPopupMenu m; |
223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
225 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
233 | switch (mouse) { | 233 | switch (mouse) { |
234 | case LeftButton: | 234 | case LeftButton: |
235 | break; | 235 | break; |
236 | case RightButton: | 236 | case RightButton: |
237 | { | 237 | { |
238 | QPopupMenu m; | 238 | QPopupMenu m; |
239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
241 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
249 | 249 | ||
250 | 250 | ||
251 | audioView->populateView(); | 251 | audioView->populateView(); |
252 | 252 | ||
253 | QListViewItemIterator audioIt( audioView ); | 253 | QListViewItemIterator audioIt( audioView ); |
254 | DocLnk lnk; | 254 | DocLnk lnk; |
255 | QString filename; | 255 | QString filename; |
256 | // iterate through all items of the listview | 256 | // iterate through all items of the listview |
257 | for ( ; audioIt.current(); ++audioIt ) { | 257 | for ( ; audioIt.current(); ++audioIt ) { |
258 | filename = audioIt.current()->text(3); | 258 | filename = audioIt.current()->text(3); |
259 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 259 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
260 | lnk.setFile( filename ); //sets file name | 260 | lnk.setFile( filename ); //sets file name |
261 | d->selectedFiles->addToSelection( lnk); | 261 | d->selectedFiles->addToSelection( lnk); |
262 | } | 262 | } |
263 | 263 | ||
264 | videoView->populateView(); | 264 | videoView->populateView(); |
265 | 265 | ||
266 | QListViewItemIterator videoIt( videoView ); | 266 | QListViewItemIterator videoIt( videoView ); |
267 | for ( ; videoIt.current(); ++videoIt ) { | 267 | for ( ; videoIt.current(); ++videoIt ) { |
268 | filename = videoIt.current()->text(3); | 268 | filename = videoIt.current()->text(3); |
269 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 269 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
270 | lnk.setFile( filename ); //sets file name | 270 | lnk.setFile( filename ); //sets file name |
271 | d->selectedFiles->addToSelection( lnk); | 271 | d->selectedFiles->addToSelection( lnk); |
272 | } | 272 | } |
273 | 273 | ||
274 | tabWidget->setCurrentPage(0); | 274 | tabWidget->setCurrentPage(0); |
275 | 275 | ||
276 | writeCurrentM3u(); | 276 | writeCurrentM3u(); |
277 | d->selectedFiles->first(); | 277 | d->selectedFiles->first(); |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | void PlayListWidget::addAllMusicToList() { | 281 | void PlayListWidget::addAllMusicToList() { |
282 | 282 | ||
283 | audioView->populateView(); | 283 | audioView->populateView(); |
284 | 284 | ||
285 | QListViewItemIterator audioIt( audioView ); | 285 | QListViewItemIterator audioIt( audioView ); |
286 | DocLnk lnk; | 286 | DocLnk lnk; |
287 | QString filename; | 287 | QString filename; |
288 | // iterate through all items of the listview | 288 | // iterate through all items of the listview |
289 | for ( ; audioIt.current(); ++audioIt ) { | 289 | for ( ; audioIt.current(); ++audioIt ) { |
290 | filename = audioIt.current()->text(3); | 290 | filename = audioIt.current()->text(3); |
291 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 291 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
292 | lnk.setFile( filename ); //sets file name | 292 | lnk.setFile( filename ); //sets file name |
293 | d->selectedFiles->addToSelection( lnk); | 293 | d->selectedFiles->addToSelection( lnk); |
294 | } | 294 | } |
295 | 295 | ||
296 | tabWidget->setCurrentPage(0); | 296 | tabWidget->setCurrentPage(0); |
297 | writeCurrentM3u(); | 297 | writeCurrentM3u(); |
298 | d->selectedFiles->first(); | 298 | d->selectedFiles->first(); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | void PlayListWidget::addAllVideoToList() { | 302 | void PlayListWidget::addAllVideoToList() { |
303 | 303 | ||
304 | videoView->populateView(); | 304 | videoView->populateView(); |
305 | 305 | ||
306 | QListViewItemIterator videoIt( videoView ); | 306 | QListViewItemIterator videoIt( videoView ); |
307 | DocLnk lnk; | 307 | DocLnk lnk; |
308 | QString filename; | 308 | QString filename; |
309 | for ( ; videoIt.current(); ++videoIt ) { | 309 | for ( ; videoIt.current(); ++videoIt ) { |
310 | filename = videoIt.current()->text(3); | 310 | filename = videoIt.current()->text(3); |
311 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 311 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
312 | lnk.setFile( filename ); //sets file name | 312 | lnk.setFile( filename ); //sets file name |
313 | d->selectedFiles->addToSelection( lnk); | 313 | d->selectedFiles->addToSelection( lnk); |
314 | } | 314 | } |
315 | tabWidget->setCurrentPage(0); | 315 | tabWidget->setCurrentPage(0); |
316 | writeCurrentM3u(); | 316 | writeCurrentM3u(); |
317 | d->selectedFiles->first(); | 317 | d->selectedFiles->first(); |
318 | } | 318 | } |
319 | 319 | ||
320 | 320 | ||
321 | void PlayListWidget::setDocument( const QString& fileref ) { | 321 | void PlayListWidget::setDocument( const QString& fileref ) { |
322 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 322 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
323 | fromSetDocument = TRUE; | 323 | fromSetDocument = TRUE; |
324 | QFileInfo fileInfo(fileref); | 324 | QFileInfo fileInfo(fileref); |
325 | 325 | ||
326 | if ( !fileInfo.exists() ) { | 326 | if ( !fileInfo.exists() ) { |
327 | QMessageBox::warning( this, tr( "Invalid File" ), | 327 | QMessageBox::warning( this, tr( "Invalid File" ), |
328 | tr( "There was a problem in getting the file." ) ); | 328 | tr( "There was a problem in getting the file." ) ); |
329 | return; | 329 | return; |
330 | } | 330 | } |
331 | 331 | ||
332 | clearList(); | 332 | clearList(); |
333 | QString extension = fileInfo.extension(false); | 333 | QString extension = fileInfo.extension(false); |
334 | 334 | ||
335 | if( extension.find( "m3u", 0, false) != -1 | 335 | if( extension.find( "m3u", 0, false) != -1 |
336 | || extension.find( "pls", 0, false) != -1 ) { | 336 | || extension.find( "pls", 0, false) != -1 ) { |
337 | readListFromFile( fileref ); | 337 | readListFromFile( fileref ); |
338 | } else { | 338 | } else { |
339 | clearList(); | 339 | clearList(); |
340 | DocLnk lnk; | 340 | DocLnk lnk; |
341 | lnk.setName( fileInfo.baseName() ); //sets name | 341 | lnk.setName( fileInfo.baseName() ); //sets name |
342 | lnk.setFile( fileref ); //sets file name | 342 | lnk.setFile( fileref ); //sets file name |
343 | addToSelection( lnk ); | 343 | addToSelection( lnk ); |
344 | writeCurrentM3u(); | 344 | writeCurrentM3u(); |
345 | 345 | ||
346 | d->setDocumentUsed = TRUE; | 346 | d->setDocumentUsed = TRUE; |
347 | mediaPlayerState.setPlaying( FALSE ); | 347 | mediaPlayerState.setPlaying( FALSE ); |
348 | mediaPlayerState.setPlaying( TRUE ); | 348 | mediaPlayerState.setPlaying( TRUE ); |
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
353 | void PlayListWidget::useSelectedDocument() { | 353 | void PlayListWidget::useSelectedDocument() { |
354 | d->setDocumentUsed = FALSE; | 354 | d->setDocumentUsed = FALSE; |
355 | } | 355 | } |
356 | 356 | ||
357 | 357 | ||
358 | const DocLnk *PlayListWidget::current() const { // this is fugly | 358 | const DocLnk *PlayListWidget::current() const { // this is fugly |
359 | assert( currentTab() == CurrentPlayList ); | 359 | assert( currentTab() == CurrentPlayList ); |
360 | 360 | ||
361 | const DocLnk *lnk = d->selectedFiles->current(); | 361 | const DocLnk *lnk = d->selectedFiles->current(); |
362 | if ( !lnk ) { | 362 | if ( !lnk ) { |
363 | d->selectedFiles->first(); | 363 | d->selectedFiles->first(); |
364 | lnk = d->selectedFiles->current(); | 364 | lnk = d->selectedFiles->current(); |
365 | } | 365 | } |
366 | assert( lnk ); | 366 | assert( lnk ); |
367 | return lnk; | 367 | return lnk; |
368 | } | 368 | } |
369 | 369 | ||
370 | 370 | ||
371 | bool PlayListWidget::prev() { | 371 | bool PlayListWidget::prev() { |
372 | if ( mediaPlayerState.isShuffled() ) { | 372 | if ( mediaPlayerState.isShuffled() ) { |
373 | const DocLnk *cur = current(); | 373 | const DocLnk *cur = current(); |
374 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 374 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
375 | for ( int i = 0; i < j; i++ ) { | 375 | for ( int i = 0; i < j; i++ ) { |
376 | if ( !d->selectedFiles->next() ) | 376 | if ( !d->selectedFiles->next() ) |
377 | d->selectedFiles->first(); | 377 | d->selectedFiles->first(); |
378 | } | 378 | } |
379 | if ( cur == current() ) | 379 | if ( cur == current() ) |
380 | if ( !d->selectedFiles->next() ) { | 380 | if ( !d->selectedFiles->next() ) { |
381 | d->selectedFiles->first(); | 381 | d->selectedFiles->first(); |
382 | } | 382 | } |
383 | return TRUE; | 383 | return TRUE; |
384 | } else { | 384 | } else { |
385 | if ( !d->selectedFiles->prev() ) { | 385 | if ( !d->selectedFiles->prev() ) { |
386 | if ( mediaPlayerState.isLooping() ) { | 386 | if ( mediaPlayerState.isLooping() ) { |
387 | return d->selectedFiles->last(); | 387 | return d->selectedFiles->last(); |
388 | } else { | 388 | } else { |
389 | return FALSE; | 389 | return FALSE; |
390 | } | 390 | } |
391 | } | 391 | } |
392 | return TRUE; | 392 | return TRUE; |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | bool PlayListWidget::next() { | 397 | bool PlayListWidget::next() { |
398 | //qDebug("<<<<<<<<<<<<next()"); | 398 | //qDebug("<<<<<<<<<<<<next()"); |
399 | if ( mediaPlayerState.isShuffled() ) { | 399 | if ( mediaPlayerState.isShuffled() ) { |
400 | return prev(); | 400 | return prev(); |
401 | } else { | 401 | } else { |
402 | if ( !d->selectedFiles->next() ) { | 402 | if ( !d->selectedFiles->next() ) { |
403 | if ( mediaPlayerState.isLooping() ) { | 403 | if ( mediaPlayerState.isLooping() ) { |
404 | return d->selectedFiles->first(); | 404 | return d->selectedFiles->first(); |
405 | } else { | 405 | } else { |
406 | return FALSE; | 406 | return FALSE; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | return TRUE; | 409 | return TRUE; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | 413 | ||
414 | bool PlayListWidget::first() { | 414 | bool PlayListWidget::first() { |
415 | return d->selectedFiles->first(); | 415 | return d->selectedFiles->first(); |
416 | } | 416 | } |
417 | 417 | ||
418 | 418 | ||
419 | bool PlayListWidget::last() { | 419 | bool PlayListWidget::last() { |
420 | return d->selectedFiles->last(); | 420 | return d->selectedFiles->last(); |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | void PlayListWidget::saveList() { | 424 | void PlayListWidget::saveList() { |
425 | writem3u(); | 425 | writem3u(); |
426 | } | 426 | } |
427 | 427 | ||
428 | 428 | ||
429 | void PlayListWidget::loadList( const DocLnk & lnk) { | 429 | void PlayListWidget::loadList( const DocLnk & lnk) { |
430 | QString name = lnk.name(); | 430 | QString name = lnk.name(); |
431 | 431 | ||
432 | if( name.length()>0) { | 432 | if( name.length()>0) { |
433 | setCaption("OpiePlayer: "+name); | 433 | setCaption("OpiePlayer: "+name); |
434 | clearList(); | 434 | clearList(); |
435 | readListFromFile(lnk.file()); | 435 | readListFromFile(lnk.file()); |
436 | tabWidget->setCurrentPage(0); | 436 | tabWidget->setCurrentPage(0); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
440 | void PlayListWidget::addSelected() { | 440 | void PlayListWidget::addSelected() { |
441 | assert( inFileListMode() ); | 441 | assert( inFileListMode() ); |
442 | 442 | ||
443 | QListViewItemIterator it( currentFileListView ); | 443 | QListViewItemIterator it( currentFileListView ); |
444 | for ( ; it.current(); ++it ) | 444 | for ( ; it.current(); ++it ) |
445 | if ( it.current()->isSelected() ) { | 445 | if ( it.current()->isSelected() ) { |
446 | QString filename = it.current()->text(3); | 446 | QString filename = it.current()->text(3); |
447 | 447 | ||
448 | DocLnk lnk; | 448 | DocLnk lnk; |
449 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 449 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
450 | lnk.setFile( filename ); //sets file name | 450 | lnk.setFile( filename ); //sets file name |
451 | 451 | ||
452 | d->selectedFiles->addToSelection( lnk ); | 452 | d->selectedFiles->addToSelection( lnk ); |
453 | } | 453 | } |
454 | 454 | ||
455 | currentFileListView->clearSelection(); | 455 | currentFileListView->clearSelection(); |
456 | 456 | ||
457 | writeCurrentM3u(); | 457 | writeCurrentM3u(); |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | void PlayListWidget::removeSelected() { | 461 | void PlayListWidget::removeSelected() { |
462 | d->selectedFiles->removeSelected( ); | 462 | d->selectedFiles->removeSelected( ); |
463 | writeCurrentM3u(); | 463 | writeCurrentM3u(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | void PlayListWidget::playIt( QListViewItem *it) { | 467 | void PlayListWidget::playIt( QListViewItem *it) { |
468 | if(!it) return; | 468 | if(!it) return; |
469 | mediaPlayerState.setPlaying(FALSE); | 469 | mediaPlayerState.setPlaying(FALSE); |
470 | mediaPlayerState.setPlaying(TRUE); | 470 | mediaPlayerState.setPlaying(TRUE); |
471 | d->selectedFiles->unSelect(); | 471 | d->selectedFiles->unSelect(); |
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | void PlayListWidget::addToSelection( QListViewItem *it) { | 475 | void PlayListWidget::addToSelection( QListViewItem *it) { |
476 | d->setDocumentUsed = FALSE; | 476 | d->setDocumentUsed = FALSE; |
477 | 477 | ||
478 | if(it) { | 478 | if(it) { |
479 | if ( currentTab() == CurrentPlayList ) | 479 | if ( currentTab() == CurrentPlayList ) |
480 | return; | 480 | return; |
481 | DocLnk lnk; | 481 | DocLnk lnk; |
482 | QString filename; | 482 | QString filename; |
483 | 483 | ||
484 | filename=it->text(3); | 484 | filename=it->text(3); |
485 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 485 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
486 | lnk.setFile( filename ); //sets file name | 486 | lnk.setFile( filename ); //sets file name |
487 | d->selectedFiles->addToSelection( lnk); | 487 | d->selectedFiles->addToSelection( lnk); |
488 | 488 | ||
489 | writeCurrentM3u(); | 489 | writeCurrentM3u(); |
490 | // tabWidget->setCurrentPage(0); | 490 | // tabWidget->setCurrentPage(0); |
491 | 491 | ||
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | 495 | ||
496 | void PlayListWidget::tabChanged(QWidget *) { | 496 | void PlayListWidget::tabChanged(QWidget *) { |
497 | 497 | ||
498 | d->tbPlay->setEnabled( true ); | 498 | d->tbPlay->setEnabled( true ); |
499 | 499 | ||
500 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), | 500 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), |
501 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 501 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
502 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), | 502 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), |
503 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 503 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
504 | 504 | ||
505 | currentFileListView = 0; | 505 | currentFileListView = 0; |
506 | 506 | ||
507 | switch ( currentTab() ) { | 507 | switch ( currentTab() ) { |
508 | case CurrentPlayList: | 508 | case CurrentPlayList: |
509 | { | 509 | { |
510 | if( !tbDeletePlaylist->isHidden() ) { | 510 | if( !tbDeletePlaylist->isHidden() ) { |
511 | tbDeletePlaylist->hide(); | 511 | tbDeletePlaylist->hide(); |
512 | } | 512 | } |
513 | d->tbRemoveFromList->setEnabled(TRUE); | 513 | d->tbRemoveFromList->setEnabled(TRUE); |
514 | d->tbAddToList->setEnabled(FALSE); | 514 | d->tbAddToList->setEnabled(FALSE); |
515 | 515 | ||
516 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 516 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
517 | } | 517 | } |
518 | break; | 518 | break; |
519 | case AudioFiles: | 519 | case AudioFiles: |
520 | { | 520 | { |
521 | audioView->populateView(); | 521 | audioView->populateView(); |
522 | 522 | ||
523 | if( !tbDeletePlaylist->isHidden() ) { | 523 | if( !tbDeletePlaylist->isHidden() ) { |
524 | tbDeletePlaylist->hide(); | 524 | tbDeletePlaylist->hide(); |
525 | } | 525 | } |
526 | d->tbRemoveFromList->setEnabled(FALSE); | 526 | d->tbRemoveFromList->setEnabled(FALSE); |
527 | d->tbAddToList->setEnabled(TRUE); | 527 | d->tbAddToList->setEnabled(TRUE); |
528 | 528 | ||
529 | connect( audioView, SIGNAL( itemsSelected( bool ) ), | 529 | connect( audioView, SIGNAL( itemsSelected( bool ) ), |
530 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 530 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
531 | 531 | ||
532 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 532 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
533 | 533 | ||
534 | currentFileListView = audioView; | 534 | currentFileListView = audioView; |
535 | } | 535 | } |
536 | break; | 536 | break; |
537 | case VideoFiles: | 537 | case VideoFiles: |
538 | { | 538 | { |
539 | videoView->populateView(); | 539 | videoView->populateView(); |
540 | if( !tbDeletePlaylist->isHidden() ) { | 540 | if( !tbDeletePlaylist->isHidden() ) { |
541 | tbDeletePlaylist->hide(); | 541 | tbDeletePlaylist->hide(); |
542 | } | 542 | } |
543 | d->tbRemoveFromList->setEnabled(FALSE); | 543 | d->tbRemoveFromList->setEnabled(FALSE); |
544 | d->tbAddToList->setEnabled(TRUE); | 544 | d->tbAddToList->setEnabled(TRUE); |
545 | 545 | ||
546 | connect( videoView, SIGNAL( itemsSelected( bool ) ), | 546 | connect( videoView, SIGNAL( itemsSelected( bool ) ), |
547 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 547 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
548 | 548 | ||
549 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 549 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
550 | 550 | ||
551 | currentFileListView = videoView; | 551 | currentFileListView = videoView; |
552 | } | 552 | } |
553 | break; | 553 | break; |
554 | case PlayLists: | 554 | case PlayLists: |
555 | { | 555 | { |
556 | if( tbDeletePlaylist->isHidden() ) { | 556 | if( tbDeletePlaylist->isHidden() ) { |
557 | tbDeletePlaylist->show(); | 557 | tbDeletePlaylist->show(); |
558 | } | 558 | } |
559 | playLists->reread(); | 559 | playLists->reread(); |
560 | d->tbAddToList->setEnabled(FALSE); | 560 | d->tbAddToList->setEnabled(FALSE); |
561 | 561 | ||
562 | d->tbPlay->setEnabled( false ); | 562 | d->tbPlay->setEnabled( false ); |
563 | } | 563 | } |
564 | break; | 564 | break; |
565 | }; | 565 | }; |
566 | } | 566 | } |
567 | 567 | ||
568 | 568 | ||
569 | void PlayListWidget::btnPlay(bool b) { | 569 | void PlayListWidget::btnPlay(bool b) { |
570 | // mediaPlayerState->setPlaying(false); | 570 | // mediaPlayerState->setPlaying(false); |
571 | mediaPlayerState.setPlaying(b); | 571 | mediaPlayerState.setPlaying(b); |
572 | insanityBool=FALSE; | 572 | insanityBool=FALSE; |
573 | } | 573 | } |
574 | 574 | ||
575 | void PlayListWidget::deletePlaylist() { | 575 | void PlayListWidget::deletePlaylist() { |
576 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 576 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
577 | (tr("You really want to delete\nthis playlist?")), | 577 | (tr("You really want to delete\nthis playlist?")), |
578 | (tr("Yes")), (tr("No")), 0 )){ | 578 | (tr("Yes")), (tr("No")), 0 )){ |
579 | case 0: // Yes clicked, | 579 | case 0: // Yes clicked, |
580 | QFile().remove(playLists->selectedDocument().file()); | 580 | QFile().remove(playLists->selectedDocument().file()); |
581 | QFile().remove(playLists->selectedDocument().linkFile()); | 581 | QFile().remove(playLists->selectedDocument().linkFile()); |
582 | playLists->reread(); | 582 | playLists->reread(); |
583 | break; | 583 | break; |
584 | case 1: // Cancel | 584 | case 1: // Cancel |
585 | break; | 585 | break; |
586 | }; | 586 | }; |
587 | } | 587 | } |
588 | 588 | ||
589 | 589 | ||
590 | void PlayListWidget::playSelected() { | 590 | void PlayListWidget::playSelected() { |
591 | btnPlay( TRUE); | 591 | btnPlay( TRUE); |
592 | } | 592 | } |
593 | 593 | ||
594 | bool PlayListWidget::inFileListMode() const | 594 | bool PlayListWidget::inFileListMode() const |
595 | { | 595 | { |
596 | TabType tab = currentTab(); | 596 | TabType tab = currentTab(); |
597 | return tab == AudioFiles || tab == VideoFiles; | 597 | return tab == AudioFiles || tab == VideoFiles; |
598 | } | 598 | } |
599 | 599 | ||
600 | void PlayListWidget::openFile() { | 600 | void PlayListWidget::openFile() { |
601 | // http://66.28.164.33:2080 | 601 | // http://66.28.164.33:2080 |
602 | // http://somafm.com/star0242.m3u | 602 | // http://somafm.com/star0242.m3u |
603 | QString filename, name; | 603 | QString filename, name; |
604 | InputDialog *fileDlg; | 604 | InputDialog *fileDlg; |
605 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 605 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
606 | fileDlg->exec(); | 606 | fileDlg->exec(); |
607 | if( fileDlg->result() == 1 ) { | 607 | if( fileDlg->result() == 1 ) { |
608 | filename = fileDlg->text(); | 608 | filename = fileDlg->text(); |
609 | qDebug( "Selected filename is " + filename ); | 609 | qDebug( "Selected filename is " + filename ); |
610 | // Om3u *m3uList; | 610 | // Om3u *m3uList; |
611 | DocLnk lnk; | 611 | DocLnk lnk; |
612 | Config cfg( "OpiePlayer" ); | 612 | Config cfg( "OpiePlayer" ); |
613 | cfg.setGroup("PlayList"); | 613 | cfg.setGroup("PlayList"); |
614 | 614 | ||
615 | if(filename.left(4) == "http") { | 615 | if(filename.left(4) == "http") { |
616 | QString m3uFile, m3uFilePath; | 616 | QString m3uFile, m3uFilePath; |
617 | if(filename.find(":",8,TRUE) != -1) { //found a port | 617 | if(filename.find(":",8,TRUE) != -1) { //found a port |
618 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 618 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
619 | m3uFile = m3uFile.right( 7); | 619 | m3uFile = m3uFile.right( 7); |
620 | } else if(filename.left(4) == "http"){ | 620 | } else if(filename.left(4) == "http"){ |
621 | m3uFile=filename; | 621 | m3uFile=filename; |
622 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 622 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
623 | } else{ | 623 | } else{ |
624 | m3uFile=filename; | 624 | m3uFile=filename; |
625 | } | 625 | } |
626 | 626 | ||
627 | lnk.setName( filename ); //sets name | 627 | lnk.setName( filename ); //sets name |
628 | lnk.setFile( filename ); //sets file name | 628 | lnk.setFile( filename ); //sets file name |
629 | 629 | ||
630 | // lnk.setIcon("opieplayer2/musicfile"); | 630 | // lnk.setIcon("opieplayer2/musicfile"); |
631 | 631 | ||
632 | d->selectedFiles->addToSelection( lnk ); | 632 | d->selectedFiles->addToSelection( lnk ); |
633 | writeCurrentM3u(); | 633 | writeCurrentM3u(); |
634 | d->selectedFiles->setSelectedItem( lnk.name()); | 634 | d->selectedFiles->setSelectedItem( lnk.name()); |
635 | } | 635 | } |
636 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 636 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
637 | readListFromFile( filename ); | 637 | readListFromFile( filename ); |
638 | } else { | 638 | } else { |
639 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 639 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
640 | lnk.setFile( filename ); //sets file name | 640 | lnk.setFile( filename ); //sets file name |
641 | d->selectedFiles->addToSelection( lnk); | 641 | d->selectedFiles->addToSelection( lnk); |
642 | writeCurrentM3u(); | 642 | writeCurrentM3u(); |
643 | d->selectedFiles->setSelectedItem( lnk.name()); | 643 | d->selectedFiles->setSelectedItem( lnk.name()); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | 646 | ||
647 | 647 | ||
648 | delete fileDlg; | 648 | delete fileDlg; |
649 | } | 649 | } |
650 | 650 | ||
651 | void PlayListWidget::readListFromFile( const QString &filename ) { | 651 | void PlayListWidget::readListFromFile( const QString &filename ) { |
652 | qDebug( "read list filename " + filename ); | 652 | qDebug( "read list filename " + filename ); |
653 | QFileInfo fi(filename); | 653 | QFileInfo fi(filename); |
654 | Om3u *m3uList; | 654 | Om3u *m3uList; |
655 | QString s, name; | 655 | QString s, name; |
656 | m3uList = new Om3u( filename, IO_ReadOnly ); | 656 | m3uList = new Om3u( filename, IO_ReadOnly ); |
657 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 657 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
658 | m3uList->readM3u(); | 658 | m3uList->readM3u(); |
659 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 659 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
660 | m3uList->readPls(); | 660 | m3uList->readPls(); |
661 | 661 | ||
662 | DocLnk lnk; | 662 | DocLnk lnk; |
663 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 663 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
664 | s = *it; | 664 | s = *it; |
665 | // qDebug(s); | 665 | // qDebug(s); |
666 | if(s.left(4)=="http") { | 666 | if(s.left(4)=="http") { |
667 | lnk.setName( s ); //sets file name | 667 | lnk.setName( s ); //sets file name |
668 | lnk.setIcon("opieplayer2/musicfile"); | 668 | lnk.setIcon("opieplayer2/musicfile"); |
669 | lnk.setFile( s ); //sets file name | 669 | lnk.setFile( s ); //sets file name |
670 | 670 | ||
671 | } else { //is file | 671 | } else { //is file |
672 | lnk.setName( QFileInfo(s).baseName()); | 672 | lnk.setName( QFileInfo(s).baseName()); |
673 | if(s.left(1) != "/") { | 673 | if(s.left(1) != "/") { |
674 | 674 | ||
675 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 675 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
676 | } else { | 676 | } else { |
677 | lnk.setFile( s); | 677 | lnk.setFile( s); |
678 | } | 678 | } |
679 | } | 679 | } |
680 | d->selectedFiles->addToSelection( lnk ); | 680 | d->selectedFiles->addToSelection( lnk ); |
681 | } | 681 | } |
682 | Config config( "OpiePlayer" ); | 682 | Config config( "OpiePlayer" ); |
683 | config.setGroup( "PlayList" ); | 683 | config.setGroup( "PlayList" ); |
684 | 684 | ||
685 | config.writeEntry("CurrentPlaylist",filename); | 685 | config.writeEntry("CurrentPlaylist",filename); |
686 | config.write(); | 686 | config.write(); |
687 | currentPlayList=filename; | 687 | currentPlayList=filename; |
688 | 688 | ||
689 | m3uList->close(); | 689 | m3uList->close(); |
690 | delete m3uList; | 690 | delete m3uList; |
691 | 691 | ||
692 | d->selectedFiles->setSelectedItem( s); | 692 | d->selectedFiles->setSelectedItem( s); |
693 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 693 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
694 | 694 | ||
695 | } | 695 | } |
696 | 696 | ||
697 | // writes current playlist to current m3u file */ | 697 | // writes current playlist to current m3u file */ |
698 | void PlayListWidget::writeCurrentM3u() { | 698 | void PlayListWidget::writeCurrentM3u() { |
699 | qDebug("writing to current m3u"); | 699 | qDebug("writing to current m3u"); |
700 | Config cfg( "OpiePlayer" ); | 700 | Config cfg( "OpiePlayer" ); |
701 | cfg.setGroup("PlayList"); | 701 | cfg.setGroup("PlayList"); |
702 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 702 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
703 | 703 | ||
704 | Om3u *m3uList; | 704 | Om3u *m3uList; |
705 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 705 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
706 | if( d->selectedFiles->first()) { | 706 | if( d->selectedFiles->first()) { |
707 | 707 | ||
708 | do { | 708 | do { |
709 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 709 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
710 | m3uList->add( d->selectedFiles->current()->file() ); | 710 | m3uList->add( d->selectedFiles->current()->file() ); |
711 | } | 711 | } |
712 | while ( d->selectedFiles->next() ); | 712 | while ( d->selectedFiles->next() ); |
713 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 713 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
714 | m3uList->write(); | 714 | m3uList->write(); |
715 | m3uList->close(); | 715 | m3uList->close(); |
716 | } | 716 | } |
717 | delete m3uList; | 717 | delete m3uList; |
718 | 718 | ||
719 | } | 719 | } |
720 | 720 | ||
721 | /* | 721 | /* |
722 | writes current playlist to m3u file */ | 722 | writes current playlist to m3u file */ |
723 | void PlayListWidget::writem3u() { | 723 | void PlayListWidget::writem3u() { |
724 | InputDialog *fileDlg; | 724 | InputDialog *fileDlg; |
725 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 725 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
726 | fileDlg->exec(); | 726 | fileDlg->exec(); |
727 | QString name, filename, list; | 727 | QString name, filename, list; |
728 | Om3u *m3uList; | 728 | Om3u *m3uList; |
729 | 729 | ||
730 | if( fileDlg->result() == 1 ) { | 730 | if( fileDlg->result() == 1 ) { |
731 | name = fileDlg->text(); | 731 | name = fileDlg->text(); |
732 | // qDebug( filename ); | 732 | // qDebug( filename ); |
733 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 733 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
734 | filename = name; | 734 | filename = name; |
735 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 735 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
736 | } | 736 | } |
737 | else //otherwise dump it somewhere noticable | 737 | else //otherwise dump it somewhere noticable |
738 | filename = QPEApplication::documentDir() + "/" + name; | 738 | filename = QPEApplication::documentDir() + "/" + name; |
739 | 739 | ||
740 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 740 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
741 | filename += ".m3u"; | 741 | filename += ".m3u"; |
742 | 742 | ||
743 | if( d->selectedFiles->first()) { //ramble through playlist view | 743 | if( d->selectedFiles->first()) { //ramble through playlist view |
744 | m3uList = new Om3u( filename, IO_ReadWrite); | 744 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
745 | 745 | ||
746 | do { | 746 | do { |
747 | m3uList->add( d->selectedFiles->current()->file()); | 747 | m3uList->add( d->selectedFiles->current()->file()); |
748 | } | 748 | } |
749 | while ( d->selectedFiles->next() ); | 749 | while ( d->selectedFiles->next() ); |
750 | // qDebug( list ); | 750 | // qDebug( list ); |
751 | m3uList->write(); | 751 | m3uList->write(); |
752 | m3uList->close(); | 752 | m3uList->close(); |
753 | delete m3uList; | 753 | delete m3uList; |
754 | 754 | ||
755 | delete fileDlg; | 755 | delete fileDlg; |
756 | 756 | ||
757 | DocLnk lnk; | 757 | DocLnk lnk; |
758 | lnk.setFile( filename); | 758 | lnk.setFile( filename); |
759 | lnk.setIcon("opieplayer2/playlist2"); | 759 | lnk.setIcon("opieplayer2/playlist2"); |
760 | lnk.setName( name); //sets file name | 760 | lnk.setName( name); //sets file name |
761 | 761 | ||
762 | // qDebug(filename); | 762 | // qDebug(filename); |
763 | Config config( "OpiePlayer" ); | 763 | Config config( "OpiePlayer" ); |
764 | config.setGroup( "PlayList" ); | 764 | config.setGroup( "PlayList" ); |
765 | 765 | ||
766 | config.writeEntry("CurrentPlaylist",filename); | 766 | config.writeEntry("CurrentPlaylist",filename); |
767 | currentPlayList=filename; | 767 | currentPlayList=filename; |
768 | 768 | ||
769 | if(!lnk.writeLink()) { | 769 | if(!lnk.writeLink()) { |
770 | qDebug("Writing doclink did not work"); | 770 | qDebug("Writing doclink did not work"); |
771 | } | 771 | } |
772 | 772 | ||
773 | setCaption(tr("OpiePlayer: ") + name); | 773 | setCaption(tr("OpiePlayer: ") + name); |
774 | } | 774 | } |
775 | } | 775 | } |
776 | } | 776 | } |
777 | 777 | ||
778 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 778 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
779 | switch ( e->key() ) { | 779 | switch ( e->key() ) { |
780 | ////////////////////////////// Zaurus keys | 780 | ////////////////////////////// Zaurus keys |
781 | case Key_F9: //activity | 781 | case Key_F9: //activity |
782 | // if(audioUI->isHidden()) | 782 | // if(audioUI->isHidden()) |
783 | // audioUI->showMaximized(); | 783 | // audioUI->showMaximized(); |
784 | break; | 784 | break; |
785 | case Key_F10: //contacts | 785 | case Key_F10: //contacts |
786 | // if( videoUI->isHidden()) | 786 | // if( videoUI->isHidden()) |
787 | // videoUI->showMaximized(); | 787 | // videoUI->showMaximized(); |
788 | break; | 788 | break; |
789 | case Key_F11: //menu | 789 | case Key_F11: //menu |
790 | break; | 790 | break; |
791 | case Key_F12: //home | 791 | case Key_F12: //home |
792 | // doBlank(); | 792 | // doBlank(); |
793 | break; | 793 | break; |
794 | case Key_F13: //mail | 794 | case Key_F13: //mail |
795 | // doUnblank(); | 795 | // doUnblank(); |
796 | break; | 796 | break; |
797 | case Key_Q: //add to playlist | 797 | case Key_Q: //add to playlist |
798 | addSelected(); | 798 | addSelected(); |
799 | break; | 799 | break; |
800 | case Key_R: //remove from playlist | 800 | case Key_R: //remove from playlist |
801 | removeSelected(); | 801 | removeSelected(); |
802 | break; | 802 | break; |
803 | // case Key_P: //play | 803 | // case Key_P: //play |
804 | // qDebug("Play"); | 804 | // qDebug("Play"); |
805 | // playSelected(); | 805 | // playSelected(); |
806 | // break; | 806 | // break; |
807 | case Key_Space: | 807 | case Key_Space: |
808 | // playSelected(); puh | 808 | // playSelected(); puh |
809 | break; | 809 | break; |
810 | case Key_1: | 810 | case Key_1: |
811 | tabWidget->setCurrentPage( 0 ); | 811 | tabWidget->setCurrentPage( 0 ); |
812 | break; | 812 | break; |
813 | case Key_2: | 813 | case Key_2: |
814 | tabWidget->setCurrentPage( 1 ); | 814 | tabWidget->setCurrentPage( 1 ); |
815 | break; | 815 | break; |
816 | case Key_3: | 816 | case Key_3: |
817 | tabWidget->setCurrentPage( 2 ); | 817 | tabWidget->setCurrentPage( 2 ); |
818 | break; | 818 | break; |
819 | case Key_4: | 819 | case Key_4: |
820 | tabWidget->setCurrentPage( 3 ); | 820 | tabWidget->setCurrentPage( 3 ); |
821 | break; | 821 | break; |
822 | case Key_Down: | 822 | case Key_Down: |
823 | if ( !d->selectedFiles->next() ) | 823 | if ( !d->selectedFiles->next() ) |
824 | d->selectedFiles->first(); | 824 | d->selectedFiles->first(); |
825 | break; | 825 | break; |
826 | case Key_Up: | 826 | case Key_Up: |
827 | if ( !d->selectedFiles->prev() ) | 827 | if ( !d->selectedFiles->prev() ) |
828 | // d->selectedFiles->last(); | 828 | // d->selectedFiles->last(); |
829 | break; | 829 | break; |
830 | } | 830 | } |
831 | } | 831 | } |
832 | 832 | ||
833 | void PlayListWidget::pmViewActivated(int index) { | 833 | void PlayListWidget::pmViewActivated(int index) { |
834 | // qDebug("%d", index); | 834 | // qDebug("%d", index); |
835 | switch(index) { | 835 | switch(index) { |
836 | case -16: | 836 | case -16: |
837 | { | 837 | { |
838 | mediaPlayerState.toggleFullscreen(); | 838 | mediaPlayerState.toggleFullscreen(); |
839 | bool b=mediaPlayerState.isFullscreen(); | 839 | bool b=mediaPlayerState.isFullscreen(); |
840 | pmView->setItemChecked( index, b); | 840 | pmView->setItemChecked( index, b); |
841 | Config cfg( "OpiePlayer" ); | 841 | Config cfg( "OpiePlayer" ); |
842 | cfg.writeEntry( "FullScreen", b ); | 842 | cfg.writeEntry( "FullScreen", b ); |
843 | } | 843 | } |
844 | break; | 844 | break; |
845 | }; | 845 | }; |
846 | } | 846 | } |
847 | 847 | ||
848 | void PlayListWidget::populateSkinsMenu() { | 848 | void PlayListWidget::populateSkinsMenu() { |
849 | int item = 0; | 849 | int item = 0; |
850 | defaultSkinIndex = 0; | 850 | defaultSkinIndex = 0; |
851 | QString skinName; | 851 | QString skinName; |
852 | Config cfg( "OpiePlayer" ); | 852 | Config cfg( "OpiePlayer" ); |
853 | cfg.setGroup("Options" ); | 853 | cfg.setGroup("Options" ); |
854 | QString skin = cfg.readEntry( "Skin", "default" ); | 854 | QString skin = cfg.readEntry( "Skin", "default" ); |
855 | 855 | ||
856 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 856 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
857 | skinsDir.setFilter( QDir::Dirs ); | 857 | skinsDir.setFilter( QDir::Dirs ); |
858 | skinsDir.setSorting(QDir::Name ); | 858 | skinsDir.setSorting(QDir::Name ); |
859 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 859 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
860 | QFileInfoListIterator it( *skinslist ); | 860 | QFileInfoListIterator it( *skinslist ); |
861 | QFileInfo *fi; | 861 | QFileInfo *fi; |
862 | while ( ( fi = it.current() ) ) { | 862 | while ( ( fi = it.current() ) ) { |
863 | skinName = fi->fileName(); | 863 | skinName = fi->fileName(); |
864 | // qDebug( fi->fileName() ); | 864 | // qDebug( fi->fileName() ); |
865 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 865 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
866 | item = skinsMenu->insertItem( fi->fileName() ) ; | 866 | item = skinsMenu->insertItem( fi->fileName() ) ; |
867 | } | 867 | } |
868 | if( skinName == "default" ) { | 868 | if( skinName == "default" ) { |
869 | defaultSkinIndex = item; | 869 | defaultSkinIndex = item; |
870 | } | 870 | } |
871 | if( skinName == skin ) { | 871 | if( skinName == skin ) { |
872 | skinsMenu->setItemChecked( item, TRUE ); | 872 | skinsMenu->setItemChecked( item, TRUE ); |
873 | } | 873 | } |
874 | ++it; | 874 | ++it; |
875 | } | 875 | } |
876 | } | 876 | } |
877 | 877 | ||
878 | void PlayListWidget::skinsMenuActivated( int item ) { | 878 | void PlayListWidget::skinsMenuActivated( int item ) { |
879 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 879 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
880 | skinsMenu->setItemChecked( i, FALSE ); | 880 | skinsMenu->setItemChecked( i, FALSE ); |
881 | } | 881 | } |
882 | skinsMenu->setItemChecked( item, TRUE ); | 882 | skinsMenu->setItemChecked( item, TRUE ); |
883 | 883 | ||
884 | { | 884 | { |
885 | Config cfg( "OpiePlayer" ); | 885 | Config cfg( "OpiePlayer" ); |
886 | cfg.setGroup("Options"); | 886 | cfg.setGroup("Options"); |
887 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 887 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
888 | } | 888 | } |
889 | 889 | ||
890 | emit skinSelected(); | 890 | emit skinSelected(); |
891 | } | 891 | } |
892 | 892 | ||
893 | PlayListWidget::TabType PlayListWidget::currentTab() const | 893 | PlayListWidget::TabType PlayListWidget::currentTab() const |
894 | { | 894 | { |
895 | static const TabType indexToTabType[ TabTypeCount ] = | 895 | static const TabType indexToTabType[ TabTypeCount ] = |
896 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 896 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
897 | 897 | ||
898 | int index = tabWidget->currentPageIndex(); | 898 | int index = tabWidget->currentPageIndex(); |
899 | assert( index < TabTypeCount && index >= 0 ); | 899 | assert( index < TabTypeCount && index >= 0 ); |
900 | 900 | ||
901 | return indexToTabType[ index ]; | 901 | return indexToTabType[ index ]; |
902 | } | 902 | } |
903 | 903 | ||
904 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 904 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
905 | { | 905 | { |
906 | if ( currentTab() == CurrentPlayList ) { | 906 | if ( currentTab() == CurrentPlayList ) { |
907 | const DocLnk *lnk = current(); | 907 | const DocLnk *lnk = current(); |
908 | return Entry( lnk->name(), lnk->file() ); | 908 | return Entry( lnk->name(), lnk->file() ); |
909 | } | 909 | } |
910 | 910 | ||
911 | return Entry( currentFileListPathName() ); | 911 | return Entry( currentFileListPathName() ); |
912 | } | 912 | } |
913 | 913 | ||
914 | QString PlayListWidget::currentFileListPathName() const { | 914 | QString PlayListWidget::currentFileListPathName() const { |
915 | return currentFileListView->currentItem()->text( 3 ); | 915 | return currentFileListView->currentItem()->text( 3 ); |
916 | } | 916 | } |