Commit a34e003a authored by Camilo Higuita's avatar Camilo Higuita

move artwork out of cache to avoid being deleted as trash on mobile, and...

move artwork out of cache to avoid being deleted as trash on mobile, and intial work ona  custom made folder picker for mobile
parent 2858b86c
......@@ -9,6 +9,7 @@
#include "pulpo/pulpo.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QDirIterator>
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
#include "kde/notify.h"
......@@ -319,6 +320,36 @@ int Babe::cursorPos(QString &axis)
else return 0;
}
QVariantList Babe::getDirs(const QString &pathUrl)
{
auto path = pathUrl;
if(path.startsWith("file://"))
path.replace("file://", "");
qDebug()<<"DIRECTRORY"<<path;
QVariantList paths;
if (QFileInfo(path).isDir())
{
QDirIterator it(path, QDir::Dirs, QDirIterator::NoIteratorFlags);
while (it.hasNext())
{
auto url = it.next();
auto name = QDir(url).dirName();
qDebug()<<name<<url;
QVariantMap map = { {"url", url }, {"name", name} };
paths << map;
}
}
return paths;
}
QVariantMap Babe::getParentDir(const QString &path)
{
return {{"url",QFileInfo(path).dir().absolutePath()}, {"name", QFileInfo(path).dir().dirName()}};
}
QString Babe::loadCover(const QString &url)
{
auto map = this->con->getDBData(QStringList() << url);
......
......@@ -14,7 +14,6 @@ class CollectionDB;
class Pulpo;
class settings;
using namespace BAE;
class Babe : public QObject
......@@ -65,6 +64,11 @@ public:
Q_INVOKABLE static int screenGeometry(QString &side);
Q_INVOKABLE static int cursorPos(QString &axis);
Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl);
Q_INVOKABLE static QVariantMap getParentDir(const QString &path);
/*USEFUL*/
Q_INVOKABLE QString loadCover(const QString &url);
......
......@@ -32,5 +32,8 @@
<file>widgets/SearchTable.qml</file>
<file>utils/Help.js</file>
<file>assets/Babe.notifyrc</file>
<file>widgets/FolderPicker.qml</file>
<file>view_models/FolderPickerList.qml</file>
<file>view_models/FolderPickerDelegate.qml</file>
</qresource>
</RCC>
......@@ -53,7 +53,7 @@ settings::settings(QObject *parent) : QObject(parent)
#endif
QDir collectionDBPath_dir(BAE::CollectionDBPath);
QDir cachePath_dir(BAE::CachePath);
QDir cachePath_dir(BAE::isMobile() ? BAE::ArtworkPath : BAE::CachePath);
QDir youtubeCache_dir(BAE::YoutubeCachePath);
if (!collectionDBPath_dir.exists())
......@@ -214,11 +214,11 @@ void settings::checkCollection()
void settings::startBrainz(const int &speed)
{
if(this->brainzOn)
{
this->brainDeamon->setInterval(speed);
this->brainDeamon->start();
}
// if(this->brainzOn)
// {
// this->brainDeamon->setInterval(speed);
// this->brainDeamon->start();
// }
}
......
......@@ -220,6 +220,7 @@ namespace BAE
const QString MusicPath = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
const QString HomePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
const QString SettingPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/babe/";
const QString ArtworkPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/babe/artwork/";
const QString CollectionDBPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/babe/";
const QString CachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)+"/babe/";
const QString YoutubeCachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)+"/babe/youtube/";
......
......@@ -32,6 +32,8 @@ ListView
snapMode: ListView.SnapToItem
function clearTable()
{
listModel.clear()
......@@ -46,7 +48,7 @@ ListView
Rectangle
{
anchors.fill: parent
color: bae.altColor()
color: "transparent"
z: -999
}
......
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
ItemDelegate
{
id: delegate
property string textColor: bae.foregroundColor()
// checkable: true
contentItem: GridLayout
{
id: gridLayout
width: parent.width
rows:1
columns:1
Label
{
id: folderTitle
Layout.fillWidth: true
Layout.fillHeight: true
Layout.row: 1
Layout.column: 1
text: name
font.bold: true
elide: Text.ElideRight
font.pointSize: 10
color: textColor
}
}
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
ListView
{
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
id: list
property int currentRow : -1
property string currentUrl
property string currentName
signal rowClicked(int index)
signal rowPressed(int index)
width: 320
height: 480
clip: true
highlight: highlight
highlightFollowsCurrentItem: false
focus: true
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: ListView.SnapToItem
function clearTable()
{
listModel.clear()
}
BabeHolder
{
id: holder
visible: list.count === 0
}
Rectangle
{
anchors.fill: parent
color: "transparent"
z: -999
}
Component
{
id: highlight
Rectangle
{
width: list.width
height: list.currentItem.height
color: bae.hightlightColor() || myPalette.highlight
opacity: 0.2
y: list.currentItem.y
}
}
ListModel { id: listModel }
model: listModel
delegate: FolderPickerDelegate
{
id: delegate
width: list.width
Connections
{
target: delegate
onPressAndHold:
{
}
onClicked:
{
list.rowClicked(index)
currentIndex = index
// currentUrl = model.get(currentIndex).url
}
}
}
ScrollBar.vertical: ScrollBar { }
}
......@@ -28,7 +28,8 @@ BabeGrid
width: parent.width
edge: Qt.BottomEdge
interactive: false
focus: true
modal:true
background: Rectangle
{
anchors.fill: parent
......@@ -180,15 +181,15 @@ BabeGrid
for(var i = 0; i<tracks.length; i++)
matches.push(find(tracks[i].album))
for(var j = 0 ; j < albumsViewGrid.gridModel.count; j++)
albumsViewGrid.gridModel.remove(j,1)
for(var j = 0 ; j < albumsViewGrid.gridModel.count; j++)
albumsViewGrid.gridModel.remove(j,1)
// for(var match in matches)
// {
// albumsViewGrid.gridModel.get(match).hide = true
// console.log(match)
// }
// for(var match in matches)
// {
// albumsViewGrid.gridModel.get(match).hide = true
// console.log(match)
// }
}
function find(query)
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../view_models"
import "../utils/Icons.js" as MdiFont
import "../utils"
Popup
{
// width: parent.width *0.7
// height: parent.height *0.7
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
modal: true
focus: true
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
property int current : 0
property alias dirList : dirList
signal pathClicked(var path)
signal accepted(var path)
signal goBack(var path)
background: Rectangle
{
anchors.fill: parent
color: bae.altColor()
z: -999
radius: 4
}
Column
{
anchors.fill: parent
RowLayout
{
width:parent.width
ToolButton
{
Layout.alignment: Qt.AlignLeft
id: goBackBtn
Icon
{
text: MdiFont.Icon.arrowLeft
}
onClicked:
{
var dir = bae.getParentDir(dirList.currentUrl)
dirList.currentUrl = dir.url
dirList.currentName = dir.name
goBack(dirList.currentUrl)
}
}
Label
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
color: bae.foregroundColor()
text: dirList.currentName
elide: Text.ElideRight
horizontalAlignment: Qt.AlignHCenter
}
Button
{
Layout.alignment: Qt.AlignRight
onClicked: {accepted(dirList.currentUrl); close()}
contentItem: Text
{
color: bae.foregroundColor()
text: "Accept"
}
background: Rectangle
{
color: bae.babeColor()
radius: 2
}
}
}
FolderPickerList
{
id: dirList
Connections
{
target: dirList
onRowClicked:
{
dirList.currentUrl = dirList.model.get(index).url
dirList.currentName = dirList.model.get(index).name
pathClicked(dirList.currentUrl)
}
}
}
}
}
......@@ -33,6 +33,12 @@ Item
// else
// root.width = columnWidth*3
// }
Rectangle
{
anchors.fill: parent
color: bae.altColor()
z: -999
}
GridLayout
{
......@@ -357,6 +363,13 @@ Item
quickBtnsVisible: false
quickPlayVisible: false
Rectangle
{
anchors.fill: parent
color: bae.altColor()
z: -999
}
onRowClicked: Player.playTrack(model.get(index))
holder.message: "Empty playlist..."
Component.onCompleted:
......
......@@ -12,6 +12,12 @@ BabeTable
for(var i in tracks)
searchTable.model.append(tracks[i])
}
Rectangle
{
anchors.fill: parent
color: bae.altColor()
z: -999
}
Component.onCompleted: populate()
}
......
......@@ -6,12 +6,33 @@ import Qt.labs.platform 1.0
import "../utils/Icons.js" as MdiFont
import "../utils"
Pane
Page
{
id: settingsView
signal iconSizeChanged(int size)
function load(folderUrl)
{
folderPicker.dirList.clearTable()
var dirs = bae.getDirs(folderUrl)
for(var path in dirs)
{
folderPicker.dirList.model.append(dirs[path])
}
}
function scanDir(folderUrl)
{
bae.scanDir(folderUrl)
}
background: Rectangle
{
anchors.fill: parent
color: bae.backgroundColor()
z: -999
}
FolderDialog
{
......@@ -21,7 +42,27 @@ Pane
onAccepted:
{
listModel.append({url: folder.toString()})
babe.scanDir(folder.toString())
scanDir(folder.toString())
}
}
FolderPicker
{
id: folderPicker
Connections
{
target: folderPicker
onPathClicked:
{
load(path)
}
onAccepted:
{
listModel.append({url: path})
scanDir(path)
}
onGoBack: load(path)
}
}
......@@ -31,13 +72,17 @@ Pane
anchors.centerIn: parent
width: parent.width /2
height: parent.height/2
border.color: "#dedede"
radius: 4
color: bae.altColor()
Label
{
anchors.bottom: sources.top
text: "Sources"
font.bold: true
padding: 10
color: bae.foregroundColor()
}
ListView
......@@ -75,6 +120,7 @@ Pane
elide: Text.ElideRight
Layout.fillWidth: true
font.pointSize: 10
color: bae.foregroundColor()
}
}
}
......@@ -108,7 +154,13 @@ Pane
onClicked:
{
folderDialog.open()
if(bae.isMobile())
{
folderPicker.open()
load(StandardPaths.standardLocations(StandardPaths.HomeLocation)[0])
}else
folderDialog.open()
}
}
......@@ -143,6 +195,8 @@ Pane
text: "Toolbar icon size"
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
color: bae.foregroundColor()
}
ComboBox
......
......@@ -13,6 +13,13 @@ BabeTable
tracksViewTable.model.append(map[i])
}
Rectangle
{
anchors.fill: parent
color: bae.altColor()
z: -999
}
Component.onCompleted: populate()
}
......
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