mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
decreased lag when opening the emote/emoji menu
This commit is contained in:
parent
653e4c6adf
commit
4c99f2b5fd
2 changed files with 13 additions and 3 deletions
|
@ -19,6 +19,8 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace messages {
|
namespace messages {
|
||||||
|
|
||||||
|
bool Image::loadedEventQueued = false;
|
||||||
|
|
||||||
Image::Image(const QString &url, qreal scale, const QString &name, const QString &tooltip,
|
Image::Image(const QString &url, qreal scale, const QString &name, const QString &tooltip,
|
||||||
const QMargins &margin, bool isHat)
|
const QMargins &margin, bool isHat)
|
||||||
: url(url)
|
: url(url)
|
||||||
|
@ -63,7 +65,7 @@ void Image::loadImage()
|
||||||
util::NetworkRequest req(this->getUrl());
|
util::NetworkRequest req(this->getUrl());
|
||||||
req.setCaller(this);
|
req.setCaller(this);
|
||||||
req.setUseQuickLoadCache(true);
|
req.setUseQuickLoadCache(true);
|
||||||
req.get([lli = this](QByteArray bytes) -> bool {
|
req.get([lli = this](QByteArray bytes)->bool {
|
||||||
QByteArray copy = QByteArray::fromRawData(bytes.constData(), bytes.length());
|
QByteArray copy = QByteArray::fromRawData(bytes.constData(), bytes.length());
|
||||||
QBuffer buffer(©);
|
QBuffer buffer(©);
|
||||||
buffer.open(QIODevice::ReadOnly);
|
buffer.open(QIODevice::ReadOnly);
|
||||||
|
@ -131,8 +133,14 @@ void Image::loadImage()
|
||||||
|
|
||||||
singletons::EmoteManager::getInstance().incGeneration();
|
singletons::EmoteManager::getInstance().incGeneration();
|
||||||
|
|
||||||
util::postToThread(
|
if (!loadedEventQueued) {
|
||||||
[] { singletons::WindowManager::getInstance().layoutVisibleChatWidgets(); });
|
loadedEventQueued = true;
|
||||||
|
|
||||||
|
QTimer::singleShot(750, [] {
|
||||||
|
singletons::WindowManager::getInstance().layoutVisibleChatWidgets();
|
||||||
|
loadedEventQueued = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,6 +40,8 @@ private:
|
||||||
int duration;
|
int duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool loadedEventQueued;
|
||||||
|
|
||||||
QPixmap *currentPixmap = nullptr;
|
QPixmap *currentPixmap = nullptr;
|
||||||
QPixmap *loadedPixmap = nullptr;
|
QPixmap *loadedPixmap = nullptr;
|
||||||
std::vector<FrameData> allFrames;
|
std::vector<FrameData> allFrames;
|
||||||
|
|
Loading…
Reference in a new issue