2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
2016-01-30 16:31:10 +00:00
|
|
|
#pragma once
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
#include "platform/platform_main_window.h"
|
2018-11-23 11:05:06 +00:00
|
|
|
#include "base/unique_qptr.h"
|
2019-09-18 11:19:05 +00:00
|
|
|
#include "ui/layers/layer_widget.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "ui/effects/animation_value.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
class MainWidget;
|
2016-10-02 09:30:28 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
namespace Intro {
|
|
|
|
class Widget;
|
2020-06-23 14:55:08 +00:00
|
|
|
enum class EnterPoint : uchar;
|
2016-11-24 19:28:23 +00:00
|
|
|
} // namespace Intro
|
|
|
|
|
2016-11-02 14:44:33 +00:00
|
|
|
namespace Window {
|
2019-09-13 06:06:02 +00:00
|
|
|
class MediaPreviewWidget;
|
2017-10-03 13:05:58 +00:00
|
|
|
class SectionMemento;
|
|
|
|
struct SectionShow;
|
2018-06-03 13:30:40 +00:00
|
|
|
class PasscodeLockWidget;
|
2016-11-02 14:44:33 +00:00
|
|
|
namespace Theme {
|
|
|
|
struct BackgroundUpdate;
|
|
|
|
class WarningWidget;
|
|
|
|
} // namespace Theme
|
|
|
|
} // namespace Window
|
|
|
|
|
2016-11-11 13:46:04 +00:00
|
|
|
namespace Ui {
|
|
|
|
class LinkButton;
|
2019-09-18 11:19:05 +00:00
|
|
|
class BoxContent;
|
|
|
|
class LayerStackWidget;
|
2016-11-11 13:46:04 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
class MediaPreviewWidget;
|
2016-02-17 16:37:21 +00:00
|
|
|
|
2023-01-10 12:23:47 +00:00
|
|
|
extern const char kOptionAutoScrollInactiveChat[];
|
|
|
|
|
2016-11-04 11:14:47 +00:00
|
|
|
class MainWindow : public Platform::MainWindow {
|
2014-05-30 08:53:19 +00:00
|
|
|
public:
|
2019-06-06 11:20:21 +00:00
|
|
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
2016-04-12 21:31:28 +00:00
|
|
|
~MainWindow();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2020-02-12 08:09:17 +00:00
|
|
|
void finishFirstShow();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2020-12-13 13:08:16 +00:00
|
|
|
void preventOrInvoke(Fn<void()> callback);
|
|
|
|
|
2018-06-03 13:30:40 +00:00
|
|
|
void setupPasscodeLock();
|
|
|
|
void clearPasscodeLock();
|
2022-12-01 10:14:35 +00:00
|
|
|
void setupIntro(Intro::EnterPoint point, QPixmap oldContentCache);
|
|
|
|
void setupMain(MsgId singlePeerShowAtMsgId, QPixmap oldContentCache);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2021-01-22 12:16:18 +00:00
|
|
|
void showSettings();
|
|
|
|
|
2021-02-25 15:12:51 +00:00
|
|
|
void setInnerFocus() override;
|
2021-01-22 12:16:18 +00:00
|
|
|
|
2020-06-10 18:08:17 +00:00
|
|
|
MainWidget *sessionContent() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2023-03-21 12:22:38 +00:00
|
|
|
void checkActivation() override;
|
2022-11-02 16:03:42 +00:00
|
|
|
[[nodiscard]] bool markingAsRead() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-09-19 10:32:34 +00:00
|
|
|
bool takeThirdSectionFromLayer();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
void sendPaths();
|
|
|
|
|
2022-11-30 12:55:51 +00:00
|
|
|
[[nodiscard]] bool contentOverlapped(const QRect &globalRect);
|
|
|
|
[[nodiscard]] bool contentOverlapped(QWidget *w, QPaintEvent *e) {
|
|
|
|
return contentOverlapped(
|
|
|
|
QRect(w->mapToGlobal(e->rect().topLeft()), e->rect().size()));
|
2015-10-01 14:05:05 +00:00
|
|
|
}
|
2022-11-30 12:55:51 +00:00
|
|
|
[[nodiscard]] bool contentOverlapped(QWidget *w, const QRegion &r) {
|
|
|
|
return contentOverlapped(QRect(
|
|
|
|
w->mapToGlobal(r.boundingRect().topLeft()),
|
|
|
|
r.boundingRect().size()));
|
2015-10-01 14:05:05 +00:00
|
|
|
}
|
|
|
|
|
2016-11-11 19:51:59 +00:00
|
|
|
void showMainMenu();
|
2020-07-07 13:54:39 +00:00
|
|
|
void fixOrder() override;
|
2016-11-11 19:51:59 +00:00
|
|
|
|
2022-12-01 10:14:35 +00:00
|
|
|
[[nodiscard]] QPixmap grabForSlideAnimation();
|
|
|
|
|
2021-02-17 05:48:39 +00:00
|
|
|
void showLayer(
|
|
|
|
std::unique_ptr<Ui::LayerWidget> &&layer,
|
|
|
|
Ui::LayerOptions options,
|
|
|
|
anim::type animated);
|
2017-09-15 17:34:41 +00:00
|
|
|
void showSpecialLayer(
|
2019-09-18 11:19:05 +00:00
|
|
|
object_ptr<Ui::LayerWidget> layer,
|
2017-09-20 10:23:57 +00:00
|
|
|
anim::type animated);
|
2017-10-03 13:05:58 +00:00
|
|
|
bool showSectionInExistingLayer(
|
|
|
|
not_null<Window::SectionMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms);
|
2017-09-15 17:34:41 +00:00
|
|
|
void ui_showBox(
|
2019-09-18 11:19:05 +00:00
|
|
|
object_ptr<Ui::BoxContent> box,
|
|
|
|
Ui::LayerOptions options,
|
2017-09-20 10:23:57 +00:00
|
|
|
anim::type animated);
|
|
|
|
void ui_hideSettingsAndLayer(anim::type animated);
|
2018-09-06 14:58:43 +00:00
|
|
|
void ui_removeLayerBlackout();
|
2022-11-02 16:03:42 +00:00
|
|
|
[[nodiscard]] bool ui_isLayerShown() const;
|
2020-04-10 13:18:51 +00:00
|
|
|
bool showMediaPreview(
|
2018-07-13 21:25:47 +00:00
|
|
|
Data::FileOrigin origin,
|
|
|
|
not_null<DocumentData*> document);
|
2020-04-10 13:18:51 +00:00
|
|
|
bool showMediaPreview(
|
2018-07-13 21:25:47 +00:00
|
|
|
Data::FileOrigin origin,
|
|
|
|
not_null<PhotoData*> photo);
|
2019-06-29 10:29:04 +00:00
|
|
|
void hideMediaPreview();
|
2015-12-22 08:01:02 +00:00
|
|
|
|
2020-03-03 12:07:22 +00:00
|
|
|
void updateControlsGeometry() override;
|
|
|
|
|
2016-11-04 08:23:50 +00:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *o, QEvent *e) override;
|
|
|
|
void closeEvent(QCloseEvent *e) override;
|
|
|
|
|
2016-11-07 15:24:28 +00:00
|
|
|
void initHook() override;
|
2017-01-01 16:45:20 +00:00
|
|
|
void clearWidgetsHook() override;
|
2016-11-07 15:24:28 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
2020-02-12 08:09:17 +00:00
|
|
|
void applyInitialWorkMode();
|
2017-04-06 19:14:12 +00:00
|
|
|
void ensureLayerCreated();
|
2018-11-23 11:05:06 +00:00
|
|
|
void destroyLayer();
|
2017-04-06 19:14:12 +00:00
|
|
|
|
2021-02-17 05:48:39 +00:00
|
|
|
void showBoxOrLayer(
|
|
|
|
std::variant<
|
|
|
|
v::null_t,
|
|
|
|
object_ptr<Ui::BoxContent>,
|
|
|
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
|
|
|
Ui::LayerOptions options,
|
|
|
|
anim::type animated);
|
|
|
|
|
2016-11-02 14:44:33 +00:00
|
|
|
void themeUpdated(const Window::Theme::BackgroundUpdate &data);
|
|
|
|
|
2020-02-19 16:54:19 +00:00
|
|
|
QPoint _lastMousePosition;
|
2014-12-12 16:27:03 +00:00
|
|
|
|
2018-06-03 13:30:40 +00:00
|
|
|
object_ptr<Window::PasscodeLockWidget> _passcodeLock = { nullptr };
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Intro::Widget> _intro = { nullptr };
|
|
|
|
object_ptr<MainWidget> _main = { nullptr };
|
2019-09-18 11:19:05 +00:00
|
|
|
base::unique_qptr<Ui::LayerStackWidget> _layer;
|
2019-09-13 06:06:02 +00:00
|
|
|
object_ptr<Window::MediaPreviewWidget> _mediaPreview = { nullptr };
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Window::Theme::WarningWidget> _testingThemeWarning = { nullptr };
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|