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 messages {
|
||||
|
||||
bool Image::loadedEventQueued = false;
|
||||
|
||||
Image::Image(const QString &url, qreal scale, const QString &name, const QString &tooltip,
|
||||
const QMargins &margin, bool isHat)
|
||||
: url(url)
|
||||
|
@ -63,7 +65,7 @@ void Image::loadImage()
|
|||
util::NetworkRequest req(this->getUrl());
|
||||
req.setCaller(this);
|
||||
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());
|
||||
QBuffer buffer(©);
|
||||
buffer.open(QIODevice::ReadOnly);
|
||||
|
@ -131,8 +133,14 @@ void Image::loadImage()
|
|||
|
||||
singletons::EmoteManager::getInstance().incGeneration();
|
||||
|
||||
util::postToThread(
|
||||
[] { singletons::WindowManager::getInstance().layoutVisibleChatWidgets(); });
|
||||
if (!loadedEventQueued) {
|
||||
loadedEventQueued = true;
|
||||
|
||||
QTimer::singleShot(750, [] {
|
||||
singletons::WindowManager::getInstance().layoutVisibleChatWidgets();
|
||||
loadedEventQueued = false;
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -40,6 +40,8 @@ private:
|
|||
int duration;
|
||||
};
|
||||
|
||||
static bool loadedEventQueued;
|
||||
|
||||
QPixmap *currentPixmap = nullptr;
|
||||
QPixmap *loadedPixmap = nullptr;
|
||||
std::vector<FrameData> allFrames;
|
||||
|
|
Loading…
Reference in a new issue