mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added cooldown to layouting to reduce lag when opening the emojis tab
This commit is contained in:
parent
fffe9c93c4
commit
2ab571fe54
|
@ -83,15 +83,15 @@ ChannelView::ChannelView(BaseWidget *parent)
|
|||
});
|
||||
});
|
||||
|
||||
this->updateTimer.setInterval(1000 / 60);
|
||||
this->updateTimer.setSingleShot(true);
|
||||
connect(&this->updateTimer, &QTimer::timeout, this, [this] {
|
||||
if (this->updateQueued) {
|
||||
this->updateQueued = false;
|
||||
this->repaint();
|
||||
this->updateTimer.start();
|
||||
}
|
||||
});
|
||||
// this->updateTimer.setInterval(1000 / 60);
|
||||
// this->updateTimer.setSingleShot(true);
|
||||
// connect(&this->updateTimer, &QTimer::timeout, this, [this] {
|
||||
// if (this->updateQueued) {
|
||||
// this->updateQueued = false;
|
||||
// this->repaint();
|
||||
// this->updateTimer.start();
|
||||
// }
|
||||
// });
|
||||
|
||||
this->pauseTimeout.setSingleShot(true);
|
||||
|
||||
|
@ -99,10 +99,20 @@ ChannelView::ChannelView(BaseWidget *parent)
|
|||
// this->resizeEvent(e);
|
||||
// delete e;
|
||||
|
||||
this->scrollBar.resize(this->scrollBar.width(), height());
|
||||
this->scrollBar.resize(this->scrollBar.width(), height() + 1);
|
||||
|
||||
singletons::SettingManager::getInstance().showLastMessageIndicator.connect(
|
||||
[this](auto, auto) { this->update(); }, this->managedConnections);
|
||||
|
||||
this->layoutCooldown = new QTimer(this);
|
||||
this->layoutCooldown->setSingleShot(true);
|
||||
this->layoutCooldown->setInterval(66);
|
||||
|
||||
QObject::connect(this->layoutCooldown, &QTimer::timeout, [this] {
|
||||
if (this->layoutQueued) {
|
||||
this->layoutMessages();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ChannelView::~ChannelView()
|
||||
|
@ -140,7 +150,13 @@ void ChannelView::queueUpdate()
|
|||
|
||||
void ChannelView::layoutMessages()
|
||||
{
|
||||
this->actuallyLayoutMessages();
|
||||
if (!this->layoutCooldown->isActive()) {
|
||||
this->actuallyLayoutMessages();
|
||||
|
||||
this->layoutCooldown->start();
|
||||
} else {
|
||||
this->layoutQueued = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelView::actuallyLayoutMessages()
|
||||
|
|
|
@ -77,6 +77,9 @@ protected:
|
|||
QPoint &relativePos, int &index);
|
||||
|
||||
private:
|
||||
QTimer *layoutCooldown;
|
||||
bool layoutQueued;
|
||||
|
||||
QTimer updateTimer;
|
||||
bool updateQueued = false;
|
||||
bool messageWasAdded = false;
|
||||
|
|
Loading…
Reference in a new issue