mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added button for opening custom url to Ui::ConfirmPhoneBox.
This commit is contained in:
parent
44f79b8331
commit
613d4932ca
3 changed files with 39 additions and 5 deletions
|
@ -58,6 +58,10 @@ void ConfirmPhone::resolve(
|
|||
}, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) {
|
||||
return bad("SetUpEmailRequired");
|
||||
});
|
||||
const auto fragmentUrl = data.vtype().match([](
|
||||
const MTPDauth_sentCodeTypeFragmentSms &data) {
|
||||
return qs(data.vurl());
|
||||
}, [](const auto &) { return QString(); });
|
||||
const auto phoneHash = qs(data.vphone_code_hash());
|
||||
const auto timeout = [&]() -> std::optional<int> {
|
||||
if (const auto nextType = data.vnext_type()) {
|
||||
|
@ -70,6 +74,7 @@ void ConfirmPhone::resolve(
|
|||
auto box = Box<Ui::ConfirmPhoneBox>(
|
||||
phone,
|
||||
sentCodeLength,
|
||||
fragmentUrl,
|
||||
timeout);
|
||||
const auto boxWeak = Ui::MakeWeak(box.data());
|
||||
box->resendRequests(
|
||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "ui/boxes/confirm_phone_box.h"
|
||||
|
||||
#include "core/file_utilities.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
|
@ -22,10 +23,20 @@ ConfirmPhoneBox::ConfirmPhoneBox(
|
|||
QWidget*,
|
||||
const QString &phone,
|
||||
int codeLength,
|
||||
const QString &openUrl,
|
||||
std::optional<int> timeout)
|
||||
: _phone(phone)
|
||||
, _sentCodeLength(codeLength)
|
||||
, _call([this] { sendCall(); }, [this] { update(); }) {
|
||||
, _call([=] { sendCall(); }, [=] { update(); }) {
|
||||
if (!openUrl.isEmpty()) {
|
||||
_fragment.create(
|
||||
this,
|
||||
tr::lng_intro_fragment_button(),
|
||||
st::fragmentBoxButton);
|
||||
_fragment->setClickedCallback([=] { File::OpenUrl(openUrl); });
|
||||
_fragment->setTextTransform(
|
||||
Ui::RoundButton::TextTransform::NoTransform);
|
||||
}
|
||||
if (timeout) {
|
||||
_call.setStatus({ Ui::SentCodeCall::State::Waiting, *timeout });
|
||||
}
|
||||
|
@ -59,7 +70,8 @@ void ConfirmPhoneBox::prepare() {
|
|||
+ _code->height()
|
||||
+ st::usernameSkip
|
||||
+ _about->height()
|
||||
+ st::usernameSkip);
|
||||
+ st::usernameSkip
|
||||
+ (_fragment ? (_fragment->height() + fragmentSkip()) : 0));
|
||||
|
||||
connect(_code, &Ui::InputField::submitted, [=] { sendCode(); });
|
||||
|
||||
|
@ -132,15 +144,27 @@ void ConfirmPhoneBox::resizeEvent(QResizeEvent *e) {
|
|||
_code->height());
|
||||
_code->moveToLeft(st::usernamePadding.left(), st::usernamePadding.top());
|
||||
|
||||
_about->moveToLeft(
|
||||
st::usernamePadding.left(),
|
||||
_code->y() + _code->height() + st::usernameSkip);
|
||||
if (_fragment) {
|
||||
_fragment->setFullWidth(_code->width());
|
||||
_fragment->moveToLeft(
|
||||
(width() - _fragment->width()) / 2,
|
||||
_code->y() + _code->height() + st::usernameSkip);
|
||||
}
|
||||
|
||||
const auto aboutTop = _fragment
|
||||
? (_fragment->y() + _fragment->height() + fragmentSkip())
|
||||
: (_code->y() + _code->height() + st::usernameSkip);
|
||||
_about->moveToLeft(st::usernamePadding.left(), aboutTop);
|
||||
}
|
||||
|
||||
void ConfirmPhoneBox::setInnerFocus() {
|
||||
_code->setFocusFast();
|
||||
}
|
||||
|
||||
int ConfirmPhoneBox::fragmentSkip() const {
|
||||
return st::usernamePadding.bottom();
|
||||
}
|
||||
|
||||
rpl::producer<QString> ConfirmPhoneBox::checkRequests() const {
|
||||
return _checkRequests.events();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Ui {
|
||||
|
||||
class FlatLabel;
|
||||
class RoundButton;
|
||||
|
||||
class ConfirmPhoneBox final : public Ui::BoxContent {
|
||||
public:
|
||||
|
@ -20,6 +21,7 @@ public:
|
|||
QWidget*,
|
||||
const QString &phone,
|
||||
int codeLength,
|
||||
const QString &openUrl,
|
||||
std::optional<int> timeout);
|
||||
|
||||
[[nodiscard]] rpl::producer<QString> checkRequests() const;
|
||||
|
@ -40,6 +42,8 @@ private:
|
|||
void sendCall();
|
||||
void checkPhoneAndHash();
|
||||
|
||||
[[nodiscard]] int fragmentSkip() const;
|
||||
|
||||
QString getPhone() const;
|
||||
void showError(const QString &error);
|
||||
|
||||
|
@ -54,6 +58,7 @@ private:
|
|||
|
||||
object_ptr<Ui::FlatLabel> _about = { nullptr };
|
||||
object_ptr<Ui::SentCodeField> _code = { nullptr };
|
||||
object_ptr<Ui::RoundButton> _fragment = { nullptr };
|
||||
|
||||
QString _error;
|
||||
Ui::SentCodeCall _call;
|
||||
|
|
Loading…
Add table
Reference in a new issue