Commit 162a39c9 authored by kempe's avatar kempe

Implemented custom stations as favorites.

This closes #3Signed-off-by: kempe's avatarkempe <l.f.kempe@gmail.com>
parent b28f0a68
......@@ -70,5 +70,7 @@ DISTFILES += \
qml/pages/BrowseByCategoryPageForm.ui.qml \
qml/pages/BrowseByCategoryPage.qml \
qml/pages/SettingsPageForm.ui.qml \
qml/pages/SettingsPage.qml
qml/pages/SettingsPage.qml \
qml/pages/FavoritePageForm.ui.qml \
qml/pages/FavoritePage.qml
......@@ -8,6 +8,7 @@ import Sailfish.Silica 1.0
*/
ContextMenu {
signal removeFavorite()
signal editFavorite()
MenuItem {
text: qsTr("Remove from favorite")
......@@ -17,4 +18,9 @@ ContextMenu {
});
}
}
MenuItem {
text: qsTr("Edit favorite")
onClicked: editFavorite(index)
}
}
import QtQuick 2.4
FavoritePageForm {
onDone: {
var item = station ? station : {}
item.url = url
item.name = name
item.stationLogo = logo
item.country = country
item.genre = genre
station = item
}
}
import QtQuick 2.6
import Sailfish.Silica 1.0
Dialog {
id: customFavoriteDialog
property var station
property alias url: urlField.text
property alias name: nameField.text
property alias logo: logoField.text
property alias country: countryField.text
property alias genre: genreField.text
canAccept: url && name
SilicaFlickable {
id: flickable
anchors.fill: parent
contentHeight: layout.height
VerticalScrollDecorator { flickable: flickable }
Column {
id: layout
width: parent.width
DialogHeader { }
TextField {
id: urlField
width: parent.width
placeholderText: qsTr("http://mystation.com/stream.mp3")
text: station ? station.url : ""
label: qsTr("URL")
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: nameField.focus = true
}
TextField {
id: nameField
width: parent.width
placeholderText: qsTr("My Station")
text: station ? station.name : ""
label: qsTr("Name")
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: logoField.focus = true
}
TextField {
id: logoField
width: parent.width
placeholderText: qsTr("http://mystation.com/logo.jpg")
text: station ? station.stationLogo : ""
label: qsTr("Logo")
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: countryField.focus = true
}
TextField {
id: countryField
width: parent.width
placeholderText: qsTr("Sweden")
text: station ? station.country : ""
label: qsTr("Country")
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: genreField.focus = true
}
TextField {
id: genreField
width: parent.width
placeholderText: "Pop"
text: station ? station.genre : ""
label: "Genre"
EnterKey.iconSource: "image://theme/icon-m-enter-accept"
EnterKey.onClicked: customFavoriteDialog.accept()
}
}
}
}
......@@ -14,9 +14,28 @@ FavoritesPageForm {
// Recives index as parameter from signal
onRemoveFavorite: FavoritesUtils.removeFavorite(getStation(index));
onEditFavorite: {
var station = getStation(index);
var dialog = pageStack.push(Qt.resolvedUrl("FavoritePage.qml"),
{station: station})
handleCustomFavorite(dialog);
}
addCustomFavorite.onClicked: {
var dialog = pageStack.push(Qt.resolvedUrl("FavoritePage.qml"))
handleCustomFavorite(dialog);
}
function getStation(index) {
return favoriteModel.get(index);
}
function handleCustomFavorite(dialog) {
dialog.accepted.connect(function() {
console.log(JSON.stringify(dialog.station))
FavoritesUtils.addFavorite(dialog.station)
})
}
Component.onCompleted: FavoritesUtils.init(favoriteModel)
}
......@@ -9,10 +9,12 @@ Page {
signal playFavorite(int index)
signal removeFavorite(int index)
signal editFavorite(int index)
allowedOrientations: Orientation.All
property bool firstPage: true
property alias favoriteModel: favoriteModel
property alias addCustomFavorite: actionAddCustomFavorite
SilicaListView {
id: favoritesListView
......@@ -20,7 +22,13 @@ Page {
anchors.fill: parent
NavigationMenu {
id: pulleyMeny
id: navigationMenu
MenuItem {
id: actionAddCustomFavorite
text: qsTr("Add Custom")
}
}
header: Column {
......@@ -57,6 +65,11 @@ Page {
onRemoveFavorite: removeFavorite(index)
}
Connections {
target: contextMenu
onEditFavorite: editFavorite(index)
}
}
}
}
......
......@@ -65,12 +65,51 @@
<translation type="unfinished">Ställ</translation>
</message>
</context>
<context>
<name>FavoritePageForm.ui</name>
<message>
<source>http://mystation.com/stream.mp3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>URL</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>My Station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>http://mystation.com/logo.jpg</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Logo</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sweden</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Country</source>
<translation type="unfinished">Land</translation>
</message>
</context>
<context>
<name>FavoritesListContextMenu</name>
<message>
<source>Remove from favorite</source>
<translation type="unfinished">Ta bort från favoriter</translation>
</message>
<message>
<source>Edit favorite</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FavoritesPageForm.ui</name>
......@@ -78,6 +117,10 @@
<source>Favorites</source>
<translation type="unfinished">Favoriter</translation>
</message>
<message>
<source>Add Custom</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NavigationMenuForm.ui</name>
......
......@@ -65,12 +65,51 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FavoritePageForm.ui</name>
<message>
<source>http://mystation.com/stream.mp3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>URL</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>My Station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>http://mystation.com/logo.jpg</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Logo</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sweden</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Country</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FavoritesListContextMenu</name>
<message>
<source>Remove from favorite</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit favorite</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FavoritesPageForm.ui</name>
......@@ -78,6 +117,10 @@
<source>Favorites</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add Custom</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NavigationMenuForm.ui</name>
......
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