Use tr:: instead of langFactory in box titles.

This commit is contained in:
John Preston 2019-06-18 17:00:55 +02:00
parent 8ed433cc01
commit d1d98c3bb1
66 changed files with 234 additions and 230 deletions

View File

@ -58,7 +58,7 @@ AboutBox::AboutBox(QWidget *parent)
}
void AboutBox::prepare() {
setTitle([] { return qsl("Telegram Desktop"); });
setTitle(rpl::single(qsl("Telegram Desktop")));
addButton(langFactory(lng_close), [this] { closeBox(); });

View File

@ -16,9 +16,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h"
#include "ui/widgets/shadow.h"
#include "ui/wrap/fade_wrap.h"
#include "ui/text/text_utilities.h"
#include "mainwidget.h"
#include "mainwindow.h"
void BoxContent::setTitle(rpl::producer<QString> title) {
getDelegate()->setTitle(std::move(title) | Ui::Text::ToWithEntities());
}
QPointer<Ui::RoundButton> BoxContent::addButton(
Fn<QString()> textFactory,
Fn<void()> clickCallback) {
@ -310,18 +315,10 @@ void AbstractBox::parentResized() {
update();
}
void AbstractBox::setTitle(Fn<TextWithEntities()> titleFactory) {
_titleFactory = std::move(titleFactory);
refreshTitle();
}
void AbstractBox::refreshTitle() {
auto wasTitle = hasTitle();
if (_titleFactory) {
if (!_title) {
_title.create(this, st::boxTitle);
}
_title->setMarkedText(_titleFactory());
void AbstractBox::setTitle(rpl::producer<TextWithEntities> title) {
const auto wasTitle = hasTitle();
if (title) {
_title.create(this, std::move(title), st::boxTitle);
updateTitlePosition();
} else {
_title.destroy();
@ -350,7 +347,6 @@ void AbstractBox::refreshAdditionalTitle() {
}
void AbstractBox::refreshLang() {
refreshTitle();
refreshAdditionalTitle();
InvokeQueued(this, [this] { updateButtonsPositions(); });
}

View File

@ -30,7 +30,7 @@ class BoxContent;
class BoxContentDelegate {
public:
virtual void setLayerType(bool layerType) = 0;
virtual void setTitle(Fn<TextWithEntities()> titleFactory) = 0;
virtual void setTitle(rpl::producer<TextWithEntities> title) = 0;
virtual void setAdditionalTitle(Fn<QString()> additionalFactory) = 0;
virtual void setCloseByOutsideClick(bool close) = 0;
@ -81,15 +81,9 @@ public:
getDelegate()->closeBox();
}
void setTitle(Fn<QString()> titleFactory) {
if (titleFactory) {
getDelegate()->setTitle([titleFactory] { return TextWithEntities { titleFactory(), EntitiesInText() }; });
} else {
getDelegate()->setTitle(Fn<TextWithEntities()>());
}
}
void setTitle(Fn<TextWithEntities()> titleFactory) {
getDelegate()->setTitle(std::move(titleFactory));
void setTitle(rpl::producer<QString> title);
void setTitle(rpl::producer<TextWithEntities> title) {
getDelegate()->setTitle(std::move(title));
}
void setAdditionalTitle(Fn<QString()> additional) {
getDelegate()->setAdditionalTitle(std::move(additional));
@ -256,7 +250,7 @@ public:
void parentResized() override;
void setLayerType(bool layerType) override;
void setTitle(Fn<TextWithEntities()> titleFactory) override;
void setTitle(rpl::producer<TextWithEntities> title) override;
void setAdditionalTitle(Fn<QString()> additionalFactory) override;
void showBox(
object_ptr<BoxContent> box,
@ -307,7 +301,6 @@ protected:
private:
void paintAdditionalTitle(Painter &p);
void updateTitlePosition();
void refreshTitle();
void refreshAdditionalTitle();
void refreshLang();

View File

@ -212,10 +212,13 @@ void AddContactBox::prepare() {
setTabOrder(_last, _first);
}
if (_user) {
setTitle(langFactory(lng_edit_contact_title));
setTitle(tr::lng_edit_contact_title());
} else {
auto readyToAdd = !_phone->getLastText().isEmpty() && (!_first->getLastText().isEmpty() || !_last->getLastText().isEmpty());
setTitle(langFactory(readyToAdd ? lng_confirm_contact_data : lng_enter_contact_data));
const auto readyToAdd = !_phone->getLastText().isEmpty()
&& (!_first->getLastText().isEmpty() || !_last->getLastText().isEmpty());
setTitle(readyToAdd
? tr::lng_confirm_contact_data()
: tr::lng_enter_contact_data());
}
updateButtons();
@ -1092,7 +1095,7 @@ EditNameBox::EditNameBox(QWidget*, not_null<UserData*> user)
void EditNameBox::prepare() {
auto newHeight = st::contactPadding.top() + _first->height();
setTitle(langFactory(lng_edit_self_title));
setTitle(tr::lng_edit_self_title());
newHeight += st::contactSkip + _last->height();
newHeight += st::boxPadding.bottom() + st::contactPadding.bottom();

View File

@ -43,7 +43,7 @@ void AutoDownloadBox::setupContent() {
using namespace rpl::mappers;
using Type = Data::AutoDownload::Type;
setTitle(langFactory(lng_media_auto_title));
setTitle(tr::lng_media_auto_title());
const auto settings = &Auth().settings().autoDownload();
const auto checked = [=](Source source, Type type) {

View File

@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_boxes.h"
void AutoLockBox::prepare() {
setTitle(langFactory(lng_passcode_autolock));
setTitle(tr::lng_passcode_autolock());
addButton(langFactory(lng_box_ok), [this] { closeBox(); });

View File

@ -122,7 +122,7 @@ BackgroundBox::BackgroundBox(QWidget*) {
}
void BackgroundBox::prepare() {
setTitle(langFactory(lng_backgrounds_header));
setTitle(tr::lng_backgrounds_header());
addButton(langFactory(lng_close), [=] { closeBox(); });

View File

@ -407,7 +407,7 @@ not_null<HistoryView::ElementDelegate*> BackgroundPreviewBox::delegate() {
}
void BackgroundPreviewBox::prepare() {
setTitle(langFactory(lng_background_header));
setTitle(tr::lng_background_header());
addButton(langFactory(lng_background_apply), [=] { apply(); });
addButton(langFactory(lng_cancel), [=] { closeBox(); });

View File

@ -120,7 +120,7 @@ private:
};
void ChangePhoneBox::EnterPhone::prepare() {
setTitle(langFactory(lng_change_phone_title));
setTitle(tr::lng_change_phone_title());
auto phoneValue = QString();
_phone.create(this, st::defaultInputField, tr::lng_change_phone_new_title(), phoneValue);
@ -235,7 +235,7 @@ ChangePhoneBox::EnterCode::EnterCode(QWidget*, const QString &phone, const QStri
}
void ChangePhoneBox::EnterCode::prepare() {
setTitle(langFactory(lng_change_phone_title));
setTitle(tr::lng_change_phone_title());
auto descriptionText = lng_change_phone_code_description__rich(
lt_phone,
@ -338,7 +338,7 @@ bool ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) {
}
void ChangePhoneBox::prepare() {
setTitle(langFactory(lng_change_phone_title));
setTitle(tr::lng_change_phone_title());
addButton(langFactory(lng_change_phone_button), [] {
Ui::show(Box<ConfirmBox>(lang(lng_change_phone_warning), [] {
Ui::show(Box<EnterPhone>());

View File

@ -282,7 +282,7 @@ void ConfirmPhoneBox::prepare() {
_code->setAutoSubmit(_sentCodeLength, [=] { sendCode(); });
_code->setChangedCallback([=] { showError(QString()); });
setTitle(langFactory(lng_confirm_phone_title));
setTitle(tr::lng_confirm_phone_title());
addButton(langFactory(lng_confirm_phone_send), [=] { sendCode(); });
addButton(langFactory(lng_cancel), [=] { closeBox(); });

View File

@ -469,7 +469,7 @@ ProxiesBox::ProxiesBox(
}
void ProxiesBox::prepare() {
setTitle(langFactory(lng_proxy_settings));
setTitle(tr::lng_proxy_settings());
addButton(langFactory(lng_proxy_add), [=] { addNewProxy(); });
addButton(langFactory(lng_close), [=] { closeBox(); });
@ -698,7 +698,7 @@ ProxyBox::ProxyBox(
}
void ProxyBox::prepare() {
setTitle(langFactory(lng_proxy_edit));
setTitle(tr::lng_proxy_edit());
refreshButtons();
setDimensionsToContent(st::boxWideWidth, _content);

View File

@ -725,7 +725,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
}
void CreatePollBox::prepare() {
setTitle(langFactory(lng_polls_create_title));
setTitle(tr::lng_polls_create_title());
const auto inner = setInnerWidget(setupContent());

View File

@ -29,7 +29,7 @@ void DownloadPathBox::prepare() {
addButton(langFactory(lng_connection_save), [this] { save(); });
addButton(langFactory(lng_cancel), [this] { closeBox(); });
setTitle(langFactory(lng_download_path_header));
setTitle(tr::lng_download_path_header());
_group->setChangedCallback([this](Directory value) { radioChanged(value); });

View File

@ -631,7 +631,7 @@ EditColorBox::EditColorBox(QWidget*, const QString &title, QColor current) : Box
}
void EditColorBox::prepare() {
setTitle([=] { return _title; });
setTitle(rpl::single(_title));
const auto hsvChanged = [=] { updateFromHSVFields(); };
const auto rgbChanged = [=] { updateFromRGBFields(); };

View File

@ -32,7 +32,9 @@ namespace {
class PrivacyExceptionsBoxController : public ChatsListBoxController {
public:
PrivacyExceptionsBoxController(Fn<QString()> titleFactory, const std::vector<not_null<PeerData*>> &selected);
PrivacyExceptionsBoxController(
rpl::producer<QString> title,
const std::vector<not_null<PeerData*>> &selected);
void rowClicked(not_null<PeerListRow*> row) override;
std::vector<not_null<PeerData*>> getResult() const;
@ -42,20 +44,20 @@ protected:
std::unique_ptr<Row> createRow(not_null<History*> history) override;
private:
Fn<QString()> _titleFactory;
rpl::producer<QString> _title;
std::vector<not_null<PeerData*>> _selected;
};
PrivacyExceptionsBoxController::PrivacyExceptionsBoxController(
Fn<QString()> titleFactory,
rpl::producer<QString> title,
const std::vector<not_null<PeerData*>> &selected)
: _titleFactory(std::move(titleFactory))
: _title(std::move(title))
, _selected(selected) {
}
void PrivacyExceptionsBoxController::prepareViewHook() {
delegate()->peerListSetTitle(_titleFactory);
delegate()->peerListSetTitle(std::move(_title));
delegate()->peerListAddSelectedRows(_selected);
}
@ -127,9 +129,7 @@ void EditPrivacyBox::editExceptions(
Exception exception,
Fn<void()> done) {
auto controller = std::make_unique<PrivacyExceptionsBoxController>(
crl::guard(this, [=] {
return _controller->exceptionBoxTitle(exception);
}),
_controller->exceptionBoxTitle(exception),
exceptions(exception));
auto initBox = [=, controller = controller.get()](
not_null<PeerListBox*> box) {
@ -272,7 +272,7 @@ Ui::FlatLabel *EditPrivacyBox::addLabel(
void EditPrivacyBox::setupContent() {
using namespace Settings;
setTitle([=] { return _controller->title(); });
setTitle(_controller->title());
auto wrap = object_ptr<Ui::VerticalLayout>(this);
const auto content = wrap.data();

View File

@ -39,7 +39,7 @@ public:
[[nodiscard]] virtual Key key() = 0;
[[nodiscard]] virtual MTPInputPrivacyKey apiKey() = 0;
[[nodiscard]] virtual QString title() = 0;
[[nodiscard]] virtual rpl::producer<QString> title() = 0;
[[nodiscard]] virtual bool hasOption(Option option) {
return true;
}
@ -50,7 +50,7 @@ public:
}
[[nodiscard]] virtual rpl::producer<QString> exceptionButtonTextKey(
Exception exception) = 0;
[[nodiscard]] virtual QString exceptionBoxTitle(
[[nodiscard]] virtual rpl::producer<QString> exceptionBoxTitle(
Exception exception) = 0;
[[nodiscard]] virtual auto exceptionsDescription()
-> rpl::producer<QString> = 0;

View File

@ -1037,7 +1037,7 @@ Ui::ScrollToRequest Content::jump(int rows) {
void LanguageBox::prepare() {
addButton(langFactory(lng_box_ok), [=] { closeBox(); });
setTitle(langFactory(lng_languages));
setTitle(tr::lng_languages());
const auto select = createMultiSelect();

View File

@ -297,7 +297,7 @@ void LocalStorageBox::Show(
}
void LocalStorageBox::prepare() {
setTitle(langFactory(lng_local_storage_title));
setTitle(tr::lng_local_storage_title());
addButton(langFactory(lng_box_ok), [this] { closeBox(); });

View File

@ -26,7 +26,7 @@ MuteSettingsBox::MuteSettingsBox(QWidget *parent, not_null<PeerData*> peer)
}
void MuteSettingsBox::prepare() {
setTitle(langFactory(lng_disable_notifications_from_tray));
setTitle(tr::lng_disable_notifications_from_tray());
auto y = 0;
object_ptr<Ui::FlatLabel> info(this, st::boxLabel);

View File

@ -108,20 +108,24 @@ void PasscodeBox::prepare() {
const auto onlyCheck = onlyCheckCurrent();
if (onlyCheck) {
_oldPasscode->show();
setTitle([=] {
return _cloudFields.customTitle.value_or(lang(_cloudPwd
? lng_cloud_password_remove
: lng_passcode_remove));
});
setTitle(_cloudFields.customTitle
? rpl::single(*_cloudFields.customTitle)
: _cloudPwd
? tr::lng_cloud_password_remove()
: tr::lng_passcode_remove());
setDimensions(st::boxWidth, st::passcodePadding.top() + _oldPasscode->height() + st::passcodeTextLine + ((_cloudFields.hasRecovery && !_hintText.isEmpty()) ? st::passcodeTextLine : 0) + st::passcodeAboutSkip + _aboutHeight + st::passcodePadding.bottom());
} else {
if (currentlyHave()) {
_oldPasscode->show();
setTitle(langFactory(_cloudPwd ? lng_cloud_password_change : lng_passcode_change));
setTitle(_cloudPwd
? tr::lng_cloud_password_change()
: tr::lng_passcode_change());
setDimensions(st::boxWidth, st::passcodePadding.top() + _oldPasscode->height() + st::passcodeTextLine + ((_cloudFields.hasRecovery && !_hintText.isEmpty()) ? st::passcodeTextLine : 0) + _newPasscode->height() + st::passcodeLittleSkip + _reenterPasscode->height() + st::passcodeSkip + (_cloudPwd ? _passwordHint->height() + st::passcodeLittleSkip : 0) + st::passcodeAboutSkip + _aboutHeight + st::passcodePadding.bottom());
} else {
_oldPasscode->hide();
setTitle(langFactory(_cloudPwd ? lng_cloud_password_create : lng_passcode_create));
setTitle(_cloudPwd
? tr::lng_cloud_password_create()
: tr::lng_passcode_create());
setDimensions(st::boxWidth, st::passcodePadding.top() + _newPasscode->height() + st::passcodeLittleSkip + _reenterPasscode->height() + st::passcodeSkip + (_cloudPwd ? _passwordHint->height() + st::passcodeLittleSkip : 0) + st::passcodeAboutSkip + _aboutHeight + (_cloudPwd ? (st::passcodeLittleSkip + _recoverEmail->height() + st::passcodeSkip) : st::passcodePadding.bottom()));
}
}
@ -908,7 +912,7 @@ rpl::producer<> RecoverBox::recoveryExpired() const {
}
void RecoverBox::prepare() {
setTitle(langFactory(lng_signin_recover_title));
setTitle(tr::lng_signin_recover_title());
addButton(langFactory(lng_passcode_submit), [=] { submit(); });
addButton(langFactory(lng_cancel), [=] { closeBox(); });

View File

@ -225,7 +225,7 @@ struct PeerListState;
class PeerListDelegate {
public:
virtual void peerListSetTitle(Fn<QString()> title) = 0;
virtual void peerListSetTitle(rpl::producer<QString> title) = 0;
virtual void peerListSetAdditionalTitle(Fn<QString()> title) = 0;
virtual void peerListSetDescription(object_ptr<Ui::FlatLabel> description) = 0;
virtual void peerListSetSearchLoading(object_ptr<Ui::FlatLabel> loading) = 0;
@ -755,7 +755,7 @@ public:
std::unique_ptr<PeerListController> controller,
Fn<void(not_null<PeerListBox*>)> init);
void peerListSetTitle(Fn<QString()> title) override {
void peerListSetTitle(rpl::producer<QString> title) override {
setTitle(std::move(title));
}
void peerListSetAdditionalTitle(

View File

@ -325,7 +325,7 @@ ContactsBoxController::ContactsBoxController(
void ContactsBoxController::prepare() {
setSearchNoResultsText(lang(lng_blocked_list_not_found));
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
delegate()->peerListSetTitle(langFactory(lng_contacts_header));
delegate()->peerListSetTitle(tr::lng_contacts_header());
prepareViewHook();
@ -497,9 +497,9 @@ void AddBotToGroupBoxController::updateLabels() {
}
void AddBotToGroupBoxController::prepareViewHook() {
delegate()->peerListSetTitle(langFactory(sharingBotGame()
? lng_bot_choose_chat
: lng_bot_choose_group));
delegate()->peerListSetTitle(sharingBotGame()
? tr::lng_bot_choose_chat()
: tr::lng_bot_choose_group());
updateLabels();
Auth().data().chatsListLoadedEvents(
) | rpl::filter([=](Data::Folder *folder) {
@ -515,7 +515,7 @@ ChooseRecipientBoxController::ChooseRecipientBoxController(
}
void ChooseRecipientBoxController::prepareViewHook() {
delegate()->peerListSetTitle(langFactory(lng_forward_choose));
delegate()->peerListSetTitle(tr::lng_forward_choose());
}
void ChooseRecipientBoxController::rowClicked(not_null<PeerListRow*> row) {

View File

@ -155,7 +155,7 @@ void AddParticipantsBoxController::updateTitle() {
&& !_peer->isMegagroup())
? QString() :
QString("%1 / %2").arg(fullCount()).arg(Global::MegagroupSizeMax());
delegate()->peerListSetTitle(langFactory(lng_profile_add_participant));
delegate()->peerListSetTitle(tr::lng_profile_add_participant());
delegate()->peerListSetAdditionalTitle([=] { return additional; });
}
@ -287,18 +287,18 @@ std::unique_ptr<PeerListRow> AddSpecialBoxController::createSearchRow(
void AddSpecialBoxController::prepare() {
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
const auto title = [&] {
auto title = [&] {
switch (_role) {
case Role::Admins:
return langFactory(lng_channel_add_admin);
return tr::lng_channel_add_admin();
case Role::Restricted:
return langFactory(lng_channel_add_exception);
return tr::lng_channel_add_exception();
case Role::Kicked:
return langFactory(lng_channel_add_removed);
return tr::lng_channel_add_removed();
}
Unexpected("Role in AddSpecialBoxController::prepare()");
}();
delegate()->peerListSetTitle(title);
delegate()->peerListSetTitle(std::move(title));
setDescriptionText(lang(lng_contacts_loading));
setSearchNoResultsText(lang(lng_blocked_list_not_found));

View File

@ -76,9 +76,9 @@ Controller::Controller(
void Controller::prepare() {
setupContent();
_box->setTitle(langFactory(_user->isContact()
? lng_edit_contact_title
: lng_enter_contact_data));
_box->setTitle(_user->isContact()
? tr::lng_edit_contact_title()
: tr::lng_enter_contact_data());
_box->addButton(langFactory(lng_box_done), _save);
_box->addButton(langFactory(lng_cancel), [=] { _box->closeBox(); });

View File

@ -285,9 +285,9 @@ object_ptr<BoxContent> EditLinkedChatBox(
st::linkedChatAboutPadding);
box->peerListSetBelowWidget(std::move(below));
box->setTitle(langFactory(channel->isBroadcast()
? lng_manage_discussion_group
: lng_manage_linked_channel));
box->setTitle(channel->isBroadcast()
? tr::lng_manage_discussion_group()
: tr::lng_manage_linked_channel());
box->addButton(langFactory(lng_close), [=] { box->closeBox(); });
};
auto controller = std::make_unique<Controller>(

View File

@ -69,7 +69,7 @@ void TransferPasswordError(
not_null<GenericBox*> box,
not_null<UserData*> user,
PasswordErrorType error) {
box->setTitle(langFactory(lng_rights_transfer_check));
box->setTitle(tr::lng_rights_transfer_check());
box->setWidth(st::transferCheckWidth);
auto text = lng_rights_transfer_check_about__rich(
@ -271,9 +271,9 @@ void EditAdminBox::prepare() {
EditParticipantBox::prepare();
auto hadRights = _oldRights.c_chatAdminRights().vflags.v;
setTitle(langFactory(hadRights
? lng_rights_edit_admin
: lng_channel_add_admin));
setTitle(hadRights
? tr::lng_rights_edit_admin()
: tr::lng_channel_add_admin());
addControl(
object_ptr<BoxContentDivider>(this),
@ -579,7 +579,7 @@ EditRestrictedBox::EditRestrictedBox(
void EditRestrictedBox::prepare() {
EditParticipantBox::prepare();
setTitle(langFactory(lng_rights_user_restrictions));
setTitle(tr::lng_rights_user_restrictions());
addControl(
object_ptr<BoxContentDivider>(this),

View File

@ -1012,18 +1012,18 @@ rpl::producer<int> ParticipantsBoxController::onlineCountValue() const {
}
void ParticipantsBoxController::prepare() {
const auto titleKey = [&] {
auto title = [&] {
switch (_role) {
case Role::Admins: return lng_channel_admins;
case Role::Admins: return tr::lng_channel_admins();
case Role::Profile:
case Role::Members: return lng_profile_participants_section;
case Role::Restricted: return lng_exceptions_list_title;
case Role::Kicked: return lng_removed_list_title;
case Role::Members: return tr::lng_profile_participants_section();
case Role::Restricted: return tr::lng_exceptions_list_title();
case Role::Kicked: return tr::lng_removed_list_title();
}
Unexpected("Role in ParticipantsBoxController::prepare()");
}();
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
delegate()->peerListSetTitle(langFactory(titleKey));
delegate()->peerListSetTitle(std::move(title));
setDescriptionText(lang(lng_contacts_loading));
setSearchNoResultsText(lang(lng_blocked_list_not_found));

View File

@ -111,7 +111,7 @@ EditPeerHistoryVisibilityBox::EditPeerHistoryVisibilityBox(
void EditPeerHistoryVisibilityBox::prepare() {
_peer->updateFull();
setTitle(langFactory(lng_manage_history_visibility_title));
setTitle(tr::lng_manage_history_visibility_title());
addButton(langFactory(lng_settings_save), [=] {
auto local = std::move(_savedCallback);
local(_historyVisibility->value());

View File

@ -269,9 +269,9 @@ Controller::Controller(
: _box(box)
, _peer(peer)
, _isGroup(_peer->isChat() || _peer->isMegagroup()) {
_box->setTitle(langFactory(_isGroup
? lng_edit_group
: lng_edit_channel_title));
_box->setTitle(_isGroup
? tr::lng_edit_group()
: tr::lng_edit_channel_title());
_box->addButton(langFactory(lng_settings_save), [this] {
save();
});

View File

@ -298,7 +298,7 @@ auto EditPeerPermissionsBox::saveEvents() const
}
void EditPeerPermissionsBox::prepare() {
setTitle(langFactory(lng_manage_peer_permissions));
setTitle(tr::lng_manage_peer_permissions());
const auto inner = setInnerWidget(object_ptr<Ui::VerticalLayout>(this));

View File

@ -58,12 +58,12 @@ public:
QString getUsernameInput();
void setFocusUsername();
LangKey getTitle() {
rpl::producer<QString> getTitle() {
return _isInviteLink
? lng_profile_invite_link_section
? tr::lng_profile_invite_link_section()
: _isGroup
? lng_manage_peer_group_type
: lng_manage_peer_channel_type;
? tr::lng_manage_peer_group_type()
: tr::lng_manage_peer_channel_type();
}
bool isInviteLink() {
@ -730,7 +730,7 @@ void EditPeerTypeBox::prepare() {
lifetime());
controller->createContent();
setTitle(langFactory(controller->getTitle()));
setTitle(controller->getTitle());
if (!controller->isInviteLink() && _savedCallback.has_value()) {
addButton(langFactory(lng_settings_save), [=] {

View File

@ -31,7 +31,7 @@ RateCallBox::RateCallBox(QWidget*, uint64 callId, uint64 callAccessHash)
}
void RateCallBox::prepare() {
setTitle(langFactory(lng_call_rate_label));
setTitle(tr::lng_call_rate_label());
addButton(langFactory(lng_cancel), [this] { closeBox(); });
for (auto i = 0; i < kMaxRating; ++i) {

View File

@ -34,17 +34,17 @@ ReportBox::ReportBox(QWidget*, not_null<PeerData*> peer, MessageIdsList ids)
}
void ReportBox::prepare() {
setTitle(langFactory([&] {
setTitle([&] {
if (_ids) {
return lng_report_message_title;
return tr::lng_report_message_title();
} else if (_peer->isUser()) {
return lng_report_bot_title;
return tr::lng_report_bot_title();
} else if (_peer->isMegagroup()) {
return lng_report_group_title;
return tr::lng_report_group_title();
} else {
return lng_report_title;
return tr::lng_report_title();
}
}()));
}());
addButton(langFactory(lng_report_button), [=] { report(); });
addButton(langFactory(lng_cancel), [=] { closeBox(); });

View File

@ -86,7 +86,7 @@ QString SelfDestructionBox::DaysLabel(int days) {
}
void SelfDestructionBox::prepare() {
setTitle(langFactory(lng_self_destruct_title));
setTitle(tr::lng_self_destruct_title());
auto fake = object_ptr<Ui::FlatLabel>(
this,

View File

@ -80,7 +80,7 @@ SessionsBox::SessionsBox(QWidget*)
}
void SessionsBox::prepare() {
setTitle(langFactory(lng_sessions_other_header));
setTitle(tr::lng_sessions_other_header());
addButton(langFactory(lng_close), [=] { closeBox(); });

View File

@ -205,7 +205,7 @@ void ShareBox::prepare() {
_select->resizeToWidth(st::boxWideWidth);
Ui::SendPendingMoveResizeEvents(_select);
setTitle(langFactory(lng_share_title));
setTitle(tr::lng_share_title());
_inner = setInnerWidget(
object_ptr<Inner>(

View File

@ -17,18 +17,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
SingleChoiceBox::SingleChoiceBox(
QWidget*,
LangKey title,
rpl::producer<QString> title,
const std::vector<QString> &optionTexts,
int initialSelection,
Fn<void(int)> callback)
: _title(title)
: _title(std::move(title))
, _optionTexts(optionTexts)
, _initialSelection(initialSelection)
, _callback(callback) {
}
void SingleChoiceBox::prepare() {
setTitle(langFactory(_title));
setTitle(std::move(_title));
addButton(langFactory(lng_box_ok), [=] { closeBox(); });

View File

@ -20,7 +20,7 @@ class SingleChoiceBox : public BoxContent {
public:
SingleChoiceBox(
QWidget*,
LangKey title,
rpl::producer<QString> title,
const std::vector<QString> &optionTexts,
int initialSelection,
Fn<void(int)> callback);
@ -29,7 +29,7 @@ protected:
void prepare() override;
private:
LangKey _title;
rpl::producer<QString> _title;
std::vector<QString> _optionTexts;
int _initialSelection = 0;
Fn<void(int)> _callback;

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/widgets/scroll_area.h"
#include "ui/image/image.h"
#include "ui/text/text_utilities.h"
#include "ui/emoji_config.h"
#include "auth_session.h"
#include "apiwrap.h"
@ -39,7 +40,7 @@ public:
bool loaded() const;
bool notInstalled() const;
bool official() const;
Fn<TextWithEntities()> title() const;
rpl::producer<TextWithEntities> title() const;
QString shortName() const;
void install();
@ -113,7 +114,7 @@ void StickerSetBox::Show(DocumentData *document) {
}
void StickerSetBox::prepare() {
setTitle(langFactory(lng_contacts_loading));
setTitle(tr::lng_contacts_loading());
_inner = setInnerWidget(object_ptr<Inner>(this, _set), st::stickersScroll);
Auth().data().stickersUpdated(
@ -519,18 +520,15 @@ bool StickerSetBox::Inner::official() const {
return _loaded && _setShortName.isEmpty();
}
Fn<TextWithEntities()> StickerSetBox::Inner::title() const {
auto text = TextWithEntities { _setTitle };
if (_loaded) {
if (_pack.isEmpty()) {
return [] { return TextWithEntities { lang(lng_attach_failed), EntitiesInText() }; };
} else {
TextUtilities::ParseEntities(text, TextParseMentions);
}
} else {
return [] { return TextWithEntities { lang(lng_contacts_loading), EntitiesInText() }; };
rpl::producer<TextWithEntities> StickerSetBox::Inner::title() const {
if (!_loaded) {
return tr::lng_contacts_loading() | Ui::Text::ToWithEntities();
} else if (_pack.isEmpty()) {
return tr::lng_attach_failed() | Ui::Text::ToWithEntities();
}
return [text] { return text; };
auto text = TextWithEntities{ _setTitle };
TextUtilities::ParseEntities(text, TextParseMentions);
return rpl::single(text);
}
QString StickerSetBox::Inner::shortName() const {

View File

@ -255,12 +255,12 @@ void StickersBox::prepare() {
if (_tabs) {
Local::readArchivedStickers();
} else {
setTitle(langFactory(lng_stickers_group_set));
setTitle(tr::lng_stickers_group_set());
}
} else if (_section == Section::Archived) {
requestArchivedSets();
} else if (_section == Section::Attached) {
setTitle(langFactory(lng_stickers_attached_sets));
setTitle(tr::lng_stickers_attached_sets());
}
if (_tabs) {
if (Auth().data().archivedStickerSetsOrder().isEmpty()) {

View File

@ -42,7 +42,7 @@ void UsernameBox::prepare() {
? QString()
: lang(lng_username_available);
setTitle(langFactory(lng_username_title));
setTitle(tr::lng_username_title());
addButton(langFactory(lng_settings_save), [=] { save(); });
addButton(langFactory(lng_cancel), [=] { closeBox(); });

View File

@ -224,7 +224,7 @@ void BoxController::prepare() {
}
});
delegate()->peerListSetTitle(langFactory(lng_call_box_title));
delegate()->peerListSetTitle(tr::lng_call_box_title());
setDescriptionText(lang(lng_contacts_loading));
delegate()->peerListRefreshRows();

View File

@ -48,7 +48,7 @@ DebugInfoBox::DebugInfoBox(QWidget*, base::weak_ptr<Call> call)
}
void DebugInfoBox::prepare() {
setTitle([] { return QString("Call Debug"); });
setTitle(rpl::single(qsl("Call Debug")));
addButton(langFactory(lng_close), [this] { closeBox(); });
_text = setInnerWidget(

View File

@ -657,7 +657,7 @@ ManageSetsBox::ManageSetsBox(QWidget*) {
void ManageSetsBox::prepare() {
const auto inner = setInnerWidget(object_ptr<Inner>(this));
setTitle(langFactory(lng_emoji_manage_sets));
setTitle(tr::lng_emoji_manage_sets());
addButton(langFactory(lng_close), [=] { closeBox(); });

View File

@ -157,10 +157,9 @@ void EditLinkBox::prepare() {
}
});
const auto title = url->getLastText().isEmpty()
? lng_formatting_link_create_title
: lng_formatting_link_edit_title;
setTitle(langFactory(title));
setTitle(url->getLastText().isEmpty()
? tr::lng_formatting_link_create_title()
: tr::lng_formatting_link_edit_title());
addButton(langFactory(lng_formatting_link_create), submit);
addButton(langFactory(lng_cancel), [=] { closeBox(); });

View File

@ -62,7 +62,7 @@ SearchFromController::SearchFromController(
void SearchFromController::prepare() {
ParticipantsBoxController::prepare();
delegate()->peerListSetTitle(langFactory(lng_search_messages_from));
delegate()->peerListSetTitle(tr::lng_search_messages_from());
}
void SearchFromController::rowClicked(not_null<PeerListRow*> row) {

View File

@ -41,7 +41,7 @@ SuggestBox::SuggestBox(QWidget*) {
}
void SuggestBox::prepare() {
setTitle(langFactory(lng_export_suggest_title));
setTitle(tr::lng_export_suggest_title());
addButton(langFactory(lng_box_ok), [=] {
closeBox();

View File

@ -384,7 +384,7 @@ FilterBox::FilterBox(QWidget*, not_null<ChannelData*> channel, const std::vector
}
void FilterBox::prepare() {
setTitle(langFactory(lng_admin_log_filter_title));
setTitle(tr::lng_admin_log_filter_title());
_inner = setInnerWidget(object_ptr<Inner>(this, _channel, _admins, _initialFilter, [this] { refreshButtons(); }));
_inner->resizeToWidth(st::boxWideWidth);

View File

@ -83,7 +83,7 @@ std::unique_ptr<PeerListRow> ListController::createRow(
void ListController::prepare() {
setSearchNoResultsText(lang(lng_bot_groups_not_found));
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
delegate()->peerListSetTitle(langFactory(lng_profile_common_groups_section));
delegate()->peerListSetTitle(tr::lng_profile_common_groups_section());
}
void ListController::loadMoreRows() {
@ -240,7 +240,7 @@ object_ptr<InnerWidget::ListWidget> InnerWidget::setupList(
return result;
}
void InnerWidget::peerListSetTitle(Fn<QString()> title) {
void InnerWidget::peerListSetTitle(rpl::producer<QString> title) {
}
void InnerWidget::peerListSetAdditionalTitle(

View File

@ -48,7 +48,7 @@ private:
using ListWidget = PeerListContent;
// PeerListContentDelegate interface.
void peerListSetTitle(Fn<QString()> title) override;
void peerListSetTitle(rpl::producer<QString> title) override;
void peerListSetAdditionalTitle(
Fn<QString()> title) override;
bool peerListIsRowSelected(not_null<PeerData*> peer) override;

View File

@ -409,7 +409,7 @@ void Members::visibleTopBottomUpdated(
setChildVisibleTopBottom(_list, visibleTop, visibleBottom);
}
void Members::peerListSetTitle(Fn<QString()> title) {
void Members::peerListSetTitle(rpl::producer<QString> title) {
}
void Members::peerListSetAdditionalTitle(

View File

@ -59,7 +59,7 @@ private:
using ListWidget = PeerListContent;
// PeerListContentDelegate interface.
void peerListSetTitle(Fn<QString()> title) override;
void peerListSetTitle(rpl::producer<QString> title) override;
void peerListSetAdditionalTitle(
Fn<QString()> title) override;
bool peerListIsRowSelected(not_null<PeerData*> peer) override;

View File

@ -71,7 +71,7 @@ ConfirmSwitchBox::ConfirmSwitchBox(
}
void ConfirmSwitchBox::prepare() {
setTitle(langFactory(lng_language_switch_title));
setTitle(tr::lng_language_switch_title());
const auto text = (_official
? lng_language_switch_about_official__rich
@ -113,7 +113,7 @@ NotReadyBox::NotReadyBox(
}
void NotReadyBox::prepare() {
setTitle(langFactory(lng_language_not_ready_title));
setTitle(tr::lng_language_not_ready_title());
const auto text = lng_language_not_ready_about__rich(
lt_lang_name,

View File

@ -31,7 +31,7 @@ class VerifyBox : public BoxContent {
public:
VerifyBox(
QWidget*,
const QString &title,
rpl::producer<QString> title,
const QString &text,
int codeLength,
Fn<void(QString code)> submit,
@ -55,7 +55,7 @@ private:
rpl::producer<QString> error,
rpl::producer<QString> resent);
QString _title;
rpl::producer<QString> _title;
Fn<void()> _submit;
QPointer<SentCodeField> _code;
QPointer<Ui::VerticalLayout> _content;
@ -64,7 +64,7 @@ private:
VerifyBox::VerifyBox(
QWidget*,
const QString &title,
rpl::producer<QString> title,
const QString &text,
int codeLength,
Fn<void(QString code)> submit,
@ -72,7 +72,7 @@ VerifyBox::VerifyBox(
rpl::producer<QString> call,
rpl::producer<QString> error,
rpl::producer<QString> resent)
: _title(title) {
: _title(std::move(title)) {
setupControls(
text,
codeLength,
@ -185,7 +185,7 @@ void VerifyBox::setInnerFocus() {
}
void VerifyBox::prepare() {
setTitle([=] { return _title; });
setTitle(std::move(_title));
addButton(langFactory(lng_change_phone_new_submit), _submit);
addButton(langFactory(lng_cancel), [=] { closeBox(); });
@ -391,7 +391,7 @@ object_ptr<BoxContent> VerifyPhoneBox(
rpl::producer<QString> call,
rpl::producer<QString> error) {
return Box<VerifyBox>(
lang(lng_passport_phone_title),
tr::lng_passport_phone_title(),
lng_passport_confirm_phone(lt_phone, App::formatPhone(phone)),
codeLength,
submit,
@ -409,7 +409,7 @@ object_ptr<BoxContent> VerifyEmailBox(
rpl::producer<QString> error,
rpl::producer<QString> resent) {
return Box<VerifyBox>(
lang(lng_passport_email_title),
tr::lng_passport_email_title(),
lng_passport_confirm_email(lt_email, email),
codeLength,
submit,

View File

@ -35,7 +35,7 @@ class RequestTypeBox : public BoxContent {
public:
RequestTypeBox(
QWidget*,
const QString &title,
rpl::producer<QString> title,
const QString &about,
std::vector<QString> labels,
Fn<void(int index)> submit);
@ -49,7 +49,7 @@ private:
std::vector<QString> labels,
Fn<void(int index)> submit);
QString _title;
rpl::producer<QString> _title;
Fn<void()> _submit;
int _height = 0;
@ -79,16 +79,16 @@ private:
RequestTypeBox::RequestTypeBox(
QWidget*,
const QString &title,
rpl::producer<QString> title,
const QString &about,
std::vector<QString> labels,
Fn<void(int index)> submit)
: _title(title) {
: _title(std::move(title)) {
setupControls(about, std::move(labels), submit);
}
void RequestTypeBox::prepare() {
setTitle([=] { return _title; });
setTitle(std::move(_title));
addButton(langFactory(lng_passport_upload_document), _submit);
addButton(langFactory(lng_cancel), [=] { closeBox(); });
setDimensions(st::boxWidth, _height);
@ -680,7 +680,7 @@ object_ptr<BoxContent> RequestIdentityType(
Fn<void(int index)> submit,
std::vector<QString> labels) {
return Box<RequestTypeBox>(
lang(lng_passport_identity_title),
tr::lng_passport_identity_title(),
lang(lng_passport_identity_about),
std::move(labels),
submit);
@ -690,7 +690,7 @@ object_ptr<BoxContent> RequestAddressType(
Fn<void(int index)> submit,
std::vector<QString> labels) {
return Box<RequestTypeBox>(
lang(lng_passport_address_title),
tr::lng_passport_address_title(),
lang(lng_passport_address_about),
std::move(labels),
submit);

View File

@ -106,6 +106,10 @@ public:
return _implementation ? _implementation(consumer) : lifetime();
}
bool empty() const {
return !_implementation;
}
private:
std::function<lifetime(const consumer_type<type_erased_handlers<Value, Error>> &)> _implementation;
@ -439,7 +443,7 @@ public:
}
explicit operator bool() const {
return (this->_generator != nullptr);
return !this->_generator.empty();
}
};

View File

@ -131,7 +131,7 @@ void Calls::setupContent() {
}
});
Ui::show(Box<SingleChoiceBox>(
lng_settings_call_output_device,
tr::lng_settings_call_output_device(),
options,
currentOption,
save));
@ -209,7 +209,7 @@ void Calls::setupContent() {
}
});
Ui::show(Box<SingleChoiceBox>(
lng_settings_call_input_device,
tr::lng_settings_call_input_device(),
options,
currentOption,
save));

View File

@ -66,7 +66,7 @@ private:
};
void BlockUserBoxController::prepareViewHook() {
delegate()->peerListSetTitle(langFactory(lng_blocked_list_add_title));
delegate()->peerListSetTitle(tr::lng_blocked_list_add_title());
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserIsBlocked, [this](const Notify::PeerUpdate &update) {
if (auto user = update.peer->asUser()) {
if (auto row = delegate()->peerListFindRow(user->id)) {
@ -154,7 +154,7 @@ AdminLog::OwnedItem GenerateForwardedItem(
} // namespace
void BlockedBoxController::prepare() {
delegate()->peerListSetTitle(langFactory(lng_blocked_list_title));
delegate()->peerListSetTitle(tr::lng_blocked_list_title());
setDescriptionText(lang(lng_contacts_loading));
delegate()->peerListRefreshRows();
@ -311,8 +311,8 @@ MTPInputPrivacyKey PhoneNumberPrivacyController::apiKey() {
return MTP_inputPrivacyKeyPhoneNumber();
}
QString PhoneNumberPrivacyController::title() {
return lang(lng_edit_privacy_phone_number_title);
rpl::producer<QString> PhoneNumberPrivacyController::title() {
return tr::lng_edit_privacy_phone_number_title();
}
rpl::producer<QString> PhoneNumberPrivacyController::optionsTitleKey() {
@ -334,10 +334,11 @@ rpl::producer<QString> PhoneNumberPrivacyController::exceptionButtonTextKey(
Unexpected("Invalid exception value.");
}
QString PhoneNumberPrivacyController::exceptionBoxTitle(Exception exception) {
rpl::producer<QString> PhoneNumberPrivacyController::exceptionBoxTitle(
Exception exception) {
switch (exception) {
case Exception::Always: return lang(lng_edit_privacy_phone_number_always_title);
case Exception::Never: return lang(lng_edit_privacy_phone_number_never_title);
case Exception::Always: return tr::lng_edit_privacy_phone_number_always_title();
case Exception::Never: return tr::lng_edit_privacy_phone_number_never_title();
}
Unexpected("Invalid exception value.");
}
@ -354,8 +355,8 @@ MTPInputPrivacyKey LastSeenPrivacyController::apiKey() {
return MTP_inputPrivacyKeyStatusTimestamp();
}
QString LastSeenPrivacyController::title() {
return lang(lng_edit_privacy_lastseen_title);
rpl::producer<QString> LastSeenPrivacyController::title() {
return tr::lng_edit_privacy_lastseen_title();
}
rpl::producer<QString> LastSeenPrivacyController::optionsTitleKey() {
@ -377,10 +378,11 @@ rpl::producer<QString> LastSeenPrivacyController::exceptionButtonTextKey(
Unexpected("Invalid exception value.");
}
QString LastSeenPrivacyController::exceptionBoxTitle(Exception exception) {
rpl::producer<QString> LastSeenPrivacyController::exceptionBoxTitle(
Exception exception) {
switch (exception) {
case Exception::Always: return lang(lng_edit_privacy_lastseen_always_title);
case Exception::Never: return lang(lng_edit_privacy_lastseen_never_title);
case Exception::Always: return tr::lng_edit_privacy_lastseen_always_title();
case Exception::Never: return tr::lng_edit_privacy_lastseen_never_title();
}
Unexpected("Invalid exception value.");
}
@ -419,8 +421,8 @@ MTPInputPrivacyKey GroupsInvitePrivacyController::apiKey() {
return MTP_inputPrivacyKeyChatInvite();
}
QString GroupsInvitePrivacyController::title() {
return lang(lng_edit_privacy_groups_title);
rpl::producer<QString> GroupsInvitePrivacyController::title() {
return tr::lng_edit_privacy_groups_title();
}
bool GroupsInvitePrivacyController::hasOption(Option option) {
@ -440,10 +442,11 @@ rpl::producer<QString> GroupsInvitePrivacyController::exceptionButtonTextKey(
Unexpected("Invalid exception value.");
}
QString GroupsInvitePrivacyController::exceptionBoxTitle(Exception exception) {
rpl::producer<QString> GroupsInvitePrivacyController::exceptionBoxTitle(
Exception exception) {
switch (exception) {
case Exception::Always: return lang(lng_edit_privacy_groups_always_title);
case Exception::Never: return lang(lng_edit_privacy_groups_never_title);
case Exception::Always: return tr::lng_edit_privacy_groups_always_title();
case Exception::Never: return tr::lng_edit_privacy_groups_never_title();
}
Unexpected("Invalid exception value.");
}
@ -461,8 +464,8 @@ MTPInputPrivacyKey CallsPrivacyController::apiKey() {
return MTP_inputPrivacyKeyPhoneCall();
}
QString CallsPrivacyController::title() {
return lang(lng_edit_privacy_calls_title);
rpl::producer<QString> CallsPrivacyController::title() {
return tr::lng_edit_privacy_calls_title();
}
rpl::producer<QString> CallsPrivacyController::optionsTitleKey() {
@ -478,10 +481,11 @@ rpl::producer<QString> CallsPrivacyController::exceptionButtonTextKey(
Unexpected("Invalid exception value.");
}
QString CallsPrivacyController::exceptionBoxTitle(Exception exception) {
rpl::producer<QString> CallsPrivacyController::exceptionBoxTitle(
Exception exception) {
switch (exception) {
case Exception::Always: return lang(lng_edit_privacy_calls_always_title);
case Exception::Never: return lang(lng_edit_privacy_calls_never_title);
case Exception::Always: return tr::lng_edit_privacy_calls_always_title();
case Exception::Never: return tr::lng_edit_privacy_calls_never_title();
}
Unexpected("Invalid exception value.");
}
@ -516,8 +520,8 @@ MTPInputPrivacyKey CallsPeer2PeerPrivacyController::apiKey() {
return MTP_inputPrivacyKeyPhoneP2P();
}
QString CallsPeer2PeerPrivacyController::title() {
return lang(lng_edit_privacy_calls_p2p_title);
rpl::producer<QString> CallsPeer2PeerPrivacyController::title() {
return tr::lng_edit_privacy_calls_p2p_title();
}
rpl::producer<QString> CallsPeer2PeerPrivacyController::optionsTitleKey() {
@ -547,10 +551,11 @@ rpl::producer<QString> CallsPeer2PeerPrivacyController::exceptionButtonTextKey(
Unexpected("Invalid exception value.");
}
QString CallsPeer2PeerPrivacyController::exceptionBoxTitle(Exception exception) {
rpl::producer<QString> CallsPeer2PeerPrivacyController::exceptionBoxTitle(
Exception exception) {
switch (exception) {
case Exception::Always: return lang(lng_edit_privacy_calls_p2p_always_title);
case Exception::Never: return lang(lng_edit_privacy_calls_p2p_never_title);
case Exception::Always: return tr::lng_edit_privacy_calls_p2p_always_title();
case Exception::Never: return tr::lng_edit_privacy_calls_p2p_never_title();
}
Unexpected("Invalid exception value.");
}
@ -567,8 +572,8 @@ MTPInputPrivacyKey ForwardsPrivacyController::apiKey() {
return MTP_inputPrivacyKeyForwards();
}
QString ForwardsPrivacyController::title() {
return lang(lng_edit_privacy_forwards_title);
rpl::producer<QString> ForwardsPrivacyController::title() {
return tr::lng_edit_privacy_forwards_title();
}
rpl::producer<QString> ForwardsPrivacyController::optionsTitleKey() {
@ -588,10 +593,11 @@ rpl::producer<QString> ForwardsPrivacyController::exceptionButtonTextKey(
Unexpected("Invalid exception value.");
}
QString ForwardsPrivacyController::exceptionBoxTitle(Exception exception) {
rpl::producer<QString> ForwardsPrivacyController::exceptionBoxTitle(
Exception exception) {
switch (exception) {
case Exception::Always: return lang(lng_edit_privacy_forwards_always_title);
case Exception::Never: return lang(lng_edit_privacy_forwards_never_title);
case Exception::Always: return tr::lng_edit_privacy_forwards_always_title();
case Exception::Never: return tr::lng_edit_privacy_forwards_never_title();
}
Unexpected("Invalid exception value.");
}
@ -759,8 +765,8 @@ MTPInputPrivacyKey ProfilePhotoPrivacyController::apiKey() {
return MTP_inputPrivacyKeyProfilePhoto();
}
QString ProfilePhotoPrivacyController::title() {
return lang(lng_edit_privacy_profile_photo_title);
rpl::producer<QString> ProfilePhotoPrivacyController::title() {
return tr::lng_edit_privacy_profile_photo_title();
}
bool ProfilePhotoPrivacyController::hasOption(Option option) {
@ -780,10 +786,11 @@ rpl::producer<QString> ProfilePhotoPrivacyController::exceptionButtonTextKey(
Unexpected("Invalid exception value.");
}
QString ProfilePhotoPrivacyController::exceptionBoxTitle(Exception exception) {
rpl::producer<QString> ProfilePhotoPrivacyController::exceptionBoxTitle(
Exception exception) {
switch (exception) {
case Exception::Always: return lang(lng_edit_privacy_profile_photo_always_title);
case Exception::Never: return lang(lng_edit_privacy_profile_photo_never_title);
case Exception::Always: return tr::lng_edit_privacy_profile_photo_always_title();
case Exception::Never: return tr::lng_edit_privacy_profile_photo_never_title();
}
Unexpected("Invalid exception value.");
}

View File

@ -45,12 +45,12 @@ public:
Key key() override;
MTPInputPrivacyKey apiKey() override;
QString title() override;
rpl::producer<QString> title() override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
};
@ -63,12 +63,12 @@ public:
Key key() override;
MTPInputPrivacyKey apiKey() override;
QString title() override;
rpl::producer<QString> title() override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
void confirmSave(
@ -85,12 +85,12 @@ public:
Key key() override;
MTPInputPrivacyKey apiKey() override;
QString title() override;
rpl::producer<QString> title() override;
bool hasOption(Option option) override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
};
@ -103,11 +103,11 @@ public:
Key key() override;
MTPInputPrivacyKey apiKey() override;
QString title() override;
rpl::producer<QString> title() override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
object_ptr<Ui::RpWidget> setupBelowWidget(
@ -123,13 +123,13 @@ public:
Key key() override;
MTPInputPrivacyKey apiKey() override;
QString title() override;
rpl::producer<QString> title() override;
rpl::producer<QString> optionsTitleKey() override;
LangKey optionLabelKey(EditPrivacyBox::Option option) override;
rpl::producer<QString> warning() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
};
@ -144,12 +144,12 @@ public:
Key key() override;
MTPInputPrivacyKey apiKey() override;
QString title() override;
rpl::producer<QString> title() override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> warning() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
object_ptr<Ui::RpWidget> setupAboveWidget(
@ -176,12 +176,12 @@ public:
Key key() override;
MTPInputPrivacyKey apiKey() override;
QString title() override;
rpl::producer<QString> title() override;
bool hasOption(Option option) override;
rpl::producer<QString> optionsTitleKey() override;
rpl::producer<QString> exceptionButtonTextKey(
Exception exception) override;
QString exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionBoxTitle(Exception exception) override;
rpl::producer<QString> exceptionsDescription() override;
};

View File

@ -507,7 +507,7 @@ ConfirmContactBox::ConfirmContactBox(
}
void ConfirmContactBox::prepare() {
setTitle([] { return "Confirmation"; });
setTitle(rpl::single(qsl("Confirmation"))); // #TODO hard_lang
auto maxWidth = 0;
if (_comment) {

View File

@ -73,7 +73,7 @@ EditInfoBox::EditInfoBox(
}
void EditInfoBox::prepare() {
setTitle([] { return QString("Edit support information"); }); // #TODO hard_lang
setTitle(rpl::single(qsl("Edit support information"))); // #TODO hard_lang
const auto save = [=] {
const auto done = crl::guard(this, [=](bool success) {

View File

@ -230,7 +230,7 @@ QString CountrySelectBox::ISOByPhone(const QString &phone) {
}
void CountrySelectBox::prepare() {
setTitle(langFactory(lng_country_select));
setTitle(tr::lng_country_select());
_select->resizeToWidth(st::boxWidth);
_select->setQueryChangedCallback([=](const QString &query) {

View File

@ -568,7 +568,7 @@ ThemeExportBox::ThemeExportBox(QWidget*, const QByteArray &paletteContent, const
}
void ThemeExportBox::prepare() {
setTitle(langFactory(lng_theme_editor_background_image));
setTitle(tr::lng_theme_editor_background_image());
addButton(langFactory(lng_theme_editor_export), [this] { exportTheme(); });
addButton(langFactory(lng_cancel), [this] { closeBox(); });

View File

@ -215,7 +215,7 @@ rpl::producer<> TermsBox::cancelClicks() const {
}
void TermsBox::prepare() {
setTitle(langFactory(lng_terms_header));
setTitle(tr::lng_terms_header());
auto check = std::make_unique<Ui::CheckView>(st::defaultCheck, false);
const auto ageCheck = check.get();

View File

@ -742,9 +742,9 @@ void PeerMenuBlockUserBox(
box->addSkip(st::boxLittleSkip);
box->setTitle([=] {
return lng_blocked_list_confirm_title(lt_name, name);
});
box->setTitle(tr::lng_blocked_list_confirm_title(
lt_name,
rpl::single(name)));
box->addButton(langFactory(lng_blocked_list_confirm_ok), [=] {
const auto reportChecked = report && report->checked();

@ -1 +1 @@
Subproject commit eeeb4edb2a087c3f8175dafafcad330864d3efc0
Subproject commit a3fac9db920b167a5f91d678ee7968f100f6fe51