mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Always start with QR-code login.
This commit is contained in:
parent
52a6282eb9
commit
ae40ea9336
3 changed files with 20 additions and 50 deletions
|
@ -83,39 +83,25 @@ PhoneWidget::PhoneWidget(
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhoneWidget::setupQrLogin() {
|
void PhoneWidget::setupQrLogin() {
|
||||||
rpl::single(
|
const auto qrLogin = Ui::CreateChild<Ui::LinkButton>(
|
||||||
rpl::empty_value()
|
this,
|
||||||
) | rpl::then(
|
tr::lng_phone_to_qr(tr::now));
|
||||||
account().appConfig().refreshed()
|
qrLogin->show();
|
||||||
) | rpl::map([=] {
|
|
||||||
const auto result = account().appConfig().get<QString>(
|
|
||||||
"qr_login_code",
|
|
||||||
"[not-set]");
|
|
||||||
DEBUG_LOG(("PhoneWidget.qr_login_code: %1").arg(result));
|
|
||||||
return result;
|
|
||||||
}) | rpl::filter([](const QString &value) {
|
|
||||||
return (value != "disabled");
|
|
||||||
}) | rpl::take(1) | rpl::start_with_next([=] {
|
|
||||||
const auto qrLogin = Ui::CreateChild<Ui::LinkButton>(
|
|
||||||
this,
|
|
||||||
tr::lng_phone_to_qr(tr::now));
|
|
||||||
qrLogin->show();
|
|
||||||
|
|
||||||
DEBUG_LOG(("PhoneWidget.qrLogin link created and shown."));
|
DEBUG_LOG(("PhoneWidget.qrLogin link created and shown."));
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
sizeValue(),
|
sizeValue(),
|
||||||
qrLogin->widthValue()
|
qrLogin->widthValue()
|
||||||
) | rpl::start_with_next([=](QSize size, int qrLoginWidth) {
|
) | rpl::start_with_next([=](QSize size, int qrLoginWidth) {
|
||||||
qrLogin->moveToLeft(
|
qrLogin->moveToLeft(
|
||||||
(size.width() - qrLoginWidth) / 2,
|
(size.width() - qrLoginWidth) / 2,
|
||||||
contentTop() + st::introQrLoginLinkTop);
|
contentTop() + st::introQrLoginLinkTop);
|
||||||
}, qrLogin->lifetime());
|
}, qrLogin->lifetime());
|
||||||
|
|
||||||
qrLogin->setClickedCallback([=] {
|
qrLogin->setClickedCallback([=] {
|
||||||
goReplace<QrWidget>(Animate::Forward);
|
goReplace<QrWidget>(Animate::Forward);
|
||||||
});
|
});
|
||||||
}, lifetime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhoneWidget::resizeEvent(QResizeEvent *e) {
|
void PhoneWidget::resizeEvent(QResizeEvent *e) {
|
||||||
|
|
|
@ -31,15 +31,7 @@ StartWidget::StartWidget(
|
||||||
|
|
||||||
void StartWidget::submit() {
|
void StartWidget::submit() {
|
||||||
account().destroyStaleAuthorizationKeys();
|
account().destroyStaleAuthorizationKeys();
|
||||||
const auto qrLogin = account().appConfig().get<QString>(
|
goNext<QrWidget>();
|
||||||
"qr_login_code",
|
|
||||||
"[not-set]");
|
|
||||||
DEBUG_LOG(("qr_login_code: %1").arg(qrLogin));
|
|
||||||
if (qrLogin == "primary") {
|
|
||||||
goNext<QrWidget>();
|
|
||||||
} else {
|
|
||||||
goNext<PhoneWidget>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<QString> StartWidget::nextButtonText() const {
|
rpl::producer<QString> StartWidget::nextButtonText() const {
|
||||||
|
|
|
@ -238,17 +238,9 @@ void Controller::clearPasscodeLock() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setupIntro() {
|
void Controller::setupIntro() {
|
||||||
const auto parent = Core::App().domain().maybeLastOrSomeAuthedAccount();
|
_widget.setupIntro(Core::App().domain().maybeLastOrSomeAuthedAccount()
|
||||||
if (!parent) {
|
? Intro::EnterPoint::Qr
|
||||||
_widget.setupIntro(Intro::EnterPoint::Start);
|
: Intro::EnterPoint::Start);
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto qrLogin = parent->appConfig().get<QString>(
|
|
||||||
"qr_login_code",
|
|
||||||
"[not-set]");
|
|
||||||
DEBUG_LOG(("qr_login_code in setup: %1").arg(qrLogin));
|
|
||||||
const auto qr = (qrLogin == "primary");
|
|
||||||
_widget.setupIntro(qr ? Intro::EnterPoint::Qr : Intro::EnterPoint::Phone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setupMain() {
|
void Controller::setupMain() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue