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