mainwindow.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "platform/platform_main_window.h"
  9. #include "ui/layers/layer_widget.h"
  10. class MainWidget;
  11. namespace Intro {
  12. class Widget;
  13. enum class EnterPoint : uchar;
  14. } // namespace Intro
  15. namespace Window {
  16. class MediaPreviewWidget;
  17. class SectionMemento;
  18. struct SectionShow;
  19. class PasscodeLockWidget;
  20. namespace Theme {
  21. struct BackgroundUpdate;
  22. class WarningWidget;
  23. } // namespace Theme
  24. } // namespace Window
  25. namespace Ui {
  26. class LinkButton;
  27. class BoxContent;
  28. class LayerStackWidget;
  29. } // namespace Ui
  30. class MediaPreviewWidget;
  31. extern const char kOptionAutoScrollInactiveChat[];
  32. class MainWindow : public Platform::MainWindow {
  33. public:
  34. explicit MainWindow(not_null<Window::Controller*> controller);
  35. ~MainWindow();
  36. void finishFirstShow();
  37. void preventOrInvoke(Fn<void()> callback);
  38. void setupPasscodeLock();
  39. void clearPasscodeLock();
  40. void setupIntro(Intro::EnterPoint point, QPixmap oldContentCache);
  41. void setupMain(MsgId singlePeerShowAtMsgId, QPixmap oldContentCache);
  42. void showSettings();
  43. void setInnerFocus() override;
  44. MainWidget *sessionContent() const;
  45. void checkActivation() override;
  46. [[nodiscard]] bool markingAsRead() const;
  47. bool takeThirdSectionFromLayer();
  48. void sendPaths();
  49. [[nodiscard]] bool contentOverlapped(const QRect &globalRect);
  50. [[nodiscard]] bool contentOverlapped(QWidget *w, QPaintEvent *e) {
  51. return contentOverlapped(
  52. QRect(w->mapToGlobal(e->rect().topLeft()), e->rect().size()));
  53. }
  54. [[nodiscard]] bool contentOverlapped(QWidget *w, const QRegion &r) {
  55. return contentOverlapped(QRect(
  56. w->mapToGlobal(r.boundingRect().topLeft()),
  57. r.boundingRect().size()));
  58. }
  59. void showMainMenu();
  60. void fixOrder() override;
  61. [[nodiscard]] QPixmap grabForSlideAnimation();
  62. void showOrHideBoxOrLayer(
  63. std::variant<
  64. v::null_t,
  65. object_ptr<Ui::BoxContent>,
  66. std::unique_ptr<Ui::LayerWidget>> &&layer,
  67. Ui::LayerOptions options,
  68. anim::type animated);
  69. void showSpecialLayer(
  70. object_ptr<Ui::LayerWidget> layer,
  71. anim::type animated);
  72. bool showSectionInExistingLayer(
  73. not_null<Window::SectionMemento*> memento,
  74. const Window::SectionShow &params);
  75. void ui_hideSettingsAndLayer(anim::type animated);
  76. void ui_removeLayerBlackout();
  77. [[nodiscard]] bool ui_isLayerShown() const;
  78. bool showMediaPreview(
  79. Data::FileOrigin origin,
  80. not_null<DocumentData*> document);
  81. bool showMediaPreview(
  82. Data::FileOrigin origin,
  83. not_null<PhotoData*> photo);
  84. void hideMediaPreview();
  85. void updateControlsGeometry() override;
  86. protected:
  87. bool eventFilter(QObject *o, QEvent *e) override;
  88. void closeEvent(QCloseEvent *e) override;
  89. void initHook() override;
  90. void clearWidgetsHook() override;
  91. private:
  92. void applyInitialWorkMode();
  93. void ensureLayerCreated();
  94. void destroyLayer();
  95. void themeUpdated(const Window::Theme::BackgroundUpdate &data);
  96. QPoint _lastMousePosition;
  97. object_ptr<Window::PasscodeLockWidget> _passcodeLock = { nullptr };
  98. object_ptr<Intro::Widget> _intro = { nullptr };
  99. object_ptr<MainWidget> _main = { nullptr };
  100. base::unique_qptr<Ui::LayerStackWidget> _layer;
  101. object_ptr<Window::MediaPreviewWidget> _mediaPreview = { nullptr };
  102. object_ptr<Window::Theme::WarningWidget> _testingThemeWarning = { nullptr };
  103. };