tdesktop/Telegram/SourceFiles/intro/introcode.h

101 lines
2.1 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
#include "intro/introwidget.h"
#include "ui/widgets/input_fields.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 {
class CodeInput final : public Ui::MaskedInputField {
Q_OBJECT
public:
CodeInput(QWidget *parent, const style::InputField &st, Fn<QString()> placeholderFactory);
2016-11-24 19:28:23 +00:00
void setDigitsCountMax(int digitsCount);
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;
};
2016-11-24 19:28:23 +00:00
class CodeWidget : public Widget::Step {
Q_OBJECT
public:
2016-11-24 19:28:23 +00:00
CodeWidget(QWidget *parent, Widget::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 slots:
void onNoTelegramCode();
void onInputChange();
void onSendCall();
void onCheckRequest();
private:
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);
bool codeSubmitFail(const RPCError &error);
void showCodeError(Fn<QString()> textFactory);
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);
bool noTelegramCodeFail(const RPCError &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
object_ptr<QTimer> _callTimer;
2016-11-24 19:28:23 +00:00
Widget::Data::CallStatus _callStatus;
int _callTimeout;
mtpRequestId _callRequestId = 0;
object_ptr<Ui::FlatLabel> _callLabel;
object_ptr<QTimer> _checkRequest;
};
2016-11-24 19:28:23 +00:00
} // namespace Intro