From d1d98c3bb1a5d55e281011d7316c1d0e92b973e0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 18 Jun 2019 17:00:55 +0200 Subject: [PATCH] Use tr:: instead of langFactory in box titles. --- Telegram/SourceFiles/boxes/about_box.cpp | 2 +- Telegram/SourceFiles/boxes/abstract_box.cpp | 22 +++-- Telegram/SourceFiles/boxes/abstract_box.h | 17 ++-- .../SourceFiles/boxes/add_contact_box.cpp | 11 ++- .../SourceFiles/boxes/auto_download_box.cpp | 2 +- Telegram/SourceFiles/boxes/auto_lock_box.cpp | 2 +- Telegram/SourceFiles/boxes/background_box.cpp | 2 +- .../boxes/background_preview_box.cpp | 2 +- .../SourceFiles/boxes/change_phone_box.cpp | 6 +- .../SourceFiles/boxes/confirm_phone_box.cpp | 2 +- Telegram/SourceFiles/boxes/connection_box.cpp | 4 +- .../SourceFiles/boxes/create_poll_box.cpp | 2 +- .../SourceFiles/boxes/download_path_box.cpp | 2 +- Telegram/SourceFiles/boxes/edit_color_box.cpp | 2 +- .../SourceFiles/boxes/edit_privacy_box.cpp | 18 ++--- Telegram/SourceFiles/boxes/edit_privacy_box.h | 4 +- Telegram/SourceFiles/boxes/language_box.cpp | 2 +- .../SourceFiles/boxes/local_storage_box.cpp | 2 +- .../SourceFiles/boxes/mute_settings_box.cpp | 2 +- Telegram/SourceFiles/boxes/passcode_box.cpp | 20 +++-- Telegram/SourceFiles/boxes/peer_list_box.h | 4 +- .../boxes/peer_list_controllers.cpp | 10 +-- .../boxes/peers/add_participants_box.cpp | 12 +-- .../boxes/peers/edit_contact_box.cpp | 6 +- .../boxes/peers/edit_linked_chat_box.cpp | 6 +- .../boxes/peers/edit_participant_box.cpp | 10 +-- .../boxes/peers/edit_participants_box.cpp | 12 +-- .../edit_peer_history_visibility_box.cpp | 2 +- .../boxes/peers/edit_peer_info_box.cpp | 6 +- .../boxes/peers/edit_peer_permissions_box.cpp | 2 +- .../boxes/peers/edit_peer_type_box.cpp | 10 +-- Telegram/SourceFiles/boxes/rate_call_box.cpp | 2 +- Telegram/SourceFiles/boxes/report_box.cpp | 12 +-- .../boxes/self_destruction_box.cpp | 2 +- Telegram/SourceFiles/boxes/sessions_box.cpp | 2 +- Telegram/SourceFiles/boxes/share_box.cpp | 2 +- .../SourceFiles/boxes/single_choice_box.cpp | 6 +- .../SourceFiles/boxes/single_choice_box.h | 4 +- .../SourceFiles/boxes/sticker_set_box.cpp | 24 +++--- Telegram/SourceFiles/boxes/stickers_box.cpp | 4 +- Telegram/SourceFiles/boxes/username_box.cpp | 2 +- .../calls/calls_box_controller.cpp | 2 +- Telegram/SourceFiles/calls/calls_top_bar.cpp | 2 +- .../chat_helpers/emoji_sets_manager.cpp | 2 +- .../chat_helpers/message_field.cpp | 7 +- .../dialogs_search_from_controllers.cpp | 2 +- .../view/export_view_panel_controller.cpp | 2 +- .../admin_log/history_admin_log_filter.cpp | 2 +- .../info_common_groups_inner_widget.cpp | 4 +- .../info_common_groups_inner_widget.h | 2 +- .../info/profile/info_profile_members.cpp | 2 +- .../info/profile/info_profile_members.h | 2 +- .../SourceFiles/lang/lang_cloud_manager.cpp | 4 +- .../passport/passport_panel_edit_contact.cpp | 14 ++-- .../passport/passport_panel_edit_document.cpp | 14 ++-- Telegram/SourceFiles/rpl/producer.h | 6 +- .../SourceFiles/settings/settings_calls.cpp | 4 +- .../settings/settings_privacy_controllers.cpp | 81 ++++++++++--------- .../settings/settings_privacy_controllers.h | 28 +++---- .../support/support_autocomplete.cpp | 2 +- .../SourceFiles/support/support_helper.cpp | 2 +- Telegram/SourceFiles/ui/countryinput.cpp | 2 +- .../window/themes/window_theme_editor.cpp | 2 +- .../window/window_lock_widgets.cpp | 2 +- .../SourceFiles/window/window_peer_menu.cpp | 6 +- Telegram/ThirdParty/qtlottie | 2 +- 66 files changed, 234 insertions(+), 230 deletions(-) diff --git a/Telegram/SourceFiles/boxes/about_box.cpp b/Telegram/SourceFiles/boxes/about_box.cpp index dab1da72db..4ca224c911 100644 --- a/Telegram/SourceFiles/boxes/about_box.cpp +++ b/Telegram/SourceFiles/boxes/about_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/abstract_box.cpp b/Telegram/SourceFiles/boxes/abstract_box.cpp index 19bcc6ab1d..2dc962386b 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.cpp +++ b/Telegram/SourceFiles/boxes/abstract_box.cpp @@ -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 title) { + getDelegate()->setTitle(std::move(title) | Ui::Text::ToWithEntities()); +} + QPointer BoxContent::addButton( Fn textFactory, Fn clickCallback) { @@ -310,18 +315,10 @@ void AbstractBox::parentResized() { update(); } -void AbstractBox::setTitle(Fn 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 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(); }); } diff --git a/Telegram/SourceFiles/boxes/abstract_box.h b/Telegram/SourceFiles/boxes/abstract_box.h index d979fdd1bf..71317a03c5 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.h +++ b/Telegram/SourceFiles/boxes/abstract_box.h @@ -30,7 +30,7 @@ class BoxContent; class BoxContentDelegate { public: virtual void setLayerType(bool layerType) = 0; - virtual void setTitle(Fn titleFactory) = 0; + virtual void setTitle(rpl::producer title) = 0; virtual void setAdditionalTitle(Fn additionalFactory) = 0; virtual void setCloseByOutsideClick(bool close) = 0; @@ -81,15 +81,9 @@ public: getDelegate()->closeBox(); } - void setTitle(Fn titleFactory) { - if (titleFactory) { - getDelegate()->setTitle([titleFactory] { return TextWithEntities { titleFactory(), EntitiesInText() }; }); - } else { - getDelegate()->setTitle(Fn()); - } - } - void setTitle(Fn titleFactory) { - getDelegate()->setTitle(std::move(titleFactory)); + void setTitle(rpl::producer title); + void setTitle(rpl::producer title) { + getDelegate()->setTitle(std::move(title)); } void setAdditionalTitle(Fn additional) { getDelegate()->setAdditionalTitle(std::move(additional)); @@ -256,7 +250,7 @@ public: void parentResized() override; void setLayerType(bool layerType) override; - void setTitle(Fn titleFactory) override; + void setTitle(rpl::producer title) override; void setAdditionalTitle(Fn additionalFactory) override; void showBox( object_ptr box, @@ -307,7 +301,6 @@ protected: private: void paintAdditionalTitle(Painter &p); void updateTitlePosition(); - void refreshTitle(); void refreshAdditionalTitle(); void refreshLang(); diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 9a9d012ea2..2842a43b3a 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -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 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(); diff --git a/Telegram/SourceFiles/boxes/auto_download_box.cpp b/Telegram/SourceFiles/boxes/auto_download_box.cpp index f9b70c0f38..4f8b42a0c1 100644 --- a/Telegram/SourceFiles/boxes/auto_download_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_download_box.cpp @@ -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) { diff --git a/Telegram/SourceFiles/boxes/auto_lock_box.cpp b/Telegram/SourceFiles/boxes/auto_lock_box.cpp index cc04f16126..0afc15b98e 100644 --- a/Telegram/SourceFiles/boxes/auto_lock_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_lock_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 6aeff5f355..4f48f08367 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 7eb0e6c652..3ca1f73e22 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -407,7 +407,7 @@ not_null 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(); }); diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 24e19d28cb..c29b17ef68 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -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(lang(lng_change_phone_warning), [] { Ui::show(Box()); diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp index b0156e2b9d..0adaa0f257 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index 5c083999dd..2fe3826fd4 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -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); diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index dd9cc22aaf..6f89b93892 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -725,7 +725,7 @@ object_ptr CreatePollBox::setupContent() { } void CreatePollBox::prepare() { - setTitle(langFactory(lng_polls_create_title)); + setTitle(tr::lng_polls_create_title()); const auto inner = setInnerWidget(setupContent()); diff --git a/Telegram/SourceFiles/boxes/download_path_box.cpp b/Telegram/SourceFiles/boxes/download_path_box.cpp index 48cbfd0436..27fdff328a 100644 --- a/Telegram/SourceFiles/boxes/download_path_box.cpp +++ b/Telegram/SourceFiles/boxes/download_path_box.cpp @@ -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); }); diff --git a/Telegram/SourceFiles/boxes/edit_color_box.cpp b/Telegram/SourceFiles/boxes/edit_color_box.cpp index f6625a5b75..99e7a346f4 100644 --- a/Telegram/SourceFiles/boxes/edit_color_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_color_box.cpp @@ -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(); }; diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index 8af1f0f4c3..4ed9dc72e0 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -32,7 +32,9 @@ namespace { class PrivacyExceptionsBoxController : public ChatsListBoxController { public: - PrivacyExceptionsBoxController(Fn titleFactory, const std::vector> &selected); + PrivacyExceptionsBoxController( + rpl::producer title, + const std::vector> &selected); void rowClicked(not_null row) override; std::vector> getResult() const; @@ -42,20 +44,20 @@ protected: std::unique_ptr createRow(not_null history) override; private: - Fn _titleFactory; + rpl::producer _title; std::vector> _selected; }; PrivacyExceptionsBoxController::PrivacyExceptionsBoxController( - Fn titleFactory, + rpl::producer title, const std::vector> &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 done) { auto controller = std::make_unique( - crl::guard(this, [=] { - return _controller->exceptionBoxTitle(exception); - }), + _controller->exceptionBoxTitle(exception), exceptions(exception)); auto initBox = [=, controller = controller.get()]( not_null 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(this); const auto content = wrap.data(); diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.h b/Telegram/SourceFiles/boxes/edit_privacy_box.h index 0b6f96cf29..2784d9e981 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.h +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.h @@ -39,7 +39,7 @@ public: [[nodiscard]] virtual Key key() = 0; [[nodiscard]] virtual MTPInputPrivacyKey apiKey() = 0; - [[nodiscard]] virtual QString title() = 0; + [[nodiscard]] virtual rpl::producer title() = 0; [[nodiscard]] virtual bool hasOption(Option option) { return true; } @@ -50,7 +50,7 @@ public: } [[nodiscard]] virtual rpl::producer exceptionButtonTextKey( Exception exception) = 0; - [[nodiscard]] virtual QString exceptionBoxTitle( + [[nodiscard]] virtual rpl::producer exceptionBoxTitle( Exception exception) = 0; [[nodiscard]] virtual auto exceptionsDescription() -> rpl::producer = 0; diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index 3b29e98b15..6cf02dbe6f 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -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(); diff --git a/Telegram/SourceFiles/boxes/local_storage_box.cpp b/Telegram/SourceFiles/boxes/local_storage_box.cpp index ab788129bf..84c90b5f9e 100644 --- a/Telegram/SourceFiles/boxes/local_storage_box.cpp +++ b/Telegram/SourceFiles/boxes/local_storage_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.cpp b/Telegram/SourceFiles/boxes/mute_settings_box.cpp index 1a8b0239e7..be96723ead 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.cpp +++ b/Telegram/SourceFiles/boxes/mute_settings_box.cpp @@ -26,7 +26,7 @@ MuteSettingsBox::MuteSettingsBox(QWidget *parent, not_null peer) } void MuteSettingsBox::prepare() { - setTitle(langFactory(lng_disable_notifications_from_tray)); + setTitle(tr::lng_disable_notifications_from_tray()); auto y = 0; object_ptr info(this, st::boxLabel); diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index c2f109ba9c..a59aa45d24 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 594aee6238..e5992f9d16 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -225,7 +225,7 @@ struct PeerListState; class PeerListDelegate { public: - virtual void peerListSetTitle(Fn title) = 0; + virtual void peerListSetTitle(rpl::producer title) = 0; virtual void peerListSetAdditionalTitle(Fn title) = 0; virtual void peerListSetDescription(object_ptr description) = 0; virtual void peerListSetSearchLoading(object_ptr loading) = 0; @@ -755,7 +755,7 @@ public: std::unique_ptr controller, Fn)> init); - void peerListSetTitle(Fn title) override { + void peerListSetTitle(rpl::producer title) override { setTitle(std::move(title)); } void peerListSetAdditionalTitle( diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index db0439c641..c687751a55 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -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 row) { diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index a6d05e4aa1..a82c42b605 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -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 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)); diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index 6f6f3c2a6e..2f746204ce 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp index ea9b9ce737..b0dfdec4c8 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp @@ -285,9 +285,9 @@ object_ptr 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( diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index aa5a62b4fb..a7e73e4a9a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -69,7 +69,7 @@ void TransferPasswordError( not_null box, not_null 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(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(this), diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 74bd2a8a7e..a52a29dc5f 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1012,18 +1012,18 @@ rpl::producer 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)); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.cpp index 30c5172814..9286c84adf 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_history_visibility_box.cpp @@ -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()); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index e874dfb1cb..98f4546aa5 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 641b66746b..d640274aac 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -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(this)); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index 7b4a00c60e..de0f936c8f 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -58,12 +58,12 @@ public: QString getUsernameInput(); void setFocusUsername(); - LangKey getTitle() { + rpl::producer 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), [=] { diff --git a/Telegram/SourceFiles/boxes/rate_call_box.cpp b/Telegram/SourceFiles/boxes/rate_call_box.cpp index 056ecd3bbf..f0c2f8d9b8 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.cpp +++ b/Telegram/SourceFiles/boxes/rate_call_box.cpp @@ -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) { diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index d61f4545b1..0c4108c912 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -34,17 +34,17 @@ ReportBox::ReportBox(QWidget*, not_null 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(); }); diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index 13083aeb6b..d4a31639bd 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -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( this, diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index 00726925da..410865a3cf 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 582654ac21..50f3f014d7 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -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( diff --git a/Telegram/SourceFiles/boxes/single_choice_box.cpp b/Telegram/SourceFiles/boxes/single_choice_box.cpp index be010700b0..90c69805ae 100644 --- a/Telegram/SourceFiles/boxes/single_choice_box.cpp +++ b/Telegram/SourceFiles/boxes/single_choice_box.cpp @@ -17,18 +17,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL SingleChoiceBox::SingleChoiceBox( QWidget*, - LangKey title, + rpl::producer title, const std::vector &optionTexts, int initialSelection, Fn 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(); }); diff --git a/Telegram/SourceFiles/boxes/single_choice_box.h b/Telegram/SourceFiles/boxes/single_choice_box.h index b61e49739d..194d401357 100644 --- a/Telegram/SourceFiles/boxes/single_choice_box.h +++ b/Telegram/SourceFiles/boxes/single_choice_box.h @@ -20,7 +20,7 @@ class SingleChoiceBox : public BoxContent { public: SingleChoiceBox( QWidget*, - LangKey title, + rpl::producer title, const std::vector &optionTexts, int initialSelection, Fn callback); @@ -29,7 +29,7 @@ protected: void prepare() override; private: - LangKey _title; + rpl::producer _title; std::vector _optionTexts; int _initialSelection = 0; Fn _callback; diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 05046a4830..8779ccfd15 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -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 title() const; + rpl::producer 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(this, _set), st::stickersScroll); Auth().data().stickersUpdated( @@ -519,18 +520,15 @@ bool StickerSetBox::Inner::official() const { return _loaded && _setShortName.isEmpty(); } -Fn 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 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 { diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 10b1118dc0..351f17e102 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -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()) { diff --git a/Telegram/SourceFiles/boxes/username_box.cpp b/Telegram/SourceFiles/boxes/username_box.cpp index 0c0dfc340b..5c80256f44 100644 --- a/Telegram/SourceFiles/boxes/username_box.cpp +++ b/Telegram/SourceFiles/boxes/username_box.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 43da316577..bd83cb88bd 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -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(); diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index 460abe3808..9f727de89c 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -48,7 +48,7 @@ DebugInfoBox::DebugInfoBox(QWidget*, base::weak_ptr call) } void DebugInfoBox::prepare() { - setTitle([] { return QString("Call Debug"); }); + setTitle(rpl::single(qsl("Call Debug"))); addButton(langFactory(lng_close), [this] { closeBox(); }); _text = setInnerWidget( diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index 3e77f5a28c..40a96e0ff1 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -657,7 +657,7 @@ ManageSetsBox::ManageSetsBox(QWidget*) { void ManageSetsBox::prepare() { const auto inner = setInnerWidget(object_ptr(this)); - setTitle(langFactory(lng_emoji_manage_sets)); + setTitle(tr::lng_emoji_manage_sets()); addButton(langFactory(lng_close), [=] { closeBox(); }); diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 56449ff978..efb90cbd84 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp b/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp index 6e110c08b7..421503c7c7 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_search_from_controllers.cpp @@ -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 row) { diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index 00850eca9a..80e45a8751 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -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(); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp index 697236c357..b87a23b9a5 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp @@ -384,7 +384,7 @@ FilterBox::FilterBox(QWidget*, not_null 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(this, _channel, _admins, _initialFilter, [this] { refreshButtons(); })); _inner->resizeToWidth(st::boxWideWidth); diff --git a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp index 64adf107f6..d86c459db9 100644 --- a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp +++ b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp @@ -83,7 +83,7 @@ std::unique_ptr 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::setupList( return result; } -void InnerWidget::peerListSetTitle(Fn title) { +void InnerWidget::peerListSetTitle(rpl::producer title) { } void InnerWidget::peerListSetAdditionalTitle( diff --git a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.h b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.h index 68b08951c6..37afd51c48 100644 --- a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.h +++ b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.h @@ -48,7 +48,7 @@ private: using ListWidget = PeerListContent; // PeerListContentDelegate interface. - void peerListSetTitle(Fn title) override; + void peerListSetTitle(rpl::producer title) override; void peerListSetAdditionalTitle( Fn title) override; bool peerListIsRowSelected(not_null peer) override; diff --git a/Telegram/SourceFiles/info/profile/info_profile_members.cpp b/Telegram/SourceFiles/info/profile/info_profile_members.cpp index e2ab05ef8a..a5703ac526 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_members.cpp @@ -409,7 +409,7 @@ void Members::visibleTopBottomUpdated( setChildVisibleTopBottom(_list, visibleTop, visibleBottom); } -void Members::peerListSetTitle(Fn title) { +void Members::peerListSetTitle(rpl::producer title) { } void Members::peerListSetAdditionalTitle( diff --git a/Telegram/SourceFiles/info/profile/info_profile_members.h b/Telegram/SourceFiles/info/profile/info_profile_members.h index 85cf56a1d1..96469fc3cc 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members.h +++ b/Telegram/SourceFiles/info/profile/info_profile_members.h @@ -59,7 +59,7 @@ private: using ListWidget = PeerListContent; // PeerListContentDelegate interface. - void peerListSetTitle(Fn title) override; + void peerListSetTitle(rpl::producer title) override; void peerListSetAdditionalTitle( Fn title) override; bool peerListIsRowSelected(not_null peer) override; diff --git a/Telegram/SourceFiles/lang/lang_cloud_manager.cpp b/Telegram/SourceFiles/lang/lang_cloud_manager.cpp index a4f2b204c9..cd7e61943a 100644 --- a/Telegram/SourceFiles/lang/lang_cloud_manager.cpp +++ b/Telegram/SourceFiles/lang/lang_cloud_manager.cpp @@ -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, diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp index f78c13cfec..849f226c6f 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp @@ -31,7 +31,7 @@ class VerifyBox : public BoxContent { public: VerifyBox( QWidget*, - const QString &title, + rpl::producer title, const QString &text, int codeLength, Fn submit, @@ -55,7 +55,7 @@ private: rpl::producer error, rpl::producer resent); - QString _title; + rpl::producer _title; Fn _submit; QPointer _code; QPointer _content; @@ -64,7 +64,7 @@ private: VerifyBox::VerifyBox( QWidget*, - const QString &title, + rpl::producer title, const QString &text, int codeLength, Fn submit, @@ -72,7 +72,7 @@ VerifyBox::VerifyBox( rpl::producer call, rpl::producer error, rpl::producer 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 VerifyPhoneBox( rpl::producer call, rpl::producer error) { return Box( - 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 VerifyEmailBox( rpl::producer error, rpl::producer resent) { return Box( - lang(lng_passport_email_title), + tr::lng_passport_email_title(), lng_passport_confirm_email(lt_email, email), codeLength, submit, diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp index 92d19d0cdd..082f89159a 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp @@ -35,7 +35,7 @@ class RequestTypeBox : public BoxContent { public: RequestTypeBox( QWidget*, - const QString &title, + rpl::producer title, const QString &about, std::vector labels, Fn submit); @@ -49,7 +49,7 @@ private: std::vector labels, Fn submit); - QString _title; + rpl::producer _title; Fn _submit; int _height = 0; @@ -79,16 +79,16 @@ private: RequestTypeBox::RequestTypeBox( QWidget*, - const QString &title, + rpl::producer title, const QString &about, std::vector labels, Fn 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 RequestIdentityType( Fn submit, std::vector labels) { return Box( - 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 RequestAddressType( Fn submit, std::vector labels) { return Box( - lang(lng_passport_address_title), + tr::lng_passport_address_title(), lang(lng_passport_address_about), std::move(labels), submit); diff --git a/Telegram/SourceFiles/rpl/producer.h b/Telegram/SourceFiles/rpl/producer.h index 339f3c746f..b00e677bfc 100644 --- a/Telegram/SourceFiles/rpl/producer.h +++ b/Telegram/SourceFiles/rpl/producer.h @@ -106,6 +106,10 @@ public: return _implementation ? _implementation(consumer) : lifetime(); } + bool empty() const { + return !_implementation; + } + private: std::function> &)> _implementation; @@ -439,7 +443,7 @@ public: } explicit operator bool() const { - return (this->_generator != nullptr); + return !this->_generator.empty(); } }; diff --git a/Telegram/SourceFiles/settings/settings_calls.cpp b/Telegram/SourceFiles/settings/settings_calls.cpp index 51be4c93f1..4e519fc333 100644 --- a/Telegram/SourceFiles/settings/settings_calls.cpp +++ b/Telegram/SourceFiles/settings/settings_calls.cpp @@ -131,7 +131,7 @@ void Calls::setupContent() { } }); Ui::show(Box( - lng_settings_call_output_device, + tr::lng_settings_call_output_device(), options, currentOption, save)); @@ -209,7 +209,7 @@ void Calls::setupContent() { } }); Ui::show(Box( - lng_settings_call_input_device, + tr::lng_settings_call_input_device(), options, currentOption, save)); diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index 2e443491fc..4ddfa1f38c 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -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 PhoneNumberPrivacyController::title() { + return tr::lng_edit_privacy_phone_number_title(); } rpl::producer PhoneNumberPrivacyController::optionsTitleKey() { @@ -334,10 +334,11 @@ rpl::producer PhoneNumberPrivacyController::exceptionButtonTextKey( Unexpected("Invalid exception value."); } -QString PhoneNumberPrivacyController::exceptionBoxTitle(Exception exception) { +rpl::producer 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 LastSeenPrivacyController::title() { + return tr::lng_edit_privacy_lastseen_title(); } rpl::producer LastSeenPrivacyController::optionsTitleKey() { @@ -377,10 +378,11 @@ rpl::producer LastSeenPrivacyController::exceptionButtonTextKey( Unexpected("Invalid exception value."); } -QString LastSeenPrivacyController::exceptionBoxTitle(Exception exception) { +rpl::producer 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 GroupsInvitePrivacyController::title() { + return tr::lng_edit_privacy_groups_title(); } bool GroupsInvitePrivacyController::hasOption(Option option) { @@ -440,10 +442,11 @@ rpl::producer GroupsInvitePrivacyController::exceptionButtonTextKey( Unexpected("Invalid exception value."); } -QString GroupsInvitePrivacyController::exceptionBoxTitle(Exception exception) { +rpl::producer 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 CallsPrivacyController::title() { + return tr::lng_edit_privacy_calls_title(); } rpl::producer CallsPrivacyController::optionsTitleKey() { @@ -478,10 +481,11 @@ rpl::producer CallsPrivacyController::exceptionButtonTextKey( Unexpected("Invalid exception value."); } -QString CallsPrivacyController::exceptionBoxTitle(Exception exception) { +rpl::producer 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 CallsPeer2PeerPrivacyController::title() { + return tr::lng_edit_privacy_calls_p2p_title(); } rpl::producer CallsPeer2PeerPrivacyController::optionsTitleKey() { @@ -547,10 +551,11 @@ rpl::producer CallsPeer2PeerPrivacyController::exceptionButtonTextKey( Unexpected("Invalid exception value."); } -QString CallsPeer2PeerPrivacyController::exceptionBoxTitle(Exception exception) { +rpl::producer 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 ForwardsPrivacyController::title() { + return tr::lng_edit_privacy_forwards_title(); } rpl::producer ForwardsPrivacyController::optionsTitleKey() { @@ -588,10 +593,11 @@ rpl::producer ForwardsPrivacyController::exceptionButtonTextKey( Unexpected("Invalid exception value."); } -QString ForwardsPrivacyController::exceptionBoxTitle(Exception exception) { +rpl::producer 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 ProfilePhotoPrivacyController::title() { + return tr::lng_edit_privacy_profile_photo_title(); } bool ProfilePhotoPrivacyController::hasOption(Option option) { @@ -780,10 +786,11 @@ rpl::producer ProfilePhotoPrivacyController::exceptionButtonTextKey( Unexpected("Invalid exception value."); } -QString ProfilePhotoPrivacyController::exceptionBoxTitle(Exception exception) { +rpl::producer 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."); } diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.h b/Telegram/SourceFiles/settings/settings_privacy_controllers.h index 8dfab6ed5a..a59b123665 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.h +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.h @@ -45,12 +45,12 @@ public: Key key() override; MTPInputPrivacyKey apiKey() override; - QString title() override; + rpl::producer title() override; rpl::producer optionsTitleKey() override; rpl::producer warning() override; rpl::producer exceptionButtonTextKey( Exception exception) override; - QString exceptionBoxTitle(Exception exception) override; + rpl::producer exceptionBoxTitle(Exception exception) override; rpl::producer exceptionsDescription() override; }; @@ -63,12 +63,12 @@ public: Key key() override; MTPInputPrivacyKey apiKey() override; - QString title() override; + rpl::producer title() override; rpl::producer optionsTitleKey() override; rpl::producer warning() override; rpl::producer exceptionButtonTextKey( Exception exception) override; - QString exceptionBoxTitle(Exception exception) override; + rpl::producer exceptionBoxTitle(Exception exception) override; rpl::producer exceptionsDescription() override; void confirmSave( @@ -85,12 +85,12 @@ public: Key key() override; MTPInputPrivacyKey apiKey() override; - QString title() override; + rpl::producer title() override; bool hasOption(Option option) override; rpl::producer optionsTitleKey() override; rpl::producer exceptionButtonTextKey( Exception exception) override; - QString exceptionBoxTitle(Exception exception) override; + rpl::producer exceptionBoxTitle(Exception exception) override; rpl::producer exceptionsDescription() override; }; @@ -103,11 +103,11 @@ public: Key key() override; MTPInputPrivacyKey apiKey() override; - QString title() override; + rpl::producer title() override; rpl::producer optionsTitleKey() override; rpl::producer exceptionButtonTextKey( Exception exception) override; - QString exceptionBoxTitle(Exception exception) override; + rpl::producer exceptionBoxTitle(Exception exception) override; rpl::producer exceptionsDescription() override; object_ptr setupBelowWidget( @@ -123,13 +123,13 @@ public: Key key() override; MTPInputPrivacyKey apiKey() override; - QString title() override; + rpl::producer title() override; rpl::producer optionsTitleKey() override; LangKey optionLabelKey(EditPrivacyBox::Option option) override; rpl::producer warning() override; rpl::producer exceptionButtonTextKey( Exception exception) override; - QString exceptionBoxTitle(Exception exception) override; + rpl::producer exceptionBoxTitle(Exception exception) override; rpl::producer exceptionsDescription() override; }; @@ -144,12 +144,12 @@ public: Key key() override; MTPInputPrivacyKey apiKey() override; - QString title() override; + rpl::producer title() override; rpl::producer optionsTitleKey() override; rpl::producer warning() override; rpl::producer exceptionButtonTextKey( Exception exception) override; - QString exceptionBoxTitle(Exception exception) override; + rpl::producer exceptionBoxTitle(Exception exception) override; rpl::producer exceptionsDescription() override; object_ptr setupAboveWidget( @@ -176,12 +176,12 @@ public: Key key() override; MTPInputPrivacyKey apiKey() override; - QString title() override; + rpl::producer title() override; bool hasOption(Option option) override; rpl::producer optionsTitleKey() override; rpl::producer exceptionButtonTextKey( Exception exception) override; - QString exceptionBoxTitle(Exception exception) override; + rpl::producer exceptionBoxTitle(Exception exception) override; rpl::producer exceptionsDescription() override; }; diff --git a/Telegram/SourceFiles/support/support_autocomplete.cpp b/Telegram/SourceFiles/support/support_autocomplete.cpp index 2bd6931de5..d9a4e46e0e 100644 --- a/Telegram/SourceFiles/support/support_autocomplete.cpp +++ b/Telegram/SourceFiles/support/support_autocomplete.cpp @@ -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) { diff --git a/Telegram/SourceFiles/support/support_helper.cpp b/Telegram/SourceFiles/support/support_helper.cpp index 49c45165e9..10f8f574bb 100644 --- a/Telegram/SourceFiles/support/support_helper.cpp +++ b/Telegram/SourceFiles/support/support_helper.cpp @@ -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) { diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index 06ec12ee18..1ef60d2f24 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -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) { diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index dba14f5bf6..dc67bfb359 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/window/window_lock_widgets.cpp b/Telegram/SourceFiles/window/window_lock_widgets.cpp index 7b01bb3797..89be814ad3 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.cpp +++ b/Telegram/SourceFiles/window/window_lock_widgets.cpp @@ -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(st::defaultCheck, false); const auto ageCheck = check.get(); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index eeaaead920..9fc2227818 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -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(); diff --git a/Telegram/ThirdParty/qtlottie b/Telegram/ThirdParty/qtlottie index eeeb4edb2a..a3fac9db92 160000 --- a/Telegram/ThirdParty/qtlottie +++ b/Telegram/ThirdParty/qtlottie @@ -1 +1 @@ -Subproject commit eeeb4edb2a087c3f8175dafafcad330864d3efc0 +Subproject commit a3fac9db920b167a5f91d678ee7968f100f6fe51