TableMenu.qml 7.82 KB
Newer Older
1 2 3 4 5
import QtQuick 2.0
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../utils/Icons.js" as MdiFont
6
import "../utils/Help.js" as H
7 8 9 10 11 12 13
import "../utils"

Menu
{
    id: rootMenu
    x: parent.width / 2 - width / 2
    y: parent.height / 2 - height / 2
14
    modal: bae.isMobile()
15 16
    focus: true

17 18 19

    property int rate : 0
    property string starColor : "#FFC107"
20
    property string starReg : bae.foregroundColor()
21
    property string starIcon: MdiFont.Icon.star
22 23
    property int assetsize : menuItemHeight/2
    property int menuItemHeight : bae.isMobile() ? 48 : 32;
24

25 26 27 28 29

    enter: Transition {
        NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
    }

30 31 32
    function rateIt(rank)
    {
        rate = rank
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
        if(bae.rateTrack(list.model.get(currentRow).url, rate))
        {
            list.currentItem.trackRating.text = rate
            list.model.get(currentRow).stars = rate
        }
        if(!bae.isMobile())
            dismiss()
        else close()
    }

    function moodIt(color)
    {
        if(bae.moodTrack(list.model.get(currentRow).url, color))
        {
            list.currentItem.trackMood = color
            list.model.get(currentRow).art = color
        }
        if(!bae.isMobile())
            dismiss()
        else close()
53 54 55
    }


56
    background: Rectangle
57
    {
58 59
        implicitWidth: 200
        implicitHeight: 40
60
        color: bae.altColor()
61
        border.color: bae.midLightColor()
62
        border.width: 1
63
        radius: 3
64

65
    }
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82


    //    Label
    //    {
    //        id: titleLabel
    //        visible: bae.isMobile()
    //        padding: bae.isMobile() ? 10 : 0
    //        font.bold: true
    //        width: parent.width
    //        height: bae.isMobile() ? menuItemHeight : 0
    //        horizontalAlignment: Qt.AlignHCenter
    //        elide: Text.ElideRight
    //        text: currentRow >= 0 ? list.model.get(currentRow).title : ""
    //        color: bae.foregroundColor()
    //    }

    TableMenuItem
83
    {
84 85 86
        height: menuItemHeight
        txt: "Babe it"
        onTriggered: {}
87
    }
88 89

    TableMenuItem
90
    {
91 92
        height: menuItemHeight
        txt: "Queue"
93
        onTriggered: list.queueTrack(list.currentIndex)
94
    }
95 96

    TableMenuItem
97
    {
98 99 100
        height: menuItemHeight
        txt: "Edit..."
        onTriggered: {}
101
    }
102 103

    TableMenuItem
104
    {
105 106
        height: menuItemHeight
        txt: "Remove"
107
        onTriggered: listModel.remove(list.currentIndex)
108
    }
109 110

    TableMenuItem
111
    {
112 113 114
        height: menuItemHeight
        txt: "Save..."
        onTriggered: {}
115
    }
116 117

    TableMenuItem
118
    {
119 120 121
        height: menuItemHeight
        txt: "Send to..."
        onTriggered: {}
122 123
    }

124

125 126
    MenuItem
    {
127 128 129 130
        height: menuItemHeight
        hoverEnabled: true
        padding: 10

131 132
        RowLayout
        {
133
            anchors.fill: parent
134 135 136 137 138
            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter
Camilo Higuita's avatar
Camilo Higuita committed
139
                BabeIcon
140 141 142
                {
                    text: starIcon
                    color: rate >= 1 ? starColor :starReg
143
                    iconSize: assetsize
144 145 146 147 148 149 150 151 152
                }

                onClicked: rateIt(1)
            }
            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter
Camilo Higuita's avatar
Camilo Higuita committed
153
                BabeIcon
154 155 156
                {
                    text: starIcon
                    color: rate >= 2 ? starColor :starReg
157
                    iconSize: assetsize
158 159 160 161 162 163 164 165 166
                }

                onClicked: rateIt(2)
            }
            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter
Camilo Higuita's avatar
Camilo Higuita committed
167
                BabeIcon
168 169 170
                {
                    text: starIcon
                    color: rate >= 3 ? starColor :starReg
171
                    iconSize: assetsize
172 173 174 175 176
                }

                onClicked: rateIt(3)
            }

177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter
                BabeIcon
                {
                    text: starIcon
                    color: rate >= 4 ? starColor :starReg
                    iconSize: assetsize
                }

                onClicked: rateIt(4)
            }

            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter
                BabeIcon
                {
                    text: starIcon
                    color: rate >= 5 ? starColor :starReg
                    iconSize: assetsize
                }

                onClicked: rateIt(5)
            }
        }

    }

    MenuItem
    {
        height: menuItemHeight
        hoverEnabled: true
        padding: 10
        RowLayout
        {
            anchors.fill: parent
            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter

                Rectangle
                {
                    anchors.centerIn: parent
                    width: assetsize
                    height: assetsize
                    color: bae.moodColor(0)
                    radius: 2
                    border.color: bae.altColor()
                    border.width: 1
                }

235
                onClicked: moodIt(bae.moodColor(0))
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
            }
            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter

                Rectangle
                {
                    anchors.centerIn: parent
                    width: assetsize
                    height: assetsize
                    color: bae.moodColor(1)
                    radius: 2
                    border.color: bae.altColor()
                    border.width: 1
                }

254
                onClicked: moodIt(bae.moodColor(1))
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
            }
            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter

                Rectangle
                {
                    anchors.centerIn: parent
                    width: assetsize
                    height: assetsize
                    color: bae.moodColor(2)
                    radius: 2
                    border.color: bae.altColor()
                    border.width: 1
                }

273
                onClicked: moodIt(bae.moodColor(2))
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
            }
            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter

                Rectangle
                {
                    anchors.centerIn: parent
                    width: assetsize
                    height: assetsize
                    color: bae.moodColor(3)
                    radius: 2
                    border.color: bae.altColor()
                    border.width: 1
                }

292
                onClicked: moodIt(bae.moodColor(3))
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
            }

            ToolButton
            {
                Layout.fillHeight: true
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignCenter

                Rectangle
                {
                    anchors.centerIn: parent
                    width: assetsize
                    height: assetsize
                    color: bae.moodColor(4)
                    radius: 2
                    border.color: bae.altColor()
                    border.width: 1
                }

312
                onClicked: moodIt(bae.moodColor(4))
313
            }
314 315 316
        }
    }
}