mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Respect PowerSaver in TranslateBox.
This commit is contained in:
@@ -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());
|
||||
|
Submodule Telegram/lib_ui updated: 67dc933d72...c3aab1bd14
Reference in New Issue
Block a user