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

Use tr:: instead of langFactory and __rich.

This commit is contained in:
John Preston
2019-06-18 18:53:27 +02:00
parent d1d98c3bb1
commit a7c8feaecb
103 changed files with 699 additions and 628 deletions

View File

@@ -91,7 +91,7 @@ CodeWidget::CodeWidget(QWidget *parent, Widget::Data *data) : Step(parent, data)
_code->setDigitsCountMax(getData()->codeLength);
setErrorBelowLink(true);
setTitleText([text = App::formatPhone(getData()->phone)] { return text; });
setTitleText(rpl::single(App::formatPhone(getData()->phone)));
updateDescText();
}
@@ -103,10 +103,9 @@ void CodeWidget::refreshLang() {
void CodeWidget::updateDescText() {
const auto byTelegram = getData()->codeByTelegram;
setDescriptionText([=] {
return Ui::Text::RichLangValue(
lang(byTelegram ? lng_code_from_telegram : lng_code_desc));
});
setDescriptionText(
(byTelegram ? tr::lng_code_from_telegram : tr::lng_code_desc)(
Ui::Text::RichLangValue));
if (getData()->codeByTelegram) {
_noTelegramCode->show();
_callTimer->stop();
@@ -155,9 +154,9 @@ void CodeWidget::updateControlsGeometry() {
_callLabel->moveToLeft(contentLeft() + st::buttonRadius, linkTop);
}
void CodeWidget::showCodeError(Fn<QString()> textFactory) {
if (textFactory) _code->showError();
showError(std::move(textFactory));
void CodeWidget::showCodeError(rpl::producer<QString> text) {
_code->showError();
showError(std::move(text));
}
void CodeWidget::setInnerFocus() {
@@ -217,7 +216,7 @@ void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) {
_sentRequest = 0;
auto &d = result.c_auth_authorization();
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
showCodeError(&Lang::Hard::ServerError);
showCodeError(rpl::single(Lang::Hard::ServerError()));
return;
}
cSetLoggedPhoneNumber(getData()->phone);
@@ -228,7 +227,7 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
stopCheck();
_sentRequest = 0;
showCodeError(langFactory(lng_flood_error));
showCodeError(tr::lng_flood_error());
return true;
}
if (MTP::isDefaultHandledError(error)) return false;
@@ -242,7 +241,7 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
goBack();
return true;
} else if (err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID")) {
showCodeError(langFactory(lng_bad_code));
showCodeError(tr::lng_bad_code());
return true;
} else if (err == qstr("PHONE_NUMBER_UNOCCUPIED")) { // success, need to signUp
getData()->code = _sentCode;
@@ -255,10 +254,9 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
return true;
}
if (Logs::DebugEnabled()) { // internal server error
auto text = err + ": " + error.description();
showCodeError([text] { return text; });
showCodeError(rpl::single(err + ": " + error.description()));
} else {
showCodeError(&Lang::Hard::ServerError);
showCodeError(rpl::single(Lang::Hard::ServerError()));
}
return false;
}
@@ -358,7 +356,7 @@ void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) {
_noTelegramCodeRequestId = 0;
if (result.type() != mtpc_auth_sentCode) {
showCodeError(&Lang::Hard::ServerError);
showCodeError(rpl::single(Lang::Hard::ServerError()));
return;
}
@@ -379,7 +377,7 @@ void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) {
bool CodeWidget::noTelegramCodeFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
_noTelegramCodeRequestId = 0;
showCodeError(langFactory(lng_flood_error));
showCodeError(tr::lng_flood_error());
return true;
}
if (MTP::isDefaultHandledError(error)) {
@@ -388,10 +386,9 @@ bool CodeWidget::noTelegramCodeFail(const RPCError &error) {
_noTelegramCodeRequestId = 0;
if (Logs::DebugEnabled()) { // internal server error
auto text = error.type() + ": " + error.description();
showCodeError([text] { return text; });
showCodeError(rpl::single(error.type() + ": " + error.description()));
} else {
showCodeError(&Lang::Hard::ServerError);
showCodeError(rpl::single(Lang::Hard::ServerError()));
}
return false;
}

View File

@@ -69,7 +69,7 @@ private:
void codeSubmitDone(const MTPauth_Authorization &result);
bool codeSubmitFail(const RPCError &error);
void showCodeError(Fn<QString()> textFactory);
void showCodeError(rpl::producer<QString> text);
void callDone(const MTPauth_SentCode &v);
void gotPassword(const MTPaccount_Password &result);

View File

@@ -44,8 +44,8 @@ PhoneWidget::PhoneWidget(QWidget *parent, Widget::Data *data) : Step(parent, dat
connect(_code, SIGNAL(changed()), this, SLOT(onInputChange()));
connect(_checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest()));
setTitleText(langFactory(lng_phone_title));
setDescriptionText(langFactory(lng_phone_desc));
setTitleText(tr::lng_phone_title());
setDescriptionText(tr::lng_phone_desc());
subscribe(getData()->updated, [this] { countryChanged(); });
setErrorCentered(true);
@@ -72,9 +72,9 @@ void PhoneWidget::updateSignupGeometry() {
}
}
void PhoneWidget::showPhoneError(Fn<QString()> textFactory) {
void PhoneWidget::showPhoneError(rpl::producer<QString> text) {
_phone->showError();
showError(std::move(textFactory));
showError(std::move(text));
}
void PhoneWidget::hidePhoneError() {
@@ -101,7 +101,7 @@ void PhoneWidget::submit() {
const auto phone = fullNumber();
if (!AllowPhoneAttempt(phone)) {
showPhoneError(langFactory(lng_bad_phone));
showPhoneError(tr::lng_bad_phone());
_phone->setFocus();
return;
}
@@ -146,7 +146,7 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
_sentRequest = 0;
if (result.type() != mtpc_auth_sentCode) {
showPhoneError(&Lang::Hard::ServerError);
showPhoneError(rpl::single(Lang::Hard::ServerError()));
return;
}
@@ -169,7 +169,7 @@ bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
stopCheck();
_sentRequest = 0;
showPhoneError(langFactory(lng_flood_error));
showPhoneError(tr::lng_flood_error());
return true;
}
if (MTP::isDefaultHandledError(error)) return false;
@@ -181,17 +181,16 @@ bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
Ui::show(Box<InformBox>(lang(lng_error_phone_flood)));
return true;
} else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
showPhoneError(langFactory(lng_bad_phone));
showPhoneError(tr::lng_bad_phone());
return true;
} else if (err == qstr("PHONE_NUMBER_BANNED")) {
ShowPhoneBannedError(_sentPhone);
return true;
}
if (Logs::DebugEnabled()) { // internal server error
auto text = err + ": " + error.description();
showPhoneError([text] { return text; });
showPhoneError(rpl::single(err + ": " + error.description()));
} else {
showPhoneError(&Lang::Hard::ServerError);
showPhoneError(rpl::single(Lang::Hard::ServerError()));
}
return false;
}

View File

@@ -54,7 +54,7 @@ private:
QString fullNumber() const;
void stopCheck();
void showPhoneError(Fn<QString()> textFactory);
void showPhoneError(rpl::producer<QString> text);
void hidePhoneError();
bool _changed = false;

View File

@@ -45,7 +45,7 @@ PwdCheckWidget::PwdCheckWidget(
connect(_pwdField, SIGNAL(changed()), this, SLOT(onInputChange()));
connect(_codeField, SIGNAL(changed()), this, SLOT(onInputChange()));
setTitleText(langFactory(lng_signin_title));
setTitleText(tr::lng_signin_title());
updateDescriptionText();
setErrorBelowLink(true);
@@ -130,7 +130,7 @@ void PwdCheckWidget::pwdSubmitDone(bool recover, const MTPauth_Authorization &re
}
auto &d = result.c_auth_authorization();
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
showError(&Lang::Hard::ServerError);
showError(rpl::single(Lang::Hard::ServerError()));
return;
}
finish(d.vuser);
@@ -140,7 +140,7 @@ void PwdCheckWidget::pwdSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
_sentRequest = 0;
stopCheck();
showError(langFactory(lng_flood_error));
showError(tr::lng_flood_error());
_pwdField->showError();
return;
}
@@ -150,7 +150,7 @@ void PwdCheckWidget::pwdSubmitFail(const RPCError &error) {
const auto &type = error.type();
if (type == qstr("PASSWORD_HASH_INVALID")
|| type == qstr("SRP_PASSWORD_CHANGED")) {
showError(langFactory(lng_signin_bad_password));
showError(tr::lng_signin_bad_password());
_pwdField->selectAll();
_pwdField->showError();
} else if (type == qstr("PASSWORD_EMPTY")
@@ -160,10 +160,9 @@ void PwdCheckWidget::pwdSubmitFail(const RPCError &error) {
handleSrpIdInvalid();
} else {
if (Logs::DebugEnabled()) { // internal server error
const auto text = type + ": " + error.description();
showError([=] { return text; });
showError(rpl::single(type + ": " + error.description()));
} else {
showError(&Lang::Hard::ServerError);
showError(rpl::single(Lang::Hard::ServerError()));
}
_pwdField->setFocus();
}
@@ -174,7 +173,7 @@ void PwdCheckWidget::handleSrpIdInvalid() {
if (_lastSrpIdInvalidTime > 0
&& now - _lastSrpIdInvalidTime < Core::kHandleSrpIdInvalidTimeout) {
_request.id = 0;
showError(&Lang::Hard::ServerError);
showError(rpl::single(Lang::Hard::ServerError()));
} else {
_lastSrpIdInvalidTime = now;
requestPasswordData();
@@ -223,12 +222,12 @@ void PwdCheckWidget::passwordChecked() {
}
void PwdCheckWidget::serverError() {
showError(&Lang::Hard::ServerError);
showError(rpl::single(Lang::Hard::ServerError()));
}
void PwdCheckWidget::codeSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
showError(langFactory(lng_flood_error));
showError(tr::lng_flood_error());
_codeField->showError();
return;
}
@@ -245,15 +244,14 @@ void PwdCheckWidget::codeSubmitFail(const RPCError &error) {
_emailPattern = QString();
onToPassword();
} else if (type == qstr("CODE_INVALID")) {
showError(langFactory(lng_signin_wrong_code));
showError(tr::lng_signin_wrong_code());
_codeField->selectAll();
_codeField->showError();
} else {
if (Logs::DebugEnabled()) { // internal server error
const auto text = type + ": " + error.description();
showError([=] { return text; });
showError(rpl::single(type + ": " + error.description()));
} else {
showError(&Lang::Hard::ServerError);
showError(rpl::single(Lang::Hard::ServerError()));
}
_codeField->setFocus();
}
@@ -326,9 +324,9 @@ void PwdCheckWidget::showReset() {
void PwdCheckWidget::updateDescriptionText() {
auto pwdHidden = _pwdField->isHidden();
auto emailPattern = _emailPattern;
setDescriptionText([=] {
return pwdHidden ? lng_signin_recover_desc(lt_email, emailPattern) : lang(lng_signin_desc);
});
setDescriptionText(pwdHidden
? tr::lng_signin_recover_desc(lt_email, rpl::single(emailPattern))
: tr::lng_signin_desc());
}
void PwdCheckWidget::onInputChange() {
@@ -379,8 +377,8 @@ void PwdCheckWidget::submit() {
}
}
QString PwdCheckWidget::nextButtonText() const {
return lang(lng_intro_submit);
rpl::producer<QString> PwdCheckWidget::nextButtonText() const {
return tr::lng_intro_submit();
}
} // namespace Intro

View File

@@ -29,7 +29,7 @@ public:
void activate() override;
void cancelled() override;
void submit() override;
QString nextButtonText() const override;
rpl::producer<QString> nextButtonText() const override;
protected:
void resizeEvent(QResizeEvent *e) override;

View File

@@ -41,8 +41,8 @@ SignupWidget::SignupWidget(QWidget *parent, Widget::Data *data) : Step(parent, d
setErrorCentered(true);
setTitleText(langFactory(lng_signup_title));
setDescriptionText(langFactory(lng_signup_desc));
setTitleText(tr::lng_signup_title());
setDescriptionText(tr::lng_signup_desc());
setMouseTracking(true);
}
@@ -122,7 +122,7 @@ void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
stopCheck();
auto &d = result.c_auth_authorization();
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
showError(&Lang::Hard::ServerError);
showError(rpl::single(Lang::Hard::ServerError()));
return;
}
finish(d.vuser, _photo->takeResultImage());
@@ -131,7 +131,7 @@ void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
bool SignupWidget::nameSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
stopCheck();
showError(langFactory(lng_flood_error));
showError(tr::lng_flood_error());
if (_invertOrder) {
_first->setFocus();
} else {
@@ -155,19 +155,18 @@ bool SignupWidget::nameSubmitFail(const RPCError &error) {
goBack();
return true;
} else if (err == "FIRSTNAME_INVALID") {
showError(langFactory(lng_bad_name));
showError(tr::lng_bad_name());
_first->setFocus();
return true;
} else if (err == "LASTNAME_INVALID") {
showError(langFactory(lng_bad_name));
showError(tr::lng_bad_name());
_last->setFocus();
return true;
}
if (Logs::DebugEnabled()) { // internal server error
auto text = err + ": " + error.description();
showError([text] { return text; });
showError(rpl::single(err + ": " + error.description()));
} else {
showError(&Lang::Hard::ServerError);
showError(rpl::single(Lang::Hard::ServerError()));
}
if (_invertOrder) {
_last->setFocus();
@@ -230,8 +229,8 @@ void SignupWidget::submit() {
}
}
QString SignupWidget::nextButtonText() const {
return lang(lng_intro_finish);
rpl::producer<QString> SignupWidget::nextButtonText() const {
return tr::lng_intro_finish();
}
} // namespace Intro

View File

@@ -28,7 +28,7 @@ public:
void activate() override;
void cancelled() override;
void submit() override;
QString nextButtonText() const override;
rpl::producer<QString> nextButtonText() const override;
protected:
void resizeEvent(QResizeEvent *e) override;

View File

@@ -16,8 +16,8 @@ namespace Intro {
StartWidget::StartWidget(QWidget *parent, Widget::Data *data) : Step(parent, data, true) {
setMouseTracking(true);
setTitleText([] { return qsl("Telegram Desktop"); });
setDescriptionText(langFactory(lng_intro_about));
setTitleText(rpl::single(qsl("Telegram Desktop")));
setDescriptionText(tr::lng_intro_about());
show();
}
@@ -25,8 +25,8 @@ void StartWidget::submit() {
goNext(new Intro::PhoneWidget(parentWidget(), getData()));
}
QString StartWidget::nextButtonText() const {
return lang(lng_start_msgs);
rpl::producer<QString> StartWidget::nextButtonText() const {
return tr::lng_start_msgs();
}
} // namespace Intro

View File

@@ -22,7 +22,7 @@ public:
StartWidget(QWidget *parent, Widget::Data *data);
void submit() override;
QString nextButtonText() const override;
rpl::producer<QString> nextButtonText() const override;
};

View File

@@ -65,9 +65,9 @@ Widget::Widget(QWidget *parent) : RpWidget(parent)
this,
object_ptr<Ui::RoundButton>(
this,
langFactory(lng_menu_settings),
tr::lng_menu_settings(),
st::defaultBoxButton))
, _next(this, Fn<QString()>(), st::introNextButton) {
, _next(this, nullptr, st::introNextButton) {
auto country = Platform::SystemCountry();
if (country.isEmpty()) {
country = str_const_toString(kDefaultCountry);
@@ -174,7 +174,7 @@ void Widget::onCheckUpdateStatus() {
this,
object_ptr<Ui::RoundButton>(
this,
langFactory(lng_menu_update),
tr::lng_menu_update(),
st::defaultBoxButton));
if (!_a_show.animating()) {
_update->setVisible(true);
@@ -241,7 +241,7 @@ void Widget::historyMove(Direction direction) {
if (_update) {
_update->toggle(!stepHasCover, anim::type::normal);
}
_next->setText([this] { return getStep()->nextButtonText(); });
_next->setText(getStep()->nextButtonText());
if (_resetAccount) _resetAccount->show(anim::type::normal);
if (_terms) _terms->show(anim::type::normal);
if (_changeLanguage) {
@@ -307,7 +307,10 @@ void Widget::appendStep(Step *step) {
void Widget::showResetButton() {
if (!_resetAccount) {
auto entity = object_ptr<Ui::RoundButton>(this, langFactory(lng_signin_reset_account), st::introResetButton);
auto entity = object_ptr<Ui::RoundButton>(
this,
tr::lng_signin_reset_account(),
st::introResetButton);
_resetAccount.create(this, std::move(entity));
_resetAccount->hide(anim::type::instant);
_resetAccount->entity()->setClickedCallback([this] { resetAccount(); });
@@ -325,9 +328,10 @@ void Widget::showTerms() {
} else if (!_terms) {
auto entity = object_ptr<Ui::FlatLabel>(
this,
rpl::single(lng_terms_signup__rich(
tr::lng_terms_signup(
lt_link,
Ui::Text::Link(lang(lng_terms_signup_link)))),
tr::lng_terms_signup_link() | Ui::Text::ToLink(),
Ui::Text::WithEntities),
st::introTermsLabel);
_terms.create(this, std::move(entity));
_terms->entity()->setClickHandlerFilter([=](
@@ -385,7 +389,7 @@ void Widget::resetAccount() {
Ui::show(Box<InformBox>(lang(lng_signin_reset_cancelled)));
} else {
Ui::hideLayer();
getStep()->showError(&Lang::Hard::ServerError);
getStep()->showError(rpl::single(Lang::Hard::ServerError()));
}
}).send();
})));
@@ -415,11 +419,11 @@ void Widget::showTerms(Fn<void()> callback) {
const auto box = Ui::show(callback
? Box<Window::TermsBox>(
getData()->termsLock,
langFactory(lng_terms_agree),
langFactory(lng_terms_decline))
tr::lng_terms_agree(),
tr::lng_terms_decline())
: Box<Window::TermsBox>(
getData()->termsLock.text,
langFactory(lng_box_ok),
tr::lng_box_ok(),
nullptr));
box->setCloseByEscape(false);
@@ -439,8 +443,8 @@ void Widget::showTerms(Fn<void()> callback) {
) | rpl::start_with_next([=] {
const auto box = Ui::show(Box<Window::TermsBox>(
TextWithEntities{ lang(lng_terms_signup_sorry) },
langFactory(lng_intro_finish),
langFactory(lng_terms_decline)));
tr::lng_intro_finish(),
tr::lng_terms_decline()));
box->agreeClicks(
) | rpl::start_with_next([=] {
if (weak) {
@@ -459,7 +463,7 @@ void Widget::showTerms(Fn<void()> callback) {
void Widget::showControls() {
getStep()->show();
_next->show();
_next->setText([this] { return getStep()->nextButtonText(); });
_next->setText(getStep()->nextButtonText());
_connecting->setForceHidden(false);
auto hasCover = getStep()->hasCover();
_settings->toggle(!hasCover, anim::type::instant);
@@ -605,8 +609,8 @@ Widget::~Widget() {
if (App::wnd()) App::wnd()->noIntro(this);
}
QString Widget::Step::nextButtonText() const {
return lang(lng_intro_next);
rpl::producer<QString> Widget::Step::nextButtonText() const {
return tr::lng_intro_next();
}
void Widget::Step::finish(const MTPUser &user, QImage &&photo) {
@@ -673,39 +677,19 @@ void Widget::Step::updateLabelsPosition() {
}
}
void Widget::Step::setTitleText(Fn<QString()> titleTextFactory) {
_titleTextFactory = std::move(titleTextFactory);
refreshTitle();
updateLabelsPosition();
void Widget::Step::setTitleText(rpl::producer<QString> titleText) {
_titleText = std::move(titleText);
}
void Widget::Step::refreshTitle() {
_title->setText(_titleTextFactory());
void Widget::Step::setDescriptionText(
rpl::producer<QString> descriptionText) {
setDescriptionText(
std::move(descriptionText) | Ui::Text::ToWithEntities());
}
void Widget::Step::setDescriptionText(Fn<QString()> descriptionTextFactory) {
_descriptionTextFactory = [=] {
return TextWithEntities{ descriptionTextFactory() };
};
refreshDescription();
updateLabelsPosition();
}
void Widget::Step::setDescriptionText(Fn<TextWithEntities()> richDescriptionTextFactory) {
_descriptionTextFactory = std::move(richDescriptionTextFactory);
refreshDescription();
updateLabelsPosition();
}
void Widget::Step::refreshDescription() {
_description->entity()->setMarkedText(_descriptionTextFactory());
}
void Widget::Step::refreshLang() {
refreshTitle();
refreshDescription();
refreshError();
updateLabelsPosition();
void Widget::Step::setDescriptionText(
rpl::producer<TextWithEntities> richDescriptionText) {
_descriptionText = std::move(richDescriptionText);
}
void Widget::Step::showFinished() {
@@ -886,14 +870,12 @@ void Widget::Step::setErrorBelowLink(bool below) {
}
}
void Widget::Step::showError(Fn<QString()> textFactory) {
_errorTextFactory = std::move(textFactory);
refreshError();
updateLabelsPosition();
void Widget::Step::showError(rpl::producer<QString> text) {
_errorText = std::move(text);
}
void Widget::Step::refreshError() {
if (!_errorTextFactory) {
void Widget::Step::refreshError(const QString &text) {
if (text.isEmpty()) {
if (_error) _error->hide(anim::type::normal);
} else {
if (!_error) {
@@ -906,13 +888,14 @@ void Widget::Step::refreshError() {
: st::introError));
_error->hide(anim::type::instant);
}
_error->entity()->setText(_errorTextFactory());
_error->entity()->setText(text);
updateLabelsPosition();
_error->show(anim::type::normal);
}
}
Widget::Step::Step(QWidget *parent, Data *data, bool hasCover) : TWidget(parent)
Widget::Step::Step(QWidget *parent, Data *data, bool hasCover)
: RpWidget(parent)
, _data(data)
, _hasCover(hasCover)
, _title(this, _hasCover ? st::introCoverTitle : st::introTitle)
@@ -933,7 +916,23 @@ Widget::Step::Step(QWidget *parent, Data *data, bool hasCover) : TWidget(parent)
}
}
});
subscribe(Lang::Current().updated(), [this] { refreshLang(); });
_errorText.value(
) | rpl::start_with_next([=](const QString &text) {
refreshError(text);
}, lifetime());
_titleText.value(
) | rpl::start_with_next([=](const QString &text) {
_title->setText(text);
updateLabelsPosition();
}, lifetime());
_descriptionText.value(
) | rpl::start_with_next([=](const TextWithEntities &text) {
_description->entity()->setMarkedText(text);
updateLabelsPosition();
}, lifetime());
}
void Widget::Step::prepareShowAnimated(Step *after) {
@@ -1030,7 +1029,7 @@ bool Widget::Step::hasBack() const {
void Widget::Step::activate() {
_title->show();
_description->show(anim::type::instant);
if (_errorTextFactory) {
if (!_errorText.current().isEmpty()) {
_error->show(anim::type::instant);
}
}

View File

@@ -90,7 +90,7 @@ public:
Forward,
Replace,
};
class Step : public TWidget, public RPCSender, protected base::Subscriber {
class Step : public Ui::RpWidget, public RPCSender, protected base::Subscriber {
public:
Step(QWidget *parent, Data *data, bool hasCover = false);
@@ -120,16 +120,16 @@ public:
virtual void finished();
virtual void submit() = 0;
virtual QString nextButtonText() const;
virtual rpl::producer<QString> nextButtonText() const;
int contentLeft() const;
int contentTop() const;
void setErrorCentered(bool centered);
void setErrorBelowLink(bool below);
void showError(Fn<QString()> textFactory);
void showError(rpl::producer<QString> text);
void hideError() {
showError(Fn<QString()>());
showError(rpl::single(QString()));
}
~Step();
@@ -138,9 +138,10 @@ public:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void setTitleText(Fn<QString()> titleTextFactory);
void setDescriptionText(Fn<QString()> descriptionTextFactory);
void setDescriptionText(Fn<TextWithEntities()> richDescriptionTextFactory);
void setTitleText(rpl::producer<QString> titleText);
void setDescriptionText(rpl::producer<QString> descriptionText);
void setDescriptionText(
rpl::producer<TextWithEntities> richDescriptionText);
bool paintAnimated(Painter &p, QRect clip);
void fillSentCodeData(const MTPDauth_sentCode &type);
@@ -190,7 +191,7 @@ public:
};
void updateLabelsPosition();
void paintContentSnapshot(Painter &p, const QPixmap &snapshot, float64 alpha, float64 howMuchHidden);
void refreshError();
void refreshError(const QString &text);
void refreshTitle();
void refreshDescription();
void refreshLang();
@@ -208,17 +209,16 @@ public:
Fn<void(Step *step, Direction direction)> _goCallback;
Fn<void()> _showResetCallback;
Fn<void()> _showTermsCallback;
Fn<void(
Fn<void()> callback)> _acceptTermsCallback;
Fn<void(Fn<void()> callback)> _acceptTermsCallback;
rpl::variable<QString> _titleText;
object_ptr<Ui::FlatLabel> _title;
Fn<QString()> _titleTextFactory;
rpl::variable<TextWithEntities> _descriptionText;
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _description;
Fn<TextWithEntities()> _descriptionTextFactory;
bool _errorCentered = false;
bool _errorBelowLink = false;
Fn<QString()> _errorTextFactory;
rpl::variable<QString> _errorText;
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _error = { nullptr };
Ui::Animations::Simple _a_show;