Commit 89052c97 authored by Camilo Higuita's avatar Camilo Higuita

clean up and refactorize qml js functions

parent 0e0e4df4
This diff is collapsed.
Qt.include("Icons.js")
function playTrack(track)
{
root.currentTrack = track
......@@ -6,6 +9,13 @@ function playTrack(track)
root.title = currentTrack.title + " - " +currentTrack.artist
currentArtwork = con.getAlbumArt(currentTrack.album, currentTrack.artist) || con.getArtistArt(currentTrack.artist)
playIcon.text = Icon.pause
if(con.getTrackBabe(currentTrack.url))
babeBtnIcon.color = "#E91E63"
else
babeBtnIcon.color = babeBtnIcon.defaultColor
}
function stop()
......@@ -14,16 +24,19 @@ function stop()
progressBar.value = 0
coverPlay.visible = false
root.title = "Babe..."
playIcon.text = Icon.play
}
function pauseTrack()
{
player.pause()
playIcon.text = Icon.play
}
function resumeTrack()
{
player.play()
playIcon.text = Icon.pause
}
function nextTrack()
......@@ -53,6 +66,28 @@ function shuffle()
return pos
}
function appendTrack(track)
{
var empty = mainPlaylistTable.count
mainPlaylistTable.model.append(track)
mainPlaylistTable.positionViewAtEnd()
if(empty === 0 && mainPlaylistTable.count>0)
{
mainPlaylistTable.currentIndex = 0
playTrack(mainPlaylistTable.model.get(0))
}
}
function appendAlbum(tracks)
{
for(var i in tracks)
appendTrack(tracks[i])
}
function savePlaylist()
{
var list = []
......@@ -69,3 +104,52 @@ function savePlaylistPos()
{
util.savePlaylistPos(mainPlaylistTable.currentIndex)
}
function clearOutPlaylist()
{
mainPlaylistTable.clearTable()
stop()
}
function cleanPlaylist()
{
var urls = []
for(var i = 0; i < mainPlaylistTable.count; i++)
{
var url = mainPlaylistTable.model.get(i).url
if(urls.indexOf(url)<0)
urls.push(url)
else mainPlaylistTable.model.remove(i)
}
}
function playAlbum(tracks)
{
mainPlaylistTable.clearTable()
for(var i in tracks)
appendTrack(tracks[i])
mainPlaylistTable.currentIndex = 0
playTrack(mainPlaylistTable.model.get(0))
root.currentView = 0
}
function babeTrack()
{
if(con.getTrackBabe(root.currentTrack.url))
{
con.babeTrack(root.currentTrack.url, false)
babeBtnIcon.text = Icon.heartOutline
babeBtnIcon.color = babeBtnIcon.defaultColor
}else
{
con.babeTrack(root.currentTrack.url, true)
babeBtnIcon.text = Icon.heartOutline
babeBtnIcon.color = "#E91E63"
}
}
......@@ -6,7 +6,10 @@
using namespace BAE;
Utils::Utils(QObject *parent) : QObject(parent)
{ }
{
}
void Utils::savePlaylist(const QStringList &list)
{
......@@ -89,3 +92,4 @@ return "#232629";
}
......@@ -21,7 +21,6 @@ public:
Q_INVOKABLE static QString altColor();
};
#endif // UTILS_H
......@@ -25,6 +25,13 @@ BabeGrid
edge: Qt.BottomEdge
interactive: false
Rectangle
{
anchors.fill: parent
z: -999
color: util.altColor()
}
Column
{
anchors.fill: parent
......
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