Commit 610a3225 authored by Camilo Higuita's avatar Camilo Higuita

pause brainz dreamon from interface

parent e909e066
...@@ -214,6 +214,24 @@ void Babe::scanDir(const QString &url) ...@@ -214,6 +214,24 @@ void Babe::scanDir(const QString &url)
emit this->set->collectionPathChanged({url}); emit this->set->collectionPathChanged({url});
} }
void Babe::brainz(const bool &on)
{
this->set->checkCollectionBrainz(on);
}
QVariant Babe::loadSetting(const QString &key, const QString &group, const QVariant &defaultValue)
{
auto res = BAE::loadSettings(key, group, defaultValue);
qDebug()<<res<<"LOADSET RES";
return res;
}
void Babe::saveSetting(const QString &key, const QVariant &value, const QString &group)
{
qDebug()<<key<<value<<group;
BAE::saveSettings(key, value, group);
}
void Babe::savePlaylist(const QStringList &list) void Babe::savePlaylist(const QStringList &list)
{ {
BAE::saveSettings("PLAYLIST", list, "MAINWINDOW"); BAE::saveSettings("PLAYLIST", list, "MAINWINDOW");
......
...@@ -54,10 +54,13 @@ public: ...@@ -54,10 +54,13 @@ public:
/* SETTINGS */ /* SETTINGS */
Q_INVOKABLE void scanDir(const QString &url); Q_INVOKABLE void scanDir(const QString &url);
Q_INVOKABLE void brainz(const bool &on);
/* STATIC METHODS */ /* STATIC METHODS */
Q_INVOKABLE static void saveSetting(const QString &key, const QVariant &value, const QString &group);
Q_INVOKABLE static QVariant loadSetting(const QString &key, const QString &group, const QVariant &defaultValue);
Q_INVOKABLE static void savePlaylist(const QStringList &list); Q_INVOKABLE static void savePlaylist(const QStringList &list);
Q_INVOKABLE static QStringList lastPlaylist(); Q_INVOKABLE static QStringList lastPlaylist();
......
...@@ -68,7 +68,7 @@ settings::settings(QObject *parent) : QObject(parent) ...@@ -68,7 +68,7 @@ settings::settings(QObject *parent) : QObject(parent)
if(BAE::isMobile()) if(BAE::isMobile())
this->populateDB({BAE::MusicPath, BAE::DownloadsPath}); this->populateDB({BAE::MusicPath, BAE::DownloadsPath});
else else
checkCollection(); checkCollectionBrainz(BAE::loadSettings("BRAINZ", "BABE", false).toBool());
connect(this->brainDeamon, &Brain::finished, [this]() connect(this->brainDeamon, &Brain::finished, [this]()
{ {
...@@ -88,9 +88,7 @@ settings::settings(QObject *parent) : QObject(parent) ...@@ -88,9 +88,7 @@ settings::settings(QObject *parent) : QObject(parent)
connect(this->fileLoader, &FileLoader::finished,[this](int size) connect(this->fileLoader, &FileLoader::finished,[this](int size)
{ {
this->brainzOn = true; if(size > 0)
if(size>0)
{ {
this->collectionWatcher(); this->collectionWatcher();
emit refreshTables({{BAE::TABLEMAP[TABLE::TRACKS], true}, emit refreshTables({{BAE::TABLEMAP[TABLE::TRACKS], true},
...@@ -99,13 +97,13 @@ settings::settings(QObject *parent) : QObject(parent) ...@@ -99,13 +97,13 @@ settings::settings(QObject *parent) : QObject(parent)
{BAE::TABLEMAP[TABLE::PLAYLISTS], true}}); {BAE::TABLEMAP[TABLE::PLAYLISTS], true}});
this->startBrainz(1500); this->startBrainz(true, 1500);
}else }else
{ {
this->dirs.clear(); this->dirs.clear();
this->collectionWatcher(); this->collectionWatcher();
this->watcher->removePaths(watcher->directories()); this->watcher->removePaths(watcher->directories());
this->startBrainz(3000); this->startBrainz(BAE::loadSettings("BRAINZ", "BABE", false).toBool(), 3000);
} }
...@@ -204,21 +202,21 @@ void settings::handleDirectoryChanged(const QString &dir) ...@@ -204,21 +202,21 @@ void settings::handleDirectoryChanged(const QString &dir)
} }
void settings::checkCollection() void settings::checkCollectionBrainz(const bool &state)
{ {
// this->refreshCollectionPaths(); // this->refreshCollectionPaths();
// this->collectionWatcher(); // this->collectionWatcher();
this->brainzOn = true; this->startBrainz(state, 3000);
this->startBrainz(3000);
} }
void settings::startBrainz(const uint &speed) void settings::startBrainz(const bool &on, const uint &speed)
{ {
if(this->brainzOn) this->brainDeamon->setInterval(speed);
{ if(on)
this->brainDeamon->setInterval(speed);
this->brainDeamon->start(); this->brainDeamon->start();
} else
this->brainDeamon->pause();
} }
void settings::populateDB(const QStringList &paths) void settings::populateDB(const QStringList &paths)
......
...@@ -31,15 +31,15 @@ class settings : public QObject ...@@ -31,15 +31,15 @@ class settings : public QObject
public: public:
explicit settings(QObject *parent = nullptr); explicit settings(QObject *parent = nullptr);
~settings(); ~settings();
void checkCollection(); void checkCollectionBrainz(const bool &state);
void collectionWatcher(); void collectionWatcher();
private slots: private slots:
void handleDirectoryChanged(const QString &dir); void handleDirectoryChanged(const QString &dir);
void on_remove_clicked(); void on_remove_clicked();
public slots: public slots:
void startBrainz(const uint &speed); void startBrainz(const bool &on, const uint &speed);
void populateDB(const QStringList &paths); void populateDB(const QStringList &paths);
private: private:
...@@ -48,8 +48,6 @@ private: ...@@ -48,8 +48,6 @@ private:
Brain *brainDeamon; Brain *brainDeamon;
YouTube *ytFetch; YouTube *ytFetch;
Socket *babeSocket; Socket *babeSocket;
bool brainzOn = false;
QString pathToRemove; QString pathToRemove;
......
This diff is collapsed.
...@@ -24,6 +24,7 @@ public: ...@@ -24,6 +24,7 @@ public:
~Brain(); ~Brain();
void start(); void start();
void stop(); void stop();
void pause();
bool isRunning() const; bool isRunning() const;
void setInterval(const uint &value); void setInterval(const uint &value);
......
...@@ -85,7 +85,12 @@ ItemDelegate ...@@ -85,7 +85,12 @@ ItemDelegate
{ {
id: artworkCover id: artworkCover
anchors.fill: parent anchors.fill: parent
source: (artwork.length>0 && artwork !== "none" && artwork)? "file://"+encodeURIComponent(artwork) : "qrc:/assets/cover.png" source:
{
if(artwork)
(artwork.length>0 && artwork !== "none")? "file://"+encodeURIComponent(artwork) : "qrc:/assets/cover.png"
else "qrc:/assets/cover.png"
}
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
cache: false cache: false
antialiasing: true antialiasing: true
......
...@@ -90,7 +90,7 @@ Menu ...@@ -90,7 +90,7 @@ Menu
{ {
height: menuItemHeight height: menuItemHeight
txt: "Queue" txt: "Queue"
onTriggered: list.queueTrack(currentIndex) onTriggered: list.queueTrack(list.currentIndex)
} }
TableMenuItem TableMenuItem
...@@ -104,7 +104,7 @@ Menu ...@@ -104,7 +104,7 @@ Menu
{ {
height: menuItemHeight height: menuItemHeight
txt: "Remove" txt: "Remove"
onTriggered: {} onTriggered: listModel.remove(list.currentIndex)
} }
TableMenuItem TableMenuItem
......
...@@ -339,7 +339,7 @@ Item ...@@ -339,7 +339,7 @@ Item
Layout.fillWidth:true Layout.fillWidth:true
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
horizontalAlignment: Qt.AlignHCenter horizontalAlignment: Qt.AlignHCenter
text: currentTrack.title + " - " + currentTrack.artist text: currentTrack.title ? currentTrack.title + " - " + currentTrack.artist : "--- - "+currentTrack.artist
color: bae.foregroundColor() color: bae.foregroundColor()
font.pointSize: 8 font.pointSize: 8
} }
......
...@@ -225,8 +225,14 @@ Drawer ...@@ -225,8 +225,14 @@ Drawer
CheckBox CheckBox
{ {
id: brainzCheck id: brainzCheck
checkState: bae.loadSetting("BRAINZ", "BABE", false) === "true" ? Qt.Checked : Qt.Unchecked
onCheckStateChanged:
{
bae.saveSetting("BRAINZ",brainzCheck.checkState === Qt.Checked ? true : false, "BABE")
bae.brainz(brainzCheck.checkState === Qt.Checked ? true : false)
}
} }
} }
} }
......
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