window_main_menu.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/object_ptr.h"
  10. #include "base/binary_guard.h"
  11. #include "ui/rp_widget.h"
  12. #include "ui/unread_badge.h"
  13. #include "ui/controls/swipe_handler_data.h"
  14. #include "ui/layers/layer_widget.h"
  15. namespace base {
  16. enum class EventFilterResult;
  17. } // namespace base
  18. namespace Ui {
  19. class IconButton;
  20. class FlatLabel;
  21. class UserpicButton;
  22. class PopupMenu;
  23. class ScrollArea;
  24. class VerticalLayout;
  25. class RippleButton;
  26. class PlainShadow;
  27. class SettingsButton;
  28. template <typename Widget>
  29. class SlideWrap;
  30. } // namespace Ui
  31. namespace Info::Profile {
  32. class Badge;
  33. class EmojiStatusPanel;
  34. } // namespace Info::Profile
  35. namespace Main {
  36. class Account;
  37. } // namespace Main
  38. namespace Window {
  39. class SessionController;
  40. class MainMenu final : public Ui::LayerWidget {
  41. public:
  42. MainMenu(QWidget *parent, not_null<SessionController*> controller);
  43. ~MainMenu();
  44. void parentResized() override;
  45. void showFinished() override;
  46. private:
  47. class ToggleAccountsButton;
  48. class ResetScaleButton;
  49. bool eventHook(QEvent *event) override;
  50. void paintEvent(QPaintEvent *e) override;
  51. void resizeEvent(QResizeEvent *e) override;
  52. void doSetInnerFocus() override {
  53. setFocus();
  54. }
  55. void moveBadge();
  56. void setupUserpicButton();
  57. void setupAccounts();
  58. void setupAccountsToggle();
  59. void setupSetEmojiStatus();
  60. void setupArchive();
  61. void setupMenu();
  62. void updateControlsGeometry();
  63. void updateInnerControlsGeometry();
  64. void initResetScaleButton();
  65. void toggleAccounts();
  66. void chooseEmojiStatus();
  67. void setupSwipe();
  68. [[nodiscard]] base::EventFilterResult redirectToInnerChecked(
  69. not_null<QEvent*> e);
  70. void drawName(Painter &p);
  71. const not_null<SessionController*> _controller;
  72. object_ptr<Ui::UserpicButton> _userpicButton;
  73. Ui::Text::String _name;
  74. int _nameVersion = 0;
  75. object_ptr<ToggleAccountsButton> _toggleAccounts;
  76. object_ptr<Ui::FlatLabel> _setEmojiStatus;
  77. std::unique_ptr<Info::Profile::EmojiStatusPanel> _emojiStatusPanel;
  78. std::unique_ptr<Info::Profile::Badge> _badge;
  79. object_ptr<ResetScaleButton> _resetScaleButton = { nullptr };
  80. object_ptr<Ui::ScrollArea> _scroll;
  81. not_null<Ui::VerticalLayout*> _inner;
  82. not_null<Ui::RpWidget*> _topShadowSkip;
  83. not_null<Ui::SlideWrap<Ui::VerticalLayout>*> _accounts;
  84. not_null<Ui::SlideWrap<Ui::PlainShadow>*> _shadow;
  85. not_null<Ui::VerticalLayout*> _menu;
  86. not_null<Ui::RpWidget*> _footer;
  87. not_null<Ui::FlatLabel*> _telegram;
  88. not_null<Ui::FlatLabel*> _version;
  89. QPointer<Ui::SettingsButton> _nightThemeToggle;
  90. rpl::event_stream<bool> _nightThemeSwitches;
  91. base::Timer _nightThemeSwitch;
  92. base::unique_qptr<Ui::PopupMenu> _contextMenu;
  93. Ui::Controls::SwipeBackResult _swipeBackData;
  94. rpl::variable<bool> _showFinished = false;
  95. bool _insideEventRedirect = false;
  96. };
  97. struct OthersUnreadState {
  98. int count = 0;
  99. bool allMuted = false;
  100. };
  101. [[nodiscard]] OthersUnreadState OtherAccountsUnreadStateCurrent(
  102. not_null<Main::Account*> current);
  103. [[nodiscard]] rpl::producer<OthersUnreadState> OtherAccountsUnreadState(
  104. not_null<Main::Account*> current);
  105. } // namespace Window