From: Elias Woods Date: Sat, 19 Jun 2010 03:34:22 +0000 (-0400) Subject: Add portrait support, download progress X-Git-Url: https://vcs.maemo.org/git/?p=groove;a=commitdiff_plain;h=6413ec62dde3e49705db1a14deaa1890163dd8f1 Add portrait support, download progress --- diff --git a/Groove.pro b/Groove.pro index de7ff66..86ae9ea 100644 --- a/Groove.pro +++ b/Groove.pro @@ -26,11 +26,13 @@ SOURCES += main.cpp \ gscom.cpp \ splayer.cpp \ streamio.cpp \ - playlist.cpp + playlist.cpp \ + downloadmanager.cpp HEADERS += \ groove.h \ gscom.h \ splayer.h \ streamio.h \ - playlist.h + playlist.h \ + downloadmanager.h diff --git a/Groove.pro.user b/Groove.pro.user index 1b5a1a2..922c54a 100644 --- a/Groove.pro.user +++ b/Groove.pro.user @@ -194,7 +194,7 @@ 1 - 2010-06-17T01:03:56 + 2010-06-18T23:28:49 diff --git a/Makefile b/Makefile index 74ab4ae..b09e6fe 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: groove -# Generated by qmake (2.01a) (Qt 4.6.2) on: Thu Jun 17 01:20:12 2010 +# Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Jun 18 23:18:05 2010 # Project: Groove.pro # Template: app # Command: /usr/bin/qmake -unix -o Makefile Groove.pro @@ -48,22 +48,26 @@ SOURCES = main.cpp \ gscom.cpp \ splayer.cpp \ streamio.cpp \ - playlist.cpp moc_groove.cpp \ + playlist.cpp \ + downloadmanager.cpp moc_groove.cpp \ moc_gscom.cpp \ moc_splayer.cpp \ moc_streamio.cpp \ - moc_playlist.cpp + moc_playlist.cpp \ + moc_downloadmanager.cpp OBJECTS = main.o \ groove.o \ gscom.o \ splayer.o \ streamio.o \ playlist.o \ + downloadmanager.o \ moc_groove.o \ moc_gscom.o \ moc_splayer.o \ moc_streamio.o \ - moc_playlist.o + moc_playlist.o \ + moc_downloadmanager.o DIST = /usr/share/qt4/mkspecs/common/g++.conf \ /usr/share/qt4/mkspecs/common/unix.conf \ /usr/share/qt4/mkspecs/common/linux.conf \ @@ -167,7 +171,7 @@ qmake: FORCE dist: @$(CHK_DIR_EXISTS) .tmp/groove1.0.0 || $(MKDIR) .tmp/groove1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/groove1.0.0/ && $(COPY_FILE) --parents groove.h gscom.h splayer.h streamio.h playlist.h .tmp/groove1.0.0/ && $(COPY_FILE) --parents main.cpp groove.cpp gscom.cpp splayer.cpp streamio.cpp playlist.cpp .tmp/groove1.0.0/ && (cd `dirname .tmp/groove1.0.0` && $(TAR) groove1.0.0.tar groove1.0.0 && $(COMPRESS) groove1.0.0.tar) && $(MOVE) `dirname .tmp/groove1.0.0`/groove1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/groove1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/groove1.0.0/ && $(COPY_FILE) --parents groove.h gscom.h splayer.h streamio.h playlist.h downloadmanager.h .tmp/groove1.0.0/ && $(COPY_FILE) --parents main.cpp groove.cpp gscom.cpp splayer.cpp streamio.cpp playlist.cpp downloadmanager.cpp .tmp/groove1.0.0/ && (cd `dirname .tmp/groove1.0.0` && $(TAR) groove1.0.0.tar groove1.0.0 && $(COMPRESS) groove1.0.0.tar) && $(MOVE) `dirname .tmp/groove1.0.0`/groove1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/groove1.0.0 clean:compiler_clean @@ -186,9 +190,9 @@ mocclean: compiler_moc_header_clean compiler_moc_source_clean mocables: compiler_moc_header_make_all compiler_moc_source_make_all -compiler_moc_header_make_all: moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp +compiler_moc_header_make_all: moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp moc_downloadmanager.cpp compiler_moc_header_clean: - -$(DEL_FILE) moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp + -$(DEL_FILE) moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp moc_downloadmanager.cpp moc_groove.cpp: gscom.h \ splayer.h \ streamio.h \ @@ -211,6 +215,9 @@ moc_streamio.cpp: splayer.h \ moc_playlist.cpp: playlist.h /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) playlist.h -o moc_playlist.cpp +moc_downloadmanager.cpp: downloadmanager.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) downloadmanager.h -o moc_downloadmanager.cpp + compiler_rcc_make_all: compiler_rcc_clean: compiler_image_collection_make_all: qmake_image_collection.cpp @@ -256,6 +263,9 @@ streamio.o: streamio.cpp streamio.h \ playlist.o: playlist.cpp playlist.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o playlist.o playlist.cpp +downloadmanager.o: downloadmanager.cpp downloadmanager.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o downloadmanager.o downloadmanager.cpp + moc_groove.o: moc_groove.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_groove.o moc_groove.cpp @@ -271,6 +281,9 @@ moc_streamio.o: moc_streamio.cpp moc_playlist.o: moc_playlist.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_playlist.o moc_playlist.cpp +moc_downloadmanager.o: moc_downloadmanager.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_downloadmanager.o moc_downloadmanager.cpp + ####### Install install_target: first FORCE diff --git a/downloadmanager.cpp b/downloadmanager.cpp new file mode 100644 index 0000000..89aed0b --- /dev/null +++ b/downloadmanager.cpp @@ -0,0 +1,6 @@ +#include "downloadmanager.h" + +downloadmanager::downloadmanager(QObject *parent) : + QObject(parent) +{ +} diff --git a/downloadmanager.h b/downloadmanager.h new file mode 100644 index 0000000..f7c3c74 --- /dev/null +++ b/downloadmanager.h @@ -0,0 +1,22 @@ +#ifndef DOWNLOADMANAGER_H +#define DOWNLOADMANAGER_H + +#include + +class downloadmanager : public QObject +{ + Q_OBJECT +public: + explicit downloadmanager(QObject *parent = 0); + explicit downloadmanager(QString songid,bool start = true,QObject *parent = 0); + void setSong(QString songid); + void startDownload(); + void stopDownload(); + +signals: + +public slots: + +}; + +#endif // DOWNLOADMANAGER_H diff --git a/groove.cpp b/groove.cpp index 3bd7b6a..102c369 100644 --- a/groove.cpp +++ b/groove.cpp @@ -16,7 +16,7 @@ groove::groove(QWidget *parent) : button = new QPushButton("Search"); QPushButton *dButton = new QPushButton("Play"); QPushButton *stopButton = new QPushButton("Stop"); - QPushButton *moreButton = new QPushButton(); + QPushButton *moreButton = new QPushButton("..."); resultView = new QTableView(); QMenu *pushMenu = new QMenu(); //showFullScreen(); @@ -26,6 +26,12 @@ groove::groove(QWidget *parent) : //pushMenu->addAction("Artist:"); //pushMenu->addAction("Album:"); + QMenu *moreAction = new QMenu(); + moreAction->addAction("Playlist"); + moreAction->addAction("Add current song to playlist"); + moreAction->addAction("Show download Progress"); + moreButton->setMenu(moreAction); + //sMethod->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Maximum); sMethod->setMaximumWidth(sMethod->sizeHint().rwidth()); sMethod->setMenu(pushMenu); @@ -47,6 +53,9 @@ groove::groove(QWidget *parent) : resultView->setPalette(pal);*/ layout->addWidget(sMethod); +#ifdef Q_WS_MAEMO_5 + setAttribute(Qt::WA_Maemo5AutoOrientation,true); +#endif layout->addWidget(lineEdit); layout->addWidget(button); vlayout->addLayout(layout); @@ -68,6 +77,7 @@ groove::groove(QWidget *parent) : connect(dButton,SIGNAL(clicked()),this, SLOT(play())); connect(stopButton,SIGNAL(clicked()),this,SLOT(stop())); connect(gs,SIGNAL(sKeyFound()),this,SLOT(startP())); + connect(moreButton,SIGNAL(clicked()),this,SLOT(moreB())); } void groove::search() { @@ -141,3 +151,7 @@ void groove::stop() { player->stop(); } +void groove::moreB() +{ + qDebug() << "He pressed the button"; +} diff --git a/groove.h b/groove.h index 177b9b6..100bc6e 100644 --- a/groove.h +++ b/groove.h @@ -20,6 +20,7 @@ public slots: void play(); void startP(); void stop(); + void moreB(); private: sPlayer *player; diff --git a/gscom.cpp b/gscom.cpp index 1e6d055..733d679 100644 --- a/gscom.cpp +++ b/gscom.cpp @@ -274,7 +274,7 @@ void gscom::addProgressbar(QString debug) gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1)); gradient.setColorAt(0.9, QColor::fromRgbF(0, 1, 0, 1)); gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0)); - QBrush brush(gradient); + QBrush brush(Qt::red); QStandardItem *pBar = new QStandardItem(text); pBar->setBackground(brush); pBar->setSelectable(false); diff --git a/splayer.cpp b/splayer.cpp index 0509b3e..bc54f00 100644 --- a/splayer.cpp +++ b/splayer.cpp @@ -20,6 +20,10 @@ sPlayer::~sPlayer() buffer->~QBuffer(); media->~MediaNode(); } +void sPlayer::abortDownload() +{ + reply->abort(); +} void sPlayer::play(QString StreamKey,QUrl server) { @@ -27,7 +31,11 @@ void sPlayer::play(QString StreamKey,QUrl server) { //reply->abort(); } - + pd = new QProgressDialog("Downloading / Buffering.", "Cancel", 0, 100); + pd->setValue(0); +#ifdef Q_WS_MAEMO_5 + pd->setAttribute(Qt::WA_Maemo5AutoOrientation,true); +#endif QNetworkRequest req; req.setUrl(server); qDebug() << server; @@ -36,6 +44,7 @@ void sPlayer::play(QString StreamKey,QUrl server) buffer->open(buffer->ReadWrite | buffer->Truncate); connect(reply,SIGNAL(finished()),this,SLOT(start())); connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(putb(qint64,qint64))); + connect(pd,SIGNAL(canceled()),this,SLOT(abortDownload())); media->stop(); playing = false; startStreamT = QTime::currentTime(); @@ -101,6 +110,9 @@ void sPlayer::putb(qint64 b, qint64 t) } else { + if(pd->maximum() != t) + pd->setMaximum(t); + pd->setValue(b); buffer->buffer().append(reply->readAll()); //qDebug() << buffer->bytesAvailable(); @@ -120,8 +132,9 @@ void sPlayer::putb(qint64 b, qint64 t) buffer->seek(last); //buffer->data().append(reply->readAll());*/ //qDebug() << "Download speed (KB/S): " << b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024; - if ( b >= t*0.05 && !playing && b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024 >= 35) + if ( b >= t*0.05 && !playing && b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024 >= 25) { + pd->hide(); playing = true; //Start playback at 25% download media->setCurrentSource(Phonon::MediaSource(buffer)); diff --git a/splayer.h b/splayer.h index 07224ad..9ae0c37 100644 --- a/splayer.h +++ b/splayer.h @@ -5,6 +5,7 @@ #include #include #include "streamio.h" +#include class sPlayer : public QObject { @@ -21,6 +22,7 @@ signals: public slots: void start(); void putb(qint64,qint64); + void abortDownload(); private: QNetworkAccessManager *manager; Phonon::AudioOutput *audioOutput; @@ -31,6 +33,6 @@ private: bool playing; QObject *internal; QTime startStreamT; + QProgressDialog *pd; }; - #endif // SPLAYER_H