Networkmanager (#134)

* rename ImageLoader* to Network*

* static NetworkManager

* NetworkManager queue arbitrary requests

* modify urlfetch to use NetworkManager

* urlfetchjson in terms of NetworkManager

* fetchurljson fetchurltimeout fetchurljsontimeout

special fetch url functions with various connects and functions to be
called

* operate on fetched data in the correct thread

* operate on fetched resources in correct thread

* networkmanager urlfetch functions

* expose urlfetch functions of networkmanager through util and
util::twitch

* add caller to util functions

* cleanup

* formatting

* urlPut function for NetworkManager and util::twitch

* cleanup worker (no more leak)

* use urlfetch for LazyLoadedImage::loadImage

* Rename NetworkManager methods (#1)

* Rename NetworkManager methods

Remove unused NetworkManager methods
Remove unused NetworkManager includes

Reorder includes in lazyloadedimage.cpp and urlfetch.hpp

* try to simplify code, might break everything

* fixed some more stuff?
This commit is contained in:
hemirt
2017-10-27 20:09:02 +02:00
committed by pajlada
parent a4c0bdb926
commit f51372102e
17 changed files with 521 additions and 427 deletions
+9 -6
View File
@@ -7,7 +7,6 @@
#include "ui_accountpopupform.h"
#include <QClipboard>
#include <QDebug>
#include <QDesktopServices>
#include <QJsonArray>
#include <QJsonDocument>
@@ -80,7 +79,9 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
AccountManager::getInstance().getTwitchUser().getUserId() +
"/follows/channels/" + this->userID);
util::twitch::put(requestUrl,[](QJsonObject obj){});
util::twitch::put(requestUrl,[](QJsonObject obj){
qDebug() << "follows channel: " << obj;
});
});
QObject::connect(this->_ui->ignore, &QPushButton::clicked, this, [=](){
@@ -88,7 +89,9 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
AccountManager::getInstance().getTwitchUser().getUserId() +
"/blocks/" + this->userID);
util::twitch::put(requestUrl,[](QJsonObject obj){});
util::twitch::put(requestUrl,[](QJsonObject obj){
qDebug() << "blocks user: " << obj;
});
});
QObject::connect(this->_ui->disableHighlights, &QPushButton::clicked, this, [=, &settings](){
@@ -118,7 +121,7 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
hide(); //
});
util::twitch::getUserID(AccountManager::getInstance().getTwitchUser().getNickName(),
util::twitch::getUserID(AccountManager::getInstance().getTwitchUser().getNickName(), this,
[=](const QString &id){
AccountManager::getInstance().getTwitchUser().setUserId(id);
});
@@ -137,7 +140,7 @@ void AccountPopupWidget::setChannel(std::shared_ptr<Channel> channel)
void AccountPopupWidget::getUserId()
{
util::twitch::getUserID(this->_ui->lblUsername->text(),[=](const QString &id){
util::twitch::getUserID(this->_ui->lblUsername->text(), this, [=](const QString &id){
userID = id;
getUserData();
});
@@ -145,7 +148,7 @@ void AccountPopupWidget::getUserId()
void AccountPopupWidget::getUserData()
{
util::twitch::get("https://api.twitch.tv/kraken/channels/" + userID,[=](const QJsonObject &obj){
util::twitch::get("https://api.twitch.tv/kraken/channels/" + userID, this, [=](const QJsonObject &obj){
_ui->lblFollowers->setText(QString::number(obj.value("followers").toInt()));
_ui->lblViews->setText(QString::number(obj.value("views").toInt()));
_ui->lblAccountAge->setText(obj.value("created_at").toString().section("T", 0, 0));