-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 39 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 1 |
2 files changed, 26 insertions, 14 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index c6de5e6..5d0f6de 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,1494 +1,1505 @@ | |||
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 | // audioUI->setFocus(); | ||
366 | } | 367 | } |
367 | 368 | ||
368 | 369 | ||
369 | PlayListWidget::~PlayListWidget() { | 370 | PlayListWidget::~PlayListWidget() { |
370 | Config cfg( "OpiePlayer" ); | 371 | Config cfg( "OpiePlayer" ); |
371 | writeConfig( cfg ); | 372 | writeConfig( cfg ); |
372 | 373 | ||
373 | if ( d->current ) | 374 | if ( d->current ) |
374 | delete d->current; | 375 | delete d->current; |
375 | delete d; | 376 | if(d) delete d; |
376 | } | 377 | } |
377 | 378 | ||
378 | 379 | ||
379 | void PlayListWidget::initializeStates() { | 380 | void PlayListWidget::initializeStates() { |
380 | 381 | ||
381 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 382 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
382 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 383 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
383 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 384 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
384 | setPlaylist( true); | 385 | setPlaylist( true); |
385 | } | 386 | } |
386 | 387 | ||
387 | 388 | ||
388 | void PlayListWidget::readConfig( Config& cfg ) { | 389 | void PlayListWidget::readConfig( Config& cfg ) { |
389 | cfg.setGroup("PlayList"); | 390 | cfg.setGroup("PlayList"); |
390 | QString currentString = cfg.readEntry("current", "" ); | 391 | QString currentString = cfg.readEntry("current", "" ); |
391 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 392 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
392 | for ( int i = 0; i < noOfFiles; i++ ) { | 393 | for ( int i = 0; i < noOfFiles; i++ ) { |
393 | QString entryName; | 394 | QString entryName; |
394 | entryName.sprintf( "File%i", i + 1 ); | 395 | entryName.sprintf( "File%i", i + 1 ); |
395 | QString linkFile = cfg.readEntry( entryName ); | 396 | QString linkFile = cfg.readEntry( entryName ); |
396 | DocLnk lnk( linkFile ); | 397 | DocLnk lnk( linkFile ); |
397 | if ( lnk.isValid() ) { | 398 | if ( lnk.isValid() ) { |
398 | d->selectedFiles->addToSelection( lnk ); | 399 | d->selectedFiles->addToSelection( lnk ); |
399 | } | 400 | } |
400 | } | 401 | } |
401 | d->selectedFiles->setSelectedItem( currentString); | 402 | d->selectedFiles->setSelectedItem( currentString); |
402 | } | 403 | } |
403 | 404 | ||
404 | 405 | ||
405 | void PlayListWidget::writeConfig( Config& cfg ) const { | 406 | void PlayListWidget::writeConfig( Config& cfg ) const { |
406 | 407 | ||
407 | d->selectedFiles->writeCurrent( cfg); | 408 | d->selectedFiles->writeCurrent( cfg); |
408 | cfg.setGroup("PlayList"); | 409 | cfg.setGroup("PlayList"); |
409 | int noOfFiles = 0; | 410 | int noOfFiles = 0; |
410 | d->selectedFiles->first(); | 411 | d->selectedFiles->first(); |
411 | do { | 412 | do { |
412 | const DocLnk *lnk = d->selectedFiles->current(); | 413 | const DocLnk *lnk = d->selectedFiles->current(); |
413 | if ( lnk ) { | 414 | if ( lnk ) { |
414 | QString entryName; | 415 | QString entryName; |
415 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 416 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
416 | // qDebug(entryName); | 417 | // qDebug(entryName); |
417 | cfg.writeEntry( entryName, lnk->linkFile() ); | 418 | cfg.writeEntry( entryName, lnk->linkFile() ); |
418 | // if this link does exist, add it so we have the file | 419 | // if this link does exist, add it so we have the file |
419 | // next time... | 420 | // next time... |
420 | if ( !QFile::exists( lnk->linkFile() ) ) { | 421 | if ( !QFile::exists( lnk->linkFile() ) ) { |
421 | // the way writing lnks doesn't really check for out | 422 | // the way writing lnks doesn't really check for out |
422 | // of disk space, but check it anyway. | 423 | // of disk space, but check it anyway. |
423 | if ( !lnk->writeLink() ) { | 424 | if ( !lnk->writeLink() ) { |
424 | QMessageBox::critical( 0, tr("Out of space"), | 425 | QMessageBox::critical( 0, tr("Out of space"), |
425 | tr( "There was a problem saving " | 426 | tr( "There was a problem saving " |
426 | "the playlist.\n" | 427 | "the playlist.\n" |
427 | "Your playlist " | 428 | "Your playlist " |
428 | "may be missing some entries\n" | 429 | "may be missing some entries\n" |
429 | "the next time you start it." ) | 430 | "the next time you start it." ) |
430 | ); | 431 | ); |
431 | } | 432 | } |
432 | } | 433 | } |
433 | noOfFiles++; | 434 | noOfFiles++; |
434 | } | 435 | } |
435 | } | 436 | } |
436 | while ( d->selectedFiles->next() ); | 437 | while ( d->selectedFiles->next() ); |
437 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 438 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
438 | } | 439 | } |
439 | 440 | ||
440 | 441 | ||
441 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 442 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
442 | d->setDocumentUsed = false; | 443 | d->setDocumentUsed = false; |
443 | if ( mediaPlayerState->playlist() ) { | 444 | if ( mediaPlayerState->playlist() ) { |
444 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 445 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
445 | d->selectedFiles->addToSelection( lnk ); | 446 | d->selectedFiles->addToSelection( lnk ); |
446 | } | 447 | } |
447 | else | 448 | else |
448 | mediaPlayerState->setPlaying( true); | 449 | mediaPlayerState->setPlaying( true); |
449 | } | 450 | } |
450 | 451 | ||
451 | 452 | ||
452 | void PlayListWidget::clearList() { | 453 | void PlayListWidget::clearList() { |
453 | while ( first() ) | 454 | while ( first() ) |
454 | d->selectedFiles->removeSelected(); | 455 | d->selectedFiles->removeSelected(); |
455 | } | 456 | } |
456 | 457 | ||
457 | 458 | ||
458 | void PlayListWidget::addAllToList() { | 459 | void PlayListWidget::addAllToList() { |
459 | DocLnkSet filesAll; | 460 | DocLnkSet filesAll; |
460 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 461 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
461 | QListIterator<DocLnk> Adit( filesAll.children() ); | 462 | QListIterator<DocLnk> Adit( filesAll.children() ); |
462 | for ( ; Adit.current(); ++Adit ) | 463 | for ( ; Adit.current(); ++Adit ) |
463 | if(QFileInfo(Adit.current()->file()).exists()) | 464 | if(QFileInfo(Adit.current()->file()).exists()) |
464 | d->selectedFiles->addToSelection( **Adit ); | 465 | d->selectedFiles->addToSelection( **Adit ); |
465 | tabWidget->setCurrentPage(0); | 466 | tabWidget->setCurrentPage(0); |
466 | 467 | ||
467 | writeCurrentM3u(); | 468 | writeCurrentM3u(); |
468 | d->selectedFiles->first(); | 469 | d->selectedFiles->first(); |
469 | } | 470 | } |
470 | 471 | ||
471 | 472 | ||
472 | void PlayListWidget::addAllMusicToList() { | 473 | void PlayListWidget::addAllMusicToList() { |
473 | QListIterator<DocLnk> dit( files.children() ); | 474 | QListIterator<DocLnk> dit( files.children() ); |
474 | for ( ; dit.current(); ++dit ) | 475 | for ( ; dit.current(); ++dit ) |
475 | if(QFileInfo(dit.current()->file()).exists()) | 476 | if(QFileInfo(dit.current()->file()).exists()) |
476 | d->selectedFiles->addToSelection( **dit ); | 477 | d->selectedFiles->addToSelection( **dit ); |
477 | tabWidget->setCurrentPage(0); | 478 | tabWidget->setCurrentPage(0); |
478 | 479 | ||
479 | writeCurrentM3u(); | 480 | writeCurrentM3u(); |
480 | d->selectedFiles->first(); | 481 | d->selectedFiles->first(); |
481 | } | 482 | } |
482 | 483 | ||
483 | 484 | ||
484 | void PlayListWidget::addAllVideoToList() { | 485 | void PlayListWidget::addAllVideoToList() { |
485 | QListIterator<DocLnk> dit( vFiles.children() ); | 486 | QListIterator<DocLnk> dit( vFiles.children() ); |
486 | for ( ; dit.current(); ++dit ) | 487 | for ( ; dit.current(); ++dit ) |
487 | if(QFileInfo( dit.current()->file()).exists()) | 488 | if(QFileInfo( dit.current()->file()).exists()) |
488 | d->selectedFiles->addToSelection( **dit ); | 489 | d->selectedFiles->addToSelection( **dit ); |
489 | tabWidget->setCurrentPage(0); | 490 | tabWidget->setCurrentPage(0); |
490 | 491 | ||
491 | writeCurrentM3u(); | 492 | writeCurrentM3u(); |
492 | d->selectedFiles->first(); | 493 | d->selectedFiles->first(); |
493 | } | 494 | } |
494 | 495 | ||
495 | 496 | ||
496 | void PlayListWidget::setDocument(const QString& fileref) { | 497 | void PlayListWidget::setDocument(const QString& fileref) { |
497 | qDebug(fileref); | 498 | fromSetDocument = true; |
498 | fromSetDocument = TRUE; | 499 | d->setDocumentUsed = TRUE; |
500 | mediaPlayerState->setPlaying( FALSE ); | ||
501 | qApp->processEvents(); | ||
502 | mediaPlayerState->setPlaying( TRUE ); | ||
503 | } | ||
504 | |||
505 | void PlayListWidget::setDocumentEx(const QString& fileref) { | ||
506 | |||
499 | QFileInfo fileInfo(fileref); | 507 | QFileInfo fileInfo(fileref); |
500 | if ( !fileInfo.exists() ) { | 508 | if ( !fileInfo.exists() ) { |
501 | QMessageBox::critical( 0, tr( "Invalid File" ), | 509 | QMessageBox::critical( 0, tr( "Invalid File" ), |
502 | tr( "There was a problem in getting the file." ) ); | 510 | tr( "There was a problem in getting the file." ) ); |
503 | return; | 511 | return; |
504 | } | 512 | } |
505 | // qDebug("setDocument "+fileref); | 513 | qDebug("setDocument "+fileref); |
506 | QString extension = fileInfo.extension(false); | 514 | QString extension = fileInfo.extension(false); |
507 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 515 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
508 | readm3u( fileref); | 516 | readm3u( fileref); |
509 | } | 517 | } |
510 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 518 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
511 | readPls( fileref); | 519 | readPls( fileref); |
512 | } | 520 | } |
513 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 521 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
514 | clearList(); | 522 | clearList(); |
515 | DocLnk lnk; | 523 | DocLnk lnk; |
516 | lnk.setName( fileInfo.baseName() ); //sets name | 524 | lnk.setName( fileInfo.baseName() ); //sets name |
517 | lnk.setFile( fileref ); //sets file name | 525 | lnk.setFile( fileref ); //sets file name |
518 | //addToSelection( lnk ); | 526 | //addToSelection( lnk ); |
519 | 527 | ||
520 | loadList( lnk); | 528 | loadList( lnk); |
521 | d->selectedFiles->first(); | 529 | d->selectedFiles->first(); |
522 | } else { | 530 | } else { |
523 | clearList(); | 531 | clearList(); |
524 | DocLnk lnk; | 532 | DocLnk lnk; |
525 | lnk.setName( fileInfo.baseName() ); //sets name | 533 | lnk.setName( fileInfo.baseName() ); //sets name |
526 | lnk.setFile( fileref ); //sets file name | 534 | lnk.setFile( fileref ); //sets file name |
527 | addToSelection( lnk ); | 535 | addToSelection( lnk ); |
528 | // addToSelection( DocLnk( fileref ) ); | 536 | // addToSelection( DocLnk( fileref ) ); |
529 | d->setDocumentUsed = TRUE; | 537 | d->setDocumentUsed = TRUE; |
530 | mediaPlayerState->setPlaying( FALSE ); | 538 | mediaPlayerState->setPlaying( FALSE ); |
531 | qApp->processEvents(); | 539 | qApp->processEvents(); |
532 | mediaPlayerState->setPlaying( TRUE ); | 540 | mediaPlayerState->setPlaying( TRUE ); |
533 | qApp->processEvents(); | 541 | // qApp->processEvents(); |
534 | setCaption(tr("OpiePlayer")); | 542 | setCaption(tr("OpiePlayer")); |
535 | } | 543 | } |
536 | } | 544 | } |
537 | 545 | ||
538 | 546 | ||
539 | void PlayListWidget::setActiveWindow() { | 547 | void PlayListWidget::setActiveWindow() { |
540 | qDebug("SETTING active window"); | 548 | qDebug("SETTING active window"); |
541 | 549 | ||
542 | // When we get raised we need to ensure that it switches views | 550 | // When we get raised we need to ensure that it switches views |
543 | char origView = mediaPlayerState->view(); | 551 | char origView = mediaPlayerState->view(); |
544 | mediaPlayerState->setView( 'l' ); // invalidate | 552 | mediaPlayerState->setView( 'l' ); // invalidate |
545 | mediaPlayerState->setView( origView ); // now switch back | 553 | mediaPlayerState->setView( origView ); // now switch back |
546 | } | 554 | } |
547 | 555 | ||
548 | 556 | ||
549 | void PlayListWidget::useSelectedDocument() { | 557 | void PlayListWidget::useSelectedDocument() { |
550 | d->setDocumentUsed = FALSE; | 558 | d->setDocumentUsed = FALSE; |
551 | } | 559 | } |
552 | 560 | ||
553 | 561 | ||
554 | const DocLnk *PlayListWidget::current() { // this is fugly | 562 | const DocLnk *PlayListWidget::current() { // this is fugly |
555 | 563 | ||
556 | // if( fromSetDocument) { | 564 | // if( fromSetDocument) { |
557 | // qDebug("from setDoc"); | 565 | // qDebug("from setDoc"); |
558 | // DocLnkSet files; | 566 | // DocLnkSet files; |
559 | // Global::findDocuments(&files, "video/*;audio/*"); | 567 | // Global::findDocuments(&files, "video/*;audio/*"); |
560 | // QListIterator<DocLnk> dit( files.children() ); | 568 | // QListIterator<DocLnk> dit( files.children() ); |
561 | // for ( ; dit.current(); ++dit ) { | 569 | // for ( ; dit.current(); ++dit ) { |
562 | // if(dit.current()->linkFile() == setDocFileRef) { | 570 | // if(dit.current()->linkFile() == setDocFileRef) { |
563 | // qDebug(setDocFileRef); | 571 | // qDebug(setDocFileRef); |
564 | // return dit; | 572 | // return dit; |
565 | // } | 573 | // } |
566 | // } | 574 | // } |
567 | // } else | 575 | // } else |
568 | 576 | ||
569 | qDebug("current"); | 577 | qDebug("current"); |
570 | 578 | ||
571 | switch (tabWidget->currentPageIndex()) { | 579 | switch (tabWidget->currentPageIndex()) { |
572 | case 0: //playlist | 580 | case 0: //playlist |
573 | { | 581 | { |
574 | qDebug("playlist"); | 582 | qDebug("playlist"); |
575 | if ( mediaPlayerState->playlist() ) { | 583 | if ( mediaPlayerState->playlist() ) { |
576 | return d->selectedFiles->current(); | 584 | return d->selectedFiles->current(); |
577 | } | 585 | } |
578 | else if ( d->setDocumentUsed && d->current ) { | 586 | else if ( d->setDocumentUsed && d->current ) { |
579 | return d->current; | 587 | return d->current; |
580 | } else { | 588 | } else { |
581 | return &(d->files->selectedDocument()); | 589 | return &(d->files->selectedDocument()); |
582 | } | 590 | } |
583 | } | 591 | } |
584 | break; | 592 | break; |
585 | case 1://audio | 593 | case 1://audio |
586 | { | 594 | { |
587 | qDebug("audioView"); | 595 | qDebug("audioView"); |
588 | QListIterator<DocLnk> dit( files.children() ); | 596 | QListIterator<DocLnk> dit( files.children() ); |
589 | for ( ; dit.current(); ++dit ) { | 597 | for ( ; dit.current(); ++dit ) { |
590 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 598 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
591 | qDebug("here"); | 599 | qDebug("here"); |
592 | insanityBool=TRUE; | 600 | insanityBool=TRUE; |
593 | return dit; | 601 | return dit; |
594 | } | 602 | } |
595 | } | 603 | } |
596 | } | 604 | } |
597 | break; | 605 | break; |
598 | case 2: // video | 606 | case 2: // video |
599 | { | 607 | { |
600 | qDebug("videoView"); | 608 | qDebug("videoView"); |
601 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 609 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
602 | for ( ; Vdit.current(); ++Vdit ) { | 610 | for ( ; Vdit.current(); ++Vdit ) { |
603 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 611 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
604 | insanityBool=TRUE; | 612 | insanityBool=TRUE; |
605 | return Vdit; | 613 | return Vdit; |
606 | } | 614 | } |
607 | } | 615 | } |
608 | } | 616 | } |
609 | break; | 617 | break; |
610 | }; | 618 | }; |
611 | return 0; | 619 | return 0; |
612 | } | 620 | } |
613 | 621 | ||
614 | bool PlayListWidget::prev() { | 622 | bool PlayListWidget::prev() { |
615 | if ( mediaPlayerState->playlist() ) { | 623 | if ( mediaPlayerState->playlist() ) { |
616 | if ( mediaPlayerState->shuffled() ) { | 624 | if ( mediaPlayerState->shuffled() ) { |
617 | const DocLnk *cur = current(); | 625 | const DocLnk *cur = current(); |
618 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 626 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
619 | for ( int i = 0; i < j; i++ ) { | 627 | for ( int i = 0; i < j; i++ ) { |
620 | if ( !d->selectedFiles->next() ) | 628 | if ( !d->selectedFiles->next() ) |
621 | d->selectedFiles->first(); | 629 | d->selectedFiles->first(); |
622 | } | 630 | } |
623 | if ( cur == current() ) | 631 | if ( cur == current() ) |
624 | if ( !d->selectedFiles->next() ) | 632 | if ( !d->selectedFiles->next() ) |
625 | d->selectedFiles->first(); | 633 | d->selectedFiles->first(); |
626 | return TRUE; | 634 | return TRUE; |
627 | } else { | 635 | } else { |
628 | if ( !d->selectedFiles->prev() ) { | 636 | if ( !d->selectedFiles->prev() ) { |
629 | if ( mediaPlayerState->looping() ) { | 637 | if ( mediaPlayerState->looping() ) { |
630 | return d->selectedFiles->last(); | 638 | return d->selectedFiles->last(); |
631 | } else { | 639 | } else { |
632 | return FALSE; | 640 | return FALSE; |
633 | } | 641 | } |
634 | } | 642 | } |
635 | return TRUE; | 643 | return TRUE; |
636 | } | 644 | } |
637 | } else { | 645 | } else { |
638 | return mediaPlayerState->looping(); | 646 | return mediaPlayerState->looping(); |
639 | } | 647 | } |
640 | } | 648 | } |
641 | 649 | ||
642 | 650 | ||
643 | bool PlayListWidget::next() { | 651 | bool PlayListWidget::next() { |
644 | if ( mediaPlayerState->playlist() ) { | 652 | if ( mediaPlayerState->playlist() ) { |
645 | if ( mediaPlayerState->shuffled() ) { | 653 | if ( mediaPlayerState->shuffled() ) { |
646 | return prev(); | 654 | return prev(); |
647 | } else { | 655 | } else { |
648 | if ( !d->selectedFiles->next() ) { | 656 | if ( !d->selectedFiles->next() ) { |
649 | if ( mediaPlayerState->looping() ) { | 657 | if ( mediaPlayerState->looping() ) { |
650 | return d->selectedFiles->first(); | 658 | return d->selectedFiles->first(); |
651 | } else { | 659 | } else { |
652 | return FALSE; | 660 | return FALSE; |
653 | } | 661 | } |
654 | } | 662 | } |
655 | return TRUE; | 663 | return TRUE; |
656 | } | 664 | } |
657 | } else { | 665 | } else { |
658 | return mediaPlayerState->looping(); | 666 | return mediaPlayerState->looping(); |
659 | } | 667 | } |
660 | } | 668 | } |
661 | 669 | ||
662 | 670 | ||
663 | bool PlayListWidget::first() { | 671 | bool PlayListWidget::first() { |
664 | if ( mediaPlayerState->playlist() ) | 672 | if ( mediaPlayerState->playlist() ) |
665 | return d->selectedFiles->first(); | 673 | return d->selectedFiles->first(); |
666 | else | 674 | else |
667 | return mediaPlayerState->looping(); | 675 | return mediaPlayerState->looping(); |
668 | } | 676 | } |
669 | 677 | ||
670 | 678 | ||
671 | bool PlayListWidget::last() { | 679 | bool PlayListWidget::last() { |
672 | if ( mediaPlayerState->playlist() ) | 680 | if ( mediaPlayerState->playlist() ) |
673 | return d->selectedFiles->last(); | 681 | return d->selectedFiles->last(); |
674 | else | 682 | else |
675 | return mediaPlayerState->looping(); | 683 | return mediaPlayerState->looping(); |
676 | } | 684 | } |
677 | 685 | ||
678 | 686 | ||
679 | void PlayListWidget::saveList() { | 687 | void PlayListWidget::saveList() { |
680 | writem3u(); | 688 | writem3u(); |
681 | } | 689 | } |
682 | 690 | ||
683 | void PlayListWidget::loadList( const DocLnk & lnk) { | 691 | void PlayListWidget::loadList( const DocLnk & lnk) { |
684 | QString name = lnk.name(); | 692 | QString name = lnk.name(); |
685 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 693 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
686 | 694 | ||
687 | if( name.length()>0) { | 695 | if( name.length()>0) { |
688 | setCaption("OpiePlayer: "+name); | 696 | setCaption("OpiePlayer: "+name); |
689 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 697 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
690 | clearList(); | 698 | clearList(); |
691 | readm3u(lnk.file()); | 699 | readm3u(lnk.file()); |
692 | tabWidget->setCurrentPage(0); | 700 | tabWidget->setCurrentPage(0); |
693 | } | 701 | } |
694 | } | 702 | } |
695 | 703 | ||
696 | void PlayListWidget::setPlaylist( bool shown ) { | 704 | void PlayListWidget::setPlaylist( bool shown ) { |
697 | if ( shown ) | 705 | if ( shown ) |
698 | d->playListFrame->show(); | 706 | d->playListFrame->show(); |
699 | else | 707 | else |
700 | d->playListFrame->hide(); | 708 | d->playListFrame->hide(); |
701 | } | 709 | } |
702 | 710 | ||
703 | void PlayListWidget::setView( char view ) { | 711 | void PlayListWidget::setView( char view ) { |
704 | if ( view == 'l' ) | 712 | if ( view == 'l' ) |
705 | showMaximized(); | 713 | showMaximized(); |
706 | else | 714 | else |
707 | hide(); | 715 | hide(); |
708 | } | 716 | } |
709 | 717 | ||
710 | void PlayListWidget::addSelected() { | 718 | void PlayListWidget::addSelected() { |
711 | qDebug("addSelected"); | 719 | qDebug("addSelected"); |
712 | DocLnk lnk; | 720 | DocLnk lnk; |
713 | QString filename; | 721 | QString filename; |
714 | switch (tabWidget->currentPageIndex()) { | 722 | switch (tabWidget->currentPageIndex()) { |
715 | 723 | ||
716 | case 0: //playlist | 724 | case 0: //playlist |
717 | return; | 725 | return; |
718 | break; | 726 | break; |
719 | case 1: { //audio | 727 | case 1: { //audio |
720 | QListViewItemIterator it( audioView ); | 728 | QListViewItemIterator it( audioView ); |
721 | for ( ; it.current(); ++it ) { | 729 | for ( ; it.current(); ++it ) { |
722 | if ( it.current()->isSelected() ) { | 730 | if ( it.current()->isSelected() ) { |
723 | filename = it.current()->text(3); | 731 | filename = it.current()->text(3); |
724 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 732 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
725 | lnk.setFile( filename ); //sets file name | 733 | lnk.setFile( filename ); //sets file name |
726 | d->selectedFiles->addToSelection( lnk); | 734 | d->selectedFiles->addToSelection( lnk); |
727 | } | 735 | } |
728 | } | 736 | } |
729 | audioView->clearSelection(); | 737 | audioView->clearSelection(); |
730 | // d->selectedFiles->next(); | 738 | // d->selectedFiles->next(); |
731 | } | 739 | } |
732 | break; | 740 | break; |
733 | 741 | ||
734 | case 2: { // video | 742 | case 2: { // video |
735 | QListViewItemIterator it( videoView ); | 743 | QListViewItemIterator it( videoView ); |
736 | for ( ; it.current(); ++it ) { | 744 | for ( ; it.current(); ++it ) { |
737 | if ( it.current()->isSelected() ) { | 745 | if ( it.current()->isSelected() ) { |
738 | 746 | ||
739 | filename = it.current()->text(3); | 747 | filename = it.current()->text(3); |
740 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 748 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
741 | lnk.setFile( filename ); //sets file name | 749 | lnk.setFile( filename ); //sets file name |
742 | d->selectedFiles->addToSelection( lnk); | 750 | d->selectedFiles->addToSelection( lnk); |
743 | } | 751 | } |
744 | } | 752 | } |
745 | videoView->clearSelection(); | 753 | videoView->clearSelection(); |
746 | } | 754 | } |
747 | break; | 755 | break; |
748 | }; | 756 | }; |
749 | // tabWidget->setCurrentPage(0); | 757 | // tabWidget->setCurrentPage(0); |
750 | writeCurrentM3u(); | 758 | writeCurrentM3u(); |
751 | 759 | ||
752 | } | 760 | } |
753 | 761 | ||
754 | void PlayListWidget::removeSelected() { | 762 | void PlayListWidget::removeSelected() { |
755 | d->selectedFiles->removeSelected( ); | 763 | d->selectedFiles->removeSelected( ); |
756 | } | 764 | } |
757 | 765 | ||
758 | void PlayListWidget::playIt( QListViewItem *) { | 766 | void PlayListWidget::playIt( QListViewItem *) { |
759 | // d->setDocumentUsed = FALSE; | 767 | // d->setDocumentUsed = FALSE; |
760 | // mediaPlayerState->curPosition =0; | 768 | // mediaPlayerState->curPosition =0; |
761 | qDebug("playIt"); | 769 | qDebug("playIt"); |
762 | mediaPlayerState->setPlaying(FALSE); | 770 | // mediaPlayerState->setPlaying(FALSE); |
763 | mediaPlayerState->setPlaying(TRUE); | 771 | mediaPlayerState->setPlaying(TRUE); |
764 | d->selectedFiles->unSelect(); | 772 | d->selectedFiles->unSelect(); |
765 | } | 773 | } |
766 | 774 | ||
767 | void PlayListWidget::addToSelection( QListViewItem *it) { | 775 | void PlayListWidget::addToSelection( QListViewItem *it) { |
768 | d->setDocumentUsed = FALSE; | 776 | d->setDocumentUsed = FALSE; |
769 | 777 | ||
770 | if(it) { | 778 | if(it) { |
771 | switch ( tabWidget->currentPageIndex()) { | 779 | switch ( tabWidget->currentPageIndex()) { |
772 | case 0: //playlist | 780 | case 0: //playlist |
773 | return; | 781 | return; |
774 | break; | 782 | break; |
775 | }; | 783 | }; |
776 | // case 1: { | 784 | // case 1: { |
777 | DocLnk lnk; | 785 | DocLnk lnk; |
778 | QString filename; | 786 | QString filename; |
779 | 787 | ||
780 | filename=it->text(3); | 788 | filename=it->text(3); |
781 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 789 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
782 | lnk.setFile( filename ); //sets file name | 790 | lnk.setFile( filename ); //sets file name |
783 | d->selectedFiles->addToSelection( lnk); | 791 | d->selectedFiles->addToSelection( lnk); |
784 | 792 | ||
785 | writeCurrentM3u(); | 793 | if(tabWidget->currentPageIndex() == 0) |
794 | writeCurrentM3u(); | ||
786 | // tabWidget->setCurrentPage(0); | 795 | // tabWidget->setCurrentPage(0); |
787 | 796 | ||
788 | } | 797 | } |
789 | } | 798 | } |
790 | 799 | ||
791 | void PlayListWidget::tabChanged(QWidget *) { | 800 | void PlayListWidget::tabChanged(QWidget *) { |
792 | 801 | ||
793 | switch ( tabWidget->currentPageIndex()) { | 802 | switch ( tabWidget->currentPageIndex()) { |
794 | case 0: | 803 | case 0: |
795 | { | 804 | { |
796 | if( !tbDeletePlaylist->isHidden()) | 805 | if( !tbDeletePlaylist->isHidden()) |
797 | tbDeletePlaylist->hide(); | 806 | tbDeletePlaylist->hide(); |
798 | d->tbRemoveFromList->setEnabled(TRUE); | 807 | d->tbRemoveFromList->setEnabled(TRUE); |
799 | d->tbAddToList->setEnabled(FALSE); | 808 | d->tbAddToList->setEnabled(FALSE); |
800 | } | 809 | } |
801 | break; | 810 | break; |
802 | case 1: | 811 | case 1: |
803 | { | 812 | { |
804 | audioView->clear(); | 813 | audioView->clear(); |
805 | populateAudioView(); | 814 | populateAudioView(); |
806 | 815 | ||
807 | if( !tbDeletePlaylist->isHidden()) | 816 | if( !tbDeletePlaylist->isHidden()) |
808 | tbDeletePlaylist->hide(); | 817 | tbDeletePlaylist->hide(); |
809 | d->tbRemoveFromList->setEnabled(FALSE); | 818 | d->tbRemoveFromList->setEnabled(FALSE); |
810 | d->tbAddToList->setEnabled(TRUE); | 819 | d->tbAddToList->setEnabled(TRUE); |
811 | } | 820 | } |
812 | break; | 821 | break; |
813 | case 2: | 822 | case 2: |
814 | { | 823 | { |
815 | videoView->clear(); | 824 | videoView->clear(); |
816 | populateVideoView(); | 825 | populateVideoView(); |
817 | if( !tbDeletePlaylist->isHidden()) | 826 | if( !tbDeletePlaylist->isHidden()) |
818 | tbDeletePlaylist->hide(); | 827 | tbDeletePlaylist->hide(); |
819 | d->tbRemoveFromList->setEnabled(FALSE); | 828 | d->tbRemoveFromList->setEnabled(FALSE); |
820 | d->tbAddToList->setEnabled(TRUE); | 829 | d->tbAddToList->setEnabled(TRUE); |
821 | } | 830 | } |
822 | break; | 831 | break; |
823 | case 3: | 832 | case 3: |
824 | { | 833 | { |
825 | if( tbDeletePlaylist->isHidden()) | 834 | if( tbDeletePlaylist->isHidden()) |
826 | tbDeletePlaylist->show(); | 835 | tbDeletePlaylist->show(); |
827 | playLists->reread(); | 836 | playLists->reread(); |
828 | } | 837 | } |
829 | break; | 838 | break; |
830 | }; | 839 | }; |
831 | } | 840 | } |
832 | 841 | ||
833 | void PlayListWidget::btnPlay(bool b) { | 842 | void PlayListWidget::btnPlay(bool b) { |
834 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | 843 | qDebug("<<<<<<<<<<<<<<<BtnPlay %d", b); |
835 | // mediaPlayerState->setPlaying(b); | 844 | // mediaPlayerState->setPlaying(b); |
836 | switch ( tabWidget->currentPageIndex()) { | 845 | switch ( tabWidget->currentPageIndex()) { |
837 | case 0: | 846 | case 0: |
838 | { | 847 | { |
839 | qDebug("1"); | 848 | qDebug("1"); |
840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 849 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 850 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 851 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
843 | // } else { | 852 | // } else { |
844 | mediaPlayerState->setPlaying(b); | 853 | mediaPlayerState->setPlaying(b); |
845 | insanityBool=FALSE; | 854 | insanityBool=FALSE; |
846 | qDebug("insanity"); | 855 | qDebug("insanity"); |
847 | // } | 856 | // } |
848 | } | 857 | } |
849 | break; | 858 | break; |
850 | case 1: | 859 | case 1: |
851 | { | 860 | { |
852 | qDebug("2"); | 861 | qDebug("2"); |
853 | // d->selectedFiles->unSelect(); | 862 | // d->selectedFiles->unSelect(); |
854 | addToSelection( audioView->currentItem() ); | 863 | addToSelection( audioView->currentItem() ); |
855 | mediaPlayerState->setPlaying(true); | 864 | mediaPlayerState->setPlaying( b); |
856 | d->selectedFiles->removeSelected( ); | 865 | d->selectedFiles->removeSelected( ); |
857 | d->selectedFiles->unSelect(); | 866 | d->selectedFiles->unSelect(); |
858 | tabWidget->setCurrentPage(1); | 867 | tabWidget->setCurrentPage(1); |
859 | insanityBool=FALSE; | 868 | insanityBool=FALSE; |
860 | }// audioView->clearSelection(); | 869 | }// audioView->clearSelection(); |
861 | break; | 870 | break; |
862 | case 2: | 871 | case 2: |
863 | { | 872 | { |
864 | qDebug("3"); | 873 | qDebug("3"); |
865 | 874 | ||
866 | addToSelection( videoView->currentItem() ); | 875 | addToSelection( videoView->currentItem() ); |
867 | mediaPlayerState->setPlaying(true); | 876 | mediaPlayerState->setPlaying( b); |
868 | // qApp->processEvents(); | 877 | // qApp->processEvents(); |
869 | d->selectedFiles->removeSelected( ); | 878 | d->selectedFiles->removeSelected( ); |
870 | d->selectedFiles->unSelect(); | 879 | d->selectedFiles->unSelect(); |
871 | tabWidget->setCurrentPage(2); | 880 | tabWidget->setCurrentPage(2); |
872 | insanityBool=FALSE; | 881 | insanityBool=FALSE; |
873 | }// videoView->clearSelection(); | 882 | }// videoView->clearSelection(); |
874 | break; | 883 | break; |
875 | }; | 884 | }; |
876 | 885 | ||
877 | } | 886 | } |
878 | 887 | ||
879 | void PlayListWidget::deletePlaylist() { | 888 | void PlayListWidget::deletePlaylist() { |
880 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 889 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
881 | (tr("You really want to delete\nthis playlist?")), | 890 | (tr("You really want to delete\nthis playlist?")), |
882 | (tr("Yes")), (tr("No")), 0 )){ | 891 | (tr("Yes")), (tr("No")), 0 )){ |
883 | case 0: // Yes clicked, | 892 | case 0: // Yes clicked, |
884 | QFile().remove(playLists->selectedDocument().file()); | 893 | QFile().remove(playLists->selectedDocument().file()); |
885 | QFile().remove(playLists->selectedDocument().linkFile()); | 894 | QFile().remove(playLists->selectedDocument().linkFile()); |
886 | playLists->reread(); | 895 | playLists->reread(); |
887 | break; | 896 | break; |
888 | case 1: // Cancel | 897 | case 1: // Cancel |
889 | break; | 898 | break; |
890 | }; | 899 | }; |
891 | } | 900 | } |
892 | 901 | ||
893 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 902 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
894 | { | 903 | { |
895 | switch (mouse) { | 904 | switch (mouse) { |
896 | case 1: | 905 | case 1: |
897 | break; | 906 | break; |
898 | case 2:{ | 907 | case 2:{ |
899 | 908 | ||
900 | QPopupMenu m; | 909 | QPopupMenu m; |
901 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 910 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
902 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 911 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
903 | m.insertSeparator(); | 912 | m.insertSeparator(); |
904 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 913 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
905 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 914 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
906 | 915 | ||
907 | m.exec( QCursor::pos() ); | 916 | m.exec( QCursor::pos() ); |
908 | } | 917 | } |
909 | break; | 918 | break; |
910 | }; | 919 | }; |
911 | } | 920 | } |
912 | 921 | ||
913 | void PlayListWidget::playSelected() | 922 | void PlayListWidget::playSelected() |
914 | { | 923 | { |
915 | qDebug("playSelected"); | 924 | qDebug("playSelected"); |
916 | btnPlay( true); | 925 | btnPlay( true); |
917 | // d->selectedFiles->unSelect(); | 926 | // d->selectedFiles->unSelect(); |
918 | } | 927 | } |
919 | 928 | ||
920 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 929 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
921 | { | 930 | { |
922 | switch (mouse) { | 931 | switch (mouse) { |
923 | case 1: | 932 | case 1: |
924 | 933 | ||
925 | break; | 934 | break; |
926 | case 2:{ | 935 | case 2:{ |
927 | QPopupMenu m; | 936 | QPopupMenu m; |
928 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 937 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
929 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 938 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
930 | // m.insertSeparator(); | 939 | // m.insertSeparator(); |
931 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 940 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
932 | m.exec( QCursor::pos() ); | 941 | m.exec( QCursor::pos() ); |
933 | } | 942 | } |
934 | break; | 943 | break; |
935 | }; | 944 | }; |
936 | 945 | ||
937 | } | 946 | } |
938 | 947 | ||
939 | void PlayListWidget::listDelete() { | 948 | void PlayListWidget::listDelete() { |
940 | Config cfg( "OpiePlayer" ); | 949 | Config cfg( "OpiePlayer" ); |
941 | cfg.setGroup("PlayList"); | 950 | cfg.setGroup("PlayList"); |
942 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 951 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
943 | QString file; | 952 | QString file; |
944 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 953 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
945 | switch ( tabWidget->currentPageIndex()) { | 954 | switch ( tabWidget->currentPageIndex()) { |
946 | case 0: | 955 | case 0: |
947 | break; | 956 | break; |
948 | case 1: | 957 | case 1: |
949 | { | 958 | { |
950 | file = audioView->currentItem()->text(0); | 959 | file = audioView->currentItem()->text(0); |
951 | QListIterator<DocLnk> Pdit( files.children() ); | 960 | QListIterator<DocLnk> Pdit( files.children() ); |
952 | for ( ; Pdit.current(); ++Pdit ) { | 961 | for ( ; Pdit.current(); ++Pdit ) { |
953 | if( Pdit.current()->name() == file) { | 962 | if( Pdit.current()->name() == file) { |
954 | LnkProperties prop( Pdit.current() ); | 963 | LnkProperties prop( Pdit.current() ); |
955 | prop.showMaximized(); | 964 | prop.showMaximized(); |
956 | prop.exec(); | 965 | prop.exec(); |
957 | } | 966 | } |
958 | } | 967 | } |
959 | populateAudioView(); | 968 | populateAudioView(); |
960 | } | 969 | } |
961 | break; | 970 | break; |
962 | case 2: | 971 | case 2: |
963 | { | 972 | { |
964 | // file = videoView->selectedItem()->text(0); | 973 | // file = videoView->selectedItem()->text(0); |
965 | // for ( int i = 0; i < noOfFiles; i++ ) { | 974 | // for ( int i = 0; i < noOfFiles; i++ ) { |
966 | // QString entryName; | 975 | // QString entryName; |
967 | // entryName.sprintf( "File%i", i + 1 ); | 976 | // entryName.sprintf( "File%i", i + 1 ); |
968 | // QString linkFile = cfg.readEntry( entryName ); | 977 | // QString linkFile = cfg.readEntry( entryName ); |
969 | // AppLnk lnk( AppLnk(linkFile)); | 978 | // AppLnk lnk( AppLnk(linkFile)); |
970 | // if( lnk.name() == file ) { | 979 | // if( lnk.name() == file ) { |
971 | // LnkProperties prop( &lnk); | 980 | // LnkProperties prop( &lnk); |
972 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 981 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
973 | // prop.showMaximized(); | 982 | // prop.showMaximized(); |
974 | // prop.exec(); | 983 | // prop.exec(); |
975 | // } | 984 | // } |
976 | // } | 985 | // } |
977 | } | 986 | } |
978 | break; | 987 | break; |
979 | }; | 988 | }; |
980 | } | 989 | } |
981 | 990 | ||
982 | void PlayListWidget::scanForAudio() { | 991 | void PlayListWidget::scanForAudio() { |
983 | // qDebug("scan for audio"); | 992 | // qDebug("scan for audio"); |
984 | files.detachChildren(); | 993 | files.detachChildren(); |
985 | QListIterator<DocLnk> sdit( files.children() ); | 994 | QListIterator<DocLnk> sdit( files.children() ); |
986 | for ( ; sdit.current(); ++sdit ) { | 995 | for ( ; sdit.current(); ++sdit ) { |
987 | delete sdit.current(); | 996 | delete sdit.current(); |
988 | } | 997 | } |
989 | Global::findDocuments( &files, audioMimes); | 998 | Global::findDocuments( &files, audioMimes); |
990 | audioScan = true; | 999 | audioScan = true; |
991 | } | 1000 | } |
992 | void PlayListWidget::scanForVideo() { | 1001 | void PlayListWidget::scanForVideo() { |
993 | // qDebug("scan for video"); | 1002 | // qDebug("scan for video"); |
994 | vFiles.detachChildren(); | 1003 | vFiles.detachChildren(); |
995 | QListIterator<DocLnk> sdit( vFiles.children() ); | 1004 | QListIterator<DocLnk> sdit( vFiles.children() ); |
996 | for ( ; sdit.current(); ++sdit ) { | 1005 | for ( ; sdit.current(); ++sdit ) { |
997 | delete sdit.current(); | 1006 | delete sdit.current(); |
998 | } | 1007 | } |
999 | Global::findDocuments(&vFiles, "video/*"); | 1008 | Global::findDocuments(&vFiles, "video/*"); |
1000 | videoScan = true; | 1009 | videoScan = true; |
1001 | } | 1010 | } |
1002 | 1011 | ||
1003 | void PlayListWidget::populateAudioView() { | 1012 | void PlayListWidget::populateAudioView() { |
1004 | 1013 | ||
1005 | audioView->clear(); | 1014 | audioView->clear(); |
1006 | StorageInfo storageInfo; | 1015 | StorageInfo storageInfo; |
1007 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1016 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1008 | if(!audioScan) scanForAudio(); | 1017 | if(!audioScan) scanForAudio(); |
1009 | 1018 | ||
1010 | QListIterator<DocLnk> dit( files.children() ); | 1019 | QListIterator<DocLnk> dit( files.children() ); |
1011 | QListIterator<FileSystem> it ( fs ); | 1020 | QListIterator<FileSystem> it ( fs ); |
1012 | 1021 | ||
1013 | QString storage; | 1022 | QString storage; |
1014 | for ( ; dit.current(); ++dit ) { | 1023 | for ( ; dit.current(); ++dit ) { |
1015 | for( ; it.current(); ++it ){ | 1024 | for( ; it.current(); ++it ){ |
1016 | const QString name = (*it)->name(); | 1025 | const QString name = (*it)->name(); |
1017 | const QString path = (*it)->path(); | 1026 | const QString path = (*it)->path(); |
1018 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1027 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1019 | } | 1028 | } |
1020 | 1029 | ||
1021 | QListViewItem * newItem; | 1030 | QListViewItem * newItem; |
1022 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 1031 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1023 | long size; | 1032 | long size; |
1024 | if( dit.current()->file().left(4) == "http" ) | 1033 | if( dit.current()->file().left(4) == "http" ) |
1025 | size=0; | 1034 | size=0; |
1026 | else | 1035 | else |
1027 | size = QFile( dit.current()->file() ).size(); | 1036 | size = QFile( dit.current()->file() ).size(); |
1028 | // qDebug(dit.current()->name()); | 1037 | // qDebug(dit.current()->name()); |
1029 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1038 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1030 | QString::number(size ), storage, dit.current()->file()); | 1039 | QString::number(size ), storage, dit.current()->file()); |
1031 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1040 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1032 | } | 1041 | } |
1033 | } | 1042 | } |
1034 | 1043 | ||
1035 | } | 1044 | } |
1036 | 1045 | ||
1037 | void PlayListWidget::populateVideoView() { | 1046 | void PlayListWidget::populateVideoView() { |
1038 | videoView->clear(); | 1047 | videoView->clear(); |
1039 | StorageInfo storageInfo; | 1048 | StorageInfo storageInfo; |
1040 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1049 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1041 | 1050 | ||
1042 | if(!videoScan ) scanForVideo(); | 1051 | if(!videoScan ) scanForVideo(); |
1043 | 1052 | ||
1044 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1053 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1045 | QListIterator<FileSystem> it ( fs ); | 1054 | QListIterator<FileSystem> it ( fs ); |
1046 | videoView->clear(); | 1055 | videoView->clear(); |
1047 | QString storage; | 1056 | QString storage; |
1048 | for ( ; Vdit.current(); ++Vdit ) { | 1057 | for ( ; Vdit.current(); ++Vdit ) { |
1049 | for( ; it.current(); ++it ){ | 1058 | for( ; it.current(); ++it ){ |
1050 | const QString name = (*it)->name(); | 1059 | const QString name = (*it)->name(); |
1051 | const QString path = (*it)->path(); | 1060 | const QString path = (*it)->path(); |
1052 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1061 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1053 | } | 1062 | } |
1054 | 1063 | ||
1055 | QListViewItem * newItem; | 1064 | QListViewItem * newItem; |
1056 | if ( QFile( Vdit.current()->file()).exists() ) { | 1065 | if ( QFile( Vdit.current()->file()).exists() ) { |
1057 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1066 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1058 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1067 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1059 | storage, Vdit.current()->file()); | 1068 | storage, Vdit.current()->file()); |
1060 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1069 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1061 | } | 1070 | } |
1062 | } | 1071 | } |
1063 | } | 1072 | } |
1064 | 1073 | ||
1065 | void PlayListWidget::openFile() { | 1074 | void PlayListWidget::openFile() { |
1066 | qDebug("<<<<<<<<<OPEN File"); | 1075 | qDebug("<<<<<<<<<OPEN File"); |
1067 | QString filename, name; | 1076 | QString filename, name; |
1068 | InputDialog *fileDlg; | 1077 | InputDialog *fileDlg; |
1069 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1078 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1070 | fileDlg->exec(); | 1079 | fileDlg->exec(); |
1071 | if( fileDlg->result() == 1 ) { | 1080 | if( fileDlg->result() == 1 ) { |
1072 | filename = fileDlg->text(); | 1081 | filename = fileDlg->text(); |
1073 | qDebug( "Selected filename is " + filename ); | 1082 | qDebug( "Selected filename is " + filename ); |
1074 | // Om3u *m3uList; | 1083 | // Om3u *m3uList; |
1075 | DocLnk lnk; | 1084 | DocLnk lnk; |
1076 | Config cfg( "OpiePlayer" ); | 1085 | Config cfg( "OpiePlayer" ); |
1077 | cfg.setGroup("PlayList"); | 1086 | cfg.setGroup("PlayList"); |
1078 | 1087 | ||
1079 | QString m3uFile; | 1088 | QString m3uFile; |
1080 | m3uFile = filename; | 1089 | m3uFile = filename; |
1081 | if(filename.left(4) == "http") { | 1090 | if(filename.left(4) == "http") { |
1082 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1091 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1083 | 1092 | ||
1084 | // m3uFile = filename.left( filename.find( ":",8,TRUE)); | 1093 | // m3uFile = filename.left( filename.find( ":",8,TRUE)); |
1085 | m3uFile = filename; | 1094 | m3uFile = filename; |
1086 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1095 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1087 | m3uFile += "/"; | 1096 | m3uFile += "/"; |
1088 | } | 1097 | } |
1089 | filename = m3uFile; | 1098 | filename = m3uFile; |
1090 | // qDebug("1 "+m3uFile); | 1099 | // qDebug("1 "+m3uFile); |
1091 | // } else if(filename.left(4) == "http"){ | 1100 | // } else if(filename.left(4) == "http"){ |
1092 | // m3uFile=filename; | 1101 | // m3uFile=filename; |
1093 | // m3uFile = m3uFile.right( m3uFile.length() - 7); | 1102 | // m3uFile = m3uFile.right( m3uFile.length() - 7); |
1094 | // qDebug("2 "+m3uFile); | 1103 | // qDebug("2 "+m3uFile); |
1095 | // } else{ | 1104 | // } else{ |
1096 | // m3uFile=filename; | 1105 | // m3uFile=filename; |
1097 | // qDebug("3 "+m3uFile); | 1106 | // qDebug("3 "+m3uFile); |
1098 | } | 1107 | } |
1099 | lnk.setName( m3uFile ); //sets name | 1108 | lnk.setName( m3uFile ); //sets name |
1100 | lnk.setFile( filename ); //sets file name | 1109 | lnk.setFile( filename ); //sets file name |
1101 | lnk.setIcon("opieplayer2/musicfile"); | 1110 | lnk.setIcon("opieplayer2/musicfile"); |
1102 | d->selectedFiles->addToSelection( lnk ); | 1111 | d->selectedFiles->addToSelection( lnk ); |
1103 | writeCurrentM3u(); | 1112 | writeCurrentM3u(); |
1104 | } | 1113 | } |
1105 | else if( filename.right( 3) == "m3u" ) { | 1114 | else if( filename.right( 3) == "m3u" ) { |
1106 | readm3u( filename ); | 1115 | readm3u( filename ); |
1107 | 1116 | ||
1108 | } else if( filename.right(3) == "pls" ) { | 1117 | } else if( filename.right(3) == "pls" ) { |
1109 | readPls( filename ); | 1118 | readPls( filename ); |
1110 | } else { | 1119 | } else { |
1111 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1120 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1112 | lnk.setFile( filename ); //sets file name | 1121 | lnk.setFile( filename ); //sets file name |
1113 | d->selectedFiles->addToSelection( lnk); | 1122 | d->selectedFiles->addToSelection( lnk); |
1114 | writeCurrentM3u(); | 1123 | writeCurrentM3u(); |
1115 | } | 1124 | } |
1116 | } | 1125 | } |
1117 | 1126 | ||
1118 | if( fileDlg ) { | 1127 | if( fileDlg ) { |
1119 | delete fileDlg; | 1128 | delete fileDlg; |
1120 | } | 1129 | } |
1121 | } | 1130 | } |
1122 | 1131 | ||
1123 | 1132 | ||
1124 | /* | 1133 | /* |
1125 | reads m3u and shows files/urls to playlist widget */ | 1134 | reads m3u and shows files/urls to playlist widget */ |
1126 | void PlayListWidget::readm3u( const QString &filename ) { | 1135 | void PlayListWidget::readm3u( const QString &filename ) { |
1127 | qDebug( "read m3u filename " + filename ); | 1136 | qDebug( "read m3u filename " + filename ); |
1128 | 1137 | ||
1129 | Om3u *m3uList; | 1138 | Om3u *m3uList; |
1130 | QString s, name; | 1139 | QString s, name; |
1131 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1140 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1132 | m3uList->readM3u(); | 1141 | m3uList->readM3u(); |
1133 | DocLnk lnk; | 1142 | DocLnk lnk; |
1134 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1143 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1135 | s = *it; | 1144 | s = *it; |
1136 | // qDebug("reading "+ s); | 1145 | // qDebug("reading "+ s); |
1137 | if(s.left(4)=="http") { | 1146 | if(s.left(4)=="http") { |
1138 | lnk.setName( s ); //sets file name | 1147 | lnk.setName( s ); //sets file name |
1139 | lnk.setIcon("opieplayer2/musicfile"); | 1148 | lnk.setIcon("opieplayer2/musicfile"); |
1140 | 1149 | ||
1141 | // if(s.right(4) != '.' || s.right(5) != '.') | 1150 | // if(s.right(4) != '.' || s.right(5) != '.') |
1142 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1151 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1143 | if( s.right(1) != "/") | 1152 | if( s.right(1) != "/") |
1144 | lnk.setFile( s+"/"); //if url with no extension | 1153 | lnk.setFile( s+"/"); //if url with no extension |
1145 | else | 1154 | else |
1146 | lnk.setFile( s ); //sets file name | 1155 | lnk.setFile( s ); //sets file name |
1147 | 1156 | ||
1148 | } else { | 1157 | } else { |
1149 | // if( QFileInfo( s ).exists() ) { | 1158 | // if( QFileInfo( s ).exists() ) { |
1150 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1159 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1151 | // if(s.right(4) == '.') {//if regular file | 1160 | // if(s.right(4) == '.') {//if regular file |
1152 | if(s.left(1) != "/") { | 1161 | if(s.left(1) != "/") { |
1153 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1162 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1154 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1163 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1155 | lnk.setIcon("SoundPlayer"); | 1164 | lnk.setIcon("SoundPlayer"); |
1156 | } else { | 1165 | } else { |
1157 | // qDebug("set link2 "+s); | 1166 | // qDebug("set link2 "+s); |
1158 | lnk.setFile( s); | 1167 | lnk.setFile( s); |
1159 | lnk.setIcon("SoundPlayer"); | 1168 | lnk.setIcon("SoundPlayer"); |
1160 | } | 1169 | } |
1161 | } | 1170 | } |
1162 | d->selectedFiles->addToSelection( lnk ); | 1171 | d->selectedFiles->addToSelection( lnk ); |
1163 | } | 1172 | } |
1164 | Config config( "OpiePlayer" ); | 1173 | Config config( "OpiePlayer" ); |
1165 | config.setGroup( "PlayList" ); | 1174 | config.setGroup( "PlayList" ); |
1166 | 1175 | ||
1167 | config.writeEntry("CurrentPlaylist",filename); | 1176 | config.writeEntry("CurrentPlaylist",filename); |
1168 | config.write(); | 1177 | config.write(); |
1169 | currentPlayList=filename; | 1178 | currentPlayList=filename; |
1170 | 1179 | ||
1171 | // m3uList->write(); | 1180 | // m3uList->write(); |
1172 | m3uList->close(); | 1181 | m3uList->close(); |
1173 | if(m3uList) delete m3uList; | 1182 | if(m3uList) delete m3uList; |
1174 | 1183 | ||
1175 | d->selectedFiles->setSelectedItem( s); | 1184 | d->selectedFiles->setSelectedItem( s); |
1176 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1185 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1177 | 1186 | ||
1178 | } | 1187 | } |
1179 | 1188 | ||
1180 | /* | 1189 | /* |
1181 | reads pls and adds files/urls to playlist */ | 1190 | reads pls and adds files/urls to playlist */ |
1182 | void PlayListWidget::readPls( const QString &filename ) { | 1191 | void PlayListWidget::readPls( const QString &filename ) { |
1183 | 1192 | ||
1184 | qDebug( "pls filename is " + filename ); | 1193 | qDebug( "pls filename is " + filename ); |
1185 | Om3u *m3uList; | 1194 | Om3u *m3uList; |
1186 | QString s, name; | 1195 | QString s, name; |
1187 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1196 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1188 | m3uList->readPls(); | 1197 | m3uList->readPls(); |
1189 | 1198 | ||
1190 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1199 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1191 | s = *it; | 1200 | s = *it; |
1192 | // s.replace( QRegExp( "%20" )," " ); | 1201 | // s.replace( QRegExp( "%20" )," " ); |
1193 | DocLnk lnk( s ); | 1202 | DocLnk lnk( s ); |
1194 | QFileInfo f( s ); | 1203 | QFileInfo f( s ); |
1195 | QString name = fullBaseName ( f); | 1204 | QString name = fullBaseName ( f); |
1196 | 1205 | ||
1197 | if( name.left( 4 ) == "http" ) { | 1206 | if( name.left( 4 ) == "http" ) { |
1198 | name = s.right( s.length() - 7); | 1207 | name = s.right( s.length() - 7); |
1199 | } else { | 1208 | } else { |
1200 | name = s; | 1209 | name = s; |
1201 | } | 1210 | } |
1202 | 1211 | ||
1203 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1212 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1204 | 1213 | ||
1205 | lnk.setName( name ); | 1214 | lnk.setName( name ); |
1206 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1215 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1207 | lnk.setFile( s ); | 1216 | lnk.setFile( s ); |
1208 | } else { //if its a url | 1217 | } else { //if its a url |
1209 | if( name.right( 1 ).find( '/' ) == -1) { | 1218 | if( name.right( 1 ).find( '/' ) == -1) { |
1210 | s += "/"; | 1219 | s += "/"; |
1211 | } | 1220 | } |
1212 | lnk.setFile( s ); | 1221 | lnk.setFile( s ); |
1213 | } | 1222 | } |
1214 | lnk.setType( "audio/x-mpegurl" ); | 1223 | lnk.setType( "audio/x-mpegurl" ); |
1215 | 1224 | ||
1216 | lnk.writeLink(); | 1225 | lnk.writeLink(); |
1217 | d->selectedFiles->addToSelection( lnk ); | 1226 | d->selectedFiles->addToSelection( lnk ); |
1218 | } | 1227 | } |
1219 | 1228 | ||
1220 | m3uList->close(); | 1229 | m3uList->close(); |
1221 | if(m3uList) delete m3uList; | 1230 | if(m3uList) delete m3uList; |
1222 | } | 1231 | } |
1223 | 1232 | ||
1224 | /* | 1233 | /* |
1225 | writes current playlist to current m3u file */ | 1234 | writes current playlist to current m3u file */ |
1226 | void PlayListWidget::writeCurrentM3u() { | 1235 | void PlayListWidget::writeCurrentM3u() { |
1227 | qDebug("writing to current m3u"); | 1236 | qDebug("writing to current m3u"); |
1228 | Config cfg( "OpiePlayer" ); | 1237 | Config cfg( "OpiePlayer" ); |
1229 | cfg.setGroup("PlayList"); | 1238 | cfg.setGroup("PlayList"); |
1230 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 1239 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
1231 | Om3u *m3uList; | 1240 | Om3u *m3uList; |
1232 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 1241 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
1233 | 1242 | ||
1234 | if( d->selectedFiles->first()) { | 1243 | if( d->selectedFiles->first()) { |
1235 | do { | 1244 | do { |
1236 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1245 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1237 | m3uList->add( d->selectedFiles->current()->file() ); | 1246 | m3uList->add( d->selectedFiles->current()->file() ); |
1238 | } | 1247 | } |
1239 | while ( d->selectedFiles->next() ); | 1248 | while ( d->selectedFiles->next() ); |
1240 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1249 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1241 | m3uList->write(); | 1250 | m3uList->write(); |
1242 | m3uList->close(); | 1251 | m3uList->close(); |
1243 | 1252 | ||
1244 | if(m3uList) delete m3uList; | 1253 | if(m3uList) delete m3uList; |
1245 | } | 1254 | } |
1246 | } | 1255 | } |
1247 | 1256 | ||
1248 | /* | 1257 | /* |
1249 | writes current playlist to m3u file */ | 1258 | writes current playlist to m3u file */ |
1250 | void PlayListWidget::writem3u() { | 1259 | void PlayListWidget::writem3u() { |
1251 | InputDialog *fileDlg; | 1260 | InputDialog *fileDlg; |
1252 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1261 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1253 | fileDlg->exec(); | 1262 | fileDlg->exec(); |
1254 | QString name, filename, list; | 1263 | QString name, filename, list; |
1255 | Om3u *m3uList; | 1264 | Om3u *m3uList; |
1256 | 1265 | ||
1257 | if( fileDlg->result() == 1 ) { | 1266 | if( fileDlg->result() == 1 ) { |
1258 | name = fileDlg->text(); | 1267 | name = fileDlg->text(); |
1259 | // qDebug( filename ); | 1268 | // qDebug( filename ); |
1260 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1269 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1261 | filename = name; | 1270 | filename = name; |
1262 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1271 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1263 | } | 1272 | } |
1264 | else //otherwise dump it somewhere noticable | 1273 | else //otherwise dump it somewhere noticable |
1265 | filename = QPEApplication::documentDir() + "/" + name; | 1274 | filename = QPEApplication::documentDir() + "/" + name; |
1266 | 1275 | ||
1267 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1276 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1268 | filename += ".m3u"; | 1277 | filename += ".m3u"; |
1269 | 1278 | ||
1270 | if( d->selectedFiles->first()) { | 1279 | if( d->selectedFiles->first()) { |
1271 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 1280 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1272 | 1281 | ||
1273 | do { | 1282 | do { |
1274 | m3uList->add( d->selectedFiles->current()->file()); | 1283 | m3uList->add( d->selectedFiles->current()->file()); |
1275 | } | 1284 | } |
1276 | while ( d->selectedFiles->next() ); | 1285 | while ( d->selectedFiles->next() ); |
1277 | // qDebug( list ); | 1286 | // qDebug( list ); |
1278 | m3uList->write(); | 1287 | m3uList->write(); |
1279 | m3uList->close(); | 1288 | m3uList->close(); |
1280 | if(m3uList) delete m3uList; | 1289 | if(m3uList) delete m3uList; |
1281 | 1290 | ||
1282 | if(fileDlg) delete fileDlg; | 1291 | if(fileDlg) delete fileDlg; |
1283 | 1292 | ||
1284 | DocLnk lnk; | 1293 | DocLnk lnk; |
1285 | lnk.setFile( filename); | 1294 | lnk.setFile( filename); |
1286 | lnk.setIcon("opieplayer2/playlist2"); | 1295 | lnk.setIcon("opieplayer2/playlist2"); |
1287 | lnk.setName( name); //sets file name | 1296 | lnk.setName( name); //sets file name |
1288 | 1297 | ||
1289 | // qDebug(filename); | 1298 | // qDebug(filename); |
1290 | Config config( "OpiePlayer" ); | 1299 | Config config( "OpiePlayer" ); |
1291 | config.setGroup( "PlayList" ); | 1300 | config.setGroup( "PlayList" ); |
1292 | 1301 | ||
1293 | config.writeEntry("CurrentPlaylist",filename); | 1302 | config.writeEntry("CurrentPlaylist",filename); |
1294 | currentPlayList=filename; | 1303 | currentPlayList=filename; |
1295 | 1304 | ||
1296 | if(!lnk.writeLink()) { | 1305 | if(!lnk.writeLink()) { |
1297 | qDebug("Writing doclink did not work"); | 1306 | qDebug("Writing doclink did not work"); |
1298 | } | 1307 | } |
1299 | 1308 | ||
1300 | setCaption(tr("OpiePlayer: ") + name); | 1309 | setCaption(tr("OpiePlayer: ") + name); |
1301 | } | 1310 | } |
1302 | } | 1311 | } |
1303 | } | 1312 | } |
1304 | 1313 | ||
1305 | 1314 | ||
1306 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1315 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1307 | { | 1316 | { |
1308 | switch ( e->key() ) { | 1317 | switch ( e->key() ) { |
1309 | ////////////////////////////// Zaurus keys | 1318 | ////////////////////////////// Zaurus keys |
1310 | case Key_F9: //activity | 1319 | case Key_F9: //activity |
1311 | // if(audioUI->isHidden()) | 1320 | // if(audioUI->isHidden()) |
1312 | // audioUI->showMaximized(); | 1321 | // audioUI->showMaximized(); |
1313 | break; | 1322 | break; |
1314 | case Key_F10: //contacts | 1323 | case Key_F10: //contacts |
1315 | // if( videoUI->isHidden()) | 1324 | // if( videoUI->isHidden()) |
1316 | // videoUI->showMaximized(); | 1325 | // videoUI->showMaximized(); |
1317 | break; | 1326 | break; |
1318 | case Key_F11: //menu | 1327 | case Key_F11: //menu |
1319 | break; | 1328 | break; |
1320 | case Key_F12: //home | 1329 | case Key_F12: //home |
1321 | // doBlank(); | 1330 | // doBlank(); |
1322 | break; | 1331 | break; |
1323 | case Key_F13: //mail | 1332 | case Key_F13: //mail |
1324 | // doUnblank(); | 1333 | // doUnblank(); |
1325 | break; | 1334 | break; |
1326 | case Key_Q: //add to playlist | 1335 | case Key_Q: //add to playlist |
1327 | qDebug("Add"); | 1336 | qDebug("Add"); |
1328 | addSelected(); | 1337 | addSelected(); |
1329 | break; | 1338 | break; |
1330 | case Key_R: //remove from playlist | 1339 | case Key_R: //remove from playlist |
1331 | removeSelected(); | 1340 | removeSelected(); |
1332 | break; | 1341 | break; |
1333 | // case Key_P: //play | 1342 | // case Key_P: //play |
1334 | // qDebug("Play"); | 1343 | // qDebug("Play"); |
1335 | // playSelected(); | 1344 | // playSelected(); |
1336 | // break; | 1345 | // break; |
1337 | case Key_Space: | 1346 | case Key_Space: |
1338 | qDebug("Play"); | 1347 | qDebug("Play"); |
1339 | // playSelected(); puh | 1348 | // playSelected(); puh |
1340 | break; | 1349 | break; |
1341 | case Key_1: | 1350 | case Key_1: |
1342 | tabWidget->setCurrentPage(0); | 1351 | tabWidget->setCurrentPage(0); |
1343 | break; | 1352 | break; |
1344 | case Key_2: | 1353 | case Key_2: |
1345 | tabWidget->setCurrentPage(1); | 1354 | tabWidget->setCurrentPage(1); |
1346 | break; | 1355 | break; |
1347 | case Key_3: | 1356 | case Key_3: |
1348 | tabWidget->setCurrentPage(2); | 1357 | tabWidget->setCurrentPage(2); |
1349 | break; | 1358 | break; |
1350 | case Key_4: | 1359 | case Key_4: |
1351 | tabWidget->setCurrentPage(3); | 1360 | tabWidget->setCurrentPage(3); |
1352 | break; | 1361 | break; |
1353 | case Key_Down: | 1362 | case Key_Down: |
1354 | if ( !d->selectedFiles->next() ) | 1363 | if ( !d->selectedFiles->next() ) |
1355 | d->selectedFiles->first(); | 1364 | d->selectedFiles->first(); |
1356 | 1365 | ||
1357 | break; | 1366 | break; |
1358 | case Key_Up: | 1367 | case Key_Up: |
1359 | if ( !d->selectedFiles->prev() ) | 1368 | if ( !d->selectedFiles->prev() ) |
1360 | // d->selectedFiles->last(); | 1369 | // d->selectedFiles->last(); |
1361 | 1370 | ||
1362 | break; | 1371 | break; |
1363 | 1372 | ||
1364 | } | 1373 | } |
1365 | } | 1374 | } |
1366 | 1375 | ||
1367 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1376 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1368 | { | 1377 | { |
1369 | // qDebug("Key press"); | 1378 | // qDebug("Key press"); |
1370 | // switch ( e->key() ) { | 1379 | // switch ( e->key() ) { |
1371 | // ////////////////////////////// Zaurus keys | 1380 | // ////////////////////////////// Zaurus keys |
1372 | // case Key_A: //add to playlist | 1381 | // case Key_A: //add to playlist |
1373 | // qDebug("Add"); | 1382 | // qDebug("Add"); |
1374 | // addSelected(); | 1383 | // addSelected(); |
1375 | // break; | 1384 | // break; |
1376 | // case Key_R: //remove from playlist | 1385 | // case Key_R: //remove from playlist |
1377 | // removeSelected(); | 1386 | // removeSelected(); |
1378 | // break; | 1387 | // break; |
1379 | // case Key_P: //play | 1388 | // case Key_P: //play |
1380 | // qDebug("Play"); | 1389 | // qDebug("Play"); |
1381 | // playSelected(); | 1390 | // playSelected(); |
1382 | // break; | 1391 | // break; |
1383 | // case Key_Space: | 1392 | // case Key_Space: |
1384 | // qDebug("Play"); | 1393 | // qDebug("Play"); |
1385 | // playSelected(); | 1394 | // playSelected(); |
1386 | // break; | 1395 | // break; |
1387 | // } | 1396 | // } |
1388 | } | 1397 | } |
1389 | 1398 | ||
1390 | void PlayListWidget::doBlank() { | 1399 | void PlayListWidget::doBlank() { |
1391 | qDebug("do blanking"); | 1400 | qDebug("do blanking"); |
1392 | fd=open("/dev/fb0",O_RDWR); | 1401 | fd=open("/dev/fb0",O_RDWR); |
1393 | if (fd != -1) { | 1402 | if (fd != -1) { |
1394 | ioctl(fd,FBIOBLANK,1); | 1403 | ioctl(fd,FBIOBLANK,1); |
1395 | // close(fd); | 1404 | // close(fd); |
1396 | } | 1405 | } |
1397 | } | 1406 | } |
1398 | 1407 | ||
1399 | void PlayListWidget::doUnblank() { | 1408 | void PlayListWidget::doUnblank() { |
1400 | // this crashes opieplayer with a segfault | 1409 | // this crashes opieplayer with a segfault |
1401 | // int fd; | 1410 | // int fd; |
1402 | // fd=open("/dev/fb0",O_RDWR); | 1411 | // fd=open("/dev/fb0",O_RDWR); |
1403 | qDebug("do unblanking"); | 1412 | qDebug("do unblanking"); |
1404 | if (fd != -1) { | 1413 | if (fd != -1) { |
1405 | ioctl(fd,FBIOBLANK,0); | 1414 | ioctl(fd,FBIOBLANK,0); |
1406 | close(fd); | 1415 | close(fd); |
1407 | } | 1416 | } |
1408 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1417 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1409 | h <<-3;// v[1]; // -3 Force on | 1418 | h <<-3;// v[1]; // -3 Force on |
1410 | } | 1419 | } |
1411 | 1420 | ||
1412 | void PlayListWidget::populateSkinsMenu() { | 1421 | void PlayListWidget::populateSkinsMenu() { |
1413 | int item = 0; | 1422 | int item = 0; |
1414 | defaultSkinIndex = 0; | 1423 | defaultSkinIndex = 0; |
1415 | QString skinName; | 1424 | QString skinName; |
1416 | Config cfg( "OpiePlayer" ); | 1425 | Config cfg( "OpiePlayer" ); |
1417 | cfg.setGroup("Options" ); | 1426 | cfg.setGroup("Options" ); |
1418 | QString skin = cfg.readEntry( "Skin", "default" ); | 1427 | QString skin = cfg.readEntry( "Skin", "default" ); |
1419 | 1428 | ||
1420 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1429 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1421 | skinsDir.setFilter( QDir::Dirs ); | 1430 | skinsDir.setFilter( QDir::Dirs ); |
1422 | skinsDir.setSorting(QDir::Name ); | 1431 | skinsDir.setSorting(QDir::Name ); |
1423 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1432 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1424 | QFileInfoListIterator it( *skinslist ); | 1433 | QFileInfoListIterator it( *skinslist ); |
1425 | QFileInfo *fi; | 1434 | QFileInfo *fi; |
1426 | while ( ( fi = it.current() ) ) { | 1435 | while ( ( fi = it.current() ) ) { |
1427 | skinName = fi->fileName(); | 1436 | skinName = fi->fileName(); |
1428 | // qDebug( fi->fileName() ); | 1437 | // qDebug( fi->fileName() ); |
1429 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1438 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1430 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1439 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1431 | } | 1440 | } |
1432 | if( skinName == "default" ) { | 1441 | if( skinName == "default" ) { |
1433 | defaultSkinIndex = item; | 1442 | defaultSkinIndex = item; |
1434 | } | 1443 | } |
1435 | if( skinName == skin ) { | 1444 | if( skinName == skin ) { |
1436 | skinsMenu->setItemChecked( item, TRUE ); | 1445 | skinsMenu->setItemChecked( item, TRUE ); |
1437 | } | 1446 | } |
1438 | ++it; | 1447 | ++it; |
1439 | } | 1448 | } |
1440 | } | 1449 | } |
1441 | 1450 | ||
1442 | void PlayListWidget::skinsMenuActivated( int item ) { | 1451 | void PlayListWidget::skinsMenuActivated( int item ) { |
1443 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1452 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1444 | skinsMenu->setItemChecked( i, FALSE ); | 1453 | skinsMenu->setItemChecked( i, FALSE ); |
1445 | } | 1454 | } |
1446 | skinsMenu->setItemChecked( item, TRUE ); | 1455 | skinsMenu->setItemChecked( item, TRUE ); |
1447 | 1456 | ||
1448 | Config cfg( "OpiePlayer" ); | 1457 | Config cfg( "OpiePlayer" ); |
1449 | cfg.setGroup("Options"); | 1458 | cfg.setGroup("Options"); |
1450 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1459 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1451 | } | 1460 | } |
1452 | 1461 | ||
1453 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1462 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1454 | qDebug("qcop message "+msg ); | 1463 | qDebug("qcop message "+msg ); |
1455 | QDataStream stream ( data, IO_ReadOnly ); | 1464 | QDataStream stream ( data, IO_ReadOnly ); |
1456 | if ( msg == "play()" ) { //plays current selection | 1465 | if ( msg == "play()" ) { //plays current selection |
1457 | btnPlay( true); | 1466 | btnPlay( true); |
1458 | } else if ( msg == "stop()" ) { | 1467 | } else if ( msg == "stop()" ) { |
1459 | mediaPlayerState->setPlaying( false); | 1468 | mediaPlayerState->setPlaying( false); |
1460 | } else if ( msg == "togglePause()" ) { | 1469 | } else if ( msg == "togglePause()" ) { |
1461 | mediaPlayerState->togglePaused(); | 1470 | mediaPlayerState->togglePaused(); |
1462 | } else if ( msg == "next()" ) { //select next in list | 1471 | } else if ( msg == "next()" ) { //select next in lis |
1463 | mediaPlayerState->setNext(); | 1472 | mediaPlayerState->setNext(); |
1464 | } else if ( msg == "prev()" ) { //select previous in list | 1473 | } else if ( msg == "prev()" ) { //select previous in list |
1465 | mediaPlayerState->setPrev(); | 1474 | mediaPlayerState->setPrev(); |
1466 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1475 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1467 | mediaPlayerState->toggleLooping(); | 1476 | mediaPlayerState->toggleLooping(); |
1468 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1477 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1469 | mediaPlayerState->toggleShuffled(); | 1478 | mediaPlayerState->toggleShuffled(); |
1470 | } else if ( msg == "volUp()" ) { //volume more | 1479 | } else if ( msg == "volUp()" ) { //volume more |
1471 | // emit moreClicked(); | 1480 | // emit moreClicked(); |
1472 | // emit moreReleased(); | 1481 | // emit moreReleased(); |
1473 | } else if ( msg == "volDown()" ) { //volume less | 1482 | } else if ( msg == "volDown()" ) { //volume less |
1474 | // emit lessClicked(); | 1483 | // emit lessClicked(); |
1475 | // emit lessReleased(); | 1484 | // emit lessReleased(); |
1476 | } else if ( msg == "play(QString)" ) { //play this now | 1485 | } else if ( msg == "play(QString)" ) { //play this now |
1477 | QString file; | 1486 | QString file; |
1478 | stream >> file; | 1487 | stream >> file; |
1479 | setDocument( (const QString &) file); | 1488 | setDocumentEx( (const QString &) file); |
1480 | } else if ( msg == "add(QString)" ) { //add to playlist | 1489 | } else if ( msg == "add(QString)" ) { //add to playlist |
1481 | QString file; | 1490 | QString file; |
1482 | stream >> file; | 1491 | stream >> file; |
1483 | QFileInfo fileInfo(file); | 1492 | QFileInfo fileInfo(file); |
1484 | DocLnk lnk; | 1493 | DocLnk lnk; |
1485 | lnk.setName( fileInfo.baseName() ); //sets name | 1494 | lnk.setName( fileInfo.baseName() ); //sets name |
1486 | lnk.setFile( file ); //sets file name | 1495 | lnk.setFile( file ); //sets file name |
1487 | addToSelection( lnk ); | 1496 | addToSelection( lnk ); |
1488 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1497 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1489 | QString file; | 1498 | QString file; |
1490 | stream >> file; | 1499 | stream >> file; |
1491 | 1500 | ||
1501 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop | ||
1502 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); | ||
1492 | } | 1503 | } |
1493 | 1504 | ||
1494 | } | 1505 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index e66bcb9..0c0e367 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -1,137 +1,138 @@ | |||
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 | #ifndef PLAY_LIST_WIDGET_H | 20 | #ifndef PLAY_LIST_WIDGET_H |
21 | #define PLAY_LIST_WIDGET_H | 21 | #define PLAY_LIST_WIDGET_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qtabwidget.h> | 25 | #include <qtabwidget.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | 28 | ||
29 | #include <qpe/qcopenvelope_qws.h> | 29 | #include <qpe/qcopenvelope_qws.h> |
30 | 30 | ||
31 | #include "om3u.h" | 31 | #include "om3u.h" |
32 | /* #include <qtimer.h> */ | 32 | /* #include <qtimer.h> */ |
33 | 33 | ||
34 | 34 | ||
35 | class PlayListWidgetPrivate; | 35 | class PlayListWidgetPrivate; |
36 | class Config; | 36 | class Config; |
37 | class QListViewItem; | 37 | class QListViewItem; |
38 | class QListView; | 38 | class QListView; |
39 | class QPoint; | 39 | class QPoint; |
40 | class QAction; | 40 | class QAction; |
41 | class QLabel; | 41 | class QLabel; |
42 | class QPopupMenu; | 42 | class QPopupMenu; |
43 | 43 | ||
44 | class PlayListWidget : public QMainWindow { | 44 | class PlayListWidget : public QMainWindow { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | public: | 46 | public: |
47 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 47 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
48 | ~PlayListWidget(); | 48 | ~PlayListWidget(); |
49 | QTabWidget * tabWidget; | 49 | QTabWidget * tabWidget; |
50 | QAction *fullScreenButton, *scaleButton; | 50 | QAction *fullScreenButton, *scaleButton; |
51 | DocLnkSet files; | 51 | DocLnkSet files; |
52 | DocLnkSet vFiles; | 52 | DocLnkSet vFiles; |
53 | QListView *audioView, *videoView, *playlistView; | 53 | QListView *audioView, *videoView, *playlistView; |
54 | QLabel *libString; | 54 | QLabel *libString; |
55 | bool fromSetDocument; | 55 | bool fromSetDocument; |
56 | bool insanityBool; | 56 | bool insanityBool; |
57 | QString setDocFileRef, currentPlayList; | 57 | QString setDocFileRef, currentPlayList; |
58 | // retrieve the current playlist entry (media file link) | 58 | // retrieve the current playlist entry (media file link) |
59 | const DocLnk *current(); | 59 | const DocLnk *current(); |
60 | void useSelectedDocument(); | 60 | void useSelectedDocument(); |
61 | /* QTimer * menuTimer; */ | 61 | /* QTimer * menuTimer; */ |
62 | FileSelector* playLists; | 62 | FileSelector* playLists; |
63 | QPushButton *tbDeletePlaylist; | 63 | QPushButton *tbDeletePlaylist; |
64 | int fd, selected; | 64 | int fd, selected; |
65 | public slots: | 65 | public slots: |
66 | bool first(); | 66 | bool first(); |
67 | bool last(); | 67 | bool last(); |
68 | bool next(); | 68 | bool next(); |
69 | bool prev(); | 69 | bool prev(); |
70 | /* void setFullScreen(); */ | 70 | /* void setFullScreen(); */ |
71 | /* void setScaled(); */ | 71 | /* void setScaled(); */ |
72 | protected: | 72 | protected: |
73 | QCopChannel * channel; | 73 | QCopChannel * channel; |
74 | QPopupMenu *skinsMenu; | 74 | QPopupMenu *skinsMenu; |
75 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 75 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
76 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 76 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
77 | void keyReleaseEvent( QKeyEvent *e); | 77 | void keyReleaseEvent( QKeyEvent *e); |
78 | void keyPressEvent( QKeyEvent *e); | 78 | void keyPressEvent( QKeyEvent *e); |
79 | private: | 79 | private: |
80 | int defaultSkinIndex; | 80 | int defaultSkinIndex; |
81 | bool audioScan, videoScan; | 81 | bool audioScan, videoScan; |
82 | void doBlank(); | 82 | void doBlank(); |
83 | void doUnblank(); | 83 | void doUnblank(); |
84 | void readm3u(const QString &); | 84 | void readm3u(const QString &); |
85 | void readPls(const QString &); | 85 | void readPls(const QString &); |
86 | 86 | ||
87 | 87 | ||
88 | void initializeStates(); | 88 | void initializeStates(); |
89 | void readConfig( Config& cfg ); | 89 | void readConfig( Config& cfg ); |
90 | void writeConfig( Config& cfg ) const; | 90 | void writeConfig( Config& cfg ) const; |
91 | PlayListWidgetPrivate *d; // Private implementation data | 91 | PlayListWidgetPrivate *d; // Private implementation data |
92 | void populateAudioView(); | 92 | void populateAudioView(); |
93 | void populateVideoView(); | 93 | void populateVideoView(); |
94 | private slots: | 94 | private slots: |
95 | 95 | ||
96 | void qcopReceive(const QCString&, const QByteArray&); | 96 | void qcopReceive(const QCString&, const QByteArray&); |
97 | void populateSkinsMenu(); | 97 | void populateSkinsMenu(); |
98 | void skinsMenuActivated(int); | 98 | void skinsMenuActivated(int); |
99 | void writem3u(); | 99 | void writem3u(); |
100 | void writeCurrentM3u(); | 100 | void writeCurrentM3u(); |
101 | void scanForAudio(); | 101 | void scanForAudio(); |
102 | void scanForVideo(); | 102 | void scanForVideo(); |
103 | void openFile(); | 103 | void openFile(); |
104 | void setDocument( const QString& fileref ); | 104 | void setDocument( const QString& fileref ); |
105 | void setDocumentEx( const QString& fileref ); | ||
105 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 106 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
106 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 107 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
107 | void setActiveWindow(); // need to handle this to show the right view | 108 | void setActiveWindow(); // need to handle this to show the right view |
108 | void setPlaylist( bool ); // Show/Hide the playlist | 109 | void setPlaylist( bool ); // Show/Hide the playlist |
109 | void setView( char ); | 110 | void setView( char ); |
110 | void clearList(); | 111 | void clearList(); |
111 | void addAllToList(); | 112 | void addAllToList(); |
112 | void addAllMusicToList(); | 113 | void addAllMusicToList(); |
113 | void addAllVideoToList(); | 114 | void addAllVideoToList(); |
114 | void saveList(); // Save the playlist | 115 | void saveList(); // Save the playlist |
115 | void loadList( const DocLnk &); // Load a playlist | 116 | void loadList( const DocLnk &); // Load a playlist |
116 | void playIt( QListViewItem *); | 117 | void playIt( QListViewItem *); |
117 | 118 | ||
118 | void btnPlay(bool); | 119 | void btnPlay(bool); |
119 | void deletePlaylist(); | 120 | void deletePlaylist(); |
120 | void addSelected(); | 121 | void addSelected(); |
121 | void removeSelected(); | 122 | void removeSelected(); |
122 | void tabChanged(QWidget*); | 123 | void tabChanged(QWidget*); |
123 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 124 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
124 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 125 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
125 | void playSelected(); | 126 | void playSelected(); |
126 | void listDelete(); | 127 | void listDelete(); |
127 | 128 | ||
128 | protected slots: | 129 | protected slots: |
129 | /* void cancelMenuTimer(); */ | 130 | /* void cancelMenuTimer(); */ |
130 | /* void showFileMenu(); */ | 131 | /* void showFileMenu(); */ |
131 | 132 | ||
132 | 133 | ||
133 | }; | 134 | }; |
134 | 135 | ||
135 | 136 | ||
136 | #endif // PLAY_LIST_WIDGET_H | 137 | #endif // PLAY_LIST_WIDGET_H |
137 | 138 | ||