payments_panel.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 "base/object_ptr.h"
  9. #include "base/weak_ptr.h"
  10. namespace Ui {
  11. class Show;
  12. class RpWidget;
  13. class SeparatePanel;
  14. class BoxContent;
  15. class Checkbox;
  16. } // namespace Ui
  17. namespace Webview {
  18. struct Available;
  19. struct ThemeParams;
  20. } // namespace Webview
  21. namespace Payments::Ui {
  22. using namespace ::Ui;
  23. class PanelDelegate;
  24. struct Invoice;
  25. struct RequestedInformation;
  26. struct ShippingOptions;
  27. enum class InformationField;
  28. enum class CardField;
  29. class FormSummary;
  30. class EditInformation;
  31. class EditCard;
  32. struct PaymentMethodDetails;
  33. struct PaymentMethodAdditional;
  34. struct NativeMethodDetails;
  35. class Panel final : public base::has_weak_ptr {
  36. public:
  37. explicit Panel(not_null<PanelDelegate*> delegate);
  38. ~Panel();
  39. void requestActivate();
  40. void toggleProgress(bool shown);
  41. void showForm(
  42. const Invoice &invoice,
  43. const RequestedInformation &current,
  44. const PaymentMethodDetails &method,
  45. const ShippingOptions &options);
  46. void updateFormThumbnail(const QImage &thumbnail);
  47. void showEditInformation(
  48. const Invoice &invoice,
  49. const RequestedInformation &current,
  50. InformationField field);
  51. void showInformationError(
  52. const Invoice &invoice,
  53. const RequestedInformation &current,
  54. InformationField field);
  55. void showEditPaymentMethod(const PaymentMethodDetails &method);
  56. void showAdditionalMethod(
  57. const PaymentMethodAdditional &method,
  58. const QString &provider,
  59. bool canSaveInformation);
  60. void showEditCard(const NativeMethodDetails &native, CardField field);
  61. void showEditCardByUrl(
  62. const QString &url,
  63. const QString &provider,
  64. bool canSaveInformation);
  65. void showCardError(const NativeMethodDetails &native, CardField field);
  66. void chooseShippingOption(const ShippingOptions &options);
  67. void chooseTips(const Invoice &invoice);
  68. void choosePaymentMethod(const PaymentMethodDetails &method);
  69. void askSetPassword();
  70. void showCloseConfirm();
  71. void showWarning(const QString &bot, const QString &provider);
  72. void requestTermsAcceptance(
  73. const QString &username,
  74. const QString &url,
  75. bool recurring);
  76. bool showWebview(
  77. const QString &url,
  78. bool allowBack,
  79. rpl::producer<QString> bottomText);
  80. void updateThemeParams(const Webview::ThemeParams &params);
  81. [[nodiscard]] rpl::producer<> backRequests() const;
  82. [[nodiscard]] rpl::producer<QString> savedMethodChosen() const;
  83. void showBox(object_ptr<Ui::BoxContent> box);
  84. void showToast(TextWithEntities &&text);
  85. void showCriticalError(const TextWithEntities &text);
  86. [[nodiscard]] std::shared_ptr<Show> uiShow();
  87. [[nodiscard]] rpl::lifetime &lifetime();
  88. private:
  89. struct Progress;
  90. struct WebviewWithLifetime;
  91. bool createWebview(const Webview::ThemeParams &params);
  92. void showWebviewProgress();
  93. void hideWebviewProgress();
  94. void showWebviewError(
  95. const QString &text,
  96. const Webview::Available &information);
  97. void setTitle(rpl::producer<QString> title);
  98. [[nodiscard]] bool progressWithBackground() const;
  99. [[nodiscard]] QRect progressRect() const;
  100. void setupProgressGeometry();
  101. void updateFooterHeight();
  102. const not_null<PanelDelegate*> _delegate;
  103. std::unique_ptr<SeparatePanel> _widget;
  104. std::unique_ptr<WebviewWithLifetime> _webview;
  105. std::unique_ptr<RpWidget> _webviewBottom;
  106. rpl::variable<int> _footerHeight;
  107. std::unique_ptr<Progress> _progress;
  108. QPointer<Checkbox> _saveWebviewInformation;
  109. QPointer<FormSummary> _weakFormSummary;
  110. rpl::variable<int> _formScrollTop;
  111. QPointer<EditInformation> _weakEditInformation;
  112. QPointer<EditCard> _weakEditCard;
  113. rpl::event_stream<QString> _savedMethodChosen;
  114. bool _themeUpdateScheduled = false;
  115. bool _webviewProgress = false;
  116. bool _testMode = false;
  117. };
  118. } // namespace Payments::Ui