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