1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
/*
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"
#include "ui/layers/layer_widget.h"
namespace Main {
class Account;
class Session;
} // namespace Main
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<Main::Account*> account);
Controller(
not_null<PeerData*> singlePeer,
MsgId showAtMsgId);
~Controller();
Controller(const Controller &other) = delete;
Controller &operator=(const Controller &other) = delete;
void showAccount(not_null<Main::Account*> 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<SessionController*>;
[[nodiscard]] auto sessionControllerChanges() const
-> rpl::producer<SessionController*>;
[[nodiscard]] bool locked() const;
[[nodiscard]] Adaptive &adaptive() const;
void finishFirstShow();
void setupPasscodeLock();
void clearPasscodeLock();
void showLogoutConfirmation();
void showSettings();
[[nodiscard]] int verticalShadowTop() const;
template <typename BoxType>
QPointer<BoxType> show(
object_ptr<BoxType> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther,
anim::type animated = anim::type::normal) {
const auto result = QPointer<BoxType>(content.data());
showBox(std::move(content), options, animated);
return result;
}
void showToast(const QString &text);
void showLayer(
std::unique_ptr<Ui::LayerWidget> &&layer,
Ui::LayerOptions options,
anim::type animated = anim::type::normal);
void showRightColumn(object_ptr<TWidget> widget);
void hideLayer(anim::type animated = anim::type::normal);
void hideSettingsAndLayer(anim::type animated = anim::type::normal);
[[nodiscard]] bool isLayerShown() const;
void activate();
void reActivate();
void updateIsActiveFocus();
void updateIsActiveBlur();
void updateIsActive();
void minimize();
void close();
void preventOrInvoke(Fn<void()> &&callback);
void invokeForSessionController(
not_null<Main::Account*> account,
PeerData *singlePeer,
Fn<void(not_null<SessionController*>)> &&callback);
void openInMediaView(Media::View::OpenRequest &&request);
[[nodiscard]] auto openInMediaViewRequests() const
-> rpl::producer<Media::View::OpenRequest>;
[[nodiscard]] QPoint getPointForCallPanelCenter() const;
using FloatDelegate = Media::Player::FloatDelegate;
void setDefaultFloatPlayerDelegate(
not_null<Media::Player::FloatDelegate*> delegate);
void replaceFloatPlayerDelegate(
not_null<Media::Player::FloatDelegate*> replacement);
void restoreFloatPlayerDelegate(
not_null<Media::Player::FloatDelegate*> replacement);
[[nodiscard]] FloatDelegate *floatPlayerDelegate() const;
[[nodiscard]] auto floatPlayerDelegateValue() const
-> rpl::producer<FloatDelegate*>;
[[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<Main::Account*> account,
MsgId singlePeerShowAtMsgId);
void setupSideBar();
void sideBarChanged();
void showBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options,
anim::type animated);
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> _adaptive;
std::unique_ptr<SessionController> _sessionController;
rpl::variable<SessionController*> _sessionControllerValue;
QPointer<Ui::BoxContent> _termsBox;
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
FloatDelegate *_defaultFloatPlayerDelegate = nullptr;
FloatDelegate *_replacementFloatPlayerDelegate = nullptr;
rpl::variable<FloatDelegate*> _floatPlayerDelegate = nullptr;
rpl::lifetime _accountLifetime;
rpl::lifetime _lifetime;
};
} // namespace Window
|