window_chat_preview.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/timer.h"
  9. #include "base/unique_qptr.h"
  10. #include "dialogs/dialogs_key.h"
  11. namespace Ui {
  12. class PopupMenu;
  13. } // namespace Ui
  14. namespace Window {
  15. class SessionController;
  16. class ChatPreviewManager final {
  17. public:
  18. ChatPreviewManager(not_null<SessionController*> controller);
  19. bool show(
  20. Dialogs::RowDescriptor row,
  21. Fn<void(bool shown)> callback = nullptr,
  22. QPointer<QWidget> parentOverride = nullptr,
  23. std::optional<QPoint> positionOverride = {});
  24. bool schedule(
  25. Dialogs::RowDescriptor row,
  26. Fn<void(bool shown)> callback = nullptr,
  27. QPointer<QWidget> parentOverride = nullptr,
  28. std::optional<QPoint> positionOverride = {});
  29. void cancelScheduled();
  30. private:
  31. void showScheduled();
  32. const not_null<SessionController*> _controller;
  33. Dialogs::RowDescriptor _scheduled;
  34. Fn<void(bool)> _scheduledCallback;
  35. QPointer<QWidget> _scheduledParentOverride;
  36. std::optional<QPoint> _scheduledPositionOverride;
  37. base::Timer _timer;
  38. rpl::lifetime _topicLifetime;
  39. base::unique_qptr<Ui::PopupMenu> _menu;
  40. };
  41. } // namespace Window