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;
|
|
|
|
} // namespace Main
|
|
|
|
|
2021-06-14 06:33:54 +00:00
|
|
|
namespace Media::View {
|
|
|
|
struct OpenRequest;
|
|
|
|
} // namespace Media::View
|
|
|
|
|
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();
|
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;
|
|
|
|
}
|
2020-06-24 07:56:16 +00:00
|
|
|
[[nodiscard]] SessionController *sessionController() const {
|
2019-06-06 11:20:21 +00:00
|
|
|
return _sessionController.get();
|
|
|
|
}
|
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();
|
|
|
|
void setupIntro();
|
2022-01-04 16:36:33 +00:00
|
|
|
void setupMain(MsgId singlePeerShowAtMsgId);
|
2019-06-06 11:20:21 +00:00
|
|
|
|
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;
|
|
|
|
}
|
2020-03-13 06:56:03 +00:00
|
|
|
void showToast(const QString &text);
|
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);
|
|
|
|
|
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,
|
|
|
|
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>;
|
|
|
|
|
2019-06-06 11:20:21 +00:00
|
|
|
QPoint getPointForCallPanelCenter() const;
|
|
|
|
|
2021-06-14 06:33:54 +00:00
|
|
|
rpl::lifetime &lifetime();
|
|
|
|
|
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-01-04 16:36:33 +00:00
|
|
|
void showAccount(
|
|
|
|
not_null<Main::Account*> account,
|
|
|
|
MsgId singlePeerShowAtMsgId);
|
|
|
|
void setupSideBar();
|
|
|
|
void sideBarChanged();
|
2022-01-26 09:41:27 +00:00
|
|
|
void logoutWithChecks(Main::Account *account);
|
2022-01-04 16:36:33 +00:00
|
|
|
|
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;
|
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;
|
2020-06-17 09:36:25 +00:00
|
|
|
base::Timer _isActiveTimer;
|
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;
|
|
|
|
|
2020-06-15 16:25:02 +00:00
|
|
|
rpl::lifetime _accountLifetime;
|
2019-06-06 11:20:21 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Window
|