2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
#include "intro/introwidget.h"
|
2016-11-15 11:56:49 +00:00
|
|
|
#include "ui/widgets/input_fields.h"
|
2016-11-11 13:46:04 +00:00
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
namespace Ui {
|
|
|
|
class RoundButton;
|
2016-11-11 13:46:04 +00:00
|
|
|
class LinkButton;
|
2016-11-24 19:28:23 +00:00
|
|
|
class FlatLabel;
|
2016-11-04 19:50:35 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
namespace Intro {
|
|
|
|
|
|
|
|
class CodeInput final : public Ui::MaskedInputField {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-06-04 15:35:11 +00:00
|
|
|
CodeInput(QWidget *parent, const style::InputField &st, Fn<QString()> placeholderFactory);
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
void setDigitsCountMax(int digitsCount);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void codeEntered();
|
|
|
|
|
|
|
|
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;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
class CodeWidget : public Widget::Step {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-11-24 19:28:23 +00:00
|
|
|
CodeWidget(QWidget *parent, Widget::Data *data);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-21 18:41:39 +00:00
|
|
|
bool hasBack() const override {
|
2014-11-26 16:45:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-11-24 19:28:23 +00:00
|
|
|
void setInnerFocus() override;
|
2016-03-14 16:59:18 +00:00
|
|
|
void activate() override;
|
|
|
|
void finished() override;
|
|
|
|
void cancelled() override;
|
2016-11-24 19:28:23 +00:00
|
|
|
void submit() override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-08-31 14:27:20 +00:00
|
|
|
void updateDescText();
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
|
|
|
private slots:
|
2015-08-31 14:27:20 +00:00
|
|
|
void onNoTelegramCode();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onInputChange();
|
|
|
|
void onSendCall();
|
|
|
|
void onCheckRequest();
|
|
|
|
|
|
|
|
private:
|
2016-11-24 19:28:23 +00:00
|
|
|
void updateCallText();
|
2017-05-30 13:54:05 +00:00
|
|
|
void refreshLang();
|
|
|
|
void updateControlsGeometry();
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
void codeSubmitDone(const MTPauth_Authorization &result);
|
|
|
|
bool codeSubmitFail(const RPCError &error);
|
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
void showCodeError(Fn<QString()> textFactory);
|
2016-03-15 19:38:30 +00:00
|
|
|
void callDone(const MTPauth_SentCode &v);
|
2015-04-02 10:33:19 +00:00
|
|
|
void gotPassword(const MTPaccount_Password &result);
|
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
void noTelegramCodeDone(const MTPauth_SentCode &result);
|
|
|
|
bool noTelegramCodeFail(const RPCError &result);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void stopCheck();
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::LinkButton> _noTelegramCode;
|
2016-11-24 19:28:23 +00:00
|
|
|
mtpRequestId _noTelegramCodeRequestId = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<CodeInput> _code;
|
2016-11-04 19:50:35 +00:00
|
|
|
QString _sentCode;
|
|
|
|
mtpRequestId _sentRequest = 0;
|
2016-11-24 19:28:23 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<QTimer> _callTimer;
|
2016-11-24 19:28:23 +00:00
|
|
|
Widget::Data::CallStatus _callStatus;
|
|
|
|
int _callTimeout;
|
|
|
|
mtpRequestId _callRequestId = 0;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _callLabel;
|
2015-08-31 14:27:20 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<QTimer> _checkRequest;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
} // namespace Intro
|