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