Commit aa6f48f0 authored by camilo higuita's avatar camilo higuita

multiple fixes: make use of url for detecting local from other remote urls,...

multiple fixes: make use of url for detecting local from other remote urls, also better albums delegates and quick fixes
parent fd5a55e0
......@@ -255,7 +255,6 @@ Maui.ApplicationWindow
icon.color: _drawer.visible ? babeColor : Kirigami.Theme.textColor
onClicked:
{
console.log("SHOW DRAWER?", _drawer.visible)
_drawer.visible = !_drawer.visible
}
......@@ -635,8 +634,12 @@ Maui.ApplicationWindow
Layout.fillWidth: true
interactive: isMobile
currentIndex: _actionGroup.currentIndex
onCurrentIndexChanged: _actionGroup.currentIndex = currentIndex
clip: true
onCurrentItemChanged: currentItem.forceActiveFocus()
TracksView
{
id: tracksView
......
......@@ -108,7 +108,10 @@ void AlbumsModel::setList()
//get albums data with modifier for missing images for artworks
this->list = this->db->getDBData(m_Query, [&](FMH::MODEL &item)
{
if(!item[FMH::MODEL_KEY::ARTWORK].isEmpty() && !FMH::fileExists(QUrl::fromLocalFile(item[FMH::MODEL_KEY::ARTWORK])))
if(!item[FMH::MODEL_KEY::ARTWORK].isEmpty())
return;
if(QUrl(item[FMH::MODEL_KEY::ARTWORK]).isLocalFile() && !FMH::fileExists(item[FMH::MODEL_KEY::ARTWORK]))
{
this->db->removeArtwork(FMH::MODEL_NAME[static_cast<FMH::MODEL_KEY>(this->query)], FMH::toMap(item));
item[FMH::MODEL_KEY::ARTWORK] = "";
......@@ -132,7 +135,7 @@ void AlbumsModel::fetchInformation()
stop = false;
QList<PULPO::REQUEST> requests;
int index = -1;
for(auto album : this->list)
for(auto &album : this->list)
{
index++;
if(!album[FMH::MODEL_KEY::ARTWORK].isEmpty())
......@@ -167,6 +170,10 @@ void AlbumsModel::fetchInformation()
newTrack[FMH::MODEL_KEY::ARTWORK] = path;
this->db->insertArtwork(newTrack);
this->updateArtwork(index, path);
album[FMH::MODEL_KEY::ARTWORK] = path;
emit this->updateModel(index, {FMH::MODEL_KEY::ARTWORK});
downloader->deleteLater();
});
......
......@@ -11,33 +11,34 @@
namespace FLoader
{
inline QStringList getPathContents(QStringList &urls, const QString &path)
inline QList<QUrl> getPathContents(QList<QUrl> &urls, const QUrl &url)
{
if(!FMH::fileExists(QUrl::fromLocalFile(path)))
if(!FMH::fileExists(url) && !url.isLocalFile())
return urls;
if (QFileInfo(path).isDir())
if (QFileInfo(url.toLocalFile()).isDir())
{
QDirIterator it(path, QStringList() << FMH::FILTER_LIST[FMH::FILTER_TYPE::AUDIO] << "*.m4a", QDir::Files, QDirIterator::Subdirectories);
QDirIterator it(url.toLocalFile(), QStringList() << FMH::FILTER_LIST[FMH::FILTER_TYPE::AUDIO] << "*.m4a", QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext())
urls << it.next();
urls << QUrl::fromLocalFile(it.next());
}else if (QFileInfo(path).isFile())
urls << path;
}else if (QFileInfo(url.toLocalFile()).isFile())
urls << url.toString();
return urls;
}
// returns the number of new items added to the collection db
inline uint getTracks(const QStringList& paths)
inline uint getTracks(const QList<QUrl>& paths)
{
qDebug()<< paths;
auto db = CollectionDB::getInstance();
const auto urls = std::accumulate(paths.begin(), paths.end(), QStringList(), getPathContents);
const auto urls = std::accumulate(paths.begin(), paths.end(), QList<QUrl>(), getPathContents);
for(const auto &path : paths)
if(FMH::fileExists(QUrl::fromLocalFile(path)))
db->addFolder(path);
if(path.isLocalFile() && FMH::fileExists(path))
db->addFolder(path.toString());
uint newTracks = 0;
......@@ -47,10 +48,10 @@ inline uint getTracks(const QStringList& paths)
TagInfo info;
for(const auto &url : urls)
{
if(db->check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS], FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url))
if(db->check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS], FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url.toString()))
continue;
if(!info.feed(url))
if(!info.feed(url.toLocalFile()))
continue;
const auto track = info.getTrack();
......@@ -58,13 +59,13 @@ inline uint getTracks(const QStringList& paths)
const auto album = BAE::fixString(info.getAlbum());
const auto title = BAE::fixString(info.getTitle()); /* to fix*/
const auto artist = BAE::fixString(info.getArtist());
const auto sourceUrl = QFileInfo(url).dir().path();
const auto sourceUrl = FMH::parentDir(url).toString();
const auto duration = info.getDuration();
const auto year = info.getYear();
FMH::MODEL trackMap =
{
{FMH::MODEL_KEY::URL, url},
{FMH::MODEL_KEY::URL, url.toString()},
{FMH::MODEL_KEY::TRACK, QString::number(track)},
{FMH::MODEL_KEY::TITLE, title},
{FMH::MODEL_KEY::ARTIST, artist},
......@@ -72,11 +73,10 @@ inline uint getTracks(const QStringList& paths)
{FMH::MODEL_KEY::DURATION,QString::number(duration)},
{FMH::MODEL_KEY::GENRE, genre},
{FMH::MODEL_KEY::SOURCE, sourceUrl},
{FMH::MODEL_KEY::FAV, url.startsWith(BAE::YoutubeCachePath) ? "1": "0"},
{FMH::MODEL_KEY::FAV, "0"},
{FMH::MODEL_KEY::RELEASEDATE, QString::number(year)}
};
qDebug() << url;
BAE::artworkCache(trackMap, FMH::MODEL_KEY::ALBUM);
if(db->addTrack(trackMap))
......
......@@ -104,7 +104,7 @@ void Player::setUrl(const QString &value)
this->pos = 0;
emit this->posChanged();
const auto media = QMediaContent(QUrl::fromLocalFile(this->url));
const auto media = QMediaContent(this->url);
this->player->setMedia(media);
this->emitState();
}
......
......@@ -8,7 +8,7 @@ function playTrack(index)
if(typeof(currentTrack) === "undefined") return
if(Maui.FM.fileExists("file://" + currentTrack.url))
if(Maui.FM.fileExists(currentTrack.url))
{
player.url = currentTrack.url;
player.playing = true
......@@ -19,14 +19,11 @@ function playTrack(index)
// else bae.loadCover(currentTrack.url)
progressBar.enabled = true
if(!isMobile)
{
root.title = currentTrack.title + " - " +currentTrack.artist
// if(!root.active)
// bae.notifySong(currentTrack.url)
}
// if(currentTrack.lyrics.length < 1)
// bae.trackLyrics(currentTrack.url)
......
......@@ -259,9 +259,6 @@ const QString CachePath = QStandardPaths::writableLocation(QStandardPaths::Gener
const QString YoutubeCachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)+"/vvave/youtube/";
const QString NotifyDir = SettingPath;
const QStringList MusicPaths = QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
const QStringList DownloadsPaths = QStandardPaths::standardLocations(QStandardPaths::DownloadLocation);
const QString MusicPath = FMH::MusicPath;
const QString HomePath = FMH::HomePath;
const QString DownloadsPath = FMH::DownloadsPath;
......@@ -281,8 +278,6 @@ const QString DBName = "collection.db";
const QStringList MoodColors = {"#F0FF01","#01FF5B","#3DAEFD","#B401FF","#E91E63"};
const QStringList defaultSources = QStringList() << BAE::MusicPath
<< BAE::DownloadsPath
<< BAE::MusicPaths
<< BAE::DownloadsPaths
<< BAE::YoutubeCachePath;
inline QString fixTitle(const QString &title,const QString &s,const QString &e)
......@@ -419,14 +414,14 @@ inline bool artworkCache(FMH::MODEL &track, const FMH::MODEL_KEY &type = FMH::MO
QDirIterator it(CachePath, QDir::Files, QDirIterator::NoIteratorFlags);
while (it.hasNext())
{
const auto file = it.next();
const auto fileName = QFileInfo(file).baseName();
const auto file = QUrl::fromLocalFile(it.next());
const auto fileName = QFileInfo(file.toLocalFile()).baseName();
switch(type)
{
case FMH::MODEL_KEY::ALBUM:
if(fileName == (track[FMH::MODEL_KEY::ARTIST]+"_"+track[FMH::MODEL_KEY::ALBUM]))
{
track.insert(FMH::MODEL_KEY::ARTWORK, file);
track.insert(FMH::MODEL_KEY::ARTWORK, file.toString());
return true;
}
break;
......@@ -434,7 +429,7 @@ inline bool artworkCache(FMH::MODEL &track, const FMH::MODEL_KEY &type = FMH::MO
case FMH::MODEL_KEY::ARTIST:
if(fileName == (track[FMH::MODEL_KEY::ARTIST]))
{
track.insert(FMH::MODEL_KEY::ARTWORK, file);
track.insert(FMH::MODEL_KEY::ARTWORK, file.toString());
return true;
}
break;
......
......@@ -81,7 +81,7 @@ Maui.ItemDelegate
source:
{
if(artwork)
(artwork.length > 0 && artwork !== "NONE")? "file://"+encodeURIComponent(artwork) : "qrc:/assets/cover.png"
(artwork.length > 0 && artwork !== "NONE")? artwork : "qrc:/assets/cover.png"
else "qrc:/assets/cover.png"
}
layer.enabled: albumRadius
......@@ -159,6 +159,32 @@ Maui.ItemDelegate
opacity: 0.2
}
layer.enabled: true
layer.effect: OpacityMask
{
maskSource: Item
{
width: blur.width
height: blur.height
Rectangle
{
anchors.centerIn: parent
width: parent.width
height: parent.height
radius: albumRadius
Rectangle
{
anchors.top: parent.top
width: parent.width
height: parent.radius
}
}
}
}
}
......@@ -189,7 +215,7 @@ Maui.ItemDelegate
Layout.fillWidth: visible
Layout.fillHeight: visible
text: list.query === Albums.ALBUMS ? model.artist : undefined
text: list.query === Albums.ALBUMS ? model.artist : ""
visible: text && (control.width > 70)
horizontalAlignment: Qt.AlignLeft
elide: Text.ElideRight
......
......@@ -92,7 +92,7 @@ Menu
MenuItem
{
visible: root.showAccounts
visible: Maui.App.handleAccounts
text: qsTr("Copy to cloud")
onTriggered:
{
......
......@@ -57,13 +57,7 @@ void vvave::checkCollection(const QStringList &paths, std::function<void(uint)>
const auto func = [=]() -> uint
{
auto newPaths = paths;
for(auto path : newPaths)
if(path.startsWith("file://"))
path.replace("file://", "");
return FLoader::getTracks(newPaths);
return FLoader::getTracks(QUrl::fromStringList(paths));
};
QFuture<uint> t1 = QtConcurrent::run(func);
......@@ -82,7 +76,7 @@ QVariantList vvave::sourceFolders()
QVariantList res;
for(const auto &item : sources)
res << FMH::getDirInfo(QUrl::fromLocalFile(item[FMH::MODEL_KEY::URL]));
res << FMH::getDirInfo(item[FMH::MODEL_KEY::URL]);
return res;
}
......
......@@ -98,6 +98,7 @@ BabeGrid
Maui.Dialog
{
id: albumDialog
property string title
parent: parent
maxHeight: maxWidth
maxWidth: Maui.Style.unit * 600
......@@ -105,7 +106,8 @@ BabeGrid
heightHint: 0.9
defaultButtons: false
page.padding: 0
headBar.visible: true
page.title: title
ColumnLayout
{
id: albumFilter
......@@ -115,6 +117,7 @@ BabeGrid
BabeTable
{
id: albumsViewTable
headBar.position: ToolBar.Footer
Layout.fillHeight: true
Layout.fillWidth: true
trackNumberVisible: true
......@@ -185,13 +188,13 @@ BabeGrid
{
query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
albumsView.table.title = album
albumDialog.title = album
tagq = Q.GET.albumTags_.arg(album)
}else if(artist && album === undefined)
{
query = Q.GET.artistTracks_.arg(artist)
artistsView.table.title = artist
albumDialog.title = artist
tagq = Q.GET.artistTags_.arg(artist)
}
......
......@@ -74,7 +74,7 @@ Item
function filter()
{
var where = "source = \""+currentFolder.replace("file://", "")+"\""
var where = "source = \""+currentFolder+"\""
_filterList.list.query = (Q.GET.tracksWhere_.arg(where))
}
......
......@@ -35,7 +35,6 @@ Maui.Page
{
id: playlistMenu
onClearOut: Player.clearOutPlaylist()
// onHideCover: cover.visible = !cover.visible
onClean: Player.cleanPlaylist()
onSaveToClicked: table.saveList()
}
......@@ -45,20 +44,17 @@ Maui.Page
footBar.width: parent.width
footBar.middleContent: AlbumsRoll
{
// height: Maui.Style.toolBarHeight * 1.3
Layout.fillWidth: true
Layout.fillHeight: true
// width: footBar.width
// height: footBar.height
id: albumsRoll
}
footBar.background: Item
{
id: footerBg
clip : true
height: footBar.implicitHeight
Image
{
id: artworkBg
......@@ -73,7 +69,7 @@ Maui.Page
smooth: true
asynchronous: true
source: "file://"+encodeURIComponent(currentArtwork)
source: currentArtwork
}
FastBlur
......@@ -88,13 +84,28 @@ Maui.Page
z:1
clip: true
LinearGradient
{
anchors.fill: parent
start: Qt.point(0, 0)
end: Qt.point(0, parent.height)
gradient: Gradient {
GradientStop { position: 0; color: Kirigami.Theme.viewBackgroundColor }
GradientStop { position: 1; color: "transparent" }
}
Rectangle
{
anchors.fill: parent
color: Kirigami.Theme.viewBackgroundColor
opacity: 0.85
opacity: 0.7
}
}
}
}
BabeTable
......
......@@ -69,7 +69,7 @@ ColumnLayout
{
Layout.fillWidth: true
height: Maui.Style.rowHeightAlt
recSize: Kirigami.Settings.isMobile ? iconSize : 16
recSize: Kirigami.Settings.isMobile ? Maui.Style.iconSizes.medium : Maui.Style.iconSizes.small
onColorClicked: populate(Q.GET.colorTracks_.arg(color.toLowerCase()))
}
......@@ -95,7 +95,7 @@ ColumnLayout
title: playlistViewModel.list.get(playlistViewModel.currentIndex).playlist
holder.emoji: "qrc:/assets/Electricity.png"
holder.isMask: false
holder.title : playlistViewModel.model.get(playlistViewModel.currentIndex).playlist
holder.title : playlistViewModel.list.get(playlistViewModel.currentIndex).playlist
holder.body: "Your playlist is empty,<br>start adding new music to it"
holder.emojiSize: Maui.Style.iconSizes.huge
......@@ -212,6 +212,5 @@ ColumnLayout
function removePlaylist()
{
playlistList.removePlaylist(playlistViewList.currentIndex)
filterList.clearTable()
}
}
......@@ -29,27 +29,24 @@ BabeList
rejectButton.visible: false
}
headBar.leftContent: Kirigami.ActionToolBar
{
Layout.fillWidth: true
actions:
[
Kirigami.Action
{
text: qsTr("Remove")
icon.name: "list-remove"
onTriggered: removePlaylist()
},
Kirigami.Action
headBar.leftContent: [
ToolButton
{
id : createPlaylistBtn
text: qsTr("Add")
icon.name : "list-add"
onTriggered : newPlaylistDialog.open()
}
]
onClicked: newPlaylistDialog.open()
},
ToolButton
{
text: qsTr("Remove")
icon.name: "list-remove"
onClicked: removePlaylist()
}
]
Maui.BaseModel
{
id: _playlistsModel
......
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