Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_settings_power_chat_effects" = "Effects in messages";
"lng_settings_power_calls" = "Animations in Calls";
"lng_settings_power_ui" = "Interface animations";
"lng_settings_power_animated_avatars" = "Animated avatars";
"lng_settings_power_auto" = "Save Power on Low Battery";
"lng_settings_power_auto_about" = "Automatically disable all animations when your laptop is in a battery saving mode.";
"lng_settings_power_turn_off" = "Please turn off Save Power on Low Battery to change these settings.";
Expand Down
9 changes: 8 additions & 1 deletion Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ For license and copyright information please follow this link:
#include "ui/dynamic_thumbnails.h"
#include "ui/vertical_list.h"
#include "ui/painter.h"
#include "ui/power_saving.h"
#include "ui/rect.h"
#include "ui/screen_reader_mode.h"
#include "ui/ui_utility.h"
Expand Down Expand Up @@ -319,6 +320,11 @@ InnerWidget::InnerWidget(
update();
}, lifetime());

PowerSaving::OnValue(PowerSaving::kAnimatedUserpics) | rpl::on_next([=] {
_videoUserpics.clear();
update();
}, lifetime());

Core::App().notifications().settingsChanged(
) | rpl::on_next([=](Window::Notifications::ChangeType change) {
if (change == Window::Notifications::ChangeType::CountMessages) {
Expand Down Expand Up @@ -1434,7 +1440,8 @@ Ui::VideoUserpic *InnerWidget::validateVideoUserpic(not_null<Row*> row) {
Ui::VideoUserpic *InnerWidget::validateVideoUserpic(
not_null<History*> history) {
const auto peer = history->peer;
if (!peer->isPremium()
if (PowerSaving::On(PowerSaving::kAnimatedUserpics)
|| !peer->isPremium()
|| peer->userpicPhotoUnknown()
|| !peer->userpicHasVideo()) {
_videoUserpics.remove(peer);
Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/dialogs/ui/dialogs_video_userpic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For license and copyright information please follow this link:
#include "dialogs/dialogs_entry.h"
#include "dialogs/ui/dialogs_layout.h"
#include "ui/painter.h"
#include "ui/power_saving.h"
#include "styles/style_dialogs.h"

namespace Dialogs::Ui {
Expand Down Expand Up @@ -165,7 +166,7 @@ void PaintUserpic(
int outerWidth,
int size,
bool paused) {
if (videoUserpic) {
if (videoUserpic && !PowerSaving::On(PowerSaving::kAnimatedUserpics)) {
videoUserpic->paintLeft(p, view, x, y, outerWidth, size, paused);
} else {
peer->paintUserpicLeft(p, view, x, y, outerWidth, size);
Expand Down
8 changes: 7 additions & 1 deletion Telegram/SourceFiles/history/history_inner_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ For license and copyright information please follow this link:
#include "ui/controls/swipe_handler.h"
#include "ui/inactive_press.h"
#include "ui/painter.h"
#include "ui/power_saving.h"
#include "ui/rect.h"
#include "ui/screen_reader_mode.h"
#include "ui/ui_utility.h"
Expand Down Expand Up @@ -418,6 +419,10 @@ HistoryInner::HistoryInner(
update();
}
}, lifetime());
PowerSaving::OnValue(PowerSaving::kAnimatedUserpics) | rpl::on_next([=] {
_videoUserpics.clear();
update();
}, lifetime());

using PlayRequest = ChatHelpers::EmojiInteractionPlayRequest;
_controller->emojiInteractions().playRequests(
Expand Down Expand Up @@ -1788,7 +1793,8 @@ int HistoryInner::SelectionViewOffset(

HistoryInner::VideoUserpic *HistoryInner::validateVideoUserpic(
not_null<PeerData*> peer) {
if (!peer->isPremium()
if (PowerSaving::On(PowerSaving::kAnimatedUserpics)
|| !peer->isPremium()
|| peer->userpicPhotoUnknown()
|| !peer->userpicHasVideo()) {
_videoUserpics.remove(peer);
Expand Down
12 changes: 11 additions & 1 deletion Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ For license and copyright information please follow this link:
#include "ui/layers/generic_box.h"
#include "ui/painter.h"
#include "ui/peer/video_userpic_player.h"
#include "ui/power_saving.h"
#include "ui/rect.h"
#include "ui/text/text_utilities.h"
#include "ui/top_background_gradient.h"
Expand Down Expand Up @@ -451,6 +452,10 @@ TopBar::TopBar(
[=] { update(); });
} else {
updateVideoUserpic();
PowerSaving::OnValue(PowerSaving::kAnimatedUserpics) | rpl::on_next([=] {
updateVideoUserpic();
update();
}, lifetime());
}

rpl::merge(
Expand Down Expand Up @@ -1803,7 +1808,9 @@ void TopBar::paintUserpic(QPainter &p, const QRect &geometry) {
_topicIconView->paintInRect(p, geometry);
return;
}
if (_videoUserpicPlayer && _videoUserpicPlayer->ready()) {
if (_videoUserpicPlayer
&& _videoUserpicPlayer->ready()
&& !PowerSaving::On(PowerSaving::kAnimatedUserpics)) {
const auto size = st::infoProfileTopBarPhotoSize;
const auto frame = _videoUserpicPlayer->frame(Size(size), _peer);
if (!frame.isNull()) {
Expand Down Expand Up @@ -2102,6 +2109,9 @@ void TopBar::fillTopBarMenu(
void TopBar::updateVideoUserpic() {
if (width() <= 0) {
return;
} else if (PowerSaving::On(PowerSaving::kAnimatedUserpics)) {
_videoUserpicPlayer = nullptr;
return;
}
const auto id = _peer->userpicPhotoId();
if (!id) {
Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/settings/settings_power_saving.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ EditFlagsDescriptor<PowerSaving::Flags> PowerSavingLabels() {
tr::lng_settings_power_ui(tr::now),
&st::menuIconStartStream,
},
{
kAnimatedUserpics,
tr::lng_settings_power_animated_avatars(tr::now),
&st::menuIconProfile,
},
};
return { .labels = {
{ tr::lng_settings_power_stickers(), std::move(stickers) },
Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/ui/power_saving.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ enum Flag : uint32 {
kCalls = (1U << 8),
kEmojiStatus = (1U << 9),
kChatEffects = (1U << 10),
kAnimatedUserpics = (1U << 11),

kAll = (1U << 11) - 1,
kAll = (1U << 12) - 1,
};
inline constexpr bool is_flag_type(Flag) { return true; }
using Flags = base::flags<Flag>;
Expand Down