summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-12 12:15:30 (UTC)
committer llornkcor <llornkcor>2002-05-12 12:15:30 (UTC)
commitc1cc5edca5d6d71350f841892fb7828f7be9ed9f (patch) (side-by-side diff)
tree014224506a39db65d54c41b18c5f7c1096cb7a92
parent06e723cc7942af2691828e7fdc6a6ec47b44edab (diff)
downloadopie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.zip
opie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.tar.gz
opie-c1cc5edca5d6d71350f841892fb7828f7be9ed9f.tar.bz2
added a few keyboard shorts
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp139
1 files changed, 133 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 038b371..ec5500f 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -25,41 +25,41 @@
#include <qpe/qpetoolbar.h>
#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/lnkproperties.h>
#include <qpe/storage.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qaction.h>
-#include <qcursor.h>
#include <qimage.h>
#include <qfile.h>
#include <qdir.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qlist.h>
#include <qlistbox.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qtoolbutton.h>
#include <qtabwidget.h>
#include <qlistview.h>
#include <qpoint.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qregexp.h>
+#include <qtextstream.h>
//#include <qtimer.h>
#include "playlistselection.h"
#include "playlistwidget.h"
#include "mediaplayerstate.h"
#include "inputDialog.h"
#include <stdlib.h>
#include "audiowidget.h"
#include "videowidget.h"
@@ -240,46 +240,51 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
audioView->setColumnAlignment(2, Qt::AlignRight);
audioView->setAllColumnsShowFocus(TRUE);
audioView->setMultiSelection( TRUE );
audioView->setSelectionMode( QListView::Extended);
tabWidget->insertTab(aTab,tr("Audio"));
QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
+ connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
+ this,SLOT( playIt( QListViewItem *)) );
// audioView
populateAudioView();
// videowidget
QWidget *vTab;
vTab = new QWidget( tabWidget, "vTab" );
videoView = new QListView( vTab, "Videoview" );
videoView->setMinimumSize(233,260);
videoView->addColumn(tr("Title"),140);
videoView->addColumn(tr("Size"),-1);
videoView->addColumn(tr("Media"),-1);
videoView->setColumnAlignment(1, Qt::AlignRight);
videoView->setColumnAlignment(2, Qt::AlignRight);
videoView->setAllColumnsShowFocus(TRUE);
videoView->setMultiSelection( TRUE );
videoView->setSelectionMode( QListView::Extended);
QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
+
connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
+ connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
+ this,SLOT( playIt( QListViewItem *)) );
tabWidget->insertTab( vTab,tr("Video"));
populateVideoView();
//playlists list
QWidget *LTab;
LTab = new QWidget( tabWidget, "LTab" );
playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
playLists->setMinimumSize(233,260);;
tabWidget->insertTab(LTab,tr("Lists"));
connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
@@ -825,43 +830,47 @@ void PlayListWidget::tabChanged(QWidget *widg) {
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
mediaPlayerState->setPlaying(b);
}
break;
case 1:
{
+// if(audioView->selectedItem()) {
addToSelection( audioView->selectedItem() );
mediaPlayerState->setPlaying(b);
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(1);
d->selectedFiles->unSelect();
insanityBool=FALSE;
// audioView->clearSelection();
+// }
}
break;
case 2:
{
+// if(videoView->selectedItem() ) {
addToSelection( videoView->selectedItem() );
mediaPlayerState->setPlaying(b);
qApp->processEvents();
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(2);
d->selectedFiles->unSelect();
insanityBool=FALSE;
// videoView->clearSelection();
+// }
}
break;
};
}
void PlayListWidget::deletePlaylist() {
switch( QMessageBox::information( this, (tr("Remove Playlist?")),
(tr("You really want to delete\nthis playlist?")),
(tr("Yes")), (tr("No")), 0 )){
case 0: // Yes clicked,
QFile().remove(playLists->selected()->file());
QFile().remove(playLists->selected()->linkFile());
@@ -874,63 +883,66 @@ void PlayListWidget::deletePlaylist() {
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
{
switch (mouse) {
case 1:
break;
case 2:{
QPopupMenu m;
m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
m.insertSeparator();
+ if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
+
m.exec( QCursor::pos() );
}
break;
};
}
void PlayListWidget::playSelected()
{
btnPlay( TRUE);
// d->selectedFiles->unSelect();
}
void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
{
switch (mouse) {
case 1:
break;
case 2:{
QPopupMenu m;
m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
-// m.insertSeparator();
+// m.insertSeparator();
+// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
m.exec( QCursor::pos() );
}
break;
};
}
void PlayListWidget::listDelete() {
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
QString file;
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
switch ( tabWidget->currentPageIndex()) {
- case 0:
+ case 0:
break;
case 1:
{
file = audioView->selectedItem()->text(0);
// Global::findDocuments(&files, "audio/*");
// AppLnkSet appFiles;
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == file) {
// qDebug(file);
LnkProperties prop( dit.current() );
// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
@@ -976,24 +988,25 @@ void PlayListWidget::populateAudioView() {
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
if(dit.current()->file().find(path) != -1 ) storage=name;
}
QListViewItem * newItem;
if ( QFile( dit.current()->file()).exists() ) {
newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
}
}
+
}
void PlayListWidget::populateVideoView() {
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
Global::findDocuments(&vFiles, "video/*");
QListIterator<DocLnk> Vdit( vFiles.children() );
QListIterator<FileSystem> it ( fs );
videoView->clear();
QString storage;
for ( ; Vdit.current(); ++Vdit ) {
@@ -1009,27 +1022,27 @@ void PlayListWidget::populateVideoView() {
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
}
}
}
void PlayListWidget::openFile() {
QString filename, name;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
filename = fileDlg->LineEdit1->text();
-//http://205.188.234.129:8030
+// http://205.188.234.129:8030
// http://66.28.68.70:8000
- qDebug(filename);
+ qDebug("Selected filename is "+filename);
if(filename.right(3) == "m3u")
readm3u( filename);
else if(filename.right(3) == "pls")
readPls( filename);
else {
DocLnk lnk;
lnk.setName(filename); //sets file name
if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
filename += "/";
lnk.setFile(filename); //sets File property
@@ -1059,49 +1072,163 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
case Key_F10: //contacts
// if( videoUI->isHidden())
// videoUI->showMaximized();
break;
case Key_F11: //menu
break;
case Key_F12: //home
// doBlank();
break;
case Key_F13: //mail
// doUnblank();
break;
-
+ case Key_Q: //add to playlist
+ qDebug("Add");
+ addSelected();
+ break;
+ case Key_R: //remove from playlist
+ removeSelected();
+ break;
+// case Key_P: //play
+// qDebug("Play");
+// playSelected();
+// break;
+ case Key_Space:
+ qDebug("Play");
+ playSelected();
+ break;
+ case Key_1:
+ tabWidget->setCurrentPage(0);
+ break;
+ case Key_2:
+ tabWidget->setCurrentPage(1);
+ break;
+ case Key_3:
+ tabWidget->setCurrentPage(2);
+ break;
+ case Key_4:
+ tabWidget->setCurrentPage(3);
+ break;
}
}
+void PlayListWidget::keyPressEvent( QKeyEvent *e)
+{
+// qDebug("Key press");
+// switch ( e->key() ) {
+// ////////////////////////////// Zaurus keys
+// case Key_A: //add to playlist
+// qDebug("Add");
+// addSelected();
+// break;
+// case Key_R: //remove from playlist
+// removeSelected();
+// break;
+// case Key_P: //play
+// qDebug("Play");
+// playSelected();
+// break;
+// case Key_Space:
+// qDebug("Play");
+// playSelected();
+// break;
+// }
+}
+
void PlayListWidget::doBlank() {
qDebug("do blanking");
fd=open("/dev/fb0",O_RDWR);
if (fd != -1) {
ioctl(fd,FBIOBLANK,1);
// close(fd);
}
}
void PlayListWidget::doUnblank() {
// this crashes opieplayer with a segfault
// int fd;
// fd=open("/dev/fb0",O_RDWR);
qDebug("do unblanking");
if (fd != -1) {
ioctl(fd,FBIOBLANK,0);
close(fd);
}
QCopEnvelope h("QPE/System", "setBacklight(int)");
h <<-3;// v[1]; // -3 Force on
}
void PlayListWidget::readm3u(const QString &filename) {
+ qDebug("playlist filename is "+filename);
+ QFile f(filename);
+
+ if(f.open(IO_ReadOnly)) {
+ QTextStream t(&f);
+ QString s;//, first, second;
+ int i=0;
+ while ( !t.atEnd()) {
+// Lview->insertLine(t.readLine(),-1);
+ s=t.readLine();
+ if(s.find("#",0,TRUE) == -1) {
+ if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
+ if(s.left(2) == "E:" || s.left(2) == "P:") {
+ s=s.right(s.length()-2);
+ DocLnk lnk( s );
+ QFileInfo f(s);
+ QString name = f.baseName();
+ name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
+ lnk.setName( name);
+ s=s.replace( QRegExp("\\"),"/");
+ lnk.setFile( s);
+// lnk.setIcon(opieplayer/MPEGPlayer);
+ qDebug("add "+name);
+ d->selectedFiles->addToSelection( lnk);
+ } else { // is url
+ DocLnk lnk( s);
+ QString name = s.right( s.length() - 7);
+// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
+ lnk.setName(name);
+ lnk.setFile( s+"/");
+// lnk.setFile( filename);
+// lnk.setComment( s+"/");
+ lnk.setType("audio/x-mpegurl");
+// lnk.setIcon( "opieplayer/MPEGPlayer");
+// qDebug("add "+s);
+ d->selectedFiles->addToSelection( lnk);
+ }
+ i++;
+ }
+ }
+ }
+ }
}
void PlayListWidget::writem3u(const QString &filename) {
}
void PlayListWidget::readPls(const QString &filename) {
+ qDebug("playlist filename is "+filename);
+ QFile f(filename);
+
+ if(f.open(IO_ReadOnly)) {
+ QTextStream t(&f);
+ QString s;//, first, second;
+ int i=0;
+ while ( !t.atEnd()) {
+// Lview->insertLine(t.readLine(),-1);
+// s=t.readLine();
+// s=s.right(s.length()-2);
+// DocLnk lnk( s );
+// QFileInfo f(s);
+// QString name = f.baseName();
+// // name = name.left(name.length()-4);
+// name = name.right(name.findRev("/",0,TRUE));
+// lnk.setName( name);
+// lnk.setFile( s);
+// qDebug("add "+name);
+// d->selectedFiles->addToSelection( lnk);
+ }
+ i++;
+ }
}