author | llornkcor <llornkcor> | 2002-05-12 12:15:30 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-12 12:15:30 (UTC) |
commit | c1cc5edca5d6d71350f841892fb7828f7be9ed9f (patch) (unidiff) | |
tree | 014224506a39db65d54c41b18c5f7c1096cb7a92 | |
parent | 06e723cc7942af2691828e7fdc6a6ec47b44edab (diff) | |
download | opie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.zip opie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.tar.gz opie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.tar.bz2 |
added a few keyboard shorts
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 139 |
1 files changed, 133 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 038b371..ec5500f 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,1107 +1,1234 @@ | |||
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 | 35 | ||
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qcursor.h> | ||
38 | #include <qimage.h> | 37 | #include <qimage.h> |
39 | #include <qfile.h> | 38 | #include <qfile.h> |
40 | #include <qdir.h> | 39 | #include <qdir.h> |
41 | #include <qlayout.h> | 40 | #include <qlayout.h> |
42 | #include <qlabel.h> | 41 | #include <qlabel.h> |
43 | #include <qlist.h> | 42 | #include <qlist.h> |
44 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
45 | #include <qmainwindow.h> | 44 | #include <qmainwindow.h> |
46 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
47 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
48 | #include <qtabwidget.h> | 47 | #include <qtabwidget.h> |
49 | #include <qlistview.h> | 48 | #include <qlistview.h> |
50 | #include <qpoint.h> | 49 | #include <qpoint.h> |
51 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
52 | #include <qpushbutton.h> | 51 | #include <qpushbutton.h> |
53 | #include <qregexp.h> | 52 | #include <qregexp.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 | // class myFileSelector { | 86 | // class myFileSelector { |
87 | 87 | ||
88 | // }; | 88 | // }; |
89 | class PlayListWidgetPrivate { | 89 | class PlayListWidgetPrivate { |
90 | public: | 90 | public: |
91 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 91 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
92 | QFrame *playListFrame; | 92 | QFrame *playListFrame; |
93 | FileSelector *files; | 93 | FileSelector *files; |
94 | PlayListSelection *selectedFiles; | 94 | PlayListSelection *selectedFiles; |
95 | bool setDocumentUsed; | 95 | bool setDocumentUsed; |
96 | DocLnk *current; | 96 | DocLnk *current; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | class ToolButton : public QToolButton { | 100 | class ToolButton : public QToolButton { |
101 | public: | 101 | public: |
102 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 102 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
103 | : QToolButton( parent, name ) { | 103 | : QToolButton( parent, name ) { |
104 | setTextLabel( name ); | 104 | setTextLabel( name ); |
105 | setPixmap( Resource::loadPixmap( icon ) ); | 105 | setPixmap( Resource::loadPixmap( icon ) ); |
106 | setAutoRaise( TRUE ); | 106 | setAutoRaise( TRUE ); |
107 | setFocusPolicy( QWidget::NoFocus ); | 107 | setFocusPolicy( QWidget::NoFocus ); |
108 | setToggleButton( t ); | 108 | setToggleButton( t ); |
109 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 109 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
110 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 110 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
111 | } | 111 | } |
112 | }; | 112 | }; |
113 | 113 | ||
114 | 114 | ||
115 | class MenuItem : public QAction { | 115 | class MenuItem : public QAction { |
116 | public: | 116 | public: |
117 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 117 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
118 | : QAction( text, QString::null, 0, 0 ) { | 118 | : QAction( text, QString::null, 0, 0 ) { |
119 | connect( this, SIGNAL( activated() ), handler, slot ); | 119 | connect( this, SIGNAL( activated() ), handler, slot ); |
120 | addTo( parent ); | 120 | addTo( parent ); |
121 | } | 121 | } |
122 | }; | 122 | }; |
123 | 123 | ||
124 | 124 | ||
125 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 125 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
126 | : QMainWindow( parent, name, fl ) { | 126 | : QMainWindow( parent, name, fl ) { |
127 | 127 | ||
128 | d = new PlayListWidgetPrivate; | 128 | d = new PlayListWidgetPrivate; |
129 | d->setDocumentUsed = FALSE; | 129 | d->setDocumentUsed = FALSE; |
130 | d->current = NULL; | 130 | d->current = NULL; |
131 | fromSetDocument = FALSE; | 131 | fromSetDocument = FALSE; |
132 | insanityBool=FALSE; | 132 | insanityBool=FALSE; |
133 | // menuTimer = new QTimer( this ,"menu timer"), | 133 | // menuTimer = new QTimer( this ,"menu timer"), |
134 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 134 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
135 | 135 | ||
136 | setBackgroundMode( PaletteButton ); | 136 | setBackgroundMode( PaletteButton ); |
137 | 137 | ||
138 | setCaption( tr("OpiePlayer") ); | 138 | setCaption( tr("OpiePlayer") ); |
139 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 139 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
140 | 140 | ||
141 | setToolBarsMovable( FALSE ); | 141 | setToolBarsMovable( FALSE ); |
142 | 142 | ||
143 | // Create Toolbar | 143 | // Create Toolbar |
144 | QPEToolBar *toolbar = new QPEToolBar( this ); | 144 | QPEToolBar *toolbar = new QPEToolBar( this ); |
145 | toolbar->setHorizontalStretchable( TRUE ); | 145 | toolbar->setHorizontalStretchable( TRUE ); |
146 | 146 | ||
147 | // Create Menubar | 147 | // Create Menubar |
148 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 148 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
149 | menu->setMargin( 0 ); | 149 | menu->setMargin( 0 ); |
150 | 150 | ||
151 | QPEToolBar *bar = new QPEToolBar( this ); | 151 | QPEToolBar *bar = new QPEToolBar( this ); |
152 | bar->setLabel( tr( "Play Operations" ) ); | 152 | bar->setLabel( tr( "Play Operations" ) ); |
153 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 153 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
154 | // this , SLOT( addSelected()) ); | 154 | // this , SLOT( addSelected()) ); |
155 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 155 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
156 | tbDeletePlaylist->setFlat(TRUE); | 156 | tbDeletePlaylist->setFlat(TRUE); |
157 | tbDeletePlaylist->setFixedSize(20,20); | 157 | tbDeletePlaylist->setFixedSize(20,20); |
158 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 158 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
159 | 159 | ||
160 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 160 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
161 | this , SLOT(addSelected()) ); | 161 | this , SLOT(addSelected()) ); |
162 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 162 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
163 | this , SLOT(removeSelected()) ); | 163 | this , SLOT(removeSelected()) ); |
164 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 164 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
165 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 165 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
166 | this , SLOT( btnPlay(bool) ), TRUE ); | 166 | this , SLOT( btnPlay(bool) ), TRUE ); |
167 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 167 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
168 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 168 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
169 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 169 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
170 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 170 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
171 | tbDeletePlaylist->hide(); | 171 | tbDeletePlaylist->hide(); |
172 | 172 | ||
173 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 173 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
174 | menu->insertItem( tr( "File" ), pmPlayList ); | 174 | menu->insertItem( tr( "File" ), pmPlayList ); |
175 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 175 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
176 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 176 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
177 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 177 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
178 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 178 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
179 | // pmPlayList->insertSeparator(-1); | 179 | // pmPlayList->insertSeparator(-1); |
180 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 180 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
181 | pmPlayList->insertSeparator(-1); | 181 | pmPlayList->insertSeparator(-1); |
182 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 182 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
183 | 183 | ||
184 | QPopupMenu *pmView = new QPopupMenu( this ); | 184 | QPopupMenu *pmView = new QPopupMenu( this ); |
185 | menu->insertItem( tr( "View" ), pmView ); | 185 | menu->insertItem( tr( "View" ), pmView ); |
186 | 186 | ||
187 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 187 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
188 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 188 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
189 | fullScreenButton->addTo(pmView); | 189 | fullScreenButton->addTo(pmView); |
190 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 190 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
191 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 191 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
192 | scaleButton->addTo(pmView); | 192 | scaleButton->addTo(pmView); |
193 | 193 | ||
194 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 194 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
195 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 195 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
196 | 196 | ||
197 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 197 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
198 | 198 | ||
199 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 199 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
200 | tabWidget->setTabShape(QTabWidget::Triangular); | 200 | tabWidget->setTabShape(QTabWidget::Triangular); |
201 | 201 | ||
202 | QWidget *pTab; | 202 | QWidget *pTab; |
203 | pTab = new QWidget( tabWidget, "pTab" ); | 203 | pTab = new QWidget( tabWidget, "pTab" ); |
204 | // playlistView = new QListView( pTab, "playlistview" ); | 204 | // playlistView = new QListView( pTab, "playlistview" ); |
205 | // playlistView->setMinimumSize(236,260); | 205 | // playlistView->setMinimumSize(236,260); |
206 | tabWidget->insertTab( pTab,"Playlist"); | 206 | tabWidget->insertTab( pTab,"Playlist"); |
207 | 207 | ||
208 | 208 | ||
209 | // Add the playlist area | 209 | // Add the playlist area |
210 | 210 | ||
211 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 211 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
212 | d->playListFrame = vbox3; | 212 | d->playListFrame = vbox3; |
213 | d->playListFrame ->setMinimumSize(235,260); | 213 | d->playListFrame ->setMinimumSize(235,260); |
214 | 214 | ||
215 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 215 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
216 | 216 | ||
217 | d->selectedFiles = new PlayListSelection( hbox2); | 217 | d->selectedFiles = new PlayListSelection( hbox2); |
218 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 218 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
219 | 219 | ||
220 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 220 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
221 | 221 | ||
222 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 222 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
223 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 223 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
224 | 224 | ||
225 | 225 | ||
226 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 226 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
227 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 227 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
228 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 228 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
229 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 229 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
230 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 230 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
231 | 231 | ||
232 | QWidget *aTab; | 232 | QWidget *aTab; |
233 | aTab = new QWidget( tabWidget, "aTab" ); | 233 | aTab = new QWidget( tabWidget, "aTab" ); |
234 | audioView = new QListView( aTab, "Audioview" ); | 234 | audioView = new QListView( aTab, "Audioview" ); |
235 | audioView->setMinimumSize(233,260); | 235 | audioView->setMinimumSize(233,260); |
236 | audioView->addColumn( tr("Title"),140); | 236 | audioView->addColumn( tr("Title"),140); |
237 | audioView->addColumn(tr("Size"), -1); | 237 | audioView->addColumn(tr("Size"), -1); |
238 | audioView->addColumn(tr("Media"),-1); | 238 | audioView->addColumn(tr("Media"),-1); |
239 | audioView->setColumnAlignment(1, Qt::AlignRight); | 239 | audioView->setColumnAlignment(1, Qt::AlignRight); |
240 | audioView->setColumnAlignment(2, Qt::AlignRight); | 240 | audioView->setColumnAlignment(2, Qt::AlignRight); |
241 | audioView->setAllColumnsShowFocus(TRUE); | 241 | audioView->setAllColumnsShowFocus(TRUE); |
242 | 242 | ||
243 | audioView->setMultiSelection( TRUE ); | 243 | audioView->setMultiSelection( TRUE ); |
244 | audioView->setSelectionMode( QListView::Extended); | 244 | audioView->setSelectionMode( QListView::Extended); |
245 | 245 | ||
246 | tabWidget->insertTab(aTab,tr("Audio")); | 246 | tabWidget->insertTab(aTab,tr("Audio")); |
247 | 247 | ||
248 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 248 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
249 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 249 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
251 | 251 | ||
252 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | ||
253 | this,SLOT( playIt( QListViewItem *)) ); | ||
252 | 254 | ||
253 | // audioView | 255 | // audioView |
254 | populateAudioView(); | 256 | populateAudioView(); |
255 | // videowidget | 257 | // videowidget |
256 | 258 | ||
257 | QWidget *vTab; | 259 | QWidget *vTab; |
258 | vTab = new QWidget( tabWidget, "vTab" ); | 260 | vTab = new QWidget( tabWidget, "vTab" ); |
259 | videoView = new QListView( vTab, "Videoview" ); | 261 | videoView = new QListView( vTab, "Videoview" ); |
260 | videoView->setMinimumSize(233,260); | 262 | videoView->setMinimumSize(233,260); |
261 | 263 | ||
262 | videoView->addColumn(tr("Title"),140); | 264 | videoView->addColumn(tr("Title"),140); |
263 | videoView->addColumn(tr("Size"),-1); | 265 | videoView->addColumn(tr("Size"),-1); |
264 | videoView->addColumn(tr("Media"),-1); | 266 | videoView->addColumn(tr("Media"),-1); |
265 | videoView->setColumnAlignment(1, Qt::AlignRight); | 267 | videoView->setColumnAlignment(1, Qt::AlignRight); |
266 | videoView->setColumnAlignment(2, Qt::AlignRight); | 268 | videoView->setColumnAlignment(2, Qt::AlignRight); |
267 | videoView->setAllColumnsShowFocus(TRUE); | 269 | videoView->setAllColumnsShowFocus(TRUE); |
268 | videoView->setMultiSelection( TRUE ); | 270 | videoView->setMultiSelection( TRUE ); |
269 | videoView->setSelectionMode( QListView::Extended); | 271 | videoView->setSelectionMode( QListView::Extended); |
270 | 272 | ||
271 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 273 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
274 | |||
272 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 275 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
273 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 276 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
277 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | ||
278 | this,SLOT( playIt( QListViewItem *)) ); | ||
274 | 279 | ||
275 | tabWidget->insertTab( vTab,tr("Video")); | 280 | tabWidget->insertTab( vTab,tr("Video")); |
276 | populateVideoView(); | 281 | populateVideoView(); |
277 | 282 | ||
278 | //playlists list | 283 | //playlists list |
279 | QWidget *LTab; | 284 | QWidget *LTab; |
280 | LTab = new QWidget( tabWidget, "LTab" ); | 285 | LTab = new QWidget( tabWidget, "LTab" ); |
281 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 286 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
282 | playLists->setMinimumSize(233,260);; | 287 | playLists->setMinimumSize(233,260);; |
283 | tabWidget->insertTab(LTab,tr("Lists")); | 288 | tabWidget->insertTab(LTab,tr("Lists")); |
284 | 289 | ||
285 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 290 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
286 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 291 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
287 | 292 | ||
288 | 293 | ||
289 | // add the library area | 294 | // add the library area |
290 | 295 | ||
291 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 296 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
292 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 297 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
293 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 298 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
294 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 299 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
295 | 300 | ||
296 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 301 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
297 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 302 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
298 | 303 | ||
299 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 304 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
300 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 305 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
301 | 306 | ||
302 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 307 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
303 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 308 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
304 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 309 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
305 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 310 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
306 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 311 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
307 | 312 | ||
308 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 313 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
309 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 314 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
310 | 315 | ||
311 | setCentralWidget( vbox5 ); | 316 | setCentralWidget( vbox5 ); |
312 | 317 | ||
313 | Config cfg( "OpiePlayer" ); | 318 | Config cfg( "OpiePlayer" ); |
314 | readConfig( cfg ); | 319 | readConfig( cfg ); |
315 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 320 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
316 | // qDebug("currentList is "+currentPlaylist); | 321 | // qDebug("currentList is "+currentPlaylist); |
317 | loadList(DocLnk( currentPlaylist)); | 322 | loadList(DocLnk( currentPlaylist)); |
318 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 323 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
319 | 324 | ||
320 | initializeStates(); | 325 | initializeStates(); |
321 | } | 326 | } |
322 | 327 | ||
323 | 328 | ||
324 | PlayListWidget::~PlayListWidget() { | 329 | PlayListWidget::~PlayListWidget() { |
325 | Config cfg( "OpiePlayer" ); | 330 | Config cfg( "OpiePlayer" ); |
326 | writeConfig( cfg ); | 331 | writeConfig( cfg ); |
327 | 332 | ||
328 | 333 | ||
329 | if ( d->current ) | 334 | if ( d->current ) |
330 | delete d->current; | 335 | delete d->current; |
331 | delete d; | 336 | delete d; |
332 | } | 337 | } |
333 | 338 | ||
334 | 339 | ||
335 | void PlayListWidget::initializeStates() { | 340 | void PlayListWidget::initializeStates() { |
336 | 341 | ||
337 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 342 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
338 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 343 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
339 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 344 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
340 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 345 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
341 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 346 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
342 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 347 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
343 | // setPlaylist( mediaPlayerState->playlist() ); | 348 | // setPlaylist( mediaPlayerState->playlist() ); |
344 | setPlaylist( true); | 349 | setPlaylist( true); |
345 | // d->selectedFiles->first(); | 350 | // d->selectedFiles->first(); |
346 | 351 | ||
347 | } | 352 | } |
348 | 353 | ||
349 | 354 | ||
350 | void PlayListWidget::readConfig( Config& cfg ) { | 355 | void PlayListWidget::readConfig( Config& cfg ) { |
351 | cfg.setGroup("PlayList"); | 356 | cfg.setGroup("PlayList"); |
352 | QString currentString = cfg.readEntry("current", "" ); | 357 | QString currentString = cfg.readEntry("current", "" ); |
353 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 358 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
354 | for ( int i = 0; i < noOfFiles; i++ ) { | 359 | for ( int i = 0; i < noOfFiles; i++ ) { |
355 | QString entryName; | 360 | QString entryName; |
356 | entryName.sprintf( "File%i", i + 1 ); | 361 | entryName.sprintf( "File%i", i + 1 ); |
357 | QString linkFile = cfg.readEntry( entryName ); | 362 | QString linkFile = cfg.readEntry( entryName ); |
358 | DocLnk lnk( linkFile ); | 363 | DocLnk lnk( linkFile ); |
359 | if ( lnk.isValid() ) { | 364 | if ( lnk.isValid() ) { |
360 | d->selectedFiles->addToSelection( lnk ); | 365 | d->selectedFiles->addToSelection( lnk ); |
361 | } | 366 | } |
362 | } | 367 | } |
363 | d->selectedFiles->setSelectedItem( currentString); | 368 | d->selectedFiles->setSelectedItem( currentString); |
364 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 369 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
365 | } | 370 | } |
366 | 371 | ||
367 | 372 | ||
368 | void PlayListWidget::writeConfig( Config& cfg ) const { | 373 | void PlayListWidget::writeConfig( Config& cfg ) const { |
369 | 374 | ||
370 | d->selectedFiles->writeCurrent( cfg); | 375 | d->selectedFiles->writeCurrent( cfg); |
371 | cfg.setGroup("PlayList"); | 376 | cfg.setGroup("PlayList"); |
372 | int noOfFiles = 0; | 377 | int noOfFiles = 0; |
373 | d->selectedFiles->first(); | 378 | d->selectedFiles->first(); |
374 | do { | 379 | do { |
375 | const DocLnk *lnk = d->selectedFiles->current(); | 380 | const DocLnk *lnk = d->selectedFiles->current(); |
376 | if ( lnk ) { | 381 | if ( lnk ) { |
377 | QString entryName; | 382 | QString entryName; |
378 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 383 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
379 | // qDebug(entryName); | 384 | // qDebug(entryName); |
380 | cfg.writeEntry( entryName, lnk->linkFile() ); | 385 | cfg.writeEntry( entryName, lnk->linkFile() ); |
381 | // if this link does exist, add it so we have the file | 386 | // if this link does exist, add it so we have the file |
382 | // next time... | 387 | // next time... |
383 | if ( !QFile::exists( lnk->linkFile() ) ) { | 388 | if ( !QFile::exists( lnk->linkFile() ) ) { |
384 | // the way writing lnks doesn't really check for out | 389 | // the way writing lnks doesn't really check for out |
385 | // of disk space, but check it anyway. | 390 | // of disk space, but check it anyway. |
386 | if ( !lnk->writeLink() ) { | 391 | if ( !lnk->writeLink() ) { |
387 | QMessageBox::critical( 0, tr("Out of space"), | 392 | QMessageBox::critical( 0, tr("Out of space"), |
388 | tr( "There was a problem saving " | 393 | tr( "There was a problem saving " |
389 | "the playlist.\n" | 394 | "the playlist.\n" |
390 | "Your playlist " | 395 | "Your playlist " |
391 | "may be missing some entries\n" | 396 | "may be missing some entries\n" |
392 | "the next time you start it." ) | 397 | "the next time you start it." ) |
393 | ); | 398 | ); |
394 | } | 399 | } |
395 | } | 400 | } |
396 | noOfFiles++; | 401 | noOfFiles++; |
397 | } | 402 | } |
398 | } | 403 | } |
399 | while ( d->selectedFiles->next() ); | 404 | while ( d->selectedFiles->next() ); |
400 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 405 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
401 | } | 406 | } |
402 | 407 | ||
403 | 408 | ||
404 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 409 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
405 | // qDebug("add"); | 410 | // qDebug("add"); |
406 | d->setDocumentUsed = FALSE; | 411 | d->setDocumentUsed = FALSE; |
407 | if ( mediaPlayerState->playlist() ) | 412 | if ( mediaPlayerState->playlist() ) |
408 | d->selectedFiles->addToSelection( lnk ); | 413 | d->selectedFiles->addToSelection( lnk ); |
409 | else | 414 | else |
410 | mediaPlayerState->setPlaying( TRUE ); | 415 | mediaPlayerState->setPlaying( TRUE ); |
411 | } | 416 | } |
412 | 417 | ||
413 | 418 | ||
414 | void PlayListWidget::clearList() { | 419 | void PlayListWidget::clearList() { |
415 | while ( first() ) | 420 | while ( first() ) |
416 | d->selectedFiles->removeSelected(); | 421 | d->selectedFiles->removeSelected(); |
417 | } | 422 | } |
418 | 423 | ||
419 | 424 | ||
420 | void PlayListWidget::addAllToList() { | 425 | void PlayListWidget::addAllToList() { |
421 | DocLnkSet filesAll; | 426 | DocLnkSet filesAll; |
422 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 427 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
423 | QListIterator<DocLnk> Adit( filesAll.children() ); | 428 | QListIterator<DocLnk> Adit( filesAll.children() ); |
424 | for ( ; Adit.current(); ++Adit ) | 429 | for ( ; Adit.current(); ++Adit ) |
425 | d->selectedFiles->addToSelection( **Adit ); | 430 | d->selectedFiles->addToSelection( **Adit ); |
426 | } | 431 | } |
427 | 432 | ||
428 | 433 | ||
429 | void PlayListWidget::addAllMusicToList() { | 434 | void PlayListWidget::addAllMusicToList() { |
430 | // DocLnkSet files; | 435 | // DocLnkSet files; |
431 | // Global::findDocuments(&files, "audio/*"); | 436 | // Global::findDocuments(&files, "audio/*"); |
432 | QListIterator<DocLnk> dit( files.children() ); | 437 | QListIterator<DocLnk> dit( files.children() ); |
433 | for ( ; dit.current(); ++dit ) | 438 | for ( ; dit.current(); ++dit ) |
434 | d->selectedFiles->addToSelection( **dit ); | 439 | d->selectedFiles->addToSelection( **dit ); |
435 | } | 440 | } |
436 | 441 | ||
437 | 442 | ||
438 | void PlayListWidget::addAllVideoToList() { | 443 | void PlayListWidget::addAllVideoToList() { |
439 | QListIterator<DocLnk> dit( vFiles.children() ); | 444 | QListIterator<DocLnk> dit( vFiles.children() ); |
440 | for ( ; dit.current(); ++dit ) | 445 | for ( ; dit.current(); ++dit ) |
441 | d->selectedFiles->addToSelection( **dit ); | 446 | d->selectedFiles->addToSelection( **dit ); |
442 | } | 447 | } |
443 | 448 | ||
444 | 449 | ||
445 | void PlayListWidget::setDocument(const QString& fileref) { | 450 | void PlayListWidget::setDocument(const QString& fileref) { |
446 | qDebug(fileref); | 451 | qDebug(fileref); |
447 | fromSetDocument = TRUE; | 452 | fromSetDocument = TRUE; |
448 | if ( fileref.isNull() ) { | 453 | if ( fileref.isNull() ) { |
449 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 454 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
450 | return; | 455 | return; |
451 | } | 456 | } |
452 | // qDebug("setDocument "+fileref); | 457 | // qDebug("setDocument "+fileref); |
453 | // if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 458 | // if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
454 | // clearList(); | 459 | // clearList(); |
455 | // addToSelection( DocLnk( fileref ) ); | 460 | // addToSelection( DocLnk( fileref ) ); |
456 | // d->setDocumentUsed = TRUE; | 461 | // d->setDocumentUsed = TRUE; |
457 | // d->selectedFiles->first(); | 462 | // d->selectedFiles->first(); |
458 | // qApp->processEvents(); | 463 | // qApp->processEvents(); |
459 | // } | 464 | // } |
460 | // else | 465 | // else |
461 | if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 466 | if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
462 | clearList(); | 467 | clearList(); |
463 | loadList(DocLnk(fileref)); | 468 | loadList(DocLnk(fileref)); |
464 | d->selectedFiles->first(); | 469 | d->selectedFiles->first(); |
465 | } else { | 470 | } else { |
466 | clearList(); | 471 | clearList(); |
467 | addToSelection( DocLnk( fileref ) ); | 472 | addToSelection( DocLnk( fileref ) ); |
468 | d->setDocumentUsed = TRUE; | 473 | d->setDocumentUsed = TRUE; |
469 | mediaPlayerState->setPlaying( FALSE ); | 474 | mediaPlayerState->setPlaying( FALSE ); |
470 | qApp->processEvents(); | 475 | qApp->processEvents(); |
471 | mediaPlayerState->setPlaying( TRUE ); | 476 | mediaPlayerState->setPlaying( TRUE ); |
472 | qApp->processEvents(); | 477 | qApp->processEvents(); |
473 | setCaption(tr("OpiePlayer")); | 478 | setCaption(tr("OpiePlayer")); |
474 | } | 479 | } |
475 | } | 480 | } |
476 | 481 | ||
477 | 482 | ||
478 | void PlayListWidget::setActiveWindow() { | 483 | void PlayListWidget::setActiveWindow() { |
479 | // When we get raised we need to ensure that it switches views | 484 | // When we get raised we need to ensure that it switches views |
480 | char origView = mediaPlayerState->view(); | 485 | char origView = mediaPlayerState->view(); |
481 | mediaPlayerState->setView( 'l' ); // invalidate | 486 | mediaPlayerState->setView( 'l' ); // invalidate |
482 | mediaPlayerState->setView( origView ); // now switch back | 487 | mediaPlayerState->setView( origView ); // now switch back |
483 | } | 488 | } |
484 | 489 | ||
485 | 490 | ||
486 | void PlayListWidget::useSelectedDocument() { | 491 | void PlayListWidget::useSelectedDocument() { |
487 | d->setDocumentUsed = FALSE; | 492 | d->setDocumentUsed = FALSE; |
488 | } | 493 | } |
489 | 494 | ||
490 | 495 | ||
491 | const DocLnk *PlayListWidget::current() { // this is fugly | 496 | const DocLnk *PlayListWidget::current() { // this is fugly |
492 | 497 | ||
493 | // if( fromSetDocument) { | 498 | // if( fromSetDocument) { |
494 | // qDebug("from setDoc"); | 499 | // qDebug("from setDoc"); |
495 | // DocLnkSet files; | 500 | // DocLnkSet files; |
496 | // Global::findDocuments(&files, "video/*;audio/*"); | 501 | // Global::findDocuments(&files, "video/*;audio/*"); |
497 | // QListIterator<DocLnk> dit( files.children() ); | 502 | // QListIterator<DocLnk> dit( files.children() ); |
498 | // for ( ; dit.current(); ++dit ) { | 503 | // for ( ; dit.current(); ++dit ) { |
499 | // if(dit.current()->linkFile() == setDocFileRef) { | 504 | // if(dit.current()->linkFile() == setDocFileRef) { |
500 | // qDebug(setDocFileRef); | 505 | // qDebug(setDocFileRef); |
501 | // return dit; | 506 | // return dit; |
502 | // } | 507 | // } |
503 | // } | 508 | // } |
504 | // } else | 509 | // } else |
505 | 510 | ||
506 | 511 | ||
507 | switch (tabWidget->currentPageIndex()) { | 512 | switch (tabWidget->currentPageIndex()) { |
508 | case 0: //playlist | 513 | case 0: //playlist |
509 | { | 514 | { |
510 | qDebug("playlist"); | 515 | qDebug("playlist"); |
511 | if ( mediaPlayerState->playlist() ) { | 516 | if ( mediaPlayerState->playlist() ) { |
512 | return d->selectedFiles->current(); | 517 | return d->selectedFiles->current(); |
513 | } | 518 | } |
514 | else if ( d->setDocumentUsed && d->current ) { | 519 | else if ( d->setDocumentUsed && d->current ) { |
515 | return d->current; | 520 | return d->current; |
516 | } else { | 521 | } else { |
517 | return d->files->selected(); | 522 | return d->files->selected(); |
518 | } | 523 | } |
519 | } | 524 | } |
520 | break; | 525 | break; |
521 | case 1://audio | 526 | case 1://audio |
522 | { | 527 | { |
523 | qDebug("audioView"); | 528 | qDebug("audioView"); |
524 | // Global::findDocuments(&files, "audio/*"); | 529 | // Global::findDocuments(&files, "audio/*"); |
525 | QListIterator<DocLnk> dit( files.children() ); | 530 | QListIterator<DocLnk> dit( files.children() ); |
526 | for ( ; dit.current(); ++dit ) { | 531 | for ( ; dit.current(); ++dit ) { |
527 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 532 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
528 | qDebug("here"); | 533 | qDebug("here"); |
529 | insanityBool=TRUE; | 534 | insanityBool=TRUE; |
530 | return dit; | 535 | return dit; |
531 | } | 536 | } |
532 | } | 537 | } |
533 | } | 538 | } |
534 | break; | 539 | break; |
535 | case 2: // video | 540 | case 2: // video |
536 | { | 541 | { |
537 | qDebug("videoView"); | 542 | qDebug("videoView"); |
538 | // Global::findDocuments(&vFiles, "video/*"); | 543 | // Global::findDocuments(&vFiles, "video/*"); |
539 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 544 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
540 | for ( ; Vdit.current(); ++Vdit ) { | 545 | for ( ; Vdit.current(); ++Vdit ) { |
541 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 546 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
542 | insanityBool=TRUE; | 547 | insanityBool=TRUE; |
543 | return Vdit; | 548 | return Vdit; |
544 | } | 549 | } |
545 | } | 550 | } |
546 | } | 551 | } |
547 | break; | 552 | break; |
548 | }; | 553 | }; |
549 | return 0; | 554 | return 0; |
550 | } | 555 | } |
551 | 556 | ||
552 | bool PlayListWidget::prev() { | 557 | bool PlayListWidget::prev() { |
553 | if ( mediaPlayerState->playlist() ) { | 558 | if ( mediaPlayerState->playlist() ) { |
554 | if ( mediaPlayerState->shuffled() ) { | 559 | if ( mediaPlayerState->shuffled() ) { |
555 | const DocLnk *cur = current(); | 560 | const DocLnk *cur = current(); |
556 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 561 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
557 | for ( int i = 0; i < j; i++ ) { | 562 | for ( int i = 0; i < j; i++ ) { |
558 | if ( !d->selectedFiles->next() ) | 563 | if ( !d->selectedFiles->next() ) |
559 | d->selectedFiles->first(); | 564 | d->selectedFiles->first(); |
560 | } | 565 | } |
561 | if ( cur == current() ) | 566 | if ( cur == current() ) |
562 | if ( !d->selectedFiles->next() ) | 567 | if ( !d->selectedFiles->next() ) |
563 | d->selectedFiles->first(); | 568 | d->selectedFiles->first(); |
564 | return TRUE; | 569 | return TRUE; |
565 | } else { | 570 | } else { |
566 | if ( !d->selectedFiles->prev() ) { | 571 | if ( !d->selectedFiles->prev() ) { |
567 | if ( mediaPlayerState->looping() ) { | 572 | if ( mediaPlayerState->looping() ) { |
568 | return d->selectedFiles->last(); | 573 | return d->selectedFiles->last(); |
569 | } else { | 574 | } else { |
570 | return FALSE; | 575 | return FALSE; |
571 | } | 576 | } |
572 | } | 577 | } |
573 | return TRUE; | 578 | return TRUE; |
574 | } | 579 | } |
575 | } else { | 580 | } else { |
576 | return mediaPlayerState->looping(); | 581 | return mediaPlayerState->looping(); |
577 | } | 582 | } |
578 | } | 583 | } |
579 | 584 | ||
580 | 585 | ||
581 | bool PlayListWidget::next() { | 586 | bool PlayListWidget::next() { |
582 | if ( mediaPlayerState->playlist() ) { | 587 | if ( mediaPlayerState->playlist() ) { |
583 | if ( mediaPlayerState->shuffled() ) { | 588 | if ( mediaPlayerState->shuffled() ) { |
584 | return prev(); | 589 | return prev(); |
585 | } else { | 590 | } else { |
586 | if ( !d->selectedFiles->next() ) { | 591 | if ( !d->selectedFiles->next() ) { |
587 | if ( mediaPlayerState->looping() ) { | 592 | if ( mediaPlayerState->looping() ) { |
588 | return d->selectedFiles->first(); | 593 | return d->selectedFiles->first(); |
589 | } else { | 594 | } else { |
590 | return FALSE; | 595 | return FALSE; |
591 | } | 596 | } |
592 | } | 597 | } |
593 | return TRUE; | 598 | return TRUE; |
594 | } | 599 | } |
595 | } else { | 600 | } else { |
596 | return mediaPlayerState->looping(); | 601 | return mediaPlayerState->looping(); |
597 | } | 602 | } |
598 | } | 603 | } |
599 | 604 | ||
600 | 605 | ||
601 | bool PlayListWidget::first() { | 606 | bool PlayListWidget::first() { |
602 | if ( mediaPlayerState->playlist() ) | 607 | if ( mediaPlayerState->playlist() ) |
603 | return d->selectedFiles->first(); | 608 | return d->selectedFiles->first(); |
604 | else | 609 | else |
605 | return mediaPlayerState->looping(); | 610 | return mediaPlayerState->looping(); |
606 | } | 611 | } |
607 | 612 | ||
608 | 613 | ||
609 | bool PlayListWidget::last() { | 614 | bool PlayListWidget::last() { |
610 | if ( mediaPlayerState->playlist() ) | 615 | if ( mediaPlayerState->playlist() ) |
611 | return d->selectedFiles->last(); | 616 | return d->selectedFiles->last(); |
612 | else | 617 | else |
613 | return mediaPlayerState->looping(); | 618 | return mediaPlayerState->looping(); |
614 | } | 619 | } |
615 | 620 | ||
616 | 621 | ||
617 | void PlayListWidget::saveList() { | 622 | void PlayListWidget::saveList() { |
618 | 623 | ||
619 | QString filename; | 624 | QString filename; |
620 | InputDialog *fileDlg; | 625 | InputDialog *fileDlg; |
621 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 626 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
622 | fileDlg->exec(); | 627 | fileDlg->exec(); |
623 | if( fileDlg->result() == 1 ) { | 628 | if( fileDlg->result() == 1 ) { |
624 | if ( d->current ) | 629 | if ( d->current ) |
625 | delete d->current; | 630 | delete d->current; |
626 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 631 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
627 | // qDebug("saving playlist "+filename+".playlist"); | 632 | // qDebug("saving playlist "+filename+".playlist"); |
628 | Config cfg( filename +".playlist"); | 633 | Config cfg( filename +".playlist"); |
629 | writeConfig( cfg ); | 634 | writeConfig( cfg ); |
630 | 635 | ||
631 | DocLnk lnk; | 636 | DocLnk lnk; |
632 | // lnk.setComment( ""); | 637 | // lnk.setComment( ""); |
633 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 638 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
634 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 639 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
635 | lnk.setIcon("opieplayer/playlist2"); | 640 | lnk.setIcon("opieplayer/playlist2"); |
636 | lnk.setName( filename); //sets file name | 641 | lnk.setName( filename); //sets file name |
637 | // qDebug(filename); | 642 | // qDebug(filename); |
638 | if(!lnk.writeLink()) | 643 | if(!lnk.writeLink()) |
639 | qDebug("Writing doclink did not work"); | 644 | qDebug("Writing doclink did not work"); |
640 | } | 645 | } |
641 | Config config( "OpiePlayer" ); | 646 | Config config( "OpiePlayer" ); |
642 | config.writeEntry("CurrentPlaylist",filename); | 647 | config.writeEntry("CurrentPlaylist",filename); |
643 | setCaption(tr("OpiePlayer: ")+filename); | 648 | setCaption(tr("OpiePlayer: ")+filename); |
644 | d->selectedFiles->first(); | 649 | d->selectedFiles->first(); |
645 | if(fileDlg) | 650 | if(fileDlg) |
646 | delete fileDlg; | 651 | delete fileDlg; |
647 | } | 652 | } |
648 | 653 | ||
649 | void PlayListWidget::loadList( const DocLnk & lnk) { | 654 | void PlayListWidget::loadList( const DocLnk & lnk) { |
650 | QString name= lnk.name(); | 655 | QString name= lnk.name(); |
651 | // qDebug("currentList is "+name); | 656 | // qDebug("currentList is "+name); |
652 | if( name.length()>1) { | 657 | if( name.length()>1) { |
653 | setCaption("OpiePlayer: "+name); | 658 | setCaption("OpiePlayer: "+name); |
654 | // qDebug("load list "+ name+".playlist"); | 659 | // qDebug("load list "+ name+".playlist"); |
655 | clearList(); | 660 | clearList(); |
656 | Config cfg( name+".playlist"); | 661 | Config cfg( name+".playlist"); |
657 | readConfig(cfg); | 662 | readConfig(cfg); |
658 | 663 | ||
659 | tabWidget->setCurrentPage(0); | 664 | tabWidget->setCurrentPage(0); |
660 | 665 | ||
661 | Config config( "OpiePlayer" ); | 666 | Config config( "OpiePlayer" ); |
662 | config.writeEntry("CurrentPlaylist", name); | 667 | config.writeEntry("CurrentPlaylist", name); |
663 | // d->selectedFiles->first(); | 668 | // d->selectedFiles->first(); |
664 | } | 669 | } |
665 | 670 | ||
666 | } | 671 | } |
667 | 672 | ||
668 | void PlayListWidget::setPlaylist( bool shown ) { | 673 | void PlayListWidget::setPlaylist( bool shown ) { |
669 | if ( shown ) | 674 | if ( shown ) |
670 | d->playListFrame->show(); | 675 | d->playListFrame->show(); |
671 | else | 676 | else |
672 | d->playListFrame->hide(); | 677 | d->playListFrame->hide(); |
673 | } | 678 | } |
674 | 679 | ||
675 | void PlayListWidget::setView( char view ) { | 680 | void PlayListWidget::setView( char view ) { |
676 | if ( view == 'l' ) | 681 | if ( view == 'l' ) |
677 | showMaximized(); | 682 | showMaximized(); |
678 | else | 683 | else |
679 | hide(); | 684 | hide(); |
680 | } | 685 | } |
681 | 686 | ||
682 | void PlayListWidget::addSelected() { | 687 | void PlayListWidget::addSelected() { |
683 | 688 | ||
684 | Config cfg( "OpiePlayer" ); | 689 | Config cfg( "OpiePlayer" ); |
685 | cfg.setGroup("PlayList"); | 690 | cfg.setGroup("PlayList"); |
686 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 691 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
687 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 692 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
688 | 693 | ||
689 | switch (tabWidget->currentPageIndex()) { | 694 | switch (tabWidget->currentPageIndex()) { |
690 | case 0: //playlist | 695 | case 0: //playlist |
691 | break; | 696 | break; |
692 | case 1: { //audio | 697 | case 1: { //audio |
693 | // QString entryName; | 698 | // QString entryName; |
694 | // entryName.sprintf( "File%i", i + 1 ); | 699 | // entryName.sprintf( "File%i", i + 1 ); |
695 | // QString linkFile = cfg.readEntry( entryName ); | 700 | // QString linkFile = cfg.readEntry( entryName ); |
696 | QListViewItemIterator it( audioView ); | 701 | QListViewItemIterator it( audioView ); |
697 | // iterate through all items of the listview | 702 | // iterate through all items of the listview |
698 | for ( ; it.current(); ++it ) { | 703 | for ( ; it.current(); ++it ) { |
699 | if ( it.current()->isSelected() ) { | 704 | if ( it.current()->isSelected() ) { |
700 | QListIterator<DocLnk> dit( files.children() ); | 705 | QListIterator<DocLnk> dit( files.children() ); |
701 | for ( ; dit.current(); ++dit ) { | 706 | for ( ; dit.current(); ++dit ) { |
702 | if( dit.current()->name() == it.current()->text(0) ) { | 707 | if( dit.current()->name() == it.current()->text(0) ) { |
703 | d->selectedFiles->addToSelection( **dit ); | 708 | d->selectedFiles->addToSelection( **dit ); |
704 | } | 709 | } |
705 | } | 710 | } |
706 | audioView->setSelected( it.current(),FALSE); | 711 | audioView->setSelected( it.current(),FALSE); |
707 | } | 712 | } |
708 | } | 713 | } |
709 | tabWidget->setCurrentPage(0); | 714 | tabWidget->setCurrentPage(0); |
710 | } | 715 | } |
711 | break; | 716 | break; |
712 | case 2: { // video | 717 | case 2: { // video |
713 | QListViewItemIterator it( videoView ); | 718 | QListViewItemIterator it( videoView ); |
714 | // iterate through all items of the listview | 719 | // iterate through all items of the listview |
715 | for ( ; it.current(); ++it ) { | 720 | for ( ; it.current(); ++it ) { |
716 | if ( it.current()->isSelected() ) { | 721 | if ( it.current()->isSelected() ) { |
717 | QListIterator<DocLnk> dit( vFiles.children() ); | 722 | QListIterator<DocLnk> dit( vFiles.children() ); |
718 | for ( ; dit.current(); ++dit ) { | 723 | for ( ; dit.current(); ++dit ) { |
719 | if( dit.current()->name() == it.current()->text(0) ) { | 724 | if( dit.current()->name() == it.current()->text(0) ) { |
720 | d->selectedFiles->addToSelection( **dit ); | 725 | d->selectedFiles->addToSelection( **dit ); |
721 | } | 726 | } |
722 | } | 727 | } |
723 | 728 | ||
724 | videoView->setSelected( it.current(),FALSE); | 729 | videoView->setSelected( it.current(),FALSE); |
725 | } | 730 | } |
726 | } | 731 | } |
727 | // for ( int i = 0; i < noOfFiles; i++ ) { | 732 | // for ( int i = 0; i < noOfFiles; i++ ) { |
728 | // QString entryName; | 733 | // QString entryName; |
729 | // entryName.sprintf( "File%i", i + 1 ); | 734 | // entryName.sprintf( "File%i", i + 1 ); |
730 | // QString linkFile = cfg.readEntry( entryName ); | 735 | // QString linkFile = cfg.readEntry( entryName ); |
731 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 736 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
732 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | 737 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), |
733 | // tr("This is all ready in your playlist.\nContinue?"), | 738 | // tr("This is all ready in your playlist.\nContinue?"), |
734 | // tr("Yes"),tr("No"),0,0,1); | 739 | // tr("Yes"),tr("No"),0,0,1); |
735 | // if (result !=0) | 740 | // if (result !=0) |
736 | // return; | 741 | // return; |
737 | // } | 742 | // } |
738 | // } | 743 | // } |
739 | // addToSelection( videoView->selectedItem() ); | 744 | // addToSelection( videoView->selectedItem() ); |
740 | tabWidget->setCurrentPage(0); | 745 | tabWidget->setCurrentPage(0); |
741 | } | 746 | } |
742 | break; | 747 | break; |
743 | }; | 748 | }; |
744 | } | 749 | } |
745 | 750 | ||
746 | void PlayListWidget::removeSelected() { | 751 | void PlayListWidget::removeSelected() { |
747 | d->selectedFiles->removeSelected( ); | 752 | d->selectedFiles->removeSelected( ); |
748 | } | 753 | } |
749 | 754 | ||
750 | void PlayListWidget::playIt( QListViewItem *it) { | 755 | void PlayListWidget::playIt( QListViewItem *it) { |
751 | // d->setDocumentUsed = FALSE; | 756 | // d->setDocumentUsed = FALSE; |
752 | mediaPlayerState->setPlaying(FALSE); | 757 | mediaPlayerState->setPlaying(FALSE); |
753 | mediaPlayerState->setPlaying(TRUE); | 758 | mediaPlayerState->setPlaying(TRUE); |
754 | d->selectedFiles->unSelect(); | 759 | d->selectedFiles->unSelect(); |
755 | } | 760 | } |
756 | 761 | ||
757 | void PlayListWidget::addToSelection( QListViewItem *it) { | 762 | void PlayListWidget::addToSelection( QListViewItem *it) { |
758 | d->setDocumentUsed = FALSE; | 763 | d->setDocumentUsed = FALSE; |
759 | 764 | ||
760 | if(it) { | 765 | if(it) { |
761 | switch (tabWidget->currentPageIndex()) { | 766 | switch (tabWidget->currentPageIndex()) { |
762 | case 1: { | 767 | case 1: { |
763 | QListIterator<DocLnk> dit( files.children() ); | 768 | QListIterator<DocLnk> dit( files.children() ); |
764 | for ( ; dit.current(); ++dit ) { | 769 | for ( ; dit.current(); ++dit ) { |
765 | if( dit.current()->name() == it->text(0)) { | 770 | if( dit.current()->name() == it->text(0)) { |
766 | d->selectedFiles->addToSelection( **dit ); | 771 | d->selectedFiles->addToSelection( **dit ); |
767 | } | 772 | } |
768 | } | 773 | } |
769 | } | 774 | } |
770 | break; | 775 | break; |
771 | case 2: { | 776 | case 2: { |
772 | QListIterator<DocLnk> dit( vFiles.children() ); | 777 | QListIterator<DocLnk> dit( vFiles.children() ); |
773 | for ( ; dit.current(); ++dit ) { | 778 | for ( ; dit.current(); ++dit ) { |
774 | if( dit.current()->name() == it->text(0)) { | 779 | if( dit.current()->name() == it->text(0)) { |
775 | d->selectedFiles->addToSelection( **dit ); | 780 | d->selectedFiles->addToSelection( **dit ); |
776 | } | 781 | } |
777 | } | 782 | } |
778 | } | 783 | } |
779 | break; | 784 | break; |
780 | case 0: | 785 | case 0: |
781 | break; | 786 | break; |
782 | }; | 787 | }; |
783 | tabWidget->setCurrentPage(0); | 788 | tabWidget->setCurrentPage(0); |
784 | } | 789 | } |
785 | } | 790 | } |
786 | 791 | ||
787 | void PlayListWidget::tabChanged(QWidget *widg) { | 792 | void PlayListWidget::tabChanged(QWidget *widg) { |
788 | 793 | ||
789 | switch ( tabWidget->currentPageIndex()) { | 794 | switch ( tabWidget->currentPageIndex()) { |
790 | case 0: | 795 | case 0: |
791 | { | 796 | { |
792 | if( !tbDeletePlaylist->isHidden()) | 797 | if( !tbDeletePlaylist->isHidden()) |
793 | tbDeletePlaylist->hide(); | 798 | tbDeletePlaylist->hide(); |
794 | d->tbRemoveFromList->setEnabled(TRUE); | 799 | d->tbRemoveFromList->setEnabled(TRUE); |
795 | d->tbAddToList->setEnabled(FALSE); | 800 | d->tbAddToList->setEnabled(FALSE); |
796 | } | 801 | } |
797 | break; | 802 | break; |
798 | case 1: | 803 | case 1: |
799 | { | 804 | { |
800 | if( !tbDeletePlaylist->isHidden()) | 805 | if( !tbDeletePlaylist->isHidden()) |
801 | tbDeletePlaylist->hide(); | 806 | tbDeletePlaylist->hide(); |
802 | d->tbRemoveFromList->setEnabled(FALSE); | 807 | d->tbRemoveFromList->setEnabled(FALSE); |
803 | d->tbAddToList->setEnabled(TRUE); | 808 | d->tbAddToList->setEnabled(TRUE); |
804 | } | 809 | } |
805 | break; | 810 | break; |
806 | case 2: | 811 | case 2: |
807 | { | 812 | { |
808 | if( !tbDeletePlaylist->isHidden()) | 813 | if( !tbDeletePlaylist->isHidden()) |
809 | tbDeletePlaylist->hide(); | 814 | tbDeletePlaylist->hide(); |
810 | d->tbRemoveFromList->setEnabled(FALSE); | 815 | d->tbRemoveFromList->setEnabled(FALSE); |
811 | d->tbAddToList->setEnabled(TRUE); | 816 | d->tbAddToList->setEnabled(TRUE); |
812 | } | 817 | } |
813 | break; | 818 | break; |
814 | case 3: | 819 | case 3: |
815 | { | 820 | { |
816 | if( tbDeletePlaylist->isHidden()) | 821 | if( tbDeletePlaylist->isHidden()) |
817 | tbDeletePlaylist->show(); | 822 | tbDeletePlaylist->show(); |
818 | playLists->reread(); | 823 | playLists->reread(); |
819 | } | 824 | } |
820 | break; | 825 | break; |
821 | }; | 826 | }; |
822 | } | 827 | } |
823 | 828 | ||
824 | 829 | ||
825 | 830 | ||
826 | void PlayListWidget::btnPlay(bool b) { | 831 | void PlayListWidget::btnPlay(bool b) { |
827 | 832 | ||
828 | // mediaPlayerState->setPlaying(b); | 833 | // mediaPlayerState->setPlaying(b); |
829 | switch ( tabWidget->currentPageIndex()) { | 834 | switch ( tabWidget->currentPageIndex()) { |
830 | case 0: | 835 | case 0: |
831 | { | 836 | { |
832 | mediaPlayerState->setPlaying(b); | 837 | mediaPlayerState->setPlaying(b); |
833 | } | 838 | } |
834 | break; | 839 | break; |
835 | case 1: | 840 | case 1: |
836 | { | 841 | { |
842 | // if(audioView->selectedItem()) { | ||
837 | addToSelection( audioView->selectedItem() ); | 843 | addToSelection( audioView->selectedItem() ); |
838 | mediaPlayerState->setPlaying(b); | 844 | mediaPlayerState->setPlaying(b); |
839 | d->selectedFiles->removeSelected( ); | 845 | d->selectedFiles->removeSelected( ); |
840 | tabWidget->setCurrentPage(1); | 846 | tabWidget->setCurrentPage(1); |
841 | d->selectedFiles->unSelect(); | 847 | d->selectedFiles->unSelect(); |
842 | insanityBool=FALSE; | 848 | insanityBool=FALSE; |
843 | // audioView->clearSelection(); | 849 | // audioView->clearSelection(); |
850 | // } | ||
844 | } | 851 | } |
845 | break; | 852 | break; |
846 | case 2: | 853 | case 2: |
847 | { | 854 | { |
855 | // if(videoView->selectedItem() ) { | ||
848 | addToSelection( videoView->selectedItem() ); | 856 | addToSelection( videoView->selectedItem() ); |
849 | mediaPlayerState->setPlaying(b); | 857 | mediaPlayerState->setPlaying(b); |
850 | qApp->processEvents(); | 858 | qApp->processEvents(); |
851 | d->selectedFiles->removeSelected( ); | 859 | d->selectedFiles->removeSelected( ); |
852 | tabWidget->setCurrentPage(2); | 860 | tabWidget->setCurrentPage(2); |
853 | d->selectedFiles->unSelect(); | 861 | d->selectedFiles->unSelect(); |
854 | insanityBool=FALSE; | 862 | insanityBool=FALSE; |
855 | // videoView->clearSelection(); | 863 | // videoView->clearSelection(); |
864 | // } | ||
856 | } | 865 | } |
857 | break; | 866 | break; |
858 | }; | 867 | }; |
859 | } | 868 | } |
860 | 869 | ||
861 | void PlayListWidget::deletePlaylist() { | 870 | void PlayListWidget::deletePlaylist() { |
862 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 871 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
863 | (tr("You really want to delete\nthis playlist?")), | 872 | (tr("You really want to delete\nthis playlist?")), |
864 | (tr("Yes")), (tr("No")), 0 )){ | 873 | (tr("Yes")), (tr("No")), 0 )){ |
865 | case 0: // Yes clicked, | 874 | case 0: // Yes clicked, |
866 | QFile().remove(playLists->selected()->file()); | 875 | QFile().remove(playLists->selected()->file()); |
867 | QFile().remove(playLists->selected()->linkFile()); | 876 | QFile().remove(playLists->selected()->linkFile()); |
868 | playLists->reread(); | 877 | playLists->reread(); |
869 | break; | 878 | break; |
870 | case 1: // Cancel | 879 | case 1: // Cancel |
871 | break; | 880 | break; |
872 | }; | 881 | }; |
873 | 882 | ||
874 | } | 883 | } |
875 | 884 | ||
876 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 885 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
877 | { | 886 | { |
878 | switch (mouse) { | 887 | switch (mouse) { |
879 | case 1: | 888 | case 1: |
880 | break; | 889 | break; |
881 | case 2:{ | 890 | case 2:{ |
882 | QPopupMenu m; | 891 | QPopupMenu m; |
883 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 892 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
884 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 893 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
885 | m.insertSeparator(); | 894 | m.insertSeparator(); |
895 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | ||
886 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 896 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
897 | |||
887 | m.exec( QCursor::pos() ); | 898 | m.exec( QCursor::pos() ); |
888 | } | 899 | } |
889 | break; | 900 | break; |
890 | }; | 901 | }; |
891 | } | 902 | } |
892 | 903 | ||
893 | void PlayListWidget::playSelected() | 904 | void PlayListWidget::playSelected() |
894 | { | 905 | { |
895 | btnPlay( TRUE); | 906 | btnPlay( TRUE); |
896 | // d->selectedFiles->unSelect(); | 907 | // d->selectedFiles->unSelect(); |
897 | } | 908 | } |
898 | 909 | ||
899 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 910 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
900 | { | 911 | { |
901 | switch (mouse) { | 912 | switch (mouse) { |
902 | case 1: | 913 | case 1: |
903 | 914 | ||
904 | break; | 915 | break; |
905 | case 2:{ | 916 | case 2:{ |
906 | QPopupMenu m; | 917 | QPopupMenu m; |
907 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 918 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
908 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 919 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
909 | // m.insertSeparator(); | 920 | // m.insertSeparator(); |
921 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | ||
910 | m.exec( QCursor::pos() ); | 922 | m.exec( QCursor::pos() ); |
911 | } | 923 | } |
912 | break; | 924 | break; |
913 | }; | 925 | }; |
914 | 926 | ||
915 | } | 927 | } |
916 | 928 | ||
917 | void PlayListWidget::listDelete() { | 929 | void PlayListWidget::listDelete() { |
918 | Config cfg( "OpiePlayer" ); | 930 | Config cfg( "OpiePlayer" ); |
919 | cfg.setGroup("PlayList"); | 931 | cfg.setGroup("PlayList"); |
920 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 932 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
921 | QString file; | 933 | QString file; |
922 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 934 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
923 | switch ( tabWidget->currentPageIndex()) { | 935 | switch ( tabWidget->currentPageIndex()) { |
924 | case 0: | 936 | case 0: |
925 | break; | 937 | break; |
926 | case 1: | 938 | case 1: |
927 | { | 939 | { |
928 | file = audioView->selectedItem()->text(0); | 940 | file = audioView->selectedItem()->text(0); |
929 | // Global::findDocuments(&files, "audio/*"); | 941 | // Global::findDocuments(&files, "audio/*"); |
930 | // AppLnkSet appFiles; | 942 | // AppLnkSet appFiles; |
931 | QListIterator<DocLnk> dit( files.children() ); | 943 | QListIterator<DocLnk> dit( files.children() ); |
932 | for ( ; dit.current(); ++dit ) { | 944 | for ( ; dit.current(); ++dit ) { |
933 | if( dit.current()->name() == file) { | 945 | if( dit.current()->name() == file) { |
934 | // qDebug(file); | 946 | // qDebug(file); |
935 | LnkProperties prop( dit.current() ); | 947 | LnkProperties prop( dit.current() ); |
936 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 948 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
937 | prop.showMaximized(); | 949 | prop.showMaximized(); |
938 | prop.exec(); | 950 | prop.exec(); |
939 | } | 951 | } |
940 | } | 952 | } |
941 | populateAudioView(); | 953 | populateAudioView(); |
942 | } | 954 | } |
943 | break; | 955 | break; |
944 | case 2: | 956 | case 2: |
945 | { | 957 | { |
946 | // file = videoView->selectedItem()->text(0); | 958 | // file = videoView->selectedItem()->text(0); |
947 | // for ( int i = 0; i < noOfFiles; i++ ) { | 959 | // for ( int i = 0; i < noOfFiles; i++ ) { |
948 | // QString entryName; | 960 | // QString entryName; |
949 | // entryName.sprintf( "File%i", i + 1 ); | 961 | // entryName.sprintf( "File%i", i + 1 ); |
950 | // QString linkFile = cfg.readEntry( entryName ); | 962 | // QString linkFile = cfg.readEntry( entryName ); |
951 | // AppLnk lnk( AppLnk(linkFile)); | 963 | // AppLnk lnk( AppLnk(linkFile)); |
952 | // if( lnk.name() == file ) { | 964 | // if( lnk.name() == file ) { |
953 | // LnkProperties prop( &lnk); | 965 | // LnkProperties prop( &lnk); |
954 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 966 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
955 | // prop.showMaximized(); | 967 | // prop.showMaximized(); |
956 | // prop.exec(); | 968 | // prop.exec(); |
957 | // } | 969 | // } |
958 | // } | 970 | // } |
959 | } | 971 | } |
960 | break; | 972 | break; |
961 | }; | 973 | }; |
962 | } | 974 | } |
963 | 975 | ||
964 | void PlayListWidget::populateAudioView() { | 976 | void PlayListWidget::populateAudioView() { |
965 | // if(files) | 977 | // if(files) |
966 | // files.~DocLnkSet(); | 978 | // files.~DocLnkSet(); |
967 | StorageInfo storageInfo; | 979 | StorageInfo storageInfo; |
968 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 980 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
969 | 981 | ||
970 | Global::findDocuments(&files, "audio/*"); | 982 | Global::findDocuments(&files, "audio/*"); |
971 | QListIterator<DocLnk> dit( files.children() ); | 983 | QListIterator<DocLnk> dit( files.children() ); |
972 | QListIterator<FileSystem> it ( fs ); | 984 | QListIterator<FileSystem> it ( fs ); |
973 | audioView->clear(); | 985 | audioView->clear(); |
974 | QString storage; | 986 | QString storage; |
975 | for ( ; dit.current(); ++dit ) { | 987 | for ( ; dit.current(); ++dit ) { |
976 | for( ; it.current(); ++it ){ | 988 | for( ; it.current(); ++it ){ |
977 | const QString name = (*it)->name(); | 989 | const QString name = (*it)->name(); |
978 | const QString path = (*it)->path(); | 990 | const QString path = (*it)->path(); |
979 | if(dit.current()->file().find(path) != -1 ) storage=name; | 991 | if(dit.current()->file().find(path) != -1 ) storage=name; |
980 | } | 992 | } |
981 | 993 | ||
982 | QListViewItem * newItem; | 994 | QListViewItem * newItem; |
983 | if ( QFile( dit.current()->file()).exists() ) { | 995 | if ( QFile( dit.current()->file()).exists() ) { |
984 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 996 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
985 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 997 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
986 | } | 998 | } |
987 | } | 999 | } |
1000 | |||
988 | } | 1001 | } |
989 | 1002 | ||
990 | void PlayListWidget::populateVideoView() { | 1003 | void PlayListWidget::populateVideoView() { |
991 | StorageInfo storageInfo; | 1004 | StorageInfo storageInfo; |
992 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1005 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
993 | 1006 | ||
994 | Global::findDocuments(&vFiles, "video/*"); | 1007 | Global::findDocuments(&vFiles, "video/*"); |
995 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1008 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
996 | QListIterator<FileSystem> it ( fs ); | 1009 | QListIterator<FileSystem> it ( fs ); |
997 | videoView->clear(); | 1010 | videoView->clear(); |
998 | QString storage; | 1011 | QString storage; |
999 | for ( ; Vdit.current(); ++Vdit ) { | 1012 | for ( ; Vdit.current(); ++Vdit ) { |
1000 | for( ; it.current(); ++it ){ | 1013 | for( ; it.current(); ++it ){ |
1001 | const QString name = (*it)->name(); | 1014 | const QString name = (*it)->name(); |
1002 | const QString path = (*it)->path(); | 1015 | const QString path = (*it)->path(); |
1003 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1016 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1004 | } | 1017 | } |
1005 | 1018 | ||
1006 | QListViewItem * newItem; | 1019 | QListViewItem * newItem; |
1007 | if ( QFile( Vdit.current()->file()).exists() ) { | 1020 | if ( QFile( Vdit.current()->file()).exists() ) { |
1008 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1021 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1009 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1022 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1010 | } | 1023 | } |
1011 | } | 1024 | } |
1012 | } | 1025 | } |
1013 | 1026 | ||
1014 | void PlayListWidget::openFile() { | 1027 | void PlayListWidget::openFile() { |
1015 | QString filename, name; | 1028 | QString filename, name; |
1016 | InputDialog *fileDlg; | 1029 | InputDialog *fileDlg; |
1017 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1030 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1018 | fileDlg->exec(); | 1031 | fileDlg->exec(); |
1019 | if( fileDlg->result() == 1 ) { | 1032 | if( fileDlg->result() == 1 ) { |
1020 | filename = fileDlg->LineEdit1->text(); | 1033 | filename = fileDlg->LineEdit1->text(); |
1021 | //http://205.188.234.129:8030 | 1034 | // http://205.188.234.129:8030 |
1022 | // http://66.28.68.70:8000 | 1035 | // http://66.28.68.70:8000 |
1023 | qDebug(filename); | 1036 | qDebug("Selected filename is "+filename); |
1024 | if(filename.right(3) == "m3u") | 1037 | if(filename.right(3) == "m3u") |
1025 | readm3u( filename); | 1038 | readm3u( filename); |
1026 | else if(filename.right(3) == "pls") | 1039 | else if(filename.right(3) == "pls") |
1027 | readPls( filename); | 1040 | readPls( filename); |
1028 | else { | 1041 | else { |
1029 | DocLnk lnk; | 1042 | DocLnk lnk; |
1030 | 1043 | ||
1031 | lnk.setName(filename); //sets file name | 1044 | lnk.setName(filename); //sets file name |
1032 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1045 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") |
1033 | filename += "/"; | 1046 | filename += "/"; |
1034 | lnk.setFile(filename); //sets File property | 1047 | lnk.setFile(filename); //sets File property |
1035 | 1048 | ||
1036 | lnk.setType("audio/x-mpegurl"); | 1049 | lnk.setType("audio/x-mpegurl"); |
1037 | lnk.setExec("opieplayer"); | 1050 | lnk.setExec("opieplayer"); |
1038 | lnk.setIcon("opieplayer/MPEGPlayer"); | 1051 | lnk.setIcon("opieplayer/MPEGPlayer"); |
1039 | 1052 | ||
1040 | if(!lnk.writeLink()) | 1053 | if(!lnk.writeLink()) |
1041 | qDebug("Writing doclink did not work"); | 1054 | qDebug("Writing doclink did not work"); |
1042 | d->selectedFiles->addToSelection( lnk); | 1055 | d->selectedFiles->addToSelection( lnk); |
1043 | // if(fileDlg2) | 1056 | // if(fileDlg2) |
1044 | // delete fileDlg2; | 1057 | // delete fileDlg2; |
1045 | } | 1058 | } |
1046 | } | 1059 | } |
1047 | if(fileDlg) | 1060 | if(fileDlg) |
1048 | delete fileDlg; | 1061 | delete fileDlg; |
1049 | } | 1062 | } |
1050 | 1063 | ||
1051 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1064 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1052 | { | 1065 | { |
1053 | switch ( e->key() ) { | 1066 | switch ( e->key() ) { |
1054 | ////////////////////////////// Zaurus keys | 1067 | ////////////////////////////// Zaurus keys |
1055 | case Key_F9: //activity | 1068 | case Key_F9: //activity |
1056 | // if(audioUI->isHidden()) | 1069 | // if(audioUI->isHidden()) |
1057 | // audioUI->showMaximized(); | 1070 | // audioUI->showMaximized(); |
1058 | break; | 1071 | break; |
1059 | case Key_F10: //contacts | 1072 | case Key_F10: //contacts |
1060 | // if( videoUI->isHidden()) | 1073 | // if( videoUI->isHidden()) |
1061 | // videoUI->showMaximized(); | 1074 | // videoUI->showMaximized(); |
1062 | break; | 1075 | break; |
1063 | case Key_F11: //menu | 1076 | case Key_F11: //menu |
1064 | break; | 1077 | break; |
1065 | case Key_F12: //home | 1078 | case Key_F12: //home |
1066 | // doBlank(); | 1079 | // doBlank(); |
1067 | break; | 1080 | break; |
1068 | case Key_F13: //mail | 1081 | case Key_F13: //mail |
1069 | // doUnblank(); | 1082 | // doUnblank(); |
1070 | break; | 1083 | break; |
1071 | 1084 | case Key_Q: //add to playlist | |
1085 | qDebug("Add"); | ||
1086 | addSelected(); | ||
1087 | break; | ||
1088 | case Key_R: //remove from playlist | ||
1089 | removeSelected(); | ||
1090 | break; | ||
1091 | // case Key_P: //play | ||
1092 | // qDebug("Play"); | ||
1093 | // playSelected(); | ||
1094 | // break; | ||
1095 | case Key_Space: | ||
1096 | qDebug("Play"); | ||
1097 | playSelected(); | ||
1098 | break; | ||
1099 | case Key_1: | ||
1100 | tabWidget->setCurrentPage(0); | ||
1101 | break; | ||
1102 | case Key_2: | ||
1103 | tabWidget->setCurrentPage(1); | ||
1104 | break; | ||
1105 | case Key_3: | ||
1106 | tabWidget->setCurrentPage(2); | ||
1107 | break; | ||
1108 | case Key_4: | ||
1109 | tabWidget->setCurrentPage(3); | ||
1110 | break; | ||
1072 | } | 1111 | } |
1073 | } | 1112 | } |
1074 | 1113 | ||
1114 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | ||
1115 | { | ||
1116 | // qDebug("Key press"); | ||
1117 | // switch ( e->key() ) { | ||
1118 | // ////////////////////////////// Zaurus keys | ||
1119 | // case Key_A: //add to playlist | ||
1120 | // qDebug("Add"); | ||
1121 | // addSelected(); | ||
1122 | // break; | ||
1123 | // case Key_R: //remove from playlist | ||
1124 | // removeSelected(); | ||
1125 | // break; | ||
1126 | // case Key_P: //play | ||
1127 | // qDebug("Play"); | ||
1128 | // playSelected(); | ||
1129 | // break; | ||
1130 | // case Key_Space: | ||
1131 | // qDebug("Play"); | ||
1132 | // playSelected(); | ||
1133 | // break; | ||
1134 | // } | ||
1135 | } | ||
1136 | |||
1075 | void PlayListWidget::doBlank() { | 1137 | void PlayListWidget::doBlank() { |
1076 | qDebug("do blanking"); | 1138 | qDebug("do blanking"); |
1077 | fd=open("/dev/fb0",O_RDWR); | 1139 | fd=open("/dev/fb0",O_RDWR); |
1078 | if (fd != -1) { | 1140 | if (fd != -1) { |
1079 | ioctl(fd,FBIOBLANK,1); | 1141 | ioctl(fd,FBIOBLANK,1); |
1080 | // close(fd); | 1142 | // close(fd); |
1081 | } | 1143 | } |
1082 | } | 1144 | } |
1083 | 1145 | ||
1084 | void PlayListWidget::doUnblank() { | 1146 | void PlayListWidget::doUnblank() { |
1085 | // this crashes opieplayer with a segfault | 1147 | // this crashes opieplayer with a segfault |
1086 | // int fd; | 1148 | // int fd; |
1087 | // fd=open("/dev/fb0",O_RDWR); | 1149 | // fd=open("/dev/fb0",O_RDWR); |
1088 | qDebug("do unblanking"); | 1150 | qDebug("do unblanking"); |
1089 | if (fd != -1) { | 1151 | if (fd != -1) { |
1090 | ioctl(fd,FBIOBLANK,0); | 1152 | ioctl(fd,FBIOBLANK,0); |
1091 | close(fd); | 1153 | close(fd); |
1092 | } | 1154 | } |
1093 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1155 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1094 | h <<-3;// v[1]; // -3 Force on | 1156 | h <<-3;// v[1]; // -3 Force on |
1095 | } | 1157 | } |
1096 | 1158 | ||
1097 | void PlayListWidget::readm3u(const QString &filename) { | 1159 | void PlayListWidget::readm3u(const QString &filename) { |
1098 | 1160 | ||
1161 | qDebug("playlist filename is "+filename); | ||
1162 | QFile f(filename); | ||
1163 | |||
1164 | if(f.open(IO_ReadOnly)) { | ||
1165 | QTextStream t(&f); | ||
1166 | QString s;//, first, second; | ||
1167 | int i=0; | ||
1168 | while ( !t.atEnd()) { | ||
1169 | // Lview->insertLine(t.readLine(),-1); | ||
1170 | s=t.readLine(); | ||
1171 | if(s.find("#",0,TRUE) == -1) { | ||
1172 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | ||
1173 | if(s.left(2) == "E:" || s.left(2) == "P:") { | ||
1174 | s=s.right(s.length()-2); | ||
1175 | DocLnk lnk( s ); | ||
1176 | QFileInfo f(s); | ||
1177 | QString name = f.baseName(); | ||
1178 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1179 | lnk.setName( name); | ||
1180 | s=s.replace( QRegExp("\\"),"/"); | ||
1181 | lnk.setFile( s); | ||
1182 | // lnk.setIcon(opieplayer/MPEGPlayer); | ||
1183 | qDebug("add "+name); | ||
1184 | d->selectedFiles->addToSelection( lnk); | ||
1185 | } else { // is url | ||
1186 | DocLnk lnk( s); | ||
1187 | QString name = s.right( s.length() - 7); | ||
1188 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1189 | lnk.setName(name); | ||
1190 | lnk.setFile( s+"/"); | ||
1191 | // lnk.setFile( filename); | ||
1192 | // lnk.setComment( s+"/"); | ||
1193 | lnk.setType("audio/x-mpegurl"); | ||
1194 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | ||
1195 | // qDebug("add "+s); | ||
1196 | d->selectedFiles->addToSelection( lnk); | ||
1197 | } | ||
1198 | i++; | ||
1199 | } | ||
1200 | } | ||
1201 | } | ||
1202 | } | ||
1099 | } | 1203 | } |
1100 | 1204 | ||
1101 | void PlayListWidget::writem3u(const QString &filename) { | 1205 | void PlayListWidget::writem3u(const QString &filename) { |
1102 | 1206 | ||
1103 | } | 1207 | } |
1104 | 1208 | ||
1105 | void PlayListWidget::readPls(const QString &filename) { | 1209 | void PlayListWidget::readPls(const QString &filename) { |
1106 | 1210 | ||
1211 | qDebug("playlist filename is "+filename); | ||
1212 | QFile f(filename); | ||
1213 | |||
1214 | if(f.open(IO_ReadOnly)) { | ||
1215 | QTextStream t(&f); | ||
1216 | QString s;//, first, second; | ||
1217 | int i=0; | ||
1218 | while ( !t.atEnd()) { | ||
1219 | // Lview->insertLine(t.readLine(),-1); | ||
1220 | // s=t.readLine(); | ||
1221 | // s=s.right(s.length()-2); | ||
1222 | // DocLnk lnk( s ); | ||
1223 | // QFileInfo f(s); | ||
1224 | // QString name = f.baseName(); | ||
1225 | // // name = name.left(name.length()-4); | ||
1226 | // name = name.right(name.findRev("/",0,TRUE)); | ||
1227 | // lnk.setName( name); | ||
1228 | // lnk.setFile( s); | ||
1229 | // qDebug("add "+name); | ||
1230 | // d->selectedFiles->addToSelection( lnk); | ||
1231 | } | ||
1232 | i++; | ||
1233 | } | ||
1107 | } | 1234 | } |