Playlist support (basic) and download progress dialogs
authorElias Woods <EliasWoods@gmail.com>
Sat, 26 Jun 2010 03:11:08 +0000 (23:11 -0400)
committerElias Woods <EliasWoods@gmail.com>
Sat, 26 Jun 2010 03:11:08 +0000 (23:11 -0400)
12 files changed:
Groove.pro
Groove.pro.user
groove.cpp
groove.h
groove.png [new file with mode: 0644]
grooveprogressbar.cpp
grooveprogressbar.h
icon.svg
playlist.cpp
playlist.h
reasource.qrc [deleted file]
splayer.cpp

index 2098722..fa7f8d2 100644 (file)
@@ -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
 }
index 0bf42b9..ae4a94e 100644 (file)
      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
      <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList">
-      <value type="QString">LIBS+=-L~/NokiaQtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-1014-slim/usr/lib -lqjson</value>
+      <value type="QString">INCLUDEPATH+=../qjson/src LIBS+=-L~/NokiaQtSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-1014-slim/usr/lib -lqjson</value>
      </valuelist>
     </valuemap>
     <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
     </valuemap>
     <value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">1</value>
     <valuemap key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployed" type="QVariantMap">
-     <value key="192.168.1.3" type="QDateTime">2010-06-25T05:45:13</value>
+     <value key="192.168.1.3" type="QDateTime">2010-06-25T21:36:22</value>
     </valuemap>
     <value key="Qt4ProjectManager.MaemoRunConfiguration.Simulator" type="QString"></value>
    </valuemap>
index 050a743..e857651 100644 (file)
@@ -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
index 5741d03..3bb0000 100644 (file)
--- a/groove.h
+++ b/groove.h
@@ -6,6 +6,7 @@
 #include "qmaemo5rotator.h"
 #include <QMenuBar>
 #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 (file)
index 0000000..1fc34a4
Binary files /dev/null and b/groove.png differ
index 82650a1..2817e83 100644 (file)
@@ -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)
 {
index f8f1989..d0067fd 100644 (file)
@@ -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();
index f9b82d1..0fe06eb 100644 (file)
--- 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">
   <defs
      id="defs4">
     <inkscape:perspective
@@ -26,7 +29,8 @@
        id="perspective10" />
     <filter
        inkscape:collect="always"
-       id="filter3692">
+       id="filter3692"
+       color-interpolation-filters="sRGB">
       <feGaussianBlur
          inkscape:collect="always"
          stdDeviation="0.17004"
      pagecolor="#ffffff"
      bordercolor="#666666"
      borderopacity="1.0"
-     inkscape:pageopacity="0.0"
+     inkscape:pageopacity="0"
      inkscape:pageshadow="2"
      inkscape:zoom="2.8"
-     inkscape:cx="192.53571"
+     inkscape:cx="130.92857"
      inkscape:cy="62.857143"
      inkscape:document-units="px"
      inkscape:current-layer="layer1"
      inkscape:label="Layer 1"
      inkscape:groupmode="layer"
      id="layer1"
-     transform="translate(0,-1004.3622)">
+     transform="translate(0,-988.3622)">
     <text
        xml:space="preserve"
-       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#1a1a1a;fill-opacity:1;stroke:#d4aa00;stroke-opacity:1;font-family:FreeSerif;-inkscape-font-specification:FreeSerif;filter:url(#filter3692)"
+       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#1a1a1a;fill-opacity:1;stroke:#d4aa00;stroke-opacity:1;filter:url(#filter3692);font-family:FreeSerif;-inkscape-font-specification:FreeSerif"
        x="-0.10571399"
        y="1033.0308"
        id="text2816"
-       transform="matrix(1.494539,0,0,1.494539,2.7232098,-495.39786)"><tspan
+       transform="matrix(1.9166445,0,0,1.9166445,3.7979447,-934.21415)"><tspan
          sodipodi:role="line"
          id="tspan2818"
          x="-0.10571399"
index 4fbdad7..10f7d49 100644 (file)
@@ -19,6 +19,10 @@ void playlist::freeMemory(int position)
    pList->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;
index 17895ee..4365d8d 100644 (file)
@@ -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 (file)
index 474bfc3..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
-    <qresource prefix="/icons">
-        <file>icon.svg</file>
-    </qresource>
-</RCC>
index e642dd1..16c8ec3 100644 (file)
@@ -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()