author | llornkcor <llornkcor> | 2002-05-12 12:15:30 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-12 12:15:30 (UTC) |
commit | c1cc5edca5d6d71350f841892fb7828f7be9ed9f (patch) (unidiff) | |
tree | 014224506a39db65d54c41b18c5f7c1096cb7a92 | |
parent | 06e723cc7942af2691828e7fdc6a6ec47b44edab (diff) | |
download | opie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.zip opie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.tar.gz opie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.tar.bz2 |
added a few keyboard shorts
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 139 |
1 files changed, 133 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 038b371..ec5500f 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -5,81 +5,81 @@ | |||
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/lnkproperties.h> | 28 | #include <qpe/lnkproperties.h> |
29 | #include <qpe/storage.h> | 29 | #include <qpe/storage.h> |
30 | 30 | ||
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | 35 | ||
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qcursor.h> | ||
38 | #include <qimage.h> | 37 | #include <qimage.h> |
39 | #include <qfile.h> | 38 | #include <qfile.h> |
40 | #include <qdir.h> | 39 | #include <qdir.h> |
41 | #include <qlayout.h> | 40 | #include <qlayout.h> |
42 | #include <qlabel.h> | 41 | #include <qlabel.h> |
43 | #include <qlist.h> | 42 | #include <qlist.h> |
44 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
45 | #include <qmainwindow.h> | 44 | #include <qmainwindow.h> |
46 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
47 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
48 | #include <qtabwidget.h> | 47 | #include <qtabwidget.h> |
49 | #include <qlistview.h> | 48 | #include <qlistview.h> |
50 | #include <qpoint.h> | 49 | #include <qpoint.h> |
51 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
52 | #include <qpushbutton.h> | 51 | #include <qpushbutton.h> |
53 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qtextstream.h> | ||
54 | 54 | ||
55 | //#include <qtimer.h> | 55 | //#include <qtimer.h> |
56 | 56 | ||
57 | #include "playlistselection.h" | 57 | #include "playlistselection.h" |
58 | #include "playlistwidget.h" | 58 | #include "playlistwidget.h" |
59 | #include "mediaplayerstate.h" | 59 | #include "mediaplayerstate.h" |
60 | 60 | ||
61 | #include "inputDialog.h" | 61 | #include "inputDialog.h" |
62 | 62 | ||
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | #include "audiowidget.h" | 64 | #include "audiowidget.h" |
65 | #include "videowidget.h" | 65 | #include "videowidget.h" |
66 | 66 | ||
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #include <sys/file.h> | 68 | #include <sys/file.h> |
69 | #include <sys/ioctl.h> | 69 | #include <sys/ioctl.h> |
70 | #include <sys/soundcard.h> | 70 | #include <sys/soundcard.h> |
71 | 71 | ||
72 | // for setBacklight() | 72 | // for setBacklight() |
73 | #include <linux/fb.h> | 73 | #include <linux/fb.h> |
74 | #include <sys/types.h> | 74 | #include <sys/types.h> |
75 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
76 | #include <stdlib.h> | 76 | #include <stdlib.h> |
77 | 77 | ||
78 | #define BUTTONS_ON_TOOLBAR | 78 | #define BUTTONS_ON_TOOLBAR |
79 | #define SIDE_BUTTONS | 79 | #define SIDE_BUTTONS |
80 | #define CAN_SAVE_LOAD_PLAYLISTS | 80 | #define CAN_SAVE_LOAD_PLAYLISTS |
81 | 81 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
@@ -220,86 +220,91 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
220 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 220 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
221 | 221 | ||
222 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 222 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
223 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 223 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
224 | 224 | ||
225 | 225 | ||
226 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 226 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
227 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 227 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
228 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 228 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
229 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 229 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
230 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 230 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
231 | 231 | ||
232 | QWidget *aTab; | 232 | QWidget *aTab; |
233 | aTab = new QWidget( tabWidget, "aTab" ); | 233 | aTab = new QWidget( tabWidget, "aTab" ); |
234 | audioView = new QListView( aTab, "Audioview" ); | 234 | audioView = new QListView( aTab, "Audioview" ); |
235 | audioView->setMinimumSize(233,260); | 235 | audioView->setMinimumSize(233,260); |
236 | audioView->addColumn( tr("Title"),140); | 236 | audioView->addColumn( tr("Title"),140); |
237 | audioView->addColumn(tr("Size"), -1); | 237 | audioView->addColumn(tr("Size"), -1); |
238 | audioView->addColumn(tr("Media"),-1); | 238 | audioView->addColumn(tr("Media"),-1); |
239 | audioView->setColumnAlignment(1, Qt::AlignRight); | 239 | audioView->setColumnAlignment(1, Qt::AlignRight); |
240 | audioView->setColumnAlignment(2, Qt::AlignRight); | 240 | audioView->setColumnAlignment(2, Qt::AlignRight); |
241 | audioView->setAllColumnsShowFocus(TRUE); | 241 | audioView->setAllColumnsShowFocus(TRUE); |
242 | 242 | ||
243 | audioView->setMultiSelection( TRUE ); | 243 | audioView->setMultiSelection( TRUE ); |
244 | audioView->setSelectionMode( QListView::Extended); | 244 | audioView->setSelectionMode( QListView::Extended); |
245 | 245 | ||
246 | tabWidget->insertTab(aTab,tr("Audio")); | 246 | tabWidget->insertTab(aTab,tr("Audio")); |
247 | 247 | ||
248 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 248 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
249 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 249 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
251 | 251 | ||
252 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | ||
253 | this,SLOT( playIt( QListViewItem *)) ); | ||
252 | 254 | ||
253 | // audioView | 255 | // audioView |
254 | populateAudioView(); | 256 | populateAudioView(); |
255 | // videowidget | 257 | // videowidget |
256 | 258 | ||
257 | QWidget *vTab; | 259 | QWidget *vTab; |
258 | vTab = new QWidget( tabWidget, "vTab" ); | 260 | vTab = new QWidget( tabWidget, "vTab" ); |
259 | videoView = new QListView( vTab, "Videoview" ); | 261 | videoView = new QListView( vTab, "Videoview" ); |
260 | videoView->setMinimumSize(233,260); | 262 | videoView->setMinimumSize(233,260); |
261 | 263 | ||
262 | videoView->addColumn(tr("Title"),140); | 264 | videoView->addColumn(tr("Title"),140); |
263 | videoView->addColumn(tr("Size"),-1); | 265 | videoView->addColumn(tr("Size"),-1); |
264 | videoView->addColumn(tr("Media"),-1); | 266 | videoView->addColumn(tr("Media"),-1); |
265 | videoView->setColumnAlignment(1, Qt::AlignRight); | 267 | videoView->setColumnAlignment(1, Qt::AlignRight); |
266 | videoView->setColumnAlignment(2, Qt::AlignRight); | 268 | videoView->setColumnAlignment(2, Qt::AlignRight); |
267 | videoView->setAllColumnsShowFocus(TRUE); | 269 | videoView->setAllColumnsShowFocus(TRUE); |
268 | videoView->setMultiSelection( TRUE ); | 270 | videoView->setMultiSelection( TRUE ); |
269 | videoView->setSelectionMode( QListView::Extended); | 271 | videoView->setSelectionMode( QListView::Extended); |
270 | 272 | ||
271 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 273 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
274 | |||
272 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 275 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
273 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 276 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
277 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | ||
278 | this,SLOT( playIt( QListViewItem *)) ); | ||
274 | 279 | ||
275 | tabWidget->insertTab( vTab,tr("Video")); | 280 | tabWidget->insertTab( vTab,tr("Video")); |
276 | populateVideoView(); | 281 | populateVideoView(); |
277 | 282 | ||
278 | //playlists list | 283 | //playlists list |
279 | QWidget *LTab; | 284 | QWidget *LTab; |
280 | LTab = new QWidget( tabWidget, "LTab" ); | 285 | LTab = new QWidget( tabWidget, "LTab" ); |
281 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 286 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
282 | playLists->setMinimumSize(233,260);; | 287 | playLists->setMinimumSize(233,260);; |
283 | tabWidget->insertTab(LTab,tr("Lists")); | 288 | tabWidget->insertTab(LTab,tr("Lists")); |
284 | 289 | ||
285 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 290 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
286 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 291 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
287 | 292 | ||
288 | 293 | ||
289 | // add the library area | 294 | // add the library area |
290 | 295 | ||
291 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 296 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
292 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 297 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
293 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 298 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
294 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 299 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
295 | 300 | ||
296 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 301 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
297 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 302 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
298 | 303 | ||
299 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 304 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
300 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 305 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
301 | 306 | ||
302 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 307 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
303 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 308 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
304 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 309 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
305 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 310 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
@@ -805,303 +810,425 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
805 | break; | 810 | break; |
806 | case 2: | 811 | case 2: |
807 | { | 812 | { |
808 | if( !tbDeletePlaylist->isHidden()) | 813 | if( !tbDeletePlaylist->isHidden()) |
809 | tbDeletePlaylist->hide(); | 814 | tbDeletePlaylist->hide(); |
810 | d->tbRemoveFromList->setEnabled(FALSE); | 815 | d->tbRemoveFromList->setEnabled(FALSE); |
811 | d->tbAddToList->setEnabled(TRUE); | 816 | d->tbAddToList->setEnabled(TRUE); |
812 | } | 817 | } |
813 | break; | 818 | break; |
814 | case 3: | 819 | case 3: |
815 | { | 820 | { |
816 | if( tbDeletePlaylist->isHidden()) | 821 | if( tbDeletePlaylist->isHidden()) |
817 | tbDeletePlaylist->show(); | 822 | tbDeletePlaylist->show(); |
818 | playLists->reread(); | 823 | playLists->reread(); |
819 | } | 824 | } |
820 | break; | 825 | break; |
821 | }; | 826 | }; |
822 | } | 827 | } |
823 | 828 | ||
824 | 829 | ||
825 | 830 | ||
826 | void PlayListWidget::btnPlay(bool b) { | 831 | void PlayListWidget::btnPlay(bool b) { |
827 | 832 | ||
828 | // mediaPlayerState->setPlaying(b); | 833 | // mediaPlayerState->setPlaying(b); |
829 | switch ( tabWidget->currentPageIndex()) { | 834 | switch ( tabWidget->currentPageIndex()) { |
830 | case 0: | 835 | case 0: |
831 | { | 836 | { |
832 | mediaPlayerState->setPlaying(b); | 837 | mediaPlayerState->setPlaying(b); |
833 | } | 838 | } |
834 | break; | 839 | break; |
835 | case 1: | 840 | case 1: |
836 | { | 841 | { |
842 | // if(audioView->selectedItem()) { | ||
837 | addToSelection( audioView->selectedItem() ); | 843 | addToSelection( audioView->selectedItem() ); |
838 | mediaPlayerState->setPlaying(b); | 844 | mediaPlayerState->setPlaying(b); |
839 | d->selectedFiles->removeSelected( ); | 845 | d->selectedFiles->removeSelected( ); |
840 | tabWidget->setCurrentPage(1); | 846 | tabWidget->setCurrentPage(1); |
841 | d->selectedFiles->unSelect(); | 847 | d->selectedFiles->unSelect(); |
842 | insanityBool=FALSE; | 848 | insanityBool=FALSE; |
843 | // audioView->clearSelection(); | 849 | // audioView->clearSelection(); |
850 | // } | ||
844 | } | 851 | } |
845 | break; | 852 | break; |
846 | case 2: | 853 | case 2: |
847 | { | 854 | { |
855 | // if(videoView->selectedItem() ) { | ||
848 | addToSelection( videoView->selectedItem() ); | 856 | addToSelection( videoView->selectedItem() ); |
849 | mediaPlayerState->setPlaying(b); | 857 | mediaPlayerState->setPlaying(b); |
850 | qApp->processEvents(); | 858 | qApp->processEvents(); |
851 | d->selectedFiles->removeSelected( ); | 859 | d->selectedFiles->removeSelected( ); |
852 | tabWidget->setCurrentPage(2); | 860 | tabWidget->setCurrentPage(2); |
853 | d->selectedFiles->unSelect(); | 861 | d->selectedFiles->unSelect(); |
854 | insanityBool=FALSE; | 862 | insanityBool=FALSE; |
855 | // videoView->clearSelection(); | 863 | // videoView->clearSelection(); |
864 | // } | ||
856 | } | 865 | } |
857 | break; | 866 | break; |
858 | }; | 867 | }; |
859 | } | 868 | } |
860 | 869 | ||
861 | void PlayListWidget::deletePlaylist() { | 870 | void PlayListWidget::deletePlaylist() { |
862 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 871 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
863 | (tr("You really want to delete\nthis playlist?")), | 872 | (tr("You really want to delete\nthis playlist?")), |
864 | (tr("Yes")), (tr("No")), 0 )){ | 873 | (tr("Yes")), (tr("No")), 0 )){ |
865 | case 0: // Yes clicked, | 874 | case 0: // Yes clicked, |
866 | QFile().remove(playLists->selected()->file()); | 875 | QFile().remove(playLists->selected()->file()); |
867 | QFile().remove(playLists->selected()->linkFile()); | 876 | QFile().remove(playLists->selected()->linkFile()); |
868 | playLists->reread(); | 877 | playLists->reread(); |
869 | break; | 878 | break; |
870 | case 1: // Cancel | 879 | case 1: // Cancel |
871 | break; | 880 | break; |
872 | }; | 881 | }; |
873 | 882 | ||
874 | } | 883 | } |
875 | 884 | ||
876 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 885 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
877 | { | 886 | { |
878 | switch (mouse) { | 887 | switch (mouse) { |
879 | case 1: | 888 | case 1: |
880 | break; | 889 | break; |
881 | case 2:{ | 890 | case 2:{ |
882 | QPopupMenu m; | 891 | QPopupMenu m; |
883 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 892 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
884 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 893 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
885 | m.insertSeparator(); | 894 | m.insertSeparator(); |
895 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | ||
886 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 896 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
897 | |||
887 | m.exec( QCursor::pos() ); | 898 | m.exec( QCursor::pos() ); |
888 | } | 899 | } |
889 | break; | 900 | break; |
890 | }; | 901 | }; |
891 | } | 902 | } |
892 | 903 | ||
893 | void PlayListWidget::playSelected() | 904 | void PlayListWidget::playSelected() |
894 | { | 905 | { |
895 | btnPlay( TRUE); | 906 | btnPlay( TRUE); |
896 | // d->selectedFiles->unSelect(); | 907 | // d->selectedFiles->unSelect(); |
897 | } | 908 | } |
898 | 909 | ||
899 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 910 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
900 | { | 911 | { |
901 | switch (mouse) { | 912 | switch (mouse) { |
902 | case 1: | 913 | case 1: |
903 | 914 | ||
904 | break; | 915 | break; |
905 | case 2:{ | 916 | case 2:{ |
906 | QPopupMenu m; | 917 | QPopupMenu m; |
907 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 918 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
908 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 919 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
909 | // m.insertSeparator(); | 920 | // m.insertSeparator(); |
921 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | ||
910 | m.exec( QCursor::pos() ); | 922 | m.exec( QCursor::pos() ); |
911 | } | 923 | } |
912 | break; | 924 | break; |
913 | }; | 925 | }; |
914 | 926 | ||
915 | } | 927 | } |
916 | 928 | ||
917 | void PlayListWidget::listDelete() { | 929 | void PlayListWidget::listDelete() { |
918 | Config cfg( "OpiePlayer" ); | 930 | Config cfg( "OpiePlayer" ); |
919 | cfg.setGroup("PlayList"); | 931 | cfg.setGroup("PlayList"); |
920 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 932 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
921 | QString file; | 933 | QString file; |
922 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 934 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
923 | switch ( tabWidget->currentPageIndex()) { | 935 | switch ( tabWidget->currentPageIndex()) { |
924 | case 0: | 936 | case 0: |
925 | break; | 937 | break; |
926 | case 1: | 938 | case 1: |
927 | { | 939 | { |
928 | file = audioView->selectedItem()->text(0); | 940 | file = audioView->selectedItem()->text(0); |
929 | // Global::findDocuments(&files, "audio/*"); | 941 | // Global::findDocuments(&files, "audio/*"); |
930 | // AppLnkSet appFiles; | 942 | // AppLnkSet appFiles; |
931 | QListIterator<DocLnk> dit( files.children() ); | 943 | QListIterator<DocLnk> dit( files.children() ); |
932 | for ( ; dit.current(); ++dit ) { | 944 | for ( ; dit.current(); ++dit ) { |
933 | if( dit.current()->name() == file) { | 945 | if( dit.current()->name() == file) { |
934 | // qDebug(file); | 946 | // qDebug(file); |
935 | LnkProperties prop( dit.current() ); | 947 | LnkProperties prop( dit.current() ); |
936 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 948 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
937 | prop.showMaximized(); | 949 | prop.showMaximized(); |
938 | prop.exec(); | 950 | prop.exec(); |
939 | } | 951 | } |
940 | } | 952 | } |
941 | populateAudioView(); | 953 | populateAudioView(); |
942 | } | 954 | } |
943 | break; | 955 | break; |
944 | case 2: | 956 | case 2: |
945 | { | 957 | { |
946 | // file = videoView->selectedItem()->text(0); | 958 | // file = videoView->selectedItem()->text(0); |
947 | // for ( int i = 0; i < noOfFiles; i++ ) { | 959 | // for ( int i = 0; i < noOfFiles; i++ ) { |
948 | // QString entryName; | 960 | // QString entryName; |
949 | // entryName.sprintf( "File%i", i + 1 ); | 961 | // entryName.sprintf( "File%i", i + 1 ); |
950 | // QString linkFile = cfg.readEntry( entryName ); | 962 | // QString linkFile = cfg.readEntry( entryName ); |
951 | // AppLnk lnk( AppLnk(linkFile)); | 963 | // AppLnk lnk( AppLnk(linkFile)); |
952 | // if( lnk.name() == file ) { | 964 | // if( lnk.name() == file ) { |
953 | // LnkProperties prop( &lnk); | 965 | // LnkProperties prop( &lnk); |
954 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 966 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
955 | // prop.showMaximized(); | 967 | // prop.showMaximized(); |
956 | // prop.exec(); | 968 | // prop.exec(); |
957 | // } | 969 | // } |
958 | // } | 970 | // } |
959 | } | 971 | } |
960 | break; | 972 | break; |
961 | }; | 973 | }; |
962 | } | 974 | } |
963 | 975 | ||
964 | void PlayListWidget::populateAudioView() { | 976 | void PlayListWidget::populateAudioView() { |
965 | // if(files) | 977 | // if(files) |
966 | // files.~DocLnkSet(); | 978 | // files.~DocLnkSet(); |
967 | StorageInfo storageInfo; | 979 | StorageInfo storageInfo; |
968 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 980 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
969 | 981 | ||
970 | Global::findDocuments(&files, "audio/*"); | 982 | Global::findDocuments(&files, "audio/*"); |
971 | QListIterator<DocLnk> dit( files.children() ); | 983 | QListIterator<DocLnk> dit( files.children() ); |
972 | QListIterator<FileSystem> it ( fs ); | 984 | QListIterator<FileSystem> it ( fs ); |
973 | audioView->clear(); | 985 | audioView->clear(); |
974 | QString storage; | 986 | QString storage; |
975 | for ( ; dit.current(); ++dit ) { | 987 | for ( ; dit.current(); ++dit ) { |
976 | for( ; it.current(); ++it ){ | 988 | for( ; it.current(); ++it ){ |
977 | const QString name = (*it)->name(); | 989 | const QString name = (*it)->name(); |
978 | const QString path = (*it)->path(); | 990 | const QString path = (*it)->path(); |
979 | if(dit.current()->file().find(path) != -1 ) storage=name; | 991 | if(dit.current()->file().find(path) != -1 ) storage=name; |
980 | } | 992 | } |
981 | 993 | ||
982 | QListViewItem * newItem; | 994 | QListViewItem * newItem; |
983 | if ( QFile( dit.current()->file()).exists() ) { | 995 | if ( QFile( dit.current()->file()).exists() ) { |
984 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 996 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
985 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 997 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
986 | } | 998 | } |
987 | } | 999 | } |
1000 | |||
988 | } | 1001 | } |
989 | 1002 | ||
990 | void PlayListWidget::populateVideoView() { | 1003 | void PlayListWidget::populateVideoView() { |
991 | StorageInfo storageInfo; | 1004 | StorageInfo storageInfo; |
992 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1005 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
993 | 1006 | ||
994 | Global::findDocuments(&vFiles, "video/*"); | 1007 | Global::findDocuments(&vFiles, "video/*"); |
995 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1008 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
996 | QListIterator<FileSystem> it ( fs ); | 1009 | QListIterator<FileSystem> it ( fs ); |
997 | videoView->clear(); | 1010 | videoView->clear(); |
998 | QString storage; | 1011 | QString storage; |
999 | for ( ; Vdit.current(); ++Vdit ) { | 1012 | for ( ; Vdit.current(); ++Vdit ) { |
1000 | for( ; it.current(); ++it ){ | 1013 | for( ; it.current(); ++it ){ |
1001 | const QString name = (*it)->name(); | 1014 | const QString name = (*it)->name(); |
1002 | const QString path = (*it)->path(); | 1015 | const QString path = (*it)->path(); |
1003 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1016 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1004 | } | 1017 | } |
1005 | 1018 | ||
1006 | QListViewItem * newItem; | 1019 | QListViewItem * newItem; |
1007 | if ( QFile( Vdit.current()->file()).exists() ) { | 1020 | if ( QFile( Vdit.current()->file()).exists() ) { |
1008 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1021 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1009 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1022 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1010 | } | 1023 | } |
1011 | } | 1024 | } |
1012 | } | 1025 | } |
1013 | 1026 | ||
1014 | void PlayListWidget::openFile() { | 1027 | void PlayListWidget::openFile() { |
1015 | QString filename, name; | 1028 | QString filename, name; |
1016 | InputDialog *fileDlg; | 1029 | InputDialog *fileDlg; |
1017 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1030 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1018 | fileDlg->exec(); | 1031 | fileDlg->exec(); |
1019 | if( fileDlg->result() == 1 ) { | 1032 | if( fileDlg->result() == 1 ) { |
1020 | filename = fileDlg->LineEdit1->text(); | 1033 | filename = fileDlg->LineEdit1->text(); |
1021 | //http://205.188.234.129:8030 | 1034 | // http://205.188.234.129:8030 |
1022 | // http://66.28.68.70:8000 | 1035 | // http://66.28.68.70:8000 |
1023 | qDebug(filename); | 1036 | qDebug("Selected filename is "+filename); |
1024 | if(filename.right(3) == "m3u") | 1037 | if(filename.right(3) == "m3u") |
1025 | readm3u( filename); | 1038 | readm3u( filename); |
1026 | else if(filename.right(3) == "pls") | 1039 | else if(filename.right(3) == "pls") |
1027 | readPls( filename); | 1040 | readPls( filename); |
1028 | else { | 1041 | else { |
1029 | DocLnk lnk; | 1042 | DocLnk lnk; |
1030 | 1043 | ||
1031 | lnk.setName(filename); //sets file name | 1044 | lnk.setName(filename); //sets file name |
1032 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1045 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") |
1033 | filename += "/"; | 1046 | filename += "/"; |
1034 | lnk.setFile(filename); //sets File property | 1047 | lnk.setFile(filename); //sets File property |
1035 | 1048 | ||
1036 | lnk.setType("audio/x-mpegurl"); | 1049 | lnk.setType("audio/x-mpegurl"); |
1037 | lnk.setExec("opieplayer"); | 1050 | lnk.setExec("opieplayer"); |
1038 | lnk.setIcon("opieplayer/MPEGPlayer"); | 1051 | lnk.setIcon("opieplayer/MPEGPlayer"); |
1039 | 1052 | ||
1040 | if(!lnk.writeLink()) | 1053 | if(!lnk.writeLink()) |
1041 | qDebug("Writing doclink did not work"); | 1054 | qDebug("Writing doclink did not work"); |
1042 | d->selectedFiles->addToSelection( lnk); | 1055 | d->selectedFiles->addToSelection( lnk); |
1043 | // if(fileDlg2) | 1056 | // if(fileDlg2) |
1044 | // delete fileDlg2; | 1057 | // delete fileDlg2; |
1045 | } | 1058 | } |
1046 | } | 1059 | } |
1047 | if(fileDlg) | 1060 | if(fileDlg) |
1048 | delete fileDlg; | 1061 | delete fileDlg; |
1049 | } | 1062 | } |
1050 | 1063 | ||
1051 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1064 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1052 | { | 1065 | { |
1053 | switch ( e->key() ) { | 1066 | switch ( e->key() ) { |
1054 | ////////////////////////////// Zaurus keys | 1067 | ////////////////////////////// Zaurus keys |
1055 | case Key_F9: //activity | 1068 | case Key_F9: //activity |
1056 | // if(audioUI->isHidden()) | 1069 | // if(audioUI->isHidden()) |
1057 | // audioUI->showMaximized(); | 1070 | // audioUI->showMaximized(); |
1058 | break; | 1071 | break; |
1059 | case Key_F10: //contacts | 1072 | case Key_F10: //contacts |
1060 | // if( videoUI->isHidden()) | 1073 | // if( videoUI->isHidden()) |
1061 | // videoUI->showMaximized(); | 1074 | // videoUI->showMaximized(); |
1062 | break; | 1075 | break; |
1063 | case Key_F11: //menu | 1076 | case Key_F11: //menu |
1064 | break; | 1077 | break; |
1065 | case Key_F12: //home | 1078 | case Key_F12: //home |
1066 | // doBlank(); | 1079 | // doBlank(); |
1067 | break; | 1080 | break; |
1068 | case Key_F13: //mail | 1081 | case Key_F13: //mail |
1069 | // doUnblank(); | 1082 | // doUnblank(); |
1070 | break; | 1083 | break; |
1071 | 1084 | case Key_Q: //add to playlist | |
1085 | qDebug("Add"); | ||
1086 | addSelected(); | ||
1087 | break; | ||
1088 | case Key_R: //remove from playlist | ||
1089 | removeSelected(); | ||
1090 | break; | ||
1091 | // case Key_P: //play | ||
1092 | // qDebug("Play"); | ||
1093 | // playSelected(); | ||
1094 | // break; | ||
1095 | case Key_Space: | ||
1096 | qDebug("Play"); | ||
1097 | playSelected(); | ||
1098 | break; | ||
1099 | case Key_1: | ||
1100 | tabWidget->setCurrentPage(0); | ||
1101 | break; | ||
1102 | case Key_2: | ||
1103 | tabWidget->setCurrentPage(1); | ||
1104 | break; | ||
1105 | case Key_3: | ||
1106 | tabWidget->setCurrentPage(2); | ||
1107 | break; | ||
1108 | case Key_4: | ||
1109 | tabWidget->setCurrentPage(3); | ||
1110 | break; | ||
1072 | } | 1111 | } |
1073 | } | 1112 | } |
1074 | 1113 | ||
1114 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | ||
1115 | { | ||
1116 | // qDebug("Key press"); | ||
1117 | // switch ( e->key() ) { | ||
1118 | // ////////////////////////////// Zaurus keys | ||
1119 | // case Key_A: //add to playlist | ||
1120 | // qDebug("Add"); | ||
1121 | // addSelected(); | ||
1122 | // break; | ||
1123 | // case Key_R: //remove from playlist | ||
1124 | // removeSelected(); | ||
1125 | // break; | ||
1126 | // case Key_P: //play | ||
1127 | // qDebug("Play"); | ||
1128 | // playSelected(); | ||
1129 | // break; | ||
1130 | // case Key_Space: | ||
1131 | // qDebug("Play"); | ||
1132 | // playSelected(); | ||
1133 | // break; | ||
1134 | // } | ||
1135 | } | ||
1136 | |||
1075 | void PlayListWidget::doBlank() { | 1137 | void PlayListWidget::doBlank() { |
1076 | qDebug("do blanking"); | 1138 | qDebug("do blanking"); |
1077 | fd=open("/dev/fb0",O_RDWR); | 1139 | fd=open("/dev/fb0",O_RDWR); |
1078 | if (fd != -1) { | 1140 | if (fd != -1) { |
1079 | ioctl(fd,FBIOBLANK,1); | 1141 | ioctl(fd,FBIOBLANK,1); |
1080 | // close(fd); | 1142 | // close(fd); |
1081 | } | 1143 | } |
1082 | } | 1144 | } |
1083 | 1145 | ||
1084 | void PlayListWidget::doUnblank() { | 1146 | void PlayListWidget::doUnblank() { |
1085 | // this crashes opieplayer with a segfault | 1147 | // this crashes opieplayer with a segfault |
1086 | // int fd; | 1148 | // int fd; |
1087 | // fd=open("/dev/fb0",O_RDWR); | 1149 | // fd=open("/dev/fb0",O_RDWR); |
1088 | qDebug("do unblanking"); | 1150 | qDebug("do unblanking"); |
1089 | if (fd != -1) { | 1151 | if (fd != -1) { |
1090 | ioctl(fd,FBIOBLANK,0); | 1152 | ioctl(fd,FBIOBLANK,0); |
1091 | close(fd); | 1153 | close(fd); |
1092 | } | 1154 | } |
1093 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1155 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1094 | h <<-3;// v[1]; // -3 Force on | 1156 | h <<-3;// v[1]; // -3 Force on |
1095 | } | 1157 | } |
1096 | 1158 | ||
1097 | void PlayListWidget::readm3u(const QString &filename) { | 1159 | void PlayListWidget::readm3u(const QString &filename) { |
1098 | 1160 | ||
1161 | qDebug("playlist filename is "+filename); | ||
1162 | QFile f(filename); | ||
1163 | |||
1164 | if(f.open(IO_ReadOnly)) { | ||
1165 | QTextStream t(&f); | ||
1166 | QString s;//, first, second; | ||
1167 | int i=0; | ||
1168 | while ( !t.atEnd()) { | ||
1169 | // Lview->insertLine(t.readLine(),-1); | ||
1170 | s=t.readLine(); | ||
1171 | if(s.find("#",0,TRUE) == -1) { | ||
1172 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | ||
1173 | if(s.left(2) == "E:" || s.left(2) == "P:") { | ||
1174 | s=s.right(s.length()-2); | ||
1175 | DocLnk lnk( s ); | ||
1176 | QFileInfo f(s); | ||
1177 | QString name = f.baseName(); | ||
1178 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1179 | lnk.setName( name); | ||
1180 | s=s.replace( QRegExp("\\"),"/"); | ||
1181 | lnk.setFile( s); | ||
1182 | // lnk.setIcon(opieplayer/MPEGPlayer); | ||
1183 | qDebug("add "+name); | ||
1184 | d->selectedFiles->addToSelection( lnk); | ||
1185 | } else { // is url | ||
1186 | DocLnk lnk( s); | ||
1187 | QString name = s.right( s.length() - 7); | ||
1188 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1189 | lnk.setName(name); | ||
1190 | lnk.setFile( s+"/"); | ||
1191 | // lnk.setFile( filename); | ||
1192 | // lnk.setComment( s+"/"); | ||
1193 | lnk.setType("audio/x-mpegurl"); | ||
1194 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | ||
1195 | // qDebug("add "+s); | ||
1196 | d->selectedFiles->addToSelection( lnk); | ||
1197 | } | ||
1198 | i++; | ||
1199 | } | ||
1200 | } | ||
1201 | } | ||
1202 | } | ||
1099 | } | 1203 | } |
1100 | 1204 | ||
1101 | void PlayListWidget::writem3u(const QString &filename) { | 1205 | void PlayListWidget::writem3u(const QString &filename) { |
1102 | 1206 | ||
1103 | } | 1207 | } |
1104 | 1208 | ||
1105 | void PlayListWidget::readPls(const QString &filename) { | 1209 | void PlayListWidget::readPls(const QString &filename) { |
1106 | 1210 | ||
1211 | qDebug("playlist filename is "+filename); | ||
1212 | QFile f(filename); | ||
1213 | |||
1214 | if(f.open(IO_ReadOnly)) { | ||
1215 | QTextStream t(&f); | ||
1216 | QString s;//, first, second; | ||
1217 | int i=0; | ||
1218 | while ( !t.atEnd()) { | ||
1219 | // Lview->insertLine(t.readLine(),-1); | ||
1220 | // s=t.readLine(); | ||
1221 | // s=s.right(s.length()-2); | ||
1222 | // DocLnk lnk( s ); | ||
1223 | // QFileInfo f(s); | ||
1224 | // QString name = f.baseName(); | ||
1225 | // // name = name.left(name.length()-4); | ||
1226 | // name = name.right(name.findRev("/",0,TRUE)); | ||
1227 | // lnk.setName( name); | ||
1228 | // lnk.setFile( s); | ||
1229 | // qDebug("add "+name); | ||
1230 | // d->selectedFiles->addToSelection( lnk); | ||
1231 | } | ||
1232 | i++; | ||
1233 | } | ||
1107 | } | 1234 | } |