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

Use tr:: instead of Lang::Viewer.

This commit is contained in:
John Preston
2019-06-18 14:16:43 +02:00
parent f35085800a
commit 7af0dd105e
43 changed files with 483 additions and 511 deletions

View File

@@ -57,7 +57,7 @@ void SetupConnectionType(not_null<Ui::VerticalLayout*> container) {
};
const auto button = AddButtonWithLabel(
container,
lng_settings_connection_type,
tr::lng_settings_connection_type(),
rpl::single(
rpl::empty_value()
) | rpl::then(base::ObservableViewer(
@@ -88,7 +88,7 @@ void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
currentVersionText());
const auto toggle = AddButton(
container,
lng_settings_update_automatically,
tr::lng_settings_update_automatically(),
st::settingsUpdateToggle);
const auto label = Ui::CreateChild<Ui::FlatLabel>(
toggle.get(),
@@ -102,16 +102,16 @@ void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
const auto inner = options->entity();
const auto install = cAlphaVersion() ? nullptr : AddButton(
inner,
lng_settings_install_beta,
tr::lng_settings_install_beta(),
st::settingsButton).get();
const auto check = AddButton(
inner,
lng_settings_check_now,
tr::lng_settings_check_now(),
st::settingsButton);
const auto update = Ui::CreateChild<Button>(
check.get(),
Lang::Viewer(lng_update_telegram) | Ui::Text::ToUpper(),
tr::lng_update_telegram() | Ui::Text::ToUpper(),
st::settingsUpdate);
update->hide();
check->widthValue() | rpl::start_with_next([=](int width) {
@@ -403,7 +403,7 @@ void SetupTray(not_null<Ui::VerticalLayout*> container) {
void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_enable_animations,
tr::lng_settings_enable_animations(),
st::settingsButton
)->toggleOn(
rpl::single(!anim::Disabled())
@@ -421,7 +421,7 @@ void SetupPerformance(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_autoplay_gifs,
tr::lng_settings_autoplay_gifs(),
st::settingsButton
)->toggleOn(
rpl::single(cAutoPlayGif())
@@ -442,10 +442,10 @@ void SetupSystemIntegration(
Fn<void(Type)> showOther) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_settings_system_integration);
AddSubsectionTitle(container, tr::lng_settings_system_integration());
AddButton(
container,
lng_settings_section_call_settings,
tr::lng_settings_section_call_settings(),
st::settingsButton
)->addClickHandler([=] {
showOther(Type::Calls);
@@ -478,7 +478,7 @@ void Advanced::setupContent() {
if (HasUpdate()) {
addDivider();
AddSkip(content);
AddSubsectionTitle(content, lng_settings_version_info);
AddSubsectionTitle(content, tr::lng_settings_version_info());
SetupUpdate(content);
AddSkip(content);
}
@@ -489,7 +489,7 @@ void Advanced::setupContent() {
if (HasConnectionType()) {
addDivider();
AddSkip(content);
AddSubsectionTitle(content, lng_settings_network_proxy);
AddSubsectionTitle(content, tr::lng_settings_network_proxy());
SetupConnectionType(content);
AddSkip(content);
}
@@ -501,7 +501,7 @@ void Advanced::setupContent() {
AddDivider(content);
AddSkip(content);
AddSubsectionTitle(content, lng_settings_performance);
AddSubsectionTitle(content, tr::lng_settings_performance());
SetupPerformance(content);
AddSkip(content);

View File

@@ -96,10 +96,10 @@ void Calls::setupContent() {
}();
AddSkip(content);
AddSubsectionTitle(content, lng_settings_call_section_output);
AddSubsectionTitle(content, tr::lng_settings_call_section_output());
AddButtonWithLabel(
content,
lng_settings_call_output_device,
tr::lng_settings_call_output_device(),
rpl::single(
currentOutputName
) | rpl::then(
@@ -171,10 +171,10 @@ void Calls::setupContent() {
AddSkip(content);
AddDivider(content);
AddSkip(content);
AddSubsectionTitle(content, lng_settings_call_section_input);
AddSubsectionTitle(content, tr::lng_settings_call_section_input());
AddButtonWithLabel(
content,
lng_settings_call_input_device,
tr::lng_settings_call_input_device(),
rpl::single(
currentInputName
) | rpl::then(
@@ -276,12 +276,12 @@ void Calls::setupContent() {
AddSkip(content);
AddDivider(content);
AddSkip(content);
AddSubsectionTitle(content, lng_settings_call_section_other);
AddSubsectionTitle(content, tr::lng_settings_call_section_other());
#if defined Q_OS_MAC && !defined OS_MAC_STORE
AddButton(
content,
lng_settings_call_audio_ducking,
tr::lng_settings_call_audio_ducking(),
st::settingsButton
)->toggleOn(
rpl::single(Global::CallAudioDuckingEnabled())
@@ -298,7 +298,7 @@ void Calls::setupContent() {
AddButton(
content,
lng_settings_call_open_system_prefs,
tr::lng_settings_call_open_system_prefs(),
st::settingsButton
)->addClickHandler([] {
const auto opened = Platform::OpenSystemSettings(

View File

@@ -419,7 +419,7 @@ void SetupStickersEmoji(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_settings_stickers_emoji);
AddSubsectionTitle(container, tr::lng_settings_stickers_emoji());
auto wrap = object_ptr<Ui::VerticalLayout>(container);
const auto inner = wrap.data();
@@ -471,7 +471,7 @@ void SetupStickersEmoji(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_stickers_you_have,
tr::lng_stickers_you_have(),
st::settingsChatButton,
&st::settingsIconStickers,
st::settingsChatIconLeft
@@ -481,7 +481,7 @@ void SetupStickersEmoji(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_emoji_manage_sets,
tr::lng_emoji_manage_sets(),
st::settingsChatButton,
&st::settingsIconEmoji,
st::settingsChatIconLeft
@@ -496,7 +496,7 @@ void SetupMessages(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_settings_messages);
AddSubsectionTitle(container, tr::lng_settings_messages());
AddSkip(container, st::settingsSendTypeSkip);
@@ -546,7 +546,7 @@ void SetupMessages(not_null<Ui::VerticalLayout*> container) {
void SetupExport(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_export_data,
tr::lng_settings_export_data(),
st::settingsButton
)->addClickHandler([] {
Ui::hideSettingsAndLayer();
@@ -560,7 +560,7 @@ void SetupExport(not_null<Ui::VerticalLayout*> container) {
void SetupLocalStorage(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_manage_local_storage,
tr::lng_settings_manage_local_storage(),
st::settingsButton
)->addClickHandler([] {
LocalStorageBox::Show(
@@ -575,11 +575,11 @@ void SetupDataStorage(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_settings_data_storage);
AddSubsectionTitle(container, tr::lng_settings_data_storage());
const auto ask = AddButton(
container,
lng_download_path_ask,
tr::lng_download_path_ask(),
st::settingsButton
)->toggleOn(rpl::single(Global::AskDownloadPath()));
@@ -590,7 +590,7 @@ void SetupDataStorage(not_null<Ui::VerticalLayout*> container) {
container,
object_ptr<Button>(
container,
Lang::Viewer(lng_download_path),
tr::lng_download_path(),
st::settingsButton)));
auto pathtext = rpl::single(
rpl::empty_value()
@@ -603,7 +603,7 @@ void SetupDataStorage(not_null<Ui::VerticalLayout*> container) {
path->entity(),
std::move(pathtext),
st::settingsButton,
lng_download_path);
tr::lng_download_path());
path->entity()->addClickHandler([] {
Ui::show(Box<DownloadPathBox>());
});
@@ -633,21 +633,21 @@ void SetupAutoDownload(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_media_auto_settings);
AddSubsectionTitle(container, tr::lng_media_auto_settings());
using Source = Data::AutoDownload::Source;
const auto add = [&](LangKey label, Source source) {
const auto add = [&](rpl::producer<QString> label, Source source) {
AddButton(
container,
label,
std::move(label),
st::settingsButton
)->addClickHandler([=] {
Ui::show(Box<AutoDownloadBox>(source));
});
};
add(lng_media_auto_in_private, Source::User);
add(lng_media_auto_in_groups, Source::Group);
add(lng_media_auto_in_channels, Source::Channel);
add(tr::lng_media_auto_in_private(), Source::User);
add(tr::lng_media_auto_in_groups(), Source::Group);
add(tr::lng_media_auto_in_channels(), Source::Channel);
AddSkip(container, st::settingsCheckboxesSkip);
}
@@ -656,7 +656,7 @@ void SetupChatBackground(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_settings_section_background);
AddSubsectionTitle(container, tr::lng_settings_section_background());
container->add(
object_ptr<BackgroundRow>(container),
@@ -905,7 +905,7 @@ void SetupDefaultThemes(not_null<Ui::VerticalLayout*> container) {
void SetupThemeOptions(not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsPrivacySkip);
AddSubsectionTitle(container, lng_settings_themes);
AddSubsectionTitle(container, tr::lng_settings_themes());
AddSkip(container, st::settingsThemesTopSkip);
SetupDefaultThemes(container);
@@ -913,7 +913,7 @@ void SetupThemeOptions(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_bg_edit_theme,
tr::lng_settings_bg_edit_theme(),
st::settingsChatButton,
&st::settingsIconThemes,
st::settingsChatIconLeft

View File

@@ -77,15 +77,6 @@ void AddDividerText(
st::settingsDividerLabelPadding));
}
not_null<Button*> AddButton(
not_null<Ui::VerticalLayout*> container,
LangKey text,
const style::InfoProfileButton &st,
const style::icon *leftIcon,
int iconLeft) {
return AddButton(container, Lang::Viewer(text), st, leftIcon, iconLeft);
}
not_null<Button*> AddButton(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text,
@@ -127,13 +118,13 @@ void CreateRightLabel(
not_null<Button*> button,
rpl::producer<QString> label,
const style::InfoProfileButton &st,
LangKey buttonText) {
rpl::producer<QString> buttonText) {
const auto name = Ui::CreateChild<Ui::FlatLabel>(
button.get(),
st::settingsButtonRight);
rpl::combine(
button->widthValue(),
Lang::Viewer(buttonText),
std::move(buttonText),
std::move(label)
) | rpl::start_with_next([=, &st](
int width,
@@ -153,13 +144,18 @@ void CreateRightLabel(
not_null<Button*> AddButtonWithLabel(
not_null<Ui::VerticalLayout*> container,
LangKey text,
rpl::producer<QString> text,
rpl::producer<QString> label,
const style::InfoProfileButton &st,
const style::icon *leftIcon,
int iconLeft) {
const auto button = AddButton(container, text, st, leftIcon, iconLeft);
CreateRightLabel(button, std::move(label), st, text);
const auto button = AddButton(
container,
rpl::duplicate(text),
st,
leftIcon,
iconLeft);
CreateRightLabel(button, std::move(label), st, std::move(text));
return button;
}
@@ -174,12 +170,6 @@ void AddSubsectionTitle(
st::settingsSubsectionTitlePadding);
}
void AddSubsectionTitle(
not_null<Ui::VerticalLayout*> container,
LangKey text) {
AddSubsectionTitle(container, Lang::Viewer(text));
}
void FillMenu(Fn<void(Type)> showOther, MenuCallback addAction) {
if (!Auth().supportMode()) {
addAction(

View File

@@ -9,8 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h"
enum LangKey : int;
namespace Ui {
class VerticalLayout;
} // namespace Ui
@@ -71,12 +69,6 @@ void AddDivider(not_null<Ui::VerticalLayout*> container);
void AddDividerText(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text);
not_null<Button*> AddButton(
not_null<Ui::VerticalLayout*> container,
LangKey text,
const style::InfoProfileButton &st,
const style::icon *leftIcon = nullptr,
int iconLeft = 0);
not_null<Button*> AddButton(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text,
@@ -85,7 +77,7 @@ not_null<Button*> AddButton(
int iconLeft = 0);
not_null<Button*> AddButtonWithLabel(
not_null<Ui::VerticalLayout*> container,
LangKey text,
rpl::producer<QString> text,
rpl::producer<QString> label,
const style::InfoProfileButton &st,
const style::icon *leftIcon = nullptr,
@@ -94,13 +86,10 @@ void CreateRightLabel(
not_null<Button*> button,
rpl::producer<QString> label,
const style::InfoProfileButton &st,
LangKey buttonText);
rpl::producer<QString> buttonText);
void AddSubsectionTitle(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text);
void AddSubsectionTitle(
not_null<Ui::VerticalLayout*> conatiner,
LangKey text);
using MenuCallback = Fn<QAction*(
const QString &text,

View File

@@ -218,17 +218,17 @@ void SetupRows(
AddRow(
container,
Lang::Viewer(lng_settings_name_label),
tr::lng_settings_name_label(),
Info::Profile::NameValue(self),
lang(lng_profile_copy_fullname),
tr::lng_profile_copy_fullname(tr::now),
[=] { Ui::show(Box<EditNameBox>(self)); },
st::settingsInfoName);
AddRow(
container,
Lang::Viewer(lng_settings_phone_label),
tr::lng_settings_phone_label(),
Info::Profile::PhoneValue(self),
lang(lng_profile_copy_phone),
tr::lng_profile_copy_phone(tr::now),
[] { Ui::show(Box<ChangePhoneBox>()); },
st::settingsInfoPhone);
@@ -239,14 +239,14 @@ void SetupRows(
return username.text.isEmpty();
});
auto label = rpl::combine(
Lang::Viewer(lng_settings_username_label),
tr::lng_settings_username_label(),
std::move(empty)
) | rpl::map([](const QString &label, bool empty) {
return empty ? "t.me/username" : label;
});
auto value = rpl::combine(
std::move(username),
Lang::Viewer(lng_settings_username_add)
tr::lng_settings_username_add()
) | rpl::map([](const TextWithEntities &username, const QString &add) {
if (!username.text.isEmpty()) {
return username;
@@ -263,7 +263,7 @@ void SetupRows(
container,
std::move(label),
std::move(value),
lang(lng_context_copy_mention),
tr::lng_context_copy_mention(tr::now),
[=] { Ui::show(Box<UsernameBox>()); },
st::settingsInfoUsername);
@@ -392,7 +392,7 @@ BioManager SetupBio(
container->add(
object_ptr<Ui::FlatLabel>(
container,
Lang::Viewer(lng_settings_about_bio),
tr::lng_settings_about_bio(),
st::boxDividerLabel),
st::settingsBioLabelPadding);

View File

@@ -268,7 +268,7 @@ void IntroWidget::forceContentRepaint() {
void IntroWidget::createTopBar() {
_topBar.create(this, st::infoLayerTopBar);
_topBar->setTitle(Lang::Viewer(lng_menu_settings));
_topBar->setTitle(tr::lng_menu_settings());
auto close = _topBar->addButton(
base::make_unique_q<Ui::IconButton>(
_topBar,

View File

@@ -34,7 +34,7 @@ void SetupLanguageButton(
bool icon) {
const auto button = AddButtonWithLabel(
container,
lng_settings_language,
tr::lng_settings_language(),
rpl::single(Lang::Current().nativeName()),
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconLanguage : nullptr);
@@ -56,12 +56,12 @@ void SetupSections(
AddSkip(container);
const auto addSection = [&](
LangKey label,
rpl::producer<QString> label,
Type type,
const style::icon *icon) {
AddButton(
container,
label,
std::move(label),
st::settingsSectionButton,
icon
)->addClickHandler([=] { showOther(type); });
@@ -73,24 +73,24 @@ void SetupSections(
AddSkip(container);
} else {
addSection(
lng_settings_information,
tr::lng_settings_information(),
Type::Information,
&st::settingsIconInformation);
}
addSection(
lng_settings_section_notify,
tr::lng_settings_section_notify(),
Type::Notifications,
&st::settingsIconNotifications);
addSection(
lng_settings_section_privacy,
tr::lng_settings_section_privacy(),
Type::PrivacySecurity,
&st::settingsIconPrivacySecurity);
addSection(
lng_settings_section_chat_settings,
tr::lng_settings_section_chat_settings(),
Type::Chat,
&st::settingsIconChat);
addSection(
lng_settings_advanced,
tr::lng_settings_advanced(),
Type::Advanced,
&st::settingsIconGeneral);
@@ -116,7 +116,7 @@ void SetupInterfaceScale(
const auto switched = (cConfigScale() == kInterfaceScaleAuto);
const auto button = AddButton(
container,
lng_settings_default_scale,
tr::lng_settings_default_scale(),
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconInterfaceScale : nullptr
)->toggleOn(toggled->events_starting_with_copy(switched));
@@ -216,7 +216,7 @@ void OpenFaq() {
void SetupFaq(not_null<Ui::VerticalLayout*> container, bool icon) {
AddButton(
container,
lng_settings_faq,
tr::lng_settings_faq(),
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconFaq : nullptr
)->addClickHandler(OpenFaq);
@@ -231,7 +231,7 @@ void SetupHelp(not_null<Ui::VerticalLayout*> container) {
if (AuthSession::Exists()) {
const auto button = AddButton(
container,
lng_settings_ask_question,
tr::lng_settings_ask_question(),
st::settingsSectionButton);
button->addClickHandler([=] {
const auto ready = crl::guard(button, [](const MTPUser &data) {

View File

@@ -491,14 +491,14 @@ void SetupAdvancedNotifications(not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, lng_settings_notifications_position);
AddSubsectionTitle(container, tr::lng_settings_notifications_position());
AddSkip(container, st::settingsCheckboxesSkip);
const auto position = container->add(
object_ptr<NotificationsCount>(container));
AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, lng_settings_notifications_count);
AddSubsectionTitle(container, tr::lng_settings_notifications_count());
const auto count = container->add(
object_ptr<Ui::SettingsSlider>(container, st::settingsSlider),
@@ -515,7 +515,7 @@ void SetupAdvancedNotifications(not_null<Ui::VerticalLayout*> container) {
}
void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
AddSubsectionTitle(container, lng_settings_notify_title);
AddSubsectionTitle(container, tr::lng_settings_notify_title());
const auto checkbox = [&](LangKey label, bool checked) {
return object_ptr<Ui::Checkbox>(
@@ -552,7 +552,7 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, lng_settings_badge_title);
AddSubsectionTitle(container, tr::lng_settings_badge_title());
const auto muted = addCheckbox(
lng_settings_include_muted,
@@ -565,7 +565,7 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, lng_settings_events_title);
AddSubsectionTitle(container, tr::lng_settings_events_title());
const auto joined = addCheckbox(
lng_settings_events_joined,
@@ -615,7 +615,7 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, lng_settings_native_title);
AddSubsectionTitle(container, tr::lng_settings_native_title());
return addCheckbox(nativeKey, Global::NativeNotifications());
}();

View File

@@ -315,21 +315,21 @@ QString PhoneNumberPrivacyController::title() {
return lang(lng_edit_privacy_phone_number_title);
}
LangKey PhoneNumberPrivacyController::optionsTitleKey() {
return lng_edit_privacy_phone_number_header;
rpl::producer<QString> PhoneNumberPrivacyController::optionsTitleKey() {
return tr::lng_edit_privacy_phone_number_header();
}
rpl::producer<QString> PhoneNumberPrivacyController::warning() {
return Lang::Viewer(lng_edit_privacy_phone_number_warning);
return tr::lng_edit_privacy_phone_number_warning();
}
LangKey PhoneNumberPrivacyController::exceptionButtonTextKey(
rpl::producer<QString> PhoneNumberPrivacyController::exceptionButtonTextKey(
Exception exception) {
switch (exception) {
case Exception::Always:
return lng_edit_privacy_phone_number_always_empty;
return tr::lng_edit_privacy_phone_number_always_empty();
case Exception::Never:
return lng_edit_privacy_phone_number_never_empty;
return tr::lng_edit_privacy_phone_number_never_empty();
}
Unexpected("Invalid exception value.");
}
@@ -343,7 +343,7 @@ QString PhoneNumberPrivacyController::exceptionBoxTitle(Exception exception) {
}
rpl::producer<QString> PhoneNumberPrivacyController::exceptionsDescription() {
return Lang::Viewer(lng_edit_privacy_phone_number_exceptions);
return tr::lng_edit_privacy_phone_number_exceptions();
}
ApiWrap::Privacy::Key LastSeenPrivacyController::key() {
@@ -358,21 +358,21 @@ QString LastSeenPrivacyController::title() {
return lang(lng_edit_privacy_lastseen_title);
}
LangKey LastSeenPrivacyController::optionsTitleKey() {
return lng_edit_privacy_lastseen_header;
rpl::producer<QString> LastSeenPrivacyController::optionsTitleKey() {
return tr::lng_edit_privacy_lastseen_header();
}
rpl::producer<QString> LastSeenPrivacyController::warning() {
return Lang::Viewer(lng_edit_privacy_lastseen_warning);
return tr::lng_edit_privacy_lastseen_warning();
}
LangKey LastSeenPrivacyController::exceptionButtonTextKey(
rpl::producer<QString> LastSeenPrivacyController::exceptionButtonTextKey(
Exception exception) {
switch (exception) {
case Exception::Always:
return lng_edit_privacy_lastseen_always_empty;
return tr::lng_edit_privacy_lastseen_always_empty();
case Exception::Never:
return lng_edit_privacy_lastseen_never_empty;
return tr::lng_edit_privacy_lastseen_never_empty();
}
Unexpected("Invalid exception value.");
}
@@ -386,7 +386,7 @@ QString LastSeenPrivacyController::exceptionBoxTitle(Exception exception) {
}
rpl::producer<QString> LastSeenPrivacyController::exceptionsDescription() {
return Lang::Viewer(lng_edit_privacy_lastseen_exceptions);
return tr::lng_edit_privacy_lastseen_exceptions();
}
void LastSeenPrivacyController::confirmSave(bool someAreDisallowed, FnMut<void()> saveCallback) {
@@ -427,15 +427,15 @@ bool GroupsInvitePrivacyController::hasOption(Option option) {
return (option != Option::Nobody);
}
LangKey GroupsInvitePrivacyController::optionsTitleKey() {
return lng_edit_privacy_groups_header;
rpl::producer<QString> GroupsInvitePrivacyController::optionsTitleKey() {
return tr::lng_edit_privacy_groups_header();
}
LangKey GroupsInvitePrivacyController::exceptionButtonTextKey(
rpl::producer<QString> GroupsInvitePrivacyController::exceptionButtonTextKey(
Exception exception) {
switch (exception) {
case Exception::Always: return lng_edit_privacy_groups_always_empty;
case Exception::Never: return lng_edit_privacy_groups_never_empty;
case Exception::Always: return tr::lng_edit_privacy_groups_always_empty();
case Exception::Never: return tr::lng_edit_privacy_groups_never_empty();
}
Unexpected("Invalid exception value.");
}
@@ -450,7 +450,7 @@ QString GroupsInvitePrivacyController::exceptionBoxTitle(Exception exception) {
auto GroupsInvitePrivacyController::exceptionsDescription()
-> rpl::producer<QString> {
return Lang::Viewer(lng_edit_privacy_groups_exceptions);
return tr::lng_edit_privacy_groups_exceptions();
}
ApiWrap::Privacy::Key CallsPrivacyController::key() {
@@ -465,15 +465,15 @@ QString CallsPrivacyController::title() {
return lang(lng_edit_privacy_calls_title);
}
LangKey CallsPrivacyController::optionsTitleKey() {
return lng_edit_privacy_calls_header;
rpl::producer<QString> CallsPrivacyController::optionsTitleKey() {
return tr::lng_edit_privacy_calls_header();
}
LangKey CallsPrivacyController::exceptionButtonTextKey(
rpl::producer<QString> CallsPrivacyController::exceptionButtonTextKey(
Exception exception) {
switch (exception) {
case Exception::Always: return lng_edit_privacy_calls_always_empty;
case Exception::Never: return lng_edit_privacy_calls_never_empty;
case Exception::Always: return tr::lng_edit_privacy_calls_always_empty();
case Exception::Never: return tr::lng_edit_privacy_calls_never_empty();
}
Unexpected("Invalid exception value.");
}
@@ -487,7 +487,7 @@ QString CallsPrivacyController::exceptionBoxTitle(Exception exception) {
}
rpl::producer<QString> CallsPrivacyController::exceptionsDescription() {
return Lang::Viewer(lng_edit_privacy_calls_exceptions);
return tr::lng_edit_privacy_calls_exceptions();
}
object_ptr<Ui::RpWidget> CallsPrivacyController::setupBelowWidget(
@@ -497,10 +497,10 @@ object_ptr<Ui::RpWidget> CallsPrivacyController::setupBelowWidget(
AddDivider(content);
AddSkip(content);
AddSubsectionTitle(content, lng_settings_calls_peer_to_peer_title);
AddSubsectionTitle(content, tr::lng_settings_calls_peer_to_peer_title());
Settings::AddPrivacyButton(
content,
lng_settings_calls_peer_to_peer_button,
tr::lng_settings_calls_peer_to_peer_button(),
ApiWrap::Privacy::Key::CallsPeer2Peer,
[] { return std::make_unique<CallsPeer2PeerPrivacyController>(); });
AddSkip(content);
@@ -520,8 +520,8 @@ QString CallsPeer2PeerPrivacyController::title() {
return lang(lng_edit_privacy_calls_p2p_title);
}
LangKey CallsPeer2PeerPrivacyController::optionsTitleKey() {
return lng_edit_privacy_calls_p2p_header;
rpl::producer<QString> CallsPeer2PeerPrivacyController::optionsTitleKey() {
return tr::lng_edit_privacy_calls_p2p_header();
}
LangKey CallsPeer2PeerPrivacyController::optionLabelKey(
@@ -535,14 +535,14 @@ LangKey CallsPeer2PeerPrivacyController::optionLabelKey(
}
rpl::producer<QString> CallsPeer2PeerPrivacyController::warning() {
return Lang::Viewer(lng_settings_peer_to_peer_about);
return tr::lng_settings_peer_to_peer_about();
}
LangKey CallsPeer2PeerPrivacyController::exceptionButtonTextKey(
rpl::producer<QString> CallsPeer2PeerPrivacyController::exceptionButtonTextKey(
Exception exception) {
switch (exception) {
case Exception::Always: return lng_edit_privacy_calls_p2p_always_empty;
case Exception::Never: return lng_edit_privacy_calls_p2p_never_empty;
case Exception::Always: return tr::lng_edit_privacy_calls_p2p_always_empty();
case Exception::Never: return tr::lng_edit_privacy_calls_p2p_never_empty();
}
Unexpected("Invalid exception value.");
}
@@ -556,7 +556,7 @@ QString CallsPeer2PeerPrivacyController::exceptionBoxTitle(Exception exception)
}
rpl::producer<QString> CallsPeer2PeerPrivacyController::exceptionsDescription() {
return Lang::Viewer(lng_edit_privacy_calls_p2p_exceptions);
return tr::lng_edit_privacy_calls_p2p_exceptions();
}
ApiWrap::Privacy::Key ForwardsPrivacyController::key() {
@@ -571,19 +571,19 @@ QString ForwardsPrivacyController::title() {
return lang(lng_edit_privacy_forwards_title);
}
LangKey ForwardsPrivacyController::optionsTitleKey() {
return lng_edit_privacy_forwards_header;
rpl::producer<QString> ForwardsPrivacyController::optionsTitleKey() {
return tr::lng_edit_privacy_forwards_header();
}
rpl::producer<QString> ForwardsPrivacyController::warning() {
return Lang::Viewer(lng_edit_privacy_forwards_warning);
return tr::lng_edit_privacy_forwards_warning();
}
LangKey ForwardsPrivacyController::exceptionButtonTextKey(
rpl::producer<QString> ForwardsPrivacyController::exceptionButtonTextKey(
Exception exception) {
switch (exception) {
case Exception::Always: return lng_edit_privacy_forwards_always_empty;
case Exception::Never: return lng_edit_privacy_forwards_never_empty;
case Exception::Always: return tr::lng_edit_privacy_forwards_always_empty();
case Exception::Never: return tr::lng_edit_privacy_forwards_never_empty();
}
Unexpected("Invalid exception value.");
}
@@ -598,7 +598,7 @@ QString ForwardsPrivacyController::exceptionBoxTitle(Exception exception) {
auto ForwardsPrivacyController::exceptionsDescription()
-> rpl::producer<QString> {
return Lang::Viewer(lng_edit_privacy_forwards_exceptions);
return tr::lng_edit_privacy_forwards_exceptions();
}
object_ptr<Ui::RpWidget> ForwardsPrivacyController::setupAboveWidget(
@@ -767,15 +767,15 @@ bool ProfilePhotoPrivacyController::hasOption(Option option) {
return (option != Option::Nobody);
}
LangKey ProfilePhotoPrivacyController::optionsTitleKey() {
return lng_edit_privacy_profile_photo_header;
rpl::producer<QString> ProfilePhotoPrivacyController::optionsTitleKey() {
return tr::lng_edit_privacy_profile_photo_header();
}
LangKey ProfilePhotoPrivacyController::exceptionButtonTextKey(
rpl::producer<QString> ProfilePhotoPrivacyController::exceptionButtonTextKey(
Exception exception) {
switch (exception) {
case Exception::Always: return lng_edit_privacy_profile_photo_always_empty;
case Exception::Never: return lng_edit_privacy_profile_photo_never_empty;
case Exception::Always: return tr::lng_edit_privacy_profile_photo_always_empty();
case Exception::Never: return tr::lng_edit_privacy_profile_photo_never_empty();
}
Unexpected("Invalid exception value.");
}
@@ -790,7 +790,7 @@ QString ProfilePhotoPrivacyController::exceptionBoxTitle(Exception exception) {
auto ProfilePhotoPrivacyController::exceptionsDescription()
-> rpl::producer<QString> {
return Lang::Viewer(lng_edit_privacy_profile_photo_exceptions);
return tr::lng_edit_privacy_profile_photo_exceptions();
}
} // namespace Settings

View File

@@ -46,9 +46,10 @@ public:
MTPInputPrivacyKey apiKey() override;
QString title() override;
LangKey optionsTitleKey() override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
LangKey exceptionButtonTextKey(Exception exception) override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
@@ -63,13 +64,16 @@ public:
MTPInputPrivacyKey apiKey() override;
QString title() override;
LangKey optionsTitleKey() override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
LangKey exceptionButtonTextKey(Exception exception) override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
void confirmSave(bool someAreDisallowed, FnMut<void()> saveCallback) override;
void confirmSave(
bool someAreDisallowed,
FnMut<void()> saveCallback) override;
};
@@ -83,8 +87,9 @@ public:
QString title() override;
bool hasOption(Option option) override;
LangKey optionsTitleKey() override;
LangKey exceptionButtonTextKey(Exception exception) override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
@@ -99,8 +104,9 @@ public:
MTPInputPrivacyKey apiKey() override;
QString title() override;
LangKey optionsTitleKey() override;
LangKey exceptionButtonTextKey(Exception exception) override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
@@ -118,10 +124,11 @@ public:
MTPInputPrivacyKey apiKey() override;
QString title() override;
LangKey optionsTitleKey() override;
rpl::producer<QString> optionsTitleKey() override;
LangKey optionLabelKey(EditPrivacyBox::Option option) override;
rpl::producer<QString> warning() override;
LangKey exceptionButtonTextKey(Exception exception) override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
@@ -138,9 +145,10 @@ public:
MTPInputPrivacyKey apiKey() override;
QString title() override;
LangKey optionsTitleKey() override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
LangKey exceptionButtonTextKey(Exception exception) override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
@@ -170,8 +178,9 @@ public:
QString title() override;
bool hasOption(Option option) override;
LangKey optionsTitleKey() override;
LangKey exceptionButtonTextKey(Exception exception) override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;

View File

@@ -106,7 +106,7 @@ rpl::producer<int> BlockedUsersCount() {
void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsPrivacySkip);
AddSubsectionTitle(container, lng_settings_privacy_title);
AddSubsectionTitle(container, tr::lng_settings_privacy_title());
auto count = BlockedUsersCount(
) | rpl::map([](int count) {
@@ -114,7 +114,7 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
});
AddButtonWithLabel(
container,
lng_settings_blocked_users,
tr::lng_settings_blocked_users(),
std::move(count),
st::settingsButton
)->addClickHandler([] {
@@ -132,38 +132,39 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
});
using Key = Privacy::Key;
const auto add = [&](LangKey label, Key key, auto controller) {
AddPrivacyButton(container, label, key, controller);
const auto add = [&](
rpl::producer<QString> label,
Key key,
auto controller) {
AddPrivacyButton(container, std::move(label), key, controller);
};
add(
lng_settings_phone_number_privacy,
tr::lng_settings_phone_number_privacy(),
Key::PhoneNumber,
[] { return std::make_unique<PhoneNumberPrivacyController>(); });
add(
lng_settings_last_seen,
tr::lng_settings_last_seen(),
Key::LastSeen,
[] { return std::make_unique<LastSeenPrivacyController>(); });
add(
lng_settings_forwards_privacy,
tr::lng_settings_forwards_privacy(),
Key::Forwards,
[] { return std::make_unique<ForwardsPrivacyController>(); });
add(
lng_settings_profile_photo_privacy,
tr::lng_settings_profile_photo_privacy(),
Key::ProfilePhoto,
[] { return std::make_unique<ProfilePhotoPrivacyController>(); });
add(
lng_settings_calls,
tr::lng_settings_calls(),
Key::Calls,
[] { return std::make_unique<CallsPrivacyController>(); });
add(
lng_settings_groups_invite,
tr::lng_settings_groups_invite(),
Key::Invites,
[] { return std::make_unique<GroupsInvitePrivacyController>(); });
AddSkip(container, st::settingsPrivacySecurityPadding);
AddDividerText(
container,
Lang::Viewer(lng_settings_group_privacy_about));
AddDividerText(container, tr::lng_settings_group_privacy_about());
}
not_null<Ui::SlideWrap<Ui::PlainShadow>*> AddSeparator(
@@ -177,15 +178,15 @@ not_null<Ui::SlideWrap<Ui::PlainShadow>*> AddSeparator(
void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
AddSkip(container);
AddSubsectionTitle(container, lng_settings_passcode_title);
AddSubsectionTitle(container, tr::lng_settings_passcode_title());
auto has = PasscodeChanges(
) | rpl::map([] {
return Global::LocalPasscode();
});
auto text = rpl::combine(
Lang::Viewer(lng_passcode_change),
Lang::Viewer(lng_passcode_turn_on),
tr::lng_passcode_change(),
tr::lng_passcode_turn_on(),
base::duplicate(has),
[](const QString &change, const QString &create, bool has) {
return has ? change : create;
@@ -207,15 +208,15 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
inner->add(
object_ptr<Button>(
inner,
Lang::Viewer(lng_settings_passcode_disable),
tr::lng_settings_passcode_disable(),
st::settingsButton)
)->addClickHandler([] {
Ui::show(Box<PasscodeBox>(true));
});
const auto label = Platform::LastUserInputTimeSupported()
? lng_passcode_autolock_away
: lng_passcode_autolock_inactive;
? tr::lng_passcode_autolock_away
: tr::lng_passcode_autolock_inactive;
auto value = PasscodeChanges(
) | rpl::map([] {
const auto autolock = Global::AutoLock();
@@ -226,7 +227,7 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
AddButtonWithLabel(
inner,
label,
label(),
std::move(value),
st::settingsButton
)->addClickHandler([] {
@@ -244,7 +245,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_settings_password_title);
AddSubsectionTitle(container, tr::lng_settings_password_title());
auto has = rpl::single(
false
@@ -300,8 +301,8 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
}, label->lifetime());
auto text = rpl::combine(
Lang::Viewer(lng_cloud_password_set),
Lang::Viewer(lng_cloud_password_edit),
tr::lng_cloud_password_set(),
tr::lng_cloud_password_edit(),
base::duplicate(has)
) | rpl::map([](const QString &set, const QString &edit, bool has) {
return has ? edit : set;
@@ -331,7 +332,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
container,
object_ptr<Button>(
container,
Lang::Viewer(lng_cloud_password_confirm),
tr::lng_cloud_password_confirm(),
st::settingsButton)));
confirm->toggleOn(rpl::single(
false
@@ -372,7 +373,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
container,
object_ptr<Button>(
container,
Lang::Viewer(lng_settings_password_disable),
tr::lng_settings_password_disable(),
st::settingsButton)));
disable->toggleOn(rpl::combine(
rpl::duplicate(has),
@@ -385,7 +386,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
container,
object_ptr<Button>(
container,
Lang::Viewer(lng_settings_password_abort),
tr::lng_settings_password_abort(),
st::settingsAttentionButton)));
abort->toggleOn(rpl::combine(
rpl::duplicate(has),
@@ -412,7 +413,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
void SetupSelfDestruction(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_settings_destroy_title);
AddSubsectionTitle(container, tr::lng_settings_destroy_title());
Auth().api().reloadSelfDestruct();
const auto label = [] {
@@ -424,7 +425,7 @@ void SetupSelfDestruction(not_null<Ui::VerticalLayout*> container) {
AddButtonWithLabel(
container,
lng_settings_destroy_if,
tr::lng_settings_destroy_if(),
label(),
st::settingsButton
)->addClickHandler([] {
@@ -436,19 +437,17 @@ void SetupSelfDestruction(not_null<Ui::VerticalLayout*> container) {
void SetupSessionsList(not_null<Ui::VerticalLayout*> container) {
AddSkip(container);
AddSubsectionTitle(container, lng_settings_sessions_title);
AddSubsectionTitle(container, tr::lng_settings_sessions_title());
AddButton(
container,
lng_settings_show_sessions,
tr::lng_settings_show_sessions(),
st::settingsButton
)->addClickHandler([] {
Ui::show(Box<SessionsBox>());
});
AddSkip(container, st::settingsPrivacySecurityPadding);
AddDividerText(
container,
Lang::Viewer(lng_settings_sessions_about));
AddDividerText(container, tr::lng_settings_sessions_about());
}
} // namespace
@@ -541,13 +540,13 @@ object_ptr<BoxContent> CloudPasswordAppOutdatedBox() {
void AddPrivacyButton(
not_null<Ui::VerticalLayout*> container,
LangKey label,
rpl::producer<QString> label,
Privacy::Key key,
Fn<std::unique_ptr<EditPrivacyController>()> controller) {
const auto shower = Ui::CreateChild<rpl::lifetime>(container.get());
AddButtonWithLabel(
container,
label,
std::move(label),
PrivacyString(key),
st::settingsButton
)->addClickHandler([=] {

View File

@@ -23,7 +23,7 @@ object_ptr<BoxContent> CloudPasswordAppOutdatedBox();
void AddPrivacyButton(
not_null<Ui::VerticalLayout*> container,
LangKey label,
rpl::producer<QString> label,
ApiWrap::Privacy::Key key,
Fn<std::unique_ptr<EditPrivacyController>()> controller);