mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
ae26b835b6
Things that were once singletons are no longer singletons, but are instead stored in the "Application" singleton Some singletons still remain, and some renaming/renamespacing is left
45 lines
927 B
C++
45 lines
927 B
C++
#include "util/networkrequest.hpp"
|
|
|
|
#include "application.hpp"
|
|
|
|
namespace chatterino {
|
|
namespace util {
|
|
|
|
NetworkRequest::NetworkRequest(const char *url)
|
|
{
|
|
this->data.request.setUrl(QUrl(url));
|
|
}
|
|
|
|
NetworkRequest::NetworkRequest(const std::string &url)
|
|
{
|
|
this->data.request.setUrl(QUrl(QString::fromStdString(url)));
|
|
}
|
|
|
|
NetworkRequest::NetworkRequest(const QString &url)
|
|
{
|
|
this->data.request.setUrl(QUrl(url));
|
|
}
|
|
|
|
void NetworkRequest::setUseQuickLoadCache(bool value)
|
|
{
|
|
this->data.useQuickLoadCache = value;
|
|
}
|
|
|
|
void NetworkRequest::Data::writeToCache(const QByteArray &bytes)
|
|
{
|
|
if (this->useQuickLoadCache) {
|
|
auto app = getApp();
|
|
|
|
QFile cachedFile(app->paths->cacheFolderPath + "/" + this->getHash());
|
|
|
|
if (cachedFile.open(QIODevice::WriteOnly)) {
|
|
cachedFile.write(bytes);
|
|
|
|
cachedFile.close();
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace util
|
|
} // namespace chatterino
|