2017-12-18 15:44:50 +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.
|
2017-12-18 15:44:50 +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
|
2017-12-18 15:44:50 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2022-02-15 02:20:55 +00:00
|
|
|
#include "data/data_cloud_file.h"
|
2017-12-18 15:44:50 +00:00
|
|
|
#include "history/history_item.h"
|
2023-01-26 15:36:43 +00:00
|
|
|
#include "spellcheck/spellcheck_types.h" // LanguageId.
|
2019-03-15 15:15:56 +00:00
|
|
|
#include "ui/empty_userpic.h"
|
2019-04-01 17:44:54 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2023-08-11 12:23:27 +00:00
|
|
|
#include "ui/effects/ripple_animation.h"
|
2022-09-30 14:49:48 +00:00
|
|
|
#include "ui/chat/message_bubble.h"
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2018-01-25 14:19:14 +00:00
|
|
|
struct WebPageData;
|
2021-06-17 23:28:09 +00:00
|
|
|
class VoiceSeekClickHandler;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2021-09-02 22:08:57 +00:00
|
|
|
namespace Ui {
|
|
|
|
struct ChatPaintContext;
|
|
|
|
class ChatStyle;
|
2022-12-05 12:18:10 +00:00
|
|
|
struct PeerUserpicView;
|
2021-09-02 22:08:57 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2020-06-08 15:17:33 +00:00
|
|
|
namespace Data {
|
|
|
|
class Session;
|
2023-05-26 09:27:34 +00:00
|
|
|
class Story;
|
2020-06-08 15:17:33 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2022-10-24 05:32:13 +00:00
|
|
|
namespace Media::Player {
|
|
|
|
class RoundPainter;
|
|
|
|
} // namespace Media::Player
|
|
|
|
|
2022-10-03 11:11:05 +00:00
|
|
|
namespace Images {
|
|
|
|
struct CornersMaskRef;
|
|
|
|
} // namespace Images
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
class Element;
|
2019-08-02 13:21:09 +00:00
|
|
|
class Document;
|
2022-05-24 15:38:46 +00:00
|
|
|
class TranscribeButton;
|
2018-01-14 16:02:25 +00:00
|
|
|
} // namespace HistoryView
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
struct HistoryMessageVia : public RuntimeComponent<HistoryMessageVia, HistoryItem> {
|
2020-06-08 15:17:33 +00:00
|
|
|
void create(not_null<Data::Session*> owner, UserId userId);
|
2017-12-18 15:44:50 +00:00
|
|
|
void resize(int32 availw) const;
|
|
|
|
|
|
|
|
UserData *bot = nullptr;
|
|
|
|
mutable QString text;
|
|
|
|
mutable int width = 0;
|
|
|
|
mutable int maxWidth = 0;
|
|
|
|
ClickHandlerPtr link;
|
|
|
|
};
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
struct HistoryMessageViews : public RuntimeComponent<HistoryMessageViews, HistoryItem> {
|
2020-09-03 08:21:31 +00:00
|
|
|
static constexpr auto kMaxRecentRepliers = 3;
|
|
|
|
|
2020-09-03 07:19:02 +00:00
|
|
|
struct Part {
|
|
|
|
QString text;
|
|
|
|
int textWidth = 0;
|
|
|
|
int count = -1;
|
|
|
|
};
|
2020-09-03 11:53:54 +00:00
|
|
|
std::vector<PeerId> recentRepliers;
|
2020-09-03 07:19:02 +00:00
|
|
|
Part views;
|
|
|
|
Part replies;
|
2020-09-17 16:25:06 +00:00
|
|
|
Part repliesSmall;
|
2020-09-22 11:01:49 +00:00
|
|
|
ChannelId commentsMegagroupId = 0;
|
2020-09-03 08:21:31 +00:00
|
|
|
MsgId commentsRootId = 0;
|
2022-10-07 11:46:27 +00:00
|
|
|
MsgId commentsInboxReadTillId = 0;
|
|
|
|
MsgId commentsMaxId = 0;
|
2022-10-05 16:06:01 +00:00
|
|
|
int forwardsCount = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
struct HistoryMessageSigned : public RuntimeComponent<HistoryMessageSigned, HistoryItem> {
|
2017-12-18 15:44:50 +00:00
|
|
|
QString author;
|
2020-10-01 09:57:03 +00:00
|
|
|
bool isAnonymousRank = false;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
struct HistoryMessageEdited : public RuntimeComponent<HistoryMessageEdited, HistoryItem> {
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2022-08-09 11:12:19 +00:00
|
|
|
class HiddenSenderInfo {
|
|
|
|
public:
|
2021-01-20 14:09:45 +00:00
|
|
|
HiddenSenderInfo(const QString &name, bool external);
|
2019-03-15 15:15:56 +00:00
|
|
|
|
|
|
|
QString name;
|
|
|
|
QString firstName;
|
|
|
|
QString lastName;
|
|
|
|
PeerId colorPeerId = 0;
|
2022-02-15 02:20:55 +00:00
|
|
|
Ui::EmptyUserpic emptyUserpic;
|
|
|
|
mutable Data::CloudImage customUserpic;
|
|
|
|
|
2022-06-14 09:48:25 +00:00
|
|
|
[[nodiscard]] static ClickHandlerPtr ForwardClickHandler();
|
|
|
|
|
2022-08-09 11:12:19 +00:00
|
|
|
[[nodiscard]] const Ui::Text::String &nameText() const;
|
2022-02-15 02:20:55 +00:00
|
|
|
[[nodiscard]] bool paintCustomUserpic(
|
|
|
|
Painter &p,
|
2022-12-05 12:18:10 +00:00
|
|
|
Ui::PeerUserpicView &view,
|
2022-02-15 02:20:55 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
int size) const;
|
2019-03-15 15:15:56 +00:00
|
|
|
|
|
|
|
inline bool operator==(const HiddenSenderInfo &other) const {
|
|
|
|
return name == other.name;
|
|
|
|
}
|
|
|
|
inline bool operator!=(const HiddenSenderInfo &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2022-08-09 11:12:19 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
mutable Ui::Text::String _nameText;
|
|
|
|
|
2019-03-15 15:15:56 +00:00
|
|
|
};
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
struct HistoryMessageForwarded : public RuntimeComponent<HistoryMessageForwarded, HistoryItem> {
|
2017-12-18 15:44:50 +00:00
|
|
|
void create(const HistoryMessageVia *via) const;
|
|
|
|
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId originalDate = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
PeerData *originalSender = nullptr;
|
2019-03-15 15:15:56 +00:00
|
|
|
std::unique_ptr<HiddenSenderInfo> hiddenSenderInfo;
|
2017-12-18 15:44:50 +00:00
|
|
|
QString originalAuthor;
|
2020-04-28 19:49:55 +00:00
|
|
|
QString psaType;
|
2017-12-18 15:44:50 +00:00
|
|
|
MsgId originalId = 0;
|
2019-06-12 13:26:04 +00:00
|
|
|
mutable Ui::Text::String text = { 1 };
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
PeerData *savedFromPeer = nullptr;
|
|
|
|
MsgId savedFromMsgId = 0;
|
2021-01-20 14:09:45 +00:00
|
|
|
bool imported = false;
|
2023-06-12 18:37:17 +00:00
|
|
|
bool story = false;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2021-12-31 12:47:23 +00:00
|
|
|
struct HistoryMessageSponsored : public RuntimeComponent<HistoryMessageSponsored, HistoryItem> {
|
|
|
|
enum class Type : uchar {
|
|
|
|
User,
|
|
|
|
Group,
|
|
|
|
Broadcast,
|
2021-12-31 13:05:20 +00:00
|
|
|
Post,
|
2021-12-31 12:47:23 +00:00
|
|
|
Bot,
|
2023-06-23 15:36:40 +00:00
|
|
|
ExternalLink,
|
2021-12-31 12:47:23 +00:00
|
|
|
};
|
|
|
|
std::unique_ptr<HiddenSenderInfo> sender;
|
|
|
|
Type type = Type::User;
|
2022-05-10 15:04:29 +00:00
|
|
|
bool recommended = false;
|
2022-10-18 02:31:25 +00:00
|
|
|
bool isForceUserpicDisplay = false;
|
2023-09-11 10:38:53 +00:00
|
|
|
QString externalLink;
|
2021-12-31 12:47:23 +00:00
|
|
|
};
|
|
|
|
|
2022-09-26 13:37:32 +00:00
|
|
|
class ReplyToMessagePointer final {
|
|
|
|
public:
|
|
|
|
ReplyToMessagePointer(HistoryItem *item = nullptr) : _data(item) {
|
|
|
|
}
|
|
|
|
ReplyToMessagePointer(ReplyToMessagePointer &&other)
|
|
|
|
: _data(base::take(other._data)) {
|
|
|
|
}
|
|
|
|
ReplyToMessagePointer &operator=(ReplyToMessagePointer &&other) {
|
|
|
|
_data = base::take(other._data);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
ReplyToMessagePointer &operator=(HistoryItem *item) {
|
|
|
|
_data = item;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool empty() const {
|
|
|
|
return !_data;
|
|
|
|
}
|
|
|
|
[[nodiscard]] HistoryItem *get() const {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
explicit operator bool() const {
|
|
|
|
return !empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] HistoryItem *operator->() const {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
[[nodiscard]] HistoryItem &operator*() const {
|
|
|
|
return *_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
HistoryItem *_data = nullptr;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2023-05-26 09:27:34 +00:00
|
|
|
class ReplyToStoryPointer final {
|
|
|
|
public:
|
|
|
|
ReplyToStoryPointer(Data::Story *story = nullptr) : _data(story) {
|
|
|
|
}
|
|
|
|
ReplyToStoryPointer(ReplyToStoryPointer &&other)
|
|
|
|
: _data(base::take(other._data)) {
|
|
|
|
}
|
|
|
|
ReplyToStoryPointer &operator=(ReplyToStoryPointer &&other) {
|
|
|
|
_data = base::take(other._data);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
ReplyToStoryPointer &operator=(Data::Story *item) {
|
|
|
|
_data = item;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool empty() const {
|
|
|
|
return !_data;
|
|
|
|
}
|
|
|
|
[[nodiscard]] Data::Story *get() const {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
explicit operator bool() const {
|
|
|
|
return !empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] Data::Story *operator->() const {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
[[nodiscard]] Data::Story &operator*() const {
|
|
|
|
return *_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Data::Story *_data = nullptr;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-09-26 13:37:32 +00:00
|
|
|
struct HistoryMessageReply
|
|
|
|
: public RuntimeComponent<HistoryMessageReply, HistoryItem> {
|
2017-12-18 15:44:50 +00:00
|
|
|
HistoryMessageReply() = default;
|
|
|
|
HistoryMessageReply(const HistoryMessageReply &other) = delete;
|
|
|
|
HistoryMessageReply(HistoryMessageReply &&other) = delete;
|
2022-09-26 13:37:32 +00:00
|
|
|
HistoryMessageReply &operator=(
|
|
|
|
const HistoryMessageReply &other) = delete;
|
|
|
|
HistoryMessageReply &operator=(HistoryMessageReply &&other) = default;
|
2017-12-18 15:44:50 +00:00
|
|
|
~HistoryMessageReply() {
|
|
|
|
// clearData() should be called by holder.
|
2022-09-26 13:37:32 +00:00
|
|
|
Expects(replyToMsg.empty());
|
2017-12-18 15:44:50 +00:00
|
|
|
Expects(replyToVia == nullptr);
|
|
|
|
}
|
|
|
|
|
2023-01-05 10:48:46 +00:00
|
|
|
static constexpr auto kBarAlpha = 230. / 255.;
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
bool updateData(not_null<HistoryItem*> holder, bool force = false);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
// Must be called before destructor.
|
2022-12-14 12:15:46 +00:00
|
|
|
void clearData(not_null<HistoryItem*> holder);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] PeerData *replyToFrom(not_null<HistoryItem*> holder) const;
|
2022-03-16 07:02:45 +00:00
|
|
|
[[nodiscard]] QString replyToFromName(
|
2022-12-14 12:15:46 +00:00
|
|
|
not_null<HistoryItem*> holder) const;
|
2022-03-16 07:02:45 +00:00
|
|
|
[[nodiscard]] QString replyToFromName(not_null<PeerData*> peer) const;
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] bool isNameUpdated(not_null<HistoryItem*> holder) const;
|
|
|
|
void updateName(not_null<HistoryItem*> holder) const;
|
2017-12-18 15:44:50 +00:00
|
|
|
void resize(int width) const;
|
2023-05-26 14:48:33 +00:00
|
|
|
void itemRemoved(
|
|
|
|
not_null<HistoryItem*> holder,
|
|
|
|
not_null<HistoryItem*> removed);
|
|
|
|
void storyRemoved(
|
|
|
|
not_null<HistoryItem*> holder,
|
|
|
|
not_null<Data::Story*> removed);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
void paint(
|
|
|
|
Painter &p,
|
2018-01-14 16:02:25 +00:00
|
|
|
not_null<const HistoryView::Element*> holder,
|
2021-09-02 22:08:57 +00:00
|
|
|
const Ui::ChatPaintContext &context,
|
2017-12-18 15:44:50 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int w,
|
2021-09-02 22:08:57 +00:00
|
|
|
bool inBubble) const;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2020-09-11 16:22:14 +00:00
|
|
|
[[nodiscard]] PeerId replyToPeer() const {
|
|
|
|
return replyToPeerId;
|
|
|
|
}
|
2019-12-27 10:41:30 +00:00
|
|
|
[[nodiscard]] MsgId replyToId() const {
|
2017-12-18 15:44:50 +00:00
|
|
|
return replyToMsgId;
|
|
|
|
}
|
2020-09-01 06:44:18 +00:00
|
|
|
[[nodiscard]] MsgId replyToTop() const {
|
|
|
|
return replyToMsgTop;
|
|
|
|
}
|
2019-12-27 10:41:30 +00:00
|
|
|
[[nodiscard]] int replyToWidth() const {
|
2017-12-18 15:44:50 +00:00
|
|
|
return maxReplyWidth;
|
|
|
|
}
|
2019-12-27 10:41:30 +00:00
|
|
|
[[nodiscard]] ClickHandlerPtr replyToLink() const {
|
2017-12-18 15:44:50 +00:00
|
|
|
return replyToLnk;
|
|
|
|
}
|
2023-05-26 09:27:34 +00:00
|
|
|
[[nodiscard]] QString statePhrase() const;
|
2022-12-14 12:15:46 +00:00
|
|
|
void setReplyToLinkFrom(not_null<HistoryItem*> holder);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2021-11-18 12:03:12 +00:00
|
|
|
void refreshReplyToMedia();
|
2019-12-27 10:41:30 +00:00
|
|
|
|
2020-09-11 16:22:14 +00:00
|
|
|
PeerId replyToPeerId = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
MsgId replyToMsgId = 0;
|
2020-09-01 06:44:18 +00:00
|
|
|
MsgId replyToMsgTop = 0;
|
2023-05-25 09:32:13 +00:00
|
|
|
StoryId replyToStoryId = 0;
|
2022-11-23 11:13:01 +00:00
|
|
|
using ColorKey = PeerId;
|
|
|
|
ColorKey replyToColorKey = 0;
|
2019-12-27 12:15:16 +00:00
|
|
|
DocumentId replyToDocumentId = 0;
|
2021-11-18 12:03:12 +00:00
|
|
|
WebPageId replyToWebPageId = 0;
|
2022-09-26 13:37:32 +00:00
|
|
|
ReplyToMessagePointer replyToMsg;
|
2023-05-26 09:27:34 +00:00
|
|
|
ReplyToStoryPointer replyToStory;
|
2022-09-26 13:37:32 +00:00
|
|
|
std::unique_ptr<HistoryMessageVia> replyToVia;
|
2022-12-30 09:37:34 +00:00
|
|
|
std::unique_ptr<Ui::SpoilerAnimation> spoiler;
|
2017-12-18 15:44:50 +00:00
|
|
|
ClickHandlerPtr replyToLnk;
|
2019-06-12 13:26:04 +00:00
|
|
|
mutable Ui::Text::String replyToName, replyToText;
|
2017-12-18 15:44:50 +00:00
|
|
|
mutable int replyToVersion = 0;
|
|
|
|
mutable int maxReplyWidth = 0;
|
|
|
|
int toWidth = 0;
|
2022-09-26 13:37:32 +00:00
|
|
|
bool topicPost = false;
|
2023-05-26 09:27:34 +00:00
|
|
|
bool storyReply = false;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2023-08-11 12:23:27 +00:00
|
|
|
struct final {
|
|
|
|
mutable std::unique_ptr<Ui::RippleAnimation> animation;
|
|
|
|
QPoint lastPoint;
|
|
|
|
} ripple;
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2023-01-26 15:36:43 +00:00
|
|
|
struct HistoryMessageTranslation
|
|
|
|
: public RuntimeComponent<HistoryMessageTranslation, HistoryItem> {
|
|
|
|
TextWithEntities text;
|
|
|
|
LanguageId to;
|
|
|
|
bool requested = false;
|
|
|
|
bool failed = false;
|
|
|
|
bool used = false;
|
|
|
|
};
|
|
|
|
|
2021-07-28 07:33:52 +00:00
|
|
|
struct HistoryMessageReplyMarkup
|
|
|
|
: public RuntimeComponent<HistoryMessageReplyMarkup, HistoryItem> {
|
2017-12-18 15:44:50 +00:00
|
|
|
using Button = HistoryMessageMarkupButton;
|
|
|
|
|
2021-10-02 11:28:21 +00:00
|
|
|
void createForwarded(const HistoryMessageReplyMarkup &original);
|
|
|
|
void updateData(HistoryMessageMarkupData &&markup);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2022-09-12 12:10:30 +00:00
|
|
|
[[nodiscard]] bool hiddenBy(Data::Media *media) const;
|
|
|
|
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData data;
|
2017-12-18 15:44:50 +00:00
|
|
|
std::unique_ptr<ReplyKeyboard> inlineKeyboard;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-07-26 23:45:01 +00:00
|
|
|
class ReplyMarkupClickHandler : public ClickHandler {
|
2017-12-18 15:44:50 +00:00
|
|
|
public:
|
2020-06-09 09:36:40 +00:00
|
|
|
ReplyMarkupClickHandler(
|
|
|
|
not_null<Data::Session*> owner,
|
|
|
|
int row,
|
|
|
|
int column,
|
|
|
|
FullMsgId context);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2021-01-21 23:36:22 +00:00
|
|
|
QString tooltip() const override;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
void setFullDisplayed(bool full) {
|
|
|
|
_fullDisplayed = full;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy to clipboard support.
|
2018-01-25 10:10:52 +00:00
|
|
|
QString copyToClipboardText() const override;
|
2017-12-18 15:44:50 +00:00
|
|
|
QString copyToClipboardContextItemText() const override;
|
|
|
|
|
|
|
|
// Finds the corresponding button in the items markup struct.
|
|
|
|
// If the button is not found it returns nullptr.
|
|
|
|
// Note: it is possible that we will point to the different button
|
|
|
|
// than the one was used when constructing the handler, but not a big deal.
|
|
|
|
const HistoryMessageMarkupButton *getButton() const;
|
|
|
|
|
2021-01-21 23:36:22 +00:00
|
|
|
const HistoryMessageMarkupButton *getUrlButton() const;
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
// We hold only FullMsgId, not HistoryItem*, because all click handlers
|
|
|
|
// are activated async and the item may be already destroyed.
|
|
|
|
void setMessageId(const FullMsgId &msgId) {
|
|
|
|
_itemId = msgId;
|
|
|
|
}
|
|
|
|
|
2021-07-26 23:45:01 +00:00
|
|
|
void onClick(ClickContext context) const override;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
private:
|
2020-06-09 09:36:40 +00:00
|
|
|
const not_null<Data::Session*> _owner;
|
2017-12-18 15:44:50 +00:00
|
|
|
FullMsgId _itemId;
|
|
|
|
int _row = 0;
|
|
|
|
int _column = 0;
|
|
|
|
bool _fullDisplayed = true;
|
|
|
|
|
|
|
|
// Returns the full text of the corresponding button.
|
|
|
|
QString buttonText() const;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class ReplyKeyboard {
|
|
|
|
private:
|
|
|
|
struct Button;
|
|
|
|
|
|
|
|
public:
|
|
|
|
class Style {
|
|
|
|
public:
|
|
|
|
Style(const style::BotKeyboardButton &st) : _st(&st) {
|
|
|
|
}
|
|
|
|
|
2021-09-02 22:08:57 +00:00
|
|
|
virtual void startPaint(
|
2022-09-16 20:23:27 +00:00
|
|
|
QPainter &p,
|
2021-09-02 22:08:57 +00:00
|
|
|
const Ui::ChatStyle *st) const = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
virtual const style::TextStyle &textStyle() const = 0;
|
|
|
|
|
|
|
|
int buttonSkip() const;
|
|
|
|
int buttonPadding() const;
|
|
|
|
int buttonHeight() const;
|
2022-10-03 11:11:05 +00:00
|
|
|
[[nodiscard]] virtual Images::CornersMaskRef buttonRounding(
|
|
|
|
Ui::BubbleRounding outer,
|
|
|
|
RectParts sides) const = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
virtual void repaint(not_null<const HistoryItem*> item) const = 0;
|
|
|
|
virtual ~Style() {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void paintButtonBg(
|
2022-09-16 20:23:27 +00:00
|
|
|
QPainter &p,
|
2021-09-02 22:08:57 +00:00
|
|
|
const Ui::ChatStyle *st,
|
2017-12-18 15:44:50 +00:00
|
|
|
const QRect &rect,
|
2022-10-03 11:11:05 +00:00
|
|
|
Ui::BubbleRounding rounding,
|
2017-12-18 15:44:50 +00:00
|
|
|
float64 howMuchOver) const = 0;
|
|
|
|
virtual void paintButtonIcon(
|
2022-09-16 20:23:27 +00:00
|
|
|
QPainter &p,
|
2021-09-02 22:08:57 +00:00
|
|
|
const Ui::ChatStyle *st,
|
2017-12-18 15:44:50 +00:00
|
|
|
const QRect &rect,
|
|
|
|
int outerWidth,
|
|
|
|
HistoryMessageMarkupButton::Type type) const = 0;
|
|
|
|
virtual void paintButtonLoading(
|
2022-09-16 20:23:27 +00:00
|
|
|
QPainter &p,
|
2021-09-02 22:08:57 +00:00
|
|
|
const Ui::ChatStyle *st,
|
2023-08-14 13:08:24 +00:00
|
|
|
const QRect &rect,
|
|
|
|
int outerWidth,
|
|
|
|
Ui::BubbleRounding rounding) const = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
virtual int minButtonWidth(
|
|
|
|
HistoryMessageMarkupButton::Type type) const = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const style::BotKeyboardButton *_st;
|
|
|
|
|
2021-09-02 22:08:57 +00:00
|
|
|
void paintButton(
|
|
|
|
Painter &p,
|
|
|
|
const Ui::ChatStyle *st,
|
|
|
|
int outerWidth,
|
2022-10-03 11:11:05 +00:00
|
|
|
const ReplyKeyboard::Button &button,
|
|
|
|
Ui::BubbleRounding rounding) const;
|
2017-12-18 15:44:50 +00:00
|
|
|
friend class ReplyKeyboard;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
ReplyKeyboard(
|
|
|
|
not_null<const HistoryItem*> item,
|
|
|
|
std::unique_ptr<Style> &&s);
|
|
|
|
ReplyKeyboard(const ReplyKeyboard &other) = delete;
|
|
|
|
ReplyKeyboard &operator=(const ReplyKeyboard &other) = delete;
|
|
|
|
|
|
|
|
bool isEnoughSpace(int width, const style::BotKeyboardButton &st) const;
|
|
|
|
void setStyle(std::unique_ptr<Style> &&s);
|
|
|
|
void resize(int width, int height);
|
|
|
|
|
|
|
|
// what width and height will best fit this keyboard
|
|
|
|
int naturalWidth() const;
|
|
|
|
int naturalHeight() const;
|
|
|
|
|
2021-09-02 22:08:57 +00:00
|
|
|
void paint(
|
|
|
|
Painter &p,
|
|
|
|
const Ui::ChatStyle *st,
|
2022-10-03 11:11:05 +00:00
|
|
|
Ui::BubbleRounding rounding,
|
2021-09-02 22:08:57 +00:00
|
|
|
int outerWidth,
|
|
|
|
const QRect &clip) const;
|
2018-01-27 13:59:24 +00:00
|
|
|
ClickHandlerPtr getLink(QPoint point) const;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2022-10-03 11:11:05 +00:00
|
|
|
void clickHandlerActiveChanged(
|
|
|
|
const ClickHandlerPtr &p,
|
|
|
|
bool active);
|
|
|
|
void clickHandlerPressedChanged(
|
|
|
|
const ClickHandlerPtr &p,
|
|
|
|
bool pressed,
|
|
|
|
Ui::BubbleRounding rounding);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
void clearSelection();
|
|
|
|
void updateMessageId();
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class Style;
|
|
|
|
struct Button {
|
|
|
|
Button();
|
|
|
|
Button(Button &&other);
|
|
|
|
Button &operator=(Button &&other);
|
|
|
|
~Button();
|
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String text = { 1 };
|
2017-12-18 15:44:50 +00:00
|
|
|
QRect rect;
|
|
|
|
int characters = 0;
|
|
|
|
float64 howMuchOver = 0.;
|
|
|
|
HistoryMessageMarkupButton::Type type;
|
|
|
|
std::shared_ptr<ReplyMarkupClickHandler> link;
|
|
|
|
mutable std::unique_ptr<Ui::RippleAnimation> ripple;
|
|
|
|
};
|
|
|
|
struct ButtonCoords {
|
|
|
|
int i, j;
|
|
|
|
};
|
|
|
|
|
|
|
|
void startAnimation(int i, int j, int direction);
|
|
|
|
|
|
|
|
ButtonCoords findButtonCoordsByClickHandler(const ClickHandlerPtr &p);
|
|
|
|
|
2019-04-01 17:44:54 +00:00
|
|
|
bool selectedAnimationCallback(crl::time now);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
const not_null<const HistoryItem*> _item;
|
|
|
|
int _width = 0;
|
|
|
|
|
|
|
|
std::vector<std::vector<Button>> _rows;
|
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
base::flat_map<int, crl::time> _animations;
|
2019-04-01 17:44:54 +00:00
|
|
|
Ui::Animations::Basic _selectedAnimation;
|
2017-12-18 15:44:50 +00:00
|
|
|
std::unique_ptr<Style> _st;
|
|
|
|
|
|
|
|
ClickHandlerPtr _savedPressed;
|
|
|
|
ClickHandlerPtr _savedActive;
|
|
|
|
mutable QPoint _savedCoords;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// Special type of Component for the channel actions log.
|
2018-01-14 16:02:25 +00:00
|
|
|
struct HistoryMessageLogEntryOriginal
|
2022-12-14 12:15:46 +00:00
|
|
|
: public RuntimeComponent<HistoryMessageLogEntryOriginal, HistoryItem> {
|
2017-12-18 15:44:50 +00:00
|
|
|
HistoryMessageLogEntryOriginal();
|
|
|
|
HistoryMessageLogEntryOriginal(HistoryMessageLogEntryOriginal &&other);
|
|
|
|
HistoryMessageLogEntryOriginal &operator=(HistoryMessageLogEntryOriginal &&other);
|
|
|
|
~HistoryMessageLogEntryOriginal();
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
WebPageData *page = nullptr;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
struct HistoryServiceData
|
|
|
|
: public RuntimeComponent<HistoryServiceData, HistoryItem> {
|
|
|
|
std::vector<ClickHandlerPtr> textLinks;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryServiceDependentData {
|
|
|
|
PeerId peerId = 0;
|
|
|
|
HistoryItem *msg = nullptr;
|
|
|
|
ClickHandlerPtr lnk;
|
|
|
|
MsgId msgId = 0;
|
|
|
|
MsgId topId = 0;
|
|
|
|
bool topicPost = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryServicePinned
|
|
|
|
: public RuntimeComponent<HistoryServicePinned, HistoryItem>
|
|
|
|
, public HistoryServiceDependentData {
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryServiceTopicInfo
|
|
|
|
: public RuntimeComponent<HistoryServiceTopicInfo, HistoryItem>
|
|
|
|
, public HistoryServiceDependentData {
|
|
|
|
QString title;
|
|
|
|
DocumentId iconId = 0;
|
|
|
|
bool closed = false;
|
|
|
|
bool reopened = false;
|
|
|
|
bool reiconed = false;
|
|
|
|
bool renamed = false;
|
|
|
|
bool hidden = false;
|
|
|
|
bool unhidden = false;
|
|
|
|
|
|
|
|
[[nodiscard]] bool created() const {
|
|
|
|
return !closed
|
|
|
|
&& !reopened
|
|
|
|
&& !reiconed
|
|
|
|
&& !renamed
|
|
|
|
&& !hidden
|
|
|
|
&& !unhidden;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryServiceGameScore
|
|
|
|
: public RuntimeComponent<HistoryServiceGameScore, HistoryItem>
|
|
|
|
, public HistoryServiceDependentData {
|
|
|
|
int score = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryServicePayment
|
|
|
|
: public RuntimeComponent<HistoryServicePayment, HistoryItem>
|
|
|
|
, public HistoryServiceDependentData {
|
|
|
|
QString slug;
|
|
|
|
QString amount;
|
|
|
|
ClickHandlerPtr invoiceLink;
|
|
|
|
bool recurringInit = false;
|
|
|
|
bool recurringUsed = false;
|
|
|
|
};
|
|
|
|
|
2023-04-03 07:58:30 +00:00
|
|
|
struct HistoryServiceSameBackground
|
|
|
|
: public RuntimeComponent<HistoryServiceSameBackground, HistoryItem>
|
|
|
|
, public HistoryServiceDependentData {
|
|
|
|
};
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
enum class HistorySelfDestructType {
|
|
|
|
Photo,
|
|
|
|
Video,
|
|
|
|
};
|
|
|
|
|
2023-08-29 10:29:59 +00:00
|
|
|
struct TimeToLiveSingleView {
|
|
|
|
friend inline auto operator<=>(
|
|
|
|
TimeToLiveSingleView,
|
|
|
|
TimeToLiveSingleView) = default;
|
|
|
|
friend inline bool operator==(
|
|
|
|
TimeToLiveSingleView,
|
|
|
|
TimeToLiveSingleView) = default;
|
|
|
|
};
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
struct HistoryServiceSelfDestruct
|
|
|
|
: public RuntimeComponent<HistoryServiceSelfDestruct, HistoryItem> {
|
|
|
|
using Type = HistorySelfDestructType;
|
|
|
|
|
|
|
|
Type type = Type::Photo;
|
2023-08-29 10:29:59 +00:00
|
|
|
std::variant<crl::time, TimeToLiveSingleView> timeToLive = crl::time();
|
|
|
|
std::variant<crl::time, TimeToLiveSingleView> destructAt = crl::time();
|
2022-12-14 12:15:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryServiceOngoingCall
|
|
|
|
: public RuntimeComponent<HistoryServiceOngoingCall, HistoryItem> {
|
|
|
|
CallId id = 0;
|
|
|
|
ClickHandlerPtr link;
|
|
|
|
rpl::lifetime lifetime;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryServiceChatThemeChange
|
|
|
|
: public RuntimeComponent<HistoryServiceChatThemeChange, HistoryItem> {
|
|
|
|
ClickHandlerPtr link;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryServiceTTLChange
|
|
|
|
: public RuntimeComponent<HistoryServiceTTLChange, HistoryItem> {
|
|
|
|
ClickHandlerPtr link;
|
|
|
|
};
|
|
|
|
|
2018-01-11 13:07:29 +00:00
|
|
|
class FileClickHandler;
|
2019-08-02 13:21:09 +00:00
|
|
|
struct HistoryDocumentThumbed : public RuntimeComponent<HistoryDocumentThumbed, HistoryView::Document> {
|
2022-09-30 14:49:48 +00:00
|
|
|
std::shared_ptr<FileClickHandler> linksavel;
|
|
|
|
std::shared_ptr<FileClickHandler> linkopenwithl;
|
|
|
|
std::shared_ptr<FileClickHandler> linkcancell;
|
|
|
|
mutable QImage thumbnail;
|
|
|
|
mutable QString link;
|
|
|
|
int thumbw = 0;
|
|
|
|
mutable int linkw = 0;
|
|
|
|
mutable Ui::BubbleRounding rounding;
|
|
|
|
mutable bool blurred : 1 = false;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2019-08-02 13:21:09 +00:00
|
|
|
struct HistoryDocumentCaptioned : public RuntimeComponent<HistoryDocumentCaptioned, HistoryView::Document> {
|
2017-12-18 15:44:50 +00:00
|
|
|
HistoryDocumentCaptioned();
|
|
|
|
|
2022-09-30 14:49:48 +00:00
|
|
|
Ui::Text::String caption;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2019-08-02 13:21:09 +00:00
|
|
|
struct HistoryDocumentNamed : public RuntimeComponent<HistoryDocumentNamed, HistoryView::Document> {
|
2022-09-30 14:49:48 +00:00
|
|
|
QString name;
|
|
|
|
int namew = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryDocumentVoicePlayback {
|
2019-08-02 13:21:09 +00:00
|
|
|
HistoryDocumentVoicePlayback(const HistoryView::Document *that);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2019-04-01 17:44:54 +00:00
|
|
|
int32 position = 0;
|
|
|
|
anim::value progress;
|
|
|
|
Ui::Animations::Basic progressAnimation;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2019-08-02 13:21:09 +00:00
|
|
|
class HistoryDocumentVoice : public RuntimeComponent<HistoryDocumentVoice, HistoryView::Document> {
|
2017-12-18 15:44:50 +00:00
|
|
|
// We don't use float64 because components should align to pointer even on 32bit systems.
|
|
|
|
static constexpr float64 kFloatToIntMultiplier = 65536.;
|
|
|
|
|
|
|
|
public:
|
2019-08-02 13:21:09 +00:00
|
|
|
void ensurePlayback(const HistoryView::Document *interfaces) const;
|
2017-12-18 15:44:50 +00:00
|
|
|
void checkPlaybackFinished() const;
|
|
|
|
|
2022-09-30 14:49:48 +00:00
|
|
|
mutable std::unique_ptr<HistoryDocumentVoicePlayback> playback;
|
|
|
|
std::shared_ptr<VoiceSeekClickHandler> seekl;
|
|
|
|
mutable int lastDurationMs = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2022-05-24 15:38:46 +00:00
|
|
|
[[nodiscard]] bool seeking() const;
|
2017-12-18 15:44:50 +00:00
|
|
|
void startSeeking();
|
|
|
|
void stopSeeking();
|
2022-05-24 15:38:46 +00:00
|
|
|
[[nodiscard]] float64 seekingStart() const;
|
|
|
|
void setSeekingStart(float64 seekingStart) const;
|
|
|
|
[[nodiscard]] float64 seekingCurrent() const;
|
|
|
|
void setSeekingCurrent(float64 seekingCurrent);
|
|
|
|
|
|
|
|
std::unique_ptr<HistoryView::TranscribeButton> transcribe;
|
|
|
|
Ui::Text::String transcribeText;
|
2022-10-24 05:32:13 +00:00
|
|
|
std::unique_ptr<Media::Player::RoundPainter> round;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool _seeking = false;
|
|
|
|
|
|
|
|
mutable int _seekingStart = 0;
|
|
|
|
mutable int _seekingCurrent = 0;
|
|
|
|
|
|
|
|
};
|