/
diev
/
stelegramdesktop-tdesktop
Обзор
Документация
Войти
/
diev
/
stelegramdesktop-tdesktop
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
Telegram/SourceFiles/ui/power_saving.cpp
56 строк
987 B
John Preston
Implement "Save Power on Low Battery" function.
01 мар 2023, 08:12
01 мар 2023, 08:12
ce0e07d
Код
Авторство
О чём код?
/* 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; bool AllForced/* = false*/; } // namespace void Set(Flags flags) { if (const auto diff = Data ^ flags) { Data = flags; if (!AllForced) { if (diff & kAnimations) { anim::SetDisabled(On(kAnimations)); } Events.fire({}); } } } Flags Current() { return Data; } void SetForceAll(bool force) { if (AllForced == force) { return; } AllForced = force; if (const auto diff = Data ^ kAll) { if (diff & kAnimations) { anim::SetDisabled(On(kAnimations)); } Events.fire({}); } } bool ForceAll() { return AllForced; } rpl::producer<> Changes() { return Events.events(); } } // namespace PowerSaving