mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-28 11:30:54 +00:00
Simplified updating of autolock time in Settings::PrivacySecurity.
This commit is contained in:
parent
77c8bf8176
commit
7852c82eab
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "facades.h"
|
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
@ -45,7 +44,6 @@ void AutoLockBox::prepare() {
|
|||||||
void AutoLockBox::durationChanged(int seconds) {
|
void AutoLockBox::durationChanged(int seconds) {
|
||||||
Core::App().settings().setAutoLock(seconds);
|
Core::App().settings().setAutoLock(seconds);
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
Global::RefLocalPasscodeChanged().notify();
|
|
||||||
|
|
||||||
Core::App().checkAutoLock();
|
Core::App().checkAutoLock();
|
||||||
closeBox();
|
closeBox();
|
||||||
|
@ -291,15 +291,24 @@ void SetupLocalPasscode(
|
|||||||
Ui::show(Box<PasscodeBox>(&controller->session(), true));
|
Ui::show(Box<PasscodeBox>(&controller->session(), true));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const auto autoLockBoxClosing =
|
||||||
|
container->lifetime().make_state<rpl::event_stream<>>();
|
||||||
const auto label = base::Platform::LastUserInputTimeSupported()
|
const auto label = base::Platform::LastUserInputTimeSupported()
|
||||||
? tr::lng_passcode_autolock_away
|
? tr::lng_passcode_autolock_away
|
||||||
: tr::lng_passcode_autolock_inactive;
|
: tr::lng_passcode_autolock_inactive;
|
||||||
auto value = PasscodeChanges(
|
auto value = autoLockBoxClosing->events_starting_with(
|
||||||
|
rpl::empty_value()
|
||||||
) | rpl::map([] {
|
) | rpl::map([] {
|
||||||
const auto autolock = Core::App().settings().autoLock();
|
const auto autolock = Core::App().settings().autoLock();
|
||||||
return (autolock % 3600)
|
return (autolock % 3600)
|
||||||
? tr::lng_passcode_autolock_minutes(tr::now, lt_count, autolock / 60)
|
? tr::lng_passcode_autolock_minutes(
|
||||||
: tr::lng_passcode_autolock_hours(tr::now, lt_count, autolock / 3600);
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
autolock / 60)
|
||||||
|
: tr::lng_passcode_autolock_hours(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
autolock / 3600);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddButtonWithLabel(
|
AddButtonWithLabel(
|
||||||
@ -308,7 +317,9 @@ void SetupLocalPasscode(
|
|||||||
std::move(value),
|
std::move(value),
|
||||||
st::settingsButton
|
st::settingsButton
|
||||||
)->addClickHandler([=] {
|
)->addClickHandler([=] {
|
||||||
Ui::show(Box<AutoLockBox>(&controller->session()));
|
const auto box = Ui::show(Box<AutoLockBox>(&controller->session()));
|
||||||
|
box->boxClosing(
|
||||||
|
) | rpl::start_to_stream(*autoLockBoxClosing, box->lifetime());
|
||||||
});
|
});
|
||||||
|
|
||||||
wrap->toggleOn(base::duplicate(has));
|
wrap->toggleOn(base::duplicate(has));
|
||||||
|
Loading…
Reference in New Issue
Block a user