tdesktop/Telegram/SourceFiles/mainwindow.h

167 lines
4.0 KiB
C
Raw Normal View History

/*
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 "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"
#include "ui/effects/animation_value.h"
class MainWidget;
2016-11-24 19:28:23 +00:00
namespace Intro {
class Widget;
enum class EnterPoint : uchar;
2016-11-24 19:28:23 +00:00
} // namespace Intro
namespace Media {
class SystemMediaControlsManager;
} // namespace Media
namespace Window {
class MediaPreviewWidget;
class SectionMemento;
struct SectionShow;
class PasscodeLockWidget;
namespace Theme {
struct BackgroundUpdate;
class WarningWidget;
} // namespace Theme
} // namespace Window
namespace Ui {
class LinkButton;
2019-09-18 11:19:05 +00:00
class BoxContent;
class LayerStackWidget;
} // namespace Ui
class MediaPreviewWidget;
class MainWindow : public Platform::MainWindow {
public:
explicit MainWindow(not_null<Window::Controller*> controller);
~MainWindow();
void finishFirstShow();
void preventOrInvoke(Fn<void()> callback);
void setupPasscodeLock();
void clearPasscodeLock();
void setupIntro(Intro::EnterPoint point);
void setupMain();
void showSettings();
2021-02-25 15:12:51 +00:00
void setInnerFocus() override;
2020-06-10 18:08:17 +00:00
MainWidget *sessionContent() const;
[[nodiscard]] bool doWeMarkAsRead();
2017-09-19 10:32:34 +00:00
bool takeThirdSectionFromLayer();
void checkHistoryActivation();
void sendPaths();
2015-10-01 14:05:05 +00:00
bool contentOverlapped(const QRect &globalRect);
bool contentOverlapped(QWidget *w, QPaintEvent *e) {
return contentOverlapped(QRect(w->mapToGlobal(e->rect().topLeft()), e->rect().size()));
}
bool contentOverlapped(QWidget *w, const QRegion &r) {
return contentOverlapped(QRect(w->mapToGlobal(r.boundingRect().topLeft()), r.boundingRect().size()));
}
2016-11-11 19:51:59 +00:00
void showMainMenu();
void updateTrayMenu() override;
void fixOrder() override;
2016-11-11 19:51:59 +00:00
void showLayer(
std::unique_ptr<Ui::LayerWidget> &&layer,
Ui::LayerOptions options,
anim::type animated);
void showSpecialLayer(
2019-09-18 11:19:05 +00:00
object_ptr<Ui::LayerWidget> layer,
anim::type animated);
bool showSectionInExistingLayer(
not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params);
void ui_showBox(
2019-09-18 11:19:05 +00:00
object_ptr<Ui::BoxContent> box,
Ui::LayerOptions options,
anim::type animated);
void ui_hideSettingsAndLayer(anim::type animated);
void ui_removeLayerBlackout();
bool ui_isLayerShown();
bool showMediaPreview(
2018-07-13 21:25:47 +00:00
Data::FileOrigin origin,
not_null<DocumentData*> document);
bool showMediaPreview(
2018-07-13 21:25:47 +00:00
Data::FileOrigin origin,
not_null<PhotoData*> photo);
void hideMediaPreview();
2020-03-03 12:07:22 +00:00
void updateControlsGeometry() override;
protected:
bool eventFilter(QObject *o, QEvent *e) override;
void closeEvent(QCloseEvent *e) override;
void initHook() override;
void activeChangedHook() override;
void clearWidgetsHook() override;
private:
[[nodiscard]] bool skipTrayClick() const;
void createTrayIconMenu();
void handleTrayIconActication(
QSystemTrayIcon::ActivationReason reason) override;
void applyInitialWorkMode();
void ensureLayerCreated();
2018-11-23 11:05:06 +00:00
void destroyLayer();
void showBoxOrLayer(
std::variant<
v::null_t,
object_ptr<Ui::BoxContent>,
std::unique_ptr<Ui::LayerWidget>> &&layer,
Ui::LayerOptions options,
anim::type animated);
void themeUpdated(const Window::Theme::BackgroundUpdate &data);
void toggleDisplayNotifyFromTray();
2015-10-17 14:52:26 +00:00
QPixmap grabInner();
std::unique_ptr<Media::SystemMediaControlsManager> _mediaControlsManager;
crl::time _lastTrayClickTime = 0;
QPoint _lastMousePosition;
bool _activeForTrayIconAction = true;
object_ptr<Window::PasscodeLockWidget> _passcodeLock = { nullptr };
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;
object_ptr<Window::MediaPreviewWidget> _mediaPreview = { nullptr };
object_ptr<Window::Theme::WarningWidget> _testingThemeWarning = { nullptr };
rpl::event_stream<> _updateTrayMenuTextActions;
};
namespace App {
MainWindow *wnd();
} // namespace App