notifications_utilities.h 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 "window/notifications_manager.h"
  9. #include "base/timer.h"
  10. namespace Ui {
  11. struct PeerUserpicView;
  12. } // namespace Ui
  13. namespace Window::Notifications {
  14. [[nodiscard]] QImage GenerateUserpic(
  15. not_null<PeerData*> peer,
  16. Ui::PeerUserpicView &view);
  17. class CachedUserpics : public QObject {
  18. public:
  19. CachedUserpics();
  20. ~CachedUserpics();
  21. [[nodiscard]] QString get(
  22. const InMemoryKey &key,
  23. not_null<PeerData*> peer,
  24. Ui::PeerUserpicView &view);
  25. private:
  26. void clear();
  27. void clearInMs(int ms);
  28. crl::time clear(crl::time ms);
  29. struct Image {
  30. crl::time until = 0;
  31. QString path;
  32. };
  33. using Images = QMap<InMemoryKey, Image>;
  34. Images _images;
  35. bool _someSavedFlag = false;
  36. base::Timer _clearTimer;
  37. };
  38. } // namespace Window::Notifications