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