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
d85dba3e0e
commit
4ec2c0d8b3
|
@ -83,15 +83,15 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this->updateTimer.setInterval(1000 / 60);
|
// this->updateTimer.setInterval(1000 / 60);
|
||||||
this->updateTimer.setSingleShot(true);
|
// this->updateTimer.setSingleShot(true);
|
||||||
connect(&this->updateTimer, &QTimer::timeout, this, [this] {
|
// connect(&this->updateTimer, &QTimer::timeout, this, [this] {
|
||||||
if (this->updateQueued) {
|
// if (this->updateQueued) {
|
||||||
this->updateQueued = false;
|
// this->updateQueued = false;
|
||||||
this->repaint();
|
// this->repaint();
|
||||||
this->updateTimer.start();
|
// this->updateTimer.start();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
this->pauseTimeout.setSingleShot(true);
|
this->pauseTimeout.setSingleShot(true);
|
||||||
|
|
||||||
|
@ -99,10 +99,20 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
// this->resizeEvent(e);
|
// this->resizeEvent(e);
|
||||||
// delete e;
|
// delete e;
|
||||||
|
|
||||||
this->scrollBar.resize(this->scrollBar.width(), height());
|
this->scrollBar.resize(this->scrollBar.width(), height() + 1);
|
||||||
|
|
||||||
singletons::SettingManager::getInstance().showLastMessageIndicator.connect(
|
singletons::SettingManager::getInstance().showLastMessageIndicator.connect(
|
||||||
[this](auto, auto) { this->update(); }, this->managedConnections);
|
[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()
|
ChannelView::~ChannelView()
|
||||||
|
@ -140,7 +150,13 @@ void ChannelView::queueUpdate()
|
||||||
|
|
||||||
void ChannelView::layoutMessages()
|
void ChannelView::layoutMessages()
|
||||||
{
|
{
|
||||||
this->actuallyLayoutMessages();
|
if (!this->layoutCooldown->isActive()) {
|
||||||
|
this->actuallyLayoutMessages();
|
||||||
|
|
||||||
|
this->layoutCooldown->start();
|
||||||
|
} else {
|
||||||
|
this->layoutQueued = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelView::actuallyLayoutMessages()
|
void ChannelView::actuallyLayoutMessages()
|
||||||
|
|
|
@ -77,6 +77,9 @@ protected:
|
||||||
QPoint &relativePos, int &index);
|
QPoint &relativePos, int &index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QTimer *layoutCooldown;
|
||||||
|
bool layoutQueued;
|
||||||
|
|
||||||
QTimer updateTimer;
|
QTimer updateTimer;
|
||||||
bool updateQueued = false;
|
bool updateQueued = false;
|
||||||
bool messageWasAdded = false;
|
bool messageWasAdded = false;
|
||||||
|
|
Loading…
Reference in a new issue