tdesktop/Telegram/SourceFiles/intro/introcode.h

114 lines
2.8 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2015-10-03 13:16:42 +00:00
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#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, base::lambda<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(base::lambda<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