attach_send_files_way.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/flags.h"
  9. namespace Ui {
  10. enum class AttachActionType {
  11. ToggleSpoiler,
  12. EditCover,
  13. ClearCover,
  14. };
  15. enum class AttachButtonType {
  16. Edit,
  17. Delete,
  18. Modify,
  19. None,
  20. };
  21. class SendFilesWay final {
  22. public:
  23. [[nodiscard]] bool groupFiles() const {
  24. return (_flags & Flag::GroupFiles) != 0;
  25. }
  26. [[nodiscard]] bool sendImagesAsPhotos() const {
  27. return (_flags & Flag::SendImagesAsPhotos) != 0;
  28. }
  29. void setGroupFiles(bool value);
  30. void setSendImagesAsPhotos(bool value);
  31. void setHasCompressedStickers(bool value);
  32. [[nodiscard]] inline bool operator<(const SendFilesWay &other) const {
  33. return _flags < other._flags;
  34. }
  35. [[nodiscard]] inline bool operator>(const SendFilesWay &other) const {
  36. return other < *this;
  37. }
  38. [[nodiscard]] inline bool operator<=(const SendFilesWay &other) const {
  39. return !(other < *this);
  40. }
  41. [[nodiscard]] inline bool operator>=(const SendFilesWay &other) const {
  42. return !(*this < other);
  43. }
  44. [[nodiscard]] inline bool operator==(const SendFilesWay &other) const {
  45. return _flags == other._flags;
  46. }
  47. [[nodiscard]] inline bool operator!=(const SendFilesWay &other) const {
  48. return !(*this == other);
  49. }
  50. [[nodiscard]] int32 serialize() const;
  51. [[nodiscard]] static std::optional<SendFilesWay> FromSerialized(
  52. int32 value);
  53. private:
  54. [[nodiscard]] bool hasCompressedStickers() const {
  55. return (_flags & Flag::HasCompressedStickers) != 0;
  56. }
  57. enum class Flag : uchar {
  58. GroupFiles = (1 << 0),
  59. SendImagesAsPhotos = (1 << 1),
  60. HasCompressedStickers = (1 << 2),
  61. Default = GroupFiles | SendImagesAsPhotos,
  62. };
  63. friend inline constexpr bool is_flag_type(Flag) { return true; };
  64. base::flags<Flag> _flags = Flag::Default;
  65. };
  66. } // namespace Ui