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:
@@ -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));
|
||||
|
||||
@@ -239,9 +239,8 @@ QString ChannelView::getSelectedText()
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
bool isSingleWord =
|
||||
isSingleMessage &&
|
||||
this->selection.max.charIndex - charIndex < part.getCharacterLength();
|
||||
bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex <
|
||||
part.getCharacterLength();
|
||||
|
||||
if (isSingleWord) {
|
||||
// return single word
|
||||
@@ -518,10 +517,9 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
|
||||
// this->selectionMax.messageIndex >= messageIndex) {
|
||||
// painter.fillRect(buffer->rect(), QColor(24, 55, 25));
|
||||
//} else {
|
||||
painter.fillRect(buffer->rect(),
|
||||
(messageRef->getMessage()->getCanHighlightTab())
|
||||
? this->colorScheme.ChatBackgroundHighlighted
|
||||
: this->colorScheme.ChatBackground);
|
||||
painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab())
|
||||
? this->colorScheme.ChatBackgroundHighlighted
|
||||
: this->colorScheme.ChatBackground);
|
||||
//}
|
||||
|
||||
// draw selection
|
||||
|
||||
+11
-10
@@ -360,17 +360,18 @@ void ChatWidget::doOpenViewerList()
|
||||
}
|
||||
auto loadingLabel = new QLabel("Loading...");
|
||||
|
||||
util::twitch::get(
|
||||
"https://tmi.twitch.tv/group/user/" + channel->name + "/chatters", [=](QJsonObject obj) {
|
||||
QJsonObject chattersObj = obj.value("chatters").toObject();
|
||||
util::twitch::get("https://tmi.twitch.tv/group/user/" + channel->name + "/chatters", this,
|
||||
[=](QJsonObject obj) {
|
||||
QJsonObject chattersObj = obj.value("chatters").toObject();
|
||||
|
||||
loadingLabel->hide();
|
||||
for (int i = 0; i < jsonLabels.size(); i++) {
|
||||
chattersList->addItem(labelList.at(i));
|
||||
foreach (const QJsonValue &v, chattersObj.value(jsonLabels.at(i)).toArray())
|
||||
chattersList->addItem(v.toString());
|
||||
}
|
||||
});
|
||||
loadingLabel->hide();
|
||||
for (int i = 0; i < jsonLabels.size(); i++) {
|
||||
chattersList->addItem(labelList.at(i));
|
||||
foreach (const QJsonValue &v,
|
||||
chattersObj.value(jsonLabels.at(i)).toArray())
|
||||
chattersList->addItem(v.toString());
|
||||
}
|
||||
});
|
||||
|
||||
searchBar->setPlaceholderText("Search User...");
|
||||
QObject::connect(searchBar, &QLineEdit::textEdited, this, [=]() {
|
||||
|
||||
@@ -213,7 +213,7 @@ void ChatWidgetHeader::checkLive()
|
||||
|
||||
auto id = QString::fromStdString(channel->roomID);
|
||||
|
||||
util::twitch::get("https://api.twitch.tv/kraken/streams/" + id, [=](QJsonObject obj) {
|
||||
util::twitch::get("https://api.twitch.tv/kraken/streams/" + id, this, [=](QJsonObject obj) {
|
||||
if (obj.value("stream").isNull()) {
|
||||
channel->isLive = false;
|
||||
this->updateChannelText();
|
||||
|
||||
@@ -137,7 +137,7 @@ AdvancedLoginWidget::AdvancedLoginWidget()
|
||||
this->ui.buttonLowerRow.layout.addWidget(&this->ui.buttonLowerRow.fillInUserIDButton);
|
||||
|
||||
connect(&this->ui.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked, [=]() {
|
||||
util::twitch::getUserID(this->ui.usernameInput.text(), [=](const QString &userID) {
|
||||
util::twitch::getUserID(this->ui.usernameInput.text(), this, [=](const QString &userID) {
|
||||
this->ui.userIDInput.setText(userID); //
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user