Commit 28b29d8d authored by Camilo Higuita's avatar Camilo Higuita

move settings to kirigami globaldrawer and initial work on babeplatform integration

parent e72ebd93
...@@ -242,6 +242,11 @@ void Babe::brainz(const bool &on) ...@@ -242,6 +242,11 @@ void Babe::brainz(const bool &on)
this->set->checkCollectionBrainz(on); this->set->checkCollectionBrainz(on);
} }
bool Babe::brainzState()
{
return loadSetting("BRAINZ", "BABE", false).toBool();
}
QVariant Babe::loadSetting(const QString &key, const QString &group, const QVariant &defaultValue) QVariant Babe::loadSetting(const QString &key, const QString &group, const QVariant &defaultValue)
{ {
return BAE::loadSettings(key, group, defaultValue); return BAE::loadSettings(key, group, defaultValue);
...@@ -412,10 +417,11 @@ QString Babe::altColor() ...@@ -412,10 +417,11 @@ QString Babe::altColor()
QString Babe::babeColor() QString Babe::babeColor()
{ {
return "#E91E63"; return "#f84172";
// return "#E91E63";
} }
void Babe::androidStatusBarColor() void Babe::androidStatusBarColor(const QString &color)
{ {
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
...@@ -423,7 +429,7 @@ void Babe::androidStatusBarColor() ...@@ -423,7 +429,7 @@ void Babe::androidStatusBarColor()
QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;"); QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
window.callMethod<void>("addFlags", "(I)V", 0x80000000); window.callMethod<void>("addFlags", "(I)V", 0x80000000);
window.callMethod<void>("clearFlags", "(I)V", 0x04000000); window.callMethod<void>("clearFlags", "(I)V", 0x04000000);
window.callMethod<void>("setStatusBarColor", "(I)V", QColor(Babe::backgroundColor()).rgba()); window.callMethod<void>("setStatusBarColor", "(I)V", QColor(color).rgba());
}); });
#endif #endif
} }
......
...@@ -60,6 +60,7 @@ public: ...@@ -60,6 +60,7 @@ public:
Q_INVOKABLE void scanDir(const QString &url); Q_INVOKABLE void scanDir(const QString &url);
Q_INVOKABLE void brainz(const bool &on); Q_INVOKABLE void brainz(const bool &on);
Q_INVOKABLE bool brainzState();
/* STATIC METHODS */ /* STATIC METHODS */
...@@ -87,7 +88,7 @@ public: ...@@ -87,7 +88,7 @@ public:
Q_INVOKABLE static QString shadowColor(); Q_INVOKABLE static QString shadowColor();
Q_INVOKABLE static QString altColor(); Q_INVOKABLE static QString altColor();
Q_INVOKABLE static QString babeColor(); Q_INVOKABLE static QString babeColor();
Q_INVOKABLE static void androidStatusBarColor(); Q_INVOKABLE static void androidStatusBarColor(const QString &color);
Q_INVOKABLE static bool isMobile(); Q_INVOKABLE static bool isMobile();
Q_INVOKABLE static int screenGeometry(QString side); Q_INVOKABLE static int screenGeometry(QString side);
...@@ -126,7 +127,9 @@ signals: ...@@ -126,7 +127,9 @@ signals:
void trackLyricsReady(QString lyrics, QString url); void trackLyricsReady(QString lyrics, QString url);
void skipTrack(); void skipTrack();
void babeIt(); void babeIt();
public slots:
friend class CollectionDB;
}; };
#endif // BABE_H #endif // BABE_H
...@@ -40,7 +40,6 @@ int main(int argc, char *argv[]) ...@@ -40,7 +40,6 @@ int main(int argc, char *argv[])
engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty()) if (engine.rootObjects().isEmpty())
return -1; return -1;
bae.androidStatusBarColor();
return app.exec(); return app.exec();
} }
...@@ -24,6 +24,7 @@ Kirigami.ApplicationWindow ...@@ -24,6 +24,7 @@ Kirigami.ApplicationWindow
title: qsTr("Babe") title: qsTr("Babe")
wideScreen: root.width > coverSize wideScreen: root.width > coverSize
Material.theme: Material.Light Material.theme: Material.Light
Material.accent: bae.babeColor() Material.accent: bae.babeColor()
Material.background: bae.backgroundColor() Material.background: bae.backgroundColor()
...@@ -33,7 +34,7 @@ Kirigami.ApplicationWindow ...@@ -33,7 +34,7 @@ Kirigami.ApplicationWindow
signal missingAlert(var track) signal missingAlert(var track)
readonly property bool isMobile: bae.isMobile() readonly property bool isMobile: bae.isMobile()
readonly property int wideSize : bae.screenGeometry("width")*0.5 readonly property int wideSize : bae.screenGeometry("width")*0.5
readonly property int toolBarIconSize: isMobile ? 24 : 22 property int toolBarIconSize: isMobile ? 24 : 22
readonly property int rowHeight: isMobile ? 64 : 52 readonly property int rowHeight: isMobile ? 64 : 52
readonly property int rowHeightAlt: isMobile ? 48 : 32 readonly property int rowHeightAlt: isMobile ? 48 : 32
...@@ -66,6 +67,20 @@ Kirigami.ApplicationWindow ...@@ -66,6 +67,20 @@ Kirigami.ApplicationWindow
onClosing: Player.savePlaylist() onClosing: Player.savePlaylist()
pageStack.onCurrentIndexChanged:
{
if(pageStack.currentIndex === 0 && isMobile && !pageStack.wideMode)
{
bae.androidStatusBarColor(bae.babeColor())
Material.background = bae.babeColor()
}else
{
bae.androidStatusBarColor(bae.backgroundColor())
Material.background = bae.backgroundColor()
}
}
BabeDialog BabeDialog
{ {
...@@ -102,7 +117,7 @@ Kirigami.ApplicationWindow ...@@ -102,7 +117,7 @@ Kirigami.ApplicationWindow
searchView.populate(searchView.searchRes) searchView.populate(searchView.searchRes)
} }
// albumsView.filter(res) // albumsView.filter(res)
currentView = 4 currentView = 5
pageStack.currentIndex = 1 pageStack.currentIndex = 1
} }
} }
...@@ -155,6 +170,8 @@ Kirigami.ApplicationWindow ...@@ -155,6 +170,8 @@ Kirigami.ApplicationWindow
visible: true visible: true
size: toolBarIconSize size: toolBarIconSize
currentIndex: currentView currentIndex: currentView
backgroundColor: pageStack.currentIndex === 0 && !pageStack.wideMode ? bae.babeColor() : bae.backgroundColor()
onPlaylistViewClicked: onPlaylistViewClicked:
{ {
...@@ -203,7 +220,14 @@ Kirigami.ApplicationWindow ...@@ -203,7 +220,14 @@ Kirigami.ApplicationWindow
currentView = 3 currentView = 3
} }
onSettingsViewClicked: settingsDrawer.visible ? settingsDrawer.close() : settingsDrawer.open() onBabeViewClicked:
{
if(!isMobile && !pageStack.wideMode)
root.width = wideSize
pageStack.currentIndex = 1
currentView = 4
}
} }
footer: Rectangle footer: Rectangle
...@@ -274,10 +298,11 @@ Kirigami.ApplicationWindow ...@@ -274,10 +298,11 @@ Kirigami.ApplicationWindow
z: -999 z: -999
} }
SettingsView globalDrawer: SettingsView
{ {
id: settingsDrawer id: settingsDrawer
onIconSizeChanged: toolBarIconSize = (size === 24 && isMobile) ? 24 : 22 contentItem.implicitWidth: columnWidth
onIconSizeChanged: toolBarIconSize = size
} }
...@@ -325,6 +350,7 @@ Kirigami.ApplicationWindow ...@@ -325,6 +350,7 @@ Kirigami.ApplicationWindow
currentView = currentIndex currentView = currentIndex
if(currentView === 0) mainPlaylist.list.forceActiveFocus() if(currentView === 0) mainPlaylist.list.forceActiveFocus()
else if(currentView === 1) tracksView.forceActiveFocus() else if(currentView === 1) tracksView.forceActiveFocus()
} }
TracksView TracksView
...@@ -382,6 +408,11 @@ Kirigami.ApplicationWindow ...@@ -382,6 +408,11 @@ Kirigami.ApplicationWindow
} }
} }
Item
{
id: babeView
}
SearchTable SearchTable
{ {
......
...@@ -205,8 +205,7 @@ void BabeSettings::handleDirectoryChanged(const QString &dir) ...@@ -205,8 +205,7 @@ void BabeSettings::handleDirectoryChanged(const QString &dir)
void BabeSettings::checkCollectionBrainz(const bool &state) void BabeSettings::checkCollectionBrainz(const bool &state)
{ {
// this->refreshCollectionPaths(); qDebug()<<"BRAINZ STATE<<"<<state;
// this->collectionWatcher();
this->startBrainz(state, 3000); this->startBrainz(state, 3000);
} }
......
...@@ -1691,6 +1691,7 @@ var Babe = { ...@@ -1691,6 +1691,7 @@ var Babe = {
"love": Icon.heartOutline, "love": Icon.heartOutline,
"media-playlist-shuffle": "\uf49D", "media-playlist-shuffle": "\uf49D",
"media-playlist-repeat": "\uf49E", "media-playlist-repeat": "\uf49E",
"babe" : Icon.heart,
"arrow-left":"\uf04D", "arrow-left":"\uf04D",
......
...@@ -13,7 +13,7 @@ ToolButton ...@@ -13,7 +13,7 @@ ToolButton
icon.name: isMobile ? "" : babeButton.iconName icon.name: isMobile ? "" : babeButton.iconName
icon.width: isMobile ? 0 : babeButton.iconSize icon.width: isMobile ? 0 : babeButton.iconSize
// icon.height: isMobile ? 0 : babeButton.iconSize // icon.height: isMobile ? 0 : babeButton.iconSize
icon.color: isMobile ? "transparent" : (iconColor || defaultColor) icon.color: isMobile ? "transparent" : (iconColor || defaultColor)
BabeIcon BabeIcon
{ {
......
...@@ -20,7 +20,7 @@ ToolBar ...@@ -20,7 +20,7 @@ ToolBar
signal albumsViewClicked() signal albumsViewClicked()
signal artistsViewClicked() signal artistsViewClicked()
signal playlistsViewClicked() signal playlistsViewClicked()
signal settingsViewClicked() signal babeViewClicked()
signal playlistViewClicked() signal playlistViewClicked()
...@@ -61,7 +61,7 @@ ToolBar ...@@ -61,7 +61,7 @@ ToolBar
{ {
id: playlistView id: playlistView
iconName: /*"headphones"*/ "media-optical-audio" iconName: /*"headphones"*/ "media-optical-audio"
iconColor: pageStack.wideMode || pageStack.currentIndex === 0 ? accentColor : textColor iconColor: textColor
iconSize: size iconSize: size
onClicked: playlistViewClicked() onClicked: playlistViewClicked()
...@@ -69,7 +69,7 @@ ToolBar ...@@ -69,7 +69,7 @@ ToolBar
hoverEnabled: !isMobile hoverEnabled: !isMobile
ToolTip.delay: 1000 ToolTip.delay: 1000
ToolTip.timeout: 5000 ToolTip.timeout: 5000
ToolTip.visible: hovered ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Playlist") ToolTip.text: qsTr("Playlist")
} }
} }
...@@ -89,7 +89,7 @@ ToolBar ...@@ -89,7 +89,7 @@ ToolBar
hoverEnabled: true hoverEnabled: true
ToolTip.delay: 1000 ToolTip.delay: 1000
ToolTip.timeout: 5000 ToolTip.timeout: 5000
ToolTip.visible: hovered ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Tracks") ToolTip.text: qsTr("Tracks")
} }
...@@ -104,7 +104,7 @@ ToolBar ...@@ -104,7 +104,7 @@ ToolBar
hoverEnabled: true hoverEnabled: true
ToolTip.delay: 1000 ToolTip.delay: 1000
ToolTip.timeout: 5000 ToolTip.timeout: 5000
ToolTip.visible: hovered ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Albums") ToolTip.text: qsTr("Albums")
} }
...@@ -120,7 +120,7 @@ ToolBar ...@@ -120,7 +120,7 @@ ToolBar
hoverEnabled: true hoverEnabled: true
ToolTip.delay: 1000 ToolTip.delay: 1000
ToolTip.timeout: 5000 ToolTip.timeout: 5000
ToolTip.visible: hovered ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Artists") ToolTip.text: qsTr("Artists")
} }
...@@ -137,7 +137,7 @@ ToolBar ...@@ -137,7 +137,7 @@ ToolBar
hoverEnabled: !isMobile hoverEnabled: !isMobile
ToolTip.delay: 1000 ToolTip.delay: 1000
ToolTip.timeout: 5000 ToolTip.timeout: 5000
ToolTip.visible: hovered ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Playlists") ToolTip.text: qsTr("Playlists")
} }
} }
...@@ -148,19 +148,17 @@ ToolBar ...@@ -148,19 +148,17 @@ ToolBar
BabeButton BabeButton
{ {
id: settingsIcon iconName: "love"
iconColor: accent && currentIndex === 4? accentColor : textColor
iconName: /*"application-menu"*/"games-config-options"
iconColor: settingsDrawer.visible ? accentColor : textColor
iconSize: size iconSize: size
onClicked: settingsViewClicked() onClicked: babeViewClicked()
hoverEnabled: !isMobile hoverEnabled: !isMobile
ToolTip.delay: 1000 ToolTip.delay: 1000
ToolTip.timeout: 5000 ToolTip.timeout: 5000
ToolTip.visible: hovered ToolTip.visible: hovered && !isMobile
ToolTip.text: qsTr("Settings") ToolTip.text: qsTr("Babe")
} }
} }
} }
......
...@@ -71,7 +71,7 @@ Item ...@@ -71,7 +71,7 @@ Item
Rectangle Rectangle
{ {
anchors.fill: parent anchors.fill: parent
color: bae.midLightColor() color: bae.midColor()
z: -999 z: -999
} }
...@@ -81,7 +81,8 @@ Item ...@@ -81,7 +81,8 @@ Item
height: mainPlaylistItem.y height: mainPlaylistItem.y
source: artwork source: artwork
radius: 100 radius: 100
transparentBorder: true transparentBorder: false
// opacity: 0.8
cached: true cached: true
} }
......
...@@ -2,23 +2,35 @@ import QtQuick 2.9 ...@@ -2,23 +2,35 @@ import QtQuick 2.9
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import Qt.labs.platform 1.0 import Qt.labs.platform 1.0
import org.kde.kirigami 2.2 as Kirigami
import "../view_models" import "../view_models"
import "../view_models/FolderPicker" import "../view_models/FolderPicker"
Drawer Kirigami.GlobalDrawer
{ {
id: settingsView id: settingsView
handleVisible: true
signal iconSizeChanged(int size)
readonly property bool activeBrainz : bae.brainzState()
y: header.height y: header.height
height: parent.height - header.height - footer.height height: parent.height - header.height - footer.height
width: root.pageStack.wideMode ? views.width -1: root.width // width: root.pageStack.wideMode ? views.width -1: root.width
edge: Qt.RightEdge edge: Qt.RightEdge
interactive: true // // interactive: true
focus: true // focus: true
modal:true // modal:true
dragMargin :0 // dragMargin :0
signal iconSizeChanged(int size)
topPadding: 0
bottomPadding: 0
leftPadding: 0
rightPadding: 0
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
function scanDir(folderUrl) function scanDir(folderUrl)
...@@ -26,12 +38,18 @@ Drawer ...@@ -26,12 +38,18 @@ Drawer
bae.scanDir(folderUrl) bae.scanDir(folderUrl)
} }
background: Rectangle // background: Rectangle
{ // {
anchors.fill: parent // anchors.fill: parent
color: bae.backgroundColor() // color: bae.backgroundColor()
z: -999 // z: -999
} // }
// contentItem: Text
// {
// color: bae.foregroundColor()
// }
FolderDialog FolderDialog
{ {
...@@ -65,167 +83,149 @@ Drawer ...@@ -65,167 +83,149 @@ Drawer
} }
} }
Rectangle
topContent: ColumnLayout
{ {
id: content width: settingsView.width
anchors.fill: parent height: settingsView.height * 0.5
color: bae.midLightColor()
ColumnLayout
{
width: settingsView.width
height: settingsView.height
ListView ListView
{
id: sources
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
Rectangle
{ {
id: sources anchors.fill: parent
Layout.fillWidth: true z: -999
Layout.fillHeight: true color: bae.altColor()
clip: true }
Rectangle ListModel
{ {
anchors.fill: parent id: listModel
z: -999 }
color: bae.altColor()
}
ListModel model: listModel
{
id: listModel
}
model: listModel delegate: ItemDelegate
{
width: parent.width
delegate: ItemDelegate contentItem: ColumnLayout
{ {
spacing: 2
width: parent.width width: parent.width
contentItem: ColumnLayout Label
{ {
spacing: 2 id: sourceUrl
width: parent.width width: parent.width
text: url
Label elide: Text.ElideRight
{ Layout.fillWidth: true
id: sourceUrl font.pointSize: 10
width: parent.width color: bae.foregroundColor()
text: url
elide: Text.ElideRight
Layout.fillWidth: true
font.pointSize: 10
color: bae.foregroundColor()
}
} }
} }
Component.onCompleted:
{
var map = bae.get("select url from folders order by addDate desc")
for(var i in map)
model.append(map[i])
}
} }
Row Component.onCompleted:
{ {
id: sourceActions var map = bae.get("select url from folders order by addDate desc")
Layout.fillWidth: true for(var i in map)
Layout.alignment: Qt.AlignRight model.append(map[i])
height: 48
BabeButton }
{ }
id: addSource
iconName: "list-add" Row
{
id: sourceActions
Layout.fillWidth: true
Layout.alignment: Qt.AlignRight
height: 48
onClicked: BabeButton
{ {
id: addSource
if(bae.isMobile()) iconName: "list-add"
{
folderPicker.open()
folderPicker.load(bae.homeDir())
}else
folderDialog.open()
} onClicked:
}
BabeButton
{ {
id: removeSource
iconName: "list-remove"
onClicked:
{
} if(bae.isMobile())
{
folderPicker.open()
folderPicker.load(bae.homeDir())
}else
folderDialog.open()
} }
} }
Row BabeButton
{ {
Layout.fillWidth: true id: removeSource
height: 48 iconName: "list-remove"
Label onClicked:
{ {
padding: 20
text: "Toolbar icon size"
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
color: bae.foregroundColor()
} }
ComboBox
{
id: iconSize
model: ListModel
{
id: sizes
ListElement { size: 16 }
ListElement { size: 24 }
ListElement { size: 32 }
}
currentIndex: 1
onCurrentIndexChanged: iconSizeChanged(sizes.get(currentIndex).size )
}
} }
}
Row Kirigami.Separator
{ {
Layout.fillWidth: true Layout.fillWidth: true
height: 48 Layout.maximumHeight: 1//implicitHeight
Label }
{
padding: 20
text: "Brainz"
elide: Text.ElideRight