intro_code.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "intro/intro_step.h"
  9. #include "intro/intro_widget.h"
  10. #include "ui/widgets/fields/masked_input_field.h"
  11. #include "base/timer.h"
  12. namespace Ui {
  13. class RoundButton;
  14. class LinkButton;
  15. class FlatLabel;
  16. class CodeInput;
  17. } // namespace Ui
  18. namespace Intro {
  19. namespace details {
  20. enum class CallStatus;
  21. class CodeWidget final : public Step {
  22. public:
  23. CodeWidget(
  24. QWidget *parent,
  25. not_null<Main::Account*> account,
  26. not_null<Data*> data);
  27. bool hasBack() const override {
  28. return true;
  29. }
  30. void setInnerFocus() override;
  31. void activate() override;
  32. void finished() override;
  33. void cancelled() override;
  34. void submit() override;
  35. rpl::producer<QString> nextButtonText() const override;
  36. rpl::producer<const style::RoundButton*> nextButtonStyle() const override;
  37. void updateDescText();
  38. protected:
  39. void resizeEvent(QResizeEvent *e) override;
  40. private:
  41. void noTelegramCode();
  42. void sendCall();
  43. void checkRequest();
  44. int errorTop() const override;
  45. void updateCallText();
  46. void refreshLang();
  47. void updateControlsGeometry();
  48. void codeSubmitDone(const MTPauth_Authorization &result);
  49. void codeSubmitFail(const MTP::Error &error);
  50. void showCodeError(rpl::producer<QString> text);
  51. void callDone(const MTPauth_SentCode &result);
  52. void gotPassword(const MTPaccount_Password &result);
  53. void noTelegramCodeDone(const MTPauth_SentCode &result);
  54. void noTelegramCodeFail(const MTP::Error &result);
  55. void submitCode(const QString &text);
  56. void stopCheck();
  57. object_ptr<Ui::LinkButton> _noTelegramCode;
  58. mtpRequestId _noTelegramCodeRequestId = 0;
  59. object_ptr<Ui::CodeInput> _code;
  60. QString _sentCode;
  61. mtpRequestId _sentRequest = 0;
  62. rpl::variable<bool> _isFragment = false;
  63. base::Timer _callTimer;
  64. CallStatus _callStatus = CallStatus();
  65. int _callTimeout;
  66. mtpRequestId _callRequestId = 0;
  67. object_ptr<Ui::FlatLabel> _callLabel;
  68. base::Timer _checkRequestTimer;
  69. };
  70. } // namespace details
  71. } // namespace Intro