2016-11-11 22:51:59 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-11-11 22:51:59 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-11-11 22:51:59 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-06-29 22:09:10 +03:00
|
|
|
#include "base/timer.h"
|
2019-09-13 15:22:54 +03:00
|
|
|
#include "base/object_ptr.h"
|
2020-06-22 17:01:41 +04:00
|
|
|
#include "base/binary_guard.h"
|
2018-10-20 23:04:10 +04:00
|
|
|
#include "ui/rp_widget.h"
|
2022-08-09 20:15:42 +03:00
|
|
|
#include "ui/unread_badge.h"
|
2025-03-14 15:02:53 +04:00
|
|
|
#include "ui/controls/swipe_handler_data.h"
|
2019-09-18 14:19:05 +03:00
|
|
|
#include "ui/layers/layer_widget.h"
|
2017-06-29 22:09:10 +03:00
|
|
|
|
2025-03-17 10:45:23 +04:00
|
|
|
namespace base {
|
|
|
|
enum class EventFilterResult;
|
|
|
|
} // namespace base
|
|
|
|
|
2016-11-11 22:51:59 +03:00
|
|
|
namespace Ui {
|
2017-04-05 12:21:38 +03:00
|
|
|
class IconButton;
|
2016-11-16 13:44:06 +03:00
|
|
|
class FlatLabel;
|
|
|
|
class UserpicButton;
|
2019-05-16 11:39:45 +03:00
|
|
|
class PopupMenu;
|
2020-06-22 17:01:41 +04:00
|
|
|
class ScrollArea;
|
|
|
|
class VerticalLayout;
|
|
|
|
class RippleButton;
|
|
|
|
class PlainShadow;
|
2022-02-09 16:54:16 +03:00
|
|
|
class SettingsButton;
|
2020-06-22 17:01:41 +04:00
|
|
|
template <typename Widget>
|
|
|
|
class SlideWrap;
|
2017-11-13 19:50:10 +04:00
|
|
|
} // namespace Ui
|
2016-11-16 13:44:06 +03:00
|
|
|
|
2022-08-11 20:22:21 +03:00
|
|
|
namespace Info::Profile {
|
2022-09-06 20:53:42 +04:00
|
|
|
class Badge;
|
2022-08-11 20:22:21 +03:00
|
|
|
class EmojiStatusPanel;
|
|
|
|
} // namespace Info::Profile
|
|
|
|
|
2020-06-22 17:01:41 +04:00
|
|
|
namespace Main {
|
|
|
|
class Account;
|
|
|
|
} // namespace Main
|
|
|
|
|
2016-11-11 22:51:59 +03:00
|
|
|
namespace Window {
|
|
|
|
|
2019-06-06 13:21:40 +03:00
|
|
|
class SessionController;
|
2017-11-13 19:50:10 +04:00
|
|
|
|
2021-07-15 14:12:38 +03:00
|
|
|
class MainMenu final : public Ui::LayerWidget {
|
2016-11-11 22:51:59 +03:00
|
|
|
public:
|
2019-06-06 13:21:40 +03:00
|
|
|
MainMenu(QWidget *parent, not_null<SessionController*> controller);
|
2022-08-11 20:22:21 +03:00
|
|
|
~MainMenu();
|
2016-11-11 22:51:59 +03:00
|
|
|
|
2019-09-18 14:19:05 +03:00
|
|
|
void parentResized() override;
|
2022-12-21 17:02:40 +03:00
|
|
|
void showFinished() override;
|
2016-11-16 13:44:06 +03:00
|
|
|
|
2025-03-14 15:02:53 +04:00
|
|
|
private:
|
|
|
|
class ToggleAccountsButton;
|
|
|
|
class ResetScaleButton;
|
|
|
|
|
|
|
|
bool eventHook(QEvent *event) override;
|
2016-11-11 22:51:59 +03:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
2019-09-18 14:19:05 +03:00
|
|
|
void doSetInnerFocus() override {
|
|
|
|
setFocus();
|
|
|
|
}
|
|
|
|
|
2022-08-11 20:22:21 +03:00
|
|
|
void moveBadge();
|
2020-06-22 17:01:41 +04:00
|
|
|
void setupUserpicButton();
|
|
|
|
void setupAccounts();
|
2020-06-22 18:33:35 +04:00
|
|
|
void setupAccountsToggle();
|
2022-09-07 20:39:57 +04:00
|
|
|
void setupSetEmojiStatus();
|
2022-02-09 17:52:20 +03:00
|
|
|
void setupArchive();
|
2022-02-09 16:54:16 +03:00
|
|
|
void setupMenu();
|
2016-11-16 13:44:06 +03:00
|
|
|
void updateControlsGeometry();
|
2020-06-22 17:01:41 +04:00
|
|
|
void updateInnerControlsGeometry();
|
2018-10-20 23:04:10 +04:00
|
|
|
void initResetScaleButton();
|
2020-06-30 11:34:02 +04:00
|
|
|
void toggleAccounts();
|
2022-09-07 20:39:57 +04:00
|
|
|
void chooseEmojiStatus();
|
2025-03-14 15:02:53 +04:00
|
|
|
void setupSwipe();
|
2016-11-16 13:44:06 +03:00
|
|
|
|
2025-03-17 10:45:23 +04:00
|
|
|
[[nodiscard]] base::EventFilterResult redirectToInnerChecked(
|
|
|
|
not_null<QEvent*> e);
|
|
|
|
|
2022-12-16 14:36:55 +03:00
|
|
|
void drawName(Painter &p);
|
|
|
|
|
2020-06-22 17:01:41 +04:00
|
|
|
const not_null<SessionController*> _controller;
|
|
|
|
object_ptr<Ui::UserpicButton> _userpicButton;
|
2022-08-09 14:12:19 +03:00
|
|
|
Ui::Text::String _name;
|
|
|
|
int _nameVersion = 0;
|
2020-06-22 18:33:35 +04:00
|
|
|
object_ptr<ToggleAccountsButton> _toggleAccounts;
|
2022-09-07 20:39:57 +04:00
|
|
|
object_ptr<Ui::FlatLabel> _setEmojiStatus;
|
2022-08-11 20:22:21 +03:00
|
|
|
std::unique_ptr<Info::Profile::EmojiStatusPanel> _emojiStatusPanel;
|
2022-09-06 20:53:42 +04:00
|
|
|
std::unique_ptr<Info::Profile::Badge> _badge;
|
2018-10-20 23:04:10 +04:00
|
|
|
object_ptr<ResetScaleButton> _resetScaleButton = { nullptr };
|
2020-06-22 17:01:41 +04:00
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
not_null<Ui::VerticalLayout*> _inner;
|
2022-02-10 14:03:07 +03:00
|
|
|
not_null<Ui::RpWidget*> _topShadowSkip;
|
2020-06-22 17:01:41 +04:00
|
|
|
not_null<Ui::SlideWrap<Ui::VerticalLayout>*> _accounts;
|
|
|
|
not_null<Ui::SlideWrap<Ui::PlainShadow>*> _shadow;
|
2022-02-09 16:54:16 +03:00
|
|
|
not_null<Ui::VerticalLayout*> _menu;
|
2020-06-22 17:01:41 +04:00
|
|
|
not_null<Ui::RpWidget*> _footer;
|
|
|
|
not_null<Ui::FlatLabel*> _telegram;
|
|
|
|
not_null<Ui::FlatLabel*> _version;
|
2022-02-09 16:54:16 +03:00
|
|
|
QPointer<Ui::SettingsButton> _nightThemeToggle;
|
|
|
|
rpl::event_stream<bool> _nightThemeSwitches;
|
2017-06-29 22:09:10 +03:00
|
|
|
base::Timer _nightThemeSwitch;
|
2019-05-16 11:39:45 +03:00
|
|
|
base::unique_qptr<Ui::PopupMenu> _contextMenu;
|
2016-11-16 13:44:06 +03:00
|
|
|
|
2025-03-14 15:02:53 +04:00
|
|
|
Ui::Controls::SwipeBackResult _swipeBackData;
|
|
|
|
|
2022-12-21 17:02:40 +03:00
|
|
|
rpl::variable<bool> _showFinished = false;
|
2025-03-17 10:45:23 +04:00
|
|
|
bool _insideEventRedirect = false;
|
2022-12-21 17:02:40 +03:00
|
|
|
|
2016-11-11 22:51:59 +03:00
|
|
|
};
|
|
|
|
|
2020-07-24 09:41:51 +04:00
|
|
|
struct OthersUnreadState {
|
|
|
|
int count = 0;
|
|
|
|
bool allMuted = false;
|
|
|
|
};
|
|
|
|
|
2024-09-16 13:02:38 +04:00
|
|
|
[[nodiscard]] OthersUnreadState OtherAccountsUnreadStateCurrent(
|
|
|
|
not_null<Main::Account*> current);
|
|
|
|
[[nodiscard]] rpl::producer<OthersUnreadState> OtherAccountsUnreadState(
|
|
|
|
not_null<Main::Account*> current);
|
2020-07-24 09:41:51 +04:00
|
|
|
|
2016-11-11 22:51:59 +03:00
|
|
|
} // namespace Window
|