summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp46
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h4
2 files changed, 50 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index a0bf4db..5e1be2f 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -17,256 +17,259 @@
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#include <qaction.h> 35#include <qaction.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qimage.h> 37#include <qimage.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlist.h> 42#include <qlist.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qmainwindow.h> 44#include <qmainwindow.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qtoolbutton.h> 46#include <qtoolbutton.h>
47#include <qtabwidget.h> 47#include <qtabwidget.h>
48#include <qlistview.h> 48#include <qlistview.h>
49#include <qpoint.h> 49#include <qpoint.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qtextstream.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
82extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86static inline QString fullBaseName ( const QFileInfo &fi ) 86static inline QString fullBaseName ( const QFileInfo &fi )
87{ 87{
88 QString str = fi. fileName ( ); 88 QString str = fi. fileName ( );
89 return str. left ( str. findRev ( '.' )); 89 return str. left ( str. findRev ( '.' ));
90} 90}
91 91
92 92
93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; 93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod";
94// class myFileSelector { 94// class myFileSelector {
95 95
96// }; 96// };
97class PlayListWidgetPrivate { 97class PlayListWidgetPrivate {
98public: 98public:
99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
100 QFrame *playListFrame; 100 QFrame *playListFrame;
101 FileSelector *files; 101 FileSelector *files;
102 PlayListSelection *selectedFiles; 102 PlayListSelection *selectedFiles;
103 bool setDocumentUsed; 103 bool setDocumentUsed;
104 DocLnk *current; 104 DocLnk *current;
105}; 105};
106 106
107 107
108class ToolButton : public QToolButton { 108class ToolButton : public QToolButton {
109public: 109public:
110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
111 : QToolButton( parent, name ) { 111 : QToolButton( parent, name ) {
112 setTextLabel( name ); 112 setTextLabel( name );
113 setPixmap( Resource::loadPixmap( icon ) ); 113 setPixmap( Resource::loadPixmap( icon ) );
114 setAutoRaise( TRUE ); 114 setAutoRaise( TRUE );
115 setFocusPolicy( QWidget::NoFocus ); 115 setFocusPolicy( QWidget::NoFocus );
116 setToggleButton( t ); 116 setToggleButton( t );
117 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 117 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
118 QPEMenuToolFocusManager::manager()->addWidget( this ); 118 QPEMenuToolFocusManager::manager()->addWidget( this );
119 } 119 }
120}; 120};
121 121
122 122
123class MenuItem : public QAction { 123class MenuItem : public QAction {
124public: 124public:
125 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 125 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
126 : QAction( text, QString::null, 0, 0 ) { 126 : QAction( text, QString::null, 0, 0 ) {
127 connect( this, SIGNAL( activated() ), handler, slot ); 127 connect( this, SIGNAL( activated() ), handler, slot );
128 addTo( parent ); 128 addTo( parent );
129 } 129 }
130}; 130};
131 131
132 132
133PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 133PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
134 : QMainWindow( parent, name, fl ) { 134 : QMainWindow( parent, name, fl ) {
135 135
136 d = new PlayListWidgetPrivate; 136 d = new PlayListWidgetPrivate;
137 d->setDocumentUsed = FALSE; 137 d->setDocumentUsed = FALSE;
138 d->current = NULL; 138 d->current = NULL;
139 fromSetDocument = FALSE; 139 fromSetDocument = FALSE;
140 insanityBool=FALSE; 140 insanityBool=FALSE;
141 audioScan = FALSE; 141 audioScan = FALSE;
142 videoScan = FALSE; 142 videoScan = FALSE;
143// menuTimer = new QTimer( this ,"menu timer"), 143// menuTimer = new QTimer( this ,"menu timer"),
144// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 144// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
145 channel = new QCopChannel( "QPE/Application/opieplayer", this );
146 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
147 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) );
145 148
146 setBackgroundMode( PaletteButton ); 149 setBackgroundMode( PaletteButton );
147 150
148 setCaption( tr("OpiePlayer") ); 151 setCaption( tr("OpiePlayer") );
149 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 152 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
150 153
151 setToolBarsMovable( FALSE ); 154 setToolBarsMovable( FALSE );
152 155
153 // Create Toolbar 156 // Create Toolbar
154 QPEToolBar *toolbar = new QPEToolBar( this ); 157 QPEToolBar *toolbar = new QPEToolBar( this );
155 toolbar->setHorizontalStretchable( TRUE ); 158 toolbar->setHorizontalStretchable( TRUE );
156 159
157 // Create Menubar 160 // Create Menubar
158 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 161 QPEMenuBar *menu = new QPEMenuBar( toolbar );
159 menu->setMargin( 0 ); 162 menu->setMargin( 0 );
160 163
161 QPEToolBar *bar = new QPEToolBar( this ); 164 QPEToolBar *bar = new QPEToolBar( this );
162 bar->setLabel( tr( "Play Operations" ) ); 165 bar->setLabel( tr( "Play Operations" ) );
163// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 166// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
164// this , SLOT( addSelected()) ); 167// this , SLOT( addSelected()) );
165 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 168 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
166 tbDeletePlaylist->setFlat(TRUE); 169 tbDeletePlaylist->setFlat(TRUE);
167 tbDeletePlaylist->setFixedSize(20,20); 170 tbDeletePlaylist->setFixedSize(20,20);
168 171
169 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 172 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
170 this , SLOT(addSelected()) ); 173 this , SLOT(addSelected()) );
171 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 174 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
172 this , SLOT(removeSelected()) ); 175 this , SLOT(removeSelected()) );
173// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 176// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
174 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 177 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
175 this , SLOT( btnPlay(bool) ), TRUE ); 178 this , SLOT( btnPlay(bool) ), TRUE );
176 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 179 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
177 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 180 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
178 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 181 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
179 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 182 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
180 tbDeletePlaylist->hide(); 183 tbDeletePlaylist->hide();
181 184
182 QPopupMenu *pmPlayList = new QPopupMenu( this ); 185 QPopupMenu *pmPlayList = new QPopupMenu( this );
183 menu->insertItem( tr( "File" ), pmPlayList ); 186 menu->insertItem( tr( "File" ), pmPlayList );
184 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 187 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
185 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 188 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
186 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 189 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
187 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 190 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
188 pmPlayList->insertSeparator(-1); 191 pmPlayList->insertSeparator(-1);
189 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 192 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
190 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 193 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
191 pmPlayList->insertSeparator(-1); 194 pmPlayList->insertSeparator(-1);
192 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 195 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
193 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 196 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
194 197
195 QPopupMenu *pmView = new QPopupMenu( this ); 198 QPopupMenu *pmView = new QPopupMenu( this );
196 menu->insertItem( tr( "View" ), pmView ); 199 menu->insertItem( tr( "View" ), pmView );
197 200
198 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 201 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
199 fullScreenButton->addTo(pmView); 202 fullScreenButton->addTo(pmView);
200 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 203 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
201 scaleButton->addTo(pmView); 204 scaleButton->addTo(pmView);
202 205
203 206
204 skinsMenu = new QPopupMenu( this ); 207 skinsMenu = new QPopupMenu( this );
205 menu->insertItem( tr( "Skins" ), skinsMenu ); 208 menu->insertItem( tr( "Skins" ), skinsMenu );
206 skinsMenu->isCheckable(); 209 skinsMenu->isCheckable();
207 connect( skinsMenu, SIGNAL( activated( int ) ) , 210 connect( skinsMenu, SIGNAL( activated( int ) ) ,
208 this, SLOT( skinsMenuActivated( int ) ) ); 211 this, SLOT( skinsMenuActivated( int ) ) );
209 populateSkinsMenu(); 212 populateSkinsMenu();
210 213
211 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 214 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
212 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 215 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
213 216
214 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 217 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
215 218
216 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 219 tabWidget = new QTabWidget( hbox6, "tabWidget" );
217// tabWidget->setTabShape(QTabWidget::Triangular); 220// tabWidget->setTabShape(QTabWidget::Triangular);
218 221
219 QWidget *pTab; 222 QWidget *pTab;
220 pTab = new QWidget( tabWidget, "pTab" ); 223 pTab = new QWidget( tabWidget, "pTab" );
221// playlistView = new QListView( pTab, "playlistview" ); 224// playlistView = new QListView( pTab, "playlistview" );
222// playlistView->setMinimumSize(236,260); 225// playlistView->setMinimumSize(236,260);
223 tabWidget->insertTab( pTab,"Playlist"); 226 tabWidget->insertTab( pTab,"Playlist");
224 227
225 228
226 // Add the playlist area 229 // Add the playlist area
227 230
228 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 231 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
229 d->playListFrame = vbox3; 232 d->playListFrame = vbox3;
230 d->playListFrame ->setMinimumSize(235,260); 233 d->playListFrame ->setMinimumSize(235,260);
231 234
232 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 235 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
233 236
234 d->selectedFiles = new PlayListSelection( hbox2); 237 d->selectedFiles = new PlayListSelection( hbox2);
235 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 238 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
236 239
237 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 240 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
238 241
239 242
240 243
241 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 244 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
242 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 245 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
243 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 246 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
244 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 247 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
245 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 248 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
246 249
247 QWidget *aTab; 250 QWidget *aTab;
248 aTab = new QWidget( tabWidget, "aTab" ); 251 aTab = new QWidget( tabWidget, "aTab" );
249 audioView = new QListView( aTab, "Audioview" ); 252 audioView = new QListView( aTab, "Audioview" );
250 audioView->setMinimumSize(233,260); 253 audioView->setMinimumSize(233,260);
251 audioView->addColumn( tr("Title"),140); 254 audioView->addColumn( tr("Title"),140);
252 audioView->addColumn(tr("Size"), -1); 255 audioView->addColumn(tr("Size"), -1);
253 audioView->addColumn(tr("Media"),-1); 256 audioView->addColumn(tr("Media"),-1);
254 audioView->addColumn( tr( "Path" ), 0 ); 257 audioView->addColumn( tr( "Path" ), 0 );
255 258
256 audioView->setColumnAlignment(1, Qt::AlignRight); 259 audioView->setColumnAlignment(1, Qt::AlignRight);
257 audioView->setColumnAlignment(2, Qt::AlignRight); 260 audioView->setColumnAlignment(2, Qt::AlignRight);
258 audioView->setAllColumnsShowFocus(TRUE); 261 audioView->setAllColumnsShowFocus(TRUE);
259 262
260 audioView->setMultiSelection( TRUE ); 263 audioView->setMultiSelection( TRUE );
261 audioView->setSelectionMode( QListView::Extended); 264 audioView->setSelectionMode( QListView::Extended);
262 audioView->setSorting( 3, TRUE ); 265 audioView->setSorting( 3, TRUE );
263 266
264 tabWidget->insertTab(aTab,tr("Audio")); 267 tabWidget->insertTab(aTab,tr("Audio"));
265 268
266 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 269 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
267 270
268// audioView 271// audioView
269// populateAudioView(); 272// populateAudioView();
270// videowidget 273// videowidget
271 274
272 QWidget *vTab; 275 QWidget *vTab;
@@ -1295,128 +1298,171 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1295// doUnblank(); 1298// doUnblank();
1296 break; 1299 break;
1297 case Key_Q: //add to playlist 1300 case Key_Q: //add to playlist
1298 qDebug("Add"); 1301 qDebug("Add");
1299 addSelected(); 1302 addSelected();
1300 break; 1303 break;
1301 case Key_R: //remove from playlist 1304 case Key_R: //remove from playlist
1302 removeSelected(); 1305 removeSelected();
1303 break; 1306 break;
1304// case Key_P: //play 1307// case Key_P: //play
1305// qDebug("Play"); 1308// qDebug("Play");
1306// playSelected(); 1309// playSelected();
1307// break; 1310// break;
1308 case Key_Space: 1311 case Key_Space:
1309 qDebug("Play"); 1312 qDebug("Play");
1310// playSelected(); puh 1313// playSelected(); puh
1311 break; 1314 break;
1312 case Key_1: 1315 case Key_1:
1313 tabWidget->setCurrentPage(0); 1316 tabWidget->setCurrentPage(0);
1314 break; 1317 break;
1315 case Key_2: 1318 case Key_2:
1316 tabWidget->setCurrentPage(1); 1319 tabWidget->setCurrentPage(1);
1317 break; 1320 break;
1318 case Key_3: 1321 case Key_3:
1319 tabWidget->setCurrentPage(2); 1322 tabWidget->setCurrentPage(2);
1320 break; 1323 break;
1321 case Key_4: 1324 case Key_4:
1322 tabWidget->setCurrentPage(3); 1325 tabWidget->setCurrentPage(3);
1323 break; 1326 break;
1324 case Key_Down: 1327 case Key_Down:
1325 if ( !d->selectedFiles->next() ) 1328 if ( !d->selectedFiles->next() )
1326 d->selectedFiles->first(); 1329 d->selectedFiles->first();
1327 1330
1328 break; 1331 break;
1329 case Key_Up: 1332 case Key_Up:
1330 if ( !d->selectedFiles->prev() ) 1333 if ( !d->selectedFiles->prev() )
1331 // d->selectedFiles->last(); 1334 // d->selectedFiles->last();
1332 1335
1333 break; 1336 break;
1334 1337
1335 } 1338 }
1336} 1339}
1337 1340
1338void PlayListWidget::keyPressEvent( QKeyEvent *) 1341void PlayListWidget::keyPressEvent( QKeyEvent *)
1339{ 1342{
1340// qDebug("Key press"); 1343// qDebug("Key press");
1341// switch ( e->key() ) { 1344// switch ( e->key() ) {
1342// ////////////////////////////// Zaurus keys 1345// ////////////////////////////// Zaurus keys
1343// case Key_A: //add to playlist 1346// case Key_A: //add to playlist
1344// qDebug("Add"); 1347// qDebug("Add");
1345// addSelected(); 1348// addSelected();
1346// break; 1349// break;
1347// case Key_R: //remove from playlist 1350// case Key_R: //remove from playlist
1348// removeSelected(); 1351// removeSelected();
1349// break; 1352// break;
1350// case Key_P: //play 1353// case Key_P: //play
1351// qDebug("Play"); 1354// qDebug("Play");
1352// playSelected(); 1355// playSelected();
1353// break; 1356// break;
1354// case Key_Space: 1357// case Key_Space:
1355// qDebug("Play"); 1358// qDebug("Play");
1356// playSelected(); 1359// playSelected();
1357// break; 1360// break;
1358// } 1361// }
1359} 1362}
1360 1363
1361void PlayListWidget::doBlank() { 1364void PlayListWidget::doBlank() {
1362 qDebug("do blanking"); 1365 qDebug("do blanking");
1363 fd=open("/dev/fb0",O_RDWR); 1366 fd=open("/dev/fb0",O_RDWR);
1364 if (fd != -1) { 1367 if (fd != -1) {
1365 ioctl(fd,FBIOBLANK,1); 1368 ioctl(fd,FBIOBLANK,1);
1366// close(fd); 1369// close(fd);
1367 } 1370 }
1368} 1371}
1369 1372
1370void PlayListWidget::doUnblank() { 1373void PlayListWidget::doUnblank() {
1371 // this crashes opieplayer with a segfault 1374 // this crashes opieplayer with a segfault
1372// int fd; 1375// int fd;
1373// fd=open("/dev/fb0",O_RDWR); 1376// fd=open("/dev/fb0",O_RDWR);
1374 qDebug("do unblanking"); 1377 qDebug("do unblanking");
1375 if (fd != -1) { 1378 if (fd != -1) {
1376 ioctl(fd,FBIOBLANK,0); 1379 ioctl(fd,FBIOBLANK,0);
1377 close(fd); 1380 close(fd);
1378 } 1381 }
1379 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1382 QCopEnvelope h("QPE/System", "setBacklight(int)");
1380 h <<-3;// v[1]; // -3 Force on 1383 h <<-3;// v[1]; // -3 Force on
1381} 1384}
1382 1385
1383void PlayListWidget::populateSkinsMenu() { 1386void PlayListWidget::populateSkinsMenu() {
1384 int item = 0; 1387 int item = 0;
1385 defaultSkinIndex = 0; 1388 defaultSkinIndex = 0;
1386 QString skinName; 1389 QString skinName;
1387 Config cfg( "OpiePlayer" ); 1390 Config cfg( "OpiePlayer" );
1388 cfg.setGroup("Options" ); 1391 cfg.setGroup("Options" );
1389 QString skin = cfg.readEntry( "Skin", "default" ); 1392 QString skin = cfg.readEntry( "Skin", "default" );
1390 1393
1391 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1394 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1392 skinsDir.setFilter( QDir::Dirs ); 1395 skinsDir.setFilter( QDir::Dirs );
1393 skinsDir.setSorting(QDir::Name ); 1396 skinsDir.setSorting(QDir::Name );
1394 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1397 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1395 QFileInfoListIterator it( *skinslist ); 1398 QFileInfoListIterator it( *skinslist );
1396 QFileInfo *fi; 1399 QFileInfo *fi;
1397 while ( ( fi = it.current() ) ) { 1400 while ( ( fi = it.current() ) ) {
1398 skinName = fi->fileName(); 1401 skinName = fi->fileName();
1399// qDebug( fi->fileName() ); 1402// qDebug( fi->fileName() );
1400 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1403 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1401 item = skinsMenu->insertItem( fi->fileName() ) ; 1404 item = skinsMenu->insertItem( fi->fileName() ) ;
1402 } 1405 }
1403 if( skinName == "default" ) { 1406 if( skinName == "default" ) {
1404 defaultSkinIndex = item; 1407 defaultSkinIndex = item;
1405 } 1408 }
1406 if( skinName == skin ) { 1409 if( skinName == skin ) {
1407 skinsMenu->setItemChecked( item, TRUE ); 1410 skinsMenu->setItemChecked( item, TRUE );
1408 } 1411 }
1409 ++it; 1412 ++it;
1410 } 1413 }
1411} 1414}
1412 1415
1413void PlayListWidget::skinsMenuActivated( int item ) { 1416void PlayListWidget::skinsMenuActivated( int item ) {
1414 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1417 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1415 skinsMenu->setItemChecked( i, FALSE ); 1418 skinsMenu->setItemChecked( i, FALSE );
1416 } 1419 }
1417 skinsMenu->setItemChecked( item, TRUE ); 1420 skinsMenu->setItemChecked( item, TRUE );
1418 1421
1419 Config cfg( "OpiePlayer" ); 1422 Config cfg( "OpiePlayer" );
1420 cfg.setGroup("Options"); 1423 cfg.setGroup("Options");
1421 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1424 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1422} 1425}
1426
1427void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1428 qDebug("qcop message "+msg );
1429 QDataStream stream ( data, IO_ReadOnly );
1430 if ( msg == "play()" ) { //plays current selection
1431 btnPlay( true);
1432 } else if ( msg == "stop()" ) {
1433 mediaPlayerState->setPlaying( false);
1434 } else if ( msg == "togglePause()" ) {
1435 mediaPlayerState->togglePaused();
1436 } else if ( msg == "next()" ) { //select next in list
1437 mediaPlayerState->setNext();
1438 } else if ( msg == "prev()" ) { //select previous in list
1439 mediaPlayerState->setPrev();
1440 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1441 mediaPlayerState->toggleLooping();
1442 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1443 mediaPlayerState->toggleShuffled();
1444 } else if ( msg == "volUp()" ) { //volume more
1445// emit moreClicked();
1446// emit moreReleased();
1447 } else if ( msg == "volDown()" ) { //volume less
1448// emit lessClicked();
1449// emit lessReleased();
1450 } else if ( msg == "play(QString)" ) { //play this now
1451 QString file;
1452 stream >> file;
1453 setDocument( (const QString &) file);
1454 } else if ( msg == "add(QString)" ) { //add to playlist
1455 QString file;
1456 stream >> file;
1457 QFileInfo fileInfo(file);
1458 DocLnk lnk;
1459 lnk.setName( fileInfo.baseName() ); //sets name
1460 lnk.setFile( file ); //sets file name
1461 addToSelection( lnk );
1462 } else if ( msg == "rem(QString)" ) { //remove from playlist
1463 QString file;
1464 stream >> file;
1465
1466 }
1467
1468}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 1118b76..e66bcb9 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,133 +1,137 @@
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#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qtabwidget.h> 25#include <qtabwidget.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29#include <qpe/qcopenvelope_qws.h>
30
29#include "om3u.h" 31#include "om3u.h"
30/* #include <qtimer.h> */ 32/* #include <qtimer.h> */
31 33
32 34
33class PlayListWidgetPrivate; 35class PlayListWidgetPrivate;
34class Config; 36class Config;
35class QListViewItem; 37class QListViewItem;
36class QListView; 38class QListView;
37class QPoint; 39class QPoint;
38class QAction; 40class QAction;
39class QLabel; 41class QLabel;
40class QPopupMenu; 42class QPopupMenu;
41 43
42class PlayListWidget : public QMainWindow { 44class PlayListWidget : public QMainWindow {
43 Q_OBJECT 45 Q_OBJECT
44public: 46public:
45 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 47 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
46 ~PlayListWidget(); 48 ~PlayListWidget();
47 QTabWidget * tabWidget; 49 QTabWidget * tabWidget;
48 QAction *fullScreenButton, *scaleButton; 50 QAction *fullScreenButton, *scaleButton;
49 DocLnkSet files; 51 DocLnkSet files;
50 DocLnkSet vFiles; 52 DocLnkSet vFiles;
51 QListView *audioView, *videoView, *playlistView; 53 QListView *audioView, *videoView, *playlistView;
52 QLabel *libString; 54 QLabel *libString;
53 bool fromSetDocument; 55 bool fromSetDocument;
54 bool insanityBool; 56 bool insanityBool;
55 QString setDocFileRef, currentPlayList; 57 QString setDocFileRef, currentPlayList;
56 // retrieve the current playlist entry (media file link) 58 // retrieve the current playlist entry (media file link)
57 const DocLnk *current(); 59 const DocLnk *current();
58 void useSelectedDocument(); 60 void useSelectedDocument();
59/* QTimer * menuTimer; */ 61/* QTimer * menuTimer; */
60 FileSelector* playLists; 62 FileSelector* playLists;
61 QPushButton *tbDeletePlaylist; 63 QPushButton *tbDeletePlaylist;
62 int fd, selected; 64 int fd, selected;
63public slots: 65public slots:
64 bool first(); 66 bool first();
65 bool last(); 67 bool last();
66 bool next(); 68 bool next();
67 bool prev(); 69 bool prev();
68/* void setFullScreen(); */ 70/* void setFullScreen(); */
69/* void setScaled(); */ 71/* void setScaled(); */
70protected: 72protected:
73 QCopChannel * channel;
71 QPopupMenu *skinsMenu; 74 QPopupMenu *skinsMenu;
72/* void contentsMousePressEvent( QMouseEvent * e ); */ 75/* void contentsMousePressEvent( QMouseEvent * e ); */
73/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 76/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
74void keyReleaseEvent( QKeyEvent *e); 77void keyReleaseEvent( QKeyEvent *e);
75void keyPressEvent( QKeyEvent *e); 78void keyPressEvent( QKeyEvent *e);
76private: 79private:
77 int defaultSkinIndex; 80 int defaultSkinIndex;
78 bool audioScan, videoScan; 81 bool audioScan, videoScan;
79 void doBlank(); 82 void doBlank();
80 void doUnblank(); 83 void doUnblank();
81 void readm3u(const QString &); 84 void readm3u(const QString &);
82 void readPls(const QString &); 85 void readPls(const QString &);
83 86
84 87
85 void initializeStates(); 88 void initializeStates();
86 void readConfig( Config& cfg ); 89 void readConfig( Config& cfg );
87 void writeConfig( Config& cfg ) const; 90 void writeConfig( Config& cfg ) const;
88 PlayListWidgetPrivate *d; // Private implementation data 91 PlayListWidgetPrivate *d; // Private implementation data
89 void populateAudioView(); 92 void populateAudioView();
90 void populateVideoView(); 93 void populateVideoView();
91private slots: 94private slots:
92 95
96 void qcopReceive(const QCString&, const QByteArray&);
93 void populateSkinsMenu(); 97 void populateSkinsMenu();
94 void skinsMenuActivated(int); 98 void skinsMenuActivated(int);
95 void writem3u(); 99 void writem3u();
96 void writeCurrentM3u(); 100 void writeCurrentM3u();
97 void scanForAudio(); 101 void scanForAudio();
98 void scanForVideo(); 102 void scanForVideo();
99 void openFile(); 103 void openFile();
100 void setDocument( const QString& fileref ); 104 void setDocument( const QString& fileref );
101 void addToSelection( const DocLnk& ); // Add a media file to the playlist 105 void addToSelection( const DocLnk& ); // Add a media file to the playlist
102 void addToSelection( QListViewItem* ); // Add a media file to the playlist 106 void addToSelection( QListViewItem* ); // Add a media file to the playlist
103 void setActiveWindow(); // need to handle this to show the right view 107 void setActiveWindow(); // need to handle this to show the right view
104 void setPlaylist( bool ); // Show/Hide the playlist 108 void setPlaylist( bool ); // Show/Hide the playlist
105 void setView( char ); 109 void setView( char );
106 void clearList(); 110 void clearList();
107 void addAllToList(); 111 void addAllToList();
108 void addAllMusicToList(); 112 void addAllMusicToList();
109 void addAllVideoToList(); 113 void addAllVideoToList();
110 void saveList(); // Save the playlist 114 void saveList(); // Save the playlist
111 void loadList( const DocLnk &); // Load a playlist 115 void loadList( const DocLnk &); // Load a playlist
112 void playIt( QListViewItem *); 116 void playIt( QListViewItem *);
113 117
114 void btnPlay(bool); 118 void btnPlay(bool);
115 void deletePlaylist(); 119 void deletePlaylist();
116 void addSelected(); 120 void addSelected();
117 void removeSelected(); 121 void removeSelected();
118 void tabChanged(QWidget*); 122 void tabChanged(QWidget*);
119 void viewPressed( int, QListViewItem *, const QPoint&, int); 123 void viewPressed( int, QListViewItem *, const QPoint&, int);
120 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 124 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
121 void playSelected(); 125 void playSelected();
122 void listDelete(); 126 void listDelete();
123 127
124protected slots: 128protected slots:
125/* void cancelMenuTimer(); */ 129/* void cancelMenuTimer(); */
126/* void showFileMenu(); */ 130/* void showFileMenu(); */
127 131
128 132
129}; 133};
130 134
131 135
132#endif // PLAY_LIST_WIDGET_H 136#endif // PLAY_LIST_WIDGET_H
133 137