Added initial implementation of global TTL settings.
This commit is contained in:
parent
97fa92de0b
commit
d0ae07f3c2
|
@ -1173,6 +1173,8 @@ PRIVATE
|
||||||
settings/settings_experimental.h
|
settings/settings_experimental.h
|
||||||
settings/settings_folders.cpp
|
settings/settings_folders.cpp
|
||||||
settings/settings_folders.h
|
settings/settings_folders.h
|
||||||
|
settings/settings_global_ttl.cpp
|
||||||
|
settings/settings_global_ttl.h
|
||||||
settings/settings_information.cpp
|
settings/settings_information.cpp
|
||||||
settings/settings_information.h
|
settings/settings_information.h
|
||||||
settings/settings_intro.cpp
|
settings/settings_intro.cpp
|
||||||
|
|
BIN
Telegram/Resources/animations/ttl.tgs
Normal file
BIN
Telegram/Resources/animations/ttl.tgs
Normal file
Binary file not shown.
BIN
Telegram/Resources/icons/settings/ttl.png
Normal file
BIN
Telegram/Resources/icons/settings/ttl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 591 B |
BIN
Telegram/Resources/icons/settings/ttl@2x.png
Normal file
BIN
Telegram/Resources/icons/settings/ttl@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
Telegram/Resources/icons/settings/ttl@3x.png
Normal file
BIN
Telegram/Resources/icons/settings/ttl@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -8,5 +8,6 @@
|
||||||
<file alias="cloud_password/password_input.tgs">../../animations/cloud_password/password_input.tgs</file>
|
<file alias="cloud_password/password_input.tgs">../../animations/cloud_password/password_input.tgs</file>
|
||||||
<file alias="cloud_password/hint.tgs">../../animations/cloud_password/hint.tgs</file>
|
<file alias="cloud_password/hint.tgs">../../animations/cloud_password/hint.tgs</file>
|
||||||
<file alias="cloud_password/email.tgs">../../animations/cloud_password/email.tgs</file>
|
<file alias="cloud_password/email.tgs">../../animations/cloud_password/email.tgs</file>
|
||||||
|
<file alias="ttl.tgs">../../animations/ttl.tgs</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -158,10 +158,12 @@ void TTLBoxOld(
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void TTLBox(not_null<Ui::GenericBox*> box, Args args) {
|
void TTLBox(not_null<Ui::GenericBox*> box, Args args) {
|
||||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
if (args.about) {
|
||||||
box,
|
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||||
std::move(args.about),
|
box,
|
||||||
st::boxLabel));
|
std::move(args.about),
|
||||||
|
st::boxLabel));
|
||||||
|
}
|
||||||
|
|
||||||
const auto ttls = std::vector<TimeId>{
|
const auto ttls = std::vector<TimeId>{
|
||||||
(86400 * 1),
|
(86400 * 1),
|
||||||
|
@ -188,17 +190,14 @@ void TTLBox(not_null<Ui::GenericBox*> box, Args args) {
|
||||||
const auto pickerTtl = TimePickerBox(box, ttls, phrases, args.startTtl);
|
const auto pickerTtl = TimePickerBox(box, ttls, phrases, args.startTtl);
|
||||||
|
|
||||||
Ui::ConfirmBox(box, {
|
Ui::ConfirmBox(box, {
|
||||||
.confirmed = [=] {
|
.confirmed = [=] { args.callback(pickerTtl()); },
|
||||||
args.callback(pickerTtl());
|
|
||||||
box->getDelegate()->hideLayer();
|
|
||||||
},
|
|
||||||
.confirmText = tr::lng_settings_save(),
|
.confirmText = tr::lng_settings_save(),
|
||||||
.cancelText = tr::lng_cancel(),
|
.cancelText = tr::lng_cancel(),
|
||||||
});
|
});
|
||||||
|
|
||||||
box->setTitle(tr::lng_manage_messages_ttl_title());
|
box->setTitle(tr::lng_manage_messages_ttl_title());
|
||||||
|
|
||||||
if (args.startTtl) {
|
if (args.startTtl && !args.hideDisable) {
|
||||||
box->addLeftButton(tr::lng_manage_messages_ttl_disable(), [=] {
|
box->addLeftButton(tr::lng_manage_messages_ttl_disable(), [=] {
|
||||||
args.callback(0);
|
args.callback(0);
|
||||||
box->getDelegate()->hideLayer();
|
box->getDelegate()->hideLayer();
|
||||||
|
|
|
@ -23,6 +23,7 @@ struct Args {
|
||||||
TimeId startTtl;
|
TimeId startTtl;
|
||||||
rpl::producer<QString> about;
|
rpl::producer<QString> about;
|
||||||
Fn<void(TimeId)> callback;
|
Fn<void(TimeId)> callback;
|
||||||
|
bool hideDisable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
void TTLBox(not_null<Ui::GenericBox*> box, Args args);
|
void TTLBox(not_null<Ui::GenericBox*> box, Args args);
|
||||||
|
|
|
@ -92,6 +92,7 @@ Args TTLValidator::createArgs() const {
|
||||||
}).fail([=] {
|
}).fail([=] {
|
||||||
state->savingRequestId = 0;
|
state->savingRequestId = 0;
|
||||||
}).send();
|
}).send();
|
||||||
|
show->hideLayer();
|
||||||
};
|
};
|
||||||
auto about = peer->isUser()
|
auto about = peer->isUser()
|
||||||
? tr::lng_ttl_edit_about(lt_user, rpl::single(peer->shortName()))
|
? tr::lng_ttl_edit_about(lt_user, rpl::single(peer->shortName()))
|
||||||
|
|
|
@ -93,6 +93,7 @@ settingsIconPin: icon {{ "settings/pin", settingsIconFg }};
|
||||||
settingsIconDownload: icon {{ "settings/download", settingsIconFg }};
|
settingsIconDownload: icon {{ "settings/download", settingsIconFg }};
|
||||||
settingsIconMention: icon {{ "settings/mention", settingsIconFg }};
|
settingsIconMention: icon {{ "settings/mention", settingsIconFg }};
|
||||||
settingsIconTopics: icon {{ "settings/topics", settingsIconFg }};
|
settingsIconTopics: icon {{ "settings/topics", settingsIconFg }};
|
||||||
|
settingsIconTTL: icon {{ "settings/ttl", settingsIconFg }};
|
||||||
|
|
||||||
settingsPremiumIconChannelsOff: icon {{ "settings/premium/channels_off", settingsIconFg }};
|
settingsPremiumIconChannelsOff: icon {{ "settings/premium/channels_off", settingsIconFg }};
|
||||||
settingsPremiumIconDouble: icon {{ "settings/premium/double", settingsIconFg }};
|
settingsPremiumIconDouble: icon {{ "settings/premium/double", settingsIconFg }};
|
||||||
|
|
273
Telegram/SourceFiles/settings/settings_global_ttl.cpp
Normal file
273
Telegram/SourceFiles/settings/settings_global_ttl.cpp
Normal file
|
@ -0,0 +1,273 @@
|
||||||
|
/*
|
||||||
|
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 "settings/settings_global_ttl.h"
|
||||||
|
|
||||||
|
#include "api/api_self_destruct.h"
|
||||||
|
#include "apiwrap.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "lottie/lottie_icon.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "menu/menu_ttl.h"
|
||||||
|
#include "settings/settings_common.h"
|
||||||
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
#include "ui/text/format_values.h"
|
||||||
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "ui/toasts/common_toasts.h"
|
||||||
|
#include "ui/widgets/buttons.h"
|
||||||
|
#include "ui/widgets/checkbox.h"
|
||||||
|
#include "ui/widgets/labels.h"
|
||||||
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
|
#include "styles/style_boxes.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
|
#include "styles/style_settings.h"
|
||||||
|
|
||||||
|
namespace Settings {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void SetupTopContent(
|
||||||
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
|
rpl::producer<> showFinished) {
|
||||||
|
const auto divider = Ui::CreateChild<Ui::BoxContentDivider>(parent.get());
|
||||||
|
const auto verticalLayout = parent->add(
|
||||||
|
object_ptr<Ui::VerticalLayout>(parent.get()));
|
||||||
|
|
||||||
|
auto icon = CreateLottieIcon(
|
||||||
|
verticalLayout,
|
||||||
|
{
|
||||||
|
.name = u"ttl"_q,
|
||||||
|
.sizeOverride = {
|
||||||
|
st::settingsCloudPasswordIconSize,
|
||||||
|
st::settingsCloudPasswordIconSize,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
st::settingsFilterIconPadding);
|
||||||
|
std::move(
|
||||||
|
showFinished
|
||||||
|
) | rpl::start_with_next([animate = std::move(icon.animate)] {
|
||||||
|
animate(anim::repeat::loop);
|
||||||
|
}, verticalLayout->lifetime());
|
||||||
|
verticalLayout->add(std::move(icon.widget));
|
||||||
|
|
||||||
|
verticalLayout->geometryValue(
|
||||||
|
) | rpl::start_with_next([=](const QRect &r) {
|
||||||
|
divider->setGeometry(r);
|
||||||
|
}, divider->lifetime());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
class GlobalTTL : public Section<GlobalTTL> {
|
||||||
|
public:
|
||||||
|
GlobalTTL(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<QString> title() override;
|
||||||
|
void setupContent();
|
||||||
|
|
||||||
|
void showFinished() override final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void rebuildButtons(TimeId currentTTL) const;
|
||||||
|
void showSure(TimeId ttl, bool rebuild) const;
|
||||||
|
|
||||||
|
void request(TimeId ttl) const;
|
||||||
|
|
||||||
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
const std::shared_ptr<Ui::RadiobuttonGroup> _group;
|
||||||
|
const std::shared_ptr<Window::Show> _show;
|
||||||
|
|
||||||
|
not_null<Ui::VerticalLayout*> _buttons;
|
||||||
|
|
||||||
|
rpl::event_stream<> _showFinished;
|
||||||
|
rpl::lifetime _requestLifetime;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GlobalTTL::GlobalTTL(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller)
|
||||||
|
: Section(parent)
|
||||||
|
, _controller(controller)
|
||||||
|
, _group(std::make_shared<Ui::RadiobuttonGroup>(0))
|
||||||
|
, _show(std::make_shared<Window::Show>(controller))
|
||||||
|
, _buttons(Ui::CreateChild<Ui::VerticalLayout>(this)) {
|
||||||
|
setupContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<QString> GlobalTTL::title() {
|
||||||
|
return tr::lng_settings_ttl_title();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalTTL::request(TimeId ttl) const {
|
||||||
|
_controller->session().api().selfDestruct().updateDefaultHistoryTTL(ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalTTL::showSure(TimeId ttl, bool rebuild) const {
|
||||||
|
const auto ttlText = Ui::FormatTTLAfter(ttl);
|
||||||
|
const auto confirmed = [=] {
|
||||||
|
if (rebuild) {
|
||||||
|
rebuildButtons(ttl);
|
||||||
|
}
|
||||||
|
_group->setChangedCallback([=](int value) {
|
||||||
|
_group->setChangedCallback(nullptr);
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.parentOverride = _show->toastParent(),
|
||||||
|
.text = tr::lng_settings_ttl_after_toast(
|
||||||
|
tr::now,
|
||||||
|
lt_after_duration,
|
||||||
|
{ .text = ttlText },
|
||||||
|
Ui::Text::WithEntities)
|
||||||
|
});
|
||||||
|
_show->hideLayer(); // Don't use close().
|
||||||
|
});
|
||||||
|
request(ttl);
|
||||||
|
};
|
||||||
|
if (_group->value()) {
|
||||||
|
confirmed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_show->showBox(Ui::MakeConfirmBox({
|
||||||
|
.text = tr::lng_settings_ttl_after_sure(
|
||||||
|
lt_after_duration,
|
||||||
|
rpl::single(ttlText)),
|
||||||
|
.confirmed = confirmed,
|
||||||
|
.cancelled = [=](Fn<void()> &&close) {
|
||||||
|
_group->setChangedCallback(nullptr);
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
.confirmText = tr::lng_sure_enable(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalTTL::rebuildButtons(TimeId currentTTL) const {
|
||||||
|
auto ttls = std::vector<TimeId>{
|
||||||
|
0,
|
||||||
|
3600 * 24,
|
||||||
|
3600 * 24 * 7,
|
||||||
|
3600 * 24 * 31,
|
||||||
|
};
|
||||||
|
if (!ranges::contains(ttls, currentTTL)) {
|
||||||
|
ttls.push_back(currentTTL);
|
||||||
|
ranges::sort(ttls);
|
||||||
|
}
|
||||||
|
if (_buttons->count() > ttls.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_buttons->clear();
|
||||||
|
for (const auto &ttl : ttls) {
|
||||||
|
const auto ttlText = Ui::FormatTTLAfter(ttl);
|
||||||
|
const auto button = AddButton(
|
||||||
|
_buttons,
|
||||||
|
(!ttl)
|
||||||
|
? tr::lng_settings_ttl_after_off()
|
||||||
|
: tr::lng_settings_ttl_after(
|
||||||
|
lt_after_duration,
|
||||||
|
rpl::single(ttlText)),
|
||||||
|
st::settingsButtonNoIcon);
|
||||||
|
button->setClickedCallback([=] {
|
||||||
|
if (_group->value() == ttl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!ttl) {
|
||||||
|
_group->setChangedCallback(nullptr);
|
||||||
|
request(ttl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showSure(ttl, false);
|
||||||
|
});
|
||||||
|
const auto radio = Ui::CreateChild<Ui::Radiobutton>(
|
||||||
|
button.get(),
|
||||||
|
_group,
|
||||||
|
ttl,
|
||||||
|
QString());
|
||||||
|
radio->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
radio->show();
|
||||||
|
button->sizeValue(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
radio->moveToRight(0, radio->checkRect().top());
|
||||||
|
}, radio->lifetime());
|
||||||
|
}
|
||||||
|
_buttons->resizeToWidth(width());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalTTL::setupContent() {
|
||||||
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
setFocus();
|
||||||
|
|
||||||
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
||||||
|
SetupTopContent(content, _showFinished.events());
|
||||||
|
|
||||||
|
AddSkip(content);
|
||||||
|
AddSubsectionTitle(content, tr::lng_settings_ttl_after_subtitle());
|
||||||
|
|
||||||
|
content->add(object_ptr<Ui::VerticalLayout>::fromRaw(_buttons));
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto &apiTTL = _controller->session().api().selfDestruct();
|
||||||
|
const auto rebuild = [=](TimeId period) {
|
||||||
|
rebuildButtons(period);
|
||||||
|
_group->setValue(period);
|
||||||
|
};
|
||||||
|
rebuild(apiTTL.periodDefaultHistoryTTLCurrent());
|
||||||
|
apiTTL.periodDefaultHistoryTTL(
|
||||||
|
) | rpl::start_with_next(rebuild, content->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto show = std::make_shared<Window::Show>(_controller);
|
||||||
|
AddButton(
|
||||||
|
content,
|
||||||
|
tr::lng_settings_ttl_after_custom(),
|
||||||
|
st::settingsButtonNoIcon)->setClickedCallback([=] {
|
||||||
|
struct Args {
|
||||||
|
std::shared_ptr<Ui::Show> show;
|
||||||
|
TimeId startTtl;
|
||||||
|
rpl::producer<QString> about;
|
||||||
|
Fn<void(TimeId)> callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
show->showBox(Box(TTLMenu::TTLBox, TTLMenu::Args{
|
||||||
|
.show = show,
|
||||||
|
.startTtl = _group->value(),
|
||||||
|
.callback = [=](TimeId ttl) { showSure(ttl, true); },
|
||||||
|
.hideDisable = true,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
AddSkip(content);
|
||||||
|
|
||||||
|
auto footer = object_ptr<Ui::FlatLabel>(
|
||||||
|
content,
|
||||||
|
tr::lng_settings_ttl_after_about(
|
||||||
|
lt_link,
|
||||||
|
tr::lng_settings_ttl_after_about_link(
|
||||||
|
) | rpl::map([](QString s) { return Ui::Text::Link(s, 1); }),
|
||||||
|
Ui::Text::WithEntities),
|
||||||
|
st::boxDividerLabel);
|
||||||
|
footer->overrideLinkClickHandler([=] {
|
||||||
|
});
|
||||||
|
content->add(object_ptr<Ui::DividerLabel>(
|
||||||
|
content,
|
||||||
|
std::move(footer),
|
||||||
|
st::settingsDividerLabelPadding));
|
||||||
|
|
||||||
|
Ui::ResizeFitChild(this, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalTTL::showFinished() {
|
||||||
|
_showFinished.fire({});
|
||||||
|
}
|
||||||
|
|
||||||
|
Type GlobalTTLId() {
|
||||||
|
return GlobalTTL::Id();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Settings
|
17
Telegram/SourceFiles/settings/settings_global_ttl.h
Normal file
17
Telegram/SourceFiles/settings/settings_global_ttl.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "settings/settings_type.h"
|
||||||
|
|
||||||
|
namespace Settings {
|
||||||
|
|
||||||
|
Type GlobalTTLId();
|
||||||
|
|
||||||
|
} // namespace Settings
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/cloud_password/settings_cloud_password_start.h"
|
#include "settings/cloud_password/settings_cloud_password_start.h"
|
||||||
#include "settings/settings_blocked_peers.h"
|
#include "settings/settings_blocked_peers.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
|
#include "settings/settings_global_ttl.h"
|
||||||
#include "settings/settings_local_passcode.h"
|
#include "settings/settings_local_passcode.h"
|
||||||
#include "settings/settings_premium.h" // Settings::ShowPremium.
|
#include "settings/settings_premium.h" // Settings::ShowPremium.
|
||||||
#include "settings/settings_privacy_controllers.h"
|
#include "settings/settings_privacy_controllers.h"
|
||||||
|
@ -31,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
@ -459,9 +461,6 @@ void SetupCloudPassword(
|
||||||
reloadOnActivation);
|
reloadOnActivation);
|
||||||
|
|
||||||
session->api().cloudPassword().reload();
|
session->api().cloudPassword().reload();
|
||||||
|
|
||||||
AddSkip(container);
|
|
||||||
AddDividerText(container, tr::lng_settings_cloud_password_start_about());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSensitiveContent(
|
void SetupSensitiveContent(
|
||||||
|
@ -671,6 +670,37 @@ void SetupSessionsList(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupGlobalTTLList(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
rpl::producer<> updateTrigger,
|
||||||
|
Fn<void(Type)> showOther) {
|
||||||
|
const auto session = &controller->session();
|
||||||
|
auto ttlLabel = rpl::combine(
|
||||||
|
session->api().selfDestruct().periodDefaultHistoryTTL(),
|
||||||
|
tr::lng_settings_ttl_after_off()
|
||||||
|
) | rpl::map([](int ttl, const QString &none) {
|
||||||
|
return ttl ? Ui::FormatTTL(ttl) : none;
|
||||||
|
});
|
||||||
|
const auto globalTTLButton = AddButtonWithLabel(
|
||||||
|
container,
|
||||||
|
tr::lng_settings_ttl_title(),
|
||||||
|
std::move(ttlLabel),
|
||||||
|
st::settingsButton,
|
||||||
|
{ &st::settingsIconTTL, kIconPurple });
|
||||||
|
globalTTLButton->addClickHandler([=] {
|
||||||
|
showOther(GlobalTTLId());
|
||||||
|
});
|
||||||
|
std::move(
|
||||||
|
updateTrigger
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
session->api().selfDestruct().reload();
|
||||||
|
}, container->lifetime());
|
||||||
|
|
||||||
|
AddSkip(container);
|
||||||
|
AddDividerText(container, tr::lng_settings_ttl_about());
|
||||||
|
}
|
||||||
|
|
||||||
void SetupSecurity(
|
void SetupSecurity(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
@ -691,6 +721,11 @@ void SetupSecurity(
|
||||||
showOther);
|
showOther);
|
||||||
SetupLocalPasscode(controller, container, showOther);
|
SetupLocalPasscode(controller, container, showOther);
|
||||||
SetupCloudPassword(controller, container, showOther);
|
SetupCloudPassword(controller, container, showOther);
|
||||||
|
SetupGlobalTTLList(
|
||||||
|
controller,
|
||||||
|
container,
|
||||||
|
rpl::duplicate(updateTrigger),
|
||||||
|
showOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -407,6 +407,30 @@ QString FormatTTL(float64 ttl) {
|
||||||
: tr::lng_years({}, lt_count, std::round(ttl / (86400 * 365)));
|
: tr::lng_years({}, lt_count, std::round(ttl / (86400 * 365)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FormatTTLAfter(float64 ttl) {
|
||||||
|
return (ttl <= 3600 * 23)
|
||||||
|
? tr::lng_settings_ttl_after_hours(tr::now, lt_count, int(ttl / 3600))
|
||||||
|
: (ttl <= (86400) * 6)
|
||||||
|
? tr::lng_settings_ttl_after_days(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
int(ttl / (86400)))
|
||||||
|
: (ttl <= (86400 * 7) * 3)
|
||||||
|
? tr::lng_settings_ttl_after_weeks(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
int(ttl / (86400 * 7)))
|
||||||
|
: (ttl <= (86400 * 31) * 11)
|
||||||
|
? tr::lng_settings_ttl_after_months(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
int(ttl / (86400 * 31)))
|
||||||
|
: tr::lng_settings_ttl_after_years(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
std::round(ttl / (86400 * 365)));
|
||||||
|
}
|
||||||
|
|
||||||
QString FormatTTLTiny(float64 ttl) {
|
QString FormatTTLTiny(float64 ttl) {
|
||||||
return (ttl <= 3600 * 9)
|
return (ttl <= 3600 * 9)
|
||||||
? tr::lng_hours_tiny(tr::now, lt_count, int(ttl / 3600))
|
? tr::lng_hours_tiny(tr::now, lt_count, int(ttl / 3600))
|
||||||
|
|
|
@ -29,6 +29,7 @@ inline constexpr auto FileStatusSizeFailed = 0xFFFFFFF2LL;
|
||||||
[[nodiscard]] QString FormatImageSizeText(const QSize &size);
|
[[nodiscard]] QString FormatImageSizeText(const QSize &size);
|
||||||
[[nodiscard]] QString FormatPhone(const QString &phone);
|
[[nodiscard]] QString FormatPhone(const QString &phone);
|
||||||
[[nodiscard]] QString FormatTTL(float64 ttl);
|
[[nodiscard]] QString FormatTTL(float64 ttl);
|
||||||
|
[[nodiscard]] QString FormatTTLAfter(float64 ttl);
|
||||||
[[nodiscard]] QString FormatTTLTiny(float64 ttl);
|
[[nodiscard]] QString FormatTTLTiny(float64 ttl);
|
||||||
[[nodiscard]] QString FormatMuteFor(float64 sec);
|
[[nodiscard]] QString FormatMuteFor(float64 sec);
|
||||||
[[nodiscard]] QString FormatMuteForTiny(float64 sec);
|
[[nodiscard]] QString FormatMuteForTiny(float64 sec);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user