mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Replace base::lambda with shorter term.
base::lambda -> Fn (type alias for std::function). base::lambda_once -> FnMut (type alias for base::unique_function). base::lambda_guarded -> crl::guard. base::lambda_call_type_t -> crl::deduced_call_type.
This commit is contained in:
@@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace Intro {
|
||||
|
||||
CodeInput::CodeInput(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory) : Ui::MaskedInputField(parent, st, std::move(placeholderFactory)) {
|
||||
CodeInput::CodeInput(QWidget *parent, const style::InputField &st, Fn<QString()> placeholderFactory) : Ui::MaskedInputField(parent, st, std::move(placeholderFactory)) {
|
||||
}
|
||||
|
||||
void CodeInput::setDigitsCountMax(int digitsCount) {
|
||||
@@ -145,7 +145,7 @@ void CodeWidget::updateControlsGeometry() {
|
||||
_callLabel->moveToLeft(contentLeft() + st::buttonRadius, linkTop);
|
||||
}
|
||||
|
||||
void CodeWidget::showCodeError(base::lambda<QString()> textFactory) {
|
||||
void CodeWidget::showCodeError(Fn<QString()> textFactory) {
|
||||
if (textFactory) _code->showError();
|
||||
showError(std::move(textFactory));
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ class CodeInput final : public Ui::MaskedInputField {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CodeInput(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory);
|
||||
CodeInput(QWidget *parent, const style::InputField &st, Fn<QString()> placeholderFactory);
|
||||
|
||||
void setDigitsCountMax(int digitsCount);
|
||||
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
void codeSubmitDone(const MTPauth_Authorization &result);
|
||||
bool codeSubmitFail(const RPCError &error);
|
||||
|
||||
void showCodeError(base::lambda<QString()> textFactory);
|
||||
void showCodeError(Fn<QString()> textFactory);
|
||||
void callDone(const MTPauth_SentCode &v);
|
||||
void gotPassword(const MTPaccount_Password &result);
|
||||
|
||||
|
@@ -93,7 +93,7 @@ void PhoneWidget::updateSignupGeometry() {
|
||||
}
|
||||
}
|
||||
|
||||
void PhoneWidget::showPhoneError(base::lambda<QString()> textFactory) {
|
||||
void PhoneWidget::showPhoneError(Fn<QString()> textFactory) {
|
||||
_phone->showError();
|
||||
showError(std::move(textFactory));
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ private:
|
||||
QString fullNumber() const;
|
||||
void stopCheck();
|
||||
|
||||
void showPhoneError(base::lambda<QString()> textFactory);
|
||||
void showPhoneError(Fn<QString()> textFactory);
|
||||
void hidePhoneError();
|
||||
//void showSignup();
|
||||
|
||||
|
@@ -277,7 +277,7 @@ void PwdCheckWidget::submit() {
|
||||
_codeField->showError();
|
||||
return;
|
||||
}
|
||||
const auto send = base::lambda_guarded(this, [=] {
|
||||
const auto send = crl::guard(this, [=] {
|
||||
_sentRequest = MTP::send(
|
||||
MTPauth_RecoverPassword(MTP_string(code)),
|
||||
rpcDone(&PwdCheckWidget::pwdSubmitDone, true),
|
||||
|
@@ -221,7 +221,7 @@ void SignupWidget::submit() {
|
||||
|| !getData()->termsPopup) {
|
||||
send();
|
||||
} else {
|
||||
acceptTerms(base::lambda_guarded(this, [=] {
|
||||
acceptTerms(crl::guard(this, [=] {
|
||||
_termsAccepted = true;
|
||||
send();
|
||||
}));
|
||||
|
@@ -48,8 +48,8 @@ public:
|
||||
TermsBox(
|
||||
QWidget*,
|
||||
const TextWithEntities &text,
|
||||
base::lambda<QString()> agree,
|
||||
base::lambda<QString()> cancel,
|
||||
Fn<QString()> agree,
|
||||
Fn<QString()> cancel,
|
||||
int age = 0);
|
||||
|
||||
rpl::producer<> agreeClicks() const;
|
||||
@@ -62,8 +62,8 @@ protected:
|
||||
|
||||
private:
|
||||
TextWithEntities _text;
|
||||
base::lambda<QString()> _agree;
|
||||
base::lambda<QString()> _cancel;
|
||||
Fn<QString()> _agree;
|
||||
Fn<QString()> _cancel;
|
||||
int _age = 0;
|
||||
rpl::event_stream<> _agreeClicks;
|
||||
rpl::event_stream<> _cancelClicks;
|
||||
@@ -73,8 +73,8 @@ private:
|
||||
TermsBox::TermsBox(
|
||||
QWidget*,
|
||||
const TextWithEntities &text,
|
||||
base::lambda<QString()> agree,
|
||||
base::lambda<QString()> cancel,
|
||||
Fn<QString()> agree,
|
||||
Fn<QString()> cancel,
|
||||
int age)
|
||||
: _text(text)
|
||||
, _agree(agree)
|
||||
@@ -161,7 +161,7 @@ Widget::Widget(QWidget *parent) : RpWidget(parent)
|
||||
this,
|
||||
langFactory(lng_menu_settings),
|
||||
st::defaultBoxButton))
|
||||
, _next(this, base::lambda<QString()>(), st::introNextButton) {
|
||||
, _next(this, Fn<QString()>(), st::introNextButton) {
|
||||
auto country = Platform::SystemCountry();
|
||||
if (country.isEmpty()) {
|
||||
country = str_const_toString(kDefaultCountry);
|
||||
@@ -392,7 +392,7 @@ void Widget::appendStep(Step *step) {
|
||||
step->setShowTermsCallback([=]() {
|
||||
showTerms();
|
||||
});
|
||||
step->setAcceptTermsCallback([=](base::lambda<void()> callback) {
|
||||
step->setAcceptTermsCallback([=](Fn<void()> callback) {
|
||||
acceptTerms(callback);
|
||||
});
|
||||
}
|
||||
@@ -438,14 +438,14 @@ void Widget::showTerms() {
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::acceptTerms(base::lambda<void()> callback) {
|
||||
void Widget::acceptTerms(Fn<void()> callback) {
|
||||
showTerms(callback);
|
||||
}
|
||||
|
||||
void Widget::resetAccount() {
|
||||
if (_resetRequest) return;
|
||||
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_signin_sure_reset), lang(lng_signin_reset), st::attentionBoxButton, base::lambda_guarded(this, [this] {
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_signin_sure_reset), lang(lng_signin_reset), st::attentionBoxButton, crl::guard(this, [this] {
|
||||
if (_resetRequest) return;
|
||||
_resetRequest = request(MTPaccount_DeleteAccount(MTP_string("Forgot password"))).done([this](const MTPBool &result) {
|
||||
_resetRequest = 0;
|
||||
@@ -497,7 +497,7 @@ void Widget::getNearestDC() {
|
||||
}).send();
|
||||
}
|
||||
|
||||
void Widget::showTerms(base::lambda<void()> callback) {
|
||||
void Widget::showTerms(Fn<void()> callback) {
|
||||
if (getData()->termsText.text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -755,7 +755,7 @@ void Widget::Step::updateLabelsPosition() {
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::Step::setTitleText(base::lambda<QString()> richTitleTextFactory) {
|
||||
void Widget::Step::setTitleText(Fn<QString()> richTitleTextFactory) {
|
||||
_titleTextFactory = std::move(richTitleTextFactory);
|
||||
refreshTitle();
|
||||
updateLabelsPosition();
|
||||
@@ -765,7 +765,7 @@ void Widget::Step::refreshTitle() {
|
||||
_title->setRichText(_titleTextFactory());
|
||||
}
|
||||
|
||||
void Widget::Step::setDescriptionText(base::lambda<QString()> richDescriptionTextFactory) {
|
||||
void Widget::Step::setDescriptionText(Fn<QString()> richDescriptionTextFactory) {
|
||||
_descriptionTextFactory = std::move(richDescriptionTextFactory);
|
||||
refreshDescription();
|
||||
updateLabelsPosition();
|
||||
@@ -967,7 +967,7 @@ void Widget::Step::setErrorBelowLink(bool below) {
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::Step::showError(base::lambda<QString()> textFactory) {
|
||||
void Widget::Step::showError(Fn<QString()> textFactory) {
|
||||
_errorTextFactory = std::move(textFactory);
|
||||
refreshError();
|
||||
updateLabelsPosition();
|
||||
@@ -1074,20 +1074,20 @@ void Widget::Step::showAnimated(Direction direction) {
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::Step::setGoCallback(base::lambda<void(Step *step, Direction direction)> callback) {
|
||||
void Widget::Step::setGoCallback(Fn<void(Step *step, Direction direction)> callback) {
|
||||
_goCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void Widget::Step::setShowResetCallback(base::lambda<void()> callback) {
|
||||
void Widget::Step::setShowResetCallback(Fn<void()> callback) {
|
||||
_showResetCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void Widget::Step::setShowTermsCallback(base::lambda<void()> callback) {
|
||||
void Widget::Step::setShowTermsCallback(Fn<void()> callback) {
|
||||
_showTermsCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void Widget::Step::setAcceptTermsCallback(
|
||||
base::lambda<void(base::lambda<void()> callback)> callback) {
|
||||
Fn<void(Fn<void()> callback)> callback) {
|
||||
_acceptTermsCallback = std::move(callback);
|
||||
}
|
||||
|
||||
|
@@ -102,12 +102,12 @@ public:
|
||||
}
|
||||
|
||||
void setGoCallback(
|
||||
base::lambda<void(Step *step, Direction direction)> callback);
|
||||
void setShowResetCallback(base::lambda<void()> callback);
|
||||
Fn<void(Step *step, Direction direction)> callback);
|
||||
void setShowResetCallback(Fn<void()> callback);
|
||||
void setShowTermsCallback(
|
||||
base::lambda<void()> callback);
|
||||
Fn<void()> callback);
|
||||
void setAcceptTermsCallback(
|
||||
base::lambda<void(base::lambda<void()> callback)> callback);
|
||||
Fn<void(Fn<void()> callback)> callback);
|
||||
|
||||
void prepareShowAnimated(Step *after);
|
||||
void showAnimated(Direction direction);
|
||||
@@ -128,9 +128,9 @@ public:
|
||||
|
||||
void setErrorCentered(bool centered);
|
||||
void setErrorBelowLink(bool below);
|
||||
void showError(base::lambda<QString()> textFactory);
|
||||
void showError(Fn<QString()> textFactory);
|
||||
void hideError() {
|
||||
showError(base::lambda<QString()>());
|
||||
showError(Fn<QString()>());
|
||||
}
|
||||
|
||||
~Step();
|
||||
@@ -139,8 +139,8 @@ public:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
void setTitleText(base::lambda<QString()> richTitleTextFactory);
|
||||
void setDescriptionText(base::lambda<QString()> richDescriptionTextFactory);
|
||||
void setTitleText(Fn<QString()> richTitleTextFactory);
|
||||
void setDescriptionText(Fn<QString()> richDescriptionTextFactory);
|
||||
bool paintAnimated(Painter &p, QRect clip);
|
||||
|
||||
void fillSentCodeData(const MTPDauth_sentCode &type);
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
void showTerms() {
|
||||
if (_showTermsCallback) _showTermsCallback();
|
||||
}
|
||||
void acceptTerms(base::lambda<void()> callback) {
|
||||
void acceptTerms(Fn<void()> callback) {
|
||||
if (_acceptTermsCallback) {
|
||||
_acceptTermsCallback(callback);
|
||||
}
|
||||
@@ -205,20 +205,20 @@ public:
|
||||
|
||||
Data *_data = nullptr;
|
||||
bool _hasCover = false;
|
||||
base::lambda<void(Step *step, Direction direction)> _goCallback;
|
||||
base::lambda<void()> _showResetCallback;
|
||||
base::lambda<void()> _showTermsCallback;
|
||||
base::lambda<void(
|
||||
base::lambda<void()> callback)> _acceptTermsCallback;
|
||||
Fn<void(Step *step, Direction direction)> _goCallback;
|
||||
Fn<void()> _showResetCallback;
|
||||
Fn<void()> _showTermsCallback;
|
||||
Fn<void(
|
||||
Fn<void()> callback)> _acceptTermsCallback;
|
||||
|
||||
object_ptr<Ui::FlatLabel> _title;
|
||||
base::lambda<QString()> _titleTextFactory;
|
||||
Fn<QString()> _titleTextFactory;
|
||||
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _description;
|
||||
base::lambda<QString()> _descriptionTextFactory;
|
||||
Fn<QString()> _descriptionTextFactory;
|
||||
|
||||
bool _errorCentered = false;
|
||||
bool _errorBelowLink = false;
|
||||
base::lambda<QString()> _errorTextFactory;
|
||||
Fn<QString()> _errorTextFactory;
|
||||
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _error = { nullptr };
|
||||
|
||||
Animation _a_show;
|
||||
@@ -248,7 +248,7 @@ private:
|
||||
void resetAccount();
|
||||
|
||||
void showTerms();
|
||||
void acceptTerms(base::lambda<void()> callback);
|
||||
void acceptTerms(Fn<void()> callback);
|
||||
void hideAndDestroy(object_ptr<Ui::FadeWrap<Ui::RpWidget>> widget);
|
||||
|
||||
Step *getStep(int skip = 0) {
|
||||
@@ -260,7 +260,7 @@ private:
|
||||
void appendStep(Step *step);
|
||||
|
||||
void getNearestDC();
|
||||
void showTerms(base::lambda<void()> callback);
|
||||
void showTerms(Fn<void()> callback);
|
||||
|
||||
Animation _a_show;
|
||||
bool _showBack = false;
|
||||
|
Reference in New Issue
Block a user