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

template widgets and initial work on playlists

parent a17a3934
......@@ -17,6 +17,9 @@ var GET = {
favoriteTracks : "select t.*, al.artwork from tracks t inner join albums al on t.album = al.album and t.artist = al.artist where stars > 0 order by stars desc limit 100",
recentTracks: "select t.* , al.artwork from tracks t inner join albums al on t.album = al.album and t.artist = al.artist order by strftime(\"%s\", addDate) desc LIMIT 100",
babedTracks: "select t.* , al.artwork from tracks t inner join albums al on t.album = al.album and t.artist = al.artist where t.babe = 1",
playlistTracks_ : "select t.* , al.artwork from tracks t inner join albums al on t.album = al.album and t.artist = al.artist inner join tracks_playlists pl on pl.url = t.url where pl.playlist = \"%1\" order by strftime(\"%s\", addDate) desc",
colorTracks_: "select t.*, al.artwork from tracks t inner join albums al on al.album = t.album and al.artist = t.artist where t.art = \"%1\""
......
......@@ -65,7 +65,7 @@ public:
bool tagsAlbum(const BAE::DB &track, const QString &value, const QString &context = "");
Q_INVOKABLE bool addPlaylist(const QString &title);
bool trackPlaylist(const QString &url, const QString &playlist);
Q_INVOKABLE bool trackPlaylist(const QString &url, const QString &playlist);
bool addFolder(const QString &url);
......@@ -90,7 +90,7 @@ public:
// QStringList getAlbumTags(const QString &album, const QString &artist);
QStringList getArtistAlbums(const QString &artist);
QStringList getPlaylists();
Q_INVOKABLE QStringList getPlaylists();
bool removePlaylistTrack(const QString &url, const QString &playlist);
bool removePlaylist(const QString &playlist);
......
......@@ -273,6 +273,7 @@ Kirigami.ApplicationWindow
id: searchBox
height: toolBarHeight
color: searchInput.activeFocus ? midColor : midLightColor
Kirigami.Separator
{
Rectangle
......@@ -292,7 +293,7 @@ Kirigami.ApplicationWindow
RowLayout
{
anchors.fill: parent
height: parent.height
Item
{
......@@ -317,6 +318,7 @@ Kirigami.ApplicationWindow
BabeButton
{
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
visible: searchInput.activeFocus
iconName: "edit-clear"
onClicked: clearSearch()
......@@ -356,7 +358,7 @@ Kirigami.ApplicationWindow
globalDrawer: SettingsView
{
id: settingsDrawer
contentItem.implicitWidth: columnWidth
// contentItem.implicitWidth: columnWidth
onIconSizeChanged: toolBarIconSize = size
}
......
......@@ -21,7 +21,6 @@
<file>view_models/BabeScrollBar.qml</file>
<file>assets/bars.gif</file>
<file>view_models/FolderPicker/FolderPickerList.qml</file>
<file>view_models/FolderPicker/FolderPickerDelegate.qml</file>
<file>view_models/BabeGrid/BabeAlbum.qml</file>
<file>view_models/BabeGrid/BabeGrid.qml</file>
<file>view_models/BabeTable/TableDelegate.qml</file>
......@@ -64,5 +63,9 @@
<file>view_models/BabePopup.qml</file>
<file>assets/banner.png</file>
<file>assets/banner.svg</file>
<file>view_models/BabeTable/PlaylistDialog.qml</file>
<file>view_models/BabeDelegate.qml</file>
<file>view_models/BabeList.qml</file>
<file>view_models/BabeTable/HeaderMenu.qml</file>
</qresource>
</RCC>
......@@ -9,7 +9,7 @@ ToolButton
property string iconName
property int iconSize : toolBarIconSize
property string iconColor: foregroundColor
property color iconColor: foregroundColor
readonly property string defaultColor : foregroundColor
// icon.name: isMobile ? "" : babeButton.iconName
......@@ -27,7 +27,7 @@ ToolButton
source: isMobile ? "" : iconName
isMask: true
smooth: true
color: isMobile ? "transparent" : (iconColor || defaultColor)
color: iconColor || defaultColor
}
......
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
ItemDelegate
{
id: listItem
width: parent.width
height: rowHeightAlt
property alias label: labelTxt.text
ColumnLayout
{
anchors.fill: parent
Layout.margins: 10
Label
{
id: labelTxt
Layout.margins: 20
Layout.fillWidth: true
Layout.fillHeight: true
width: parent.width
height: parent.height
horizontalAlignment: Qt.AlignLeft
verticalAlignment: Qt.AlignVCenter
text: labelTxt.text
elide: Text.ElideRight
color: foregroundColor
}
}
}
......@@ -11,7 +11,7 @@ Dialog
modal: true
padding: 10
padding: 0
Material.accent: babeColor
Material.background: backgroundColor
......
......@@ -58,6 +58,7 @@ Item
text: message ? qsTr(message) : qsTr("Nothing here...")
padding: 10
font.bold: true
textFormat: Text.RichText
horizontalAlignment: Qt.AlignHCenter
elide: Text.ElideRight
color: foregroundColor
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
ListView
{
id: babeList
property alias holder : holder
clip: true
highlight: Rectangle
{
width: babeList.width
height: babeList.currentItem.height
color: babeHighlightColor
y: babeList.currentItem.y
}
focus: true
interactive: true
highlightFollowsCurrentItem: false
keyNavigationWraps: !isMobile
keyNavigationEnabled : !isMobile
Keys.onUpPressed: decrementCurrentIndex()
Keys.onDownPressed: incrementCurrentIndex()
Keys.onReturnPressed: rowClicked(currentIndex)
Keys.onEnterPressed: quickPlayTrack(currentIndex)
boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.DragAndOvershootBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: ListView.SnapToItem
addDisplaced: Transition
{
NumberAnimation { properties: "x,y"; duration: 1000 }
}
function clearTable()
{
listModel.clear()
}
BabeHolder
{
id: holder
visible: count === 0
}
Rectangle
{
anchors.fill: parent
color: "transparent"
z: -999
}
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../view_models/FolderPicker"
import "../../utils"
import ".."
ListView
BabeList
{
id: list
holder.message: "<h2>This list is empty</h2><p>You can sdd new music sources from the settings</p>"
// cacheBuffer : 300
property bool headerBar: false
......@@ -23,7 +21,7 @@ ListView
property string headerTitle
property bool headerClose : false
property alias holder : holder
property alias holder : list.holder
signal rowClicked(int index)
signal rowPressed(int index)
......@@ -35,55 +33,6 @@ ListView
signal playAll()
signal appendAll()
clip: true
highlight: Rectangle
{
width: list.width
height: list.currentItem.height
color: babeHighlightColor
y: list.currentItem.y
}
focus: true
interactive: true
highlightFollowsCurrentItem: false
keyNavigationWraps: !isMobile
keyNavigationEnabled : !isMobile
Keys.onUpPressed: decrementCurrentIndex()
Keys.onDownPressed: incrementCurrentIndex()
Keys.onReturnPressed: rowClicked(currentIndex)
Keys.onEnterPressed: quickPlayTrack(currentIndex)
boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.DragAndOvershootBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: ListView.SnapToItem
addDisplaced: Transition
{
NumberAnimation { properties: "x,y"; duration: 1000 }
}
function clearTable()
{
listModel.clear()
}
BabeHolder
{
id: holder
visible: list.count === 0
}
Rectangle
{
anchors.fill: parent
color: "transparent"
z: -999
}
headerPositioning: ListView.OverlayHeader
header: Rectangle
{
......@@ -146,11 +95,37 @@ ListView
{
id: menuBtn
iconName: /*"application-menu"*/ "overflow-menu"
onClicked: {}
onClicked: headerMenu.open()
}
}
}
PlaylistDialog
{
id: playlistDialog
}
HeaderMenu
{
id: headerMenu
onSaveListClicked:
{
console.log(list.count)
if (count > 0)
for(var i in count)
{
var url = listModel.get(i).url
console.log(url)
playlistDialog.tracks.push(url)
}
playlistDialog.open()
}
}
TableMenu
{
......@@ -202,8 +177,6 @@ ListView
ScrollBar.vertical:BabeScrollBar { }
function openItemMenu(index)
{
currentIndex = index
......
import QtQuick 2.0
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../view_models/BabeMenu"
import "../../utils"
import ".."
BabeMenu
{
signal saveListClicked();
BabeMenuItem
{
text: "Queue list"
onTriggered: {}
}
BabeMenuItem
{
text: "Save list to..."
onTriggered: saveListClicked()
}
BabeMenuItem
{
text: "Send list to..."
onTriggered: {}
}
}
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.2 as Kirigami
import "../../view_models/BabeDialog"
import "../../view_models"
BabeDialog
{
title: "Add "+ tracks.length +" tracks to..."
standardButtons: Dialog.Save | Dialog.Cancel
width: isMobile ? parent.width*0.7 : parent.width*0.4
height: parent.height*0.5
property var tracks : []
Column
{
anchors.fill: parent
BabeList
{
id: playlistsList
width: parent.width
height: parent.height
holder.message: "<h2>There's not playlists</h2><br><p>Create a new one and start adding tracks to it<p/>"
ListModel { id: listModel }
model: listModel
delegate: BabeDelegate
{
id: delegate
label: playlist
Connections
{
target: delegate
onClicked:
{
playlistsList.currentIndex = index
}
}
}
Component.onCompleted:
{
var playlists = bae.get("select * from playlists order by addDate desc")
if(playlists.length > 0)
for(var i in playlists)
playlistsList.model.append(playlists[i])
}
}
}
onAccepted: addToPlaylist(tracks)
function addToPlaylist(tracks)
{
if(tracks.length > 0)
for(var i in tracks)
bae.trackPlaylist(tracks[i], playlistsList.model.get(playlistsList.currentIndex).playlist)
}
}
......@@ -39,21 +39,19 @@ BabeMenu
else close()
}
// Label
// {
// id: titleLabel
// visible: root.isMobile
// padding: root.isMobile ? 10 : 0
// font.bold: true
// width: parent.width
// height: root.isMobile ? menuItemHeight : 0
// horizontalAlignment: Qt.AlignHCenter
// elide: Text.ElideRight
// text: list.currentIndex >= 0 ? list.model.get(list.currentIndex).title : ""
// color: root.palette["foreground"]
// }
Label
{
id: titleLabel
visible: root.isMobile
padding: root.isMobile ? 10 : 0
font.bold: true
width: parent.width
height: root.isMobile ? rowHeightAlt : 0
horizontalAlignment: Qt.AlignHCenter
elide: Text.ElideRight
text: list.currentIndex >= 0 ? list.model.get(list.currentIndex).title : ""
color: foregroundColor
}
BabeMenuItem
{
......@@ -69,29 +67,32 @@ BabeMenu
BabeMenuItem
{
text: "Edit..."
onTriggered: {}
text: "Save to..."
onTriggered:
{
playlistDialog.tracks = [list.model.get(list.currentIndex).url]
playlistDialog.open()
}
}
BabeMenuItem
{
text: "Remove"
onTriggered: listModel.remove(list.currentIndex)
text: "Edit..."
onTriggered: {}
}
BabeMenuItem
{
text: "Save..."
text: "Send to..."
onTriggered: {}
}
BabeMenuItem
{
text: "Send to..."
onTriggered: {}
text: "Remove"
onTriggered: listModel.remove(list.currentIndex)
}
BabeMenuItem
{
id: starsRow
......
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
ItemDelegate
{
id: delegate
property string textColor: foregroundColor
width: parent.width
height: rowHeightAlt
// checkable: true
RowLayout
{
id: rowLayout
anchors.fill: parent
spacing:0
Item
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignLeft
Layout.margins: 15
anchors.verticalCenter: parent.verticalCenter
Label
{
id: folderTitle
width: parent.width
height: parent.height
verticalAlignment: Qt.AlignVCenter
text: name
font.bold: true
elide: Text.ElideRight
font.pointSize: 10
color: textColor
}
}
}
}
......@@ -3,7 +3,7 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import ".."
ListView
BabeList
{
id: list
......@@ -14,74 +14,24 @@ ListView
signal rowClicked(int index)
signal rowPressed(int index)
clip: true
highlight: highlight
highlightFollowsCurrentItem: false
focus: true
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: ListView.SnapToItem
function clearTable()
{
listModel.clear()
}
BabeHolder
{
id: holder
visible: list.count === 0
}
Rectangle
{
anchors.fill: parent
color: "transparent"
z: -999
}
Component
{
id: highlight
Rectangle
{
width: list.width
height: list.currentItem.height
color: babeHighlightColor
opacity: 0.2
y: list.currentItem.y
}
}
ListModel { id: listModel }
model: listModel
delegate: FolderPickerDelegate
delegate: BabeDelegate
{
id: delegate
width: list.width
label : name
Connections
{
target: delegate
onPressAndHold:
{
}
onClicked:
{
list.rowClicked(index)
currentIndex = index
// currentUrl = model.get(currentIndex).url
list.rowClicked(index)
}
}
}
......
......@@ -21,10 +21,8 @@ ToolBar
signal playlistsViewClicked()
signal babeViewClicked()
signal playlistViewClicked()
width: parent.width
id: babeBar
visible: false
Rectangle
{
......@@ -33,6 +31,7 @@ ToolBar
Kirigami.Separator
{
Rectangle
{
anchors.fill: parent
......@@ -51,115 +50,109 @@ ToolBar
RowLayout
{
anchors.fill: parent
anchors.centerIn: parent
// spacing: 0
// Layout.margins: 0
BabeButton
{
id: playlistView
iconName: /*"headphones"*/ "media-optical-audio"
iconColor: (pageStack.wideMode || pageStack.currentIndex === 0 ) && !isMobile ? accentColor : textColor
onClicked: playlistViewClicked()
hoverEnabled: !isMobile
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Playlist")
}
Item
{
Layout.fillWidth: true
}
BabeButton
{
id: playlistView
anchors.centerIn: parent
BabeButton
{
id: tracksView
iconName: /*"headphones"*/ "media-optical-audio"
iconColor: (pageStack.wideMode || pageStack.currentIndex === 0 ) && !isMobile ? accentColor : textColor
onClicked: playlistViewClicked()
iconName: /*"musicnote"*/ "filename-filetype-amarok"
iconColor: accent && currentIndex === 0? accentColor : textColor
onClicked: tracksViewClicked()
hoverEnabled: !isMobile
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Playlist")
}
hoverEnabled: true
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Tracks")
}
BabeButton
{
id: albumsView
BabeButton
{
id: tracksView
iconName: /*"musicnote"*/ "filename-filetype-amarok"
iconColor: accent && currentIndex === 0? accentColor : textColor
onClicked: tracksViewClicked()
hoverEnabled: true
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Tracks")
}
iconName