intro_phone.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 "ui/countryinput.h"
  9. #include "intro/intro_step.h"
  10. #include "base/timer.h"
  11. namespace Ui {
  12. class PhonePartInput;
  13. class CountryCodeInput;
  14. class RoundButton;
  15. class FlatLabel;
  16. } // namespace Ui
  17. namespace Intro {
  18. namespace details {
  19. class PhoneWidget final : public Step {
  20. public:
  21. PhoneWidget(
  22. QWidget *parent,
  23. not_null<Main::Account*> account,
  24. not_null<Data*> data);
  25. void selectCountry(const QString &country);
  26. void setInnerFocus() override;
  27. void activate() override;
  28. void finished() override;
  29. void cancelled() override;
  30. void submit() override;
  31. bool hasBack() const override {
  32. return true;
  33. }
  34. protected:
  35. void resizeEvent(QResizeEvent *e) override;
  36. private:
  37. void setupQrLogin();
  38. void phoneChanged();
  39. void checkRequest();
  40. void countryChanged();
  41. void phoneSubmitDone(const MTPauth_SentCode &result);
  42. void phoneSubmitFail(const MTP::Error &error);
  43. QString fullNumber() const;
  44. void stopCheck();
  45. void showPhoneError(rpl::producer<QString> text);
  46. void hidePhoneError();
  47. bool _changed = false;
  48. object_ptr<CountryInput> _country;
  49. object_ptr<Ui::CountryCodeInput> _code;
  50. object_ptr<Ui::PhonePartInput> _phone;
  51. QString _sentPhone;
  52. mtpRequestId _sentRequest = 0;
  53. base::Timer _checkRequestTimer;
  54. };
  55. } // namespace details
  56. } // namespace Intro