SettingsView.qml 4.65 KB
Newer Older
Camilo Higuita's avatar
Camilo Higuita committed
1 2 3 4 5 6 7 8
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import Qt.labs.platform 1.0

import "../utils/Icons.js" as MdiFont
import "../utils"

9
Page
Camilo Higuita's avatar
Camilo Higuita committed
10 11 12
{
    id: settingsView

13 14
    signal iconSizeChanged(int size)

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    function load(folderUrl)
    {
        folderPicker.dirList.clearTable()
        var dirs = bae.getDirs(folderUrl)
        for(var path in dirs)
        {
            folderPicker.dirList.model.append(dirs[path])
        }
    }

    function scanDir(folderUrl)
    {
        bae.scanDir(folderUrl)
    }

    background: Rectangle
    {
        anchors.fill: parent
        color: bae.backgroundColor()
        z: -999
    }
36

Camilo Higuita's avatar
Camilo Higuita committed
37 38 39
    FolderDialog
    {
        id: folderDialog
40

Camilo Higuita's avatar
Camilo Higuita committed
41 42 43
        folder: StandardPaths.standardLocations(StandardPaths.MusicLocation)[0]
        onAccepted:
        {
44
            listModel.append({url: folder.toString()})
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
            scanDir(folder.toString())
        }
    }
    FolderPicker
    {

        id: folderPicker
        Connections
        {
            target: folderPicker
            onPathClicked:
            {
                load(path)
            }
            onAccepted:
            {
                listModel.append({url: path})
                scanDir(path)
            }
            onGoBack: load(path)

Camilo Higuita's avatar
Camilo Higuita committed
66 67 68 69 70 71 72 73 74 75
        }
    }


    Rectangle
    {
        anchors.centerIn: parent
        width: parent.width /2
        height: parent.height/2
        radius: 4
76 77
color: bae.altColor()

Camilo Higuita's avatar
Camilo Higuita committed
78 79 80 81 82

        Label
        {
            anchors.bottom: sources.top
            text: "Sources"
83 84 85
            font.bold: true
            padding: 10
            color: bae.foregroundColor()
Camilo Higuita's avatar
Camilo Higuita committed
86 87 88 89 90 91 92 93
        }

        ListView
        {
            id: sources
            anchors.fill: parent
            width: parent.width
            height: parent.height
Camilo Higuita's avatar
Camilo Higuita committed
94
            clip: true
95 96 97 98

            visible : !bae.isMobile()


Camilo Higuita's avatar
Camilo Higuita committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
            ListModel
            {
                id: listModel
            }

            model: listModel

            delegate: ItemDelegate
            {
                width: parent.width

                contentItem: ColumnLayout
                {
                    spacing: 2
                    width: parent.width

                    Label
                    {
                        id: sourceUrl
                        width: parent.width
119
                        text: url
Camilo Higuita's avatar
Camilo Higuita committed
120 121 122
                        elide: Text.ElideRight
                        Layout.fillWidth: true
                        font.pointSize: 10
123
                        color: bae.foregroundColor()
Camilo Higuita's avatar
Camilo Higuita committed
124 125 126 127 128
                    }
                }
            }


129 130
            Component.onCompleted:
            {
131
                var map = bae.get("select url from sources")
132 133 134 135 136
                for(var i in map)
                {
                    model.append(map[i])
                }
            }
Camilo Higuita's avatar
Camilo Higuita committed
137 138 139 140
        }

        Row
        {
141
            id: sourceActions
Camilo Higuita's avatar
Camilo Higuita committed
142 143
            anchors.top: sources.bottom
            width: parent.width
144
            visible : !bae.isMobile()
Camilo Higuita's avatar
Camilo Higuita committed
145 146 147 148

            ToolButton
            {
                id: addSource
149

Camilo Higuita's avatar
Camilo Higuita committed
150 151 152 153 154 155 156
                Icon
                {
                    text: MdiFont.Icon.plus
                }

                onClicked:
                {
157 158 159 160 161 162 163
                    if(bae.isMobile())
                    {
                        folderPicker.open()
                        load(StandardPaths.standardLocations(StandardPaths.HomeLocation)[0])
                    }else
                        folderDialog.open()

Camilo Higuita's avatar
Camilo Higuita committed
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
                }
            }

            ToolButton
            {
                id: removeSource
                Icon
                {
                    id: albumsIcon
                    text: MdiFont.Icon.minus
                }

                onClicked:
                {

                }

            }
        }

184 185 186 187 188 189 190 191 192 193 194 195 196 197
        Row
        {
            anchors.top: sourceActions.bottom
            width: parent.width
            height: iconSize.height

            Label
            {
                width: parent.width - iconSize.width
                height: parent.height

                text: "Toolbar icon size"
                elide: Text.ElideRight
                verticalAlignment: Text.AlignVCenter
198 199

                color: bae.foregroundColor()
200 201 202 203 204 205 206 207 208 209 210 211 212 213
            }

            ComboBox
            {
                id: iconSize
                width: 100
                model: ListModel
                {
                    id: sizes
                    ListElement { size: 16 }
                    ListElement { size: 24 }
                    ListElement { size: 32 }
                }

214
                currentIndex:  1
215 216 217
                onCurrentIndexChanged: iconSizeChanged(sizes.get(currentIndex).size )
            }
        }
Camilo Higuita's avatar
Camilo Higuita committed
218 219
    }
}