Commit 1a456cd3 authored by Camilo Higuita's avatar Camilo Higuita

babe tracks and more fixes

parent d25c39c7
......@@ -759,7 +759,7 @@ int CollectionDB::getTrackStars(const QString &path)
return stars;
}
int CollectionDB::getTrackBabe(const QString &path)
bool CollectionDB::getTrackBabe(const QString &path)
{
int babe = 0;
auto query = this->getDBData(QString("SELECT %1 FROM %2 WHERE %3 = \"%4\"").arg(KEYMAP[KEY::BABE],
......@@ -769,7 +769,7 @@ int CollectionDB::getTrackBabe(const QString &path)
for(auto track : query)
babe = track[KEY::BABE].toInt();
return babe;
return babe == 0 ? false : true ;
}
QString CollectionDB::getArtistArt(const QString &artist)
......
......@@ -43,7 +43,7 @@ public:
void addTrack(const BAE::DB &track);
bool updateTrack(const BAE::DB &track);
bool rateTrack(const QString &path, const int &value);
bool babeTrack(const QString &path, const bool &value);
Q_INVOKABLE bool babeTrack(const QString &path, const bool &value);
bool moodTrack(const QString &path, const QString &value);
bool artTrack(const QString &path, const QString &value);
bool lyricsTrack(const BAE::DB &track, const QString &value);
......@@ -82,7 +82,7 @@ public:
QString getTrackArt(const QString &path);
QStringList getTrackTags(const QString &path);
int getTrackStars(const QString &path);
int getTrackBabe(const QString &path);
Q_INVOKABLE bool getTrackBabe(const QString &path);
Q_INVOKABLE QString getArtistArt(const QString &artist);
QString getArtistWiki(const QString &artist);
// QStringList getArtistTags(const QString &artist);
......
......@@ -21,6 +21,10 @@ Kirigami.ApplicationWindow
height: 500
title: qsTr("Babe")
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
property int columnWidth: Kirigami.Units.gridUnit * 13
property int currentView : 0
property int iconSize
......@@ -28,12 +32,53 @@ Kirigami.ApplicationWindow
property var currentTrack
property string currentArtwork
signal appendTrack(var track)
// minimumWidth: columnWidth
pageStack.defaultColumnWidth: columnWidth
pageStack.initialPage: [playlistPage, views]
function play(track)
{
Player.playTrack(track)
playIcon.text = MdiFont.Icon.pause
if(con.getTrackBabe(currentTrack.url))
{
babeBtnIcon.text = MdiFont.Icon.heartOutline
babeBtnIcon.color = "#E91E63"
}else
{
babeBtnIcon.text = MdiFont.Icon.heartOutline
babeBtnIcon.color = myPalette.dark
}
}
function pause()
{
Player.pauseTrack()
playIcon.text= MdiFont.Icon.play
}
function resume()
{
Player.resumeTrack()
playIcon.text= MdiFont.Icon.pause
}
function appendTrack(track)
{
var empty = mainPlaylistTable.count
mainPlaylistTable.model.append(track)
mainPlaylistTable.positionViewAtEnd()
if(empty === 0 && mainPlaylistTable.count>0)
{
play(mainPlaylistTable.model.get(0))
}
}
Connections
{
target: player
......@@ -55,10 +100,7 @@ Kirigami.ApplicationWindow
onSettingsViewClicked: currentView = 4
}
onAppendTrack:
{
mainPlaylistTable.model.append(track)
}
Page
{
......@@ -107,7 +149,6 @@ Kirigami.ApplicationWindow
anchors.centerIn: parent
source: currentArtwork ? "file://"+encodeURIComponent(currentArtwork) : "qrc:/assets/cover.png"
fillMode: Image.PreserveAspectFit
}
}
......@@ -145,17 +186,38 @@ Kirigami.ApplicationWindow
Row
{
anchors.centerIn: parent
ToolButton
{
id: previousBtn
Icon {text: MdiFont.Icon.skipPrevious}
onClicked: Player.previousTrack()
Icon
{
id: babeBtnIcon
text: MdiFont.Icon.heartOutline
color: myPalette.dark
}
onClicked:
{
if(con.getTrackBabe(currentTrack.url))
{
con.babeTrack(currentTrack.url, false)
babeBtnIcon.text = MdiFont.Icon.heartOutline
babeBtnIcon.color = myPalette.dark
}else
{
con.babeTrack(currentTrack.url, true)
babeBtnIcon.text = MdiFont.Icon.heartOutline
babeBtnIcon.color = "#E91E63"
}
}
}
ToolButton
{
id: babeBtn
Icon{text: MdiFont.Icon.heartOutline}
id: previousBtn
Icon {text: MdiFont.Icon.skipPrevious}
onClicked: Player.previousTrack()
}
ToolButton
......@@ -164,15 +226,8 @@ Kirigami.ApplicationWindow
Icon {id: playIcon; text: MdiFont.Icon.play }
onClicked:
{
if(player.isPaused())
{
Player.resumeTrack()
playIcon.text= MdiFont.Icon.pause
}else
{
Player.pauseTrack()
playIcon.text= MdiFont.Icon.play
}
if(player.isPaused()) resume()
else pause()
}
}
......@@ -183,6 +238,12 @@ Kirigami.ApplicationWindow
onClicked: Player.nextTrack()
}
ToolButton
{
id: shuffleBtn
Icon{text: MdiFont.Icon.shuffle}
}
}
}
}
......@@ -202,8 +263,8 @@ Kirigami.ApplicationWindow
height: parent.height
onRowClicked:
{
Player.playTrack(model.get(index))
playIcon.text = MdiFont.Icon.pause
play(model.get(index))
}
}
}
......@@ -244,8 +305,7 @@ Kirigami.ApplicationWindow
mainPlaylistTable.clearTable()
for(var i in tracks)
appendTrack(tracks[i])
Player.playTrack(mainPlaylistTable.model.get(0))
playIcon.text= MdiFont.Icon.pause
play(mainPlaylistTable.model.get(0))
}
onAppendAlbum:
{
......@@ -263,8 +323,7 @@ Kirigami.ApplicationWindow
mainPlaylistTable.clearTable()
for(var i in tracks)
appendTrack(tracks[i])
Player.playTrack(mainPlaylistTable.model.get(0))
playIcon.text= MdiFont.Icon.pause
play(mainPlaylistTable.model.get(0))
}
onAppendAlbum:
{
......
......@@ -71,7 +71,7 @@ Pane
}
}
ScrollBar.vertical: ScrollBar{}
// ScrollBar.vertical: ScrollBar{}
}
}
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