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