2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Implement some power saving options.

This commit is contained in:
John Preston
2023-02-21 16:31:55 +04:00
parent 02bc950b57
commit 2a4c39b9d7
53 changed files with 446 additions and 108 deletions

View File

@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_common.h"
#include "settings/settings_chat.h"
#include "settings/settings_experimental.h"
#include "settings/settings_power_saving.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/widgets/labels.h"
@@ -658,20 +659,16 @@ void SetupWindowTitleOptions(
SetupWindowTitleContent);
}
void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
void SetupAnimations(
not_null<Window::Controller*> window,
not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
tr::lng_settings_enable_animations(),
tr::lng_settings_power_title(),
st::settingsButtonNoIcon
)->toggleOn(
rpl::single(!anim::Disabled())
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled == anim::Disabled());
}) | rpl::start_with_next([](bool enabled) {
anim::SetDisabled(!enabled);
Local::writeSettings();
}, container->lifetime());
)->setClickedCallback([=] {
window->show(Box(PowerSavingBox));
});
}
void SetupHardwareAcceleration(not_null<Ui::VerticalLayout*> container) {
@@ -804,7 +801,7 @@ void SetupOpenGL(
void SetupPerformance(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container) {
SetupAnimations(container);
SetupAnimations(&controller->window(), container);
SetupHardwareAcceleration(container);
#ifdef Q_OS_WIN
SetupANGLE(controller, container);