tdesktop/Telegram/SourceFiles/ui/boxes/confirm_phone_box.h

67 lines
1.5 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
2017-04-06 14:38:10 +00:00
#include "boxes/abstract_box.h"
2021-10-18 15:48:46 +00:00
#include "ui/widgets/sent_code_field.h"
namespace Ui {
2021-10-18 22:43:50 +00:00
class FlatLabel;
class ConfirmPhoneBox final : public Ui::BoxContent {
public:
ConfirmPhoneBox(
QWidget*,
const QString &phone,
int codeLength,
std::optional<int> timeout);
[[nodiscard]] rpl::producer<QString> checkRequests() const;
[[nodiscard]] rpl::producer<> resendRequests() const;
void callDone();
void showServerError(const QString &text);
protected:
void prepare() override;
void setInnerFocus() override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private:
void sendCode();
void sendCall();
void checkPhoneAndHash();
QString getPhone() const;
void showError(const QString &error);
// _hash from the link for account.sendConfirmPhoneCode call.
// _phoneHash from auth.sentCode for account.confirmPhone call.
const QString _phone;
// If we receive the code length, we autosubmit _code field when enough symbols is typed.
const int _sentCodeLength = 0;
bool _isWaitingCheck = false;
object_ptr<Ui::FlatLabel> _about = { nullptr };
2021-10-18 15:48:46 +00:00
object_ptr<Ui::SentCodeField> _code = { nullptr };
QString _error;
2021-10-18 15:48:46 +00:00
Ui::SentCodeCall _call;
rpl::event_stream<QString> _checkRequests;
rpl::event_stream<> _resendRequests;
};
2021-10-18 22:43:50 +00:00
} // namespace Ui