mirror-chatterino2/src/singletons/helper/GifTimer.cpp

33 lines
815 B
C++
Raw Normal View History

2018-06-26 14:09:39 +02:00
#include "singletons/helper/GifTimer.hpp"
2018-06-26 14:09:39 +02:00
#include "Application.hpp"
2018-06-28 19:46:45 +02:00
#include "singletons/Settings.hpp"
2018-06-26 14:09:39 +02:00
#include "singletons/WindowManager.hpp"
namespace chatterino {
void GIFTimer::initialize()
{
this->timer.setInterval(GIF_FRAME_LENGTH);
this->timer.setTimerType(Qt::PreciseTimer);
2018-10-31 19:45:51 +01:00
getSettings()->animateEmotes.connect([this](bool enabled, auto) {
2018-08-15 23:48:16 +02:00
if (enabled)
this->timer.start();
2018-08-15 23:48:16 +02:00
else
this->timer.stop();
});
QObject::connect(&this->timer, &QTimer::timeout, [this] {
2018-10-31 19:45:51 +01:00
if (getSettings()->animationsWhenFocused &&
2018-08-15 23:48:16 +02:00
qApp->activeWindow() == nullptr)
return;
this->position_ += GIF_FRAME_LENGTH;
this->signal.invoke();
2018-08-15 23:48:16 +02:00
getApp()->windows->repaintGifEmotes();
});
}
} // namespace chatterino