main.qml 7.15 KB
Newer Older
Camilo Higuita's avatar
Camilo Higuita committed
1 2 3 4
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtLocation 5.9
import QtQuick.Layouts 1.3
5
import QtGraphicalEffects 1.0
6
//import org.kde.kirigami 2.0 as Kirigami
7 8

import "utils/Icons.js" as MdiFont
Camilo Higuita's avatar
Camilo Higuita committed
9
import "utils/Player.js" as Player
10
import "utils"
Camilo Higuita's avatar
Camilo Higuita committed
11 12 13
import "view_models"
import "widgets"

14 15
//Kirigami.ApplicationWindow
ApplicationWindow
Camilo Higuita's avatar
Camilo Higuita committed
16
{
17
    id: root
Camilo Higuita's avatar
Camilo Higuita committed
18 19 20 21 22
    visible: true
    width: 400
    height: 500
    title: qsTr("Babe")

23 24 25 26

    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }


27
    //    property int columnWidth: Kirigami.Units.gridUnit * 13
28
    property int columnWidth: Math.sqrt(root.width*root.height)*0.4
29
    property int currentView : 0
30
    property int iconSize
31
    property alias mainPlaylist : mainPlaylist
32
    //    minimumWidth: columnWidth
33

34 35
    //    pageStack.defaultColumnWidth: columnWidth
    //    pageStack.initialPage: [playlistPage, views]
36 37


38
    onWidthChanged: if(bae.isMobile())
39 40 41 42 43
                    {
                        if(root.width>root.height)
                            mainPlaylist.cover.visible = false
                        else  mainPlaylist.cover.visible = true
                    }
44 45


46 47
    onClosing: Player.savePlaylist()

48 49 50 51 52 53 54 55 56 57
    function runSearch()
    {
        if(searchInput.text)
        {
            var query = searchInput.text
            var queries = query.split(",")
            var res = bae.searchFor(queries)

            searchView.populate(res)
            //                albumsView.filter(res)
Camilo Higuita's avatar
Camilo Higuita committed
58
            currentView = 5
59 60
        }
    }
61

62 63
    Connections
    {
Camilo Higuita's avatar
Camilo Higuita committed
64
        target: player
65
        onPos: mainPlaylist.progressBar.value = pos
Camilo Higuita's avatar
Camilo Higuita committed
66
        onFinished: Player.nextTrack()
67

68 69
    }

70 71
    Connections
    {
72
        target: bae
73 74 75 76 77 78 79 80 81 82
        onRefreshTables:
        {
            tracksView.clearTable()
            albumsView.clearGrid()
            artistsView.clearGrid()

            tracksView.populate()
            albumsView.populate()
            artistsView.populate()
        }
83 84 85 86 87 88

        onTrackLyricsReady:
        {
            if(url === root.mainPlaylist.currentTrack.url)
                root.mainPlaylist.infoView.lyrics = lyrics
        }
89 90 91

        onSkipTrack: Player.nextTrack()
        onBabeIt: Player.babeTrack()
92 93
    }

Camilo Higuita's avatar
Camilo Higuita committed
94 95 96 97
    header: BabeBar
    {
        id: mainToolbar
        visible: true
98
        size: iconSize
99
        currentIndex: currentView
Camilo Higuita's avatar
Camilo Higuita committed
100

101 102 103 104 105
        onPlaylistViewClicked: currentView = 0
        onTracksViewClicked: currentView = 1
        onAlbumsViewClicked: currentView = 2
        onArtistsViewClicked: currentView = 3
        onPlaylistsViewClicked: currentView = 4
Camilo Higuita's avatar
Camilo Higuita committed
106
        onSettingsViewClicked: settingsDrawer.visible ? settingsDrawer.close() : settingsDrawer.open()
Camilo Higuita's avatar
Camilo Higuita committed
107 108
    }

109 110 111 112
    footer: Rectangle
    {
        id: searchBox
        width: parent.width
113
        height: 48
114
        color: bae.midColor()
115 116 117 118 119 120

        TextInput
        {
            id: searchInput
            anchors.fill: parent
            anchors.centerIn: parent
121
            color: bae.foregroundColor()
122 123
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment:  Text.AlignVCenter
124
            selectByMouse: !bae.isMobile()
125 126
            selectionColor: bae.hightlightColor()
            selectedTextColor: bae.foregroundColor()
127 128
            property string placeholderText: "Search..."

129 130 131 132 133 134 135 136 137 138
            //            Label
            //            {
            //                text: searchInput.placeholderText
            //                visible: !(searchInput.focus || searchInput.text)
            //                horizontalAlignment: Text.AlignHCenter
            //                verticalAlignment:  Text.AlignVCenter
            //                font.bold: true
            //                color: bae.foregroundColor()
            //            }

Camilo Higuita's avatar
Camilo Higuita committed
139
            BabeIcon
140
            {
141
                anchors.centerIn: parent
142
                visible: !(searchInput.focus || searchInput.text)
143 144
                id: searchBtn
                text: MdiFont.Icon.magnify
145
                color: bae.foregroundColor()
146 147
            }

148

149 150 151 152 153
            //            onTextChanged:
            //            {
            //                if(searchInput.text.length===0)
            //                    albumsView.populate()
            //            }
154

155 156
            onAccepted: runSearch()
        }
157 158


159 160
    }

161
    background: Rectangle
162 163
    {
        anchors.fill: parent
164
        color: bae.altColor()
165 166 167
        z: -999
    }

Camilo Higuita's avatar
Camilo Higuita committed
168 169 170 171 172
    SettingsView
    {
        id: settingsDrawer
        onIconSizeChanged: iconSize = size
    }
173 174


175
    Page
Camilo Higuita's avatar
Camilo Higuita committed
176
    {
177
        id: views
178 179
        width: parent.width
        height: parent.height
180
        clip: true
Camilo Higuita's avatar
Camilo Higuita committed
181

182
        transform: Translate {
Camilo Higuita's avatar
Camilo Higuita committed
183 184
            x: (settingsDrawer.position * views.width * 0.33)*-1
        }
185

186
        Column
Camilo Higuita's avatar
Camilo Higuita committed
187
        {
188 189
            width: parent.width
            height: parent.height
Camilo Higuita's avatar
Camilo Higuita committed
190

191
            SwipeView
Camilo Higuita's avatar
Camilo Higuita committed
192
            {
193 194
                id: swipeView
                width: parent.width
195 196 197 198
                height: parent.height

                onCurrentIndexChanged: currentView = currentIndex

199
                Component.onCompleted: contentItem.interactive = bae.isMobile()
200

201
                currentIndex: currentView
202 203


204 205 206
                MainPlaylist
                {
                    id: mainPlaylist
207 208 209 210 211 212
                    Connections
                    {
                        target: mainPlaylist
                        onCoverPressed: Player.appendAlbum(tracks)
                        onCoverDoubleClicked: Player.playAlbum(tracks)
                    }
213
                }
214

215

216 217
                TracksView
                {
218
                    id: tracksView
219 220 221 222 223 224 225
                    Connections
                    {
                        target: tracksView
                        onRowClicked: Player.addTrack(tracksView.model.get(index))
                        onQuickPlayTrack: Player.quickPlay(tracksView.model.get(index))
                    }

226
                }
Camilo Higuita's avatar
Camilo Higuita committed
227

Camilo Higuita's avatar
Camilo Higuita committed
228
                AlbumsView
229
                {
230
                    id: albumsView
231 232 233 234 235 236 237 238
                    Connections
                    {
                        target: albumsView
                        onRowClicked: Player.addTrack(track)
                        onPlayAlbum: Player.playAlbum(tracks)
                        onAppendAlbum: Player.appendAlbum(tracks)
                        onPlayTrack: Player.quickPlay(track)
                    }
Camilo Higuita's avatar
Camilo Higuita committed
239
                }
240

Camilo Higuita's avatar
Camilo Higuita committed
241 242
                ArtistsView
                {
243
                    id: artistsView
244 245 246 247 248 249 250 251 252

                    Connections
                    {
                        target: artistsView
                        onRowClicked: Player.addTrack(track)
                        onPlayAlbum: Player.playAlbum(tracks)
                        onAppendAlbum: Player.appendAlbum(tracks)
                        onPlayTrack: Player.quickPlay(track)
                    }
Camilo Higuita's avatar
Camilo Higuita committed
253
                }
254

255
                PlaylistsView {}
Camilo Higuita's avatar
Camilo Higuita committed
256

257

258 259 260
                SearchTable
                {
                    id: searchView
261 262 263 264 265 266
                    Connections
                    {
                        target: searchView
                        onRowClicked: Player.addTrack(searchView.model.get(index))
                        onQuickPlayTrack: Player.quickPlay(searchView.model.get(index))
                    }
267 268
                }

269 270 271
            }
        }
    }
Camilo Higuita's avatar
Camilo Higuita committed
272
}