tdesktop/Telegram/SourceFiles/intro/intro_code.h

107 lines
2.2 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
2019-11-26 11:10:44 +00:00
#include "intro/intro_step.h"
2019-11-27 09:45:23 +00:00
#include "intro/intro_widget.h"
#include "ui/widgets/input_fields.h"
2019-11-27 08:33:18 +00:00
#include "base/timer.h"
namespace Ui {
class RoundButton;
class LinkButton;
2016-11-24 19:28:23 +00:00
class FlatLabel;
} // namespace Ui
2016-11-24 19:28:23 +00:00
namespace Intro {
2019-11-26 11:10:44 +00:00
namespace details {
enum class CallStatus;
2016-11-24 19:28:23 +00:00
class CodeInput final : public Ui::MaskedInputField {
public:
CodeInput(
QWidget *parent,
const style::InputField &st,
rpl::producer<QString> placeholder);
2016-11-24 19:28:23 +00:00
void setDigitsCountMax(int digitsCount);
protected:
2016-11-24 19:28:23 +00:00
void correctValue(const QString &was, int wasCursor, QString &now, int &nowCursor) override;
private:
int _digitsCountMax = 5;
};
2019-11-27 08:33:18 +00:00
class CodeWidget final : public Step {
public:
2019-07-24 08:46:23 +00:00
CodeWidget(
QWidget *parent,
not_null<Main::Account*> account,
2019-11-26 11:10:44 +00:00
not_null<Data*> data);
bool hasBack() const override {
return true;
}
2016-11-24 19:28:23 +00:00
void setInnerFocus() override;
void activate() override;
void finished() override;
void cancelled() override;
2016-11-24 19:28:23 +00:00
void submit() override;
void updateDescText();
2016-11-24 19:28:23 +00:00
protected:
void resizeEvent(QResizeEvent *e) override;
private:
2019-11-27 08:33:18 +00:00
void noTelegramCode();
void codeChanged();
void sendCall();
void checkRequest();
2019-11-26 14:27:09 +00:00
int errorTop() const override;
2016-11-24 19:28:23 +00:00
void updateCallText();
void refreshLang();
void updateControlsGeometry();
2016-11-24 19:28:23 +00:00
void codeSubmitDone(const MTPauth_Authorization &result);
2021-03-12 12:48:00 +00:00
void codeSubmitFail(const MTP::Error &error);
2016-11-24 19:28:23 +00:00
void showCodeError(rpl::producer<QString> text);
2016-03-15 19:38:30 +00:00
void callDone(const MTPauth_SentCode &v);
void gotPassword(const MTPaccount_Password &result);
void noTelegramCodeDone(const MTPauth_SentCode &result);
2021-03-12 12:48:00 +00:00
void noTelegramCodeFail(const MTP::Error &result);
void stopCheck();
object_ptr<Ui::LinkButton> _noTelegramCode;
2016-11-24 19:28:23 +00:00
mtpRequestId _noTelegramCodeRequestId = 0;
object_ptr<CodeInput> _code;
QString _sentCode;
mtpRequestId _sentRequest = 0;
2016-11-24 19:28:23 +00:00
2019-11-27 08:33:18 +00:00
base::Timer _callTimer;
2019-11-26 11:10:44 +00:00
CallStatus _callStatus = CallStatus();
2016-11-24 19:28:23 +00:00
int _callTimeout;
mtpRequestId _callRequestId = 0;
object_ptr<Ui::FlatLabel> _callLabel;
2019-11-27 08:33:18 +00:00
base::Timer _checkRequestTimer;
};
2016-11-24 19:28:23 +00:00
2019-11-26 11:10:44 +00:00
} // namespace details
2016-11-24 19:28:23 +00:00
} // namespace Intro