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