Commit 6ceb9610 authored by Camilo higuita's avatar Camilo higuita

add folders view

parent 581060a7
......@@ -283,6 +283,19 @@ QString Babe::albumWiki(const QString &album, const QString &artist)
return "";
}
QVariantList Babe::getFolders()
{
auto sources = this->getDBData("select * from sources");
QVariantList res;
for(auto item : sources)
res << FMH::getDirInfo(item[BAE::KEY::URL]);
qDebug()<<"FOLDERS:"<< res;
return res;
}
bool Babe::babeTrack(const QString &path, const bool &value)
{
if(update(TABLEMAP[TABLE::TRACKS],
......@@ -443,7 +456,7 @@ QString Babe::moodColor(const int &pos)
QString Babe::homeDir()
{
return BAE::HomePath;
return BAE::HomePath;
}
QString Babe::musicDir()
......
......@@ -50,6 +50,7 @@ public:
Q_INVOKABLE QString artistWiki(const QString &artist);
Q_INVOKABLE QString albumWiki(const QString &album, const QString &artist);
Q_INVOKABLE QVariantList getFolders();
Q_INVOKABLE bool babeTrack(const QString &path, const bool &value);
/* SETTINGS */
......
......@@ -11,7 +11,7 @@ var GET = {
albumTracksSimple_ : "select * from tracks where album = \"%1\" and artist = \"%2\"",
artistTracksSimple_ : "select * from tracks where artist = \"%1\"",
tracksWhere_ : "select t.*, al.artwork from tracks t inner join albums al on al.album = t.album and al.artist = t.artist where %1",
// sourceTracks_: "select * from tracks where sources_url = \"%1\"",
mostPlayedTracks : "select t.*, al.artwork from tracks t inner join albums al on t.album = al.album and t.artist = al.artist WHERE t.played > 0 ORDER BY played desc LIMIT 100",
favoriteTracks : "select t.*, al.artwork from tracks t inner join albums al on t.album = al.album and t.artist = al.artist where stars > 0 order by stars desc limit 100",
......
......@@ -96,10 +96,11 @@ Maui.ApplicationWindow
artists: 2,
playlists: 3,
search: 4,
vvave: 5,
linking: 6,
youtube: 7,
spotify: 8
folders: 5,
vvave: 6,
linking: 7,
youtube: 8,
spotify: 9
})
......@@ -322,6 +323,17 @@ Maui.ApplicationWindow
}
},
Kirigami.Action
{
text: qsTr("Folders")
iconName: "folder"
onTriggered:
{
pageStack.currentIndex = 1
currentView = viewsIndex.folders
}
},
Kirigami.Action
{
text: qsTr("Linking")
......@@ -726,7 +738,7 @@ Maui.ApplicationWindow
bae.saveSetting("SHUFFLE",isShuffle, "PLAYBACK")
}
}
]
]
}
Maui.Page
......@@ -796,6 +808,7 @@ Maui.ApplicationWindow
{
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
albumsView.table.headBarTitle = album
albumsView.populateTable(query)
......@@ -931,6 +944,22 @@ Maui.ApplicationWindow
}
}
FoldersView
{
id: foldersView
Connections
{
target: foldersView.list
onRowClicked: Player.addTrack(foldersView.list.model.get(index))
onQuickPlayTrack: Player.quickPlay(foldersView.list.model.get(index))
onPlayAll: Player.playAll(foldersView.getTracks())
onAppendAll: Player.appendAll(foldersView.getTracks())
onQueueTrack: Player.queueTracks([foldersView.list.model.get(index)], index)
}
}
BabeitView
{
id: babeitView
......
Subproject commit e8147d49dafbd388d6750177624a513c064ab595
Subproject commit 153795d9c5492a069375b8ae89ae4d67b6ff2171
......@@ -75,5 +75,6 @@
<file>assets/BugSearch.png</file>
<file>assets/Astronaut.png</file>
<file>assets/MusicCloud.png</file>
<file>widgets/FoldersView.qml</file>
</qresource>
</RCC>
......@@ -50,6 +50,12 @@ function refreshCollection(size)
refreshTracks()
refreshAlbums()
refreshArtists()
refreshFolders()
}
function refreshFolders()
{
foldersView.populate()
}
function refreshTracks()
......
......@@ -21,9 +21,9 @@ Brain::~Brain()
void Brain::start()
{
if(!this->isRunning())
this->go = true;
QMetaObject::invokeMethod(this, "synapse");
// if(!this->isRunning())
// this->go = true;
// QMetaObject::invokeMethod(this, "synapse");
}
void Brain::stop()
......
......@@ -64,7 +64,7 @@ SwipeDelegate
color: isCurrentListItem ? highlightColor : (trackMood.length > 0 ? Qt.tint(bgColor, Qt.rgba(Qt.lighter(trackMood, 1.3).r,
Qt.lighter(trackMood, 1.3).g,
Qt.lighter(trackMood, 1.3).b,
0.5 ) ):
0.3 ) ):
index % 2 === 0 ? Qt.lighter(bgColor) : bgColor)
}
......
......@@ -20,6 +20,8 @@ Kirigami.PageRow
defaultColumnWidth: albumsViewGrid.albumCoverSize * 4
interactive: currentIndex === 1
property var tracks: []
property alias grid : albumsViewGrid
property alias table : albumsViewTable
property alias tagBar : tagBar
......@@ -124,11 +126,11 @@ Kirigami.PageRow
albumsPageRoot.currentIndex = 1
var map = bae.get(query)
tracks = bae.get(query)
if(map.length > 0)
for(var i in map)
albumsViewTable.model.append(map[i])
if(tracks.length > 0)
for(var i in tracks)
albumsViewTable.model.append(tracks[i])
}
function filter(tracks)
......
import QtQuick 2.0
import QtQuick.Controls 2.2
import org.kde.maui 1.0 as Maui
import "../view_models/BabeTable"
import "../db/Queries.js" as Q
StackView
{
id: stack
property alias list : filterList
property var tracks : []
property string currentFolder : ""
initialItem: Maui.Page
{
anchors.fill: parent
headBarTitle: qsTr("Source folders")
headBarExit: false
margins: space.large
Maui.GridBrowser
{
anchors.fill: parent
id: browser
onItemClicked:
{
stack.push(filterList)
var item = browser.model.get(index)
filterList.headBarTitle= item.label
currentFolder = item.path
filter()
}
}
}
BabeTable
{
id: filterList
coverArtVisible: true
headBarExitIcon: "go-previous"
holder.emoji: "qrc:/assets/MusicCloud.png"
holder.isMask: false
holder.title : "No Tracks!"
holder.body: "This source folder seems to be empty!"
holder.emojiSize: iconSizes.huge
onExit:
{
stack.pop()
}
}
function populate()
{
browser.model.clear()
var folders = bae.getFolders();
if(folders.length > 0)
for(var i in folders)
browser.model.append(folders[i])
}
function filter()
{
filterList.model.clear()
tracks = getTracks()
for(var i in tracks)
filterList.model.append(tracks[i])
}
function getTracks()
{
var where = "sources_url = \""+currentFolder+"\""
return bae.get(Q.GET.tracksWhere_.arg(where))
}
}
......@@ -2,8 +2,9 @@ import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import org.kde.maui 1.0 as Maui
Page
Maui.Page
{
property bool isConnected : false
......@@ -29,32 +30,32 @@ Page
{
anchors.fill: parent
Item
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignCenter
Layout.margins: contentMargins*2
width: parent.width
Image
{
width: 120
anchors.centerIn: parent
id: beatsImg
fillMode: Image.PreserveAspectFit
source: "qrc:/assets/banner-yellow.png"
horizontalAlignment: Qt.AlignHCenter
}
// ColorOverlay
// {
// anchors.fill: beatsImg
// source: beatsImg
// color: foregroundColor
// }
}
Item
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignCenter
Layout.margins: contentMargins*2
width: parent.width
Image
{
width: 120
anchors.centerIn: parent
id: beatsImg
fillMode: Image.PreserveAspectFit
source: "qrc:/assets/banner-yellow.png"
horizontalAlignment: Qt.AlignHCenter
}
// ColorOverlay
// {
// anchors.fill: beatsImg
// source: beatsImg
// color: foregroundColor
// }
}
}
}
This diff is collapsed.
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