Commit c45e9650 authored by Camilo Higuita's avatar Camilo Higuita

move albums and artists view to use kirigami page row instead of drawer

parent f2a16c3c
......@@ -16,3 +16,4 @@ SOURCES += \
LIBS += -ltag
WEBENGINE_CONFIG+=proprietary_codecs
......@@ -99,7 +99,7 @@ Kirigami.ApplicationWindow
property int columnWidth: Kirigami.Units.gridUnit * 17
property int coverSize: focusMode ? columnWidth :
(isAndroid ? Math.sqrt(root.width * root.height) * 0.4 :
columnWidth * (isMobile ? 0.7 : 0.6))
columnWidth * (isMobile ? 0.7 : 0.6))
/***************************************************/
......@@ -806,27 +806,92 @@ Kirigami.ApplicationWindow
AlbumsView
{
id: albumsView
Connections
{
target: albumsView
onRowClicked: Player.addTrack(track)
onPlayAlbum: Player.playAll(tracks)
onAppendAlbum: Player.appendAll(tracks)
onPlayTrack: Player.quickPlay(track)
onAlbumCoverClicked:
{
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
albumsView.table.headerBarTitle = album
albumsView.populateTable(query)
}
onAlbumCoverPressedAndHold:
{
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
var map = bae.get(query)
albumsView.playAlbum(map)
}
onPlayAll:
{
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
query = query.arg(data.artist)
var tracks = bae.get(query)
Player.playAll(tracks)
}
onAppendAll:
{
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
var tracks = bae.get(query)
Player.appendAll(tracks)
}
}
}
ArtistsView
AlbumsView
{
id: artistsView
Connections
{
target: artistsView
onRowClicked: Player.addTrack(track)
onPlayAlbum: Player.playAll(tracks)
onAppendAlbum: Player.appendAll(tracks)
onPlayTrack: Player.quickPlay(track)
onAlbumCoverClicked:
{
var query = Q.GET.artistTracks_.arg(artist)
artistsView.table.headerBarTitle = artist
artistsView.populateTable(query)
}
onAlbumCoverPressedAndHold:
{
var query = Q.GET.artistTracks_.arg(artist)
var map = bae.get(query)
artistsView.playAlbum(map)
}
onPlayAll:
{
var query = Q.GET.artistTracks_.arg(artist)
query = query.arg(data.artist)
var tracks = bae.get(query)
Player.playAll(tracks)
}
onAppendAll:
{
var query = Q.GET.artistTracks_.arg(artist)
var tracks = bae.get(query)
Player.appendAll(tracks)
}
}
}
......
......@@ -5,7 +5,6 @@
<file>utils/Icons.js</file>
<file>utils/materialdesignicons-webfont.ttf</file>
<file>widgets/TracksView.qml</file>
<file>widgets/ArtistsView.qml</file>
<file>widgets/AlbumsView.qml</file>
<file>assets/cover.png</file>
<file>data_models/db_model.qml</file>
......
......@@ -13,7 +13,8 @@ BabePopup
WebEngineView
{
anchors.fill: parent
url: "https://accounts.spotify.com/en/authorize?response_type=token&client_id=a49552c9276745f5b4752250c2d84367&scope=streaming user-read-private user-read-birthdate user-read-email&redirect_uri=vvave:%2F%2Fcallback"
url: "https://accounts.spotify.com/en/authorize?response_type=token&client_id=a49552c9276745f5b4752250c2d84367&scope=streaming user-read-private user-read-email&redirect_uri=vvave:%2F%2Fcallback"
onLoadingChanged:
{
var myUrl = url.toString()
......
......@@ -33,7 +33,7 @@ Page
{
loginLoader.source = "LoginForm.qml"
loginLoader.item.parent = spotifyView
loginLoader.item.open()
}
......
......@@ -12,7 +12,7 @@
<!-- We will insert our code here. -->
<script>
window.onSpotifyWebPlaybackSDKReady = () => {
const token = 'BQD-clXoAed6M7WCfM4BxxVHQ5LC0sGgu5adY29NIkF5fS1mf-_t_48CNFTk4UYfenLC4qx9eKY7gtQ5sfiZOginbjR_tWfbc2rHoY90p_vILZlqHeWzNttfDSo7vKckLbReeQ_2Iv8g1JOP-SepvaBPbtAGMSQx';
const token = 'BQAoL8vs__zD6Cdz4M4_xgIuJxAFKP6QlwgUEVs-eOe5pQmQEuSEML4VIM2gO0hjKQSOkhVFQOg0K_RHxz3mXkUNcA8v8-e4yFfJEByEun72KUslpbww6EUCeTqsi6L9E2S4dYCx3cnl-0qs8fSfD60W1_YglG3B';
const player = new Spotify.Player({
name: 'Web Playback SDK Quick Start Player',
getOAuthToken: cb => { cb(token); }
......
.import "../db/Queries.js" as Q
function rootWidth()
{
return root.width;
......@@ -58,15 +61,15 @@ function refreshTracks()
function refreshAlbums()
{
albumsView.clearGrid()
albumsView.populate()
albumsView.grid.clearGrid()
albumsView.populate(Q.GET.allAlbumsAsc)
}
function refreshArtists()
{
artistsView.clearGrid()
artistsView.populate()
artistsView.grid.clearGrid()
artistsView.populate(Q.GET.allArtistsAsc)
}
function notify(title, body)
......
......@@ -8,177 +8,101 @@ import "../view_models/BabeTable"
import "../db/Queries.js" as Q
import org.kde.kirigami 2.2 as Kirigami
BabeGrid
Kirigami.PageRow
{
id: albumsViewGrid
visible: true
id: albumsPageRoot
clip: true
separatorVisible: wideMode
initialPage: [albumsViewGrid, albumsViewTable]
defaultColumnWidth: albumsViewGrid.albumCoverSize * 4
interactive: currentIndex === 1
property alias list : drawerList.list
property alias table : drawerList
property alias grid : albumsViewGrid
property alias table : albumsViewTable
signal rowClicked(var track)
signal playAlbum(var tracks)
signal playTrack(var track)
signal queueTrack(var track)
signal appendAlbum(var tracks)
// transform: Translate
// {
// y: (drawer.height)*-1
// }
onBgClicked: if(drawer.visible) drawer.close()
onFocusChanged: drawer.close()
signal appendAll(string album, string artist)
signal playAll(string album, string artist)
signal albumCoverClicked(string album, string artist)
signal albumCoverPressedAndHold(string album, string artist)
Drawer
BabeGrid
{
id: drawer
id: albumsViewGrid
visible: true
onAlbumCoverClicked: albumsPageRoot.albumCoverClicked(album, artist)
onAlbumCoverPressed: albumCoverPressedAndHold(album, artist)
y: parent.height-height-root.footer.height
}
width: albumsViewGrid.width
BabeTable
{
id: albumsViewTable
anchors.fill: parent
trackNumberVisible: true
headerBarVisible: true
headerBarExit: !albumsPageRoot.wideMode
headerBarExitIcon: "go-previous"
coverArtVisible: true
quickPlayVisible: true
focus: true
height:
onRowClicked:
{
var customHeight = (drawerList.count*rowHeight)+toolBarHeight
if(customHeight > parent.height)
(parent.height*0.9) - root.header.height - root.footer.height
else
{
if(customHeight < parent.height*0.4)
(parent.height*0.4) - root.footer.height
else
customHeight - root.footer.height
}
albumsPageRoot.rowClicked(model.get(index))
}
edge: Qt.RightEdge
interactive: false
focus: true
modal: false
dragMargin: 0
margins: 0
spacing: 0
closePolicy: Popup.CloseOnPressOutsideParent
onOpened: drawerList.forceActiveFocus()
enter: Transition
onQuickPlayTrack:
{
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
albumsPageRoot.playTrack(model.get(index))
}
exit: Transition
onQueueTrack:
{
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 }
albumsPageRoot.queueTrack(model.get(index))
}
onPlayAll:
{
albumsPageRoot.currentIndex = 0
var data = albumsViewGrid.gridModel.get(albumsViewGrid.grid.currentIndex)
albumsPageRoot.playAll(data.album, data.artist)
}
BabeTable
onAppendAll:
{
id: drawerList
anchors.fill: parent
trackNumberVisible: true
headerBarVisible: true
headerBarExit: true
coverArtVisible: true
quickPlayVisible: true
focus: true
Kirigami.Separator
{
visible: !isAndroid
width: parent.width
height: 1
z: 999
anchors
{
left: parent.left
right: parent.right
top: parent.top
}
}
onRowClicked:
{
drawer.close()
albumsViewGrid.rowClicked(model.get(index))
}
onQuickPlayTrack:
{
drawer.close()
albumsViewGrid.playTrack(model.get(index))
}
onQueueTrack:
{
albumsViewGrid.queueTrack(model.get(index))
drawer.close()
}
onPlayAll:
{
drawer.close()
var data = albumsViewGrid.gridModel.get(albumsViewGrid.grid.currentIndex)
var query = Q.GET.albumTracks_.arg(data.album)
query = query.arg(data.artist)
var tracks = bae.get(query)
albumsViewGrid.playAlbum(tracks)
}
onAppendAll:
{
var data = albumsView.gridModel.get(albumsViewGrid.grid.currentIndex)
var query = Q.GET.albumTracks_.arg(data.album)
query = query.arg(data.artist)
var tracks = bae.get(query)
albumsViewGrid.appendAlbum(tracks)
drawer.close()
}
onExit: drawer.close()
albumsPageRoot.currentIndex = 0
var data = albumsViewGrid.gridModel.get(albumsViewGrid.grid.currentIndex)
albumsPageRoot.appendAll(data.album, data.artist)
}
onExit: albumsPageRoot.currentIndex = 0
}
onAlbumCoverClicked:
function populate(query)
{
drawerList.headerBarTitle = album
drawer.open()
table.clearTable()
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
var map = bae.get(query)
if(map.length > 0)
for(var i in map)
drawerList.model.append(map[i])
grid.gridModel.append(map[i])
}
onAlbumCoverPressed:
function populateTable(query)
{
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
var map = bae.get(query)
playAlbum(map)
}
table.clearTable()
albumsPageRoot.currentIndex = 1
function populate()
{
var map = bae.get(Q.GET.allAlbumsAsc)
var map = bae.get(query)
if(map.length > 0)
for(var i in map)
gridModel.append(map[i])
albumsViewTable.model.append(map[i])
}
function filter(tracks)
......@@ -206,6 +130,5 @@ BabeGrid
indexes.push(i)
}
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.2 as Kirigami
import "../view_models/BabeGrid"
import "../view_models/BabeTable"
import "../db/Queries.js" as Q
BabeGrid
{
id: artistsViewGrid
visible: true
// albumCardVisible: false
// albumCoverRadius: Math.min(albumCoverSize, albumCoverSize)
property alias list : drawerList.list
property alias table : drawerList
property int customHeight : (drawerList.count*rowHeight)+toolBarHeight
signal rowClicked(var track)
signal playAlbum(var tracks)
signal playTrack(var track)
signal queueTrack(var track)
signal appendAlbum(var tracks)
// transform: Translate
// {
// y: (drawer.position * artistsViewGrid.height)*-1
// }
onBgClicked: if(drawer.visible) drawer.close()
onFocusChanged: drawer.close()
Drawer
{
id: drawer
y: parent.height-height-root.footer.height
width: artistsViewGrid.width
height:
{
if(customHeight > parent.height)
(parent.height*0.9) - root.header.height - root.footer.height
else
{
if(customHeight < parent.height*0.4)
(parent.height*0.4) - root.footer.height
else
customHeight - root.footer.height
}
}
edge: Qt.RightEdge
interactive: false
focus: true
modal: false
dragMargin: 0
margins: 0
spacing: 0
onOpened: drawerList.forceActiveFocus()
enter: Transition
{
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
exit: Transition
{
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 }
}
BabeTable
{
id: drawerList
anchors.fill: parent
trackNumberVisible: true
headerBarVisible: true
headerBarExit: true
coverArtVisible: true
Kirigami.Separator
{
visible: !isAndroid
width: parent.width
height: 1
z: 999
anchors
{
left: parent.left
right: parent.right
top: parent.top
}
}
onRowClicked:
{
drawer.close()
artistsViewGrid.rowClicked(model.get(index))
}
onQuickPlayTrack:
{
drawer.close()
artistsViewGrid.playTrack(model.get(index))
}
onQueueTrack:
{
drawer.close()
artistsViewGrid.queueTrack(model.get(index))
}
onPlayAll:
{
drawer.close()
var data = artistsViewGrid.gridModel.get(artistsViewGrid.grid.currentIndex)
var query = Q.GET.artistTracks_.arg(data.artist)
var tracks = bae.get(query)
artistsViewGrid.playAlbum(tracks)
}
onAppendAll:
{
var data = artistsViewGrid.gridModel.get(artistsViewGrid.grid.currentIndex)
var query = Q.GET.artistTracks_.arg(data.artist)
var tracks = bae.get(query)
artistsViewGrid.appendAlbum(tracks)
drawer.close()
}
onExit: drawer.close()
}
}
onAlbumCoverClicked:
{
drawerList.headerBarTitle = artist
drawer.open()
table.clearTable()
var query = Q.GET.artistTracks_.arg(artist)
var map = bae.get(query)
if(map.length > 0)
for(var i in map)
drawerList.model.append(map[i])
}
onAlbumCoverPressed:
{
var query = Q.GET.artistTracks_.arg(artist)
var map = bae.get(query)
playAlbum(map)
}
function populate()
{
var map = bae.get(Q.GET.allArtistsAsc)
if(map.length > 0)
for(var i in map)
gridModel.append(map[i])
}
}
......@@ -30,6 +30,7 @@ ListView
hideRepeated: true
anchors.verticalCenter: parent.verticalCenter
increaseCurrentItem : true
Connections
{
target: delegate
......
......@@ -27,7 +27,7 @@ Kirigami.PageRow
separatorVisible: wideMode
initialPage: [playlistList, playlistViewDrawer]
defaultColumnWidth: Kirigami.Units.gridUnit * 15
interactive: false
interactive: currentIndex === 1 && !wideMode
Page
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment