mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Implement some power saving options.
This commit is contained in:
parent
02bc950b57
commit
2a4c39b9d7
53 changed files with 446 additions and 108 deletions
|
@ -1215,6 +1215,8 @@ PRIVATE
|
||||||
settings/settings_main.h
|
settings/settings_main.h
|
||||||
settings/settings_notifications.cpp
|
settings/settings_notifications.cpp
|
||||||
settings/settings_notifications.h
|
settings/settings_notifications.h
|
||||||
|
settings/settings_power_saving.cpp
|
||||||
|
settings/settings_power_saving.h
|
||||||
settings/settings_premium.cpp
|
settings/settings_premium.cpp
|
||||||
settings/settings_premium.h
|
settings/settings_premium.h
|
||||||
settings/settings_privacy_controllers.cpp
|
settings/settings_privacy_controllers.cpp
|
||||||
|
|
|
@ -593,7 +593,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_version_info" = "Version and updates";
|
"lng_settings_version_info" = "Version and updates";
|
||||||
"lng_settings_system_integration" = "System integration";
|
"lng_settings_system_integration" = "System integration";
|
||||||
"lng_settings_performance" = "Performance";
|
"lng_settings_performance" = "Performance";
|
||||||
"lng_settings_enable_animations" = "Enable animations";
|
|
||||||
"lng_settings_enable_hwaccel" = "Hardware accelerated video decoding";
|
"lng_settings_enable_hwaccel" = "Hardware accelerated video decoding";
|
||||||
"lng_settings_enable_opengl" = "Enable OpenGL rendering for media";
|
"lng_settings_enable_opengl" = "Enable OpenGL rendering for media";
|
||||||
"lng_settings_angle_backend" = "ANGLE graphics backend";
|
"lng_settings_angle_backend" = "ANGLE graphics backend";
|
||||||
|
@ -609,6 +608,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_security_bots" = "Bots and websites";
|
"lng_settings_security_bots" = "Bots and websites";
|
||||||
"lng_settings_clear_payment_info" = "Clear Payment and Shipping Info";
|
"lng_settings_clear_payment_info" = "Clear Payment and Shipping Info";
|
||||||
|
|
||||||
|
"lng_settings_power_title" = "Power efficiency";
|
||||||
|
"lng_settings_power_stickers" = "Animated Stickers";
|
||||||
|
"lng_settings_power_stickers_panel" = "Autoplay in panel";
|
||||||
|
"lng_settings_power_stickers_chat" = "Autoplay in chat";
|
||||||
|
"lng_settings_power_emoji" = "Animated Emoji";
|
||||||
|
"lng_settings_power_emoji_panel" = "Autoplay in panel";
|
||||||
|
"lng_settings_power_emoji_reactions" = "Autoplay in reactions menu";
|
||||||
|
"lng_settings_power_emoji_chat" = "Autoplay in messages";
|
||||||
|
"lng_settings_power_chat" = "Animations in Chats";
|
||||||
|
"lng_settings_power_chat_background" = "Background rotation";
|
||||||
|
"lng_settings_power_chat_spoiler" = "Animated spoiler effect";
|
||||||
|
"lng_settings_power_calls" = "Animations in Calls";
|
||||||
|
"lng_settings_power_ui" = "Interface animations";
|
||||||
|
|
||||||
"lng_settings_cloud_password_on" = "On";
|
"lng_settings_cloud_password_on" = "On";
|
||||||
"lng_settings_cloud_password_off" = "Off";
|
"lng_settings_cloud_password_off" = "Off";
|
||||||
"lng_settings_cloud_password_start_title" = "Two-Step Verification";
|
"lng_settings_cloud_password_start_title" = "Two-Step Verification";
|
||||||
|
|
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
#include "boxes/peers/edit_participants_box.h"
|
#include "boxes/peers/edit_participants_box.h"
|
||||||
#include "boxes/peers/edit_peer_info_box.h"
|
#include "boxes/peers/edit_peer_info_box.h"
|
||||||
|
#include "settings/settings_power_saving.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -42,6 +43,11 @@ namespace {
|
||||||
constexpr auto kSlowmodeValues = 7;
|
constexpr auto kSlowmodeValues = 7;
|
||||||
constexpr auto kSuggestGigagroupThreshold = 199000;
|
constexpr auto kSuggestGigagroupThreshold = 199000;
|
||||||
|
|
||||||
|
[[nodiscard]] auto Dependencies(PowerSaving::Flags)
|
||||||
|
-> std::vector<std::pair<PowerSaving::Flag, PowerSaving::Flag>> {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
struct NestedRestrictionLabels {
|
struct NestedRestrictionLabels {
|
||||||
std::optional<rpl::producer<QString>> nestedLabel;
|
std::optional<rpl::producer<QString>> nestedLabel;
|
||||||
std::vector<RestrictionLabel> restrictionLabels;
|
std::vector<RestrictionLabel> restrictionLabels;
|
||||||
|
@ -194,7 +200,6 @@ auto Dependencies(ChatRestrictions)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ChatRestrictions NegateRestrictions(ChatRestrictions value) {
|
ChatRestrictions NegateRestrictions(ChatRestrictions value) {
|
||||||
using Flag = ChatRestriction;
|
using Flag = ChatRestriction;
|
||||||
|
|
||||||
|
@ -473,13 +478,14 @@ template <
|
||||||
ApplyDependencies(state->checkViews, dependencies, view);
|
ApplyDependencies(state->checkViews, dependencies, view);
|
||||||
};
|
};
|
||||||
|
|
||||||
container->add(
|
if (header) {
|
||||||
object_ptr<Ui::FlatLabel>(
|
container->add(
|
||||||
container,
|
object_ptr<Ui::FlatLabel>(
|
||||||
std::move(header),
|
container,
|
||||||
st::rightsHeaderLabel),
|
std::move(header),
|
||||||
st::rightsHeaderMargin);
|
st::rightsHeaderLabel),
|
||||||
|
st::rightsHeaderMargin);
|
||||||
|
}
|
||||||
const auto addCheckbox = [&](
|
const auto addCheckbox = [&](
|
||||||
not_null<Ui::VerticalLayout*> verticalLayout,
|
not_null<Ui::VerticalLayout*> verticalLayout,
|
||||||
bool isInner,
|
bool isInner,
|
||||||
|
@ -1131,3 +1137,18 @@ ChatAdminRights AdminRightsForOwnershipTransfer(
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditFlagsControl<PowerSaving::Flags, Ui::RpWidget> CreateEditPowerSaving(
|
||||||
|
QWidget *parent,
|
||||||
|
PowerSaving::Flags flags) {
|
||||||
|
auto widget = object_ptr<Ui::VerticalLayout>(parent);
|
||||||
|
auto result = CreateEditFlags(
|
||||||
|
widget.data(),
|
||||||
|
nullptr,
|
||||||
|
flags,
|
||||||
|
std::map<PowerSaving::Flags, QString>{},
|
||||||
|
Settings::PowerSavingLabelsList());
|
||||||
|
result.widget = std::move(widget);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,11 @@ class RpWidget;
|
||||||
class VerticalLayout;
|
class VerticalLayout;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace PowerSaving {
|
||||||
|
enum Flag : uint32;
|
||||||
|
using Flags = base::flags<Flag>;
|
||||||
|
} // namespace PowerSaving
|
||||||
|
|
||||||
template <typename Object>
|
template <typename Object>
|
||||||
class object_ptr;
|
class object_ptr;
|
||||||
|
|
||||||
|
@ -82,3 +87,8 @@ struct EditFlagsControl {
|
||||||
ChatRestrictions restrictions);
|
ChatRestrictions restrictions);
|
||||||
[[nodiscard]] ChatAdminRights AdminRightsForOwnershipTransfer(
|
[[nodiscard]] ChatAdminRights AdminRightsForOwnershipTransfer(
|
||||||
Data::AdminRightsSetOptions options);
|
Data::AdminRightsSetOptions options);
|
||||||
|
|
||||||
|
[[nodiscard]] auto CreateEditPowerSaving(
|
||||||
|
QWidget *parent,
|
||||||
|
PowerSaving::Flags flags
|
||||||
|
) -> EditFlagsControl<PowerSaving::Flags, Ui::RpWidget>;
|
||||||
|
|
|
@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/path_shift_gradient.h"
|
#include "ui/effects/path_shift_gradient.h"
|
||||||
#include "ui/emoji_config.h"
|
#include "ui/emoji_config.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
|
@ -1125,8 +1126,8 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
|
||||||
_pathGradient->startFrame(0, width(), width() / 2);
|
_pathGradient->startFrame(0, width(), width() / 2);
|
||||||
|
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
const auto paused = _controller->isGifPausedAtLeastFor(
|
const auto paused = On(PowerSaving::kStickersPanel)
|
||||||
Window::GifPauseReason::Layer);
|
|| _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|
||||||
for (int32 i = from; i < to; ++i) {
|
for (int32 i = from; i < to; ++i) {
|
||||||
for (int32 j = 0; j < _perRow; ++j) {
|
for (int32 j = 0; j < _perRow; ++j) {
|
||||||
int32 index = i * _perRow + j;
|
int32 index = i * _perRow + j;
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "calls/calls_call.h"
|
#include "calls/calls_call.h"
|
||||||
|
@ -496,18 +497,12 @@ void TopBar::initBlobsUnder(
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
using namespace rpl::mappers;
|
||||||
auto hideBlobs = rpl::combine(
|
auto hideBlobs = rpl::combine(
|
||||||
rpl::single(anim::Disabled()) | rpl::then(anim::Disables()),
|
PowerSaving::Value(PowerSaving::kCalls),
|
||||||
Core::App().appDeactivatedValue(),
|
Core::App().appDeactivatedValue(),
|
||||||
group->instanceStateValue()
|
group->instanceStateValue()
|
||||||
) | rpl::map([](
|
) | rpl::map(_1 || _2 || _3 == GroupCall::InstanceState::Disconnected);
|
||||||
bool animDisabled,
|
|
||||||
bool hide,
|
|
||||||
GroupCall::InstanceState instanceState) {
|
|
||||||
return (instanceState == GroupCall::InstanceState::Disconnected)
|
|
||||||
|| animDisabled
|
|
||||||
|| hide;
|
|
||||||
});
|
|
||||||
|
|
||||||
std::move(
|
std::move(
|
||||||
hideBlobs
|
hideBlobs
|
||||||
|
|
|
@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "ui/effects/cross_line.h"
|
#include "ui/effects/cross_line.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "core/application.h" // Core::App().domain, .activeWindow.
|
#include "core/application.h" // Core::App().domain, .activeWindow.
|
||||||
#include "main/main_domain.h" // Core::App().domain().activate.
|
#include "main/main_domain.h" // Core::App().domain().activate.
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -234,10 +235,10 @@ Members::Controller::Controller(
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
rpl::single(anim::Disabled()) | rpl::then(anim::Disables()),
|
PowerSaving::Value(PowerSaving::kCalls),
|
||||||
Core::App().appDeactivatedValue()
|
Core::App().appDeactivatedValue()
|
||||||
) | rpl::start_with_next([=](bool animDisabled, bool deactivated) {
|
) | rpl::start_with_next([=](bool disabled, bool deactivated) {
|
||||||
const auto hide = !(!animDisabled && !deactivated);
|
const auto hide = disabled || deactivated;
|
||||||
|
|
||||||
if (!(hide && _soundingAnimationHideLastTime)) {
|
if (!(hide && _soundingAnimationHideLastTime)) {
|
||||||
_soundingAnimationHideLastTime = hide ? crl::now() : 0;
|
_soundingAnimationHideLastTime = hide ? crl::now() : 0;
|
||||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
#include "ui/emoji_config.h"
|
#include "ui/emoji_config.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "boxes/sticker_set_box.h"
|
#include "boxes/sticker_set_box.h"
|
||||||
|
@ -709,9 +710,13 @@ object_ptr<TabbedSelector::InnerFooter> EmojiListWidget::createFooter() {
|
||||||
Expects(_footer == nullptr);
|
Expects(_footer == nullptr);
|
||||||
|
|
||||||
using FooterDescriptor = StickersListFooter::Descriptor;
|
using FooterDescriptor = StickersListFooter::Descriptor;
|
||||||
|
const auto flag = powerSavingFlag();
|
||||||
|
const auto footerPaused = [method = pausedMethod(), flag]() {
|
||||||
|
return On(flag) || method();
|
||||||
|
};
|
||||||
auto result = object_ptr<StickersListFooter>(FooterDescriptor{
|
auto result = object_ptr<StickersListFooter>(FooterDescriptor{
|
||||||
.session = &session(),
|
.session = &session(),
|
||||||
.paused = pausedMethod(),
|
.paused = footerPaused,
|
||||||
.parent = this,
|
.parent = this,
|
||||||
.st = &st(),
|
.st = &st(),
|
||||||
});
|
});
|
||||||
|
@ -1006,7 +1011,7 @@ void EmojiListWidget::validateEmojiPaintContext(
|
||||||
.size = QSize(_customSingleSize, _customSingleSize),
|
.size = QSize(_customSingleSize, _customSingleSize),
|
||||||
.now = crl::now(),
|
.now = crl::now(),
|
||||||
.scale = context.progress,
|
.scale = context.progress,
|
||||||
.paused = paused(),
|
.paused = On(powerSavingFlag()) || paused(),
|
||||||
.scaled = context.expanding,
|
.scaled = context.expanding,
|
||||||
};
|
};
|
||||||
if (!_emojiPaintContext) {
|
if (!_emojiPaintContext) {
|
||||||
|
@ -2179,6 +2184,14 @@ QPoint EmojiListWidget::buttonRippleTopLeft(int section) const {
|
||||||
: QPoint());
|
: QPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PowerSaving::Flag EmojiListWidget::powerSavingFlag() const {
|
||||||
|
const auto reactions = (_mode == Mode::FullReactions)
|
||||||
|
|| (_mode == Mode::RecentReactions);
|
||||||
|
return reactions
|
||||||
|
? PowerSaving::kEmojiReactions
|
||||||
|
: PowerSaving::kEmojiPanel;
|
||||||
|
}
|
||||||
|
|
||||||
void EmojiListWidget::refreshEmoji() {
|
void EmojiListWidget::refreshEmoji() {
|
||||||
refreshRecent();
|
refreshRecent();
|
||||||
refreshCustom();
|
refreshCustom();
|
||||||
|
|
|
@ -24,6 +24,10 @@ namespace Data {
|
||||||
class StickersSet;
|
class StickersSet;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
|
namespace PowerSaving {
|
||||||
|
enum Flag : uint32;
|
||||||
|
} // namespace PowerSaving
|
||||||
|
|
||||||
namespace tr {
|
namespace tr {
|
||||||
template <typename ...Tags>
|
template <typename ...Tags>
|
||||||
struct phrase;
|
struct phrase;
|
||||||
|
@ -322,6 +326,7 @@ private:
|
||||||
[[nodiscard]] std::unique_ptr<Ui::RippleAnimation> createButtonRipple(
|
[[nodiscard]] std::unique_ptr<Ui::RippleAnimation> createButtonRipple(
|
||||||
int section);
|
int section);
|
||||||
[[nodiscard]] QPoint buttonRippleTopLeft(int section) const;
|
[[nodiscard]] QPoint buttonRippleTopLeft(int section) const;
|
||||||
|
[[nodiscard]] PowerSaving::Flag powerSavingFlag() const;
|
||||||
|
|
||||||
void repaintCustom(uint64 setId);
|
void repaintCustom(uint64 setId);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
@ -325,6 +326,9 @@ void InitMessageFieldHandlers(
|
||||||
const style::InputField *fieldStyle) {
|
const style::InputField *fieldStyle) {
|
||||||
field->setTagMimeProcessor(
|
field->setTagMimeProcessor(
|
||||||
FieldTagMimeProcessor(session, allowPremiumEmoji));
|
FieldTagMimeProcessor(session, allowPremiumEmoji));
|
||||||
|
const auto paused = [customEmojiPaused] {
|
||||||
|
return On(PowerSaving::kEmojiChat) || customEmojiPaused();
|
||||||
|
};
|
||||||
field->setCustomEmojiFactory(
|
field->setCustomEmojiFactory(
|
||||||
session->data().customEmojiManager().factory(),
|
session->data().customEmojiManager().factory(),
|
||||||
std::move(customEmojiPaused));
|
std::move(customEmojiPaused));
|
||||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "lottie/lottie_multi_player.h"
|
#include "lottie/lottie_multi_player.h"
|
||||||
#include "lottie/lottie_single_player.h"
|
#include "lottie/lottie_single_player.h"
|
||||||
#include "lottie/lottie_animation.h"
|
#include "lottie/lottie_animation.h"
|
||||||
|
@ -265,10 +266,14 @@ auto StickersListWidget::choosingUpdated() const
|
||||||
object_ptr<TabbedSelector::InnerFooter> StickersListWidget::createFooter() {
|
object_ptr<TabbedSelector::InnerFooter> StickersListWidget::createFooter() {
|
||||||
Expects(_footer == nullptr);
|
Expects(_footer == nullptr);
|
||||||
|
|
||||||
|
const auto footerPaused = [method = pausedMethod()] {
|
||||||
|
return On(PowerSaving::kStickersPanel) || method();
|
||||||
|
};
|
||||||
|
|
||||||
using FooterDescriptor = StickersListFooter::Descriptor;
|
using FooterDescriptor = StickersListFooter::Descriptor;
|
||||||
auto result = object_ptr<StickersListFooter>(FooterDescriptor{
|
auto result = object_ptr<StickersListFooter>(FooterDescriptor{
|
||||||
.session = &session(),
|
.session = &session(),
|
||||||
.paused = pausedMethod(),
|
.paused = footerPaused,
|
||||||
.parent = this,
|
.parent = this,
|
||||||
.settingsButtonVisible = true,
|
.settingsButtonVisible = true,
|
||||||
});
|
});
|
||||||
|
@ -854,7 +859,8 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||||
: &_selected);
|
: &_selected);
|
||||||
|
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
const auto paused = this->paused();
|
const auto paused = On(PowerSaving::kStickersPanel)
|
||||||
|
|| this->paused();
|
||||||
if (sets.empty() && _section == Section::Search) {
|
if (sets.empty() && _section == Section::Search) {
|
||||||
paintEmptySearchResults(p);
|
paintEmptySearchResults(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/unread_badge.h"
|
#include "ui/unread_badge.h"
|
||||||
#include "ui/unread_badge_paint.h"
|
#include "ui/unread_badge_paint.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "support/support_helper.h"
|
#include "support/support_helper.h"
|
||||||
|
@ -262,7 +263,8 @@ void PaintFolderEntryText(
|
||||||
: st::dialogsTextPaletteArchive),
|
: st::dialogsTextPaletteArchive),
|
||||||
.spoiler = Text::DefaultSpoilerCache(),
|
.spoiler = Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.elisionLines = rect.height() / st::dialogsTextFont->height,
|
.elisionLines = rect.height() / st::dialogsTextFont->height,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -420,7 +422,8 @@ void PaintRow(
|
||||||
.availableWidth = availableWidth,
|
.availableWidth = availableWidth,
|
||||||
.spoiler = Text::DefaultSpoilerCache(),
|
.spoiler = Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
} else if (draft
|
} else if (draft
|
||||||
|
@ -514,7 +517,8 @@ void PaintRow(
|
||||||
: st::dialogsTextPaletteDraft)),
|
: st::dialogsTextPaletteDraft)),
|
||||||
.spoiler = Text::DefaultSpoilerCache(),
|
.spoiler = Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "lang/lang_text_entity.h"
|
#include "lang/lang_text_entity.h"
|
||||||
|
@ -296,6 +297,8 @@ void MessageView::paint(
|
||||||
finalRight -= st::forumDialogJumpArrowSkip;
|
finalRight -= st::forumDialogJumpArrowSkip;
|
||||||
}
|
}
|
||||||
const auto lines = rect.height() / st::dialogsTextFont->height;
|
const auto lines = rect.height() / st::dialogsTextFont->height;
|
||||||
|
const auto pausedSpoiler = context.paused
|
||||||
|
|| On(PowerSaving::kChatSpoiler);
|
||||||
if (!_senderCache.isEmpty()) {
|
if (!_senderCache.isEmpty()) {
|
||||||
_senderCache.draw(p, {
|
_senderCache.draw(p, {
|
||||||
.position = rect.topLeft(),
|
.position = rect.topLeft(),
|
||||||
|
@ -323,7 +326,7 @@ void MessageView::paint(
|
||||||
p.drawImage(mini, image.data);
|
p.drawImage(mini, image.data);
|
||||||
if (image.hasSpoiler()) {
|
if (image.hasSpoiler()) {
|
||||||
const auto frame = DefaultImageSpoiler().frame(
|
const auto frame = DefaultImageSpoiler().frame(
|
||||||
_spoiler->index(context.now, context.paused));
|
_spoiler->index(context.now, pausedSpoiler));
|
||||||
FillSpoilerRect(p, mini, frame);
|
FillSpoilerRect(p, mini, frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,7 +344,8 @@ void MessageView::paint(
|
||||||
.palette = palette,
|
.palette = palette,
|
||||||
.spoiler = Text::DefaultSpoilerCache(),
|
.spoiler = Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = pausedSpoiler,
|
||||||
.elisionLines = lines,
|
.elisionLines = lines,
|
||||||
});
|
});
|
||||||
rect.setLeft(rect.x() + _textCache.maxWidth());
|
rect.setLeft(rect.x() + _textCache.maxWidth());
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
|
@ -138,7 +139,8 @@ void TopicsView::paint(
|
||||||
.palette = palette,
|
.palette = palette,
|
||||||
.spoiler = Text::DefaultSpoilerCache(),
|
.spoiler = Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
const auto skip = skipBig
|
const auto skip = skipBig
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/chat/chat_theme.h"
|
#include "ui/chat/chat_theme.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/history_item_helpers.h"
|
#include "history/history_item_helpers.h"
|
||||||
|
@ -469,6 +470,8 @@ void HistoryMessageReply::paint(
|
||||||
p.setOpacity(opacity);
|
p.setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto pausedSpoiler = context.paused
|
||||||
|
|| On(PowerSaving::kChatSpoiler);
|
||||||
if (w > st::msgReplyBarSkip) {
|
if (w > st::msgReplyBarSkip) {
|
||||||
if (replyToMsg) {
|
if (replyToMsg) {
|
||||||
const auto media = replyToMsg->media();
|
const auto media = replyToMsg->media();
|
||||||
|
@ -499,7 +502,7 @@ void HistoryMessageReply::paint(
|
||||||
Ui::DefaultImageSpoiler().frame(
|
Ui::DefaultImageSpoiler().frame(
|
||||||
spoiler->index(
|
spoiler->index(
|
||||||
context.now,
|
context.now,
|
||||||
context.paused)));
|
pausedSpoiler)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -529,7 +532,9 @@ void HistoryMessageReply::paint(
|
||||||
: st->imgReplyTextPalette()),
|
: st->imgReplyTextPalette()),
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = (context.paused
|
||||||
|
|| On(PowerSaving::kEmojiChat)),
|
||||||
|
.pausedSpoiler = pausedSpoiler,
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
p.setTextPalette(stm->textPalette);
|
p.setTextPalette(stm->textPalette);
|
||||||
|
|
|
@ -43,6 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/choose_send_as.h"
|
#include "ui/chat/choose_send_as.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/controls/emoji_button.h"
|
#include "ui/controls/emoji_button.h"
|
||||||
#include "ui/controls/send_button.h"
|
#include "ui/controls/send_button.h"
|
||||||
#include "ui/controls/send_as_button.h"
|
#include "ui/controls/send_as_button.h"
|
||||||
|
@ -1826,7 +1827,7 @@ void HistoryWidget::setupShortcuts() {
|
||||||
&& Ui::AppInFocus()
|
&& Ui::AppInFocus()
|
||||||
&& Ui::InFocusChain(this)
|
&& Ui::InFocusChain(this)
|
||||||
&& !controller()->isLayerShown()
|
&& !controller()->isLayerShown()
|
||||||
&& (Core::App().activeWindow() == &controller()->window());
|
&& window()->isActiveWindow();
|
||||||
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
||||||
using Command = Shortcuts::Command;
|
using Command = Shortcuts::Command;
|
||||||
request->check(Command::Search, 1) && request->handle([=] {
|
request->check(Command::Search, 1) && request->handle([=] {
|
||||||
|
@ -2996,7 +2997,15 @@ void HistoryWidget::newItemAdded(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto view = item->mainView();
|
const auto view = item->mainView();
|
||||||
if (anim::Disabled() || !view) {
|
if (!view) {
|
||||||
|
return;
|
||||||
|
} else if (anim::Disabled()) {
|
||||||
|
if (!On(PowerSaving::kChatBackground)) {
|
||||||
|
// Strange case of disabled animations, but enabled bg rotation.
|
||||||
|
if (item->out() || _history->peer->isSelf()) {
|
||||||
|
_list->theme()->rotateComplexGradientBackground();
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_itemRevealPending.emplace(item);
|
_itemRevealPending.emplace(item);
|
||||||
|
@ -7690,6 +7699,7 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||||
if (_editMsgId || _replyToId || (!hasForward && _kbReplyTo)) {
|
if (_editMsgId || _replyToId || (!hasForward && _kbReplyTo)) {
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
const auto paused = p.inactive();
|
const auto paused = p.inactive();
|
||||||
|
const auto pausedSpoiler = paused || On(PowerSaving::kChatSpoiler);
|
||||||
auto replyLeft = st::historyReplySkip;
|
auto replyLeft = st::historyReplySkip;
|
||||||
(_editMsgId ? st::historyEditIcon : st::historyReplyIcon).paint(p, st::historyReplyIconPosition + QPoint(0, backy), width());
|
(_editMsgId ? st::historyEditIcon : st::historyReplyIcon).paint(p, st::historyReplyIconPosition + QPoint(0, backy), width());
|
||||||
if (!drawWebPagePreview) {
|
if (!drawWebPagePreview) {
|
||||||
|
@ -7708,7 +7718,7 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||||
p,
|
p,
|
||||||
to,
|
to,
|
||||||
Ui::DefaultImageSpoiler().frame(
|
Ui::DefaultImageSpoiler().frame(
|
||||||
_replySpoiler->index(now, paused)));
|
_replySpoiler->index(now, pausedSpoiler)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
replyLeft += st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x();
|
replyLeft += st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x();
|
||||||
|
@ -7728,7 +7738,8 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||||
.palette = &st::historyComposeAreaPalette,
|
.palette = &st::historyComposeAreaPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = now,
|
.now = now,
|
||||||
.paused = paused,
|
.pausedEmoji = paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = pausedSpoiler,
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_chat_participants.h"
|
#include "api/api_chat_participants.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/view/controls/history_view_voice_record_bar.h"
|
#include "history/view/controls/history_view_voice_record_bar.h"
|
||||||
|
@ -800,7 +801,8 @@ void FieldHeader::paintEditOrReplyToMessage(Painter &p) {
|
||||||
.palette = &st::historyComposeAreaPalette,
|
.palette = &st::historyComposeAreaPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = crl::now(),
|
.now = crl::now(),
|
||||||
.paused = p.inactive(),
|
.pausedEmoji = p.inactive() || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = p.inactive() || On(PowerSaving::kChatSpoiler),
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.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 "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
|
@ -309,6 +310,7 @@ void ForwardPanel::paint(
|
||||||
const_cast<ForwardPanel*>(this)->checkTexts();
|
const_cast<ForwardPanel*>(this)->checkTexts();
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
const auto paused = p.inactive();
|
const auto paused = p.inactive();
|
||||||
|
const auto pausedSpoiler = paused || On(PowerSaving::kChatSpoiler);
|
||||||
const auto firstItem = _data.items.front();
|
const auto firstItem = _data.items.front();
|
||||||
const auto firstMedia = firstItem->media();
|
const auto firstMedia = firstItem->media();
|
||||||
const auto hasPreview = (_data.items.size() < 2)
|
const auto hasPreview = (_data.items.size() < 2)
|
||||||
|
@ -335,7 +337,7 @@ void ForwardPanel::paint(
|
||||||
}));
|
}));
|
||||||
if (_spoiler) {
|
if (_spoiler) {
|
||||||
Ui::FillSpoilerRect(p, to, Ui::DefaultImageSpoiler().frame(
|
Ui::FillSpoilerRect(p, to, Ui::DefaultImageSpoiler().frame(
|
||||||
_spoiler->index(now, paused)));
|
_spoiler->index(now, pausedSpoiler)));
|
||||||
}
|
}
|
||||||
const auto skip = st::msgReplyBarSize.height()
|
const auto skip = st::msgReplyBarSize.height()
|
||||||
+ st::msgReplyBarSkip
|
+ st::msgReplyBarSkip
|
||||||
|
@ -359,7 +361,8 @@ void ForwardPanel::paint(
|
||||||
.palette = &st::historyComposeAreaPalette,
|
.palette = &st::historyComposeAreaPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = now,
|
.now = now,
|
||||||
.paused = paused,
|
.pausedEmoji = paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = pausedSpoiler,
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/text/text_entity.h"
|
#include "ui/text/text_entity.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
@ -1472,7 +1473,8 @@ void Message::paintText(
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = context.selection,
|
.selection = context.selection,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "menu/menu_ttl_validator.h"
|
#include "menu/menu_ttl_validator.h"
|
||||||
|
@ -554,7 +555,8 @@ void Service::draw(Painter &p, const PaintContext &context) const {
|
||||||
.palette = &st->serviceTextPalette(),
|
.palette = &st->serviceTextPalette(),
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = context.selection,
|
.selection = context.selection,
|
||||||
.fullWidthSelection = false,
|
.fullWidthSelection = false,
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/text/text_isolated_emoji.h"
|
#include "ui/text/text_isolated_emoji.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
@ -264,6 +265,7 @@ void CustomEmoji::paintCustom(
|
||||||
}
|
}
|
||||||
//const auto preview = context.imageStyle()->msgServiceBg->c;
|
//const auto preview = context.imageStyle()->msgServiceBg->c;
|
||||||
auto &textst = context.st->messageStyle(false, false);
|
auto &textst = context.st->messageStyle(false, false);
|
||||||
|
const auto paused = context.paused || On(PowerSaving::kEmojiChat);
|
||||||
if (context.selected()) {
|
if (context.selected()) {
|
||||||
const auto factor = style::DevicePixelRatio();
|
const auto factor = style::DevicePixelRatio();
|
||||||
const auto size = QSize(_singleSize, _singleSize) * factor;
|
const auto size = QSize(_singleSize, _singleSize) * factor;
|
||||||
|
@ -278,7 +280,7 @@ void CustomEmoji::paintCustom(
|
||||||
emoji->paint(q, {
|
emoji->paint(q, {
|
||||||
.textColor = textst.historyTextFg->c,
|
.textColor = textst.historyTextFg->c,
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.paused = paused,
|
||||||
});
|
});
|
||||||
q.end();
|
q.end();
|
||||||
|
|
||||||
|
@ -291,7 +293,7 @@ void CustomEmoji::paintCustom(
|
||||||
.textColor = textst.historyTextFg->c,
|
.textColor = textst.historyTextFg->c,
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.position = { x, y },
|
.position = { x, y },
|
||||||
.paused = context.paused,
|
.paused = paused,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
|
@ -749,7 +750,8 @@ void Document::draw(
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = selection,
|
.selection = selection,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "payments/payments_checkout_process.h"
|
#include "payments/payments_checkout_process.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
@ -236,7 +237,8 @@ void ExtendedPreview::draw(Painter &p, const PaintContext &context) const {
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = context.selection,
|
.selection = context.selection,
|
||||||
});
|
});
|
||||||
} else if (!inWebPage) {
|
} else if (!inWebPage) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_game.h"
|
#include "data/data_game.h"
|
||||||
|
@ -253,7 +254,8 @@ void Game::draw(Painter &p, const PaintContext &context) const {
|
||||||
.availableWidth = paintw,
|
.availableWidth = paintw,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = toDescriptionSelection(context.selection),
|
.selection = toDescriptionSelection(context.selection),
|
||||||
.elisionLines = _descriptionLines,
|
.elisionLines = _descriptionLines,
|
||||||
.elisionRemoveFromEnd = endskip,
|
.elisionRemoveFromEnd = endskip,
|
||||||
|
|
|
@ -38,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/grouped_layout.h"
|
#include "ui/grouped_layout.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/effects/path_shift_gradient.h"
|
#include "ui/effects/path_shift_gradient.h"
|
||||||
#include "ui/effects/spoiler_mess.h"
|
#include "ui/effects/spoiler_mess.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -681,7 +682,8 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = context.selection,
|
.selection = context.selection,
|
||||||
});
|
});
|
||||||
} else if (!inWebPage && !skipDrawingSurrounding) {
|
} else if (!inWebPage && !skipDrawingSurrounding) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
|
@ -237,7 +238,8 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
|
||||||
.availableWidth = paintw,
|
.availableWidth = paintw,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = toDescriptionSelection(context.selection),
|
.selection = toDescriptionSelection(context.selection),
|
||||||
});
|
});
|
||||||
tshift += _descriptionHeight;
|
tshift += _descriptionHeight;
|
||||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/chat/message_bubble.h"
|
#include "ui/chat/message_bubble.h"
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
|
@ -261,12 +262,14 @@ void Media::fillImageSpoiler(
|
||||||
history()->owner().registerHeavyViewPart(_parent);
|
history()->owner().registerHeavyViewPart(_parent);
|
||||||
}
|
}
|
||||||
_parent->clearCustomEmojiRepaint();
|
_parent->clearCustomEmojiRepaint();
|
||||||
|
const auto pausedSpoiler = context.paused
|
||||||
|
|| On(PowerSaving::kChatSpoiler);
|
||||||
Ui::FillSpoilerRect(
|
Ui::FillSpoilerRect(
|
||||||
p,
|
p,
|
||||||
rect,
|
rect,
|
||||||
MediaRoundingMask(spoiler->backgroundRounding),
|
MediaRoundingMask(spoiler->backgroundRounding),
|
||||||
Ui::DefaultImageSpoiler().frame(
|
Ui::DefaultImageSpoiler().frame(
|
||||||
spoiler->animation->index(context.now, context.paused)),
|
spoiler->animation->index(context.now, pausedSpoiler)),
|
||||||
spoiler->cornerCache);
|
spoiler->cornerCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/message_bubble.h"
|
#include "ui/chat/message_bubble.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "layout/layout_selection.h"
|
#include "layout/layout_selection.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
|
@ -368,7 +369,8 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const {
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = context.selection,
|
.selection = context.selection,
|
||||||
});
|
});
|
||||||
} else if (_parent->media() == this) {
|
} else if (_parent->media() == this) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/grouped_layout.h"
|
#include "ui/grouped_layout.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_streaming.h"
|
#include "data/data_streaming.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
|
@ -355,7 +356,8 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = context.selection,
|
.selection = context.selection,
|
||||||
});
|
});
|
||||||
} else if (!inWebPage) {
|
} else if (!inWebPage) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/custom_emoji_instance.h"
|
#include "ui/text/custom_emoji_instance.h"
|
||||||
#include "ui/emoji_config.h"
|
#include "ui/emoji_config.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
|
@ -247,13 +248,17 @@ void Sticker::paintAnimationFrame(
|
||||||
: (context.selected() && !_nextLastDiceFrame)
|
: (context.selected() && !_nextLastDiceFrame)
|
||||||
? context.st->msgStickerOverlay()->c
|
? context.st->msgStickerOverlay()->c
|
||||||
: QColor(0, 0, 0, 0);
|
: QColor(0, 0, 0, 0);
|
||||||
|
const auto powerSavingFlag = (isEmojiSticker() || _diceIndex >= 0)
|
||||||
|
? PowerSaving::kEmojiChat
|
||||||
|
: PowerSaving::kStickersChat;
|
||||||
|
const auto paused = context.paused || On(powerSavingFlag);
|
||||||
const auto frame = _player
|
const auto frame = _player
|
||||||
? _player->frame(
|
? _player->frame(
|
||||||
_size,
|
_size,
|
||||||
colored,
|
colored,
|
||||||
mirrorHorizontal(),
|
mirrorHorizontal(),
|
||||||
context.now,
|
context.now,
|
||||||
context.paused)
|
paused)
|
||||||
: StickerPlayer::FrameInfo();
|
: StickerPlayer::FrameInfo();
|
||||||
if (_nextLastDiceFrame) {
|
if (_nextLastDiceFrame) {
|
||||||
_nextLastDiceFrame = false;
|
_nextLastDiceFrame = false;
|
||||||
|
@ -282,7 +287,7 @@ void Sticker::paintAnimationFrame(
|
||||||
const auto count = _player->framesCount();
|
const auto count = _player->framesCount();
|
||||||
_frameIndex = frame.index;
|
_frameIndex = frame.index;
|
||||||
_framesCount = count;
|
_framesCount = count;
|
||||||
_nextLastDiceFrame = !context.paused
|
_nextLastDiceFrame = !paused
|
||||||
&& (_diceIndex > 0)
|
&& (_diceIndex > 0)
|
||||||
&& (_frameIndex + 2 == count);
|
&& (_frameIndex + 2 == count);
|
||||||
const auto playOnce = (_diceIndex > 0)
|
const auto playOnce = (_diceIndex > 0)
|
||||||
|
@ -294,7 +299,7 @@ void Sticker::paintAnimationFrame(
|
||||||
const auto lastDiceFrame = (_diceIndex > 0) && atTheEnd();
|
const auto lastDiceFrame = (_diceIndex > 0) && atTheEnd();
|
||||||
const auto switchToNext = !playOnce
|
const auto switchToNext = !playOnce
|
||||||
|| (!lastDiceFrame && (_frameIndex != 0 || !_oncePlayed));
|
|| (!lastDiceFrame && (_frameIndex != 0 || !_oncePlayed));
|
||||||
if (!context.paused
|
if (!paused
|
||||||
&& switchToNext
|
&& switchToNext
|
||||||
&& _player->markFrameShown()
|
&& _player->markFrameShown()
|
||||||
&& playOnce
|
&& playOnce
|
||||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_wall_paper.h"
|
#include "data/data_wall_paper.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
|
@ -578,7 +579,8 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
|
||||||
.availableWidth = paintw,
|
.availableWidth = paintw,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
.paused = context.paused,
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
.selection = toDescriptionSelection(context.selection),
|
.selection = toDescriptionSelection(context.selection),
|
||||||
.elisionLines = std::max(_descriptionLines, 0),
|
.elisionLines = std::max(_descriptionLines, 0),
|
||||||
.elisionRemoveFromEnd = (_descriptionLines > 0) ? endskip : 0,
|
.elisionRemoveFromEnd = (_descriptionLines > 0) ? endskip : 0,
|
||||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/effects/reaction_fly_animation.h"
|
#include "ui/effects/reaction_fly_animation.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
namespace HistoryView::Reactions {
|
namespace HistoryView::Reactions {
|
||||||
|
@ -417,7 +418,7 @@ void InlineList::paint(
|
||||||
p,
|
p,
|
||||||
custom,
|
custom,
|
||||||
inner.topLeft(),
|
inner.topLeft(),
|
||||||
context.now,
|
context,
|
||||||
textFg.color());
|
textFg.color());
|
||||||
} else if (!button.image.isNull()) {
|
} else if (!button.image.isNull()) {
|
||||||
p.drawImage(image.topLeft(), button.image);
|
p.drawImage(image.topLeft(), button.image);
|
||||||
|
@ -546,7 +547,7 @@ void InlineList::paintCustomFrame(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
not_null<Ui::Text::CustomEmoji*> emoji,
|
not_null<Ui::Text::CustomEmoji*> emoji,
|
||||||
QPoint innerTopLeft,
|
QPoint innerTopLeft,
|
||||||
crl::time now,
|
const PaintContext &context,
|
||||||
const QColor &textColor) const {
|
const QColor &textColor) const {
|
||||||
if (_customCache.isNull()) {
|
if (_customCache.isNull()) {
|
||||||
using namespace Ui::Text;
|
using namespace Ui::Text;
|
||||||
|
@ -563,8 +564,8 @@ void InlineList::paintCustomFrame(
|
||||||
auto q = QPainter(&_customCache);
|
auto q = QPainter(&_customCache);
|
||||||
emoji->paint(q, {
|
emoji->paint(q, {
|
||||||
.textColor = textColor,
|
.textColor = textColor,
|
||||||
.now = now,
|
.now = context.now,
|
||||||
.paused = p.inactive(),
|
.paused = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
});
|
});
|
||||||
q.end();
|
q.end();
|
||||||
_customCache = Images::Round(
|
_customCache = Images::Round(
|
||||||
|
|
|
@ -109,7 +109,7 @@ private:
|
||||||
Painter &p,
|
Painter &p,
|
||||||
not_null<Ui::Text::CustomEmoji*> emoji,
|
not_null<Ui::Text::CustomEmoji*> emoji,
|
||||||
QPoint innerTopLeft,
|
QPoint innerTopLeft,
|
||||||
crl::time now,
|
const PaintContext &context,
|
||||||
const QColor &textColor) const;
|
const QColor &textColor) const;
|
||||||
|
|
||||||
QSize countOptimalSize() override;
|
QSize countOptimalSize() override;
|
||||||
|
|
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/item_text_options.h"
|
#include "ui/item_text_options.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "ui/gl/gl_surface.h"
|
#include "ui/gl/gl_surface.h"
|
||||||
|
@ -4279,6 +4280,8 @@ void OverlayWidget::paintCaptionContent(
|
||||||
.availableWidth = inner.width(),
|
.availableWidth = inner.width(),
|
||||||
.palette = &st::mediaviewTextPalette,
|
.palette = &st::mediaviewTextPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
|
.pausedEmoji = On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = On(PowerSaving::kChatSpoiler),
|
||||||
.elisionLines = inner.height() / st::mediaviewCaptionStyle.font->height,
|
.elisionLines = inner.height() / st::mediaviewCaptionStyle.font->height,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
|
|
||||||
namespace Overview {
|
namespace Overview {
|
||||||
|
@ -363,11 +364,12 @@ void Photo::paint(Painter &p, const QRect &clip, TextSelection selection, const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_spoiler) {
|
if (_spoiler) {
|
||||||
|
const auto paused = context->paused || On(PowerSaving::kChatSpoiler);
|
||||||
Ui::FillSpoilerRect(
|
Ui::FillSpoilerRect(
|
||||||
p,
|
p,
|
||||||
QRect(0, 0, _width, _height),
|
QRect(0, 0, _width, _height),
|
||||||
Ui::DefaultImageSpoiler().frame(
|
Ui::DefaultImageSpoiler().frame(
|
||||||
_spoiler->index(context->ms, context->paused)));
|
_spoiler->index(context->ms, paused)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
|
@ -517,11 +519,12 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_spoiler) {
|
if (_spoiler) {
|
||||||
|
const auto paused = context->paused || On(PowerSaving::kChatSpoiler);
|
||||||
Ui::FillSpoilerRect(
|
Ui::FillSpoilerRect(
|
||||||
p,
|
p,
|
||||||
QRect(0, 0, _width, _height),
|
QRect(0, 0, _width, _height),
|
||||||
Ui::DefaultImageSpoiler().frame(
|
Ui::DefaultImageSpoiler().frame(
|
||||||
_spoiler->index(context->ms, context->paused)));
|
_spoiler->index(context->ms, paused)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
#include "settings/settings_chat.h"
|
#include "settings/settings_chat.h"
|
||||||
#include "settings/settings_experimental.h"
|
#include "settings/settings_experimental.h"
|
||||||
|
#include "settings/settings_power_saving.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
@ -658,20 +659,16 @@ void SetupWindowTitleOptions(
|
||||||
SetupWindowTitleContent);
|
SetupWindowTitleContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
|
void SetupAnimations(
|
||||||
|
not_null<Window::Controller*> window,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
AddButton(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
tr::lng_settings_enable_animations(),
|
tr::lng_settings_power_title(),
|
||||||
st::settingsButtonNoIcon
|
st::settingsButtonNoIcon
|
||||||
)->toggleOn(
|
)->setClickedCallback([=] {
|
||||||
rpl::single(!anim::Disabled())
|
window->show(Box(PowerSavingBox));
|
||||||
)->toggledValue(
|
});
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled == anim::Disabled());
|
|
||||||
}) | rpl::start_with_next([](bool enabled) {
|
|
||||||
anim::SetDisabled(!enabled);
|
|
||||||
Local::writeSettings();
|
|
||||||
}, container->lifetime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupHardwareAcceleration(not_null<Ui::VerticalLayout*> container) {
|
void SetupHardwareAcceleration(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
@ -804,7 +801,7 @@ void SetupOpenGL(
|
||||||
void SetupPerformance(
|
void SetupPerformance(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container) {
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
SetupAnimations(container);
|
SetupAnimations(&controller->window(), container);
|
||||||
SetupHardwareAcceleration(container);
|
SetupHardwareAcceleration(container);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
SetupANGLE(controller, container);
|
SetupANGLE(controller, container);
|
||||||
|
|
|
@ -33,7 +33,9 @@ void SetupWindowTitleContent(
|
||||||
void SetupSystemIntegrationContent(
|
void SetupSystemIntegrationContent(
|
||||||
Window::SessionController *controller,
|
Window::SessionController *controller,
|
||||||
not_null<Ui::VerticalLayout*> container);
|
not_null<Ui::VerticalLayout*> container);
|
||||||
void SetupAnimations(not_null<Ui::VerticalLayout*> container);
|
void SetupAnimations(
|
||||||
|
not_null<Window::Controller*> window,
|
||||||
|
not_null<Ui::VerticalLayout*> container);
|
||||||
|
|
||||||
class Advanced : public Section<Advanced> {
|
class Advanced : public Section<Advanced> {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -98,7 +98,7 @@ object_ptr<Ui::RpWidget> CreateIntroSettings(
|
||||||
if (anim::Disabled()) {
|
if (anim::Disabled()) {
|
||||||
AddDivider(result);
|
AddDivider(result);
|
||||||
AddSkip(result);
|
AddSkip(result);
|
||||||
SetupAnimations(result);
|
SetupAnimations(window, result);
|
||||||
AddSkip(result);
|
AddSkip(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
66
Telegram/SourceFiles/settings/settings_power_saving.cpp
Normal file
66
Telegram/SourceFiles/settings/settings_power_saving.cpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "settings/settings_power_saving.h"
|
||||||
|
|
||||||
|
#include "boxes/peers/edit_peer_permissions_box.h"
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "ui/layers/generic_box.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
|
|
||||||
|
namespace Settings {
|
||||||
|
|
||||||
|
void PowerSavingBox(not_null<Ui::GenericBox*> box) {
|
||||||
|
box->setTitle(tr::lng_settings_power_title());
|
||||||
|
|
||||||
|
auto [checkboxes, getResult, changes] = CreateEditPowerSaving(
|
||||||
|
box,
|
||||||
|
PowerSaving::kAll & ~PowerSaving::Current());
|
||||||
|
|
||||||
|
box->addRow(std::move(checkboxes), {});
|
||||||
|
|
||||||
|
box->addButton(tr::lng_settings_save(), [=] {
|
||||||
|
Set(PowerSaving::kAll & ~getResult());
|
||||||
|
Core::App().saveSettingsDelayed();
|
||||||
|
box->closeBox();
|
||||||
|
});
|
||||||
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<NestedPowerSavingLabels> PowerSavingLabelsList() {
|
||||||
|
using namespace PowerSaving;
|
||||||
|
using Label = PowerSavingLabel;
|
||||||
|
auto stickers = std::vector<Label>{
|
||||||
|
{ kStickersPanel, tr::lng_settings_power_stickers_panel(tr::now) },
|
||||||
|
{ kStickersChat, tr::lng_settings_power_stickers_chat(tr::now) },
|
||||||
|
};
|
||||||
|
auto emoji = std::vector<Label>{
|
||||||
|
{ kEmojiPanel, tr::lng_settings_power_emoji_panel(tr::now) },
|
||||||
|
{ kEmojiReactions, tr::lng_settings_power_emoji_reactions(tr::now) },
|
||||||
|
{ kEmojiChat, tr::lng_settings_power_emoji_chat(tr::now) },
|
||||||
|
};
|
||||||
|
auto chat = std::vector<Label>{
|
||||||
|
{ kChatBackground, tr::lng_settings_power_chat_background(tr::now) },
|
||||||
|
{ kChatSpoiler, tr::lng_settings_power_chat_spoiler(tr::now) },
|
||||||
|
};
|
||||||
|
auto calls = std::vector<Label>{
|
||||||
|
{ kCalls, tr::lng_settings_power_calls(tr::now) },
|
||||||
|
};
|
||||||
|
auto animations = std::vector<Label>{
|
||||||
|
{ kAnimations, tr::lng_settings_power_ui(tr::now) },
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
{ tr::lng_settings_power_stickers(), std::move(stickers) },
|
||||||
|
{ tr::lng_settings_power_emoji(), std::move(emoji) },
|
||||||
|
{ tr::lng_settings_power_chat(), std::move(chat) },
|
||||||
|
{ std::nullopt, std::move(calls) },
|
||||||
|
{ std::nullopt, std::move(animations) },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Settings
|
34
Telegram/SourceFiles/settings/settings_power_saving.h
Normal file
34
Telegram/SourceFiles/settings/settings_power_saving.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace PowerSaving {
|
||||||
|
enum Flag : uint32;
|
||||||
|
} // namespace PowerSaving
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class GenericBox;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace Settings {
|
||||||
|
|
||||||
|
void PowerSavingBox(not_null<Ui::GenericBox*> box);
|
||||||
|
|
||||||
|
struct PowerSavingLabel {
|
||||||
|
PowerSaving::Flag flags;
|
||||||
|
QString label;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NestedPowerSavingLabels {
|
||||||
|
std::optional<rpl::producer<QString>> nestedLabel;
|
||||||
|
std::vector<PowerSavingLabel> restrictionLabels;
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] std::vector<NestedPowerSavingLabels> PowerSavingLabelsList();
|
||||||
|
|
||||||
|
} // namespace PowerSaving
|
|
@ -13,9 +13,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "ui/effects/animation_value.h"
|
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "ui/chat/attach/attach_send_files_way.h"
|
#include "ui/chat/attach/attach_send_files_way.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "core/update_checker.h"
|
#include "core/update_checker.h"
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
|
@ -232,14 +232,14 @@ bool ReadSetting(
|
||||||
context.cacheBigFileTotalTimeLimit = NoTimeLimit(timeBig) ? 0 : timeBig;
|
context.cacheBigFileTotalTimeLimit = NoTimeLimit(timeBig) ? 0 : timeBig;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiAnimationsDisabled: {
|
case dbiPowerSaving: {
|
||||||
qint32 disabled;
|
qint32 settings;
|
||||||
stream >> disabled;
|
stream >> settings;
|
||||||
if (!CheckStreamStatus(stream)) {
|
if (!CheckStreamStatus(stream)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
anim::SetDisabled(disabled == 1);
|
PowerSaving::Set(PowerSaving::Flags::from_raw(settings));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiSoundFlashBounceNotifyOld: {
|
case dbiSoundFlashBounceNotifyOld: {
|
||||||
|
|
|
@ -154,7 +154,7 @@ enum {
|
||||||
dbiThemeKey = 0x54,
|
dbiThemeKey = 0x54,
|
||||||
dbiTileBackground = 0x55,
|
dbiTileBackground = 0x55,
|
||||||
dbiCacheSettingsOld = 0x56,
|
dbiCacheSettingsOld = 0x56,
|
||||||
dbiAnimationsDisabled = 0x57,
|
dbiPowerSaving = 0x57,
|
||||||
dbiScalePercent = 0x58,
|
dbiScalePercent = 0x58,
|
||||||
dbiPlaybackSpeedOld = 0x59,
|
dbiPlaybackSpeedOld = 0x59,
|
||||||
dbiLanguagesKey = 0x5a,
|
dbiLanguagesKey = 0x5a,
|
||||||
|
|
|
@ -6,7 +6,7 @@ For license and copyright information please follow this link:
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
//
|
|
||||||
#include "storage/serialize_common.h"
|
#include "storage/serialize_common.h"
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
#include "storage/details/storage_file_utilities.h"
|
#include "storage/details/storage_file_utilities.h"
|
||||||
|
@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_document_media.h"
|
#include "data/data_document_media.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
#include "ui/effects/animation_value.h"
|
#include "ui/power_saving.h"
|
||||||
#include "core/update_checker.h"
|
#include "core/update_checker.h"
|
||||||
#include "core/file_location.h"
|
#include "core/file_location.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -473,6 +473,8 @@ void writeSettings() {
|
||||||
}
|
}
|
||||||
size += sizeof(quint32) + sizeof(qint32) * 8;
|
size += sizeof(quint32) + sizeof(qint32) * 8;
|
||||||
|
|
||||||
|
const auto powerSaving = PowerSaving::Current().value();
|
||||||
|
|
||||||
EncryptedDescriptor data(size);
|
EncryptedDescriptor data(size);
|
||||||
data.stream << quint32(dbiAutoStart) << qint32(cAutoStart());
|
data.stream << quint32(dbiAutoStart) << qint32(cAutoStart());
|
||||||
data.stream << quint32(dbiStartMinimized) << qint32(cStartMinimized());
|
data.stream << quint32(dbiStartMinimized) << qint32(cStartMinimized());
|
||||||
|
@ -484,7 +486,7 @@ void writeSettings() {
|
||||||
data.stream << quint32(dbiFallbackProductionConfig) << configSerialized;
|
data.stream << quint32(dbiFallbackProductionConfig) << configSerialized;
|
||||||
data.stream << quint32(dbiApplicationSettings) << applicationSettings;
|
data.stream << quint32(dbiApplicationSettings) << applicationSettings;
|
||||||
data.stream << quint32(dbiDialogLastPath) << cDialogLastPath();
|
data.stream << quint32(dbiDialogLastPath) << cDialogLastPath();
|
||||||
data.stream << quint32(dbiAnimationsDisabled) << qint32(anim::Disabled() ? 1 : 0);
|
data.stream << quint32(dbiPowerSaving) << qint32(powerSaving);
|
||||||
|
|
||||||
data.stream
|
data.stream
|
||||||
<< quint32(dbiThemeKey)
|
<< quint32(dbiThemeKey)
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/spoiler_mess.h"
|
#include "ui/effects/spoiler_mess.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
@ -200,11 +201,12 @@ void AbstractSingleMediaPreview::paintEvent(QPaintEvent *e) {
|
||||||
const auto position = QPoint(_previewLeft, _previewTop);
|
const auto position = QPoint(_previewLeft, _previewTop);
|
||||||
p.drawPixmap(position, pixmap);
|
p.drawPixmap(position, pixmap);
|
||||||
if (_spoiler) {
|
if (_spoiler) {
|
||||||
|
const auto paused = On(PowerSaving::kChatSpoiler);
|
||||||
FillSpoilerRect(
|
FillSpoilerRect(
|
||||||
p,
|
p,
|
||||||
QRect(position, pixmap.size() / pixmap.devicePixelRatio()),
|
QRect(position, pixmap.size() / pixmap.devicePixelRatio()),
|
||||||
DefaultImageSpoiler().frame(
|
DefaultImageSpoiler().frame(
|
||||||
_spoiler->index(crl::now(), false)));
|
_spoiler->index(crl::now(), paused)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_animated && !isAnimatedPreviewReady() && !_spoiler) {
|
if (_animated && !isAnimatedPreviewReady() && !_spoiler) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/spoiler_mess.h"
|
#include "ui/effects/spoiler_mess.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
@ -243,11 +244,12 @@ void AlbumThumbnail::paintInAlbum(
|
||||||
_albumCorners);
|
_albumCorners);
|
||||||
}
|
}
|
||||||
p.drawPixmap(paintedTo, _albumImageBlurred);
|
p.drawPixmap(paintedTo, _albumImageBlurred);
|
||||||
|
const auto paused = On(PowerSaving::kChatSpoiler);
|
||||||
FillSpoilerRect(
|
FillSpoilerRect(
|
||||||
p,
|
p,
|
||||||
paintedTo,
|
paintedTo,
|
||||||
corners,
|
corners,
|
||||||
DefaultImageSpoiler().frame(_spoiler->index(crl::now(), false)),
|
DefaultImageSpoiler().frame(_spoiler->index(crl::now(), paused)),
|
||||||
_cornerCache);
|
_cornerCache);
|
||||||
p.setOpacity(1.);
|
p.setOpacity(1.);
|
||||||
}
|
}
|
||||||
|
@ -439,12 +441,13 @@ void AlbumThumbnail::paintPhoto(Painter &p, int left, int top, int outerWidth) {
|
||||||
outerWidth,
|
outerWidth,
|
||||||
pixmap);
|
pixmap);
|
||||||
if (_spoiler) {
|
if (_spoiler) {
|
||||||
|
const auto paused = On(PowerSaving::kChatSpoiler);
|
||||||
FillSpoilerRect(
|
FillSpoilerRect(
|
||||||
p,
|
p,
|
||||||
rect,
|
rect,
|
||||||
Images::CornersMaskRef(
|
Images::CornersMaskRef(
|
||||||
Images::CornersMask(ImageRoundRadius::Large)),
|
Images::CornersMask(ImageRoundRadius::Large)),
|
||||||
DefaultImageSpoiler().frame(_spoiler->index(crl::now(), false)),
|
DefaultImageSpoiler().frame(_spoiler->index(crl::now(), paused)),
|
||||||
_cornerCache);
|
_cornerCache);
|
||||||
} else if (_isVideo) {
|
} else if (_isVideo) {
|
||||||
paintPlayVideo(p, rect);
|
paintPlayVideo(p, rect);
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_theme.h"
|
#include "ui/chat/chat_theme.h"
|
||||||
|
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/chat/message_bubble.h"
|
#include "ui/chat/message_bubble.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
|
@ -519,7 +520,7 @@ void ChatTheme::clearBackgroundState() {
|
||||||
bool ChatTheme::readyForBackgroundRotation() const {
|
bool ChatTheme::readyForBackgroundRotation() const {
|
||||||
Expects(_cacheBackgroundTimer.has_value());
|
Expects(_cacheBackgroundTimer.has_value());
|
||||||
|
|
||||||
return !anim::Disabled()
|
return !On(PowerSaving::kChatBackground)
|
||||||
&& !_backgroundFade.animating()
|
&& !_backgroundFade.animating()
|
||||||
&& !_cacheBackgroundTimer->isActive()
|
&& !_cacheBackgroundTimer->isActive()
|
||||||
&& !_backgroundState.now.pixmap.isNull();
|
&& !_backgroundState.now.pixmap.isNull();
|
||||||
|
@ -528,10 +529,8 @@ bool ChatTheme::readyForBackgroundRotation() const {
|
||||||
void ChatTheme::generateNextBackgroundRotation() {
|
void ChatTheme::generateNextBackgroundRotation() {
|
||||||
if (_backgroundCachingRequest
|
if (_backgroundCachingRequest
|
||||||
|| !_backgroundNext.image.isNull()
|
|| !_backgroundNext.image.isNull()
|
||||||
|| !readyForBackgroundRotation()) {
|
|| !readyForBackgroundRotation()
|
||||||
return;
|
|| background().colors.size() < 3) {
|
||||||
}
|
|
||||||
if (background().colors.size() < 3) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
constexpr auto kAddRotationDoubled = (720 - 45);
|
constexpr auto kAddRotationDoubled = (720 - 45);
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/paint/blobs.h"
|
#include "ui/paint/blobs.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
|
@ -116,10 +117,10 @@ GroupCallUserpics::GroupCallUserpics(
|
||||||
});
|
});
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
rpl::single(anim::Disabled()) | rpl::then(anim::Disables()),
|
PowerSaving::Value(PowerSaving::kCalls),
|
||||||
std::move(hideBlobs)
|
std::move(hideBlobs)
|
||||||
) | rpl::start_with_next([=](bool animDisabled, bool deactivated) {
|
) | rpl::start_with_next([=](bool disabled, bool deactivated) {
|
||||||
const auto hide = animDisabled || deactivated;
|
const auto hide = disabled || deactivated;
|
||||||
|
|
||||||
if (!(hide && _speakingAnimationHideLastTime)) {
|
if (!(hide && _speakingAnimationHideLastTime)) {
|
||||||
_speakingAnimationHideLastTime = hide ? crl::now() : 0;
|
_speakingAnimationHideLastTime = hide ? crl::now() : 0;
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
#include "styles/palette.h"
|
#include "styles/palette.h"
|
||||||
|
|
||||||
|
@ -378,6 +379,7 @@ void MessageBar::paint(Painter &p) {
|
||||||
: (shiftTo + shiftFull);
|
: (shiftTo + shiftFull);
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
const auto paused = p.inactive();
|
const auto paused = p.inactive();
|
||||||
|
const auto pausedSpoiler = paused || On(PowerSaving::kChatSpoiler);
|
||||||
|
|
||||||
paintLeftBar(p);
|
paintLeftBar(p);
|
||||||
|
|
||||||
|
@ -389,7 +391,7 @@ void MessageBar::paint(Painter &p) {
|
||||||
_image,
|
_image,
|
||||||
_spoiler.get(),
|
_spoiler.get(),
|
||||||
now,
|
now,
|
||||||
paused);
|
pausedSpoiler);
|
||||||
}
|
}
|
||||||
} else if (!_animation->imageTo.isNull()
|
} else if (!_animation->imageTo.isNull()
|
||||||
|| (!_animation->imageFrom.isNull()
|
|| (!_animation->imageFrom.isNull()
|
||||||
|
@ -413,7 +415,7 @@ void MessageBar::paint(Painter &p) {
|
||||||
_animation->imageFrom,
|
_animation->imageFrom,
|
||||||
_animation->spoilerFrom.get(),
|
_animation->spoilerFrom.get(),
|
||||||
now,
|
now,
|
||||||
paused);
|
pausedSpoiler);
|
||||||
p.setOpacity(progress);
|
p.setOpacity(progress);
|
||||||
paintImageWithSpoiler(
|
paintImageWithSpoiler(
|
||||||
p,
|
p,
|
||||||
|
@ -421,7 +423,7 @@ void MessageBar::paint(Painter &p) {
|
||||||
_animation->imageTo,
|
_animation->imageTo,
|
||||||
_spoiler.get(),
|
_spoiler.get(),
|
||||||
now,
|
now,
|
||||||
paused);
|
pausedSpoiler);
|
||||||
p.setOpacity(1.);
|
p.setOpacity(1.);
|
||||||
} else {
|
} else {
|
||||||
paintImageWithSpoiler(
|
paintImageWithSpoiler(
|
||||||
|
@ -430,7 +432,7 @@ void MessageBar::paint(Painter &p) {
|
||||||
_image,
|
_image,
|
||||||
_spoiler.get(),
|
_spoiler.get(),
|
||||||
now,
|
now,
|
||||||
paused);
|
pausedSpoiler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_animation || _animation->bodyAnimation == BodyAnimation::None) {
|
if (!_animation || _animation->bodyAnimation == BodyAnimation::None) {
|
||||||
|
@ -452,7 +454,8 @@ void MessageBar::paint(Painter &p) {
|
||||||
.palette = &_st.textPalette,
|
.palette = &_st.textPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = now,
|
.now = now,
|
||||||
.paused = paused,
|
.pausedEmoji = paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = pausedSpoiler,
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "ui/abstract_button.h"
|
#include "ui/abstract_button.h"
|
||||||
#include "ui/paint/blobs.h"
|
#include "ui/paint/blobs.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/widgets/call_button.h"
|
#include "ui/widgets/call_button.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
|
@ -516,15 +517,13 @@ CallMuteButton::CallMuteButton(
|
||||||
parent,
|
parent,
|
||||||
_st->active.bgSize,
|
_st->active.bgSize,
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
rpl::single(anim::Disabled()) | rpl::then(anim::Disables()),
|
PowerSaving::Value(PowerSaving::kCalls),
|
||||||
std::move(hideBlobs),
|
std::move(hideBlobs),
|
||||||
_state.value(
|
_state.value(
|
||||||
) | rpl::map([](const CallMuteButtonState &state) {
|
) | rpl::map([](const CallMuteButtonState &state) {
|
||||||
return IsInactive(state.type);
|
return IsInactive(state.type);
|
||||||
})
|
})
|
||||||
) | rpl::map([](bool animDisabled, bool hide, bool isBadState) {
|
) | rpl::map(rpl::mappers::_1 || rpl::mappers::_2 || rpl::mappers::_3)))
|
||||||
return isBadState || !(!animDisabled && !hide);
|
|
||||||
})))
|
|
||||||
, _content(base::make_unique_q<AbstractButton>(parent))
|
, _content(base::make_unique_q<AbstractButton>(parent))
|
||||||
, _colors(Colors())
|
, _colors(Colors())
|
||||||
, _iconState(iconStateFrom(initial.type)) {
|
, _iconState(iconStateFrom(initial.type)) {
|
||||||
|
|
46
Telegram/SourceFiles/ui/power_saving.cpp
Normal file
46
Telegram/SourceFiles/ui/power_saving.cpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "ui/power_saving.h"
|
||||||
|
|
||||||
|
namespace PowerSaving {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
Flags Data/* = {}*/;
|
||||||
|
rpl::event_stream<> Events;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Flags Current() {
|
||||||
|
return Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(Flags flags) {
|
||||||
|
if (const auto diff = Data ^ flags) {
|
||||||
|
Data = flags;
|
||||||
|
if (diff & kAnimations) {
|
||||||
|
anim::SetDisabled(On(kAnimations));
|
||||||
|
}
|
||||||
|
Events.fire({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<Flags> Changes() {
|
||||||
|
return Events.events() | rpl::map(Current);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<Flags> Value() {
|
||||||
|
return rpl::single(Current()) | rpl::then(Changes());
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<bool> Value(Flag flag) {
|
||||||
|
return Value() | rpl::map([=](Flags flags) {
|
||||||
|
return (flags & flag) != 0;
|
||||||
|
}) | rpl::distinct_until_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PowerSaving
|
38
Telegram/SourceFiles/ui/power_saving.h
Normal file
38
Telegram/SourceFiles/ui/power_saving.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace PowerSaving {
|
||||||
|
|
||||||
|
enum Flag : uint32 {
|
||||||
|
kAnimations = (1U << 0),
|
||||||
|
kStickersPanel = (1U << 1),
|
||||||
|
kStickersChat = (1U << 2),
|
||||||
|
kEmojiPanel = (1U << 3),
|
||||||
|
kEmojiReactions = (1U << 4),
|
||||||
|
kEmojiChat = (1U << 5),
|
||||||
|
kChatBackground = (1U << 6),
|
||||||
|
kChatSpoiler = (1U << 7),
|
||||||
|
kCalls = (1U << 8),
|
||||||
|
|
||||||
|
kAll = (1U << 9) - 1,
|
||||||
|
};
|
||||||
|
inline constexpr bool is_flag_type(Flag) { return true; }
|
||||||
|
using Flags = base::flags<Flag>;
|
||||||
|
|
||||||
|
[[nodiscard]] Flags Current();
|
||||||
|
[[nodiscard]] rpl::producer<Flags> Changes();
|
||||||
|
[[nodiscard]] rpl::producer<Flags> Value();
|
||||||
|
[[nodiscard]] rpl::producer<bool> Value(Flag flag);
|
||||||
|
[[nodiscard]] void Set(Flags flags);
|
||||||
|
|
||||||
|
[[nodiscard]] inline bool On(Flag flag) {
|
||||||
|
return Current() & flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PowerSaving
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/emoji_config.h"
|
#include "ui/emoji_config.h"
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/power_saving.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_forum_topic.h"
|
#include "data/data_forum_topic.h"
|
||||||
|
@ -825,6 +826,8 @@ void Notification::paintTitle(Painter &p) {
|
||||||
.availableWidth = _titleRect.width(),
|
.availableWidth = _titleRect.width(),
|
||||||
.palette = &st::dialogsTextPalette,
|
.palette = &st::dialogsTextPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
|
.pausedEmoji = On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = On(PowerSaving::kChatSpoiler),
|
||||||
.elisionLines = 1,
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -837,6 +840,8 @@ void Notification::paintText(Painter &p) {
|
||||||
.availableWidth = _textRect.width(),
|
.availableWidth = _textRect.width(),
|
||||||
.palette = &st::dialogsTextPalette,
|
.palette = &st::dialogsTextPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
|
.pausedEmoji = On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = On(PowerSaving::kChatSpoiler),
|
||||||
.elisionLines = _textRect.height() / st::dialogsTextFont->height,
|
.elisionLines = _textRect.height() / st::dialogsTextFont->height,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,6 +303,8 @@ PRIVATE
|
||||||
ui/empty_userpic.h
|
ui/empty_userpic.h
|
||||||
ui/grouped_layout.cpp
|
ui/grouped_layout.cpp
|
||||||
ui/grouped_layout.h
|
ui/grouped_layout.h
|
||||||
|
ui/power_saving.cpp
|
||||||
|
ui/power_saving.h
|
||||||
ui/unread_badge_paint.cpp
|
ui/unread_badge_paint.cpp
|
||||||
ui/unread_badge_paint.h
|
ui/unread_badge_paint.h
|
||||||
ui/userpic_view.cpp
|
ui/userpic_view.cpp
|
||||||
|
|
Loading…
Add table
Reference in a new issue