Commit d3814702 authored by camilo higuita's avatar camilo higuita

save correct image artwork to local file format

parent 18252740
......@@ -180,13 +180,11 @@ Maui.ApplicationWindow
}
}
footBar.visible: !mainlistEmpty
footBar.implicitHeight: footBar.visible ? Maui.Style.toolBarHeight * 1.2 : 0
footer: ColumnLayout
{
id: _footerLayout
height: footBar.height
visible: !mainlistEmpty
height: visible ? Maui.Style.toolBarHeight * 1.2 : 0
width: root.width
spacing: 0
......@@ -240,8 +238,6 @@ Maui.ApplicationWindow
}
}
Maui.ToolBar
{
Layout.fillHeight: true
......
......@@ -117,6 +117,8 @@ void AlbumsModel::setList()
item[FMH::MODEL_KEY::ARTWORK] = "";
}
});
this->fetchInformation();
this->sortList();
emit this->postListChanged();
}
......@@ -161,17 +163,15 @@ void AlbumsModel::fetchInformation()
{
if(res.context == PULPO::CONTEXT::IMAGE && !res.value.toString().isEmpty())
{
qDebug()<<"SAVING ARTWORK FOR: " << request.track[FMH::MODEL_KEY::ALBUM];
auto downloader = new FMH::Downloader;
QObject::connect(downloader, &FMH::Downloader::fileSaved, [&, index, request, downloader = std::move(downloader)](QString path)
{
qDebug()<< "Saving artwork file to" << path;
FMH::MODEL newTrack = request.track;
newTrack[FMH::MODEL_KEY::ARTWORK] = path;
newTrack[FMH::MODEL_KEY::ARTWORK] = QUrl::fromLocalFile(path).toString();
this->db->insertArtwork(newTrack);
this->updateArtwork(index, path);
// this->updateArtwork(index, path);
album[FMH::MODEL_KEY::ARTWORK] = path;
album[FMH::MODEL_KEY::ARTWORK] = newTrack[FMH::MODEL_KEY::ARTWORK];
emit this->updateModel(index, {FMH::MODEL_KEY::ARTWORK});
downloader->deleteLater();
......@@ -183,6 +183,8 @@ void AlbumsModel::fetchInformation()
name.replace("/", "-");
name.replace("&", "-");
downloader->setFile(res.value.toString(), BAE::CachePath + name + format);
qDebug()<<"SAVING ARTWORK FOR: " << request.track[FMH::MODEL_KEY::ALBUM]<< BAE::CachePath + name + format;
}
}
};
......
......@@ -246,17 +246,17 @@ inline QString getNameFromLocation(const QString &str)
return ret;
}
const QString SettingPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/vvave/";
const QString ArtworkPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/vvave/artwork/";
const QString CollectionDBPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/vvave/";
const QString SettingPath = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/vvave/").toLocalFile();
const QString ArtworkPath = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/vvave/artwork/").toString();
const QString CollectionDBPath = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/vvave/").toLocalFile();
#ifdef Q_OS_ANDROID
const QString CachePath = BAE::ArtworkPath;
#else
const QString CachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)+"/vvave/";
const QString CachePath = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)+"/vvave/").toString();
#endif
const QString YoutubeCachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)+"/vvave/youtube/";
const QString YoutubeCachePath = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)+"/vvave/youtube/").toLocalFile();
const QString NotifyDir = SettingPath;
const QString MusicPath = FMH::MusicPath;
......@@ -411,7 +411,7 @@ inline QVariant loadSettings(const QString &key, const QString &group, const QVa
inline bool artworkCache(FMH::MODEL &track, const FMH::MODEL_KEY &type = FMH::MODEL_KEY::ID)
{
QDirIterator it(CachePath, QDir::Files, QDirIterator::NoIteratorFlags);
QDirIterator it(QUrl(CachePath).toLocalFile(), QDir::Files, QDirIterator::NoIteratorFlags);
while (it.hasNext())
{
const auto file = QUrl::fromLocalFile(it.next());
......
......@@ -210,8 +210,6 @@ Maui.ItemDelegate
}
}
ColumnLayout
{
id: _labelsLayout
......
......@@ -46,7 +46,7 @@ Maui.SwipeBrowserDelegate
rightPadding: leftPadding
leftPadding: Maui.Style.space.small
iconSizeHint: Maui.Style.rowHeight
iconSizeHint: height
label1.text: number ? model.track + ". " + model.title : model.title
label2.text: model.artist + " | " + model.album
label2.visible: coverArt ? !sameAlbum : true
......@@ -57,10 +57,7 @@ Maui.SwipeBrowserDelegate
label4.text: model.rate ? H.setStars(model.rate) : ""
iconVisible: !sameAlbum && coverArt
imageSource: typeof model.artwork === 'undefined' ?
"qrc:/assets/cover.png" :
remoteArtwork ? model.artwork :
((model.artwork && model.artwork.length > 0 && model.artwork !== "NONE")? "file://"+encodeURIComponent(model.artwork) : "qrc:/assets/cover.png")
imageSource: model.artwork ? model.artwork : "qrc:/assets/cover.png"
signal play()
......
......@@ -3,6 +3,7 @@ import QtQuick 2.9
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.7 as Kirigami
import org.kde.mauikit 1.0 as Maui
import QtGraphicalEffects 1.0
import "../../view_models/BabeGrid"
import "../../utils/Player.js" as Player
......@@ -34,77 +35,20 @@ ListView
// onCurrentIndexChanged: Player.playAt(currentIndex)
delegate: GridLayout
delegate: Maui.SwipeBrowserDelegate
{
height: albumsRollRoot.height
isCurrentItem: false
hoverEnabled: false
width: albumsRollRoot.width
clip: true
columns: 2
rows: 2
rowSpacing: Maui.Style.space.tiny
columnSpacing: Maui.Style.space.big
BabeAlbum
{
id: delegate
Layout.row: 1
Layout.rowSpan: 2
Layout.column: 1
Layout.preferredWidth: albumSize
Layout.preferredHeight: albumSize
Layout.alignment: Qt.AlignCenter
albumSize : Maui.Style.iconSizes.big + Maui.Style.space.big
albumRadius : Maui.Style.radiusV
showLabels: false
showIndicator: false
hideRepeated: false
// increaseCurrentItem : true
Connections
{
target: delegate
onClicked:
{
albumsRollRoot.currentIndex = index
play(index)
}
}
}
Label
{
Layout.row: 1
Layout.column: 2
Layout.fillWidth: true
Layout.fillHeight: true
text: model.title
color: Kirigami.Theme.textColor
font.pointSize: Maui.Style.fontSizes.default
verticalAlignment: Qt.AlignBottom
clip: true
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
elide: Text.ElideRight
}
Label
{
Layout.row: 2
Layout.column: 2
Layout.fillWidth: true
Layout.fillHeight: true
text: model.artist + " | " + model.album
font.pointSize: Maui.Style.fontSizes.small
verticalAlignment: Qt.AlignTop
clip: true
color: Kirigami.Theme.textColor
elide: Text.ElideRight
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
}
height: albumsRollRoot.height
label1.text: model.title
label2.text: model.artist + " | " + model.album
imageSource: model.artwork
iconVisible : true
label1.visible : albumsRollRoot.width > height
label2.visible : label1.visible
}
// MouseArea
// {
// anchors.fill : parent
......
......@@ -40,7 +40,6 @@ Maui.Page
}
footBar.visible: !mainlistEmpty
footBar.implicitHeight: Maui.Style.toolBarHeight * 1.3
footBar.width: parent.width
footBar.middleContent: AlbumsRoll
{
......@@ -54,7 +53,6 @@ Maui.Page
id: footerBg
height: footBar.implicitHeight
Image
{
id: artworkBg
......
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