mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-28 03:20:57 +00:00
Separate some lang phrases.
This commit is contained in:
parent
4960e08a24
commit
123523ef62
@ -601,6 +601,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_edit_privacy_calls_p2p_always_title" = "Always allow";
|
||||
"lng_edit_privacy_calls_p2p_never_title" = "Never allow";
|
||||
|
||||
"lng_edit_privacy_calls_p2p_everyone" = "Everybody";
|
||||
"lng_edit_privacy_calls_p2p_contacts" = "My contacts";
|
||||
"lng_edit_privacy_calls_p2p_nobody" = "Nobody";
|
||||
|
||||
"lng_self_destruct_title" = "Account self-destruction";
|
||||
"lng_self_destruct_description" = "If you don't come online at least once within this period, your account will be deleted along with all groups, messages and contacts.";
|
||||
"lng_self_destruct_months#one" = "{count} month";
|
||||
|
@ -83,6 +83,15 @@ std::unique_ptr<PrivacyExceptionsBoxController::Row> PrivacyExceptionsBoxControl
|
||||
|
||||
} // namespace
|
||||
|
||||
LangKey EditPrivacyBox::Controller::optionLabelKey(Option option) {
|
||||
switch (option) {
|
||||
case Option::Everyone: return lng_edit_privacy_everyone;
|
||||
case Option::Contacts: return lng_edit_privacy_contacts;
|
||||
case Option::Nobody: return lng_edit_privacy_nobody;
|
||||
}
|
||||
Unexpected("Option value in optionsLabelKey.");
|
||||
}
|
||||
|
||||
EditPrivacyBox::EditPrivacyBox(
|
||||
QWidget*,
|
||||
std::unique_ptr<Controller> controller,
|
||||
@ -182,29 +191,21 @@ bool EditPrivacyBox::showExceptionLink(Exception exception) const {
|
||||
Unexpected("Invalid exception value.");
|
||||
}
|
||||
|
||||
Ui::Radioenum<EditPrivacyBox::Option> *EditPrivacyBox::AddOption(
|
||||
Ui::Radioenum<EditPrivacyBox::Option> *EditPrivacyBox::addOption(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const std::shared_ptr<Ui::RadioenumGroup<Option>> &group,
|
||||
Option option) {
|
||||
const auto label = [&] {
|
||||
switch (option) {
|
||||
case Option::Everyone: return lng_edit_privacy_everyone;
|
||||
case Option::Contacts: return lng_edit_privacy_contacts;
|
||||
case Option::Nobody: return lng_edit_privacy_nobody;
|
||||
}
|
||||
Unexpected("Option value in EditPrivacyBox::AddOption.");
|
||||
}();
|
||||
return container->add(
|
||||
object_ptr<Ui::Radioenum<Option>>(
|
||||
container,
|
||||
group,
|
||||
option,
|
||||
lang(label),
|
||||
lang(_controller->optionLabelKey(option)),
|
||||
st::settingsSendType),
|
||||
st::settingsSendTypePadding);
|
||||
}
|
||||
|
||||
Ui::FlatLabel *EditPrivacyBox::AddLabel(
|
||||
Ui::FlatLabel *EditPrivacyBox::addLabel(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text) {
|
||||
const auto wrap = container->add(
|
||||
@ -244,9 +245,9 @@ void EditPrivacyBox::setupContent() {
|
||||
toggle->fire({});
|
||||
});
|
||||
|
||||
const auto addOption = [&](Option option) {
|
||||
const auto addOptionRow = [&](Option option) {
|
||||
return (_controller->hasOption(option) || (_value.option == option))
|
||||
? AddOption(content, group, option)
|
||||
? addOption(content, group, option)
|
||||
: nullptr;
|
||||
};
|
||||
const auto addExceptionLink = [=](Exception exception) {
|
||||
@ -286,10 +287,10 @@ void EditPrivacyBox::setupContent() {
|
||||
};
|
||||
|
||||
AddSubsectionTitle(content, _controller->optionsTitleKey());
|
||||
addOption(Option::Everyone);
|
||||
addOption(Option::Contacts);
|
||||
addOption(Option::Nobody);
|
||||
AddLabel(content, _controller->warning());
|
||||
addOptionRow(Option::Everyone);
|
||||
addOptionRow(Option::Contacts);
|
||||
addOptionRow(Option::Nobody);
|
||||
addLabel(content, _controller->warning());
|
||||
AddSkip(content);
|
||||
|
||||
AddDivider(content);
|
||||
@ -297,7 +298,7 @@ void EditPrivacyBox::setupContent() {
|
||||
AddSubsectionTitle(content, lng_edit_privacy_exceptions);
|
||||
const auto always = addExceptionLink(Exception::Always);
|
||||
const auto never = addExceptionLink(Exception::Never);
|
||||
AddLabel(content, _controller->exceptionsDescription());
|
||||
addLabel(content, _controller->exceptionsDescription());
|
||||
AddSkip(content);
|
||||
|
||||
addButton(langFactory(lng_settings_save), [=] {
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
virtual LangKey optionsTitleKey() = 0;
|
||||
virtual LangKey optionLabelKey(Option option);
|
||||
virtual rpl::producer<QString> warning() {
|
||||
return rpl::never<QString>();
|
||||
}
|
||||
@ -82,14 +83,6 @@ public:
|
||||
std::unique_ptr<Controller> controller,
|
||||
const Value &value);
|
||||
|
||||
static Ui::Radioenum<Option> *AddOption(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const std::shared_ptr<Ui::RadioenumGroup<Option>> &group,
|
||||
Option option);
|
||||
static Ui::FlatLabel *AddLabel(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
@ -98,6 +91,14 @@ private:
|
||||
void setupContent();
|
||||
QVector<MTPInputPrivacyRule> collectResult();
|
||||
|
||||
Ui::Radioenum<Option> *addOption(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const std::shared_ptr<Ui::RadioenumGroup<Option>> &group,
|
||||
Option option);
|
||||
Ui::FlatLabel *addLabel(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text);
|
||||
|
||||
void editExceptionUsers(Exception exception, Fn<void()> done);
|
||||
std::vector<not_null<UserData*>> &exceptionUsers(Exception exception);
|
||||
|
||||
|
@ -384,6 +384,16 @@ LangKey CallsPeer2PeerPrivacyController::optionsTitleKey() {
|
||||
return lng_edit_privacy_calls_p2p_header;
|
||||
}
|
||||
|
||||
LangKey CallsPeer2PeerPrivacyController::optionLabelKey(
|
||||
EditPrivacyBox::Option option) {
|
||||
switch (option) {
|
||||
case Option::Everyone: return lng_edit_privacy_calls_p2p_everyone;
|
||||
case Option::Contacts: return lng_edit_privacy_calls_p2p_contacts;
|
||||
case Option::Nobody: return lng_edit_privacy_calls_p2p_nobody;
|
||||
}
|
||||
Unexpected("Option value in optionsLabelKey.");
|
||||
}
|
||||
|
||||
rpl::producer<QString> CallsPeer2PeerPrivacyController::warning() {
|
||||
return Lang::Viewer(lng_settings_peer_to_peer_about);
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
|
||||
QString title() override;
|
||||
LangKey optionsTitleKey() override;
|
||||
LangKey optionLabelKey(EditPrivacyBox::Option option) override;
|
||||
rpl::producer<QString> warning() override;
|
||||
LangKey exceptionButtonTextKey(Exception exception) override;
|
||||
QString exceptionBoxTitle(Exception exception) override;
|
||||
|
@ -44,17 +44,33 @@ rpl::producer<> PasscodeChanges() {
|
||||
));
|
||||
}
|
||||
|
||||
QString PrivacyBase(ApiWrap::Privacy::Option option) {
|
||||
const auto key = [&] {
|
||||
QString PrivacyBase(
|
||||
ApiWrap::Privacy::Key key,
|
||||
ApiWrap::Privacy::Option option) {
|
||||
const auto phrase = [&] {
|
||||
using Key = ApiWrap::Privacy::Key;
|
||||
using Option = ApiWrap::Privacy::Option;
|
||||
switch (option) {
|
||||
case Option::Everyone: return lng_edit_privacy_everyone;
|
||||
case Option::Contacts: return lng_edit_privacy_contacts;
|
||||
case Option::Nobody: return lng_edit_privacy_nobody;
|
||||
switch (key) {
|
||||
case Key::CallsPeer2Peer:
|
||||
switch (option) {
|
||||
case Option::Everyone:
|
||||
return lng_edit_privacy_calls_p2p_everyone;
|
||||
case Option::Contacts:
|
||||
return lng_edit_privacy_calls_p2p_contacts;
|
||||
case Option::Nobody:
|
||||
return lng_edit_privacy_calls_p2p_nobody;
|
||||
}
|
||||
Unexpected("Value in Privacy::Option.");
|
||||
default:
|
||||
switch (option) {
|
||||
case Option::Everyone: return lng_edit_privacy_everyone;
|
||||
case Option::Contacts: return lng_edit_privacy_contacts;
|
||||
case Option::Nobody: return lng_edit_privacy_nobody;
|
||||
}
|
||||
Unexpected("Value in Privacy::Option.");
|
||||
}
|
||||
Unexpected("Value in Privacy::Option.");
|
||||
}();
|
||||
return lang(key);
|
||||
return lang(phrase);
|
||||
}
|
||||
|
||||
void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
|
||||
@ -84,7 +100,7 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
|
||||
Auth().api().reloadPrivacy(key);
|
||||
return Auth().api().privacyValue(
|
||||
key
|
||||
) | rpl::map([](const Privacy &value) {
|
||||
) | rpl::map([=](const Privacy &value) {
|
||||
auto add = QStringList();
|
||||
if (const auto never = value.never.size()) {
|
||||
add.push_back("-" + QString::number(never));
|
||||
@ -93,9 +109,10 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
|
||||
add.push_back("+" + QString::number(always));
|
||||
}
|
||||
if (!add.isEmpty()) {
|
||||
return PrivacyBase(value.option) + " (" + add.join(", ") + ")";
|
||||
return PrivacyBase(key, value.option)
|
||||
+ " (" + add.join(", ") + ")";
|
||||
} else {
|
||||
return PrivacyBase(value.option);
|
||||
return PrivacyBase(key, value.option);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user