boost_box.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. namespace Ui {
  10. void StartFireworks(not_null<QWidget*> parent);
  11. class Show;
  12. class RpWidget;
  13. class GenericBox;
  14. class VerticalLayout;
  15. class FlatLabel;
  16. struct BoostCounters {
  17. int level = 0;
  18. int boosts = 0;
  19. int thisLevelBoosts = 0;
  20. int nextLevelBoosts = 0; // Zero means no next level is available.
  21. int mine = 0;
  22. friend inline constexpr bool operator==(
  23. BoostCounters,
  24. BoostCounters) = default;
  25. };
  26. struct BoostFeatures {
  27. base::flat_map<int, int> nameColorsByLevel;
  28. base::flat_map<int, int> linkStylesByLevel;
  29. int linkLogoLevel = 0;
  30. int transcribeLevel = 0;
  31. int emojiPackLevel = 0;
  32. int emojiStatusLevel = 0;
  33. int wallpaperLevel = 0;
  34. int wallpapersCount = 0;
  35. int customWallpaperLevel = 0;
  36. int sponsoredLevel = 0;
  37. };
  38. struct BoostBoxData {
  39. QString name;
  40. BoostCounters boost;
  41. BoostFeatures features;
  42. int lifting = 0;
  43. bool allowMulti = false;
  44. bool group = false;
  45. };
  46. void BoostBox(
  47. not_null<GenericBox*> box,
  48. BoostBoxData data,
  49. Fn<void(Fn<void(BoostCounters)>)> boost);
  50. void BoostBoxAlready(not_null<GenericBox*> box, bool group);
  51. void GiftForBoostsBox(
  52. not_null<GenericBox*> box,
  53. QString channel,
  54. int receive,
  55. bool again);
  56. void GiftedNoBoostsBox(not_null<GenericBox*> box, bool group);
  57. void PremiumForBoostsBox(
  58. not_null<GenericBox*> box,
  59. bool group,
  60. Fn<void()> buyPremium);
  61. struct AskBoostChannelColor {
  62. int requiredLevel = 0;
  63. };
  64. struct AskBoostWallpaper {
  65. int requiredLevel = 0;
  66. bool group = false;
  67. };
  68. struct AskBoostEmojiStatus {
  69. int requiredLevel = 0;
  70. bool group = false;
  71. };
  72. struct AskBoostEmojiPack {
  73. int requiredLevel = 0;
  74. };
  75. struct AskBoostCustomReactions {
  76. int count = 0;
  77. };
  78. struct AskBoostCpm {
  79. int requiredLevel = 0;
  80. };
  81. struct AskBoostWearCollectible {
  82. int requiredLevel = 0;
  83. };
  84. struct AskBoostReason {
  85. std::variant<
  86. AskBoostChannelColor,
  87. AskBoostWallpaper,
  88. AskBoostEmojiStatus,
  89. AskBoostEmojiPack,
  90. AskBoostCustomReactions,
  91. AskBoostCpm,
  92. AskBoostWearCollectible> data;
  93. };
  94. struct AskBoostBoxData {
  95. QString link;
  96. BoostCounters boost;
  97. AskBoostReason reason;
  98. };
  99. void AskBoostBox(
  100. not_null<GenericBox*> box,
  101. AskBoostBoxData data,
  102. Fn<void()> openStatistics,
  103. Fn<void()> startGiveaway);
  104. [[nodiscard]] object_ptr<RpWidget> MakeLinkLabel(
  105. not_null<QWidget*> parent,
  106. rpl::producer<QString> text,
  107. rpl::producer<QString> link,
  108. std::shared_ptr<Show> show,
  109. object_ptr<RpWidget> right);
  110. void FillBoostLimit(
  111. rpl::producer<> showFinished,
  112. not_null<VerticalLayout*> container,
  113. rpl::producer<BoostCounters> data,
  114. style::margins limitLinePadding);
  115. [[nodiscard]] object_ptr<Ui::FlatLabel> MakeBoostFeaturesBadge(
  116. not_null<QWidget*> parent,
  117. rpl::producer<QString> text,
  118. Fn<QBrush(QRect)> bg);
  119. } // namespace Ui