2016-05-19 12:03:51 +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.
|
2016-05-19 12:03:51 +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
|
2016-05-19 12:03:51 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2021-07-26 20:06:14 +00:00
|
|
|
#include "chat_helpers/bot_command.h"
|
2018-01-22 16:42:25 +00:00
|
|
|
#include "dialogs/dialogs_key.h"
|
2020-06-25 14:17:37 +00:00
|
|
|
#include "media/player/media_player_float.h" // FloatSectionDelegate
|
2019-09-13 12:22:54 +00:00
|
|
|
#include "base/object_ptr.h"
|
2021-07-26 23:18:11 +00:00
|
|
|
#include "window/window_section_common.h"
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2021-08-26 13:25:48 +00:00
|
|
|
class PeerData;
|
|
|
|
|
2023-05-26 16:30:02 +00:00
|
|
|
namespace ChatHelpers {
|
|
|
|
class Show;
|
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
2022-08-16 11:28:17 +00:00
|
|
|
namespace Data {
|
|
|
|
struct ReactionId;
|
2022-10-25 08:07:47 +00:00
|
|
|
class ForumTopic;
|
2022-08-16 11:28:17 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2019-04-16 14:05:56 +00:00
|
|
|
|
2019-09-18 11:19:05 +00:00
|
|
|
namespace Ui {
|
|
|
|
class LayerWidget;
|
2021-08-26 13:25:48 +00:00
|
|
|
class ChatTheme;
|
2021-08-26 15:02:21 +00:00
|
|
|
} // namespace Ui
|
2021-08-26 13:25:48 +00:00
|
|
|
|
2016-05-19 12:03:51 +00:00
|
|
|
namespace Window {
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2017-10-03 13:05:58 +00:00
|
|
|
class SlideAnimation;
|
|
|
|
struct SectionShow;
|
|
|
|
enum class SlideDirection;
|
2017-05-22 15:25:49 +00:00
|
|
|
|
|
|
|
enum class Column {
|
|
|
|
First,
|
|
|
|
Second,
|
|
|
|
Third,
|
|
|
|
};
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
class AbstractSectionWidget
|
|
|
|
: public Ui::RpWidget
|
2022-03-14 16:56:55 +00:00
|
|
|
, public Media::Player::FloatSectionDelegate {
|
2017-05-22 15:25:49 +00:00
|
|
|
public:
|
2017-09-13 16:57:44 +00:00
|
|
|
AbstractSectionWidget(
|
|
|
|
QWidget *parent,
|
2021-08-13 18:18:06 +00:00
|
|
|
not_null<SessionController*> controller,
|
2021-08-26 13:25:48 +00:00
|
|
|
rpl::producer<PeerData*> peerForBackground);
|
2017-05-22 15:25:49 +00:00
|
|
|
|
2019-08-16 12:44:20 +00:00
|
|
|
[[nodiscard]] Main::Session &session() const;
|
2020-08-31 11:17:02 +00:00
|
|
|
[[nodiscard]] not_null<SessionController*> controller() const {
|
2020-06-10 18:08:17 +00:00
|
|
|
return _controller;
|
|
|
|
}
|
2019-08-16 12:44:20 +00:00
|
|
|
|
|
|
|
// Tabbed selector management.
|
2020-05-05 12:55:05 +00:00
|
|
|
virtual bool pushTabbedSelectorToThirdSection(
|
2022-10-25 08:07:47 +00:00
|
|
|
not_null<Data::Thread*> thread,
|
2020-08-31 11:17:02 +00:00
|
|
|
const SectionShow ¶ms) {
|
2020-05-05 12:55:05 +00:00
|
|
|
return false;
|
2019-08-16 12:44:20 +00:00
|
|
|
}
|
|
|
|
virtual bool returnTabbedSelector() {
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-16 14:05:56 +00:00
|
|
|
|
2017-05-22 15:25:49 +00:00
|
|
|
private:
|
2020-08-31 11:17:02 +00:00
|
|
|
const not_null<SessionController*> _controller;
|
2017-05-22 15:25:49 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-05-19 12:03:51 +00:00
|
|
|
class SectionMemento;
|
|
|
|
|
|
|
|
struct SectionSlideParams {
|
|
|
|
QPixmap oldContentCache;
|
2022-02-23 10:53:27 +00:00
|
|
|
int topSkip = 0;
|
2022-05-19 07:51:03 +00:00
|
|
|
QPixmap topMask;
|
2016-05-19 12:03:51 +00:00
|
|
|
bool withTopBarShadow = false;
|
2017-10-03 17:41:44 +00:00
|
|
|
bool withTabs = false;
|
|
|
|
bool withFade = false;
|
2017-01-14 18:50:16 +00:00
|
|
|
|
|
|
|
explicit operator bool() const {
|
|
|
|
return !oldContentCache.isNull();
|
|
|
|
}
|
2016-05-19 12:03:51 +00:00
|
|
|
};
|
|
|
|
|
2017-05-22 15:25:49 +00:00
|
|
|
class SectionWidget : public AbstractSectionWidget {
|
2016-05-19 12:03:51 +00:00
|
|
|
public:
|
2020-06-10 18:08:17 +00:00
|
|
|
SectionWidget(
|
|
|
|
QWidget *parent,
|
2021-08-13 18:18:06 +00:00
|
|
|
not_null<SessionController*> controller,
|
2021-08-26 13:25:48 +00:00
|
|
|
rpl::producer<PeerData*> peerForBackground = nullptr);
|
|
|
|
SectionWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<SessionController*> controller,
|
|
|
|
not_null<PeerData*> peerForBackground);
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
virtual Dialogs::RowDescriptor activeChat() const {
|
|
|
|
return {};
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// When resizing the widget with top edge moved up or down and we
|
|
|
|
// want to add this top movement to the scroll position, so inner
|
|
|
|
// content will not move.
|
|
|
|
void setGeometryWithTopMoved(const QRect &newGeometry, int topDelta);
|
|
|
|
|
|
|
|
virtual bool hasTopBarShadow() const {
|
|
|
|
return false;
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
virtual bool forceAnimateBack() const {
|
|
|
|
return false;
|
|
|
|
}
|
2017-10-03 13:05:58 +00:00
|
|
|
void showAnimated(
|
|
|
|
SlideDirection direction,
|
|
|
|
const SectionSlideParams ¶ms);
|
2017-01-14 18:50:16 +00:00
|
|
|
void showFast();
|
2022-02-23 10:53:27 +00:00
|
|
|
[[nodiscard]] bool animatingShow() const;
|
2016-05-19 12:03:51 +00:00
|
|
|
|
|
|
|
// This can be used to grab with or without top bar shadow.
|
|
|
|
// This will be protected when animation preparation will be done inside.
|
2019-09-13 12:22:54 +00:00
|
|
|
virtual QPixmap grabForShowAnimation(const SectionSlideParams ¶ms);
|
2016-05-19 12:03:51 +00:00
|
|
|
|
|
|
|
// Attempt to show the required section inside the existing one.
|
|
|
|
// For example if this section already shows exactly the required
|
|
|
|
// memento it can simply return true - it is shown already.
|
2017-06-24 17:05:32 +00:00
|
|
|
//
|
|
|
|
// If this method returns false it is not supposed to modify the memento.
|
|
|
|
// If this method returns true it may modify the memento ("take" heavy items).
|
2017-10-03 13:05:58 +00:00
|
|
|
virtual bool showInternal(
|
|
|
|
not_null<SectionMemento*> memento,
|
|
|
|
const SectionShow ¶ms) = 0;
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2020-08-31 11:17:02 +00:00
|
|
|
virtual bool showMessage(
|
|
|
|
PeerId peerId,
|
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId messageId) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] virtual bool preventsClose(
|
|
|
|
Fn<void()> &&continueCallback) const {
|
2020-11-21 23:18:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-26 23:18:11 +00:00
|
|
|
// Send bot command from peer info or media viewer.
|
|
|
|
virtual SectionActionResult sendBotCommand(
|
|
|
|
Bot::SendCommandRequest request) {
|
|
|
|
return SectionActionResult::Ignore;
|
|
|
|
}
|
|
|
|
|
2022-11-01 07:18:56 +00:00
|
|
|
virtual bool confirmSendingFiles(const QStringList &files) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
virtual bool confirmSendingFiles(not_null<const QMimeData*> data) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-19 12:03:51 +00:00
|
|
|
// Create a memento of that section to store it in the history stack.
|
2017-06-24 17:05:32 +00:00
|
|
|
// This method may modify the section ("take" heavy items).
|
2020-12-14 14:48:10 +00:00
|
|
|
virtual std::shared_ptr<SectionMemento> createMemento();
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
void setInnerFocus() {
|
|
|
|
doSetInnerFocus();
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
2022-11-02 16:03:42 +00:00
|
|
|
virtual void checkActivation() {
|
|
|
|
}
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<int> desiredHeight() const;
|
|
|
|
[[nodiscard]] virtual rpl::producer<> removeRequests() const {
|
|
|
|
return rpl::never<>();
|
|
|
|
}
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
// Some sections convert to layers on some geometry sizes.
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] virtual object_ptr<Ui::LayerWidget> moveContentToLayer(
|
2017-09-30 18:26:45 +00:00
|
|
|
QRect bodyGeometry) {
|
2017-09-15 17:34:41 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-06-10 18:08:17 +00:00
|
|
|
static void PaintBackground(
|
2020-08-31 11:17:02 +00:00
|
|
|
not_null<SessionController*> controller,
|
2021-08-26 15:02:21 +00:00
|
|
|
not_null<Ui::ChatTheme*> theme,
|
2020-06-10 18:08:17 +00:00
|
|
|
not_null<QWidget*> widget,
|
|
|
|
QRect clip);
|
2023-01-05 10:48:46 +00:00
|
|
|
static void PaintBackground(
|
|
|
|
not_null<Ui::ChatTheme*> theme,
|
|
|
|
not_null<QWidget*> widget,
|
|
|
|
int fillHeight,
|
|
|
|
int fromy,
|
|
|
|
QRect clip);
|
|
|
|
static void PaintBackground(
|
|
|
|
QPainter &p,
|
|
|
|
not_null<Ui::ChatTheme*> theme,
|
|
|
|
QSize fill,
|
|
|
|
QRect clip);
|
2018-01-09 17:08:31 +00:00
|
|
|
|
2016-05-19 12:03:51 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
// Temp variable used in resizeEvent() implementation, that is passed
|
|
|
|
// to setGeometryWithTopMoved() to adjust the scroll position with the resize.
|
|
|
|
int topDelta() const {
|
|
|
|
return _topDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called after the hideChildren() call in showAnimated().
|
2017-10-03 17:41:44 +00:00
|
|
|
virtual void showAnimatedHook(
|
2020-08-31 11:17:02 +00:00
|
|
|
const SectionSlideParams ¶ms) {
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called after the showChildren() call in showFinished().
|
|
|
|
virtual void showFinishedHook() {
|
|
|
|
}
|
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
virtual void doSetInnerFocus() {
|
|
|
|
setFocus();
|
|
|
|
}
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
~SectionWidget();
|
|
|
|
|
2016-05-19 12:03:51 +00:00
|
|
|
private:
|
|
|
|
void showFinished();
|
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<SlideAnimation> _showAnimation;
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
// Saving here topDelta in setGeometryWithTopMoved() to get it passed to resizeEvent().
|
2016-05-19 12:03:51 +00:00
|
|
|
int _topDelta = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-08-27 20:44:47 +00:00
|
|
|
[[nodiscard]] auto ChatThemeValueFromPeer(
|
|
|
|
not_null<SessionController*> controller,
|
|
|
|
not_null<PeerData*> peer)
|
|
|
|
-> rpl::producer<std::shared_ptr<Ui::ChatTheme>>;
|
|
|
|
|
2022-04-21 11:06:50 +00:00
|
|
|
[[nodiscard]] bool ShowSendPremiumError(
|
|
|
|
not_null<SessionController*> controller,
|
|
|
|
not_null<DocumentData*> document);
|
2023-05-26 16:30:02 +00:00
|
|
|
[[nodiscard]] bool ShowSendPremiumError(
|
|
|
|
std::shared_ptr<ChatHelpers::Show> show,
|
|
|
|
not_null<DocumentData*> document);
|
2022-04-21 11:06:50 +00:00
|
|
|
|
2022-04-21 15:34:00 +00:00
|
|
|
[[nodiscard]] bool ShowReactPremiumError(
|
|
|
|
not_null<SessionController*> controller,
|
|
|
|
not_null<HistoryItem*> item,
|
2022-08-16 11:28:17 +00:00
|
|
|
const Data::ReactionId &id);
|
2022-04-21 15:34:00 +00:00
|
|
|
|
2016-05-19 12:03:51 +00:00
|
|
|
} // namespace Window
|