From 2f9c66b9177f647336c61dda586b1918bcb2f2a3 Mon Sep 17 00:00:00 2001 From: Elias Woods Date: Sat, 19 Jun 2010 01:30:10 -0400 Subject: [PATCH] Progressbar fix --- Groove.pro | 6 ++++-- Groove.pro.user | 2 +- Makefile | 2 +- grooveprogressbar.cpp | 26 ++++++++++++++++++++++++++ grooveprogressbar.h | 25 +++++++++++++++++++++++++ splayer.cpp | 13 +++++++++---- splayer.h | 3 ++- streamio.cpp | 4 ++-- 8 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 grooveprogressbar.cpp create mode 100644 grooveprogressbar.h diff --git a/Groove.pro b/Groove.pro index 86ae9ea..719fe07 100644 --- a/Groove.pro +++ b/Groove.pro @@ -27,7 +27,8 @@ SOURCES += main.cpp \ splayer.cpp \ streamio.cpp \ playlist.cpp \ - downloadmanager.cpp + downloadmanager.cpp \ + grooveprogressbar.cpp HEADERS += \ groove.h \ @@ -35,4 +36,5 @@ HEADERS += \ splayer.h \ streamio.h \ playlist.h \ - downloadmanager.h + downloadmanager.h \ + grooveprogressbar.h diff --git a/Groove.pro.user b/Groove.pro.user index 922c54a..b68c481 100644 --- a/Groove.pro.user +++ b/Groove.pro.user @@ -194,7 +194,7 @@ 1 - 2010-06-18T23:28:49 + 2010-06-19T01:08:31 diff --git a/Makefile b/Makefile index b09e6fe..308dfaa 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: groove -# Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Jun 18 23:18:05 2010 +# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Jun 19 00:00:46 2010 # Project: Groove.pro # Template: app # Command: /usr/bin/qmake -unix -o Makefile Groove.pro diff --git a/grooveprogressbar.cpp b/grooveprogressbar.cpp new file mode 100644 index 0000000..dc130bd --- /dev/null +++ b/grooveprogressbar.cpp @@ -0,0 +1,26 @@ +#include "grooveprogressbar.h" + +grooveProgressBar::grooveProgressBar(QDialog *parent) : + QDialog(parent) +{ + bar = new QProgressBar(); + bar->setMaximum(100); + bar->setValue(0); + lay = new QHBoxLayout(); + lay->addWidget(bar); + this->setLayout(lay); + this->setWindowTitle("Downloading / Buffering"); +} +void grooveProgressBar::setMaximum(int maximum) +{ + bar->setMaximum(maximum); +} +int grooveProgressBar::maximum() +{ + return bar->maximum(); +} + +void grooveProgressBar::setValue(int position) +{ + bar->setValue(position); +} diff --git a/grooveprogressbar.h b/grooveprogressbar.h new file mode 100644 index 0000000..770e1b1 --- /dev/null +++ b/grooveprogressbar.h @@ -0,0 +1,25 @@ +#ifndef GROOVEPROGRESSBAR_H +#define GROOVEPROGRESSBAR_H + +#include +#include + +class grooveProgressBar : public QDialog +{ + Q_OBJECT +public: + explicit grooveProgressBar(QDialog *parent = 0); + void setMaximum(int maximum); + void setValue(int position); + int maximum(); + +signals: + +public slots: + +private: + QProgressBar *bar; + QHBoxLayout *lay; +}; + +#endif // GROOVEPROGRESSBAR_H diff --git a/splayer.cpp b/splayer.cpp index bc54f00..dae3fcc 100644 --- a/splayer.cpp +++ b/splayer.cpp @@ -22,7 +22,8 @@ sPlayer::~sPlayer() } void sPlayer::abortDownload() { - reply->abort(); + //pd->hide(); + //reply->abort(); } void sPlayer::play(QString StreamKey,QUrl server) @@ -31,11 +32,15 @@ void sPlayer::play(QString StreamKey,QUrl server) { //reply->abort(); } - pd = new QProgressDialog("Downloading / Buffering.", "Cancel", 0, 100); - pd->setValue(0); + pd = new grooveProgressBar(); + //pd->setAttribute(); + #ifdef Q_WS_MAEMO_5 pd->setAttribute(Qt::WA_Maemo5AutoOrientation,true); + //pd->setModal(false); #endif + pd->show(); + pd->setValue(0); QNetworkRequest req; req.setUrl(server); qDebug() << server; @@ -44,7 +49,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())); + //connect(pd,SIGNAL(canceled()),this,SLOT(abortDownload())); media->stop(); playing = false; startStreamT = QTime::currentTime(); diff --git a/splayer.h b/splayer.h index 9ae0c37..fe3a5ec 100644 --- a/splayer.h +++ b/splayer.h @@ -6,6 +6,7 @@ #include #include "streamio.h" #include +#include "grooveprogressbar.h" class sPlayer : public QObject { @@ -33,6 +34,6 @@ private: bool playing; QObject *internal; QTime startStreamT; - QProgressDialog *pd; + grooveProgressBar *pd; }; #endif // SPLAYER_H diff --git a/streamio.cpp b/streamio.cpp index ce3cc30..6d9133b 100644 --- a/streamio.cpp +++ b/streamio.cpp @@ -9,7 +9,7 @@ void StreamIO::setSizeOfStream(qint64 s) { internal->stream()->setStreamSize(s); } -/*qint64 StreamIO::size() +qint64 StreamIO::size() { return sized; } @@ -20,7 +20,7 @@ qint64 StreamIO::bytesAvailable() bool StreamIO::isSequential() { return true; -}/* +} qint64 StreamIO::readData(char* data, qint64 maxsize) { internal->data().at(rpos); -- 1.7.9.5