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
|
|
|
|
|
|
|
|
#include "history/history_item.h"
|
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"
|
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
|
|
|
|
2020-06-08 15:17:33 +00:00
|
|
|
namespace Data {
|
|
|
|
class Session;
|
|
|
|
} // namespace Data
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
class Element;
|
2019-08-02 13:21:09 +00:00
|
|
|
class Document;
|
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
|
|
|
MsgId repliesInboxReadTillId = 0;
|
|
|
|
MsgId repliesOutboxReadTillId = 0;
|
|
|
|
MsgId repliesMaxId = 0;
|
|
|
|
ChannelId commentsMegagroupId = 0;
|
2020-09-03 08:21:31 +00:00
|
|
|
MsgId commentsRootId = 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
|
|
|
void refresh(const QString &date);
|
|
|
|
int maxWidth() const;
|
|
|
|
|
|
|
|
QString author;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String signature;
|
2020-10-01 09:57:03 +00:00
|
|
|
bool isElided = false;
|
|
|
|
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> {
|
2017-12-18 15:44:50 +00:00
|
|
|
void refresh(const QString &date, bool displayed);
|
|
|
|
int maxWidth() const;
|
|
|
|
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date = 0;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String text;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2019-03-15 15:15:56 +00:00
|
|
|
struct HiddenSenderInfo {
|
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;
|
|
|
|
Ui::EmptyUserpic userpic;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String nameText;
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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;
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
|
|
|
|
2018-01-14 16:02:25 +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;
|
|
|
|
HistoryMessageReply &operator=(const HistoryMessageReply &other) = delete;
|
|
|
|
HistoryMessageReply &operator=(HistoryMessageReply &&other) {
|
2020-09-11 16:22:14 +00:00
|
|
|
replyToPeerId = other.replyToPeerId;
|
2017-12-18 15:44:50 +00:00
|
|
|
replyToMsgId = other.replyToMsgId;
|
2020-09-01 06:44:18 +00:00
|
|
|
replyToMsgTop = other.replyToMsgTop;
|
2020-01-16 08:58:44 +00:00
|
|
|
replyToDocumentId = other.replyToDocumentId;
|
2017-12-18 15:44:50 +00:00
|
|
|
std::swap(replyToMsg, other.replyToMsg);
|
|
|
|
replyToLnk = std::move(other.replyToLnk);
|
|
|
|
replyToName = std::move(other.replyToName);
|
|
|
|
replyToText = std::move(other.replyToText);
|
|
|
|
replyToVersion = other.replyToVersion;
|
|
|
|
maxReplyWidth = other.maxReplyWidth;
|
|
|
|
replyToVia = std::move(other.replyToVia);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
~HistoryMessageReply() {
|
|
|
|
// clearData() should be called by holder.
|
|
|
|
Expects(replyToMsg == nullptr);
|
|
|
|
Expects(replyToVia == nullptr);
|
|
|
|
}
|
|
|
|
|
2018-01-26 15:40:11 +00:00
|
|
|
bool updateData(not_null<HistoryMessage*> holder, bool force = false);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
// Must be called before destructor.
|
2018-01-26 15:40:11 +00:00
|
|
|
void clearData(not_null<HistoryMessage*> holder);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
bool isNameUpdated() const;
|
|
|
|
void updateName() const;
|
|
|
|
void resize(int width) const;
|
|
|
|
void itemRemoved(HistoryMessage *holder, HistoryItem *removed);
|
|
|
|
|
|
|
|
enum class PaintFlag {
|
|
|
|
InBubble = (1 << 0),
|
|
|
|
Selected = (1 << 1),
|
|
|
|
};
|
|
|
|
using PaintFlags = base::flags<PaintFlag>;
|
|
|
|
friend inline constexpr auto is_flag_type(PaintFlag) { return true; };
|
|
|
|
void paint(
|
|
|
|
Painter &p,
|
2018-01-14 16:02:25 +00:00
|
|
|
not_null<const HistoryView::Element*> holder,
|
2017-12-18 15:44:50 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int w,
|
|
|
|
PaintFlags flags) const;
|
|
|
|
|
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;
|
|
|
|
}
|
2018-06-04 16:58:35 +00:00
|
|
|
void setReplyToLinkFrom(
|
|
|
|
not_null<HistoryMessage*> holder);
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2019-12-27 14:29:51 +00:00
|
|
|
void refreshReplyToDocument();
|
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;
|
2017-12-18 15:44:50 +00:00
|
|
|
HistoryItem *replyToMsg = nullptr;
|
2019-12-27 12:15:16 +00:00
|
|
|
DocumentId replyToDocumentId = 0;
|
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;
|
|
|
|
std::unique_ptr<HistoryMessageVia> replyToVia;
|
|
|
|
int toWidth = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HistoryMessageMarkupButton {
|
|
|
|
enum class Type {
|
|
|
|
Default,
|
|
|
|
Url,
|
|
|
|
Callback,
|
2020-08-25 10:57:17 +00:00
|
|
|
CallbackWithPassword,
|
2017-12-18 15:44:50 +00:00
|
|
|
RequestPhone,
|
|
|
|
RequestLocation,
|
2020-01-15 13:30:29 +00:00
|
|
|
RequestPoll,
|
2017-12-18 15:44:50 +00:00
|
|
|
SwitchInline,
|
|
|
|
SwitchInlineSame,
|
|
|
|
Game,
|
|
|
|
Buy,
|
2019-05-22 14:29:02 +00:00
|
|
|
Auth,
|
2017-12-18 15:44:50 +00:00
|
|
|
};
|
2019-05-22 14:29:02 +00:00
|
|
|
|
|
|
|
HistoryMessageMarkupButton(
|
|
|
|
Type type,
|
|
|
|
const QString &text,
|
|
|
|
const QByteArray &data = QByteArray(),
|
2019-05-27 13:26:12 +00:00
|
|
|
const QString &forwardText = QString(),
|
2019-05-22 14:29:02 +00:00
|
|
|
int32 buttonId = 0);
|
|
|
|
|
|
|
|
static HistoryMessageMarkupButton *Get(
|
2020-06-08 15:17:33 +00:00
|
|
|
not_null<Data::Session*> owner,
|
2019-05-22 14:29:02 +00:00
|
|
|
FullMsgId itemId,
|
|
|
|
int row,
|
|
|
|
int column);
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
Type type;
|
2019-05-27 13:26:12 +00:00
|
|
|
QString text, forwardText;
|
2017-12-18 15:44:50 +00:00
|
|
|
QByteArray data;
|
2019-05-22 14:29:02 +00:00
|
|
|
int32 buttonId = 0;
|
|
|
|
mutable mtpRequestId requestId = 0;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
HistoryMessageReplyMarkup() = default;
|
2021-07-28 07:33:52 +00:00
|
|
|
HistoryMessageReplyMarkup(ReplyMarkupFlags flags) : flags(flags) {
|
2017-12-18 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void create(const MTPReplyMarkup &markup);
|
|
|
|
void create(const HistoryMessageReplyMarkup &markup);
|
|
|
|
|
|
|
|
std::vector<std::vector<Button>> rows;
|
2021-07-28 07:33:52 +00:00
|
|
|
ReplyMarkupFlags flags = 0;
|
2021-07-05 17:59:23 +00:00
|
|
|
QString placeholder;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
|
|
|
std::unique_ptr<ReplyKeyboard> inlineKeyboard;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void createFromButtonRows(const QVector<MTPKeyboardButtonRow> &v);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
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) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void startPaint(Painter &p) const = 0;
|
|
|
|
virtual const style::TextStyle &textStyle() const = 0;
|
|
|
|
|
|
|
|
int buttonSkip() const;
|
|
|
|
int buttonPadding() const;
|
|
|
|
int buttonHeight() const;
|
|
|
|
virtual int buttonRadius() const = 0;
|
|
|
|
|
|
|
|
virtual void repaint(not_null<const HistoryItem*> item) const = 0;
|
|
|
|
virtual ~Style() {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void paintButtonBg(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &rect,
|
|
|
|
float64 howMuchOver) const = 0;
|
|
|
|
virtual void paintButtonIcon(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &rect,
|
|
|
|
int outerWidth,
|
|
|
|
HistoryMessageMarkupButton::Type type) const = 0;
|
|
|
|
virtual void paintButtonLoading(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &rect) const = 0;
|
|
|
|
virtual int minButtonWidth(
|
|
|
|
HistoryMessageMarkupButton::Type type) const = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const style::BotKeyboardButton *_st;
|
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
void paintButton(Painter &p, int outerWidth, const ReplyKeyboard::Button &button) 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;
|
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
void paint(Painter &p, 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
|
|
|
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active);
|
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed);
|
|
|
|
|
|
|
|
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
|
|
|
|
: 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
|
|
|
|
|
|
|
};
|
|
|
|
|
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> {
|
2019-03-13 09:35:47 +00:00
|
|
|
std::shared_ptr<FileClickHandler> _linksavel;
|
|
|
|
std::shared_ptr<FileClickHandler> _linkopenwithl;
|
|
|
|
std::shared_ptr<FileClickHandler> _linkcancell;
|
2017-12-18 15:44:50 +00:00
|
|
|
int _thumbw = 0;
|
|
|
|
|
|
|
|
mutable int _linkw = 0;
|
|
|
|
mutable QString _link;
|
|
|
|
};
|
|
|
|
|
2019-08-02 13:21:09 +00:00
|
|
|
struct HistoryDocumentCaptioned : public RuntimeComponent<HistoryDocumentCaptioned, HistoryView::Document> {
|
2017-12-18 15:44:50 +00:00
|
|
|
HistoryDocumentCaptioned();
|
|
|
|
|
2019-06-12 13:26:04 +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> {
|
2017-12-18 15:44:50 +00:00
|
|
|
QString _name;
|
|
|
|
int _namew = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
mutable std::unique_ptr<HistoryDocumentVoicePlayback> _playback;
|
|
|
|
std::shared_ptr<VoiceSeekClickHandler> _seekl;
|
|
|
|
mutable int _lastDurationMs = 0;
|
|
|
|
|
|
|
|
bool seeking() const {
|
|
|
|
return _seeking;
|
|
|
|
}
|
|
|
|
void startSeeking();
|
|
|
|
void stopSeeking();
|
|
|
|
float64 seekingStart() const {
|
|
|
|
return _seekingStart / kFloatToIntMultiplier;
|
|
|
|
}
|
|
|
|
void setSeekingStart(float64 seekingStart) const {
|
|
|
|
_seekingStart = qRound(seekingStart * kFloatToIntMultiplier);
|
|
|
|
}
|
|
|
|
float64 seekingCurrent() const {
|
|
|
|
return _seekingCurrent / kFloatToIntMultiplier;
|
|
|
|
}
|
|
|
|
void setSeekingCurrent(float64 seekingCurrent) {
|
|
|
|
_seekingCurrent = qRound(seekingCurrent * kFloatToIntMultiplier);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool _seeking = false;
|
|
|
|
|
|
|
|
mutable int _seekingStart = 0;
|
|
|
|
mutable int _seekingCurrent = 0;
|
|
|
|
|
|
|
|
};
|