mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-02 07:35:12 +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/layers/generic_box.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/multi_select.h"
|
#include "ui/widgets/multi_select.h"
|
||||||
@@ -131,6 +132,14 @@ void TranslateBox(
|
|||||||
// container,
|
// container,
|
||||||
// tr::lng_translate_box_original());
|
// 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>>(
|
const auto original = box->addRow(object_ptr<SlideWrap<FlatLabel>>(
|
||||||
box,
|
box,
|
||||||
object_ptr<FlatLabel>(box, stLabel)));
|
object_ptr<FlatLabel>(box, stLabel)));
|
||||||
@@ -139,6 +148,7 @@ void TranslateBox(
|
|||||||
original->entity()->setContextMenuHook([](auto&&) {
|
original->entity()->setContextMenuHook([](auto&&) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
original->entity()->setAnimationsPausedCallback(animationsPaused);
|
||||||
original->entity()->setMarkedText(
|
original->entity()->setMarkedText(
|
||||||
text,
|
text,
|
||||||
Core::MarkedTextContext{
|
Core::MarkedTextContext{
|
||||||
@@ -194,6 +204,7 @@ void TranslateBox(
|
|||||||
box,
|
box,
|
||||||
object_ptr<FlatLabel>(box, stLabel)));
|
object_ptr<FlatLabel>(box, stLabel)));
|
||||||
translated->entity()->setSelectable(!hasCopyRestriction);
|
translated->entity()->setSelectable(!hasCopyRestriction);
|
||||||
|
translated->entity()->setAnimationsPausedCallback(animationsPaused);
|
||||||
|
|
||||||
constexpr auto kMaxLines = 3;
|
constexpr auto kMaxLines = 3;
|
||||||
container->resizeToWidth(box->width());
|
container->resizeToWidth(box->width());
|
||||||
|
Submodule Telegram/lib_ui updated: 67dc933d72...c3aab1bd14
Reference in New Issue
Block a user