settings_credits_graphics.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. template <typename Object>
  9. class object_ptr;
  10. class PeerData;
  11. struct ShareBoxStyleOverrides;
  12. namespace ChatHelpers {
  13. class Show;
  14. } // namespace ChatHelpers
  15. namespace Data {
  16. struct Boost;
  17. struct CreditsHistoryEntry;
  18. struct SubscriptionEntry;
  19. struct GiftCode;
  20. struct CreditTopupOption;
  21. struct SavedStarGift;
  22. class SavedStarGiftId;
  23. struct StarGift;
  24. } // namespace Data
  25. namespace HistoryView {
  26. struct ScheduleBoxStyleArgs;
  27. } // namespace HistoryView
  28. namespace Main {
  29. class Session;
  30. class SessionShow;
  31. } // namespace Main
  32. namespace Window {
  33. class SessionController;
  34. } // namespace Window
  35. namespace style {
  36. struct Box;
  37. struct Table;
  38. struct FlatLabel;
  39. struct PopupMenu;
  40. struct PeerListItem;
  41. } // namespace style
  42. namespace Ui {
  43. class GenericBox;
  44. class RpWidget;
  45. class VerticalLayout;
  46. class PopupMenu;
  47. } // namespace Ui
  48. namespace Settings {
  49. struct SubscriptionRightLabel {
  50. Fn<void(QPainter &, int x, int y, int h)> draw;
  51. QSize size;
  52. };
  53. SubscriptionRightLabel PaintSubscriptionRightLabelCallback(
  54. not_null<Main::Session*> session,
  55. const style::PeerListItem &st,
  56. int amount);
  57. void FillCreditOptions(
  58. std::shared_ptr<Main::SessionShow> show,
  59. not_null<Ui::VerticalLayout*> container,
  60. not_null<PeerData*> peer,
  61. StarsAmount minCredits,
  62. Fn<void()> paid,
  63. rpl::producer<QString> subtitle,
  64. std::vector<Data::CreditTopupOption> preloadedTopupOptions);
  65. [[nodiscard]] not_null<Ui::RpWidget*> AddBalanceWidget(
  66. not_null<Ui::RpWidget*> parent,
  67. rpl::producer<StarsAmount> balanceValue,
  68. bool rightAlign,
  69. rpl::producer<float64> opacityValue = nullptr);
  70. void AddWithdrawalWidget(
  71. not_null<Ui::VerticalLayout*> container,
  72. not_null<Window::SessionController*> controller,
  73. not_null<PeerData*> peer,
  74. rpl::producer<QString> secondButtonUrl,
  75. rpl::producer<StarsAmount> availableBalanceValue,
  76. rpl::producer<QDateTime> dateValue,
  77. bool withdrawalEnabled,
  78. rpl::producer<QString> usdValue);
  79. struct GiftWearBoxStyleOverride {
  80. const style::Box *box = nullptr;
  81. const style::FlatLabel *title = nullptr;
  82. const style::FlatLabel *subtitle = nullptr;
  83. const style::icon *radiantIcon = nullptr;
  84. const style::icon *proofIcon = nullptr;
  85. const style::FlatLabel *infoTitle = nullptr;
  86. const style::FlatLabel *infoAbout = nullptr;
  87. };
  88. [[nodiscard]] GiftWearBoxStyleOverride DarkGiftWearBoxStyle();
  89. struct CreditsEntryBoxStyleOverrides {
  90. const style::Box *box = nullptr;
  91. const style::PopupMenu *menu = nullptr;
  92. const style::Table *table = nullptr;
  93. const style::FlatLabel *tableValueMultiline = nullptr;
  94. const style::FlatLabel *tableValueMessage = nullptr;
  95. const style::icon *link = nullptr;
  96. const style::icon *share = nullptr;
  97. const style::icon *transfer = nullptr;
  98. const style::icon *wear = nullptr;
  99. const style::icon *takeoff = nullptr;
  100. const style::icon *show = nullptr;
  101. const style::icon *hide = nullptr;
  102. const style::icon *pin = nullptr;
  103. const style::icon *unpin = nullptr;
  104. std::shared_ptr<ShareBoxStyleOverrides> shareBox;
  105. std::shared_ptr<GiftWearBoxStyleOverride> giftWearBox;
  106. };
  107. [[nodiscard]] CreditsEntryBoxStyleOverrides DarkCreditsEntryBoxStyle();
  108. void GenericCreditsEntryBox(
  109. not_null<Ui::GenericBox*> box,
  110. std::shared_ptr<ChatHelpers::Show> show,
  111. const Data::CreditsHistoryEntry &e,
  112. const Data::SubscriptionEntry &s,
  113. CreditsEntryBoxStyleOverrides st = {});
  114. void ReceiptCreditsBox(
  115. not_null<Ui::GenericBox*> box,
  116. not_null<Window::SessionController*> controller,
  117. const Data::CreditsHistoryEntry &e,
  118. const Data::SubscriptionEntry &s);
  119. void BoostCreditsBox(
  120. not_null<Ui::GenericBox*> box,
  121. not_null<Window::SessionController*> controller,
  122. const Data::Boost &b);
  123. void GiftedCreditsBox(
  124. not_null<Ui::GenericBox*> box,
  125. not_null<Window::SessionController*> controller,
  126. not_null<PeerData*> from,
  127. not_null<PeerData*> to,
  128. int count,
  129. TimeId date);
  130. void CreditsPrizeBox(
  131. not_null<Ui::GenericBox*> box,
  132. not_null<Window::SessionController*> controller,
  133. const Data::GiftCode &data,
  134. TimeId date);
  135. void GlobalStarGiftBox(
  136. not_null<Ui::GenericBox*> box,
  137. std::shared_ptr<ChatHelpers::Show> show,
  138. const Data::StarGift &data,
  139. CreditsEntryBoxStyleOverrides st = {});
  140. [[nodiscard]] Data::CreditsHistoryEntry SavedStarGiftEntry(
  141. not_null<PeerData*> owner,
  142. const Data::SavedStarGift &data);
  143. [[nodiscard]] Data::SavedStarGiftId EntryToSavedStarGiftId(
  144. not_null<Main::Session*> session,
  145. const Data::CreditsHistoryEntry &entry);
  146. void SavedStarGiftBox(
  147. not_null<Ui::GenericBox*> box,
  148. not_null<Window::SessionController*> controller,
  149. not_null<PeerData*> owner,
  150. const Data::SavedStarGift &data,
  151. Fn<std::vector<Data::CreditsHistoryEntry>()> pinned = nullptr);
  152. enum class SavedStarGiftMenuType {
  153. List,
  154. View,
  155. };
  156. void FillSavedStarGiftMenu(
  157. std::shared_ptr<ChatHelpers::Show> show,
  158. not_null<Ui::PopupMenu*> menu,
  159. const Data::CreditsHistoryEntry &e,
  160. SavedStarGiftMenuType type,
  161. CreditsEntryBoxStyleOverrides st = {});
  162. void StarGiftViewBox(
  163. not_null<Ui::GenericBox*> box,
  164. not_null<Window::SessionController*> controller,
  165. const Data::GiftCode &data,
  166. not_null<HistoryItem*> item);
  167. void ShowRefundInfoBox(
  168. not_null<Window::SessionController*> controller,
  169. FullMsgId refundItemId);
  170. [[nodiscard]] object_ptr<Ui::RpWidget> GenericEntryPhoto(
  171. not_null<Ui::RpWidget*> parent,
  172. Fn<Fn<void(Painter &, int, int, int, int)>(Fn<void()> update)> callback,
  173. int photoSize);
  174. [[nodiscard]] object_ptr<Ui::RpWidget> HistoryEntryPhoto(
  175. not_null<Ui::RpWidget*> parent,
  176. not_null<PhotoData*> photo,
  177. int photoSize);
  178. [[nodiscard]] object_ptr<Ui::RpWidget> PaidMediaThumbnail(
  179. not_null<Ui::RpWidget*> parent,
  180. not_null<PhotoData*> photo,
  181. PhotoData *second,
  182. int totalCount,
  183. int photoSize);
  184. [[nodiscard]] object_ptr<Ui::RpWidget> SubscriptionUserpic(
  185. not_null<Ui::RpWidget*> parent,
  186. not_null<PeerData*> peer,
  187. int photoSize);
  188. struct SmallBalanceBot {
  189. UserId botId = 0;
  190. };
  191. struct SmallBalanceReaction {
  192. ChannelId channelId = 0;
  193. };
  194. struct SmallBalanceSubscription {
  195. QString name;
  196. };
  197. struct SmallBalanceDeepLink {
  198. QString purpose;
  199. };
  200. struct SmallBalanceStarGift {
  201. PeerId recipientId;
  202. };
  203. struct SmallBalanceForMessage {
  204. PeerId recipientId;
  205. };
  206. struct SmallBalanceSource : std::variant<
  207. SmallBalanceBot,
  208. SmallBalanceReaction,
  209. SmallBalanceSubscription,
  210. SmallBalanceDeepLink,
  211. SmallBalanceStarGift,
  212. SmallBalanceForMessage> {
  213. using variant::variant;
  214. };
  215. void SmallBalanceBox(
  216. not_null<Ui::GenericBox*> box,
  217. std::shared_ptr<Main::SessionShow> show,
  218. uint64 wholeCredits,
  219. SmallBalanceSource source,
  220. Fn<void()> paid);
  221. enum class SmallBalanceResult {
  222. Already,
  223. Success,
  224. Blocked,
  225. Cancelled,
  226. };
  227. void MaybeRequestBalanceIncrease(
  228. std::shared_ptr<Main::SessionShow> show,
  229. uint64 credits,
  230. SmallBalanceSource source,
  231. Fn<void(SmallBalanceResult)> done);
  232. void AddMiniStars(
  233. not_null<Ui::VerticalLayout*> content,
  234. not_null<Ui::RpWidget*> widget,
  235. int photoSize,
  236. int boxWidth,
  237. float64 heightRatio);
  238. } // namespace Settings