/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "mainwindow.h" #include "window/window_adaptive.h" namespace Main { class Account; class Session; } // namespace Main namespace Ui { class Show; } // namespace Ui namespace Ui::Toast { struct Config; } // namespace Ui::Toast namespace Media::View { struct OpenRequest; } // namespace Media::View namespace Media::Player { class FloatDelegate; } // namespace Media::Player namespace Window { class Controller final : public base::has_weak_ptr { public: Controller(); explicit Controller(not_null account); Controller( not_null singlePeer, MsgId showAtMsgId); ~Controller(); Controller(const Controller &other) = delete; Controller &operator=(const Controller &other) = delete; void showAccount(not_null account); [[nodiscard]] PeerData *singlePeer() const; [[nodiscard]] bool isPrimary() const { return (singlePeer() == nullptr); } [[nodiscard]] not_null<::MainWindow*> widget() { return &_widget; } [[nodiscard]] Main::Account &account() const { Expects(_account != nullptr); return *_account; } [[nodiscard]] Main::Account *maybeAccount() const { return _account; } [[nodiscard]] Main::Session *maybeSession() const; [[nodiscard]] SessionController *sessionController() const { return _sessionController.get(); } [[nodiscard]] auto sessionControllerValue() const -> rpl::producer; [[nodiscard]] auto sessionControllerChanges() const -> rpl::producer; [[nodiscard]] bool locked() const; [[nodiscard]] Adaptive &adaptive() const; void firstShow(); void finishFirstShow(); void setupPasscodeLock(); void clearPasscodeLock(); void showLogoutConfirmation(); void showSettings(); [[nodiscard]] int verticalShadowTop() const; void showToast(Ui::Toast::Config &&config); void showToast(TextWithEntities &&text, crl::time duration = 0); void showToast(const QString &text, crl::time duration = 0); void showRightColumn(object_ptr widget); void showBox( object_ptr content, Ui::LayerOptions options, anim::type animated); void showLayer( std::unique_ptr &&layer, Ui::LayerOptions options, anim::type animated = anim::type::normal); void hideLayer(anim::type animated = anim::type::normal); void hideSettingsAndLayer(anim::type animated = anim::type::normal); [[nodiscard]] bool isLayerShown() const; template < typename BoxType, typename = std::enable_if_t< std::is_base_of_v>> QPointer show( object_ptr content, Ui::LayerOptions options = Ui::LayerOption::KeepOther, anim::type animated = anim::type()) { auto result = QPointer(content.data()); showBox(std::move(content), options, animated); return result; } void activate(); void reActivate(); void updateIsActiveFocus(); void updateIsActiveBlur(); void updateIsActive(); void minimize(); void close(); void preventOrInvoke(Fn &&callback); void invokeForSessionController( not_null account, PeerData *singlePeer, Fn)> &&callback); void openInMediaView(Media::View::OpenRequest &&request); [[nodiscard]] auto openInMediaViewRequests() const -> rpl::producer; [[nodiscard]] QPoint getPointForCallPanelCenter() const; using FloatDelegate = Media::Player::FloatDelegate; void setDefaultFloatPlayerDelegate( not_null delegate); void replaceFloatPlayerDelegate( not_null replacement); void restoreFloatPlayerDelegate( not_null replacement); [[nodiscard]] FloatDelegate *floatPlayerDelegate() const; [[nodiscard]] auto floatPlayerDelegateValue() const -> rpl::producer; [[nodiscard]] std::shared_ptr uiShow(); [[nodiscard]] rpl::lifetime &lifetime(); private: struct CreateArgs { PeerData *singlePeer = nullptr; }; explicit Controller(CreateArgs &&args); void setupIntro(QPixmap oldContentCache); void setupMain(MsgId singlePeerShowAtMsgId, QPixmap oldContentCache); void showAccount( not_null account, MsgId singlePeerShowAtMsgId); void setupSideBar(); void sideBarChanged(); void checkThemeEditor(); void checkLockByTerms(); void showTermsDecline(); void showTermsDelete(); PeerData *_singlePeer = nullptr; Main::Account *_account = nullptr; base::Timer _isActiveTimer; ::MainWindow _widget; const std::unique_ptr _adaptive; std::unique_ptr _sessionController; rpl::variable _sessionControllerValue; QPointer _termsBox; rpl::event_stream _openInMediaViewRequests; FloatDelegate *_defaultFloatPlayerDelegate = nullptr; FloatDelegate *_replacementFloatPlayerDelegate = nullptr; rpl::variable _floatPlayerDelegate = nullptr; rpl::lifetime _accountLifetime; rpl::lifetime _lifetime; }; } // namespace Window