tdesktop/Telegram/SourceFiles/window/window_main_menu.h

113 lines
2.8 KiB
C
Raw Normal View History

2016-11-11 19:51:59 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2016-11-11 19:51:59 +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
#include "base/timer.h"
2019-09-13 12:22:54 +00:00
#include "base/object_ptr.h"
#include "base/binary_guard.h"
#include "ui/rp_widget.h"
2019-09-18 11:19:05 +00:00
#include "ui/layers/layer_widget.h"
2016-11-11 19:51:59 +00:00
namespace Ui {
class IconButton;
class FlatLabel;
class UserpicButton;
class PopupMenu;
class ScrollArea;
class VerticalLayout;
class RippleButton;
class PlainShadow;
template <typename Widget>
class SlideWrap;
namespace Menu {
class Menu;
} // namespace Menu
} // namespace Ui
namespace Main {
class Account;
} // namespace Main
2016-11-11 19:51:59 +00:00
namespace Window {
class SessionController;
class MainMenu final : public Ui::LayerWidget {
2016-11-11 19:51:59 +00:00
public:
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-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:
class AccountButton;
class ToggleAccountsButton;
class ResetScaleButton;
void setupArchiveButton();
void setupCloudButton();
void setupUserpicButton();
void setupAccounts();
void setupAccountsToggle();
[[nodiscard]] not_null<Ui::SlideWrap<Ui::RippleButton>*> setupAddAccount(
not_null<Ui::VerticalLayout*> container);
void rebuildAccounts();
void updateControlsGeometry();
void updateInnerControlsGeometry();
void updatePhone();
void initResetScaleButton();
void refreshMenu();
void refreshBackground();
void toggleAccounts();
const not_null<SessionController*> _controller;
object_ptr<Ui::UserpicButton> _userpicButton;
object_ptr<ToggleAccountsButton> _toggleAccounts;
object_ptr<Ui::IconButton> _archiveButton;
object_ptr<Ui::IconButton> _cloudButton;
object_ptr<ResetScaleButton> _resetScaleButton = { nullptr };
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*> _menu;
not_null<Ui::RpWidget*> _footer;
not_null<Ui::FlatLabel*> _telegram;
not_null<Ui::FlatLabel*> _version;
std::shared_ptr<QPointer<QAction>> _nightThemeAction;
base::Timer _nightThemeSwitch;
base::unique_qptr<Ui::PopupMenu> _contextMenu;
base::binary_guard _accountSwitchGuard;
QString _phoneText;
QImage _background;
2016-11-11 19:51:59 +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