tray_win.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 Window {
  11. struct CounterLayerArgs;
  12. } // namespace Window
  13. namespace Ui {
  14. class PopupMenu;
  15. } // namespace Ui
  16. class QPlatformSystemTrayIcon;
  17. namespace Platform {
  18. class Tray final {
  19. public:
  20. Tray();
  21. [[nodiscard]] rpl::producer<> aboutToShowRequests() const;
  22. [[nodiscard]] rpl::producer<> showFromTrayRequests() const;
  23. [[nodiscard]] rpl::producer<> hideToTrayRequests() const;
  24. [[nodiscard]] rpl::producer<> iconClicks() const;
  25. [[nodiscard]] bool hasIcon() const;
  26. void createIcon();
  27. void destroyIcon();
  28. void updateIcon();
  29. void createMenu();
  30. void destroyMenu();
  31. void addAction(rpl::producer<QString> text, Fn<void()> &&callback);
  32. void showTrayMessage() const;
  33. [[nodiscard]] bool hasTrayMessageSupport() const;
  34. [[nodiscard]] rpl::lifetime &lifetime();
  35. // Windows only.
  36. [[nodiscard]] static Window::CounterLayerArgs CounterLayerArgs(
  37. int size,
  38. int counter,
  39. bool muted);
  40. [[nodiscard]] static QPixmap IconWithCounter(
  41. Window::CounterLayerArgs &&args,
  42. bool smallIcon,
  43. bool monochrome,
  44. bool supportMode);
  45. [[nodiscard]] static QString QuitJumpListIconPath();
  46. private:
  47. base::unique_qptr<QPlatformSystemTrayIcon> _icon;
  48. base::unique_qptr<Ui::PopupMenu> _menu;
  49. rpl::event_stream<> _iconClicks;
  50. rpl::event_stream<> _aboutToShowRequests;
  51. rpl::lifetime _callbackFromTrayLifetime;
  52. rpl::lifetime _actionsLifetime;
  53. rpl::lifetime _lifetime;
  54. };
  55. void RefreshTaskbarThemeValue();
  56. } // namespace Platform