delete_messages_box.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 "ui/layers/box_content.h"
  9. namespace Main {
  10. class Session;
  11. } // namespace Main
  12. namespace Ui {
  13. class Checkbox;
  14. class FlatLabel;
  15. class LinkButton;
  16. template <typename Widget>
  17. class SlideWrap;
  18. } // namespace Ui
  19. class DeleteMessagesBox final : public Ui::BoxContent {
  20. public:
  21. DeleteMessagesBox(
  22. QWidget*,
  23. not_null<HistoryItem*> item,
  24. bool suggestModerateActions);
  25. DeleteMessagesBox(
  26. QWidget*,
  27. not_null<Main::Session*> session,
  28. MessageIdsList &&selected);
  29. DeleteMessagesBox(
  30. QWidget*,
  31. not_null<PeerData*> peer,
  32. QDate firstDayToDelete,
  33. QDate lastDayToDelete);
  34. DeleteMessagesBox(QWidget*, not_null<PeerData*> peer, bool justClear);
  35. void setDeleteConfirmedCallback(Fn<void()> callback) {
  36. _deleteConfirmedCallback = std::move(callback);
  37. }
  38. protected:
  39. void prepare() override;
  40. void resizeEvent(QResizeEvent *e) override;
  41. void keyPressEvent(QKeyEvent *e) override;
  42. private:
  43. struct RevokeConfig {
  44. TextWithEntities checkbox;
  45. TextWithEntities description;
  46. };
  47. void deleteAndClear();
  48. [[nodiscard]] PeerData *checkFromSinglePeer() const;
  49. [[nodiscard]] bool hasScheduledMessages() const;
  50. [[nodiscard]] std::optional<RevokeConfig> revokeText(
  51. not_null<PeerData*> peer) const;
  52. const not_null<Main::Session*> _session;
  53. PeerData * const _wipeHistoryPeer = nullptr;
  54. const bool _wipeHistoryJustClear = false;
  55. const QDate _wipeHistoryFirstToDelete;
  56. const QDate _wipeHistoryLastToDelete;
  57. const MessageIdsList _ids;
  58. PeerData *_moderateFrom = nullptr;
  59. ChannelData *_moderateInChannel = nullptr;
  60. bool _moderateBan = false;
  61. bool _moderateDeleteAll = false;
  62. bool _revokeForBot = false;
  63. object_ptr<Ui::FlatLabel> _text = { nullptr };
  64. object_ptr<Ui::Checkbox> _revoke = { nullptr };
  65. object_ptr<Ui::SlideWrap<Ui::Checkbox>> _revokeRemember = { nullptr };
  66. object_ptr<Ui::Checkbox> _banUser = { nullptr };
  67. object_ptr<Ui::Checkbox> _reportSpam = { nullptr };
  68. object_ptr<Ui::Checkbox> _deleteAll = { nullptr };
  69. object_ptr<Ui::LinkButton> _autoDeleteSettings = { nullptr };
  70. int _fullHeight = 0;
  71. Fn<void()> _deleteConfirmedCallback;
  72. };