Commit e76b120d authored by Mike Sheldon's avatar Mike Sheldon

Add support for tuning to new stations in the MeeGo client

parent 6c210991
......@@ -66,10 +66,12 @@ Page {
Button {
text: "New Station"
onClicked: rootWin.openFile("NewStationPage.qml")
}
Button {
text: "Preferences"
onClicked: rootWin.openFile("PreferencesPage.qml")
}
Button {
......
......@@ -4,6 +4,304 @@ import com.nokia.meego 1.0
Page {
id: stationPage
anchors.margins: rootWin.pageMargin
tools: commonTools
tools: preferenceTools
property int button_height: 100
property int button_width: 220
property string station_type: ""
states: [
State {
name: "inLandscape"
when: !rootWin.inPortrait
PropertyChanges {
target: grid_station_types
rows: 2
columns: 3
}
},
State {
name: "inPortrait"
when: rootWin.inPortrait
PropertyChanges {
target: grid_station_types
rows: 3
columns: 2
}
}
]
Image {
id: imgLibre
source: "librefm-logo.png"
anchors.horizontalCenter: parent.horizontalCenter
z: -1
}
Grid {
id: grid_station_types
anchors.centerIn: parent
anchors.verticalCenterOffset: 60
spacing: 10
Button {
height: button_height
width: button_width
text: "Tag Station"
onClicked: {
station_type = "globaltags";
lbl_input_name.text = "Tag Station"
txt_input.placeholderText = "e.g. folk, female vocals, rock, guitar, violin"
grid_station_types.visible = false;
grid_input.visible = true;
}
}
Button {
height: button_height
width: button_width
text: "Artist Station"
onClicked: {
station_type = "artist";
lbl_input_name.text = "Similar Artist Station"
txt_input.placeholderText = "e.g. The Acousticals, Brad Sucks, Hungry Lucy"
grid_station_types.visible = false;
grid_input.visible = true;
}
}
Button {
height: button_height
width: button_width
text: "Loved Station"
onClicked: {
grid_station_types.visible = false;
grid_loved_types.visible = true;
}
}
Button {
height: button_height
width: button_width
text: "Recommendation\nStation"
onClicked: {
grid_station_types.visible = false;
grid_recommended_types.visible = true;
}
}
Button {
height: button_height
width: button_width
text: "Mix Station"
onClicked: {
grid_station_types.visible = false;
grid_mix_types.visible = true;
}
}
Button {
height: button_height
width: button_width
text: "Neighbourhood\nStation"
onClicked: {
grid_station_types.visible = false;
grid_neighbourhood_types.visible = true;
}
}
}
Grid {
id: grid_loved_types
anchors.centerIn: parent
anchors.verticalCenterOffset: 60
spacing: 10
visible: false
Button {
height: button_height
width: button_width
text: "Your Loved\nStation"
onClicked: {
rootWin.openFile("StationPage.qml");
rootWin.tuneStationByName("my-loved");
}
}
Button {
height: button_height
width: button_width
text: "Someone Else's\nLoved Station"
onClicked: {
station_type = "loved";
lbl_input_name.text = "Loved Station";
txt_input.placeholderText = "e.g. elleo, mattl, etc.";
grid_loved_types.visible = false;
grid_input.visible = true;
}
}
Button {
height: button_height
width: button_width
text: "The Community's\nLoved Station"
onClicked: {
rootWin.openFile("StationPage.qml");
rootWin.tuneStation("librefm://community/loved");
}
}
}
Grid {
id: grid_recommended_types
anchors.centerIn: parent
anchors.verticalCenterOffset: 60
spacing: 10
visible: false
Button {
height: button_height
width: button_width
text: "Your Recommendation\nStation"
onClicked: {
rootWin.openFile("StationPage.qml");
rootWin.tuneStationByName("my-recommended");
}
}
Button {
height: button_height
width: button_width
text: "Someone Else's\nRecommendation Station"
onClicked: {
station_type = "recommended";
lbl_input_name.text = "Recommendation Station";
txt_input.placeholderText = "e.g. elleo, mattl, etc.";
grid_recommended_types.visible = false;
grid_input.visible = true;
}
}
}
Grid {
id: grid_mix_types
anchors.centerIn: parent
anchors.verticalCenterOffset: 60
spacing: 10
visible: false
Button {
height: button_height
width: button_width
text: "Your Mix Station"
onClicked: {
rootWin.openFile("StationPage.qml");
rootWin.tuneStationByName("my-mix");
}
}
Button {
height: button_height
width: button_width
text: "Someone Else's\nMix Station"
onClicked: {
station_type = "mix";
lbl_input_name.text = "Mix Station";
txt_input.placeholderText = "e.g. elleo, mattl, etc.";
grid_mix_types.visible = false;
grid_input.visible = true;
}
}
}
Grid {
id: grid_neighbourhood_types
anchors.centerIn: parent
anchors.verticalCenterOffset: 60
spacing: 10
visible: false
Button {
height: button_height
width: button_width
text: "Your Neighbourhood\nStation"
onClicked: {
rootWin.openFile("StationPage.qml");
rootWin.tuneStationByName("my-neighbourhood");
}
}
Button {
height: button_height
width: button_width
text: "Someone Else's\nNeighbourhood Station"
onClicked: {
station_type = "neighbours";
lbl_input_name.text = "Neighbourhood Station";
txt_input.placeholderText = "e.g. elleo, mattl, etc.";
grid_neighbourhood_types.visible = false;
grid_input.visible = true;
}
}
}
Grid {
id: grid_input
anchors.centerIn: parent
anchors.verticalCenterOffset: 60
spacing: 10
visible: false
rows: 3
columns: 1
Label {
anchors.horizontalCenter: parent.horizontalCenter
id: lbl_input_name
font.weight: Font.Bold
font.pixelSize: 30
}
TextField {
id: txt_input
width: 400
}
Button {
text: "Listen"
width: 400
onClicked: {
rootWin.openFile("StationPage.qml");
if (station_type == "artist") {
rootWin.tuneStation("librefm://artist/" + txt_input.text + "/similarartists");
} else if (station_type == "globaltags") {
rootWin.tuneStation("librefm://globaltags/" + txt_input.text);
} else {
rootWin.tuneStation("librefm://user/" + txt_input.text + "/" + station_type);
}
txt_input.text = "";
}
}
}
ToolBarLayout {
id: preferenceTools
visible: true
ToolIcon { iconId: "toolbar-back"; onClicked: {
if(grid_station_types.visible == true) {
pageStack.pop();
} else {
grid_station_types.visible = true;
grid_loved_types.visible = false;
grid_recommended_types.visible = false;
grid_mix_types.visible = false;
grid_neighbourhood_types.visible = false;
grid_input.visible = false;
}
}
}
}
}
import QtQuick 1.1
import com.nokia.meego 1.0
Page {
id: stationPage
anchors.margins: rootWin.pageMargin
tools: commonTools
Image {
id: imgLibre
source: "librefm-logo.png"
anchors.horizontalCenter: parent.horizontalCenter
z: -1
}
Column {
anchors.centerIn: parent
Button {
text: "Change Login Details"
onClicked: rootWin.openFile("LoginPage.qml")
}
}
}
......@@ -8,6 +8,7 @@ PageStackWindow {
signal login(string username, string password)
signal tuneStation(string station)
signal tuneStationByName(string name)
signal next()
signal prev()
signal play()
......
......@@ -29,6 +29,7 @@ int main(int argc, char *argv[])
view.rootContext()->setContextProperty("serverComm", &sc);
QObject::connect(root, SIGNAL(login(QString, QString)), &sc, SLOT(login(QString, QString)));
QObject::connect(root, SIGNAL(tuneStation(QString)), &sc, SLOT(tuneStation(QString)));
QObject::connect(root, SIGNAL(tuneStationByName(QString)), &sc, SLOT(tuneStationByName(QString)));
QObject::connect(root, SIGNAL(next()), &sc, SLOT(next()));
QObject::connect(root, SIGNAL(prev()), &sc, SLOT(prev()));
QObject::connect(root, SIGNAL(play()), &sc, SLOT(play()));
......
......@@ -40,6 +40,7 @@ void ServerComm::login(const QString &username, const QString &password) {
loginFailed();
return;
}
this->username = username;
loggingIn();
QString passMD5 = QCryptographicHash::hash(QByteArray(password.toAscii()), QCryptographicHash::Md5).toHex();
long timestamp = QDateTime::currentDateTime().toTime_t();
......@@ -135,6 +136,18 @@ void ServerComm::tuneStation(const QString &station) {
tune_netman->post(QNetworkRequest(url), params);
}
void ServerComm::tuneStationByName(const QString &name) {
if (name == "my-loved") {
tuneStation("librefm://user/" + username + "/loved");
} else if (name == "my-recommended") {
tuneStation("librefm://user/" + username + "/recommended");
} else if (name == "my-mix") {
tuneStation("librefm://user/" + username + "/mix");
} else if (name == "my-neighbourhood") {
tuneStation("librefm://user/" + username + "/neighbours");
}
}
void ServerComm::tuneReply(QNetworkReply *reply) {
QDomDocument xml("tuneresponse");
xml.setContent(reply);
......
......@@ -15,6 +15,7 @@ class ServerComm : public QObject
Q_OBJECT
public:
explicit ServerComm(QObject *parent = 0);
QString username;
private:
QString ws_sk;
......@@ -49,6 +50,7 @@ private slots:
public slots:
void login(const QString &username, const QString &password);
void tuneStation(const QString &station);
void tuneStationByName(const QString &name);
void getPlaylist();
void loadSong(int song);
void play();
......
......@@ -57,4 +57,5 @@ OTHER_FILES += \
StationPage.qml \
About.qml \
librefm.qml \
NewStationPage.qml
NewStationPage.qml \
PreferencesPage.qml
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