import QtQuick 2.0
import QtQml 2.2
import Sailfish.Silica 1.0
import QtQuick.LocalStorage 2.0
import QtGraphicalEffects 1.0
import "../helpers/db.js" as Favorites

Dialog {
    id: settingsDialog

    Column {
        anchors.left: parent.left
        anchors.right: parent.right
        spacing: Theme.paddingMedium

        DialogHeader {}

        Label {
            anchors.right: parent.right
            anchors.rightMargin: Theme.paddingLarge
            color: Theme.highlightColor
            font.pixelSize: Theme.fontSizeLarge
            text: qsTr("Player settings")
        }

        Separator {
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.rightMargin: Theme.paddingMedium
            color: Theme.highlightColor
        }

        ComboBox {
            id: appStart
            width: parent.width
            label: qsTr("Auto play")
            anchors.margins: Theme.paddingLarge
            description: qsTr("What to do when AllRadio2 starts")
            currentIndex: Favorites.getSetting("appStart",0)
            menu: ContextMenu {
                MenuItem { text: qsTr("Off") }
                MenuItem { text: qsTr("Last played") }
                MenuItem { text: qsTr("Random favorite") }
            }
        }
        Label {
            anchors.right: parent.right
            anchors.rightMargin: Theme.paddingLarge
            color: Theme.highlightColor
            font.pixelSize: Theme.fontSizeLarge
            text: qsTr("Server settings")
        }

        Separator {
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.rightMargin: Theme.paddingMedium
            color: Theme.highlightColor
        }

        ComboBox {
            id: serverL
            width: parent.width
            label: qsTr("Server")
            anchors.margins: Theme.paddingLarge
            description: qsTr("Select anohter server")
            //currentIndex: Favorites.getSetting("appStart",0)
            menu : ContextMenu {
                id: contextMenu
                Column {
                    Repeater {

                        model: radioBrowser.serversModel
                        delegate: QtObject {
                            property Item child: MenuItem {
                                text: modelData
                                onClicked: console.log("***")
                            }
                        }
                    }
                }
            }

            /*   menu: ContextMenu {
                MenuItem { text: qsTr("None") }
                MenuItem { text: qsTr("Last played") }
                MenuItem { text: qsTr("Random favorite") }
            }*/
        }
    }

    onAccepted: Favorites.setSetting("appStart",appStart.currentIndex)

}

