From 5068c9a64e0e1ab0e7397808123bf263e9ed9f91 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 15 Aug 2018 23:48:16 +0200 Subject: [PATCH] Fixes #161 --- src/singletons/Settings.hpp | 2 ++ src/singletons/helper/GifTimer.cpp | 13 +++++++------ src/widgets/settingspages/LookPage.cpp | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 28d0e43d3..8337786dc 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -25,6 +25,8 @@ public: /// Appearance BoolSetting showTimestamps = {"/appearance/messages/showTimestamps", true}; + BoolSetting enableAnimationsWhenFocused = { + "/appearance/enableAnimationsWhenFocused", false}; QStringSetting timestampFormat = {"/appearance/messages/timestampFormat", "h:mm"}; BoolSetting showBadges = {"/appearance/messages/showBadges", true}; diff --git a/src/singletons/helper/GifTimer.cpp b/src/singletons/helper/GifTimer.cpp index 8ef657e7a..8f3624523 100644 --- a/src/singletons/helper/GifTimer.cpp +++ b/src/singletons/helper/GifTimer.cpp @@ -11,18 +11,19 @@ void GIFTimer::initialize() this->timer.setInterval(30); getSettings()->enableGifAnimations.connect([this](bool enabled, auto) { - if (enabled) { + if (enabled) this->timer.start(); - } else { + else this->timer.stop(); - } }); QObject::connect(&this->timer, &QTimer::timeout, [this] { + if (getSettings()->enableAnimationsWhenFocused && + qApp->activeWindow() == nullptr) + return; + this->signal.invoke(); - // fourtf: - auto app = getApp(); - app->windows->repaintGifEmotes(); + getApp()->windows->repaintGifEmotes(); }); } diff --git a/src/widgets/settingspages/LookPage.cpp b/src/widgets/settingspages/LookPage.cpp index 4db671499..eb2a9ff1c 100644 --- a/src/widgets/settingspages/LookPage.cpp +++ b/src/widgets/settingspages/LookPage.cpp @@ -218,6 +218,9 @@ void LookPage::addEmoteTab(LayoutCreator layout) */ layout.append( this->createCheckBox("Animations", getSettings()->enableGifAnimations)); + layout.append( + this->createCheckBox("Animations only when chatterino has focus", + getSettings()->enableAnimationsWhenFocused)); auto scaleBox = layout.emplace().withoutMargin(); {