mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Moved creation of link button in cloud password settings to common file.
This commit is contained in:
parent
3ef352b63c
commit
4d5cb6398e
5 changed files with 40 additions and 31 deletions
|
@ -166,6 +166,26 @@ not_null<Ui::CenterWrap<Ui::InputField>*> AddWrappedField(
|
|||
text)));
|
||||
}
|
||||
|
||||
not_null<Ui::LinkButton*> AddLinkButton(
|
||||
not_null<Ui::CenterWrap<Ui::InputField>*> wrap,
|
||||
rpl::producer<QString> &&text) {
|
||||
const auto button = Ui::CreateChild<Ui::LinkButton>(
|
||||
wrap->parentWidget(),
|
||||
QString());
|
||||
std::move(
|
||||
text
|
||||
) | rpl::start_with_next([=](const QString &text) {
|
||||
button->setText(text);
|
||||
}, button->lifetime());
|
||||
|
||||
wrap->geometryValue(
|
||||
) | rpl::start_with_next([=](QRect r) {
|
||||
r.translate(wrap->entity()->pos().x(), 0);
|
||||
button->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
|
||||
}, button->lifetime());
|
||||
return button;
|
||||
}
|
||||
|
||||
not_null<Ui::FlatLabel*> AddError(
|
||||
not_null<Ui::VerticalLayout*> content,
|
||||
Ui::PasswordInput *input) {
|
||||
|
|
|
@ -15,6 +15,7 @@ template <typename Widget>
|
|||
class CenterWrap;
|
||||
class FlatLabel;
|
||||
class InputField;
|
||||
class LinkButton;
|
||||
class PasswordInput;
|
||||
class RoundButton;
|
||||
class VerticalLayout;
|
||||
|
@ -60,6 +61,10 @@ void SetupHeader(
|
|||
not_null<Ui::VerticalLayout*> content,
|
||||
rpl::producer<QString> &&text);
|
||||
|
||||
[[nodiscard]] not_null<Ui::LinkButton*> AddLinkButton(
|
||||
not_null<Ui::CenterWrap<Ui::InputField>*> wrap,
|
||||
rpl::producer<QString> &&text);
|
||||
|
||||
void AddSkipInsteadOfField(not_null<Ui::VerticalLayout*> content);
|
||||
void AddSkipInsteadOfError(not_null<Ui::VerticalLayout*> content);
|
||||
|
||||
|
|
|
@ -132,14 +132,9 @@ void Email::setupContent() {
|
|||
}));
|
||||
};
|
||||
|
||||
const auto skip = Ui::CreateChild<Ui::LinkButton>(
|
||||
this,
|
||||
tr::lng_cloud_password_skip_email(tr::now));
|
||||
wrap->geometryValue(
|
||||
) | rpl::start_with_next([=](QRect r) {
|
||||
r.translate(wrap->entity()->pos().x(), 0);
|
||||
skip->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
|
||||
}, skip->lifetime());
|
||||
const auto skip = AddLinkButton(
|
||||
wrap,
|
||||
tr::lng_cloud_password_skip_email());
|
||||
skip->setClickedCallback([=] {
|
||||
confirm(QString());
|
||||
});
|
||||
|
|
|
@ -96,14 +96,15 @@ void EmailConfirm::setupContent() {
|
|||
|
||||
AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip);
|
||||
|
||||
auto objectInput = object_ptr<Ui::SentCodeField>(
|
||||
content,
|
||||
st::settingLocalPasscodeInputField,
|
||||
tr::lng_change_phone_code_title());
|
||||
const auto newInput = objectInput.data();
|
||||
const auto wrap = content->add(
|
||||
object_ptr<Ui::CenterWrap<Ui::SentCodeField>>(
|
||||
object_ptr<Ui::CenterWrap<Ui::InputField>>(
|
||||
content,
|
||||
object_ptr<Ui::SentCodeField>(
|
||||
content,
|
||||
st::settingLocalPasscodeInputField,
|
||||
tr::lng_change_phone_code_title())));
|
||||
const auto newInput = wrap->entity();
|
||||
std::move(objectInput)));
|
||||
|
||||
const auto error = AddError(content, nullptr);
|
||||
QObject::connect(newInput, &Ui::InputField::changed, [=] {
|
||||
|
@ -127,14 +128,7 @@ void EmailConfirm::setupContent() {
|
|||
}
|
||||
}, resendInfo->lifetime());
|
||||
|
||||
const auto resend = Ui::CreateChild<Ui::LinkButton>(
|
||||
this,
|
||||
tr::lng_cloud_password_resend(tr::now));
|
||||
wrap->geometryValue(
|
||||
) | rpl::start_with_next([=](QRect r) {
|
||||
r.translate(wrap->entity()->pos().x(), 0);
|
||||
resend->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
|
||||
}, resend->lifetime());
|
||||
const auto resend = AddLinkButton(wrap, tr::lng_cloud_password_resend());
|
||||
resend->setClickedCallback([=] {
|
||||
if (_requestLifetime) {
|
||||
return;
|
||||
|
|
|
@ -67,15 +67,10 @@ void Hint::setupContent() {
|
|||
showOther(CloudPasswordEmailId());
|
||||
};
|
||||
|
||||
const auto skip = Ui::CreateChild<Ui::LinkButton>(
|
||||
this,
|
||||
tr::lng_settings_cloud_password_skip_hint(tr::now));
|
||||
wrap->geometryValue(
|
||||
) | rpl::start_with_next([=](QRect r) {
|
||||
r.translate(wrap->entity()->pos().x(), 0);
|
||||
skip->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
|
||||
}, skip->lifetime());
|
||||
skip->setClickedCallback([=] {
|
||||
AddLinkButton(
|
||||
wrap,
|
||||
tr::lng_settings_cloud_password_skip_hint()
|
||||
)->setClickedCallback([=] {
|
||||
save(QString());
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue