tdesktop/Telegram/SourceFiles/intro/intro_code.h

96 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
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/fields/masked_input_field.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;
class CodeInput;
} // 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
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;
rpl::producer<QString> nextButtonText() const override;
rpl::producer<const style::RoundButton*> nextButtonStyle() const 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 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);
2023-01-10 13:10:34 +00:00
void callDone(const MTPauth_SentCode &result);
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 submitCode(const QString &text);
void stopCheck();
object_ptr<Ui::LinkButton> _noTelegramCode;
2016-11-24 19:28:23 +00:00
mtpRequestId _noTelegramCodeRequestId = 0;
object_ptr<Ui::CodeInput> _code;
QString _sentCode;
mtpRequestId _sentRequest = 0;
2016-11-24 19:28:23 +00:00
rpl::variable<bool> _isFragment = false;
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