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 #ifdef USEWINSDK
if (this->hasCustomWindowFrame()) if (this->hasCustomWindowFrame())
{ {
QPainter painter(this);
QColor bg = this->overrideBackgroundColor_.value_or( QColor bg = this->overrideBackgroundColor_.value_or(
this->theme->window.background); this->theme->window.background);

View file

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

View file

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

View file

@ -109,7 +109,7 @@ NetworkRequest NetworkRequest::timeout(int ms) &&
NetworkRequest NetworkRequest::concurrent() && NetworkRequest NetworkRequest::concurrent() &&
{ {
this->data->executeConcurrently = true; this->data->executeConcurrently_ = true;
return std::move(*this); return std::move(*this);
} }
@ -135,7 +135,7 @@ NetworkRequest NetworkRequest::payload(const QByteArray &payload) &&
NetworkRequest NetworkRequest::cache() && NetworkRequest NetworkRequest::cache() &&
{ {
this->data->useQuickLoadCache_ = true; this->data->cache_ = true;
return std::move(*this); return std::move(*this);
} }
@ -144,15 +144,15 @@ void NetworkRequest::execute()
this->executed_ = true; this->executed_ = true;
// Only allow caching for GET request // Only allow caching for GET request
if (this->data->useQuickLoadCache_ && if (this->data->cache_ &&
this->data->requestType_ != NetworkRequestType::Get) this->data->requestType_ != NetworkRequestType::Get)
{ {
qDebug() << "Can only cache GET requests!"; 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. // 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)); load(std::move(this->data));
} }

View file

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