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

31 lines
720 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(30);
getSettings()->enableGifAnimations.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-08-15 23:48:16 +02:00
if (getSettings()->enableAnimationsWhenFocused &&
qApp->activeWindow() == nullptr)
return;
this->signal.invoke();
2018-08-15 23:48:16 +02:00
getApp()->windows->repaintGifEmotes();
});
}
} // namespace chatterino