From: Elias Woods Date: Sat, 26 Jun 2010 03:11:08 +0000 (-0400) Subject: Playlist support (basic) and download progress dialogs X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=256f3e93e093f74932bbf2ac33d9aa74d24a9134;hp=80457891b14cd66154daf083a7ad3eae1d7e4b2e;p=groove Playlist support (basic) and download progress dialogs --- diff --git a/Groove.pro b/Groove.pro index 2098722..fa7f8d2 100644 --- a/Groove.pro +++ b/Groove.pro @@ -5,18 +5,18 @@ TEMPLATE = app TARGET = groove #target = groove -target.path = /usr/bin +#target.path = /usr/bin #//target.path = /usr/local/ -INSTALLS += target +#INSTALLS += target #CONFIG += build_all DEPENDPATH += . INCLUDEPATH += . -#INCLUDEPATH += /usr/include/qjson -INCLUDEPATH += ../qjson/src/ +INCLUDEPATH += /usr/include/qjson +#INCLUDEPATH += ../qjson/src/ #INCLUDEPATH += ./src/ #LIBS += -L/usr/lib -lqjson ##Desktop Target -#LIBS += -L/usr/local/lib -lqjson ##Armel Target -LIBS += -L~/NokiaQtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-1014-slim/usr/lib -lqjson ##Armel Target SDK +LIBS += -L/usr/local/lib -lqjson ##Armel Target +#LIBS += -L~/NokiaQtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-1014-slim/usr/lib -lqjson ##Armel Target SDK #LIBS += -L../qjson/lib -lqjson ##X86 maemo QT += network QT += phonon @@ -42,10 +42,8 @@ HEADERS += \ qmaemo5rotator.h OTHER_FILES += \ - icon.svg - -RESOURCES += \ - reasource.qrc + icon.svg \ + groove.png unix { PREFIX = /usr BINDIR = $$PREFIX/bin @@ -55,7 +53,13 @@ unix { #MAKE INSTALL - INSTALLS += target + INSTALLS += target desktop icon64 target.path =$$BINDIR + + desktop.path = $$DATADIR/applications/hildon + desktop.files += groove.desktop + + icon64.path = $$DATADIR/icons/hicolor/64x64/apps + icon64.files += groove.png } diff --git a/Groove.pro.user b/Groove.pro.user index 0bf42b9..ae4a94e 100644 --- a/Groove.pro.user +++ b/Groove.pro.user @@ -118,7 +118,7 @@ qmake QtProjectManager.QMakeBuildStep - LIBS+=-L~/NokiaQtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-1014-slim/usr/lib -lqjson + INCLUDEPATH+=../qjson/src LIBS+=-L~/NokiaQtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-1014-slim/usr/lib -lqjson @@ -194,7 +194,7 @@ 1 - 2010-06-25T05:45:13 + 2010-06-25T21:36:22 diff --git a/groove.cpp b/groove.cpp index 050a743..e857651 100644 --- a/groove.cpp +++ b/groove.cpp @@ -25,11 +25,12 @@ groove::groove(QWidget *parent) : pushMenu->addAction("Song:"); //pushMenu->addAction("Artist:"); //pushMenu->addAction("Album:"); - + pd = new grooveProgressBar(this); + pd->hide(); QMenu *moreAction = new QMenu(); moreAction->addAction("Playlist"); - moreAction->addAction("Add current song to playlist"); - moreAction->addAction("Show download Progress"); + connect(moreAction->addAction("Add current song to playlist"),SIGNAL(triggered()),this,SLOT(addSongPlaylist())); + connect(moreAction->addAction("Show download Progress"),SIGNAL(triggered()),pd,SLOT(show())); moreButton->setMenu(moreAction); //sMethod->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Maximum); @@ -79,6 +80,8 @@ groove::groove(QWidget *parent) : pl = new playlist(); pl->setGscom(gs); player->setPlaylist(pl); + connect(pl,SIGNAL(downloadProgress(int,qint64,qint64)),this,SLOT(progressUpdate(int,qint64,qint64))); + connect(pl,SIGNAL(bufferReady(int)),pd,SLOT(close())); } void groove::search() { @@ -135,10 +138,35 @@ void groove::play() return; //gs->getSong(); player->play(pl->addSong(item)); + pd->setMaximum(100); + pd->setValue(0); + pd->show(); } //selected. //if } +void groove::addSongPlaylist() +{ + QModelIndexList selected = resultView->selectionModel()->selectedRows(0); + if(!selected.isEmpty()) + { + QStandardItem *item = model->item(selected.first().row(),2); + if(item == 0) + return; + //gs->getSong(); + if(pl->currentplaying() == -1) + { + player->play(pl->addSong(item)); + } + else + pl->addSong(item); + pd->setMaximum(100); + pd->setValue(0); + pd->show(); + model->item(selected.first().row(),1)->setText("Added to Playlist");; + } +} + void groove::stop() { player->stop(); @@ -147,6 +175,15 @@ void groove::moreB() { qDebug() << "He pressed the button"; } +void groove::progressUpdate(int p, qint64 d, qint64 t) +{ + //if(!pd->isHidden()) + //{ + pd->setMaximum(t); + pd->setValue(d); + //} +} + void groove::orientationChanged() { #ifdef Q_WS_MAEMO_5 diff --git a/groove.h b/groove.h index 5741d03..3bb0000 100644 --- a/groove.h +++ b/groove.h @@ -6,6 +6,7 @@ #include "qmaemo5rotator.h" #include #include "playlist.h" +#include "grooveprogressbar.h" class groove : public QWidget { @@ -23,7 +24,9 @@ public slots: void stop(); void moreB(); void orientationChanged(); - +private slots: + void progressUpdate(int,qint64,qint64); + void addSongPlaylist(); private: sPlayer *player; QMenuBar *mBar; @@ -36,6 +39,7 @@ private: gscom *gs; QMaemo5Rotator *rot; playlist *pl; + grooveProgressBar *pd; }; diff --git a/groove.png b/groove.png new file mode 100644 index 0000000..1fc34a4 Binary files /dev/null and b/groove.png differ diff --git a/grooveprogressbar.cpp b/grooveprogressbar.cpp index 82650a1..2817e83 100644 --- a/grooveprogressbar.cpp +++ b/grooveprogressbar.cpp @@ -1,6 +1,6 @@ #include "grooveprogressbar.h" #include "qmaemo5rotator.h" -grooveProgressBar::grooveProgressBar(QDialog *parent) : +grooveProgressBar::grooveProgressBar(QWidget *parent) : QDialog(parent) { bar = new QProgressBar(); @@ -10,7 +10,7 @@ grooveProgressBar::grooveProgressBar(QDialog *parent) : lay->addWidget(bar); this->setLayout(lay); this->setWindowTitle("Downloading / Buffering"); - rot = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior,this); + //rot = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior,this); } void grooveProgressBar::setMaximum(int maximum) { diff --git a/grooveprogressbar.h b/grooveprogressbar.h index f8f1989..d0067fd 100644 --- a/grooveprogressbar.h +++ b/grooveprogressbar.h @@ -9,7 +9,7 @@ class grooveProgressBar : public QDialog { Q_OBJECT public: - explicit grooveProgressBar(QDialog *parent = 0); + explicit grooveProgressBar(QWidget *parent = 0); void setMaximum(int maximum); void setValue(int position); int maximum(); diff --git a/icon.svg b/icon.svg index f9b82d1..0fe06eb 100644 --- a/icon.svg +++ b/icon.svg @@ -9,12 +9,15 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="48" - height="48" + width="64" + height="64" id="svg2" version="1.1" inkscape:version="0.47 r22583" - sodipodi:docname="icon.svg"> + sodipodi:docname="icon.svg" + inkscape:export-filename="/home/eli/Projects/qt4/Groove/icon.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + id="filter3692" + color-interpolation-filters="sRGB"> + transform="translate(0,-988.3622)"> at(position)->buffer->~QBuffer(); pList->at(position)->buffer = new QBuffer(); } +bool playlist::existAt(int position) +{ + return (pList->size() > position); +} int playlist::currentplaying() { @@ -26,7 +30,10 @@ int playlist::currentplaying() } bool playlist::bReady(int b) { - return pList->at(b)->bufferready; + if(pList->size() > b) + return pList->at(b)->bufferready; + else + return false; } void playlist::setBufferRdy(int b) { @@ -63,8 +70,7 @@ void playlist::beginDownload(int position) req.setUrl(*pList->at(currentdownloaditem)->server); qDebug() << pList->at(currentdownloaditem)->server; req.setHeader(req.ContentTypeHeader,QVariant("application/x-www-form-urlencoded")); - if(reply) - reply->~QNetworkReply(); + delete reply; reply = manager->post(req,QString("streamKey=" + pList->at(this->currentdownloaditem)->streamkey->toAscii()).toAscii()); pList->at(this->currentdownloaditem)->buffer->open(QBuffer::ReadWrite | QBuffer::Truncate); connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadSlot(qint64,qint64))); @@ -88,6 +94,7 @@ void playlist::skeyFound() else if(this->currentplaying() == this->currentSkeyItem) this->beginDownload(this->currentSkeyItem); + this->currentSkeyItem = -1; } int playlist::addSong(QStandardItem *item) @@ -110,7 +117,7 @@ int playlist::addSong(QStandardItem *item) void playlist::downloadDone(int position) { - if(pList->size() < position+1) + if(this->existAt(position+1) && this->currentSkeyItem == -1) beginDownload(position+1); else this->currentdownloaditem = -1; diff --git a/playlist.h b/playlist.h index 17895ee..4365d8d 100644 --- a/playlist.h +++ b/playlist.h @@ -34,6 +34,7 @@ public: bool bReady(int b); int findFirstNotPlayed(); void beginDownload(int position); + bool existAt(int position); signals: void downloadProgress(int position, qint64 d, qint64 t); diff --git a/reasource.qrc b/reasource.qrc deleted file mode 100644 index 474bfc3..0000000 --- a/reasource.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - icon.svg - - diff --git a/splayer.cpp b/splayer.cpp index e642dd1..16c8ec3 100644 --- a/splayer.cpp +++ b/splayer.cpp @@ -25,7 +25,14 @@ void sPlayer::setPlaylist(playlist *playList) void sPlayer::markComplete() { pl->markPlayed(pl->currentplaying()); - pl->setCurrentPlaying(-1); + if(pl->existAt(pl->currentplaying()+1)) + { + pl->setCurrentPlaying(pl->currentplaying()+1); + if(pl->bReady(pl->currentplaying())) + this->start(pl->currentplaying()); + } + else + pl->setCurrentPlaying(-1); } sPlayer::~sPlayer()