dialogs_common.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. namespace Ui {
  9. class RippleAnimation;
  10. } // namespace Ui
  11. namespace Dialogs {
  12. class Row;
  13. enum class SortMode {
  14. Date = 0x00,
  15. Name = 0x01,
  16. Add = 0x02,
  17. };
  18. struct PositionChange {
  19. int from = -1;
  20. int to = -1;
  21. int height = 0;
  22. };
  23. struct UnreadState {
  24. int messages = 0;
  25. int messagesMuted = 0;
  26. int chats = 0;
  27. int chatsMuted = 0;
  28. int marks = 0;
  29. int marksMuted = 0;
  30. int reactions = 0;
  31. int reactionsMuted = 0;
  32. int mentions = 0;
  33. bool known = false;
  34. UnreadState &operator+=(const UnreadState &other) {
  35. messages += other.messages;
  36. messagesMuted += other.messagesMuted;
  37. chats += other.chats;
  38. chatsMuted += other.chatsMuted;
  39. marks += other.marks;
  40. marksMuted += other.marksMuted;
  41. reactions += other.reactions;
  42. reactionsMuted += other.reactionsMuted;
  43. mentions += other.mentions;
  44. return *this;
  45. }
  46. UnreadState &operator-=(const UnreadState &other) {
  47. messages -= other.messages;
  48. messagesMuted -= other.messagesMuted;
  49. chats -= other.chats;
  50. chatsMuted -= other.chatsMuted;
  51. marks -= other.marks;
  52. marksMuted -= other.marksMuted;
  53. reactions -= other.reactions;
  54. reactionsMuted -= other.reactionsMuted;
  55. mentions -= other.mentions;
  56. return *this;
  57. }
  58. };
  59. inline UnreadState operator+(const UnreadState &a, const UnreadState &b) {
  60. auto result = a;
  61. result += b;
  62. return result;
  63. }
  64. inline UnreadState operator-(const UnreadState &a, const UnreadState &b) {
  65. auto result = a;
  66. result -= b;
  67. return result;
  68. }
  69. struct BadgesState {
  70. int unreadCounter = 0;
  71. bool unread : 1 = false;
  72. bool unreadMuted : 1 = false;
  73. bool mention : 1 = false;
  74. bool mentionMuted : 1 = false;
  75. bool reaction : 1 = false;
  76. bool reactionMuted : 1 = false;
  77. friend inline constexpr auto operator<=>(
  78. BadgesState,
  79. BadgesState) = default;
  80. [[nodiscard]] bool empty() const {
  81. return !unread && !mention && !reaction;
  82. }
  83. };
  84. enum class CountInBadge : uchar {
  85. Default,
  86. Chats,
  87. Messages,
  88. };
  89. enum class IncludeInBadge : uchar {
  90. Default,
  91. Unmuted,
  92. All,
  93. UnmutedOrAll,
  94. };
  95. struct RowsByLetter {
  96. not_null<Row*> main;
  97. base::flat_map<QChar, not_null<Row*>> letters;
  98. };
  99. struct RightButton final {
  100. QImage bg;
  101. QImage selectedBg;
  102. QImage activeBg;
  103. Ui::Text::String text;
  104. std::unique_ptr<Ui::RippleAnimation> ripple;
  105. };
  106. } // namespace Dialogs