tray_linux.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 "platform/platform_tray.h"
  9. #include "base/unique_qptr.h"
  10. namespace base::Platform::DBus {
  11. class ServiceWatcher;
  12. } // namespace base::Platform::DBus
  13. namespace Ui {
  14. class PopupMenu;
  15. } // namespace Ui
  16. class QMenu;
  17. class QSystemTrayIcon;
  18. namespace Platform {
  19. class IconGraphic;
  20. class TrayEventFilter;
  21. class Tray final {
  22. public:
  23. Tray();
  24. ~Tray();
  25. [[nodiscard]] rpl::producer<> aboutToShowRequests() const;
  26. [[nodiscard]] rpl::producer<> showFromTrayRequests() const;
  27. [[nodiscard]] rpl::producer<> hideToTrayRequests() const;
  28. [[nodiscard]] rpl::producer<> iconClicks() const;
  29. [[nodiscard]] bool hasIcon() const;
  30. void createIcon();
  31. void destroyIcon();
  32. void updateIcon();
  33. void createMenu();
  34. void destroyMenu();
  35. void addAction(rpl::producer<QString> text, Fn<void()> &&callback);
  36. void showTrayMessage() const;
  37. [[nodiscard]] bool hasTrayMessageSupport() const;
  38. [[nodiscard]] rpl::lifetime &lifetime();
  39. private:
  40. std::unique_ptr<base::Platform::DBus::ServiceWatcher> _sniWatcher;
  41. std::unique_ptr<IconGraphic> _iconGraphic;
  42. base::unique_qptr<QSystemTrayIcon> _icon;
  43. base::unique_qptr<QMenu> _menu;
  44. base::unique_qptr<Ui::PopupMenu> _menuCustom;
  45. base::unique_qptr<TrayEventFilter> _eventFilter;
  46. rpl::event_stream<> _iconClicks;
  47. rpl::event_stream<> _aboutToShowRequests;
  48. rpl::lifetime _actionsLifetime;
  49. rpl::lifetime _lifetime;
  50. };
  51. } // namespace Platform