Commit 3ccff1b2 authored by Camilo Higuita's avatar Camilo Higuita

save tracks on mainplaylist

parent 03c19f69
......@@ -195,6 +195,7 @@ SOURCES += main.cpp \
taglib/fileref.cpp \
taglib/tag.cpp \
taglib/tagunion.cpp \
utils/utils.cpp
RESOURCES += qml.qrc
......@@ -336,7 +337,8 @@ HEADERS += \
taglib/taglib_export.h \
taglib/tagunion.h \
taglib/config.h \
taglib/taglib_config.h
taglib/taglib_config.h \
utils/utils.h
#unix:!macx: LIBS += -L$$PWD/3rdparty/taglib/taglib/ -ltag
......
......@@ -4,6 +4,7 @@
#include <QApplication>
#include "db/collectionDB.h"
#include "utils/bae.h"
#include "utils/utils.h"
#include "settings/settings.h"
#include "services/local/player.h"
#include <QLibrary>
......@@ -25,10 +26,12 @@ int main(int argc, char *argv[])
CollectionDB con;
settings settings;
Player player;
Utils util;
context->setContextProperty("con", &con);
context->setContextProperty("set", &settings);
context->setContextProperty("player", &player);
context->setContextProperty("util", &util);
//#ifdef Q_OS_ANDROID
// KirigamiPlugin::getInstance().registerTypes();
......
......@@ -25,7 +25,7 @@ ApplicationWindow
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
// property int columnWidth: Kirigami.Units.gridUnit * 13
// property int columnWidth: Kirigami.Units.gridUnit * 13
property int columnWidth: 200
property int currentView : 0
......@@ -36,8 +36,8 @@ ApplicationWindow
// minimumWidth: columnWidth
// pageStack.defaultColumnWidth: columnWidth
// pageStack.initialPage: [playlistPage, views]
// pageStack.defaultColumnWidth: columnWidth
// pageStack.initialPage: [playlistPage, views]
function play(track)
{
......@@ -81,6 +81,9 @@ ApplicationWindow
}
}
onClosing: Player.savePlaylist()
Connections
{
target: player
......@@ -129,7 +132,7 @@ ApplicationWindow
id: views
width: parent.width
height: parent.height
// clip: true
// clip: true
Column
{
......@@ -148,13 +151,13 @@ ApplicationWindow
{
id: playlistPage
// Component.onCompleted:
// {
// if(mainPlaylistTable.count>0)
// root.width = columnWidth
// else
// root.width = columnWidth*3
// }
// Component.onCompleted:
// {
// if(mainPlaylistTable.count>0)
// root.width = columnWidth
// else
// root.width = columnWidth*3
// }
GridLayout
{
......@@ -305,6 +308,16 @@ ApplicationWindow
onRowClicked:
{
play(model.get(index))
}
Component.onCompleted:
{
var list = util.lastPlaylist()
for(var i in list)
{
var track = con.get("select * from tracks where url = \""+list[i]+"\"")
appendTrack(track[0])
}
}
}
......
......@@ -31,3 +31,15 @@ function previousTrack()
mainPlaylistTable.currentIndex = previous
playTrack(mainPlaylistTable.model.get(previous))
}
function savePlaylist()
{
var list = []
var n = mainPlaylistTable.count
for(var i=0 ; i<n; i++)
{
var url = mainPlaylistTable.model.get(i).url
list.push(url)
}
util.savePlaylist(list)
}
#include "utils.h"
#include "bae.h"
using namespace BAE;
Utils::Utils(QObject *parent) : QObject(parent)
{ }
void Utils::savePlaylist(const QStringList &list)
{
qDebug()<<"SAVED PLAYLIST:::"<<list;
BAE::saveSettings("PLAYLIST", list, "MAINWINDOW");
}
QStringList Utils::lastPlaylist()
{
return BAE::loadSettings("PLAYLIST","MAINWINDOW",{}).toStringList();
}
#ifndef UTILS_H
#define UTILS_H
#include <QObject>
class Utils : public QObject
{
Q_OBJECT
public:
explicit Utils(QObject *parent = nullptr);
Q_INVOKABLE static void savePlaylist(const QStringList &list);
Q_INVOKABLE static QStringList lastPlaylist();
signals:
public slots:
};
#endif // UTILS_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