git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 27cd3051 authored by Mike Sheldon's avatar Mike Sheldon

Add support for loving and banning tracks in the Meego client

parent 71d536e7
......@@ -25,7 +25,7 @@ Page {
Column {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 20
spacing: 35
Image {
id: imgLibre
......@@ -39,28 +39,44 @@ Page {
id: lblStationName
text: " "
anchors.horizontalCenter: parent.horizontalCenter
}
Image {
id: imgCover
source: "empty-album.png"
anchors.horizontalCenter: parent.horizontalCenter
height: 200
width: 200
anchors.verticalCenterOffset: 5
font.weight: Font.Bold
font.pixelSize: 30
}
Row {
spacing: 50
anchors.horizontalCenter: parent.horizontalCenter
Label {
id: lblArtist
text: "Tuning in..."
}
Label {
id: lblSpacer
Image {
id: imgCover
source: "empty-album.png"
height: 200
width: 200
}
Label {
id: lblTrack
Column {
spacing: 40
anchors.verticalCenter: parent.verticalCenter
Row {
anchors.horizontalCenter: parent.horizontalCenter
Label {
id: lblArtist
text: "Tuning in..."
}
Label {
id: lblSpacer
}
Label {
id: lblTrack
}
}
Slider {
id: songProgress
value: 0.5
}
}
}
ButtonRow {
......@@ -73,6 +89,10 @@ Page {
anchors.verticalCenterOffset: -1
source: "ban.png"
}
onClicked: {
rootWin.ban();
rootWin.next();
}
}
Button {
......@@ -152,6 +172,9 @@ Page {
anchors.verticalCenterOffset: -1
source: "love.png"
}
onClicked: {
rootWin.love();
}
}
}
......
......@@ -12,6 +12,8 @@ PageStackWindow {
signal prev()
signal play()
signal pause()
signal love()
signal ban()
function openFile(file) {
var component = Qt.createComponent(file)
......@@ -24,6 +26,6 @@ PageStackWindow {
ToolBarLayout {
id: commonTools
visible: false
ToolIcon { iconId: "toolbar-back"; onClicked: { pageStack.pop(); } }
ToolIcon { iconId: "toolbar-back"; onClicked: { pageStack.pop(); pause(); } }
}
}
......@@ -33,6 +33,8 @@ int main(int argc, char *argv[])
QObject::connect(root, SIGNAL(prev()), &sc, SLOT(prev()));
QObject::connect(root, SIGNAL(play()), &sc, SLOT(play()));
QObject::connect(root, SIGNAL(pause()), &sc, SLOT(pause()));
QObject::connect(root, SIGNAL(love()), &sc, SLOT(love()));
QObject::connect(root, SIGNAL(ban()), &sc, SLOT(ban()));
QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
view.showFullScreen();
......
......@@ -207,11 +207,11 @@ void ServerComm::parseTrack(QDomNode trackNode) {
}
}
}
qDebug() << "Artist: " << t->artist;
playlist->append(*t);
}
void ServerComm::loadSong(int song) {
qDebug() << "Loading song";
currentSong = song;
Track t = playlist->at(song);
playing(t.artist, t.album, t.title, t.image);
......@@ -225,19 +225,50 @@ void ServerComm::loadSong(int song) {
}
void ServerComm::play() {
qDebug() << "Play";
media->play();
}
void ServerComm::pause() {
qDebug() << "Pausing";
media->pause();
}
void ServerComm::next() {
qDebug() << "Next song";
loadSong(++currentSong);
}
void ServerComm::prev() {
qDebug() << "Previous song";
if(currentSong > 0) {
loadSong(--currentSong);
}
}
void ServerComm::love() {
qDebug() << "Loving song";
Track t = playlist->at(currentSong);
QNetworkAccessManager *love_netman = new QNetworkAccessManager(this);
QUrl url = QUrl(ws_url);
QByteArray params;
params.append("method=track.love");
params.append("&sk="); params.append(ws_sk);
params.append("&artist="); params.append(t.artist);
params.append("&track="); params.append(t.title);
love_netman->post(QNetworkRequest(url), params);
}
void ServerComm::ban() {
qDebug() << "Banning song";
Track t = playlist->at(currentSong);
QNetworkAccessManager *ban_netman = new QNetworkAccessManager(this);
QUrl url = QUrl(ws_url);
QByteArray params;
params.append("method=track.ban");
params.append("&sk="); params.append(ws_sk);
params.append("&artist="); params.append(t.artist);
params.append("&track="); params.append(t.title);
ban_netman->post(QNetworkRequest(url), params);
}
......@@ -50,6 +50,8 @@ public slots:
void pause();
void next();
void prev();
void love();
void ban();
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment