2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Simplified confirmed callback for ConfirmBox instances.

This commit is contained in:
23rd
2020-09-24 15:48:02 +03:00
committed by John Preston
parent 9f3af7234e
commit f81271d1fe
21 changed files with 89 additions and 144 deletions

View File

@@ -1321,16 +1321,13 @@ void ToggleNightModeWithConfirmation(
if (Background()->nightModeChangeAllowed()) {
toggle();
} else {
const auto box = std::make_shared<QPointer<ConfirmBox>>();
const auto disableAndToggle = [=] {
const auto disableAndToggle = [=](Fn<void()> &&close) {
Core::App().settings().setSystemDarkModeEnabled(false);
Core::App().saveSettingsDelayed();
toggle();
if (*box) {
(*box)->closeBox();
}
close();
};
*box = window->show(Box<ConfirmBox>(
window->show(Box<ConfirmBox>(
tr::lng_settings_auto_night_warning(tr::now),
tr::lng_settings_auto_night_disable(tr::now),
disableAndToggle));