payments_form_summary.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include "styles/style_widgets.h"
  12. namespace Ui {
  13. class ScrollArea;
  14. class FadeShadow;
  15. class RoundButton;
  16. class VerticalLayout;
  17. } // namespace Ui
  18. namespace Payments::Ui {
  19. using namespace ::Ui;
  20. class PanelDelegate;
  21. class FormSummary final : public RpWidget {
  22. public:
  23. FormSummary(
  24. QWidget *parent,
  25. const Invoice &invoice,
  26. const RequestedInformation &current,
  27. const PaymentMethodDetails &method,
  28. const ShippingOptions &options,
  29. not_null<PanelDelegate*> delegate,
  30. int scrollTop);
  31. void updateThumbnail(const QImage &thumbnail);
  32. [[nodiscard]] rpl::producer<int> scrollTopValue() const;
  33. bool showCriticalError(const TextWithEntities &text);
  34. [[nodiscard]] int contentHeight() const;
  35. private:
  36. void resizeEvent(QResizeEvent *e) override;
  37. void setupControls();
  38. void setupContent(not_null<VerticalLayout*> layout);
  39. void setupCover(not_null<VerticalLayout*> layout);
  40. void setupPrices(not_null<VerticalLayout*> layout);
  41. void setupSuggestedTips(not_null<VerticalLayout*> layout);
  42. void setupSections(not_null<VerticalLayout*> layout);
  43. void updateControlsGeometry();
  44. [[nodiscard]] QString formatAmount(
  45. int64 amount,
  46. bool forceStripDotZero = false) const;
  47. [[nodiscard]] int64 computeTotalAmount() const;
  48. const not_null<PanelDelegate*> _delegate;
  49. Invoice _invoice;
  50. PaymentMethodDetails _method;
  51. ShippingOptions _options;
  52. RequestedInformation _information;
  53. object_ptr<ScrollArea> _scroll;
  54. not_null<VerticalLayout*> _layout;
  55. object_ptr<FadeShadow> _topShadow;
  56. object_ptr<FadeShadow> _bottomShadow;
  57. object_ptr<RoundButton> _submit;
  58. object_ptr<RoundButton> _cancel;
  59. rpl::event_stream<QImage> _thumbnails;
  60. style::complex_color _tipLightBg;
  61. style::complex_color _tipLightRipple;
  62. style::complex_color _tipChosenBg;
  63. style::complex_color _tipChosenRipple;
  64. style::RoundButton _tipButton;
  65. style::RoundButton _tipChosen;
  66. int _initialScrollTop = 0;
  67. };
  68. } // namespace Payments::Ui