Commit e0e31f6a authored by Camilo higuita's avatar Camilo higuita

not more pulpo brain breaks and redo the thing and fight the pointers and make it all async

parent bc6ce57d
......@@ -158,10 +158,10 @@ void Babe::trackLyrics(const QString &url)
if(track.isEmpty()) return;
qDebug()<< "Getting lyrics for track"<< track.first()[FMH::MODEL_KEY::TITLE];
if(!track.first()[FMH::MODEL_KEY::LYRICS].isEmpty() && track.first()[FMH::MODEL_KEY::LYRICS] != SLANG[W::NONE])
emit this->trackLyricsReady(track.first()[FMH::MODEL_KEY::LYRICS], url);
else
// qDebug()<< "Getting lyrics for track"<< track.first()[FMH::MODEL_KEY::TITLE];
// if(!track.first()[FMH::MODEL_KEY::LYRICS].isEmpty() && track.first()[FMH::MODEL_KEY::LYRICS] != SLANG[W::NONE])
// emit this->trackLyricsReady(track.first()[FMH::MODEL_KEY::LYRICS], url);
// else
this->fetchTrackLyrics(track.first());
}
......@@ -208,15 +208,31 @@ QString Babe::albumArt(const QString &album, const QString &artist)
}
void Babe::fetchTrackLyrics(FMH::MODEL &song)
{
this->pulpo->registerServices({SERVICES::LyricWikia, SERVICES::Genius});
this->pulpo->setOntology(PULPO::ONTOLOGY::TRACK);
this->pulpo->setInfo(PULPO::INFO::LYRICS);
{/*
auto p = new Pulpo(this);
connect(p, &Pulpo::infoReady, [=](const FMH::MODEL &track, const PULPO::RESPONSE &res)
{
qDebug()<<"GOT THE LYRICS";
if(!res[PULPO::ONTOLOGY::TRACK][PULPO::INFO::LYRICS].isEmpty())
{
auto lyrics = res[PULPO::ONTOLOGY::TRACK][PULPO::INFO::LYRICS][PULPO::CONTEXT::LYRIC].toString();
// this->db->lyricsTrack(track, lyrics);
emit this->trackLyricsReady(lyrics, track[FMH::MODEL_KEY::URL]);
p->deleteLater();
}
});
p->registerServices({SERVICES::Genius});
p->setOntology(PULPO::ONTOLOGY::TRACK);
p->setInfo(PULPO::INFO::LYRICS);
qDebug()<<"STARTED FETCHING LYRICS";
this->pulpo->feed(song, PULPO::RECURSIVE::OFF);
p->feed(song, PULPO::RECURSIVE::OFF);
qDebug()<<"DONE FETCHING LYRICS";
qDebug()<<"DONE FETCHING LYRICS";*/
}
//void Babe::linkDecoder(QString json)
......
......@@ -155,149 +155,78 @@ Maui.ApplicationWindow
/* UI */
altToolBars: false
// accentColor: babeColor
// headBarFGColor: altColorText
// headBarBGColor: /*currentView === viewsIndex.vvave ? "#7e57c2" :*/ "#212121"
// altColorText: darkTextColor
accentColor: babeColor
headBarFGColor: altColorText
headBarBGColor: /*currentView === viewsIndex.vvave ? "#7e57c2" :*/ "#212121"
altColorText: darkTextColor
floatingBar: false
// leftIcon.iconColor: currentView === viewsIndex.search ? babeColor : altColorText
onSearchButtonClicked:
{
pageStack.currentIndex = 1
currentView = viewsIndex.search
searchView.searchInput.forceActiveFocus()
}
headBar.flickable: true
headBar.stickyMiddleContent: true
headBar.middleContent: Kirigami.ActionToolBar
{
Layout.minimumWidth: iconSizes.medium * 1.5
actions: [
Kirigami.Action
{
Kirigami.Theme.textColor: "red"
iconName: "view-media-track"
// height: headBar.height
// showIndicator: currentView === viewsIndex.tracks
icon.color: currentView === viewsIndex.tracks ? babeColor : textColor
onTriggered: currentView = viewsIndex.tracks
text: qsTr("Tracks")
// tooltipText: pageStack.wideMode ? "" : text
// colorScheme.highlightColor: babeColor
},
Kirigami.Action
{
text: qsTr("Albums")
// height: headBar.height
// showIndicator: currentView === viewsIndex.albums
iconName: /*"album"*/ "view-media-album-cover"
icon.color: currentView === viewsIndex.albums ? babeColor : textColor
onTriggered: currentView = viewsIndex.albums
// tooltipText: pageStack.wideMode ? "" : text
// colorScheme.highlightColor: babeColor
},
Kirigami.Action
{
text: qsTr("Artists")
// height: headBar.height
// showIndicator: currentView === viewsIndex.artists
iconName: "view-media-artist"
icon.color: currentView === viewsIndex.artists ? babeColor : textColor
onTriggered: currentView = viewsIndex.artists
// tooltipText: pageStack.wideMode ? "" : text
// colorScheme.highlightColor: babeColor
},
Kirigami.Action
{
text: qsTr("Playlists")
// height: headBar.height
// showIndicator: currentView === viewsIndex.playlists
iconName: "view-media-playlist"
icon.color: currentView === viewsIndex.playlists ? babeColor : textColor
onTriggered: currentView = viewsIndex.playlists
// tooltipText: pageStack.wideMode ? "" : text
// colorScheme.highlightColor: babeColor
headBar.middleContent : [
Maui.ToolButton
{
iconName: "view-media-track"
height: headBar.height
showIndicator: currentView === viewsIndex.tracks
iconColor: currentView === viewsIndex.tracks ? babeColor : altColorText
onClicked: currentView = viewsIndex.tracks
text: qsTr("Tracks")
tooltipText: pageStack.wideMode ? "" : text
colorScheme.highlightColor: babeColor
},
Kirigami.Action
{
text: qsTr("Folders")
iconName: "folder"
icon.color: currentView === viewsIndex.folders ? babeColor : textColor
onTriggered:
{
pageStack.currentIndex = 1
currentView = viewsIndex.folders
}
},
// Maui.MenuItem
// {
// text: qsTr("Linking")
// icon.name: "view-links"
// onTriggered:
// {
// pageStack.currentIndex = 1
// currentView = viewsIndex.linking
// if(!isLinked) linkingView.linkingConf.open()
// }
// },
Layout.fillHeight: true
Layout.fillWidth: isMobile
Kirigami.Action
{
text: qsTr("YouTube")
iconName: "internet-services"
icon.color: currentView === viewsIndex.youtube ? babeColor : textColor
},
onTriggered:
{
pageStack.currentIndex = 1
currentView = viewsIndex.youtube
}
}
// Maui.MenuItem
// {
// text: qsTr("Cloud")
// icon.name: "folder-cloud"
// onTriggered:
// {
// pageStack.currentIndex = 1
// currentView = viewsIndex.cloud
// }
// },
Maui.ToolButton
{
text: qsTr("Albums")
height: headBar.height
showIndicator: currentView === viewsIndex.albums
iconName: /*"album"*/ "view-media-album-cover"
iconColor: currentView === viewsIndex.albums ? babeColor : altColorText
onClicked: currentView = viewsIndex.albums
tooltipText: pageStack.wideMode ? "" : text
colorScheme.highlightColor: babeColor
Layout.fillHeight: true
Layout.fillWidth: isMobile
// Maui.MenuItem
// {
// text: qsTr("Spotify")
// icon.name: "internet-services"
// onTriggered:
// {
// pageStack.currentIndex = 1
// currentView = viewsIndex.spotify
// }
// },
},
Maui.ToolButton
{
text: qsTr("Artists")
height: headBar.height
showIndicator: currentView === viewsIndex.artists
iconName: "view-media-artist"
iconColor: currentView === viewsIndex.artists ? babeColor : altColorText
onClicked: currentView = viewsIndex.artists
tooltipText: pageStack.wideMode ? "" : text
colorScheme.highlightColor: babeColor
Layout.fillHeight: true
Layout.fillWidth: isMobile
},
Maui.ToolButton
{
text: qsTr("Playlists")
height: headBar.height
showIndicator: currentView === viewsIndex.playlists
iconName: "view-media-playlist"
iconColor: currentView === viewsIndex.playlists ? babeColor : altColorText
onClicked: currentView = viewsIndex.playlists
tooltipText: pageStack.wideMode ? "" : text
colorScheme.highlightColor: babeColor
]
Layout.fillHeight: true
Layout.fillWidth: isMobile
}
}
]
footBar.visible: !mainlistEmpty
footBar.implicitHeight: footBar.visible ? toolBarHeight * 1.2 : 0
......@@ -430,6 +359,15 @@ Maui.ApplicationWindow
}
}
leftIcon.iconColor: currentView === viewsIndex.search ? babeColor : altColorText
onSearchButtonClicked:
{
pageStack.currentIndex = 1
currentView = viewsIndex.search
searchView.searchInput.forceActiveFocus()
}
InfoView
{
id: infoView
......@@ -454,13 +392,6 @@ Maui.ApplicationWindow
mainMenu: [
Maui.MenuItem
{
text: qsTr("Sources...")
icon.name: "folder-add"
onTriggered: sourcesDialog.open()
}
// Maui.MenuItem
// {
// text: "Vvave Stream"
......@@ -472,7 +403,71 @@ Maui.ApplicationWindow
// }
// },
Maui.MenuItem
{
text: qsTr("Folders")
icon.name: "folder"
onTriggered:
{
pageStack.currentIndex = 1
currentView = viewsIndex.folders
}
},
// Maui.MenuItem
// {
// text: qsTr("Linking")
// icon.name: "view-links"
// onTriggered:
// {
// pageStack.currentIndex = 1
// currentView = viewsIndex.linking
// if(!isLinked) linkingView.linkingConf.open()
// }
// },
Maui.MenuItem
{
text: qsTr("YouTube")
icon.name: "internet-services"
onTriggered:
{
pageStack.currentIndex = 1
currentView = viewsIndex.youtube
}
},
// Maui.MenuItem
// {
// text: qsTr("Cloud")
// icon.name: "folder-cloud"
// onTriggered:
// {
// pageStack.currentIndex = 1
// currentView = viewsIndex.cloud
// }
// },
// Maui.MenuItem
// {
// text: qsTr("Spotify")
// icon.name: "internet-services"
// onTriggered:
// {
// pageStack.currentIndex = 1
// currentView = viewsIndex.spotify
// }
// },
MenuSeparator{},
Maui.MenuItem
{
text: qsTr("Sources...")
icon.name: "folder-add"
onTriggered: sourcesDialog.open()
}
// Maui.Menu
// {
......@@ -639,7 +634,7 @@ Maui.ApplicationWindow
height: root.height - root.headBar.implicitHeight - root.footBar.implicitHeight
modal: !root.isWide
handleVisible: false
handleVisible: modal
closePolicy: Popup.NoAutoClose
contentItem: MainPlaylist
{
......@@ -1020,7 +1015,7 @@ Maui.ApplicationWindow
onRefreshTables: H.refreshCollection(size)
// onRefreshTracks: H.refreshTracks()
// onRefreshAlbums: H.refreshAlbums()
onRefreshAlbums: H.refreshAlbums()
// onRefreshArtists: H.refreshArtists()
onCoverReady:
......
......@@ -26,20 +26,27 @@
//#include "qgumbodocument.h"
//#include "qgumbonode.h"
Pulpo::Pulpo(const FMH::MODEL &song,QObject *parent)
Pulpo::Pulpo(const FMH::MODEL &song, QObject *parent)
: QObject(parent), track(song) {}
Pulpo::Pulpo(QObject *parent): QObject(parent) {}
Pulpo::~Pulpo() {}
Pulpo::~Pulpo()
{
qDebug()<< "DELETING PULPO INSTANCE";
for(auto &instance : this->serviceInstances)
delete instance;
}
bool Pulpo::feed(const FMH::MODEL &song, const RECURSIVE &recursive)
{
if(song.isEmpty())
return false;
this->track = song;
this->recursive = recursive;
if(this->registeredServices.isEmpty()) return false;
if(this->track.isEmpty()) return false;
this->initServices();
......@@ -101,106 +108,111 @@ void Pulpo::initServices()
for(auto service : this->registeredServices)
switch (service)
{
case SERVICES::LastFm:
{
lastfm lastfm(this->track);
connect(&lastfm, &lastfm::infoReady, this, &Pulpo::passSignal);
if(lastfm.setUpService(this->ontology, this->info))
case SERVICES::LastFm:
{
if(recursive == RECURSIVE::OFF) return;
auto lastfm = new class lastfm(this->track);
this->serviceInstances.push_back(lastfm);
connect(lastfm, &lastfm::infoReady,[=](FMH::MODEL track, PULPO::RESPONSE response)
{
this->passSignal(track, response);
// lastfm->deleteLater();
});
}else qDebug()<<"Error settingUp lastfm service";
if(lastfm->setUpService(this->ontology, this->info))
{
if(recursive == RECURSIVE::OFF) return;
break;
}
}else qDebug()<<"Error settingUp lastfm service";
case SERVICES::Spotify:
{
spotify spotify(this->track);
connect(&spotify, &spotify::infoReady, this, &Pulpo::passSignal);
break;
}
if(spotify.setUpService(this->ontology,this->info))
case SERVICES::Spotify:
{
if(recursive== RECURSIVE::OFF) return;
spotify spotify(this->track);
connect(&spotify, &spotify::infoReady, this, &Pulpo::passSignal);
}else qDebug()<<"Error settingUp spotify service";
if(spotify.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return;
break;
}
case SERVICES::Genius:
{
genius genius(this->track);
connect(&genius, &genius::infoReady, this, &Pulpo::passSignal);
}else qDebug()<<"Error settingUp spotify service";
if(genius.setUpService(this->ontology,this->info))
break;
}
case SERVICES::Genius:
{
if(recursive== RECURSIVE::OFF) return;
auto genius = new class genius(this->track);
connect(genius, &genius::infoReady, this, &Pulpo::passSignal);
}else qDebug()<<"Error settingUp genius service";
if(genius->setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return;
break;
}
case SERVICES::MusicBrainz:
{
musicBrainz musicbrainz(this->track);
connect(&musicbrainz, &musicBrainz::infoReady, this, &Pulpo::passSignal);
}else qDebug()<<"Error settingUp genius service";
if(musicbrainz.setUpService(this->ontology,this->info))
break;
}
case SERVICES::MusicBrainz:
{
if(recursive== RECURSIVE::OFF) return;
musicBrainz musicbrainz(this->track);
connect(&musicbrainz, &musicBrainz::infoReady, this, &Pulpo::passSignal);
}else qDebug()<<"Error settingUp musicBrainz service";
if(musicbrainz.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return;
break;
}
case SERVICES::iTunes:
{
break;
}
case SERVICES::WikiLyrics:
{
break;
}
case SERVICES::LyricWikia:
{
lyricWikia lyricwikia(this->track);
connect(&lyricwikia, &lyricWikia::infoReady, this, &Pulpo::passSignal);
}else qDebug()<<"Error settingUp musicBrainz service";
if(lyricwikia.setUpService(this->ontology,this->info))
break;
}
case SERVICES::iTunes:
{
break;
}
case SERVICES::WikiLyrics:
{
if(recursive== RECURSIVE::OFF) return;
break;
}
case SERVICES::LyricWikia:
{
auto lyricwikia = new lyricWikia(this->track);
connect(lyricwikia, &lyricWikia::infoReady, this, &Pulpo::passSignal);
}else qDebug()<<"Error settingUp lyricwikia service";
if(lyricwikia->setUpService(this->ontology, this->info))
{
if(recursive == RECURSIVE::OFF) return;
break;
}
case SERVICES::Wikipedia:
{
break;
}
}else qDebug()<<"Error settingUp lyricwikia service";
case SERVICES::Deezer:
{
deezer deezer(this->track);
connect(&deezer, &deezer::infoReady, this, &Pulpo::passSignal);
break;
}
case SERVICES::Wikipedia:
{
break;
}
if(deezer.setUpService(this->ontology, this->info))
case SERVICES::Deezer:
{
if(recursive== RECURSIVE::OFF) return;
deezer deezer(this->track);
connect(&deezer, &deezer::infoReady, this, &Pulpo::passSignal);
}else qDebug()<<"Error settingUp deezer service";
if(deezer.setUpService(this->ontology, this->info))
{
if(recursive== RECURSIVE::OFF) return;
break;
}
case SERVICES::ALL:
{
break;
}
case SERVICES::NONE:
{
break;
}
}else qDebug()<<"Error settingUp deezer service";
break;
}
case SERVICES::ALL:
{
break;
}
case SERVICES::NONE:
{
break;
}
}
}
......@@ -226,10 +238,10 @@ bool Pulpo::parseArray()
switch(this->ontology)
{
case PULPO::ONTOLOGY::ALBUM: return this->parseAlbum();
case PULPO::ONTOLOGY::ARTIST: return this->parseArtist();
case PULPO::ONTOLOGY::TRACK: return this->parseTrack();
default: return false;
case PULPO::ONTOLOGY::ALBUM: return this->parseAlbum();
case PULPO::ONTOLOGY::ARTIST: return this->parseArtist();
case PULPO::ONTOLOGY::TRACK: return this->parseTrack();
default: return false;
}
}
......@@ -278,12 +290,12 @@ void Pulpo::startConnectionAsync(const QString &url, const QMap<QString,QString>
auto downloader = new FMH::Downloader;
connect(downloader, &FMH::Downloader::dataReady, [=](QByteArray array)
{
qDebug()<< "DATA READY << " << array;
// qDebug()<< "DATA READY << " << array;
emit this->arrayReady(array);
// downloader->deleteLater();
downloader->deleteLater();
});
qDebug()<< "trying to get AYNC DOWNLOADER for "<< url;
// qDebug()<< "trying to get ASYNC DOWNLOADER for "<< url;
downloader->getArray(url);
}
}
......
......@@ -48,6 +48,8 @@ private:
QNetworkAccessManager *manager;
QNetworkReply *reply;
QList<Pulpo *> serviceInstances;
protected:
QByteArray array;
FMH::MODEL track;
......
......@@ -7,6 +7,12 @@ genius::genius(const FMH::MODEL &song)
this->availableInfo.insert(ONTOLOGY::TRACK, {INFO::TAGS, INFO::WIKI, INFO::ARTWORK, INFO::LYRICS});
this->track = song;
connect(this, &genius::arrayReady, [this](QByteArray data)
{
this->array = data;
this->parseArray();
});
}
bool genius::setUpService(const PULPO::ONTOLOGY &ontology, const PULPO::INFO &info)
......@@ -28,22 +34,22 @@ bool genius::setUpService(const PULPO::ONTOLOGY &ontology, const PULPO::INFO &in
switch(this->ontology)