author | llornkcor <llornkcor> | 2003-04-26 02:02:26 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-04-26 02:02:26 (UTC) |
commit | 908a099ba19192dcb341959125efce6cf0df20f1 (patch) (unidiff) | |
tree | ad59a689d097b1a4ffccb3ca849e936c48a9cad0 | |
parent | 4a5b422ef2410d89aa1c3624da2ead151d815ecd (diff) | |
download | opie-908a099ba19192dcb341959125efce6cf0df20f1.zip opie-908a099ba19192dcb341959125efce6cf0df20f1.tar.gz opie-908a099ba19192dcb341959125efce6cf0df20f1.tar.bz2 |
change playlist file access mode when writing
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 795feaf..c6de5e6 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1143,257 +1143,257 @@ void PlayListWidget::readm3u( const QString &filename ) { | |||
1143 | if( s.right(1) != "/") | 1143 | if( s.right(1) != "/") |
1144 | lnk.setFile( s+"/"); //if url with no extension | 1144 | lnk.setFile( s+"/"); //if url with no extension |
1145 | else | 1145 | else |
1146 | lnk.setFile( s ); //sets file name | 1146 | lnk.setFile( s ); //sets file name |
1147 | 1147 | ||
1148 | } else { | 1148 | } else { |
1149 | // if( QFileInfo( s ).exists() ) { | 1149 | // if( QFileInfo( s ).exists() ) { |
1150 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1150 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1151 | // if(s.right(4) == '.') {//if regular file | 1151 | // if(s.right(4) == '.') {//if regular file |
1152 | if(s.left(1) != "/") { | 1152 | if(s.left(1) != "/") { |
1153 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1153 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1154 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1154 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1155 | lnk.setIcon("SoundPlayer"); | 1155 | lnk.setIcon("SoundPlayer"); |
1156 | } else { | 1156 | } else { |
1157 | // qDebug("set link2 "+s); | 1157 | // qDebug("set link2 "+s); |
1158 | lnk.setFile( s); | 1158 | lnk.setFile( s); |
1159 | lnk.setIcon("SoundPlayer"); | 1159 | lnk.setIcon("SoundPlayer"); |
1160 | } | 1160 | } |
1161 | } | 1161 | } |
1162 | d->selectedFiles->addToSelection( lnk ); | 1162 | d->selectedFiles->addToSelection( lnk ); |
1163 | } | 1163 | } |
1164 | Config config( "OpiePlayer" ); | 1164 | Config config( "OpiePlayer" ); |
1165 | config.setGroup( "PlayList" ); | 1165 | config.setGroup( "PlayList" ); |
1166 | 1166 | ||
1167 | config.writeEntry("CurrentPlaylist",filename); | 1167 | config.writeEntry("CurrentPlaylist",filename); |
1168 | config.write(); | 1168 | config.write(); |
1169 | currentPlayList=filename; | 1169 | currentPlayList=filename; |
1170 | 1170 | ||
1171 | // m3uList->write(); | 1171 | // m3uList->write(); |
1172 | m3uList->close(); | 1172 | m3uList->close(); |
1173 | if(m3uList) delete m3uList; | 1173 | if(m3uList) delete m3uList; |
1174 | 1174 | ||
1175 | d->selectedFiles->setSelectedItem( s); | 1175 | d->selectedFiles->setSelectedItem( s); |
1176 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1176 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1177 | 1177 | ||
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | /* | 1180 | /* |
1181 | reads pls and adds files/urls to playlist */ | 1181 | reads pls and adds files/urls to playlist */ |
1182 | void PlayListWidget::readPls( const QString &filename ) { | 1182 | void PlayListWidget::readPls( const QString &filename ) { |
1183 | 1183 | ||
1184 | qDebug( "pls filename is " + filename ); | 1184 | qDebug( "pls filename is " + filename ); |
1185 | Om3u *m3uList; | 1185 | Om3u *m3uList; |
1186 | QString s, name; | 1186 | QString s, name; |
1187 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1187 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1188 | m3uList->readPls(); | 1188 | m3uList->readPls(); |
1189 | 1189 | ||
1190 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1190 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1191 | s = *it; | 1191 | s = *it; |
1192 | // s.replace( QRegExp( "%20" )," " ); | 1192 | // s.replace( QRegExp( "%20" )," " ); |
1193 | DocLnk lnk( s ); | 1193 | DocLnk lnk( s ); |
1194 | QFileInfo f( s ); | 1194 | QFileInfo f( s ); |
1195 | QString name = fullBaseName ( f); | 1195 | QString name = fullBaseName ( f); |
1196 | 1196 | ||
1197 | if( name.left( 4 ) == "http" ) { | 1197 | if( name.left( 4 ) == "http" ) { |
1198 | name = s.right( s.length() - 7); | 1198 | name = s.right( s.length() - 7); |
1199 | } else { | 1199 | } else { |
1200 | name = s; | 1200 | name = s; |
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1203 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1204 | 1204 | ||
1205 | lnk.setName( name ); | 1205 | lnk.setName( name ); |
1206 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1206 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1207 | lnk.setFile( s ); | 1207 | lnk.setFile( s ); |
1208 | } else { //if its a url | 1208 | } else { //if its a url |
1209 | if( name.right( 1 ).find( '/' ) == -1) { | 1209 | if( name.right( 1 ).find( '/' ) == -1) { |
1210 | s += "/"; | 1210 | s += "/"; |
1211 | } | 1211 | } |
1212 | lnk.setFile( s ); | 1212 | lnk.setFile( s ); |
1213 | } | 1213 | } |
1214 | lnk.setType( "audio/x-mpegurl" ); | 1214 | lnk.setType( "audio/x-mpegurl" ); |
1215 | 1215 | ||
1216 | lnk.writeLink(); | 1216 | lnk.writeLink(); |
1217 | d->selectedFiles->addToSelection( lnk ); | 1217 | d->selectedFiles->addToSelection( lnk ); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | m3uList->close(); | 1220 | m3uList->close(); |
1221 | if(m3uList) delete m3uList; | 1221 | if(m3uList) delete m3uList; |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | /* | 1224 | /* |
1225 | writes current playlist to current m3u file */ | 1225 | writes current playlist to current m3u file */ |
1226 | void PlayListWidget::writeCurrentM3u() { | 1226 | void PlayListWidget::writeCurrentM3u() { |
1227 | qDebug("writing to current m3u"); | 1227 | qDebug("writing to current m3u"); |
1228 | Config cfg( "OpiePlayer" ); | 1228 | Config cfg( "OpiePlayer" ); |
1229 | cfg.setGroup("PlayList"); | 1229 | cfg.setGroup("PlayList"); |
1230 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 1230 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
1231 | Om3u *m3uList; | 1231 | Om3u *m3uList; |
1232 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 1232 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
1233 | 1233 | ||
1234 | if( d->selectedFiles->first()) { | 1234 | if( d->selectedFiles->first()) { |
1235 | do { | 1235 | do { |
1236 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1236 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1237 | m3uList->add( d->selectedFiles->current()->file() ); | 1237 | m3uList->add( d->selectedFiles->current()->file() ); |
1238 | } | 1238 | } |
1239 | while ( d->selectedFiles->next() ); | 1239 | while ( d->selectedFiles->next() ); |
1240 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1240 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1241 | m3uList->write(); | 1241 | m3uList->write(); |
1242 | m3uList->close(); | 1242 | m3uList->close(); |
1243 | 1243 | ||
1244 | if(m3uList) delete m3uList; | 1244 | if(m3uList) delete m3uList; |
1245 | } | 1245 | } |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | /* | 1248 | /* |
1249 | writes current playlist to m3u file */ | 1249 | writes current playlist to m3u file */ |
1250 | void PlayListWidget::writem3u() { | 1250 | void PlayListWidget::writem3u() { |
1251 | InputDialog *fileDlg; | 1251 | InputDialog *fileDlg; |
1252 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1252 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1253 | fileDlg->exec(); | 1253 | fileDlg->exec(); |
1254 | QString name, filename, list; | 1254 | QString name, filename, list; |
1255 | Om3u *m3uList; | 1255 | Om3u *m3uList; |
1256 | 1256 | ||
1257 | if( fileDlg->result() == 1 ) { | 1257 | if( fileDlg->result() == 1 ) { |
1258 | name = fileDlg->text(); | 1258 | name = fileDlg->text(); |
1259 | // qDebug( filename ); | 1259 | // qDebug( filename ); |
1260 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1260 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1261 | filename = name; | 1261 | filename = name; |
1262 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1262 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1263 | } | 1263 | } |
1264 | else //otherwise dump it somewhere noticable | 1264 | else //otherwise dump it somewhere noticable |
1265 | filename = QPEApplication::documentDir() + "/" + name; | 1265 | filename = QPEApplication::documentDir() + "/" + name; |
1266 | 1266 | ||
1267 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1267 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1268 | filename += ".m3u"; | 1268 | filename += ".m3u"; |
1269 | 1269 | ||
1270 | if( d->selectedFiles->first()) { | 1270 | if( d->selectedFiles->first()) { |
1271 | m3uList = new Om3u(filename, IO_ReadWrite); | 1271 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1272 | 1272 | ||
1273 | do { | 1273 | do { |
1274 | m3uList->add( d->selectedFiles->current()->file()); | 1274 | m3uList->add( d->selectedFiles->current()->file()); |
1275 | } | 1275 | } |
1276 | while ( d->selectedFiles->next() ); | 1276 | while ( d->selectedFiles->next() ); |
1277 | // qDebug( list ); | 1277 | // qDebug( list ); |
1278 | m3uList->write(); | 1278 | m3uList->write(); |
1279 | m3uList->close(); | 1279 | m3uList->close(); |
1280 | if(m3uList) delete m3uList; | 1280 | if(m3uList) delete m3uList; |
1281 | 1281 | ||
1282 | if(fileDlg) delete fileDlg; | 1282 | if(fileDlg) delete fileDlg; |
1283 | 1283 | ||
1284 | DocLnk lnk; | 1284 | DocLnk lnk; |
1285 | lnk.setFile( filename); | 1285 | lnk.setFile( filename); |
1286 | lnk.setIcon("opieplayer2/playlist2"); | 1286 | lnk.setIcon("opieplayer2/playlist2"); |
1287 | lnk.setName( name); //sets file name | 1287 | lnk.setName( name); //sets file name |
1288 | 1288 | ||
1289 | // qDebug(filename); | 1289 | // qDebug(filename); |
1290 | Config config( "OpiePlayer" ); | 1290 | Config config( "OpiePlayer" ); |
1291 | config.setGroup( "PlayList" ); | 1291 | config.setGroup( "PlayList" ); |
1292 | 1292 | ||
1293 | config.writeEntry("CurrentPlaylist",filename); | 1293 | config.writeEntry("CurrentPlaylist",filename); |
1294 | currentPlayList=filename; | 1294 | currentPlayList=filename; |
1295 | 1295 | ||
1296 | if(!lnk.writeLink()) { | 1296 | if(!lnk.writeLink()) { |
1297 | qDebug("Writing doclink did not work"); | 1297 | qDebug("Writing doclink did not work"); |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | setCaption(tr("OpiePlayer: ") + name); | 1300 | setCaption(tr("OpiePlayer: ") + name); |
1301 | } | 1301 | } |
1302 | } | 1302 | } |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | 1305 | ||
1306 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1306 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1307 | { | 1307 | { |
1308 | switch ( e->key() ) { | 1308 | switch ( e->key() ) { |
1309 | ////////////////////////////// Zaurus keys | 1309 | ////////////////////////////// Zaurus keys |
1310 | case Key_F9: //activity | 1310 | case Key_F9: //activity |
1311 | // if(audioUI->isHidden()) | 1311 | // if(audioUI->isHidden()) |
1312 | // audioUI->showMaximized(); | 1312 | // audioUI->showMaximized(); |
1313 | break; | 1313 | break; |
1314 | case Key_F10: //contacts | 1314 | case Key_F10: //contacts |
1315 | // if( videoUI->isHidden()) | 1315 | // if( videoUI->isHidden()) |
1316 | // videoUI->showMaximized(); | 1316 | // videoUI->showMaximized(); |
1317 | break; | 1317 | break; |
1318 | case Key_F11: //menu | 1318 | case Key_F11: //menu |
1319 | break; | 1319 | break; |
1320 | case Key_F12: //home | 1320 | case Key_F12: //home |
1321 | // doBlank(); | 1321 | // doBlank(); |
1322 | break; | 1322 | break; |
1323 | case Key_F13: //mail | 1323 | case Key_F13: //mail |
1324 | // doUnblank(); | 1324 | // doUnblank(); |
1325 | break; | 1325 | break; |
1326 | case Key_Q: //add to playlist | 1326 | case Key_Q: //add to playlist |
1327 | qDebug("Add"); | 1327 | qDebug("Add"); |
1328 | addSelected(); | 1328 | addSelected(); |
1329 | break; | 1329 | break; |
1330 | case Key_R: //remove from playlist | 1330 | case Key_R: //remove from playlist |
1331 | removeSelected(); | 1331 | removeSelected(); |
1332 | break; | 1332 | break; |
1333 | // case Key_P: //play | 1333 | // case Key_P: //play |
1334 | // qDebug("Play"); | 1334 | // qDebug("Play"); |
1335 | // playSelected(); | 1335 | // playSelected(); |
1336 | // break; | 1336 | // break; |
1337 | case Key_Space: | 1337 | case Key_Space: |
1338 | qDebug("Play"); | 1338 | qDebug("Play"); |
1339 | // playSelected(); puh | 1339 | // playSelected(); puh |
1340 | break; | 1340 | break; |
1341 | case Key_1: | 1341 | case Key_1: |
1342 | tabWidget->setCurrentPage(0); | 1342 | tabWidget->setCurrentPage(0); |
1343 | break; | 1343 | break; |
1344 | case Key_2: | 1344 | case Key_2: |
1345 | tabWidget->setCurrentPage(1); | 1345 | tabWidget->setCurrentPage(1); |
1346 | break; | 1346 | break; |
1347 | case Key_3: | 1347 | case Key_3: |
1348 | tabWidget->setCurrentPage(2); | 1348 | tabWidget->setCurrentPage(2); |
1349 | break; | 1349 | break; |
1350 | case Key_4: | 1350 | case Key_4: |
1351 | tabWidget->setCurrentPage(3); | 1351 | tabWidget->setCurrentPage(3); |
1352 | break; | 1352 | break; |
1353 | case Key_Down: | 1353 | case Key_Down: |
1354 | if ( !d->selectedFiles->next() ) | 1354 | if ( !d->selectedFiles->next() ) |
1355 | d->selectedFiles->first(); | 1355 | d->selectedFiles->first(); |
1356 | 1356 | ||
1357 | break; | 1357 | break; |
1358 | case Key_Up: | 1358 | case Key_Up: |
1359 | if ( !d->selectedFiles->prev() ) | 1359 | if ( !d->selectedFiles->prev() ) |
1360 | // d->selectedFiles->last(); | 1360 | // d->selectedFiles->last(); |
1361 | 1361 | ||
1362 | break; | 1362 | break; |
1363 | 1363 | ||
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1367 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1368 | { | 1368 | { |
1369 | // qDebug("Key press"); | 1369 | // qDebug("Key press"); |
1370 | // switch ( e->key() ) { | 1370 | // switch ( e->key() ) { |
1371 | // ////////////////////////////// Zaurus keys | 1371 | // ////////////////////////////// Zaurus keys |
1372 | // case Key_A: //add to playlist | 1372 | // case Key_A: //add to playlist |
1373 | // qDebug("Add"); | 1373 | // qDebug("Add"); |
1374 | // addSelected(); | 1374 | // addSelected(); |
1375 | // break; | 1375 | // break; |
1376 | // case Key_R: //remove from playlist | 1376 | // case Key_R: //remove from playlist |
1377 | // removeSelected(); | 1377 | // removeSelected(); |
1378 | // break; | 1378 | // break; |
1379 | // case Key_P: //play | 1379 | // case Key_P: //play |
1380 | // qDebug("Play"); | 1380 | // qDebug("Play"); |
1381 | // playSelected(); | 1381 | // playSelected(); |
1382 | // break; | 1382 | // break; |
1383 | // case Key_Space: | 1383 | // case Key_Space: |
1384 | // qDebug("Play"); | 1384 | // qDebug("Play"); |
1385 | // playSelected(); | 1385 | // playSelected(); |
1386 | // break; | 1386 | // break; |
1387 | // } | 1387 | // } |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | void PlayListWidget::doBlank() { | 1390 | void PlayListWidget::doBlank() { |
1391 | qDebug("do blanking"); | 1391 | qDebug("do blanking"); |
1392 | fd=open("/dev/fb0",O_RDWR); | 1392 | fd=open("/dev/fb0",O_RDWR); |
1393 | if (fd != -1) { | 1393 | if (fd != -1) { |
1394 | ioctl(fd,FBIOBLANK,1); | 1394 | ioctl(fd,FBIOBLANK,1); |
1395 | // close(fd); | 1395 | // close(fd); |
1396 | } | 1396 | } |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | void PlayListWidget::doUnblank() { | 1399 | void PlayListWidget::doUnblank() { |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index e9615f1..580460e 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -616,257 +616,257 @@ void PlayListWidget::openFile() { | |||
616 | QString m3uFile, m3uFilePath; | 616 | QString m3uFile, m3uFilePath; |
617 | if(filename.find(":",8,TRUE) != -1) { //found a port | 617 | if(filename.find(":",8,TRUE) != -1) { //found a port |
618 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 618 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
619 | m3uFile = m3uFile.right( 7); | 619 | m3uFile = m3uFile.right( 7); |
620 | } else if(filename.left(4) == "http"){ | 620 | } else if(filename.left(4) == "http"){ |
621 | m3uFile=filename; | 621 | m3uFile=filename; |
622 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 622 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
623 | } else{ | 623 | } else{ |
624 | m3uFile=filename; | 624 | m3uFile=filename; |
625 | } | 625 | } |
626 | 626 | ||
627 | lnk.setName( filename ); //sets name | 627 | lnk.setName( filename ); //sets name |
628 | lnk.setFile( filename ); //sets file name | 628 | lnk.setFile( filename ); //sets file name |
629 | 629 | ||
630 | // lnk.setIcon("opieplayer2/musicfile"); | 630 | // lnk.setIcon("opieplayer2/musicfile"); |
631 | 631 | ||
632 | d->selectedFiles->addToSelection( lnk ); | 632 | d->selectedFiles->addToSelection( lnk ); |
633 | writeCurrentM3u(); | 633 | writeCurrentM3u(); |
634 | d->selectedFiles->setSelectedItem( lnk.name()); | 634 | d->selectedFiles->setSelectedItem( lnk.name()); |
635 | } | 635 | } |
636 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 636 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
637 | readListFromFile( filename ); | 637 | readListFromFile( filename ); |
638 | } else { | 638 | } else { |
639 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 639 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
640 | lnk.setFile( filename ); //sets file name | 640 | lnk.setFile( filename ); //sets file name |
641 | d->selectedFiles->addToSelection( lnk); | 641 | d->selectedFiles->addToSelection( lnk); |
642 | writeCurrentM3u(); | 642 | writeCurrentM3u(); |
643 | d->selectedFiles->setSelectedItem( lnk.name()); | 643 | d->selectedFiles->setSelectedItem( lnk.name()); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | 646 | ||
647 | 647 | ||
648 | delete fileDlg; | 648 | delete fileDlg; |
649 | } | 649 | } |
650 | 650 | ||
651 | void PlayListWidget::readListFromFile( const QString &filename ) { | 651 | void PlayListWidget::readListFromFile( const QString &filename ) { |
652 | qDebug( "read list filename " + filename ); | 652 | qDebug( "read list filename " + filename ); |
653 | QFileInfo fi(filename); | 653 | QFileInfo fi(filename); |
654 | Om3u *m3uList; | 654 | Om3u *m3uList; |
655 | QString s, name; | 655 | QString s, name; |
656 | m3uList = new Om3u( filename, IO_ReadOnly ); | 656 | m3uList = new Om3u( filename, IO_ReadOnly ); |
657 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 657 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
658 | m3uList->readM3u(); | 658 | m3uList->readM3u(); |
659 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 659 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
660 | m3uList->readPls(); | 660 | m3uList->readPls(); |
661 | 661 | ||
662 | DocLnk lnk; | 662 | DocLnk lnk; |
663 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 663 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
664 | s = *it; | 664 | s = *it; |
665 | // qDebug(s); | 665 | // qDebug(s); |
666 | if(s.left(4)=="http") { | 666 | if(s.left(4)=="http") { |
667 | lnk.setName( s ); //sets file name | 667 | lnk.setName( s ); //sets file name |
668 | lnk.setIcon("opieplayer2/musicfile"); | 668 | lnk.setIcon("opieplayer2/musicfile"); |
669 | lnk.setFile( s ); //sets file name | 669 | lnk.setFile( s ); //sets file name |
670 | 670 | ||
671 | } else { //is file | 671 | } else { //is file |
672 | lnk.setName( QFileInfo(s).baseName()); | 672 | lnk.setName( QFileInfo(s).baseName()); |
673 | if(s.left(1) != "/") { | 673 | if(s.left(1) != "/") { |
674 | 674 | ||
675 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 675 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
676 | } else { | 676 | } else { |
677 | lnk.setFile( s); | 677 | lnk.setFile( s); |
678 | } | 678 | } |
679 | } | 679 | } |
680 | d->selectedFiles->addToSelection( lnk ); | 680 | d->selectedFiles->addToSelection( lnk ); |
681 | } | 681 | } |
682 | Config config( "OpiePlayer" ); | 682 | Config config( "OpiePlayer" ); |
683 | config.setGroup( "PlayList" ); | 683 | config.setGroup( "PlayList" ); |
684 | 684 | ||
685 | config.writeEntry("CurrentPlaylist",filename); | 685 | config.writeEntry("CurrentPlaylist",filename); |
686 | config.write(); | 686 | config.write(); |
687 | currentPlayList=filename; | 687 | currentPlayList=filename; |
688 | 688 | ||
689 | m3uList->close(); | 689 | m3uList->close(); |
690 | delete m3uList; | 690 | delete m3uList; |
691 | 691 | ||
692 | d->selectedFiles->setSelectedItem( s); | 692 | d->selectedFiles->setSelectedItem( s); |
693 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 693 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
694 | 694 | ||
695 | } | 695 | } |
696 | 696 | ||
697 | // writes current playlist to current m3u file */ | 697 | // writes current playlist to current m3u file */ |
698 | void PlayListWidget::writeCurrentM3u() { | 698 | void PlayListWidget::writeCurrentM3u() { |
699 | qDebug("writing to current m3u"); | 699 | qDebug("writing to current m3u"); |
700 | Config cfg( "OpiePlayer" ); | 700 | Config cfg( "OpiePlayer" ); |
701 | cfg.setGroup("PlayList"); | 701 | cfg.setGroup("PlayList"); |
702 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 702 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
703 | 703 | ||
704 | Om3u *m3uList; | 704 | Om3u *m3uList; |
705 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 705 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
706 | if( d->selectedFiles->first()) { | 706 | if( d->selectedFiles->first()) { |
707 | 707 | ||
708 | do { | 708 | do { |
709 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 709 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
710 | m3uList->add( d->selectedFiles->current()->file() ); | 710 | m3uList->add( d->selectedFiles->current()->file() ); |
711 | } | 711 | } |
712 | while ( d->selectedFiles->next() ); | 712 | while ( d->selectedFiles->next() ); |
713 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 713 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
714 | m3uList->write(); | 714 | m3uList->write(); |
715 | m3uList->close(); | 715 | m3uList->close(); |
716 | } | 716 | } |
717 | delete m3uList; | 717 | delete m3uList; |
718 | 718 | ||
719 | } | 719 | } |
720 | 720 | ||
721 | /* | 721 | /* |
722 | writes current playlist to m3u file */ | 722 | writes current playlist to m3u file */ |
723 | void PlayListWidget::writem3u() { | 723 | void PlayListWidget::writem3u() { |
724 | InputDialog *fileDlg; | 724 | InputDialog *fileDlg; |
725 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 725 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
726 | fileDlg->exec(); | 726 | fileDlg->exec(); |
727 | QString name, filename, list; | 727 | QString name, filename, list; |
728 | Om3u *m3uList; | 728 | Om3u *m3uList; |
729 | 729 | ||
730 | if( fileDlg->result() == 1 ) { | 730 | if( fileDlg->result() == 1 ) { |
731 | name = fileDlg->text(); | 731 | name = fileDlg->text(); |
732 | // qDebug( filename ); | 732 | // qDebug( filename ); |
733 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 733 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
734 | filename = name; | 734 | filename = name; |
735 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 735 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
736 | } | 736 | } |
737 | else //otherwise dump it somewhere noticable | 737 | else //otherwise dump it somewhere noticable |
738 | filename = QPEApplication::documentDir() + "/" + name; | 738 | filename = QPEApplication::documentDir() + "/" + name; |
739 | 739 | ||
740 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 740 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
741 | filename += ".m3u"; | 741 | filename += ".m3u"; |
742 | 742 | ||
743 | if( d->selectedFiles->first()) { //ramble through playlist view | 743 | if( d->selectedFiles->first()) { //ramble through playlist view |
744 | m3uList = new Om3u( filename, IO_ReadWrite); | 744 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
745 | 745 | ||
746 | do { | 746 | do { |
747 | m3uList->add( d->selectedFiles->current()->file()); | 747 | m3uList->add( d->selectedFiles->current()->file()); |
748 | } | 748 | } |
749 | while ( d->selectedFiles->next() ); | 749 | while ( d->selectedFiles->next() ); |
750 | // qDebug( list ); | 750 | // qDebug( list ); |
751 | m3uList->write(); | 751 | m3uList->write(); |
752 | m3uList->close(); | 752 | m3uList->close(); |
753 | delete m3uList; | 753 | delete m3uList; |
754 | 754 | ||
755 | delete fileDlg; | 755 | delete fileDlg; |
756 | 756 | ||
757 | DocLnk lnk; | 757 | DocLnk lnk; |
758 | lnk.setFile( filename); | 758 | lnk.setFile( filename); |
759 | lnk.setIcon("opieplayer2/playlist2"); | 759 | lnk.setIcon("opieplayer2/playlist2"); |
760 | lnk.setName( name); //sets file name | 760 | lnk.setName( name); //sets file name |
761 | 761 | ||
762 | // qDebug(filename); | 762 | // qDebug(filename); |
763 | Config config( "OpiePlayer" ); | 763 | Config config( "OpiePlayer" ); |
764 | config.setGroup( "PlayList" ); | 764 | config.setGroup( "PlayList" ); |
765 | 765 | ||
766 | config.writeEntry("CurrentPlaylist",filename); | 766 | config.writeEntry("CurrentPlaylist",filename); |
767 | currentPlayList=filename; | 767 | currentPlayList=filename; |
768 | 768 | ||
769 | if(!lnk.writeLink()) { | 769 | if(!lnk.writeLink()) { |
770 | qDebug("Writing doclink did not work"); | 770 | qDebug("Writing doclink did not work"); |
771 | } | 771 | } |
772 | 772 | ||
773 | setCaption(tr("OpiePlayer: ") + name); | 773 | setCaption(tr("OpiePlayer: ") + name); |
774 | } | 774 | } |
775 | } | 775 | } |
776 | } | 776 | } |
777 | 777 | ||
778 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 778 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
779 | switch ( e->key() ) { | 779 | switch ( e->key() ) { |
780 | ////////////////////////////// Zaurus keys | 780 | ////////////////////////////// Zaurus keys |
781 | case Key_F9: //activity | 781 | case Key_F9: //activity |
782 | // if(audioUI->isHidden()) | 782 | // if(audioUI->isHidden()) |
783 | // audioUI->showMaximized(); | 783 | // audioUI->showMaximized(); |
784 | break; | 784 | break; |
785 | case Key_F10: //contacts | 785 | case Key_F10: //contacts |
786 | // if( videoUI->isHidden()) | 786 | // if( videoUI->isHidden()) |
787 | // videoUI->showMaximized(); | 787 | // videoUI->showMaximized(); |
788 | break; | 788 | break; |
789 | case Key_F11: //menu | 789 | case Key_F11: //menu |
790 | break; | 790 | break; |
791 | case Key_F12: //home | 791 | case Key_F12: //home |
792 | // doBlank(); | 792 | // doBlank(); |
793 | break; | 793 | break; |
794 | case Key_F13: //mail | 794 | case Key_F13: //mail |
795 | // doUnblank(); | 795 | // doUnblank(); |
796 | break; | 796 | break; |
797 | case Key_Q: //add to playlist | 797 | case Key_Q: //add to playlist |
798 | addSelected(); | 798 | addSelected(); |
799 | break; | 799 | break; |
800 | case Key_R: //remove from playlist | 800 | case Key_R: //remove from playlist |
801 | removeSelected(); | 801 | removeSelected(); |
802 | break; | 802 | break; |
803 | // case Key_P: //play | 803 | // case Key_P: //play |
804 | // qDebug("Play"); | 804 | // qDebug("Play"); |
805 | // playSelected(); | 805 | // playSelected(); |
806 | // break; | 806 | // break; |
807 | case Key_Space: | 807 | case Key_Space: |
808 | // playSelected(); puh | 808 | // playSelected(); puh |
809 | break; | 809 | break; |
810 | case Key_1: | 810 | case Key_1: |
811 | tabWidget->setCurrentPage( 0 ); | 811 | tabWidget->setCurrentPage( 0 ); |
812 | break; | 812 | break; |
813 | case Key_2: | 813 | case Key_2: |
814 | tabWidget->setCurrentPage( 1 ); | 814 | tabWidget->setCurrentPage( 1 ); |
815 | break; | 815 | break; |
816 | case Key_3: | 816 | case Key_3: |
817 | tabWidget->setCurrentPage( 2 ); | 817 | tabWidget->setCurrentPage( 2 ); |
818 | break; | 818 | break; |
819 | case Key_4: | 819 | case Key_4: |
820 | tabWidget->setCurrentPage( 3 ); | 820 | tabWidget->setCurrentPage( 3 ); |
821 | break; | 821 | break; |
822 | case Key_Down: | 822 | case Key_Down: |
823 | if ( !d->selectedFiles->next() ) | 823 | if ( !d->selectedFiles->next() ) |
824 | d->selectedFiles->first(); | 824 | d->selectedFiles->first(); |
825 | break; | 825 | break; |
826 | case Key_Up: | 826 | case Key_Up: |
827 | if ( !d->selectedFiles->prev() ) | 827 | if ( !d->selectedFiles->prev() ) |
828 | // d->selectedFiles->last(); | 828 | // d->selectedFiles->last(); |
829 | break; | 829 | break; |
830 | } | 830 | } |
831 | } | 831 | } |
832 | 832 | ||
833 | void PlayListWidget::pmViewActivated(int index) { | 833 | void PlayListWidget::pmViewActivated(int index) { |
834 | // qDebug("%d", index); | 834 | // qDebug("%d", index); |
835 | switch(index) { | 835 | switch(index) { |
836 | case -16: | 836 | case -16: |
837 | { | 837 | { |
838 | mediaPlayerState.toggleFullscreen(); | 838 | mediaPlayerState.toggleFullscreen(); |
839 | bool b=mediaPlayerState.isFullscreen(); | 839 | bool b=mediaPlayerState.isFullscreen(); |
840 | pmView->setItemChecked( index, b); | 840 | pmView->setItemChecked( index, b); |
841 | Config cfg( "OpiePlayer" ); | 841 | Config cfg( "OpiePlayer" ); |
842 | cfg.writeEntry( "FullScreen", b ); | 842 | cfg.writeEntry( "FullScreen", b ); |
843 | } | 843 | } |
844 | break; | 844 | break; |
845 | }; | 845 | }; |
846 | } | 846 | } |
847 | 847 | ||
848 | void PlayListWidget::populateSkinsMenu() { | 848 | void PlayListWidget::populateSkinsMenu() { |
849 | int item = 0; | 849 | int item = 0; |
850 | defaultSkinIndex = 0; | 850 | defaultSkinIndex = 0; |
851 | QString skinName; | 851 | QString skinName; |
852 | Config cfg( "OpiePlayer" ); | 852 | Config cfg( "OpiePlayer" ); |
853 | cfg.setGroup("Options" ); | 853 | cfg.setGroup("Options" ); |
854 | QString skin = cfg.readEntry( "Skin", "default" ); | 854 | QString skin = cfg.readEntry( "Skin", "default" ); |
855 | 855 | ||
856 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 856 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
857 | skinsDir.setFilter( QDir::Dirs ); | 857 | skinsDir.setFilter( QDir::Dirs ); |
858 | skinsDir.setSorting(QDir::Name ); | 858 | skinsDir.setSorting(QDir::Name ); |
859 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 859 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
860 | QFileInfoListIterator it( *skinslist ); | 860 | QFileInfoListIterator it( *skinslist ); |
861 | QFileInfo *fi; | 861 | QFileInfo *fi; |
862 | while ( ( fi = it.current() ) ) { | 862 | while ( ( fi = it.current() ) ) { |
863 | skinName = fi->fileName(); | 863 | skinName = fi->fileName(); |
864 | // qDebug( fi->fileName() ); | 864 | // qDebug( fi->fileName() ); |
865 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 865 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
866 | item = skinsMenu->insertItem( fi->fileName() ) ; | 866 | item = skinsMenu->insertItem( fi->fileName() ) ; |
867 | } | 867 | } |
868 | if( skinName == "default" ) { | 868 | if( skinName == "default" ) { |
869 | defaultSkinIndex = item; | 869 | defaultSkinIndex = item; |
870 | } | 870 | } |
871 | if( skinName == skin ) { | 871 | if( skinName == skin ) { |
872 | skinsMenu->setItemChecked( item, TRUE ); | 872 | skinsMenu->setItemChecked( item, TRUE ); |