From ef1f1846a46e1764e4d18939db2b87041a85eea7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 30 Jun 2023 21:12:44 +0400 Subject: [PATCH] Respect PowerSaver in TranslateBox. --- Telegram/SourceFiles/boxes/translate_box.cpp | 11 +++++++++++ Telegram/lib_ui | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/boxes/translate_box.cpp b/Telegram/SourceFiles/boxes/translate_box.cpp index 066ba855b2..b21cf229cc 100644 --- a/Telegram/SourceFiles/boxes/translate_box.cpp +++ b/Telegram/SourceFiles/boxes/translate_box.cpp @@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/layers/generic_box.h" #include "ui/text/text_utilities.h" #include "ui/painter.h" +#include "ui/power_saving.h" #include "ui/widgets/buttons.h" #include "ui/widgets/labels.h" #include "ui/widgets/multi_select.h" @@ -131,6 +132,14 @@ void TranslateBox( // container, // tr::lng_translate_box_original()); + const auto animationsPaused = [] { + using Which = FlatLabel::WhichAnimationsPaused; + const auto emoji = On(PowerSaving::kEmojiChat); + const auto spoiler = On(PowerSaving::kChatSpoiler); + return emoji + ? (spoiler ? Which::All : Which::CustomEmoji) + : (spoiler ? Which::Spoiler : Which::None); + }; const auto original = box->addRow(object_ptr>( box, object_ptr(box, stLabel))); @@ -139,6 +148,7 @@ void TranslateBox( original->entity()->setContextMenuHook([](auto&&) { }); } + original->entity()->setAnimationsPausedCallback(animationsPaused); original->entity()->setMarkedText( text, Core::MarkedTextContext{ @@ -194,6 +204,7 @@ void TranslateBox( box, object_ptr(box, stLabel))); translated->entity()->setSelectable(!hasCopyRestriction); + translated->entity()->setAnimationsPausedCallback(animationsPaused); constexpr auto kMaxLines = 3; container->resizeToWidth(box->width()); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 67dc933d72..c3aab1bd14 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 67dc933d72fa5e20e6480bbff5a88a2c52d9d0d0 +Subproject commit c3aab1bd141101c32393edc07032113ae4f1122a