Commit 1c3f0e52 authored by Camilo higuita's avatar Camilo higuita

more fixes

parent 8a885393
...@@ -136,7 +136,7 @@ bool CollectionDB::check_existance(const QString &tableName, const QString &sear ...@@ -136,7 +136,7 @@ bool CollectionDB::check_existance(const QString &tableName, const QString &sear
return false; return false;
} }
if (query.next()) if (query.first())
return true; return true;
return false; return false;
......
...@@ -87,8 +87,8 @@ int main(int argc, char *argv[]) ...@@ -87,8 +87,8 @@ int main(int argc, char *argv[])
const auto currentSources = vvave.getSourceFolders(); const auto currentSources = vvave.getSourceFolders();
const QStringList sources = currentSources.isEmpty() ? BAE::defaultSources : currentSources; const QStringList sources = currentSources.isEmpty() ? BAE::defaultSources : currentSources;
vvave.scanDir(sources); vvave.scanDir(sources);
// if(!urls.isEmpty()) if(!urls.isEmpty())
// bae.openUrls(urls); vvave.openUrls(urls);
}); });
auto context = engine.rootContext(); auto context = engine.rootContext();
......
...@@ -442,6 +442,21 @@ Maui.ApplicationWindow ...@@ -442,6 +442,21 @@ Maui.ApplicationWindow
text: qsTr("Sources...") text: qsTr("Sources...")
icon.name: "folder-add" icon.name: "folder-add"
onTriggered: sourcesDialog.open() onTriggered: sourcesDialog.open()
},
Maui.MenuItem
{
text: qsTr("Open...")
icon.name: "folder-add"
onTriggered:
{
fmDialog.onlyDirs = false
fmDialog.filterType = FMList.AUDIO
fmDialog.show(function(paths)
{
vvave.openUrls(paths)
})
}
} }
// Maui.Menu // Maui.Menu
...@@ -1016,6 +1031,10 @@ Maui.ApplicationWindow ...@@ -1016,6 +1031,10 @@ Maui.ApplicationWindow
currentBabe = mainPlaylist.list.get(currentTrackIndex).fav == "1" currentBabe = mainPlaylist.list.get(currentTrackIndex).fav == "1"
} }
onOpenFiles: Player.playAll(tracks) onOpenFiles:
{
Player.appendTracksAt(tracks, 0)
Player.playAt(0)
}
} }
} }
...@@ -16,7 +16,7 @@ function playTrack(index) ...@@ -16,7 +16,7 @@ function playTrack(index)
if(currentTrack.artwork && currentTrack.artwork.length && currentTrack.artwork !== "NONE") if(currentTrack.artwork && currentTrack.artwork.length && currentTrack.artwork !== "NONE")
currentArtwork = currentTrack.artwork currentArtwork = currentTrack.artwork
else bae.loadCover(currentTrack.url) // else bae.loadCover(currentTrack.url)
progressBar.enabled = true progressBar.enabled = true
...@@ -24,8 +24,8 @@ function playTrack(index) ...@@ -24,8 +24,8 @@ function playTrack(index)
{ {
root.title = currentTrack.title + " - " +currentTrack.artist root.title = currentTrack.title + " - " +currentTrack.artist
if(!root.active) // if(!root.active)
bae.notifySong(currentTrack.url) // bae.notifySong(currentTrack.url)
} }
// if(currentTrack.lyrics.length < 1) // if(currentTrack.lyrics.length < 1)
...@@ -116,7 +116,7 @@ function shuffle() ...@@ -116,7 +116,7 @@ function shuffle()
function playAt(index) function playAt(index)
{ {
if((index < mainPlaylist.listView.count) && (mainPlaylist.listView.count > 0) && (index > -1)) if((index < mainPlaylist.listView.count) && (index > -1))
{ {
currentTrackIndex = index currentTrackIndex = index
mainPlaylist.listView.currentIndex = currentTrackIndex mainPlaylist.listView.currentIndex = currentTrackIndex
......
...@@ -11,6 +11,12 @@ ...@@ -11,6 +11,12 @@
#include <QtConcurrent> #include <QtConcurrent>
#include <QFuture> #include <QFuture>
#ifdef STATIC_MAUIKIT
#include "fm.h"
#else
#include <MauiKit/fm.h>
#endif
/* /*
* Sets upthe app default config paths * Sets upthe app default config paths
* BrainDeamon to get collection information * BrainDeamon to get collection information
...@@ -53,13 +59,17 @@ vvave::~vvave() {} ...@@ -53,13 +59,17 @@ vvave::~vvave() {}
void vvave::runBrain() void vvave::runBrain()
{ {
QFutureWatcher<void> *watcher = new QFutureWatcher<void>; QFutureWatcher<void> *watcher = new QFutureWatcher<void>;
QObject::connect(watcher, &QFutureWatcher<void>::finished, [=]()
QObject::connect(watcher, &QFutureWatcher<void>::finished, watcher, &QFutureWatcher<void>::deleteLater);
QObject::connect(qApp, &QCoreApplication::aboutToQuit, [=]()
{ {
watcher->deleteLater(); if(watcher)
watcher->future().waitForFinished();
}); });
auto func = [=]() auto func = [=]()
{ {
// the album artworks package // the album artworks package
...@@ -97,7 +107,6 @@ void vvave::checkCollection(const QStringList &paths, std::function<void(uint)> ...@@ -97,7 +107,6 @@ void vvave::checkCollection(const QStringList &paths, std::function<void(uint)>
cb(newTracks); cb(newTracks);
watcher->deleteLater(); watcher->deleteLater();
}); });
const auto func = [&paths]() -> uint const auto func = [&paths]() -> uint
{ {
auto newPaths = paths; auto newPaths = paths;
...@@ -114,7 +123,6 @@ void vvave::checkCollection(const QStringList &paths, std::function<void(uint)> ...@@ -114,7 +123,6 @@ void vvave::checkCollection(const QStringList &paths, std::function<void(uint)>
} }
//// PUBLIC SLOTS //// PUBLIC SLOTS
QVariantList vvave::sourceFolders() QVariantList vvave::sourceFolders()
...@@ -136,18 +144,62 @@ QString vvave::moodColor(const int &index) ...@@ -136,18 +144,62 @@ QString vvave::moodColor(const int &index)
void vvave::scanDir(const QStringList &paths) void vvave::scanDir(const QStringList &paths)
{ {
this->checkCollection(paths, [this](uint size) this->checkCollection(paths, [=](uint size)
{ {
emit this->refreshTables(size); emit this->refreshTables(size);
runBrain(); // runBrain();
}); });
} }
QStringList vvave::getSourceFolders() QStringList vvave::getSourceFolders()
{ {
const auto folders = this->db->getSourcesFolders(); return this->db->getSourcesFolders();
qDebug()<< folders; }
return folders;
void vvave::openUrls(const QStringList &urls)
{
if(urls.isEmpty()) return;
QVariantList data;
TagInfo info;
for(QString url : urls)
if(db->check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS], FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url))
{
const auto value = this->db->getDBData(QStringList() << url).first();
data << FM::toMap(value);
}
else
{
if(info.feed(url))
{
auto album = BAE::fixString(info.getAlbum());
auto track= info.getTrack();
auto title = BAE::fixString(info.getTitle()); /* to fix*/
auto artist = BAE::fixString(info.getArtist());
auto genre = info.getGenre();
auto sourceUrl = QFileInfo(url).dir().path();
auto duration = info.getDuration();
auto year = info.getYear();
data << QVariantMap({
{FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url},
{FMH::MODEL_NAME[FMH::MODEL_KEY::TRACK], QString::number(track)},
{FMH::MODEL_NAME[FMH::MODEL_KEY::TITLE], title},
{FMH::MODEL_NAME[FMH::MODEL_KEY::ARTIST], artist},
{FMH::MODEL_NAME[FMH::MODEL_KEY::ALBUM], album},
{FMH::MODEL_NAME[FMH::MODEL_KEY::DURATION],QString::number(duration)},
{FMH::MODEL_NAME[FMH::MODEL_KEY::GENRE], genre},
{FMH::MODEL_NAME[FMH::MODEL_KEY::SOURCE], sourceUrl},
{FMH::MODEL_NAME[FMH::MODEL_KEY::FAV],"0"},
{FMH::MODEL_NAME[FMH::MODEL_KEY::RELEASEDATE], QString::number(year)}
});
}
}
qDebug()<<"opening urls " << urls << data;
emit this->openFiles(data);
} }
......
...@@ -25,6 +25,7 @@ signals: ...@@ -25,6 +25,7 @@ signals:
void refreshTracks(); void refreshTracks();
void refreshAlbums(); void refreshAlbums();
void refreshArtists(); void refreshArtists();
void openFiles(QVariantList tracks);
public slots: public slots:
///DB Interfaces ///DB Interfaces
...@@ -34,9 +35,7 @@ public slots: ...@@ -34,9 +35,7 @@ public slots:
void scanDir(const QStringList &paths = BAE::defaultSources); void scanDir(const QStringList &paths = BAE::defaultSources);
QStringList getSourceFolders(); QStringList getSourceFolders();
void openUrls(const QStringList &urls);
}; };
#endif // VVAVE_H #endif // VVAVE_H
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