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)
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)
{
BAE::saveSettings("PLAYLIST", list, "MAINWINDOW");
......
......@@ -54,10 +54,13 @@ public:
/* SETTINGS */
Q_INVOKABLE void scanDir(const QString &url);
Q_INVOKABLE void brainz(const bool &on);
/* 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 QStringList lastPlaylist();
......
......@@ -68,7 +68,7 @@ settings::settings(QObject *parent) : QObject(parent)
if(BAE::isMobile())
this->populateDB({BAE::MusicPath, BAE::DownloadsPath});
else
checkCollection();
checkCollectionBrainz(BAE::loadSettings("BRAINZ", "BABE", false).toBool());
connect(this->brainDeamon, &Brain::finished, [this]()
{
......@@ -88,9 +88,7 @@ settings::settings(QObject *parent) : QObject(parent)
connect(this->fileLoader, &FileLoader::finished,[this](int size)
{
this->brainzOn = true;
if(size>0)
if(size > 0)
{
this->collectionWatcher();
emit refreshTables({{BAE::TABLEMAP[TABLE::TRACKS], true},
......@@ -99,13 +97,13 @@ settings::settings(QObject *parent) : QObject(parent)
{BAE::TABLEMAP[TABLE::PLAYLISTS], true}});
this->startBrainz(1500);
this->startBrainz(true, 1500);
}else
{
this->dirs.clear();
this->collectionWatcher();
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)
}
void settings::checkCollection()
void settings::checkCollectionBrainz(const bool &state)
{
// this->refreshCollectionPaths();
// this->collectionWatcher();
this->brainzOn = true;
this->startBrainz(3000);
this->startBrainz(state, 3000);
}
void settings::startBrainz(const uint &speed)
void settings::startBrainz(const bool &on, const uint &speed)
{
if(this->brainzOn)
{
this->brainDeamon->setInterval(speed);
this->brainDeamon->setInterval(speed);
if(on)
this->brainDeamon->start();
}
else
this->brainDeamon->pause();
}
void settings::populateDB(const QStringList &paths)
......
......@@ -31,15 +31,15 @@ class settings : public QObject
public:
explicit settings(QObject *parent = nullptr);
~settings();
void checkCollection();
void collectionWatcher();
void checkCollectionBrainz(const bool &state);
void collectionWatcher();
private slots:
void handleDirectoryChanged(const QString &dir);
void on_remove_clicked();
public slots:
void startBrainz(const uint &speed);
void startBrainz(const bool &on, const uint &speed);
void populateDB(const QStringList &paths);
private:
......@@ -48,8 +48,6 @@ private:
Brain *brainDeamon;
YouTube *ytFetch;
Socket *babeSocket;
bool brainzOn = false;
QString pathToRemove;
......
This diff is collapsed.
......@@ -24,6 +24,7 @@ public:
~Brain();
void start();
void stop();
void pause();
bool isRunning() const;
void setInterval(const uint &value);
......
......@@ -85,7 +85,12 @@ ItemDelegate
{
id: artworkCover
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
cache: false
antialiasing: true
......
......@@ -90,7 +90,7 @@ Menu
{
height: menuItemHeight
txt: "Queue"
onTriggered: list.queueTrack(currentIndex)
onTriggered: list.queueTrack(list.currentIndex)
}
TableMenuItem
......@@ -104,7 +104,7 @@ Menu
{
height: menuItemHeight
txt: "Remove"
onTriggered: {}
onTriggered: listModel.remove(list.currentIndex)
}
TableMenuItem
......
......@@ -339,7 +339,7 @@ Item
Layout.fillWidth:true
Layout.alignment: Qt.AlignCenter
horizontalAlignment: Qt.AlignHCenter
text: currentTrack.title + " - " + currentTrack.artist
text: currentTrack.title ? currentTrack.title + " - " + currentTrack.artist : "--- - "+currentTrack.artist
color: bae.foregroundColor()
font.pointSize: 8
}
......
......@@ -225,8 +225,14 @@ Drawer
CheckBox
{
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