Skip to content

Commit 6413ec6

Browse files
committed
Add portrait support, download progress
1 parent b7de84b commit 6413ec6

File tree

10 files changed

+88
-15
lines changed

10 files changed

+88
-15
lines changed

Groove.pro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ SOURCES += main.cpp \
2626
gscom.cpp \
2727
splayer.cpp \
2828
streamio.cpp \
29-
playlist.cpp
29+
playlist.cpp \
30+
downloadmanager.cpp
3031

3132
HEADERS += \
3233
groove.h \
3334
gscom.h \
3435
splayer.h \
3536
streamio.h \
36-
playlist.h
37+
playlist.h \
38+
downloadmanager.h

Groove.pro.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
</valuemap>
195195
<value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">1</value>
196196
<valuemap key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployed" type="QVariantMap">
197-
<value key="192.168.1.3" type="QDateTime">2010-06-17T01:03:56</value>
197+
<value key="192.168.1.3" type="QDateTime">2010-06-18T23:28:49</value>
198198
</valuemap>
199199
<value key="Qt4ProjectManager.MaemoRunConfiguration.Simulator" type="QString"></value>
200200
</valuemap>

Makefile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#############################################################################
22
# Makefile for building: groove
3-
# Generated by qmake (2.01a) (Qt 4.6.2) on: Thu Jun 17 01:20:12 2010
3+
# Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Jun 18 23:18:05 2010
44
# Project: Groove.pro
55
# Template: app
66
# Command: /usr/bin/qmake -unix -o Makefile Groove.pro
@@ -48,22 +48,26 @@ SOURCES = main.cpp \
4848
gscom.cpp \
4949
splayer.cpp \
5050
streamio.cpp \
51-
playlist.cpp moc_groove.cpp \
51+
playlist.cpp \
52+
downloadmanager.cpp moc_groove.cpp \
5253
moc_gscom.cpp \
5354
moc_splayer.cpp \
5455
moc_streamio.cpp \
55-
moc_playlist.cpp
56+
moc_playlist.cpp \
57+
moc_downloadmanager.cpp
5658
OBJECTS = main.o \
5759
groove.o \
5860
gscom.o \
5961
splayer.o \
6062
streamio.o \
6163
playlist.o \
64+
downloadmanager.o \
6265
moc_groove.o \
6366
moc_gscom.o \
6467
moc_splayer.o \
6568
moc_streamio.o \
66-
moc_playlist.o
69+
moc_playlist.o \
70+
moc_downloadmanager.o
6771
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
6872
/usr/share/qt4/mkspecs/common/unix.conf \
6973
/usr/share/qt4/mkspecs/common/linux.conf \
@@ -167,7 +171,7 @@ qmake: FORCE
167171

168172
dist:
169173
@$(CHK_DIR_EXISTS) .tmp/groove1.0.0 || $(MKDIR) .tmp/groove1.0.0
170-
$(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
174+
$(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
171175

172176

173177
clean:compiler_clean
@@ -186,9 +190,9 @@ mocclean: compiler_moc_header_clean compiler_moc_source_clean
186190

187191
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
188192

189-
compiler_moc_header_make_all: moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp
193+
compiler_moc_header_make_all: moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp moc_downloadmanager.cpp
190194
compiler_moc_header_clean:
191-
-$(DEL_FILE) moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp
195+
-$(DEL_FILE) moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp moc_downloadmanager.cpp
192196
moc_groove.cpp: gscom.h \
193197
splayer.h \
194198
streamio.h \
@@ -211,6 +215,9 @@ moc_streamio.cpp: splayer.h \
211215
moc_playlist.cpp: playlist.h
212216
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) playlist.h -o moc_playlist.cpp
213217

218+
moc_downloadmanager.cpp: downloadmanager.h
219+
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) downloadmanager.h -o moc_downloadmanager.cpp
220+
214221
compiler_rcc_make_all:
215222
compiler_rcc_clean:
216223
compiler_image_collection_make_all: qmake_image_collection.cpp
@@ -256,6 +263,9 @@ streamio.o: streamio.cpp streamio.h \
256263
playlist.o: playlist.cpp playlist.h
257264
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o playlist.o playlist.cpp
258265

266+
downloadmanager.o: downloadmanager.cpp downloadmanager.h
267+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o downloadmanager.o downloadmanager.cpp
268+
259269
moc_groove.o: moc_groove.cpp
260270
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_groove.o moc_groove.cpp
261271

@@ -271,6 +281,9 @@ moc_streamio.o: moc_streamio.cpp
271281
moc_playlist.o: moc_playlist.cpp
272282
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_playlist.o moc_playlist.cpp
273283

284+
moc_downloadmanager.o: moc_downloadmanager.cpp
285+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_downloadmanager.o moc_downloadmanager.cpp
286+
274287
####### Install
275288

276289
install_target: first FORCE

downloadmanager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "downloadmanager.h"
2+
3+
downloadmanager::downloadmanager(QObject *parent) :
4+
QObject(parent)
5+
{
6+
}

downloadmanager.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef DOWNLOADMANAGER_H
2+
#define DOWNLOADMANAGER_H
3+
4+
#include <QObject>
5+
6+
class downloadmanager : public QObject
7+
{
8+
Q_OBJECT
9+
public:
10+
explicit downloadmanager(QObject *parent = 0);
11+
explicit downloadmanager(QString songid,bool start = true,QObject *parent = 0);
12+
void setSong(QString songid);
13+
void startDownload();
14+
void stopDownload();
15+
16+
signals:
17+
18+
public slots:
19+
20+
};
21+
22+
#endif // DOWNLOADMANAGER_H

groove.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ groove::groove(QWidget *parent) :
1616
button = new QPushButton("Search");
1717
QPushButton *dButton = new QPushButton("Play");
1818
QPushButton *stopButton = new QPushButton("Stop");
19-
QPushButton *moreButton = new QPushButton();
19+
QPushButton *moreButton = new QPushButton("...");
2020
resultView = new QTableView();
2121
QMenu *pushMenu = new QMenu();
2222
//showFullScreen();
@@ -26,6 +26,12 @@ groove::groove(QWidget *parent) :
2626
//pushMenu->addAction("Artist:");
2727
//pushMenu->addAction("Album:");
2828

29+
QMenu *moreAction = new QMenu();
30+
moreAction->addAction("Playlist");
31+
moreAction->addAction("Add current song to playlist");
32+
moreAction->addAction("Show download Progress");
33+
moreButton->setMenu(moreAction);
34+
2935
//sMethod->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Maximum);
3036
sMethod->setMaximumWidth(sMethod->sizeHint().rwidth());
3137
sMethod->setMenu(pushMenu);
@@ -47,6 +53,9 @@ groove::groove(QWidget *parent) :
4753
resultView->setPalette(pal);*/
4854

4955
layout->addWidget(sMethod);
56+
#ifdef Q_WS_MAEMO_5
57+
setAttribute(Qt::WA_Maemo5AutoOrientation,true);
58+
#endif
5059
layout->addWidget(lineEdit);
5160
layout->addWidget(button);
5261
vlayout->addLayout(layout);
@@ -68,6 +77,7 @@ groove::groove(QWidget *parent) :
6877
connect(dButton,SIGNAL(clicked()),this, SLOT(play()));
6978
connect(stopButton,SIGNAL(clicked()),this,SLOT(stop()));
7079
connect(gs,SIGNAL(sKeyFound()),this,SLOT(startP()));
80+
connect(moreButton,SIGNAL(clicked()),this,SLOT(moreB()));
7181
}
7282
void groove::search()
7383
{
@@ -141,3 +151,7 @@ void groove::stop()
141151
{
142152
player->stop();
143153
}
154+
void groove::moreB()
155+
{
156+
qDebug() << "He pressed the button";
157+
}

groove.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public slots:
2020
void play();
2121
void startP();
2222
void stop();
23+
void moreB();
2324

2425
private:
2526
sPlayer *player;

gscom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void gscom::addProgressbar(QString debug)
274274
gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
275275
gradient.setColorAt(0.9, QColor::fromRgbF(0, 1, 0, 1));
276276
gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
277-
QBrush brush(gradient);
277+
QBrush brush(Qt::red);
278278
QStandardItem *pBar = new QStandardItem(text);
279279
pBar->setBackground(brush);
280280
pBar->setSelectable(false);

splayer.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,22 @@ sPlayer::~sPlayer()
2020
buffer->~QBuffer();
2121
media->~MediaNode();
2222
}
23+
void sPlayer::abortDownload()
24+
{
25+
reply->abort();
26+
}
2327

2428
void sPlayer::play(QString StreamKey,QUrl server)
2529
{
2630
if(playing)
2731
{
2832
//reply->abort();
2933
}
30-
34+
pd = new QProgressDialog("Downloading / Buffering.", "Cancel", 0, 100);
35+
pd->setValue(0);
36+
#ifdef Q_WS_MAEMO_5
37+
pd->setAttribute(Qt::WA_Maemo5AutoOrientation,true);
38+
#endif
3139
QNetworkRequest req;
3240
req.setUrl(server);
3341
qDebug() << server;
@@ -36,6 +44,7 @@ void sPlayer::play(QString StreamKey,QUrl server)
3644
buffer->open(buffer->ReadWrite | buffer->Truncate);
3745
connect(reply,SIGNAL(finished()),this,SLOT(start()));
3846
connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(putb(qint64,qint64)));
47+
connect(pd,SIGNAL(canceled()),this,SLOT(abortDownload()));
3948
media->stop();
4049
playing = false;
4150
startStreamT = QTime::currentTime();
@@ -101,6 +110,9 @@ void sPlayer::putb(qint64 b, qint64 t)
101110
}
102111
else
103112
{
113+
if(pd->maximum() != t)
114+
pd->setMaximum(t);
115+
pd->setValue(b);
104116

105117
buffer->buffer().append(reply->readAll());
106118
//qDebug() << buffer->bytesAvailable();
@@ -120,8 +132,9 @@ void sPlayer::putb(qint64 b, qint64 t)
120132
buffer->seek(last);
121133
//buffer->data().append(reply->readAll());*/
122134
//qDebug() << "Download speed (KB/S): " << b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024;
123-
if ( b >= t*0.05 && !playing && b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024 >= 35)
135+
if ( b >= t*0.05 && !playing && b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024 >= 25)
124136
{
137+
pd->hide();
125138
playing = true;
126139
//Start playback at 25% download
127140
media->setCurrentSource(Phonon::MediaSource(buffer));

splayer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <QObject>
66
#include <phonon>
77
#include "streamio.h"
8+
#include <QProgressDialog>
89

910
class sPlayer : public QObject
1011
{
@@ -21,6 +22,7 @@ class sPlayer : public QObject
2122
public slots:
2223
void start();
2324
void putb(qint64,qint64);
25+
void abortDownload();
2426
private:
2527
QNetworkAccessManager *manager;
2628
Phonon::AudioOutput *audioOutput;
@@ -31,6 +33,6 @@ public slots:
3133
bool playing;
3234
QObject *internal;
3335
QTime startStreamT;
36+
QProgressDialog *pd;
3437
};
35-
3638
#endif // SPLAYER_H

0 commit comments

Comments
 (0)