2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-23 18:57:12 +00:00

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