mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Use tr:: instead of Lang::Viewer.
This commit is contained in:
@@ -63,14 +63,14 @@ void AutoDownloadBox::setupContent() {
|
||||
};
|
||||
|
||||
const auto values = Ui::CreateChild<base::flat_map<Type, int>>(content);
|
||||
const auto add = [&](Type type, LangKey label) {
|
||||
const auto add = [&](Type type, rpl::producer<QString> label) {
|
||||
if (ranges::find(kHidden, type) != end(kHidden)) {
|
||||
return;
|
||||
}
|
||||
const auto value = settings->bytesLimit(_source, type);
|
||||
AddButton(
|
||||
content,
|
||||
label,
|
||||
std::move(label),
|
||||
st::settingsButton
|
||||
)->toggleOn(
|
||||
rpl::single(value > 0)
|
||||
@@ -80,13 +80,13 @@ void AutoDownloadBox::setupContent() {
|
||||
}, content->lifetime());
|
||||
values->emplace(type, value);
|
||||
};
|
||||
add(Type::Photo, lng_media_photo_title);
|
||||
add(Type::VoiceMessage, lng_media_audio_title);
|
||||
add(Type::VideoMessage, lng_media_video_messages_title);
|
||||
add(Type::Video, lng_media_video_title);
|
||||
add(Type::File, lng_media_file_title);
|
||||
add(Type::Music, lng_media_music_title);
|
||||
add(Type::GIF, lng_media_animation_title);
|
||||
add(Type::Photo, tr::lng_media_photo_title());
|
||||
add(Type::VoiceMessage, tr::lng_media_audio_title());
|
||||
add(Type::VideoMessage, tr::lng_media_video_messages_title());
|
||||
add(Type::Video, tr::lng_media_video_title());
|
||||
add(Type::File, tr::lng_media_file_title());
|
||||
add(Type::Music, tr::lng_media_music_title());
|
||||
add(Type::GIF, tr::lng_media_animation_title());
|
||||
|
||||
const auto limits = Ui::CreateChild<rpl::event_stream<int>>(content);
|
||||
using Pair = base::flat_map<Type, int>::value_type;
|
||||
@@ -98,7 +98,7 @@ void AutoDownloadBox::setupContent() {
|
||||
const auto limit = Ui::CreateChild<int>(content, initialLimit);
|
||||
AddButtonWithLabel(
|
||||
content,
|
||||
lng_media_size_limit,
|
||||
tr::lng_media_size_limit(),
|
||||
limits->events_starting_with_copy(
|
||||
initialLimit
|
||||
) | rpl::map([](int value) {
|
||||
|
@@ -350,9 +350,7 @@ void ChangePhoneBox::prepare() {
|
||||
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
this,
|
||||
Lang::Viewer(
|
||||
lng_change_phone_about
|
||||
) | Ui::Text::ToRichLangValue(),
|
||||
tr::lng_change_phone_about(Ui::Text::RichLangValue),
|
||||
st::changePhoneDescription);
|
||||
label->moveToLeft((st::boxWideWidth - label->width()) / 2, st::changePhoneDescriptionTop);
|
||||
|
||||
|
@@ -597,7 +597,7 @@ not_null<Ui::InputField*> CreatePollBox::setupQuestion(
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
using namespace Settings;
|
||||
|
||||
AddSubsectionTitle(container, lng_polls_create_question);
|
||||
AddSubsectionTitle(container, tr::lng_polls_create_question());
|
||||
const auto question = container->add(
|
||||
object_ptr<Ui::InputField>(
|
||||
container,
|
||||
@@ -645,7 +645,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
const auto question = setupQuestion(container);
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
AddSubsectionTitle(container, lng_polls_create_options);
|
||||
AddSubsectionTitle(container, tr::lng_polls_create_options());
|
||||
const auto options = lifetime().make_state<Options>(
|
||||
getDelegate()->outerContainer(),
|
||||
container);
|
||||
|
@@ -311,13 +311,13 @@ void EditPrivacyBox::setupContent() {
|
||||
content,
|
||||
object_ptr<Button>(
|
||||
content,
|
||||
Lang::Viewer(text),
|
||||
rpl::duplicate(text),
|
||||
st::settingsButton)));
|
||||
CreateRightLabel(
|
||||
button->entity(),
|
||||
std::move(label),
|
||||
st::settingsButton,
|
||||
text);
|
||||
std::move(text));
|
||||
button->toggleOn(rpl::duplicate(
|
||||
optionValue
|
||||
) | rpl::map([=] {
|
||||
@@ -344,7 +344,7 @@ void EditPrivacyBox::setupContent() {
|
||||
|
||||
AddDivider(content);
|
||||
AddSkip(content);
|
||||
AddSubsectionTitle(content, lng_edit_privacy_exceptions);
|
||||
AddSubsectionTitle(content, tr::lng_edit_privacy_exceptions());
|
||||
const auto always = addExceptionLink(Exception::Always);
|
||||
const auto never = addExceptionLink(Exception::Never);
|
||||
addLabel(content, _controller->exceptionsDescription());
|
||||
|
@@ -43,12 +43,12 @@ public:
|
||||
[[nodiscard]] virtual bool hasOption(Option option) {
|
||||
return true;
|
||||
}
|
||||
[[nodiscard]] virtual LangKey optionsTitleKey() = 0;
|
||||
[[nodiscard]] virtual rpl::producer<QString> optionsTitleKey() = 0;
|
||||
[[nodiscard]] virtual LangKey optionLabelKey(Option option);
|
||||
[[nodiscard]] virtual rpl::producer<QString> warning() {
|
||||
return rpl::never<QString>();
|
||||
}
|
||||
[[nodiscard]] virtual LangKey exceptionButtonTextKey(
|
||||
[[nodiscard]] virtual rpl::producer<QString> exceptionButtonTextKey(
|
||||
Exception exception) = 0;
|
||||
[[nodiscard]] virtual QString exceptionBoxTitle(
|
||||
Exception exception) = 0;
|
||||
|
@@ -99,7 +99,7 @@ void Controller::setupCover() {
|
||||
_user,
|
||||
_window->sessionController(),
|
||||
(_phone.isEmpty()
|
||||
? Lang::Viewer(lng_contact_mobile_hidden)
|
||||
? tr::lng_contact_mobile_hidden()
|
||||
: rpl::single(App::formatPhone(_phone)))),
|
||||
style::margins())->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
|
@@ -248,10 +248,9 @@ object_ptr<Ui::RpWidget> SetupUnlink(
|
||||
Fn<void(ChannelData*)> callback) {
|
||||
auto result = object_ptr<Info::Profile::Button>(
|
||||
parent,
|
||||
Lang::Viewer(channel->isBroadcast()
|
||||
? lng_manage_discussion_group_unlink
|
||||
: lng_manage_linked_channel_unlink
|
||||
) | Ui::Text::ToUpper(),
|
||||
(channel->isBroadcast()
|
||||
? tr::lng_manage_discussion_group_unlink
|
||||
: tr::lng_manage_linked_channel_unlink)() | Ui::Text::ToUpper(),
|
||||
st::infoUnlinkChatButton);
|
||||
result->addClickHandler([=] {
|
||||
callback(nullptr);
|
||||
|
@@ -320,7 +320,7 @@ void EditAdminBox::prepare() {
|
||||
: channel->anyoneCanAddMembers();
|
||||
auto [checkboxes, getChecked, changes] = CreateEditAdminRights(
|
||||
this,
|
||||
lng_rights_edit_admin_header,
|
||||
tr::lng_rights_edit_admin_header(),
|
||||
prepareFlags,
|
||||
disabledMessages,
|
||||
isGroup,
|
||||
@@ -401,9 +401,9 @@ not_null<Ui::SlideWrap<Ui::RpWidget>*> EditAdminBox::setupTransferButton(
|
||||
addDivider();
|
||||
container->add(EditPeerInfoBox::CreateButton(
|
||||
this,
|
||||
Lang::Viewer(isGroup
|
||||
? lng_rights_transfer_group
|
||||
: lng_rights_transfer_channel),
|
||||
(isGroup
|
||||
? tr::lng_rights_transfer_group
|
||||
: tr::lng_rights_transfer_channel)(),
|
||||
rpl::single(QString()),
|
||||
[=] { transferOwnership(); },
|
||||
st::peerPermissionsButton));
|
||||
@@ -620,7 +620,7 @@ void EditRestrictedBox::prepare() {
|
||||
|
||||
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
||||
this,
|
||||
lng_rights_user_restrictions_header,
|
||||
tr::lng_rights_user_restrictions_header(),
|
||||
prepareFlags,
|
||||
disabledMessages);
|
||||
addControl(std::move(checkboxes), QMargins());
|
||||
|
@@ -26,8 +26,8 @@ namespace {
|
||||
void AddRadioButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
HistoryVisibility value,
|
||||
LangKey groupTextKey,
|
||||
LangKey groupAboutKey,
|
||||
const QString &groupText,
|
||||
rpl::producer<QString> groupAbout,
|
||||
std::shared_ptr<Ui::RadioenumGroup<HistoryVisibility>> historyVisibility) {
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
@@ -36,13 +36,13 @@ void AddRadioButton(
|
||||
container,
|
||||
historyVisibility,
|
||||
value,
|
||||
lang(groupTextKey),
|
||||
groupText,
|
||||
st::defaultBoxCheckbox));
|
||||
container->add(object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>(
|
||||
container,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(groupAboutKey),
|
||||
std::move(groupAbout),
|
||||
st::editPeerPrivacyLabel),
|
||||
st::editPeerPreHistoryLabelMargins));
|
||||
}
|
||||
@@ -80,16 +80,16 @@ void FillContent(
|
||||
AddRadioButton(
|
||||
container,
|
||||
HistoryVisibility::Visible,
|
||||
lng_manage_history_visibility_shown,
|
||||
lng_manage_history_visibility_shown_about,
|
||||
tr::lng_manage_history_visibility_shown(tr::now),
|
||||
tr::lng_manage_history_visibility_shown_about(),
|
||||
historyVisibility);
|
||||
AddRadioButton(
|
||||
container,
|
||||
HistoryVisibility::Hidden,
|
||||
lng_manage_history_visibility_hidden,
|
||||
tr::lng_manage_history_visibility_hidden(tr::now),
|
||||
(peer->isChat()
|
||||
? lng_manage_history_visibility_hidden_legacy
|
||||
: lng_manage_history_visibility_hidden_about),
|
||||
? tr::lng_manage_history_visibility_hidden_legacy
|
||||
: tr::lng_manage_history_visibility_hidden_about)(),
|
||||
historyVisibility);
|
||||
}
|
||||
|
||||
|
@@ -193,7 +193,8 @@ private:
|
||||
|
||||
bool canEditInformation() const;
|
||||
void refreshHistoryVisibility(anim::type animated = anim::type::normal);
|
||||
void showEditPeerTypeBox(std::optional<LangKey> error = std::nullopt);
|
||||
void showEditPeerTypeBox(
|
||||
std::optional<rpl::producer<QString>> error = {});
|
||||
void showEditLinkedChatBox();
|
||||
void fillPrivacyTypeButton();
|
||||
void fillLinkedChatButton();
|
||||
@@ -449,7 +450,7 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
|
||||
|
||||
container->add(object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(lng_group_stickers),
|
||||
tr::lng_group_stickers(),
|
||||
st::editPeerSectionLabel));
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
@@ -457,7 +458,7 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
|
||||
|
||||
container->add(object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(lng_group_stickers_description),
|
||||
tr::lng_group_stickers_description(),
|
||||
st::editPeerPrivacyLabel));
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
@@ -465,7 +466,7 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
|
||||
|
||||
container->add(object_ptr<Ui::LinkButton>(
|
||||
_wrap,
|
||||
lang(lng_group_stickers_add),
|
||||
tr::lng_group_stickers_add(tr::now),
|
||||
st::editPeerInviteLinkButton)
|
||||
)->addClickHandler([=] {
|
||||
Ui::show(Box<StickersBox>(channel), LayerOption::KeepOther);
|
||||
@@ -493,7 +494,8 @@ void Controller::refreshHistoryVisibility(anim::type animated) {
|
||||
animated);
|
||||
};
|
||||
|
||||
void Controller::showEditPeerTypeBox(std::optional<LangKey> error) {
|
||||
void Controller::showEditPeerTypeBox(
|
||||
std::optional<rpl::producer<QString>> error) {
|
||||
const auto boxCallback = crl::guard(this, [=](
|
||||
Privacy checked, QString publicLink) {
|
||||
_privacyTypeUpdates.fire(std::move(checked));
|
||||
@@ -575,19 +577,19 @@ void Controller::fillPrivacyTypeButton() {
|
||||
const auto isGroup = (_peer->isChat() || _peer->isMegagroup());
|
||||
AddButtonWithText(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(isGroup
|
||||
? lng_manage_peer_group_type
|
||||
: lng_manage_peer_channel_type),
|
||||
(isGroup
|
||||
? tr::lng_manage_peer_group_type
|
||||
: tr::lng_manage_peer_channel_type)(),
|
||||
_privacyTypeUpdates.events(
|
||||
) | rpl::map([=](Privacy flag) {
|
||||
return lang(Privacy::Public == flag
|
||||
return (Privacy::Public == flag
|
||||
? (isGroup
|
||||
? lng_manage_public_group_title
|
||||
: lng_manage_public_peer_title)
|
||||
? tr::lng_manage_public_group_title
|
||||
: tr::lng_manage_public_peer_title)
|
||||
: (isGroup
|
||||
? lng_manage_private_group_title
|
||||
: lng_manage_private_peer_title));
|
||||
}),
|
||||
? tr::lng_manage_private_group_title
|
||||
: tr::lng_manage_private_peer_title))();
|
||||
}) | rpl::flatten_latest(),
|
||||
[=] { showEditPeerTypeBox(); });
|
||||
|
||||
_privacyTypeUpdates.fire_copy(*_privacySavedValue);
|
||||
@@ -602,10 +604,10 @@ void Controller::fillLinkedChatButton() {
|
||||
|
||||
const auto isGroup = (_peer->isChat() || _peer->isMegagroup());
|
||||
auto text = !isGroup
|
||||
? Lang::Viewer(lng_manage_discussion_group)
|
||||
? tr::lng_manage_discussion_group()
|
||||
: rpl::combine(
|
||||
Lang::Viewer(lng_manage_linked_channel),
|
||||
Lang::Viewer(lng_manage_linked_channel_restore),
|
||||
tr::lng_manage_linked_channel(),
|
||||
tr::lng_manage_linked_channel_restore(),
|
||||
_linkedChatUpdates.events()
|
||||
) | rpl::map([=](
|
||||
const QString &edit,
|
||||
@@ -619,7 +621,7 @@ void Controller::fillLinkedChatButton() {
|
||||
return chat ? chat->name : QString();
|
||||
}) | rpl::type_erased()
|
||||
: rpl::combine(
|
||||
Lang::Viewer(lng_manage_discussion_group_add),
|
||||
tr::lng_manage_discussion_group_add(),
|
||||
_linkedChatUpdates.events()
|
||||
) | rpl::map([=](const QString &add, ChannelData *chat) {
|
||||
return chat
|
||||
@@ -645,7 +647,7 @@ void Controller::fillInviteLinkButton() {
|
||||
|
||||
AddButtonWithText(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(lng_profile_invite_link_section),
|
||||
tr::lng_profile_invite_link_section(),
|
||||
rpl::single(QString()), //Empty text.
|
||||
buttonCallback);
|
||||
}
|
||||
@@ -657,7 +659,7 @@ void Controller::fillSignaturesButton() {
|
||||
|
||||
AddButtonWithText(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(lng_edit_sign_messages),
|
||||
tr::lng_edit_sign_messages(),
|
||||
rpl::single(QString()),
|
||||
[=] {}
|
||||
)->toggleOn(rpl::single(channel->addsSignature())
|
||||
@@ -701,13 +703,13 @@ void Controller::fillHistoryVisibilityButton() {
|
||||
};
|
||||
AddButtonWithText(
|
||||
container,
|
||||
Lang::Viewer(lng_manage_history_visibility_title),
|
||||
tr::lng_manage_history_visibility_title(),
|
||||
updateHistoryVisibility->events(
|
||||
) | rpl::map([](HistoryVisibility flag) {
|
||||
return lang((HistoryVisibility::Visible == flag)
|
||||
? lng_manage_history_visibility_shown
|
||||
: lng_manage_history_visibility_hidden);
|
||||
}),
|
||||
return (HistoryVisibility::Visible == flag
|
||||
? tr::lng_manage_history_visibility_shown
|
||||
: tr::lng_manage_history_visibility_hidden)();
|
||||
}) | rpl::flatten_latest(),
|
||||
buttonCallback);
|
||||
|
||||
updateHistoryVisibility->fire_copy(*_historyVisibilitySavedValue);
|
||||
@@ -824,7 +826,7 @@ void Controller::fillManageSection() {
|
||||
if (canEditPermissions) {
|
||||
AddButtonWithCount(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(lng_manage_peer_permissions),
|
||||
tr::lng_manage_peer_permissions(),
|
||||
Info::Profile::RestrictionsCountValue(_peer)
|
||||
| ToPositiveNumberStringRestrictions(),
|
||||
[=] { ShowEditPermissions(_peer); },
|
||||
@@ -833,7 +835,7 @@ void Controller::fillManageSection() {
|
||||
if (canViewAdmins) {
|
||||
AddButtonWithCount(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(lng_manage_peer_administrators),
|
||||
tr::lng_manage_peer_administrators(),
|
||||
Info::Profile::AdminsCountValue(_peer)
|
||||
| ToPositiveNumberString(),
|
||||
[=] {
|
||||
@@ -847,7 +849,7 @@ void Controller::fillManageSection() {
|
||||
if (canViewMembers) {
|
||||
AddButtonWithCount(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(lng_manage_peer_members),
|
||||
tr::lng_manage_peer_members(),
|
||||
Info::Profile::MembersCountValue(_peer)
|
||||
| ToPositiveNumberString(),
|
||||
[=] {
|
||||
@@ -861,7 +863,7 @@ void Controller::fillManageSection() {
|
||||
if (canViewKicked) {
|
||||
AddButtonWithCount(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(lng_manage_peer_removed_users),
|
||||
tr::lng_manage_peer_removed_users(),
|
||||
Info::Profile::KickedCountValue(channel)
|
||||
| ToPositiveNumberString(),
|
||||
[=] {
|
||||
@@ -875,7 +877,7 @@ void Controller::fillManageSection() {
|
||||
if (hasRecentActions) {
|
||||
AddButtonWithCount(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(lng_manage_peer_recent_actions),
|
||||
tr::lng_manage_peer_recent_actions(),
|
||||
rpl::single(QString()), //Empty count.
|
||||
[=] {
|
||||
navigation->showSection(AdminLog::SectionMemento(channel));
|
||||
@@ -895,9 +897,9 @@ void Controller::fillManageSection() {
|
||||
if (canDeleteChannel) {
|
||||
AddButtonDelete(
|
||||
_controls.buttonsLayout,
|
||||
Lang::Viewer(_isGroup
|
||||
? lng_profile_delete_group
|
||||
: lng_profile_delete_channel),
|
||||
(_isGroup
|
||||
? tr::lng_profile_delete_group
|
||||
: tr::lng_profile_delete_channel)(),
|
||||
[=]{ deleteWithConfirmation(); }
|
||||
);
|
||||
}
|
||||
@@ -1079,17 +1081,17 @@ void Controller::saveUsername() {
|
||||
continueSave();
|
||||
return;
|
||||
}
|
||||
const auto errorKey = [&] {
|
||||
|
||||
// Very rare case.
|
||||
showEditPeerTypeBox([&] {
|
||||
if (type == qstr("USERNAME_INVALID")) {
|
||||
return lng_create_channel_link_invalid;
|
||||
return tr::lng_create_channel_link_invalid();
|
||||
} else if (type == qstr("USERNAME_OCCUPIED")
|
||||
|| type == qstr("USERNAMES_UNAVAILABLE")) {
|
||||
return lng_create_channel_link_occupied;
|
||||
return tr::lng_create_channel_link_occupied();
|
||||
}
|
||||
return lng_create_channel_link_invalid;
|
||||
}();
|
||||
// Very rare case.
|
||||
showEditPeerTypeBox(errorKey);
|
||||
return tr::lng_create_channel_link_invalid();
|
||||
}());
|
||||
cancelSave();
|
||||
}).send();
|
||||
}
|
||||
|
@@ -336,7 +336,7 @@ void EditPeerPermissionsBox::prepare() {
|
||||
|
||||
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
||||
this,
|
||||
lng_rights_default_restrictions_header,
|
||||
tr::lng_rights_default_restrictions_header(),
|
||||
restrictions,
|
||||
disabledMessages);
|
||||
|
||||
@@ -367,7 +367,7 @@ void EditPeerPermissionsBox::addBannedButtons(
|
||||
const auto navigation = App::wnd()->sessionController();
|
||||
container->add(EditPeerInfoBox::CreateButton(
|
||||
container,
|
||||
Lang::Viewer(lng_manage_peer_exceptions),
|
||||
tr::lng_manage_peer_exceptions(),
|
||||
(channel
|
||||
? Info::Profile::RestrictedCountValue(channel)
|
||||
: rpl::single(0)) | ToPositiveNumberString(),
|
||||
@@ -381,7 +381,7 @@ void EditPeerPermissionsBox::addBannedButtons(
|
||||
if (channel) {
|
||||
container->add(EditPeerInfoBox::CreateButton(
|
||||
container,
|
||||
Lang::Viewer(lng_manage_peer_removed_users),
|
||||
tr::lng_manage_peer_removed_users(),
|
||||
Info::Profile::KickedCountValue(channel)
|
||||
| ToPositiveNumberString(),
|
||||
[=] {
|
||||
@@ -400,7 +400,7 @@ template <
|
||||
typename FlagLabelPairs>
|
||||
EditFlagsControl<Flags> CreateEditFlags(
|
||||
QWidget *parent,
|
||||
LangKey header,
|
||||
rpl::producer<QString> header,
|
||||
Flags checked,
|
||||
const DisabledMessagePairs &disabledMessagePairs,
|
||||
const FlagLabelPairs &flagLabelPairs) {
|
||||
@@ -433,7 +433,7 @@ EditFlagsControl<Flags> CreateEditFlags(
|
||||
container->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(header),
|
||||
std::move(header),
|
||||
st::rightsHeaderLabel),
|
||||
st::rightsHeaderMargin);
|
||||
|
||||
@@ -490,7 +490,7 @@ EditFlagsControl<Flags> CreateEditFlags(
|
||||
|
||||
EditFlagsControl<MTPDchatBannedRights::Flags> CreateEditRestrictions(
|
||||
QWidget *parent,
|
||||
LangKey header,
|
||||
rpl::producer<QString> header,
|
||||
MTPDchatBannedRights::Flags restrictions,
|
||||
std::map<MTPDchatBannedRights::Flags, QString> disabledMessages) {
|
||||
auto result = CreateEditFlags(
|
||||
@@ -511,7 +511,7 @@ EditFlagsControl<MTPDchatBannedRights::Flags> CreateEditRestrictions(
|
||||
|
||||
EditFlagsControl<MTPDchatAdminRights::Flags> CreateEditAdminRights(
|
||||
QWidget *parent,
|
||||
LangKey header,
|
||||
rpl::producer<QString> header,
|
||||
MTPDchatAdminRights::Flags rights,
|
||||
std::map<MTPDchatAdminRights::Flags, QString> disabledMessages,
|
||||
bool isGroup,
|
||||
|
@@ -44,13 +44,13 @@ struct EditFlagsControl {
|
||||
|
||||
EditFlagsControl<MTPDchatBannedRights::Flags> CreateEditRestrictions(
|
||||
QWidget *parent,
|
||||
LangKey header,
|
||||
rpl::producer<QString> header,
|
||||
MTPDchatBannedRights::Flags restrictions,
|
||||
std::map<MTPDchatBannedRights::Flags, QString> disabledMessages);
|
||||
|
||||
EditFlagsControl<MTPDchatAdminRights::Flags> CreateEditAdminRights(
|
||||
QWidget *parent,
|
||||
LangKey header,
|
||||
rpl::producer<QString> header,
|
||||
MTPDchatAdminRights::Flags rights,
|
||||
std::map<MTPDchatAdminRights::Flags, QString> disabledMessages,
|
||||
bool isGroup,
|
||||
|
@@ -78,9 +78,9 @@ public:
|
||||
return _controls.privacy->value();
|
||||
}
|
||||
|
||||
void showError(LangKey key) {
|
||||
void showError(rpl::producer<QString> text) {
|
||||
_controls.usernameInput->showError();
|
||||
showUsernameError(Lang::Viewer(key));
|
||||
showUsernameError(std::move(text));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -129,10 +129,10 @@ private:
|
||||
void addRoundButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
Privacy value,
|
||||
LangKey groupTextKey,
|
||||
LangKey channelTextKey,
|
||||
LangKey groupAboutKey,
|
||||
LangKey channelAboutKey);
|
||||
const QString &groupText,
|
||||
const QString &channelText,
|
||||
rpl::producer<QString> groupAbout,
|
||||
rpl::producer<QString> channelAbout);
|
||||
|
||||
bool inviteLinkShown();
|
||||
QString inviteLinkText();
|
||||
@@ -197,21 +197,21 @@ void Controller::createContent() {
|
||||
void Controller::addRoundButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
Privacy value,
|
||||
LangKey groupTextKey,
|
||||
LangKey channelTextKey,
|
||||
LangKey groupAboutKey,
|
||||
LangKey channelAboutKey) {
|
||||
const QString &groupText,
|
||||
const QString &channelText,
|
||||
rpl::producer<QString> groupAbout,
|
||||
rpl::producer<QString> channelAbout) {
|
||||
container->add(object_ptr<Ui::Radioenum<Privacy>>(
|
||||
container,
|
||||
_controls.privacy,
|
||||
value,
|
||||
lang(_isGroup ? groupTextKey : channelTextKey),
|
||||
(_isGroup ? groupText : channelText),
|
||||
st::editPeerPrivacyBoxCheckbox));
|
||||
container->add(object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>(
|
||||
container,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(_isGroup ? groupAboutKey : channelAboutKey),
|
||||
std::move(_isGroup ? groupAbout : channelAbout),
|
||||
st::editPeerPrivacyLabel),
|
||||
st::editPeerPrivacyLabelMargins));
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
@@ -249,17 +249,17 @@ void Controller::fillPrivaciesButtons(
|
||||
addRoundButton(
|
||||
container,
|
||||
Privacy::Public,
|
||||
lng_create_public_group_title,
|
||||
lng_create_public_channel_title,
|
||||
lng_create_public_group_about,
|
||||
lng_create_public_channel_about);
|
||||
tr::lng_create_public_group_title(tr::now),
|
||||
tr::lng_create_public_channel_title(tr::now),
|
||||
tr::lng_create_public_group_about(),
|
||||
tr::lng_create_public_channel_about());
|
||||
addRoundButton(
|
||||
container,
|
||||
Privacy::Private,
|
||||
lng_create_private_group_title,
|
||||
lng_create_private_channel_title,
|
||||
lng_create_private_group_about,
|
||||
lng_create_private_channel_about);
|
||||
tr::lng_create_private_group_title(tr::now),
|
||||
tr::lng_create_private_channel_title(tr::now),
|
||||
tr::lng_create_private_group_about(),
|
||||
tr::lng_create_private_channel_about());
|
||||
|
||||
_controls.privacy->setChangedCallback([=](Privacy value) {
|
||||
privacyChanged(value);
|
||||
@@ -303,7 +303,7 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
|
||||
container,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(lng_create_group_link),
|
||||
tr::lng_create_group_link(),
|
||||
st::editPeerSectionLabel),
|
||||
st::editPeerUsernameTitleLabelMargins));
|
||||
|
||||
@@ -334,7 +334,7 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
|
||||
container,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(lng_create_channel_link_about),
|
||||
tr::lng_create_channel_link_about(),
|
||||
st::editPeerPrivacyLabel),
|
||||
st::editPeerUsernameAboutLabelMargins));
|
||||
|
||||
@@ -415,8 +415,7 @@ void Controller::checkUsernameAvailability() {
|
||||
return;
|
||||
}
|
||||
if (!mtpIsTrue(result) && checking != username) {
|
||||
showUsernameError(
|
||||
Lang::Viewer(lng_create_channel_link_occupied));
|
||||
showUsernameError(tr::lng_create_channel_link_occupied());
|
||||
} else {
|
||||
showUsernameGood();
|
||||
}
|
||||
@@ -438,12 +437,10 @@ void Controller::checkUsernameAvailability() {
|
||||
setFocusUsername();
|
||||
}
|
||||
} else if (type == qstr("USERNAME_INVALID")) {
|
||||
showUsernameError(
|
||||
Lang::Viewer(lng_create_channel_link_invalid));
|
||||
showUsernameError(tr::lng_create_channel_link_invalid());
|
||||
} else if (type == qstr("USERNAME_OCCUPIED")
|
||||
&& checking != username) {
|
||||
showUsernameError(
|
||||
Lang::Viewer(lng_create_channel_link_occupied));
|
||||
showUsernameError(tr::lng_create_channel_link_occupied());
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
@@ -475,11 +472,9 @@ void Controller::usernameChanged() {
|
||||
&& (ch != '_');
|
||||
}) != username.end();
|
||||
if (bad) {
|
||||
showUsernameError(
|
||||
Lang::Viewer(lng_create_channel_link_bad_symbols));
|
||||
showUsernameError(tr::lng_create_channel_link_bad_symbols());
|
||||
} else if (username.size() < kMinUsernameLength) {
|
||||
showUsernameError(
|
||||
Lang::Viewer(lng_create_channel_link_too_short));
|
||||
showUsernameError(tr::lng_create_channel_link_too_short());
|
||||
} else {
|
||||
_controls.usernameResult = nullptr;
|
||||
_checkUsernameTimer.callOnce(kUsernameCheckTimeout);
|
||||
@@ -494,7 +489,7 @@ void Controller::showUsernameError(rpl::producer<QString> &&error) {
|
||||
void Controller::showUsernameGood() {
|
||||
_isAllowSave = true;
|
||||
showUsernameResult(
|
||||
Lang::Viewer(lng_create_channel_link_available),
|
||||
tr::lng_create_channel_link_available(),
|
||||
&st::editPeerUsernameGood);
|
||||
}
|
||||
|
||||
@@ -585,7 +580,7 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkEdit() {
|
||||
if (!_isInviteLink) {
|
||||
container->add(object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(lng_profile_invite_link_section),
|
||||
tr::lng_profile_invite_link_section(),
|
||||
st::editPeerSectionLabel));
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
@@ -659,7 +654,7 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkCreate() {
|
||||
if (!_isInviteLink) {
|
||||
container->add(object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(lng_profile_invite_link_section),
|
||||
tr::lng_profile_invite_link_section(),
|
||||
st::editPeerSectionLabel));
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
@@ -700,7 +695,7 @@ EditPeerTypeBox::EditPeerTypeBox(
|
||||
std::optional<FnMut<void(Privacy, QString)>> savedCallback,
|
||||
std::optional<Privacy> privacySaved,
|
||||
std::optional<QString> usernameSaved,
|
||||
std::optional<LangKey> usernameError)
|
||||
std::optional<rpl::producer<QString>> usernameError)
|
||||
: _peer(peer)
|
||||
, _savedCallback(std::move(savedCallback))
|
||||
, _privacySavedValue(privacySaved)
|
||||
@@ -728,7 +723,7 @@ void EditPeerTypeBox::prepare() {
|
||||
[=] {
|
||||
controller->setFocusUsername();
|
||||
if (_usernameError.has_value()) {
|
||||
controller->showError(*_usernameError);
|
||||
controller->showError(std::move(*_usernameError));
|
||||
_usernameError = std::nullopt;
|
||||
}
|
||||
},
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
std::optional<FnMut<void(Privacy, QString)>> savedCallback = {},
|
||||
std::optional<Privacy> privacySaved = {},
|
||||
std::optional<QString> usernameSaved = {},
|
||||
std::optional<LangKey> usernameError = {});
|
||||
std::optional<rpl::producer<QString>> usernameError = {});
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
|
||||
std::optional<Privacy> _privacySavedValue;
|
||||
std::optional<QString> _usernameSavedValue;
|
||||
std::optional<LangKey> _usernameError;
|
||||
std::optional<rpl::producer<QString>> _usernameError;
|
||||
|
||||
rpl::event_stream<> _focusRequests;
|
||||
|
||||
|
@@ -359,7 +359,7 @@ void SessionsBox::Inner::setupContent() {
|
||||
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
AddSubsectionTitle(content, lng_sessions_header);
|
||||
AddSubsectionTitle(content, tr::lng_sessions_header());
|
||||
_current = content->add(object_ptr<List>(content));
|
||||
const auto terminateWrap = content->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
@@ -369,12 +369,10 @@ void SessionsBox::Inner::setupContent() {
|
||||
_terminateAll = terminateInner->add(
|
||||
object_ptr<Info::Profile::Button>(
|
||||
terminateInner,
|
||||
Lang::Viewer(lng_sessions_terminate_all),
|
||||
tr::lng_sessions_terminate_all(),
|
||||
st::terminateSessionsButton));
|
||||
AddSkip(terminateInner);
|
||||
AddDividerText(
|
||||
terminateInner,
|
||||
Lang::Viewer(lng_sessions_terminate_all_about));
|
||||
AddDividerText(terminateInner, tr::lng_sessions_terminate_all_about());
|
||||
|
||||
const auto incompleteWrap = content->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
@@ -382,12 +380,10 @@ void SessionsBox::Inner::setupContent() {
|
||||
object_ptr<Ui::VerticalLayout>(content)))->setDuration(0);
|
||||
const auto incompleteInner = incompleteWrap->entity();
|
||||
AddSkip(incompleteInner);
|
||||
AddSubsectionTitle(incompleteInner, lng_sessions_incomplete);
|
||||
AddSubsectionTitle(incompleteInner, tr::lng_sessions_incomplete());
|
||||
_incomplete = incompleteInner->add(object_ptr<List>(incompleteInner));
|
||||
AddSkip(incompleteInner);
|
||||
AddDividerText(
|
||||
incompleteInner,
|
||||
Lang::Viewer(lng_sessions_incomplete_about));
|
||||
AddDividerText(incompleteInner, tr::lng_sessions_incomplete_about());
|
||||
|
||||
const auto listWrap = content->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
@@ -395,7 +391,7 @@ void SessionsBox::Inner::setupContent() {
|
||||
object_ptr<Ui::VerticalLayout>(content)))->setDuration(0);
|
||||
const auto listInner = listWrap->entity();
|
||||
AddSkip(listInner);
|
||||
AddSubsectionTitle(listInner, lng_sessions_other_header);
|
||||
AddSubsectionTitle(listInner, tr::lng_sessions_other_header());
|
||||
_list = listInner->add(object_ptr<List>(listInner));
|
||||
AddSkip(listInner);
|
||||
|
||||
@@ -404,7 +400,7 @@ void SessionsBox::Inner::setupContent() {
|
||||
content,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
content,
|
||||
Lang::Viewer(lng_sessions_other_desc),
|
||||
tr::lng_sessions_other_desc(),
|
||||
st::boxDividerLabel),
|
||||
st::settingsDividerLabelPadding))->setDuration(0);
|
||||
|
||||
|
Reference in New Issue
Block a user