-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 7862d8d..ae03ec8 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,762 +1,761 @@ | |||
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 | 21 | ||
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/fileselector.h> | 24 | #include <qpe/fileselector.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | 26 | ||
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qaction.h> | 31 | #include <qaction.h> |
32 | #include <qimage.h> | 32 | #include <qimage.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | #include <qlist.h> | 36 | #include <qlist.h> |
37 | #include <qlistbox.h> | 37 | #include <qlistbox.h> |
38 | #include <qmainwindow.h> | 38 | #include <qmainwindow.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | #include <qtabwidget.h> | 41 | #include <qtabwidget.h> |
42 | #include <qlistview.h> | 42 | #include <qlistview.h> |
43 | #include <qpoint.h> | 43 | #include <qpoint.h> |
44 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | 46 | ||
47 | //#include <qtimer.h> | 47 | //#include <qtimer.h> |
48 | 48 | ||
49 | #include "playlistselection.h" | 49 | #include "playlistselection.h" |
50 | #include "playlistwidget.h" | 50 | #include "playlistwidget.h" |
51 | #include "mediaplayerstate.h" | 51 | #include "mediaplayerstate.h" |
52 | 52 | ||
53 | #include "fileBrowser.h" | ||
54 | #include "inputDialog.h" | 53 | #include "inputDialog.h" |
55 | 54 | ||
56 | #include <stdlib.h> | 55 | #include <stdlib.h> |
57 | 56 | ||
58 | #define BUTTONS_ON_TOOLBAR | 57 | #define BUTTONS_ON_TOOLBAR |
59 | #define SIDE_BUTTONS | 58 | #define SIDE_BUTTONS |
60 | #define CAN_SAVE_LOAD_PLAYLISTS | 59 | #define CAN_SAVE_LOAD_PLAYLISTS |
61 | 60 | ||
62 | extern MediaPlayerState *mediaPlayerState; | 61 | extern MediaPlayerState *mediaPlayerState; |
63 | 62 | ||
64 | // class myFileSelector { | 63 | // class myFileSelector { |
65 | 64 | ||
66 | // }; | 65 | // }; |
67 | class PlayListWidgetPrivate { | 66 | class PlayListWidgetPrivate { |
68 | public: | 67 | public: |
69 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
70 | QFrame *playListFrame; | 69 | QFrame *playListFrame; |
71 | FileSelector *files; | 70 | FileSelector *files; |
72 | PlayListSelection *selectedFiles; | 71 | PlayListSelection *selectedFiles; |
73 | bool setDocumentUsed; | 72 | bool setDocumentUsed; |
74 | DocLnk *current; | 73 | DocLnk *current; |
75 | }; | 74 | }; |
76 | 75 | ||
77 | 76 | ||
78 | class ToolButton : public QToolButton { | 77 | class ToolButton : public QToolButton { |
79 | public: | 78 | public: |
80 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 79 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
81 | : QToolButton( parent, name ) { | 80 | : QToolButton( parent, name ) { |
82 | setTextLabel( name ); | 81 | setTextLabel( name ); |
83 | setPixmap( Resource::loadPixmap( icon ) ); | 82 | setPixmap( Resource::loadPixmap( icon ) ); |
84 | setAutoRaise( TRUE ); | 83 | setAutoRaise( TRUE ); |
85 | setFocusPolicy( QWidget::NoFocus ); | 84 | setFocusPolicy( QWidget::NoFocus ); |
86 | setToggleButton( t ); | 85 | setToggleButton( t ); |
87 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 86 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
88 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 87 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
89 | } | 88 | } |
90 | }; | 89 | }; |
91 | 90 | ||
92 | 91 | ||
93 | class MenuItem : public QAction { | 92 | class MenuItem : public QAction { |
94 | public: | 93 | public: |
95 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 94 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
96 | : QAction( text, QString::null, 0, 0 ) { | 95 | : QAction( text, QString::null, 0, 0 ) { |
97 | connect( this, SIGNAL( activated() ), handler, slot ); | 96 | connect( this, SIGNAL( activated() ), handler, slot ); |
98 | addTo( parent ); | 97 | addTo( parent ); |
99 | } | 98 | } |
100 | }; | 99 | }; |
101 | 100 | ||
102 | 101 | ||
103 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
104 | : QMainWindow( parent, name, fl ) { | 103 | : QMainWindow( parent, name, fl ) { |
105 | 104 | ||
106 | d = new PlayListWidgetPrivate; | 105 | d = new PlayListWidgetPrivate; |
107 | d->setDocumentUsed = FALSE; | 106 | d->setDocumentUsed = FALSE; |
108 | d->current = NULL; | 107 | d->current = NULL; |
109 | // menuTimer = new QTimer( this ,"menu timer"), | 108 | // menuTimer = new QTimer( this ,"menu timer"), |
110 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 109 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
111 | 110 | ||
112 | setBackgroundMode( PaletteButton ); | 111 | setBackgroundMode( PaletteButton ); |
113 | 112 | ||
114 | setCaption( tr("OpiePlayer") ); | 113 | setCaption( tr("OpiePlayer") ); |
115 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 114 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
116 | 115 | ||
117 | setToolBarsMovable( FALSE ); | 116 | setToolBarsMovable( FALSE ); |
118 | 117 | ||
119 | // Create Toolbar | 118 | // Create Toolbar |
120 | QPEToolBar *toolbar = new QPEToolBar( this ); | 119 | QPEToolBar *toolbar = new QPEToolBar( this ); |
121 | toolbar->setHorizontalStretchable( TRUE ); | 120 | toolbar->setHorizontalStretchable( TRUE ); |
122 | 121 | ||
123 | // Create Menubar | 122 | // Create Menubar |
124 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 123 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
125 | menu->setMargin( 0 ); | 124 | menu->setMargin( 0 ); |
126 | 125 | ||
127 | QPEToolBar *bar = new QPEToolBar( this ); | 126 | QPEToolBar *bar = new QPEToolBar( this ); |
128 | bar->setLabel( tr( "Play Operations" ) ); | 127 | bar->setLabel( tr( "Play Operations" ) ); |
129 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", | 128 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", |
130 | // this , SLOT( addSelected()) ); | 129 | // this , SLOT( addSelected()) ); |
131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("close"),"",bar,"close"); | 130 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("close"),"",bar,"close"); |
132 | tbDeletePlaylist->setFlat(TRUE); | 131 | tbDeletePlaylist->setFlat(TRUE); |
133 | tbDeletePlaylist->setFixedSize(20,20); | 132 | tbDeletePlaylist->setFixedSize(20,20); |
134 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 133 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
135 | 134 | ||
136 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", | 135 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", |
137 | this , SLOT(addSelected()) ); | 136 | this , SLOT(addSelected()) ); |
138 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", | 137 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", |
139 | this , SLOT(removeSelected()) ); | 138 | this , SLOT(removeSelected()) ); |
140 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 139 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
141 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", | 140 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", |
142 | this , SLOT( btnPlay(bool) ), TRUE ); | 141 | this , SLOT( btnPlay(bool) ), TRUE ); |
143 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", | 142 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", |
144 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 143 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
145 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", | 144 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", |
146 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 145 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
147 | tbDeletePlaylist->hide(); | 146 | tbDeletePlaylist->hide(); |
148 | 147 | ||
149 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 148 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
150 | menu->insertItem( tr( "File" ), pmPlayList ); | 149 | menu->insertItem( tr( "File" ), pmPlayList ); |
151 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 150 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
152 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 151 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
153 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 152 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
154 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 153 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
155 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 154 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
156 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 155 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
157 | 156 | ||
158 | QPopupMenu *pmView = new QPopupMenu( this ); | 157 | QPopupMenu *pmView = new QPopupMenu( this ); |
159 | menu->insertItem( tr( "View" ), pmView ); | 158 | menu->insertItem( tr( "View" ), pmView ); |
160 | 159 | ||
161 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 160 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
162 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 161 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
163 | fullScreenButton->addTo(pmView); | 162 | fullScreenButton->addTo(pmView); |
164 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | 163 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); |
165 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 164 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
166 | scaleButton->addTo(pmView); | 165 | scaleButton->addTo(pmView); |
167 | 166 | ||
168 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 167 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
169 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 168 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
170 | 169 | ||
171 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 170 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
172 | 171 | ||
173 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 172 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
174 | tabWidget->setTabShape(QTabWidget::Triangular); | 173 | tabWidget->setTabShape(QTabWidget::Triangular); |
175 | 174 | ||
176 | QWidget *pTab; | 175 | QWidget *pTab; |
177 | pTab = new QWidget( tabWidget, "pTab" ); | 176 | pTab = new QWidget( tabWidget, "pTab" ); |
178 | playlistView = new QListView( pTab, "Videoview" ); | 177 | playlistView = new QListView( pTab, "Videoview" ); |
179 | playlistView->setMinimumSize(236,260); | 178 | playlistView->setMinimumSize(236,260); |
180 | tabWidget->insertTab( pTab,"Playlist"); | 179 | tabWidget->insertTab( pTab,"Playlist"); |
181 | 180 | ||
182 | // Add the playlist area | 181 | // Add the playlist area |
183 | 182 | ||
184 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 183 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
185 | d->playListFrame = vbox3; | 184 | d->playListFrame = vbox3; |
186 | d->playListFrame ->setMinimumSize(235,260); | 185 | d->playListFrame ->setMinimumSize(235,260); |
187 | 186 | ||
188 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 187 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
189 | 188 | ||
190 | d->selectedFiles = new PlayListSelection( hbox2); | 189 | d->selectedFiles = new PlayListSelection( hbox2); |
191 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 190 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
192 | 191 | ||
193 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 192 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
194 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 193 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
195 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 194 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
196 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 195 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
197 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 196 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
198 | 197 | ||
199 | QWidget *aTab; | 198 | QWidget *aTab; |
200 | aTab = new QWidget( tabWidget, "aTab" ); | 199 | aTab = new QWidget( tabWidget, "aTab" ); |
201 | audioView = new QListView( aTab, "Audioview" ); | 200 | audioView = new QListView( aTab, "Audioview" ); |
202 | audioView->setMinimumSize(233,260); | 201 | audioView->setMinimumSize(233,260); |
203 | audioView->addColumn( "Title",150); | 202 | audioView->addColumn( "Title",150); |
204 | audioView->addColumn("Size", 45); | 203 | audioView->addColumn("Size", 45); |
205 | audioView->addColumn("Media",35); | 204 | audioView->addColumn("Media",35); |
206 | audioView->setColumnAlignment(1, Qt::AlignRight); | 205 | audioView->setColumnAlignment(1, Qt::AlignRight); |
207 | audioView->setColumnAlignment(2, Qt::AlignRight); | 206 | audioView->setColumnAlignment(2, Qt::AlignRight); |
208 | tabWidget->insertTab(aTab,"Audio"); | 207 | tabWidget->insertTab(aTab,"Audio"); |
209 | // audioView | 208 | // audioView |
210 | Global::findDocuments(&files, "audio/*"); | 209 | Global::findDocuments(&files, "audio/*"); |
211 | QListIterator<DocLnk> dit( files.children() ); | 210 | QListIterator<DocLnk> dit( files.children() ); |
212 | QString storage; | 211 | QString storage; |
213 | for ( ; dit.current(); ++dit ) { | 212 | for ( ; dit.current(); ++dit ) { |
214 | QListViewItem * newItem; | 213 | QListViewItem * newItem; |
215 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | 214 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; |
216 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | 215 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; |
217 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | 216 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; |
218 | else storage="RAM"; | 217 | else storage="RAM"; |
219 | if ( QFile( dit.current()->file()).exists() ) { | 218 | if ( QFile( dit.current()->file()).exists() ) { |
220 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 219 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
221 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 220 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
222 | } | 221 | } |
223 | } | 222 | } |
224 | // videowidget | 223 | // videowidget |
225 | 224 | ||
226 | QWidget *vTab; | 225 | QWidget *vTab; |
227 | vTab = new QWidget( tabWidget, "vTab" ); | 226 | vTab = new QWidget( tabWidget, "vTab" ); |
228 | videoView = new QListView( vTab, "Videoview" ); | 227 | videoView = new QListView( vTab, "Videoview" ); |
229 | videoView->setMinimumSize(233,260); | 228 | videoView->setMinimumSize(233,260); |
230 | 229 | ||
231 | videoView->addColumn("Title",150); | 230 | videoView->addColumn("Title",150); |
232 | videoView->addColumn("Size",45); | 231 | videoView->addColumn("Size",45); |
233 | videoView->addColumn("Media",35); | 232 | videoView->addColumn("Media",35); |
234 | videoView->setColumnAlignment(1, Qt::AlignRight); | 233 | videoView->setColumnAlignment(1, Qt::AlignRight); |
235 | videoView->setColumnAlignment(2, Qt::AlignRight); | 234 | videoView->setColumnAlignment(2, Qt::AlignRight); |
236 | 235 | ||
237 | tabWidget->insertTab( vTab,"Video"); | 236 | tabWidget->insertTab( vTab,"Video"); |
238 | 237 | ||
239 | Global::findDocuments(&vFiles, "video/*"); | 238 | Global::findDocuments(&vFiles, "video/*"); |
240 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 239 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
241 | for ( ; Vdit.current(); ++Vdit ) { | 240 | for ( ; Vdit.current(); ++Vdit ) { |
242 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | 241 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; |
243 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | 242 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; |
244 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | 243 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; |
245 | else storage="RAM"; | 244 | else storage="RAM"; |
246 | QListViewItem * newItem; | 245 | QListViewItem * newItem; |
247 | if ( QFile( Vdit.current()->file()).exists() ) { | 246 | if ( QFile( Vdit.current()->file()).exists() ) { |
248 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 247 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
249 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 248 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
250 | } | 249 | } |
251 | } | 250 | } |
252 | 251 | ||
253 | //playlists list | 252 | //playlists list |
254 | QWidget *LTab; | 253 | QWidget *LTab; |
255 | LTab = new QWidget( tabWidget, "LTab" ); | 254 | LTab = new QWidget( tabWidget, "LTab" ); |
256 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 255 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
257 | playLists->setMinimumSize(233,260);; | 256 | playLists->setMinimumSize(233,260);; |
258 | tabWidget->insertTab(LTab,"Lists"); | 257 | tabWidget->insertTab(LTab,"Lists"); |
259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 258 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
260 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 259 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
261 | 260 | ||
262 | 261 | ||
263 | // add the library area | 262 | // add the library area |
264 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 263 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
265 | 264 | ||
266 | 265 | ||
267 | connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 266 | connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
268 | this, SLOT( fauxPlay( QListViewItem *) ) ); | 267 | this, SLOT( fauxPlay( QListViewItem *) ) ); |
269 | connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 268 | connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
270 | this, SLOT( fauxPlay( QListViewItem *)) ); | 269 | this, SLOT( fauxPlay( QListViewItem *)) ); |
271 | 270 | ||
272 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 271 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
273 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 272 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
274 | 273 | ||
275 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 274 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
276 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 275 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
277 | 276 | ||
278 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 277 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
279 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 278 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
280 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 279 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
281 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 280 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
282 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 281 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
283 | 282 | ||
284 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 283 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
285 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 284 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
286 | 285 | ||
287 | setCentralWidget( vbox5 ); | 286 | setCentralWidget( vbox5 ); |
288 | 287 | ||
289 | Config cfg( "MediaPlayer" ); | 288 | Config cfg( "MediaPlayer" ); |
290 | readConfig( cfg ); | 289 | readConfig( cfg ); |
291 | 290 | ||
292 | initializeStates(); | 291 | initializeStates(); |
293 | } | 292 | } |
294 | 293 | ||
295 | 294 | ||
296 | PlayListWidget::~PlayListWidget() { | 295 | PlayListWidget::~PlayListWidget() { |
297 | Config cfg( "MediaPlayer" ); | 296 | Config cfg( "MediaPlayer" ); |
298 | writeConfig( cfg ); | 297 | writeConfig( cfg ); |
299 | 298 | ||
300 | if ( d->current ) | 299 | if ( d->current ) |
301 | delete d->current; | 300 | delete d->current; |
302 | delete d; | 301 | delete d; |
303 | } | 302 | } |
304 | 303 | ||
305 | 304 | ||
306 | void PlayListWidget::initializeStates() { | 305 | void PlayListWidget::initializeStates() { |
307 | 306 | ||
308 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 307 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
309 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 308 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
310 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 309 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
311 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 310 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
312 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 311 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
313 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 312 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
314 | // setPlaylist( mediaPlayerState->playlist() ); | 313 | // setPlaylist( mediaPlayerState->playlist() ); |
315 | setPlaylist( true); | 314 | setPlaylist( true); |
316 | d->selectedFiles->first(); | 315 | d->selectedFiles->first(); |
317 | 316 | ||
318 | } | 317 | } |
319 | 318 | ||
320 | 319 | ||
321 | void PlayListWidget::readConfig( Config& cfg ) { | 320 | void PlayListWidget::readConfig( Config& cfg ) { |
322 | cfg.setGroup("PlayList"); | 321 | cfg.setGroup("PlayList"); |
323 | 322 | ||
324 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 323 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
325 | 324 | ||
326 | for ( int i = 0; i < noOfFiles; i++ ) { | 325 | for ( int i = 0; i < noOfFiles; i++ ) { |
327 | QString entryName; | 326 | QString entryName; |
328 | entryName.sprintf( "File%i", i + 1 ); | 327 | entryName.sprintf( "File%i", i + 1 ); |
329 | QString linkFile = cfg.readEntry( entryName ); | 328 | QString linkFile = cfg.readEntry( entryName ); |
330 | DocLnk lnk( linkFile ); | 329 | DocLnk lnk( linkFile ); |
331 | if ( lnk.isValid() ) | 330 | if ( lnk.isValid() ) |
332 | d->selectedFiles->addToSelection( lnk ); | 331 | d->selectedFiles->addToSelection( lnk ); |
333 | } | 332 | } |
334 | } | 333 | } |
335 | 334 | ||
336 | 335 | ||
337 | void PlayListWidget::writeConfig( Config& cfg ) const { | 336 | void PlayListWidget::writeConfig( Config& cfg ) const { |
338 | cfg.setGroup("PlayList"); | 337 | cfg.setGroup("PlayList"); |
339 | 338 | ||
340 | int noOfFiles = 0; | 339 | int noOfFiles = 0; |
341 | 340 | ||
342 | d->selectedFiles->first(); | 341 | d->selectedFiles->first(); |
343 | do { | 342 | do { |
344 | const DocLnk *lnk = d->selectedFiles->current(); | 343 | const DocLnk *lnk = d->selectedFiles->current(); |
345 | if ( lnk ) { | 344 | if ( lnk ) { |
346 | QString entryName; | 345 | QString entryName; |
347 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 346 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
348 | cfg.writeEntry( entryName, lnk->linkFile() ); | 347 | cfg.writeEntry( entryName, lnk->linkFile() ); |
349 | // if this link does exist, add it so we have the file | 348 | // if this link does exist, add it so we have the file |
350 | // next time... | 349 | // next time... |
351 | if ( !QFile::exists( lnk->linkFile() ) ) { | 350 | if ( !QFile::exists( lnk->linkFile() ) ) { |
352 | // the way writing lnks doesn't really check for out | 351 | // the way writing lnks doesn't really check for out |
353 | // of disk space, but check it anyway. | 352 | // of disk space, but check it anyway. |
354 | if ( !lnk->writeLink() ) { | 353 | if ( !lnk->writeLink() ) { |
355 | QMessageBox::critical( 0, tr("Out of space"), | 354 | QMessageBox::critical( 0, tr("Out of space"), |
356 | tr( "There was a problem saving " | 355 | tr( "There was a problem saving " |
357 | "the playlist.\n" | 356 | "the playlist.\n" |
358 | "Your playlist " | 357 | "Your playlist " |
359 | "may be missing some entries\n" | 358 | "may be missing some entries\n" |
360 | "the next time you start it." ) | 359 | "the next time you start it." ) |
361 | ); | 360 | ); |
362 | } | 361 | } |
363 | } | 362 | } |
364 | noOfFiles++; | 363 | noOfFiles++; |
365 | } | 364 | } |
366 | } while ( d->selectedFiles->next() ); | 365 | } while ( d->selectedFiles->next() ); |
367 | 366 | ||
368 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 367 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
369 | 368 | ||
370 | 369 | ||
371 | } | 370 | } |
372 | 371 | ||
373 | 372 | ||
374 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 373 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
375 | qDebug("add"); | 374 | qDebug("add"); |
376 | d->setDocumentUsed = FALSE; | 375 | d->setDocumentUsed = FALSE; |
377 | if ( mediaPlayerState->playlist() ) | 376 | if ( mediaPlayerState->playlist() ) |
378 | d->selectedFiles->addToSelection( lnk ); | 377 | d->selectedFiles->addToSelection( lnk ); |
379 | else | 378 | else |
380 | mediaPlayerState->setPlaying( TRUE ); | 379 | mediaPlayerState->setPlaying( TRUE ); |
381 | } | 380 | } |
382 | 381 | ||
383 | 382 | ||
384 | void PlayListWidget::clearList() { | 383 | void PlayListWidget::clearList() { |
385 | while ( first() ) | 384 | while ( first() ) |
386 | d->selectedFiles->removeSelected(); | 385 | d->selectedFiles->removeSelected(); |
387 | } | 386 | } |
388 | 387 | ||
389 | 388 | ||
390 | void PlayListWidget::addAllToList() { | 389 | void PlayListWidget::addAllToList() { |
391 | DocLnkSet files; | 390 | DocLnkSet files; |
392 | Global::findDocuments(&files, "video/*;audio/*"); | 391 | Global::findDocuments(&files, "video/*;audio/*"); |
393 | QListIterator<DocLnk> dit( files.children() ); | 392 | QListIterator<DocLnk> dit( files.children() ); |
394 | for ( ; dit.current(); ++dit ) | 393 | for ( ; dit.current(); ++dit ) |
395 | d->selectedFiles->addToSelection( **dit ); | 394 | d->selectedFiles->addToSelection( **dit ); |
396 | } | 395 | } |
397 | 396 | ||
398 | 397 | ||
399 | void PlayListWidget::addAllMusicToList() { | 398 | void PlayListWidget::addAllMusicToList() { |
400 | DocLnkSet files; | 399 | DocLnkSet files; |
401 | Global::findDocuments(&files, "audio/*"); | 400 | Global::findDocuments(&files, "audio/*"); |
402 | QListIterator<DocLnk> dit( files.children() ); | 401 | QListIterator<DocLnk> dit( files.children() ); |
403 | for ( ; dit.current(); ++dit ) | 402 | for ( ; dit.current(); ++dit ) |
404 | d->selectedFiles->addToSelection( **dit ); | 403 | d->selectedFiles->addToSelection( **dit ); |
405 | } | 404 | } |
406 | 405 | ||
407 | 406 | ||
408 | void PlayListWidget::addAllVideoToList() { | 407 | void PlayListWidget::addAllVideoToList() { |
409 | DocLnkSet files; | 408 | DocLnkSet files; |
410 | Global::findDocuments(&files, "video/*"); | 409 | Global::findDocuments(&files, "video/*"); |
411 | QListIterator<DocLnk> dit( files.children() ); | 410 | QListIterator<DocLnk> dit( files.children() ); |
412 | for ( ; dit.current(); ++dit ) | 411 | for ( ; dit.current(); ++dit ) |
413 | d->selectedFiles->addToSelection( **dit ); | 412 | d->selectedFiles->addToSelection( **dit ); |
414 | } | 413 | } |
415 | 414 | ||
416 | 415 | ||
417 | void PlayListWidget::setDocument(const QString& fileref) { | 416 | void PlayListWidget::setDocument(const QString& fileref) { |
418 | if ( fileref.isNull() ) { | 417 | if ( fileref.isNull() ) { |
419 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 418 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
420 | return; | 419 | return; |
421 | } | 420 | } |
422 | if ( mediaPlayerState->playlist() ) | 421 | if ( mediaPlayerState->playlist() ) |
423 | addToSelection( DocLnk( fileref ) ); | 422 | addToSelection( DocLnk( fileref ) ); |
424 | else { | 423 | else { |
425 | d->setDocumentUsed = TRUE; | 424 | d->setDocumentUsed = TRUE; |
426 | if ( d->current ) | 425 | if ( d->current ) |
427 | delete d->current; | 426 | delete d->current; |
428 | d->current = new DocLnk( fileref ); | 427 | d->current = new DocLnk( fileref ); |
429 | } | 428 | } |
430 | mediaPlayerState->setPlaying( FALSE ); | 429 | mediaPlayerState->setPlaying( FALSE ); |
431 | mediaPlayerState->setPlaying( TRUE ); | 430 | mediaPlayerState->setPlaying( TRUE ); |
432 | } | 431 | } |
433 | 432 | ||
434 | 433 | ||
435 | void PlayListWidget::setActiveWindow() { | 434 | void PlayListWidget::setActiveWindow() { |
436 | // When we get raised we need to ensure that it switches views | 435 | // When we get raised we need to ensure that it switches views |
437 | char origView = mediaPlayerState->view(); | 436 | char origView = mediaPlayerState->view(); |
438 | mediaPlayerState->setView( 'l' ); // invalidate | 437 | mediaPlayerState->setView( 'l' ); // invalidate |
439 | mediaPlayerState->setView( origView ); // now switch back | 438 | mediaPlayerState->setView( origView ); // now switch back |
440 | } | 439 | } |
441 | 440 | ||
442 | 441 | ||
443 | void PlayListWidget::useSelectedDocument() { | 442 | void PlayListWidget::useSelectedDocument() { |
444 | d->setDocumentUsed = FALSE; | 443 | d->setDocumentUsed = FALSE; |
445 | } | 444 | } |
446 | 445 | ||
447 | 446 | ||
448 | const DocLnk *PlayListWidget::current() { | 447 | const DocLnk *PlayListWidget::current() { |
449 | 448 | ||
450 | // qDebug("in Playlist widget ::current"); | 449 | // qDebug("in Playlist widget ::current"); |
451 | if ( mediaPlayerState->playlist() ) { | 450 | if ( mediaPlayerState->playlist() ) { |
452 | return d->selectedFiles->current(); | 451 | return d->selectedFiles->current(); |
453 | } | 452 | } |
454 | else if ( d->setDocumentUsed && d->current ) { | 453 | else if ( d->setDocumentUsed && d->current ) { |
455 | return d->current; | 454 | return d->current; |
456 | } else { | 455 | } else { |
457 | return d->files->selected(); | 456 | return d->files->selected(); |
458 | } | 457 | } |
459 | } | 458 | } |
460 | 459 | ||
461 | 460 | ||
462 | bool PlayListWidget::prev() { | 461 | bool PlayListWidget::prev() { |
463 | if ( mediaPlayerState->playlist() ) { | 462 | if ( mediaPlayerState->playlist() ) { |
464 | if ( mediaPlayerState->shuffled() ) { | 463 | if ( mediaPlayerState->shuffled() ) { |
465 | const DocLnk *cur = current(); | 464 | const DocLnk *cur = current(); |
466 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 465 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
467 | for ( int i = 0; i < j; i++ ) { | 466 | for ( int i = 0; i < j; i++ ) { |
468 | if ( !d->selectedFiles->next() ) | 467 | if ( !d->selectedFiles->next() ) |
469 | d->selectedFiles->first(); | 468 | d->selectedFiles->first(); |
470 | } | 469 | } |
471 | if ( cur == current() ) | 470 | if ( cur == current() ) |
472 | if ( !d->selectedFiles->next() ) | 471 | if ( !d->selectedFiles->next() ) |
473 | d->selectedFiles->first(); | 472 | d->selectedFiles->first(); |
474 | return TRUE; | 473 | return TRUE; |
475 | } else { | 474 | } else { |
476 | if ( !d->selectedFiles->prev() ) { | 475 | if ( !d->selectedFiles->prev() ) { |
477 | if ( mediaPlayerState->looping() ) { | 476 | if ( mediaPlayerState->looping() ) { |
478 | return d->selectedFiles->last(); | 477 | return d->selectedFiles->last(); |
479 | } else { | 478 | } else { |
480 | return FALSE; | 479 | return FALSE; |
481 | } | 480 | } |
482 | } | 481 | } |
483 | return TRUE; | 482 | return TRUE; |
484 | } | 483 | } |
485 | } else { | 484 | } else { |
486 | return mediaPlayerState->looping(); | 485 | return mediaPlayerState->looping(); |
487 | } | 486 | } |
488 | } | 487 | } |
489 | 488 | ||
490 | 489 | ||
491 | bool PlayListWidget::next() { | 490 | bool PlayListWidget::next() { |
492 | if ( mediaPlayerState->playlist() ) { | 491 | if ( mediaPlayerState->playlist() ) { |
493 | if ( mediaPlayerState->shuffled() ) { | 492 | if ( mediaPlayerState->shuffled() ) { |
494 | return prev(); | 493 | return prev(); |
495 | } else { | 494 | } else { |
496 | if ( !d->selectedFiles->next() ) { | 495 | if ( !d->selectedFiles->next() ) { |
497 | if ( mediaPlayerState->looping() ) { | 496 | if ( mediaPlayerState->looping() ) { |
498 | return d->selectedFiles->first(); | 497 | return d->selectedFiles->first(); |
499 | } else { | 498 | } else { |
500 | return FALSE; | 499 | return FALSE; |
501 | } | 500 | } |
502 | } | 501 | } |
503 | return TRUE; | 502 | return TRUE; |
504 | } | 503 | } |
505 | } else { | 504 | } else { |
506 | return mediaPlayerState->looping(); | 505 | return mediaPlayerState->looping(); |
507 | } | 506 | } |
508 | } | 507 | } |
509 | 508 | ||
510 | 509 | ||
511 | bool PlayListWidget::first() { | 510 | bool PlayListWidget::first() { |
512 | if ( mediaPlayerState->playlist() ) | 511 | if ( mediaPlayerState->playlist() ) |
513 | return d->selectedFiles->first(); | 512 | return d->selectedFiles->first(); |
514 | else | 513 | else |
515 | return mediaPlayerState->looping(); | 514 | return mediaPlayerState->looping(); |
516 | } | 515 | } |
517 | 516 | ||
518 | 517 | ||
519 | bool PlayListWidget::last() { | 518 | bool PlayListWidget::last() { |
520 | if ( mediaPlayerState->playlist() ) | 519 | if ( mediaPlayerState->playlist() ) |
521 | return d->selectedFiles->last(); | 520 | return d->selectedFiles->last(); |
522 | else | 521 | else |
523 | return mediaPlayerState->looping(); | 522 | return mediaPlayerState->looping(); |
524 | } | 523 | } |
525 | 524 | ||
526 | 525 | ||
527 | void PlayListWidget::saveList() { | 526 | void PlayListWidget::saveList() { |
528 | 527 | ||
529 | QString filename; | 528 | QString filename; |
530 | InputDialog *fileDlg; | 529 | InputDialog *fileDlg; |
531 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); | 530 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); |
532 | fileDlg->exec(); | 531 | fileDlg->exec(); |
533 | if( fileDlg->result() == 1 ) { | 532 | if( fileDlg->result() == 1 ) { |
534 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 533 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
535 | qDebug("saving playlist "+filename+".playlist"); | 534 | qDebug("saving playlist "+filename+".playlist"); |
536 | 535 | ||
537 | // DocLnk *lnk; | 536 | // DocLnk *lnk; |
538 | // lnk.setName( filename); //sets file name | 537 | // lnk.setName( filename); //sets file name |
539 | // // lnk.setComment(title); | 538 | // // lnk.setComment(title); |
540 | // lnk.setFile( filename+".playlist"); //sets File property | 539 | // lnk.setFile( filename+".playlist"); //sets File property |
541 | // lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D | 540 | // lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D |
542 | // lnk.setIcon("MPEGPlayer"); | 541 | // lnk.setIcon("MPEGPlayer"); |
543 | // if(!lnk.writeLink()) | 542 | // if(!lnk.writeLink()) |
544 | // qDebug("Writing doclink did not work"); | 543 | // qDebug("Writing doclink did not work"); |
545 | 544 | ||
546 | Config cfg( filename +".playlist"); | 545 | Config cfg( filename +".playlist"); |
547 | writeConfig( cfg ); | 546 | writeConfig( cfg ); |
548 | } | 547 | } |
549 | DocLnk lnk; | 548 | DocLnk lnk; |
550 | lnk.setName( filename); //sets file name | 549 | lnk.setName( filename); //sets file name |
551 | // lnk.setComment(title); | 550 | // lnk.setComment(title); |
552 | lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property | 551 | lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property |
553 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 552 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
554 | lnk.setIcon("MPEGPlayer"); | 553 | lnk.setIcon("MPEGPlayer"); |
555 | if(!lnk.writeLink()) | 554 | if(!lnk.writeLink()) |
556 | qDebug("Writing doclink did not work"); | 555 | qDebug("Writing doclink did not work"); |
557 | 556 | ||
558 | if(fileDlg) | 557 | if(fileDlg) |
559 | delete fileDlg; | 558 | delete fileDlg; |
560 | } | 559 | } |
561 | 560 | ||
562 | 561 | ||
563 | void PlayListWidget::loadList( const DocLnk & lnk) { | 562 | void PlayListWidget::loadList( const DocLnk & lnk) { |
564 | 563 | qDebug("load list "+ lnk.name()+".playlist"); | |
565 | clearList(); | 564 | clearList(); |
566 | Config cfg( lnk.file()); | 565 | Config cfg( lnk.name()+".playlist"); |
567 | readConfig(cfg); | 566 | readConfig(cfg); |
568 | tabWidget->setCurrentPage(0); | 567 | tabWidget->setCurrentPage(0); |
569 | setCaption("OpiePlayer: "+lnk.name()); | 568 | setCaption("OpiePlayer: "+lnk.name()); |
570 | } | 569 | } |
571 | 570 | ||
572 | 571 | ||
573 | void PlayListWidget::setPlaylist( bool shown ) { | 572 | void PlayListWidget::setPlaylist( bool shown ) { |
574 | if ( shown ) | 573 | if ( shown ) |
575 | d->playListFrame->show(); | 574 | d->playListFrame->show(); |
576 | else | 575 | else |
577 | d->playListFrame->hide(); | 576 | d->playListFrame->hide(); |
578 | } | 577 | } |
579 | 578 | ||
580 | 579 | ||
581 | void PlayListWidget::setView( char view ) { | 580 | void PlayListWidget::setView( char view ) { |
582 | if ( view == 'l' ) | 581 | if ( view == 'l' ) |
583 | showMaximized(); | 582 | showMaximized(); |
584 | else | 583 | else |
585 | hide(); | 584 | hide(); |
586 | } | 585 | } |
587 | 586 | ||
588 | void PlayListWidget::addSelected() { | 587 | void PlayListWidget::addSelected() { |
589 | 588 | ||
590 | switch (tabWidget->currentPageIndex()) { | 589 | switch (tabWidget->currentPageIndex()) { |
591 | case 0: //playlist | 590 | case 0: //playlist |
592 | break; | 591 | break; |
593 | case 1: { //audio | 592 | case 1: { //audio |
594 | addToSelection( audioView->selectedItem() ); | 593 | addToSelection( audioView->selectedItem() ); |
595 | } | 594 | } |
596 | break; | 595 | break; |
597 | case 2: { // video | 596 | case 2: { // video |
598 | addToSelection( videoView->selectedItem() ); | 597 | addToSelection( videoView->selectedItem() ); |
599 | } | 598 | } |
600 | break; | 599 | break; |
601 | }; | 600 | }; |
602 | } | 601 | } |
603 | 602 | ||
604 | void PlayListWidget::removeSelected() { | 603 | void PlayListWidget::removeSelected() { |
605 | d->selectedFiles->removeSelected( ); | 604 | d->selectedFiles->removeSelected( ); |
606 | } | 605 | } |
607 | 606 | ||
608 | 607 | ||
609 | void PlayListWidget::playIt( QListViewItem *it) { | 608 | void PlayListWidget::playIt( QListViewItem *it) { |
610 | // d->setDocumentUsed = FALSE; | 609 | // d->setDocumentUsed = FALSE; |
611 | mediaPlayerState->setPlaying(TRUE); | 610 | mediaPlayerState->setPlaying(TRUE); |
612 | } | 611 | } |
613 | 612 | ||
614 | void PlayListWidget::addToSelection( QListViewItem *it) { | 613 | void PlayListWidget::addToSelection( QListViewItem *it) { |
615 | d->setDocumentUsed = FALSE; | 614 | d->setDocumentUsed = FALSE; |
616 | 615 | ||
617 | if(it) { | 616 | if(it) { |
618 | // qDebug("add to selection"); | 617 | // qDebug("add to selection"); |
619 | switch (tabWidget->currentPageIndex()) { | 618 | switch (tabWidget->currentPageIndex()) { |
620 | case 1: { | 619 | case 1: { |
621 | // qDebug("case 1"); | 620 | // qDebug("case 1"); |
622 | QListIterator<DocLnk> dit( files.children() ); | 621 | QListIterator<DocLnk> dit( files.children() ); |
623 | for ( ; dit.current(); ++dit ) { | 622 | for ( ; dit.current(); ++dit ) { |
624 | // qDebug(dit.current()->name()); | 623 | // qDebug(dit.current()->name()); |
625 | if( dit.current()->name() == it->text(0)) { | 624 | if( dit.current()->name() == it->text(0)) { |
626 | d->selectedFiles->addToSelection( **dit ); | 625 | d->selectedFiles->addToSelection( **dit ); |
627 | } | 626 | } |
628 | } | 627 | } |
629 | } | 628 | } |
630 | break; | 629 | break; |
631 | case 2: { | 630 | case 2: { |
632 | // qDebug("case 2"); | 631 | // qDebug("case 2"); |
633 | QListIterator<DocLnk> dit( vFiles.children() ); | 632 | QListIterator<DocLnk> dit( vFiles.children() ); |
634 | for ( ; dit.current(); ++dit ) { | 633 | for ( ; dit.current(); ++dit ) { |
635 | // qDebug(dit.current()->name()); | 634 | // qDebug(dit.current()->name()); |
636 | if( dit.current()->name() == it->text(0)) { | 635 | if( dit.current()->name() == it->text(0)) { |
637 | d->selectedFiles->addToSelection( **dit ); | 636 | d->selectedFiles->addToSelection( **dit ); |
638 | } | 637 | } |
639 | } | 638 | } |
640 | } | 639 | } |
641 | break; | 640 | break; |
642 | case 0: | 641 | case 0: |
643 | break; | 642 | break; |
644 | }; | 643 | }; |
645 | tabWidget->setCurrentPage(0); | 644 | tabWidget->setCurrentPage(0); |
646 | // mediaPlayerState->setPlaying( TRUE ); | 645 | // mediaPlayerState->setPlaying( TRUE ); |
647 | } | 646 | } |
648 | } | 647 | } |
649 | 648 | ||
650 | void PlayListWidget::tabChanged(QWidget *widg) { | 649 | void PlayListWidget::tabChanged(QWidget *widg) { |
651 | 650 | ||
652 | switch ( tabWidget->currentPageIndex()) { | 651 | switch ( tabWidget->currentPageIndex()) { |
653 | case 0: | 652 | case 0: |
654 | { | 653 | { |
655 | if( !tbDeletePlaylist->isHidden()) | 654 | if( !tbDeletePlaylist->isHidden()) |
656 | tbDeletePlaylist->hide(); | 655 | tbDeletePlaylist->hide(); |
657 | d->tbRemoveFromList->setEnabled(TRUE); | 656 | d->tbRemoveFromList->setEnabled(TRUE); |
658 | d->tbAddToList->setEnabled(FALSE); | 657 | d->tbAddToList->setEnabled(FALSE); |
659 | } | 658 | } |
660 | break; | 659 | break; |
661 | case 1: | 660 | case 1: |
662 | { | 661 | { |
663 | if( !tbDeletePlaylist->isHidden()) | 662 | if( !tbDeletePlaylist->isHidden()) |
664 | tbDeletePlaylist->hide(); | 663 | tbDeletePlaylist->hide(); |
665 | d->tbRemoveFromList->setEnabled(FALSE); | 664 | d->tbRemoveFromList->setEnabled(FALSE); |
666 | d->tbAddToList->setEnabled(TRUE); | 665 | d->tbAddToList->setEnabled(TRUE); |
667 | } | 666 | } |
668 | break; | 667 | break; |
669 | case 2: | 668 | case 2: |
670 | { | 669 | { |
671 | if( !tbDeletePlaylist->isHidden()) | 670 | if( !tbDeletePlaylist->isHidden()) |
672 | tbDeletePlaylist->hide(); | 671 | tbDeletePlaylist->hide(); |
673 | d->tbRemoveFromList->setEnabled(FALSE); | 672 | d->tbRemoveFromList->setEnabled(FALSE); |
674 | d->tbAddToList->setEnabled(TRUE); | 673 | d->tbAddToList->setEnabled(TRUE); |
675 | } | 674 | } |
676 | break; | 675 | break; |
677 | case 3: | 676 | case 3: |
678 | { | 677 | { |
679 | if( tbDeletePlaylist->isHidden()) | 678 | if( tbDeletePlaylist->isHidden()) |
680 | tbDeletePlaylist->show(); | 679 | tbDeletePlaylist->show(); |
681 | playLists->reread(); | 680 | playLists->reread(); |
682 | } | 681 | } |
683 | break; | 682 | break; |
684 | }; | 683 | }; |
685 | } | 684 | } |
686 | 685 | ||
687 | /* | 686 | /* |
688 | list is right clicked*/ | 687 | list is right clicked*/ |
689 | void PlayListWidget::fauxPlay(QListViewItem *it) { | 688 | void PlayListWidget::fauxPlay(QListViewItem *it) { |
690 | 689 | ||
691 | switch (tabWidget->currentPageIndex()) { | 690 | switch (tabWidget->currentPageIndex()) { |
692 | case 0: //playlist | 691 | case 0: //playlist |
693 | break; | 692 | break; |
694 | case 1: { //audio | 693 | case 1: { //audio |
695 | QListIterator<DocLnk> dit( files.children() ); | 694 | QListIterator<DocLnk> dit( files.children() ); |
696 | for ( ; dit.current(); ++dit ) { | 695 | for ( ; dit.current(); ++dit ) { |
697 | // qDebug(dit.current()->name()); | 696 | // qDebug(dit.current()->name()); |
698 | if( dit.current()->name() == it->text(0)) { | 697 | if( dit.current()->name() == it->text(0)) { |
699 | d->selectedFiles->addToSelection( **dit ); | 698 | d->selectedFiles->addToSelection( **dit ); |
700 | } | 699 | } |
701 | } | 700 | } |
702 | } | 701 | } |
703 | break; | 702 | break; |
704 | case 2: { // video | 703 | case 2: { // video |
705 | QListIterator<DocLnk> dit( vFiles.children() ); | 704 | QListIterator<DocLnk> dit( vFiles.children() ); |
706 | for ( ; dit.current(); ++dit ) { | 705 | for ( ; dit.current(); ++dit ) { |
707 | // qDebug(dit.current()->name()); | 706 | // qDebug(dit.current()->name()); |
708 | if( dit.current()->name() == it->text(0)) { | 707 | if( dit.current()->name() == it->text(0)) { |
709 | d->selectedFiles->addToSelection( **dit ); | 708 | d->selectedFiles->addToSelection( **dit ); |
710 | } | 709 | } |
711 | } | 710 | } |
712 | } | 711 | } |
713 | break; | 712 | break; |
714 | }; | 713 | }; |
715 | mediaPlayerState->setPlaying( TRUE ); | 714 | mediaPlayerState->setPlaying( TRUE ); |
716 | // tabWidget->setCurrentPage(0); | 715 | // tabWidget->setCurrentPage(0); |
717 | d->selectedFiles->removeSelected(); | 716 | d->selectedFiles->removeSelected(); |
718 | } | 717 | } |
719 | 718 | ||
720 | /* | 719 | /* |
721 | play button is pressed*/ | 720 | play button is pressed*/ |
722 | void PlayListWidget::btnPlay(bool b) { // this is fugly | 721 | void PlayListWidget::btnPlay(bool b) { // this is fugly |
723 | switch ( tabWidget->currentPageIndex()) { | 722 | switch ( tabWidget->currentPageIndex()) { |
724 | case 0: | 723 | case 0: |
725 | { | 724 | { |
726 | mediaPlayerState->setPlaying(b); | 725 | mediaPlayerState->setPlaying(b); |
727 | } | 726 | } |
728 | break; | 727 | break; |
729 | case 1: | 728 | case 1: |
730 | { | 729 | { |
731 | addToSelection( audioView->selectedItem() ); | 730 | addToSelection( audioView->selectedItem() ); |
732 | mediaPlayerState->setPlaying(b); | 731 | mediaPlayerState->setPlaying(b); |
733 | d->selectedFiles->removeSelected( ); | 732 | d->selectedFiles->removeSelected( ); |
734 | tabWidget->setCurrentPage(1); | 733 | tabWidget->setCurrentPage(1); |
735 | } | 734 | } |
736 | break; | 735 | break; |
737 | case 2: | 736 | case 2: |
738 | { | 737 | { |
739 | addToSelection( videoView->selectedItem() ); | 738 | addToSelection( videoView->selectedItem() ); |
740 | mediaPlayerState->setPlaying(b); | 739 | mediaPlayerState->setPlaying(b); |
741 | d->selectedFiles->removeSelected( ); | 740 | d->selectedFiles->removeSelected( ); |
742 | tabWidget->setCurrentPage(2); | 741 | tabWidget->setCurrentPage(2); |
743 | } | 742 | } |
744 | break; | 743 | break; |
745 | }; | 744 | }; |
746 | 745 | ||
747 | } | 746 | } |
748 | 747 | ||
749 | void PlayListWidget::deletePlaylist() { | 748 | void PlayListWidget::deletePlaylist() { |
750 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 749 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
751 | (tr("You really want to delete\nthis playlist?")), | 750 | (tr("You really want to delete\nthis playlist?")), |
752 | (tr("Yes")), (tr("No")), 0 )){ | 751 | (tr("Yes")), (tr("No")), 0 )){ |
753 | case 0: // Yes clicked, | 752 | case 0: // Yes clicked, |
754 | QFile().remove(playLists->selected()->file()); | 753 | QFile().remove(playLists->selected()->file()); |
755 | QFile().remove(playLists->selected()->linkFile()); | 754 | QFile().remove(playLists->selected()->linkFile()); |
756 | playLists->reread(); | 755 | playLists->reread(); |
757 | break; | 756 | break; |
758 | case 1: // Cancel | 757 | case 1: // Cancel |
759 | break; | 758 | break; |
760 | }; | 759 | }; |
761 | 760 | ||
762 | } | 761 | } |