2016-11-11 19:51:59 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-11-11 19:51:59 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-11-11 19:51:59 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-06-29 19:09:10 +00:00
|
|
|
#include "base/timer.h"
|
2019-09-13 12:22:54 +00:00
|
|
|
#include "base/object_ptr.h"
|
2020-06-22 13:01:41 +00:00
|
|
|
#include "base/binary_guard.h"
|
2018-10-20 19:04:10 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2019-09-18 11:19:05 +00:00
|
|
|
#include "ui/layers/layer_widget.h"
|
2017-06-29 19:09:10 +00:00
|
|
|
|
2016-11-11 19:51:59 +00:00
|
|
|
namespace Ui {
|
2017-04-05 09:21:38 +00:00
|
|
|
class IconButton;
|
2016-11-16 10:44:06 +00:00
|
|
|
class FlatLabel;
|
2016-11-11 19:51:59 +00:00
|
|
|
class Menu;
|
2016-11-16 10:44:06 +00:00
|
|
|
class UserpicButton;
|
2019-05-16 08:39:45 +00:00
|
|
|
class PopupMenu;
|
2020-06-22 13:01:41 +00:00
|
|
|
class ScrollArea;
|
|
|
|
class VerticalLayout;
|
|
|
|
class RippleButton;
|
|
|
|
class PlainShadow;
|
|
|
|
template <typename Widget>
|
|
|
|
class SlideWrap;
|
2017-11-13 15:50:10 +00:00
|
|
|
} // namespace Ui
|
2016-11-16 10:44:06 +00:00
|
|
|
|
2020-06-22 13:01:41 +00:00
|
|
|
namespace Main {
|
|
|
|
class Account;
|
|
|
|
} // namespace Main
|
|
|
|
|
2016-11-11 19:51:59 +00:00
|
|
|
namespace Window {
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2017-11-13 15:50:10 +00:00
|
|
|
|
2019-09-18 11:19:05 +00:00
|
|
|
class MainMenu : public Ui::LayerWidget, private base::Subscriber {
|
2016-11-11 19:51:59 +00:00
|
|
|
public:
|
2019-06-06 10:21:40 +00:00
|
|
|
MainMenu(QWidget *parent, not_null<SessionController*> controller);
|
2016-11-11 19:51:59 +00:00
|
|
|
|
2019-09-18 11:19:05 +00:00
|
|
|
void parentResized() override;
|
2016-11-16 10:44:06 +00:00
|
|
|
|
2016-11-11 19:51:59 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
2019-09-18 11:19:05 +00:00
|
|
|
void doSetInnerFocus() override {
|
|
|
|
setFocus();
|
|
|
|
}
|
|
|
|
|
2016-11-11 19:51:59 +00:00
|
|
|
private:
|
2020-06-22 13:01:41 +00:00
|
|
|
class AccountButton;
|
2020-06-22 14:33:35 +00:00
|
|
|
class ToggleAccountsButton;
|
2020-06-22 13:01:41 +00:00
|
|
|
class ResetScaleButton;
|
|
|
|
|
|
|
|
void setupArchiveButton();
|
2020-06-29 05:55:19 +00:00
|
|
|
void setupCloudButton();
|
2020-06-22 13:01:41 +00:00
|
|
|
void setupUserpicButton();
|
|
|
|
void setupAccounts();
|
2020-06-22 14:33:35 +00:00
|
|
|
void setupAccountsToggle();
|
2020-06-22 13:01:41 +00:00
|
|
|
[[nodiscard]] not_null<Ui::SlideWrap<Ui::RippleButton>*> setupAddAccount(
|
|
|
|
not_null<Ui::VerticalLayout*> container);
|
|
|
|
void rebuildAccounts();
|
2016-11-16 10:44:06 +00:00
|
|
|
void updateControlsGeometry();
|
2020-06-22 13:01:41 +00:00
|
|
|
void updateInnerControlsGeometry();
|
2017-05-07 09:00:49 +00:00
|
|
|
void updatePhone();
|
2018-10-20 19:04:10 +00:00
|
|
|
void initResetScaleButton();
|
2017-04-28 17:16:14 +00:00
|
|
|
void refreshMenu();
|
2019-05-24 18:46:52 +00:00
|
|
|
void refreshBackground();
|
2020-06-30 07:34:02 +00:00
|
|
|
void toggleAccounts();
|
2016-11-16 10:44:06 +00:00
|
|
|
|
2020-06-22 13:01:41 +00:00
|
|
|
const not_null<SessionController*> _controller;
|
|
|
|
object_ptr<Ui::UserpicButton> _userpicButton;
|
2020-06-22 14:33:35 +00:00
|
|
|
object_ptr<ToggleAccountsButton> _toggleAccounts;
|
2020-06-22 13:01:41 +00:00
|
|
|
object_ptr<Ui::IconButton> _archiveButton;
|
2020-06-29 05:55:19 +00:00
|
|
|
object_ptr<Ui::IconButton> _cloudButton;
|
2018-10-20 19:04:10 +00:00
|
|
|
object_ptr<ResetScaleButton> _resetScaleButton = { nullptr };
|
2020-06-22 13:01:41 +00:00
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
not_null<Ui::VerticalLayout*> _inner;
|
|
|
|
base::flat_map<
|
|
|
|
not_null<Main::Account*>,
|
|
|
|
base::unique_qptr<AccountButton>> _watched;
|
|
|
|
not_null<Ui::SlideWrap<Ui::VerticalLayout>*> _accounts;
|
|
|
|
Ui::SlideWrap<Ui::RippleButton> *_addAccount = nullptr;
|
|
|
|
not_null<Ui::SlideWrap<Ui::PlainShadow>*> _shadow;
|
|
|
|
not_null<Ui::Menu*> _menu;
|
|
|
|
not_null<Ui::RpWidget*> _footer;
|
|
|
|
not_null<Ui::FlatLabel*> _telegram;
|
|
|
|
not_null<Ui::FlatLabel*> _version;
|
2017-06-29 19:09:10 +00:00
|
|
|
std::shared_ptr<QPointer<QAction>> _nightThemeAction;
|
|
|
|
base::Timer _nightThemeSwitch;
|
2019-05-16 08:39:45 +00:00
|
|
|
base::unique_qptr<Ui::PopupMenu> _contextMenu;
|
2016-11-16 10:44:06 +00:00
|
|
|
|
2020-06-22 13:01:41 +00:00
|
|
|
base::binary_guard _accountSwitchGuard;
|
|
|
|
|
2017-05-07 09:00:49 +00:00
|
|
|
QString _phoneText;
|
2019-05-24 18:46:52 +00:00
|
|
|
QImage _background;
|
2016-11-11 19:51:59 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-07-24 05:41:51 +00:00
|
|
|
struct OthersUnreadState {
|
|
|
|
int count = 0;
|
|
|
|
bool allMuted = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
[[nodiscard]] OthersUnreadState OtherAccountsUnreadStateCurrent();
|
|
|
|
[[nodiscard]] rpl::producer<OthersUnreadState> OtherAccountsUnreadState();
|
|
|
|
|
2016-11-11 19:51:59 +00:00
|
|
|
} // namespace Window
|