smoll changes

This commit is contained in:
fourtf 2019-08-21 00:01:27 +02:00
parent d98318e1cc
commit f3e48c1325
5 changed files with 14 additions and 16 deletions

View file

@ -643,8 +643,6 @@ void BaseWindow::drawCustomWindowFrame(QPainter &painter)
#ifdef USEWINSDK
if (this->hasCustomWindowFrame())
{
QPainter painter(this);
QColor bg = this->overrideBackgroundColor_.value_or(
this->theme->window.background);

View file

@ -55,7 +55,7 @@ QString NetworkData::getHash()
void writeToCache(const std::shared_ptr<NetworkData> &data,
const QByteArray &bytes)
{
if (data->useQuickLoadCache_)
if (data->cache_)
{
QtConcurrent::run([data, bytes] {
QFile cachedFile(getPaths()->cacheDirectory() + "/" +
@ -155,7 +155,7 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
// log("starting {}", data->request_.url().toString());
if (data->onSuccess_)
{
if (data->executeConcurrently)
if (data->executeConcurrently_)
QtConcurrent::run(
[onSuccess = std::move(data->onSuccess_),
result = std::move(result)] { onSuccess(result); });
@ -170,7 +170,7 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
QObject::connect(
reply, &QNetworkReply::finished, worker,
[data, handleReply, worker]() mutable {
if (data->executeConcurrently || isGuiThread())
if (data->executeConcurrently_ || isGuiThread())
{
handleReply();
delete worker;
@ -211,7 +211,7 @@ void loadCached(const std::shared_ptr<NetworkData> &data)
if (data->onSuccess_)
{
if (data->executeConcurrently || isGuiThread())
if (data->executeConcurrently_ || isGuiThread())
{
// XXX: If outcome is Failure, we should invalidate the cache file
// somehow/somewhere
@ -239,7 +239,7 @@ void loadCached(const std::shared_ptr<NetworkData> &data)
void load(const std::shared_ptr<NetworkData> &data)
{
if (data->useQuickLoadCache_)
if (data->cache_)
{
QtConcurrent::run(loadCached, data);
loadCached(data);

View file

@ -35,8 +35,8 @@ struct NetworkData {
QNetworkRequest request_;
bool hasCaller_{};
QObjectRef<QObject> caller_;
bool useQuickLoadCache_{};
bool executeConcurrently{};
bool cache_{};
bool executeConcurrently_{};
NetworkReplyCreatedCallback onReplyCreated_;
NetworkErrorCallback onError_;

View file

@ -109,7 +109,7 @@ NetworkRequest NetworkRequest::timeout(int ms) &&
NetworkRequest NetworkRequest::concurrent() &&
{
this->data->executeConcurrently = true;
this->data->executeConcurrently_ = true;
return std::move(*this);
}
@ -135,7 +135,7 @@ NetworkRequest NetworkRequest::payload(const QByteArray &payload) &&
NetworkRequest NetworkRequest::cache() &&
{
this->data->useQuickLoadCache_ = true;
this->data->cache_ = true;
return std::move(*this);
}
@ -144,15 +144,15 @@ void NetworkRequest::execute()
this->executed_ = true;
// Only allow caching for GET request
if (this->data->useQuickLoadCache_ &&
if (this->data->cache_ &&
this->data->requestType_ != NetworkRequestType::Get)
{
qDebug() << "Can only cache GET requests!";
this->data->useQuickLoadCache_ = false;
this->data->cache_ = false;
}
// Can not have a caller and be concurrent at the same time.
assert(!(this->data->caller_ && this->data->executeConcurrently));
assert(!(this->data->caller_ && this->data->executeConcurrently_));
load(std::move(this->data));
}

View file

@ -337,7 +337,7 @@ void Image::load()
NetworkRequest(this->url().string)
.concurrent()
.cache()
.onSuccess([that = this, weak = weakOf(this)](auto result) -> Outcome {
.onSuccess([weak = weakOf(this)](auto result) -> Outcome {
auto shared = weak.lock();
if (!shared)
return Failure;
@ -348,7 +348,7 @@ void Image::load()
QBuffer buffer(const_cast<QByteArray *>(&data));
buffer.open(QIODevice::ReadOnly);
QImageReader reader(&buffer);
auto parsed = detail::readFrames(reader, that->url());
auto parsed = detail::readFrames(reader, shared->url());
postToThread(makeConvertCallback(parsed, [weak](auto frames) {
if (auto shared = weak.lock())