payments_edit_card.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/rp_widget.h"
  9. #include "payments/ui/payments_panel_data.h"
  10. #include "base/object_ptr.h"
  11. namespace Ui {
  12. class ScrollArea;
  13. class FadeShadow;
  14. class RoundButton;
  15. class Checkbox;
  16. } // namespace Ui
  17. namespace Payments::Ui {
  18. using namespace ::Ui;
  19. class PanelDelegate;
  20. class Field;
  21. class EditCard final : public RpWidget {
  22. public:
  23. EditCard(
  24. QWidget *parent,
  25. const NativeMethodDetails &native,
  26. CardField field,
  27. not_null<PanelDelegate*> delegate);
  28. void setFocus(CardField field);
  29. void setFocusFast(CardField field);
  30. void showError(CardField field);
  31. private:
  32. void resizeEvent(QResizeEvent *e) override;
  33. void focusInEvent(QFocusEvent *e) override;
  34. void setupControls();
  35. [[nodiscard]] not_null<Ui::RpWidget*> setupContent();
  36. void updateControlsGeometry();
  37. [[nodiscard]] Field *lookupField(CardField field) const;
  38. [[nodiscard]] UncheckedCardDetails collect() const;
  39. const not_null<PanelDelegate*> _delegate;
  40. NativeMethodDetails _native;
  41. object_ptr<ScrollArea> _scroll;
  42. object_ptr<FadeShadow> _topShadow;
  43. object_ptr<FadeShadow> _bottomShadow;
  44. object_ptr<RoundButton> _submit;
  45. object_ptr<RoundButton> _cancel;
  46. std::unique_ptr<Field> _number;
  47. std::unique_ptr<Field> _cvc;
  48. std::unique_ptr<Field> _expire;
  49. std::unique_ptr<Field> _name;
  50. std::unique_ptr<Field> _country;
  51. std::unique_ptr<Field> _zip;
  52. Checkbox *_save = nullptr;
  53. CardField _focusField = CardField::Number;
  54. };
  55. } // namespace Payments::Ui