2019-06-06 11:20:21 +00:00
|
|
|
/*
|
|
|
|
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"
|
2021-05-26 23:16:12 +00:00
|
|
|
#include "window/window_adaptive.h"
|
2019-09-18 11:19:05 +00:00
|
|
|
#include "ui/layers/layer_widget.h"
|
2019-06-06 11:20:21 +00:00
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Account;
|
2022-06-15 10:49:06 +00:00
|
|
|
class Session;
|
2019-06-06 11:20:21 +00:00
|
|
|
} // namespace Main
|
|
|
|
|
2023-05-02 09:33:19 +00:00
|
|
|
namespace Ui {
|
|
|
|
class Show;
|
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Ui::Toast {
|
|
|
|
struct Config;
|
|
|
|
} // namespace Ui::Toast
|
|
|
|
|
2021-06-14 06:33:54 +00:00
|
|
|
namespace Media::View {
|
|
|
|
struct OpenRequest;
|
|
|
|
} // namespace Media::View
|
|
|
|
|
2023-01-19 07:40:39 +00:00
|
|
|
namespace Media::Player {
|
|
|
|
class FloatDelegate;
|
|
|
|
} // namespace Media::Player
|
|
|
|
|
2019-06-06 11:20:21 +00:00
|
|
|
namespace Window {
|
|
|
|
|
2021-06-24 09:04:21 +00:00
|
|
|
class Controller final : public base::has_weak_ptr {
|
2019-06-06 11:20:21 +00:00
|
|
|
public:
|
2020-06-15 16:25:02 +00:00
|
|
|
Controller();
|
2023-01-17 15:47:58 +00:00
|
|
|
explicit Controller(not_null<Main::Account*> account);
|
2022-01-04 16:36:33 +00:00
|
|
|
Controller(
|
|
|
|
not_null<PeerData*> singlePeer,
|
|
|
|
MsgId showAtMsgId);
|
2019-06-06 11:20:21 +00:00
|
|
|
~Controller();
|
|
|
|
|
|
|
|
Controller(const Controller &other) = delete;
|
|
|
|
Controller &operator=(const Controller &other) = delete;
|
|
|
|
|
2020-06-15 16:25:02 +00:00
|
|
|
void showAccount(not_null<Main::Account*> account);
|
2022-01-04 11:18:13 +00:00
|
|
|
[[nodiscard]] PeerData *singlePeer() const;
|
2022-01-04 12:29:40 +00:00
|
|
|
[[nodiscard]] bool isPrimary() const {
|
|
|
|
return (singlePeer() == nullptr);
|
|
|
|
}
|
2020-06-15 16:25:02 +00:00
|
|
|
|
2020-06-24 07:56:16 +00:00
|
|
|
[[nodiscard]] not_null<::MainWindow*> widget() {
|
2019-06-06 11:20:21 +00:00
|
|
|
return &_widget;
|
|
|
|
}
|
2020-06-24 07:56:16 +00:00
|
|
|
[[nodiscard]] Main::Account &account() const {
|
2020-06-15 16:25:02 +00:00
|
|
|
Expects(_account != nullptr);
|
|
|
|
|
|
|
|
return *_account;
|
|
|
|
}
|
2022-06-15 10:49:06 +00:00
|
|
|
[[nodiscard]] Main::Account *maybeAccount() const {
|
|
|
|
return _account;
|
|
|
|
}
|
|
|
|
[[nodiscard]] Main::Session *maybeSession() const;
|
2020-06-24 07:56:16 +00:00
|
|
|
[[nodiscard]] SessionController *sessionController() const {
|
2019-06-06 11:20:21 +00:00
|
|
|
return _sessionController.get();
|
|
|
|
}
|
2023-01-09 13:12:37 +00:00
|
|
|
[[nodiscard]] auto sessionControllerValue() const
|
|
|
|
-> rpl::producer<SessionController*>;
|
|
|
|
[[nodiscard]] auto sessionControllerChanges() const
|
|
|
|
-> rpl::producer<SessionController*>;
|
2020-06-24 07:56:16 +00:00
|
|
|
[[nodiscard]] bool locked() const;
|
2019-06-06 11:20:21 +00:00
|
|
|
|
2021-05-27 13:54:24 +00:00
|
|
|
[[nodiscard]] Adaptive &adaptive() const;
|
2021-05-26 23:16:12 +00:00
|
|
|
|
2020-02-12 08:09:17 +00:00
|
|
|
void finishFirstShow();
|
2019-06-06 11:20:21 +00:00
|
|
|
|
|
|
|
void setupPasscodeLock();
|
|
|
|
void clearPasscodeLock();
|
|
|
|
|
2021-02-03 02:49:26 +00:00
|
|
|
void showLogoutConfirmation();
|
|
|
|
|
2019-06-06 11:20:21 +00:00
|
|
|
void showSettings();
|
|
|
|
|
2020-07-07 13:54:39 +00:00
|
|
|
[[nodiscard]] int verticalShadowTop() const;
|
|
|
|
|
2019-06-10 14:58:45 +00:00
|
|
|
template <typename BoxType>
|
|
|
|
QPointer<BoxType> show(
|
|
|
|
object_ptr<BoxType> content,
|
2019-09-18 11:19:05 +00:00
|
|
|
Ui::LayerOptions options = Ui::LayerOption::KeepOther,
|
2019-06-10 14:58:45 +00:00
|
|
|
anim::type animated = anim::type::normal) {
|
|
|
|
const auto result = QPointer<BoxType>(content.data());
|
|
|
|
showBox(std::move(content), options, animated);
|
|
|
|
return result;
|
|
|
|
}
|
2023-05-02 09:33:19 +00:00
|
|
|
|
|
|
|
void showToast(Ui::Toast::Config &&config);
|
|
|
|
void showToast(TextWithEntities &&text, crl::time duration = 0);
|
|
|
|
void showToast(const QString &text, crl::time duration = 0);
|
|
|
|
|
2021-02-21 03:48:32 +00:00
|
|
|
void showLayer(
|
|
|
|
std::unique_ptr<Ui::LayerWidget> &&layer,
|
|
|
|
Ui::LayerOptions options,
|
|
|
|
anim::type animated = anim::type::normal);
|
2019-06-10 14:58:45 +00:00
|
|
|
|
2019-09-03 08:25:19 +00:00
|
|
|
void showRightColumn(object_ptr<TWidget> widget);
|
|
|
|
|
2022-06-07 18:05:37 +00:00
|
|
|
void hideLayer(anim::type animated = anim::type::normal);
|
2022-02-20 11:00:36 +00:00
|
|
|
void hideSettingsAndLayer(anim::type animated = anim::type::normal);
|
2022-11-30 13:28:09 +00:00
|
|
|
[[nodiscard]] bool isLayerShown() const;
|
2022-02-20 11:00:36 +00:00
|
|
|
|
2019-06-06 11:20:21 +00:00
|
|
|
void activate();
|
|
|
|
void reActivate();
|
2020-06-17 09:36:25 +00:00
|
|
|
void updateIsActiveFocus();
|
|
|
|
void updateIsActiveBlur();
|
|
|
|
void updateIsActive();
|
2019-06-06 11:20:21 +00:00
|
|
|
void minimize();
|
|
|
|
void close();
|
|
|
|
|
2020-12-13 13:08:16 +00:00
|
|
|
void preventOrInvoke(Fn<void()> &&callback);
|
|
|
|
|
2021-06-15 23:06:22 +00:00
|
|
|
void invokeForSessionController(
|
|
|
|
not_null<Main::Account*> account,
|
2022-06-10 10:59:19 +00:00
|
|
|
PeerData *singlePeer,
|
2021-06-15 23:06:22 +00:00
|
|
|
Fn<void(not_null<SessionController*>)> &&callback);
|
|
|
|
|
2021-06-14 06:33:54 +00:00
|
|
|
void openInMediaView(Media::View::OpenRequest &&request);
|
|
|
|
[[nodiscard]] auto openInMediaViewRequests() const
|
|
|
|
-> rpl::producer<Media::View::OpenRequest>;
|
|
|
|
|
2023-01-19 07:40:39 +00:00
|
|
|
[[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*>;
|
2019-06-06 11:20:21 +00:00
|
|
|
|
2023-05-02 09:33:19 +00:00
|
|
|
[[nodiscard]] std::shared_ptr<Ui::Show> uiShow();
|
|
|
|
|
2023-01-19 07:40:39 +00:00
|
|
|
[[nodiscard]] rpl::lifetime &lifetime();
|
2021-06-14 06:33:54 +00:00
|
|
|
|
2019-06-06 11:20:21 +00:00
|
|
|
private:
|
2022-01-04 11:18:13 +00:00
|
|
|
struct CreateArgs {
|
|
|
|
PeerData *singlePeer = nullptr;
|
|
|
|
};
|
|
|
|
explicit Controller(CreateArgs &&args);
|
|
|
|
|
2022-12-01 10:14:35 +00:00
|
|
|
void setupIntro(QPixmap oldContentCache);
|
|
|
|
void setupMain(MsgId singlePeerShowAtMsgId, QPixmap oldContentCache);
|
|
|
|
|
2022-01-04 16:36:33 +00:00
|
|
|
void showAccount(
|
|
|
|
not_null<Main::Account*> account,
|
|
|
|
MsgId singlePeerShowAtMsgId);
|
|
|
|
void setupSideBar();
|
|
|
|
void sideBarChanged();
|
|
|
|
|
2019-06-10 14:58:45 +00:00
|
|
|
void showBox(
|
2019-09-18 11:19:05 +00:00
|
|
|
object_ptr<Ui::BoxContent> content,
|
|
|
|
Ui::LayerOptions options,
|
2019-06-10 14:58:45 +00:00
|
|
|
anim::type animated);
|
2019-09-02 16:10:18 +00:00
|
|
|
void checkThemeEditor();
|
2020-06-24 07:56:16 +00:00
|
|
|
void checkLockByTerms();
|
|
|
|
void showTermsDecline();
|
|
|
|
void showTermsDelete();
|
2019-06-10 14:58:45 +00:00
|
|
|
|
2022-01-04 11:18:13 +00:00
|
|
|
PeerData *_singlePeer = nullptr;
|
2020-06-15 16:25:02 +00:00
|
|
|
Main::Account *_account = nullptr;
|
2022-08-12 13:21:52 +00:00
|
|
|
base::Timer _isActiveTimer;
|
2019-06-22 09:52:18 +00:00
|
|
|
::MainWindow _widget;
|
2021-05-27 13:54:24 +00:00
|
|
|
const std::unique_ptr<Adaptive> _adaptive;
|
2019-08-16 12:44:20 +00:00
|
|
|
std::unique_ptr<SessionController> _sessionController;
|
2023-01-09 13:12:37 +00:00
|
|
|
rpl::variable<SessionController*> _sessionControllerValue;
|
2020-06-24 07:56:16 +00:00
|
|
|
QPointer<Ui::BoxContent> _termsBox;
|
2019-06-06 11:20:21 +00:00
|
|
|
|
2021-06-14 06:33:54 +00:00
|
|
|
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
|
|
|
|
|
2023-01-19 07:40:39 +00:00
|
|
|
FloatDelegate *_defaultFloatPlayerDelegate = nullptr;
|
|
|
|
FloatDelegate *_replacementFloatPlayerDelegate = nullptr;
|
|
|
|
rpl::variable<FloatDelegate*> _floatPlayerDelegate = nullptr;
|
|
|
|
|
2020-06-15 16:25:02 +00:00
|
|
|
rpl::lifetime _accountLifetime;
|
2019-06-06 11:20:21 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Window
|