Respect PowerSaver in TranslateBox.

This commit is contained in:
John Preston 2023-06-30 21:12:44 +04:00
parent e66d9d5d24
commit ef1f1846a4
2 changed files with 12 additions and 1 deletions

View File

@ -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<SlideWrap<FlatLabel>>(
box,
object_ptr<FlatLabel>(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<FlatLabel>(box, stLabel)));
translated->entity()->setSelectable(!hasCopyRestriction);
translated->entity()->setAnimationsPausedCallback(animationsPaused);
constexpr auto kMaxLines = 3;
container->resizeToWidth(box->width());

@ -1 +1 @@
Subproject commit 67dc933d72fa5e20e6480bbff5a88a2c52d9d0d0
Subproject commit c3aab1bd141101c32393edc07032113ae4f1122a