menu_send.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 "api/api_common.h"
  9. namespace style {
  10. struct ComposeIcons;
  11. } // namespace style
  12. namespace ChatHelpers {
  13. class Show;
  14. } // namespace ChatHelpers
  15. namespace Ui {
  16. class PopupMenu;
  17. class RpWidget;
  18. class Show;
  19. } // namespace Ui
  20. namespace Data {
  21. class Thread;
  22. } // namespace Data
  23. namespace SendMenu {
  24. enum class Type : uchar {
  25. Disabled,
  26. SilentOnly,
  27. Scheduled,
  28. ScheduledToUser, // For "Send when online".
  29. Reminder,
  30. };
  31. enum class SpoilerState : uchar {
  32. None,
  33. Enabled,
  34. Possible,
  35. };
  36. enum class CaptionState : uchar {
  37. None,
  38. Below,
  39. Above,
  40. };
  41. struct Details {
  42. Type type = Type::Disabled;
  43. SpoilerState spoiler = SpoilerState::None;
  44. CaptionState caption = CaptionState::None;
  45. std::optional<uint64> price;
  46. bool effectAllowed = false;
  47. };
  48. enum class FillMenuResult : uchar {
  49. Prepared,
  50. Skipped,
  51. Failed,
  52. };
  53. enum class ActionType : uchar {
  54. Send,
  55. Schedule,
  56. SpoilerOn,
  57. SpoilerOff,
  58. CaptionUp,
  59. CaptionDown,
  60. ChangePrice,
  61. };
  62. struct Action {
  63. using Type = ActionType;
  64. Api::SendOptions options;
  65. Type type = Type::Send;
  66. };
  67. [[nodiscard]] Fn<void(Action, Details)> DefaultCallback(
  68. std::shared_ptr<ChatHelpers::Show> show,
  69. Fn<void(Api::SendOptions)> send);
  70. FillMenuResult FillSendMenu(
  71. not_null<Ui::PopupMenu*> menu,
  72. std::shared_ptr<ChatHelpers::Show> showForEffect,
  73. Details details,
  74. Fn<void(Action, Details)> action,
  75. const style::ComposeIcons *iconsOverride = nullptr,
  76. std::optional<QPoint> desiredPositionOverride = std::nullopt);
  77. FillMenuResult AttachSendMenuEffect(
  78. not_null<Ui::PopupMenu*> menu,
  79. std::shared_ptr<ChatHelpers::Show> show,
  80. Details details,
  81. Fn<void(Action, Details)> action,
  82. std::optional<QPoint> desiredPositionOverride = std::nullopt);
  83. void SetupMenuAndShortcuts(
  84. not_null<Ui::RpWidget*> button,
  85. std::shared_ptr<ChatHelpers::Show> show,
  86. Fn<Details()> details,
  87. Fn<void(Action, Details)> action);
  88. void SetupUnreadMentionsMenu(
  89. not_null<Ui::RpWidget*> button,
  90. Fn<Data::Thread*()> currentThread);
  91. void SetupUnreadReactionsMenu(
  92. not_null<Ui::RpWidget*> button,
  93. Fn<Data::Thread*()> currentThread);
  94. } // namespace SendMenu