TableMenu.qml 3.87 KB
Newer Older
1 2 3 4
import QtQuick 2.0
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
5
import "../../view_models/BabeMenu"
6
import "../../utils"
7
import ".."
8

9
BabeMenu
10 11 12
{

    property int rate : 0
13
    property bool babe : false
14
    property string starColor : "#FFC107"
15
    property string starReg : foregroundColor
16
    property string starIcon: "draw-star"
17

18 19 20
    function rateIt(rank)
    {
        rate = rank
21
        if(bae.rateTrack(list.model.get(list.currentIndex).url, rate))
22
        {
23
            list.currentItem.trackRating.text = list.currentItem.setStars(rate)
24
            list.model.get(list.currentIndex).stars = rate
25
        }
26
        if(!root.isMobile)
27 28 29 30 31 32
            dismiss()
        else close()
    }

    function moodIt(color)
    {
33
        if(bae.colorTagTrack(list.model.get(list.currentIndex).url, color))
34 35
        {
            list.currentItem.trackMood = color
36
            list.model.get(list.currentIndex).art = color
37
        }
38
        if(!root.isMobile)
39 40
            dismiss()
        else close()
41 42
    }

43 44
    function babeIt(index)
    {
45
        console.log(index);
46 47
        var url = listModel.get(index).url
        var value = listModel.get(index).babe == "1" ? false : true
48 49 50

        if(bae.babeTrack(url, value))
            list.model.get(index).babe = value ? "1" : "0"
51 52

        return value
53 54 55 56 57 58
    }

    Label
    {
        id: titleLabel
        visible: root.isMobile
59
        padding: root.isMobile ? contentMargins : 0
60 61
        font.bold: true
        width: parent.width
62
        height: root.isMobile ? iconSizes.medium : 0
63 64 65 66 67
        horizontalAlignment: Qt.AlignHCenter
        elide: Text.ElideRight
        text: list.currentIndex >= 0 ? list.model.get(list.currentIndex).title : ""
        color: foregroundColor
    }
68

69
    BabeMenuItem
70
    {
71 72
        text: babe == false ? "Babe it" : "UnBabe it"
        onTriggered: babeIt(list.currentIndex)
73
    }
74

75
    BabeMenuItem
76
    {
77
        text: "Queue"
78
        onTriggered: list.queueTrack(list.currentIndex)
79
    }
80

81
    BabeMenuItem
82
    {
83 84 85 86 87 88
        text: "Save to..."
        onTriggered:
        {
            playlistDialog.tracks = [list.model.get(list.currentIndex).url]
            playlistDialog.open()
        }
89
    }
90

91
    BabeMenuItem
92
    {
93 94
        text: "Edit..."
        onTriggered: {}
95
    }
96

97
    BabeMenuItem
98
    {
99
        text: "Send to..."
100
        onTriggered: {}
101
    }
102

103
    BabeMenuItem
104
    {
105 106
        text: "Remove"
        onTriggered: listModel.remove(list.currentIndex)
107 108
    }

109
    BabeMenuItem
110
    {
111
        id: starsRow
112
        width: parent.width
113 114
        RowLayout
        {
115
            anchors.fill: parent
116
            width: parent.width
117
            BabeButton
118 119
            {
                Layout.fillWidth: true
120 121
                iconName: starIcon
                iconColor: rate >= 1 ? starColor :starReg
122 123
                onClicked: rateIt(1)
            }
124
            BabeButton
125 126
            {
                Layout.fillWidth: true
127

128 129
                iconName: starIcon
                iconColor: rate >= 2 ? starColor :starReg
130 131
                onClicked: rateIt(2)
            }
132
            BabeButton
133 134
            {
                Layout.fillWidth: true
135

136 137
                iconName: starIcon
                iconColor: rate >= 3 ? starColor :starReg
138 139 140 141

                onClicked: rateIt(3)
            }

142
            BabeButton
143 144
            {
                Layout.fillWidth: true
145

146 147
                iconName: starIcon
                iconColor: rate >= 4 ? starColor :starReg
148 149 150 151

                onClicked: rateIt(4)
            }

152
            BabeButton
153 154
            {
                Layout.fillWidth: true
155

156 157
                iconName: starIcon
                iconColor: rate >= 5 ? starColor :starReg
158 159 160 161 162 163 164

                onClicked: rateIt(5)
            }
        }

    }

165
    BabeMenuItem
166
    {
167
        id: colorsRow
168 169
        width: parent.width

170
        ColorTagsBar
171 172
        {
            anchors.fill: parent
173
            onColorClicked: moodIt(color)
174 175 176
        }
    }
}