Commit ac0991cd authored by Camilo Higuita's avatar Camilo Higuita

initial work on spotify streaming service

parent e29f8218
breeze-icons @ a54611fa
Subproject commit dc7909ded2d29e27956f6df0a61fc10d890ba2c6
Subproject commit a54611fafe2c47d2f2ff2bbe21dbcf234a855ec2
......@@ -3,4 +3,4 @@
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
sdk.dir=/home/camilo/Android/Sdk
sdk.dir=/opt/android-sdk
......@@ -6,8 +6,6 @@ import QtQuick.Controls.Material 2.1
import QtQuick.Window 2.3
import "services/local"
import "utils"
import "widgets"
......@@ -19,7 +17,10 @@ import "widgets/SearchView"
import "view_models"
import "view_models/BabeDialog"
import "services/local"
import "services/web"
import "services/web/Spotify"
import "db/Queries.js" as Q
import "utils/Player.js" as Player
......@@ -114,8 +115,10 @@ Kirigami.ApplicationWindow
playlists: 3,
search: 4,
vvave: 5,
youtube: 6,
linking: 7
linking: 6,
youtube: 7,
spotify: 8
})
property string syncPlaylist: ""
......@@ -778,7 +781,8 @@ Kirigami.ApplicationWindow
onCurrentItemChanged: currentItem.forceActiveFocus()
onCurrentIndexChanged: {
onCurrentIndexChanged:
{
currentView = currentIndex
if (pageStack.currentIndex === 0)
mainPlaylist.list.forceActiveFocus()
......@@ -842,7 +846,8 @@ Kirigami.ApplicationWindow
onQuickPlayTrack: Player.quickPlay(track)
onPlayAll: Player.playAll(tracks)
onAppendAll: Player.appendAll(tracks)
onPlaySync: {
onPlaySync:
{
var tracks = bae.get(Q.GET.playlistTracks_.arg(playlist))
Player.playAll(tracks)
root.sync = true
......@@ -860,15 +865,12 @@ Kirigami.ApplicationWindow
Connections
{
target: searchView.searchTable
onRowClicked: Player.addTrack(
searchView.searchTable.model.get(
index))
onQuickPlayTrack: Player.quickPlay(
searchView.searchTable.model.get(
index))
onRowClicked: Player.addTrack(searchView.searchTable.model.get(index))
onQuickPlayTrack: Player.quickPlay(searchView.searchTable.model.get(index))
onPlayAll: Player.playAll(searchView.searchRes)
onAppendAll: Player.appendAll(searchView.searchRes)
onArtworkDoubleClicked: {
onArtworkDoubleClicked:
{
var query = Q.GET.albumTracks_.arg(
searchView.searchTable.model.get(
index).album)
......@@ -885,14 +887,19 @@ Kirigami.ApplicationWindow
id: babeitView
}
LinkingView
{
id: linkingView
}
YouTube
{
id: youtubeView
}
LinkingView
Spotify
{
id: linkingView
id: spotifyView
}
}
}
......
......@@ -83,5 +83,7 @@
<file>widgets/MainPlaylist/AlbumsRoll.qml</file>
<file>assets/heart_indicator.gif</file>
<file>assets/heart_indicator_white.gif</file>
<file>services/web/Spotify/Spotify.qml</file>
<file>services/web/Spotify/LoginForm.qml</file>
</qresource>
</RCC>
import QtQuick 2.0
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtWebEngine 1.5
import "../../../view_models"
Item {
BabePopup
{
padding: 0
maxHeight: parent.height * 0.8
maxWidth: parent.width * 0.5
closePolicy: Popup.CloseOnPressOutsideParent
WebEngineView
{
anchors.fill: parent
url: "https://accounts.spotify.com/en/authorize?response_type=code&client_id=a49552c9276745f5b4752250c2d84367&scope=streaming&redirect_uri=vvave:%2F%2Fcallback"
onLoadingChanged:
{
if(loadRequest.status === WebEngineLoadRequest.LoadSucceededStatus)
console.log("page loaded sucessfully")
}
}
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../../view_models"
import "../../../view_models/BabeTable"
import org.kde.kirigami 2.2 as Kirigami
Page
{
Loader
{
id: loginLoader
}
Component
{
id: loginForm
LoginForm
{
parent: spotifyView
}
}
ColumnLayout
{
anchors.fill: parent
spacing: 0
BabeTable
{
Layout.fillWidth: true
Layout.fillHeight: true
headerBarExit: false
headerBarLeft: BabeButton
{
iconName: "internet-services"
onClicked:
{
loginLoader.sourceComponent = loginForm
loginLoader.item.open()
}
}
}
ToolBar
{
id: searchBox
Layout.fillWidth: true
position: ToolBar.Footer
RowLayout
{
anchors.fill: parent
TextInput
{
id: searchInput
color: textColor
Layout.fillWidth: true
Layout.fillHeight: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
selectByMouse: !isMobile
selectionColor: highlightColor
selectedTextColor: highlightedTextColor
focus: true
text: ""
wrapMode: TextEdit.Wrap
onAccepted: runSearch(searchInput.text)
}
BabeButton
{
Layout.rightMargin: contentMargins
iconName: "edit-clear"
onClicked: searchInput.clear()
}
}
}
}
}
#include "spotify.h"
spotify::spotify(QObject *parent) : QObject(parent)
#include <QObject>
#include <QtNetwork>
#include <QUrl>
#include <QNetworkAccessManager>
#include <QDomDocument>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QJsonDocument>
#include <QVariantMap>
using namespace BAE;
Spotify::Spotify(QObject *parent) : QObject(parent)
{
}
......@@ -2,16 +2,21 @@
#define SPOTIFY_H
#include <QObject>
#include <QWidget>
#include <QMap>
class spotify : public QObject
#include "../../../pulpo/pulpo.h"
#include "../../../utils/bae.h"
class Spotify : public QObject
{
Q_OBJECT
public:
explicit spotify(QObject *parent = nullptr);
explicit Spotify(QObject *parent = nullptr);
signals:
public slots:
};
#endif // SPOTIFY_H
\ No newline at end of file
#endif // SPOTIFY_H
......@@ -7,38 +7,37 @@
#include "../../pulpo/pulpo.h"
#include "../../utils/bae.h"
class YouTube : public QObject
{
Q_OBJECT
enum class METHOD : uint8_t
{
SEARCH
};
public:
explicit YouTube(QObject *parent = nullptr);
~YouTube();
Q_INVOKABLE bool getQuery(const QString &query, const int &limit = 5);
bool packQueryResults(const QByteArray &array);
void getId(const QString &results);
void getUrl(const QString &id);
Q_INVOKABLE QString getKey() const;
QByteArray startConnection(const QString &url, const QMap<QString, QString> &headers = {});
Q_INVOKABLE static QUrl fromUserInput(const QString &userInput);
private:
const QString KEY = "AIzaSyDMLmTSEN7i6psE2tHdaG6hy3ljWKXIYBk";
const QMap<METHOD, QString> API =
{
{METHOD::SEARCH, "https://www.googleapis.com/youtube/v3/search?"}
};
signals:
void queryResultsReady(QVariantList res);
Q_OBJECT
enum class METHOD : uint8_t
{
SEARCH
};
public:
explicit YouTube(QObject *parent = nullptr);
~YouTube();
Q_INVOKABLE bool getQuery(const QString &query, const int &limit = 5);
bool packQueryResults(const QByteArray &array);
void getId(const QString &results);
void getUrl(const QString &id);
Q_INVOKABLE QString getKey() const;
QByteArray startConnection(const QString &url, const QMap<QString, QString> &headers = {});
Q_INVOKABLE static QUrl fromUserInput(const QString &userInput);
private:
const QString KEY = "AIzaSyDMLmTSEN7i6psE2tHdaG6hy3ljWKXIYBk";
const QMap<METHOD, QString> API =
{
{METHOD::SEARCH, "https://www.googleapis.com/youtube/v3/search?"}
};
signals:
void queryResultsReady(QVariantList res);
};
#endif // YOUTUBE_H
......@@ -2,11 +2,12 @@ import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1
import org.kde.kirigami 2.2 as Kirigami
Popup
{
property int maxWidth : 200
property int maxHeight : 200
property int maxWidth : Kirigami.Units.devicePixelRatio * 200
property int maxHeight : maxWidth
parent: ApplicationWindow.overlay
......@@ -31,8 +32,8 @@ Popup
clip: true
margins: 1
padding: 2
margins: 0
padding: space.small
enter: Transition
{
......
......@@ -140,9 +140,7 @@ ItemDelegate
height: parent.height * 0.4
width: height
anchors.bottom: parent.bottom
anchors.bottomMargin: space.big
anchors.horizontalCenter:parent.horizontalCenter
anchors.centerIn: parent
radius: Math.min(width, height)
color: "white"
......
......@@ -67,7 +67,8 @@ SOURCES += main.cpp \
utils/babeconsole.cpp \
services/local/youtubedl.cpp \
services/local/linking.cpp \
settings/fileloader.cpp
settings/fileloader.cpp \
services/web/Spotify/spotify.cpp
RESOURCES += qml.qrc \
......@@ -113,7 +114,8 @@ HEADERS += \
utils/babeconsole.h \
utils/singleton.h \
services/local/youtubedl.h \
services/local/linking.h
services/local/linking.h \
services/web/Spotify/spotify.h
#TAGLIB
......
......@@ -60,6 +60,18 @@ Kirigami.GlobalDrawer
}
},
Kirigami.Action
{
text: qsTr("Linking")
iconName: isMobile ? "computer-laptop" : "phone"
onTriggered:
{
pageStack.currentIndex = 1
currentView = viewsIndex.linking
if(!isLinked) linkingView.linkingConf.open()
}
},
Kirigami.Action
{
text: qsTr("YouTube")
......@@ -73,17 +85,14 @@ Kirigami.GlobalDrawer
Kirigami.Action
{
text: qsTr("Linking")
iconName: isMobile ? "computer-laptop" : "phone"
text: qsTr("Spotify")
onTriggered:
{
pageStack.currentIndex = 1
currentView = viewsIndex.linking
if(!isLinked) linkingView.linkingConf.open()
currentView = viewsIndex.spotify
}
},
Kirigami.Action
{
text: qsTr("Collection")
......
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