2016-09-28 10:15:03 +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-09-28 10:15:03 +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-09-28 10:15:03 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-06-22 15:11:41 +00:00
|
|
|
#include "history/history_media.h"
|
2016-09-28 10:15:03 +00:00
|
|
|
#include "ui/effects/radial_animation.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_document.h"
|
|
|
|
#include "data/data_photo.h"
|
|
|
|
#include "data/data_web_page.h"
|
|
|
|
#include "data/data_game.h"
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
class ReplyMarkupClickHandler;
|
|
|
|
struct HistoryDocumentNamed;
|
|
|
|
struct HistoryMessageVia;
|
|
|
|
struct HistoryMessageReply;
|
|
|
|
struct HistoryMessageForwarded;
|
|
|
|
|
2017-05-18 17:20:07 +00:00
|
|
|
namespace Media {
|
|
|
|
namespace Clip {
|
|
|
|
class Playback;
|
|
|
|
} // namespace Clip
|
|
|
|
} // namespace Media
|
|
|
|
|
2017-12-05 08:43:18 +00:00
|
|
|
namespace Ui {
|
|
|
|
class EmptyUserpic;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2017-12-13 18:10:48 +00:00
|
|
|
TextWithEntities WithCaptionSelectedText(
|
|
|
|
const QString &attachType,
|
|
|
|
const Text &caption,
|
|
|
|
TextSelection selection);
|
|
|
|
QString WithCaptionNotificationText(
|
|
|
|
const QString &attachType,
|
|
|
|
const Text &caption);
|
|
|
|
QString WithCaptionDialogsText(
|
|
|
|
const QString &attachType,
|
|
|
|
const Text &caption);
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
class HistoryFileMedia : public HistoryMedia {
|
|
|
|
public:
|
|
|
|
using HistoryMedia::HistoryMedia;
|
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return p == _openl || p == _savel || p == _cancell;
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return p == _openl || p == _savel || p == _cancell;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
|
|
|
|
2017-12-18 13:13:41 +00:00
|
|
|
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
|
|
|
|
2017-07-11 17:11:06 +00:00
|
|
|
bool allowsFastShare() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
~HistoryFileMedia();
|
|
|
|
|
|
|
|
protected:
|
2017-12-18 13:13:41 +00:00
|
|
|
using FileClickHandlerPtr = std::shared_ptr<FileClickHandler>;
|
|
|
|
FileClickHandlerPtr _openl, _savel, _cancell;
|
|
|
|
|
|
|
|
void setLinks(
|
|
|
|
FileClickHandlerPtr &&openl,
|
|
|
|
FileClickHandlerPtr &&savel,
|
|
|
|
FileClickHandlerPtr &&cancell);
|
2017-12-15 16:25:47 +00:00
|
|
|
void setDocumentLinks(
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
not_null<HistoryItem*> realParent,
|
|
|
|
bool inlinegif = false) {
|
2017-12-18 13:13:41 +00:00
|
|
|
FileClickHandlerPtr open, save;
|
2017-12-15 16:25:47 +00:00
|
|
|
const auto context = realParent->fullId();
|
2016-09-28 10:15:03 +00:00
|
|
|
if (inlinegif) {
|
2017-12-18 09:07:18 +00:00
|
|
|
open = std::make_shared<GifOpenClickHandler>(document, context);
|
2016-09-28 10:15:03 +00:00
|
|
|
} else {
|
2017-12-18 09:07:18 +00:00
|
|
|
open = std::make_shared<DocumentOpenClickHandler>(document, context);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
if (inlinegif) {
|
2017-12-18 09:07:18 +00:00
|
|
|
save = std::make_shared<GifOpenClickHandler>(document, context);
|
2017-12-10 10:26:58 +00:00
|
|
|
} else if (document->isVoiceMessage()) {
|
2017-12-18 09:07:18 +00:00
|
|
|
save = std::make_shared<DocumentOpenClickHandler>(document, context);
|
2016-09-28 10:15:03 +00:00
|
|
|
} else {
|
2017-12-18 09:07:18 +00:00
|
|
|
save = std::make_shared<DocumentSaveClickHandler>(document, context);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
2017-12-15 16:25:47 +00:00
|
|
|
setLinks(
|
|
|
|
std::move(open),
|
|
|
|
std::move(save),
|
2017-12-18 09:07:18 +00:00
|
|
|
std::make_shared<DocumentCancelClickHandler>(document, context));
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
|
|
|
// < 0 will contain played string, _statusSize = -(seconds + 1) played
|
|
|
|
// 0x7FFFFFF0 will contain status for not yet downloaded file
|
|
|
|
// 0x7FFFFFF1 will contain status for already downloaded file
|
|
|
|
// 0x7FFFFFF2 will contain status for failed to download / upload file
|
|
|
|
mutable int32 _statusSize;
|
|
|
|
mutable QString _statusText;
|
|
|
|
|
|
|
|
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
|
|
|
void setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void step_radial(TimeMs ms, bool timer);
|
2016-12-07 13:32:25 +00:00
|
|
|
void thumbAnimationCallback();
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
void ensureAnimation() const;
|
2016-12-09 06:19:55 +00:00
|
|
|
void checkAnimationFinished() const;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
bool isRadialAnimation(TimeMs ms) const {
|
2016-09-28 10:15:03 +00:00
|
|
|
if (!_animation || !_animation->radial.animating()) return false;
|
|
|
|
|
|
|
|
_animation->radial.step(ms);
|
|
|
|
return _animation && _animation->radial.animating();
|
|
|
|
}
|
2016-12-01 19:20:33 +00:00
|
|
|
bool isThumbAnimation(TimeMs ms) const {
|
2016-12-07 13:32:25 +00:00
|
|
|
if (_animation) {
|
2016-12-09 06:19:55 +00:00
|
|
|
if (_animation->a_thumbOver.animating(ms)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
checkAnimationFinished();
|
2016-12-07 13:32:25 +00:00
|
|
|
}
|
|
|
|
return false;
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual float64 dataProgress() const = 0;
|
|
|
|
virtual bool dataFinished() const = 0;
|
|
|
|
virtual bool dataLoaded() const = 0;
|
|
|
|
|
|
|
|
struct AnimationData {
|
2016-12-07 13:32:25 +00:00
|
|
|
AnimationData(AnimationCallbacks &&radialCallbacks)
|
2017-02-21 13:45:56 +00:00
|
|
|
: radial(std::move(radialCallbacks)) {
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation a_thumbOver;
|
2016-09-28 10:15:03 +00:00
|
|
|
Ui::RadialAnimation radial;
|
|
|
|
};
|
2017-02-21 13:45:56 +00:00
|
|
|
mutable std::unique_ptr<AnimationData> _animation;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class HistoryPhoto : public HistoryFileMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryPhoto(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
const QString &caption);
|
|
|
|
HistoryPhoto(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<PeerData*> chat,
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
int width);
|
|
|
|
HistoryPhoto(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<PeerData*> chat,
|
|
|
|
const MTPDphoto &photo,
|
|
|
|
int width);
|
2017-12-15 16:25:47 +00:00
|
|
|
HistoryPhoto(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<HistoryItem*> realParent,
|
|
|
|
const HistoryPhoto &other);
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
void init();
|
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypePhoto;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
return std::make_unique<HistoryPhoto>(newParent, realParent, *this);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int width) override;
|
|
|
|
|
2017-12-13 18:10:48 +00:00
|
|
|
void draw(Painter &p, const QRect &clip, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-10-13 19:07:04 +00:00
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _caption.adjustSelection(selection, type);
|
|
|
|
}
|
2017-06-23 19:28:42 +00:00
|
|
|
uint16 fullSelectionLength() const override {
|
|
|
|
return _caption.length();
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
bool hasTextForCopy() const override {
|
|
|
|
return !_caption.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
QString inDialogsText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
2017-05-18 12:37:06 +00:00
|
|
|
|
2017-12-15 19:05:10 +00:00
|
|
|
PhotoData *getPhoto() const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
2017-12-13 18:10:48 +00:00
|
|
|
bool canBeGrouped() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
QSize sizeForGrouping() const override;
|
|
|
|
void drawGrouped(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &clip,
|
|
|
|
TextSelection selection,
|
|
|
|
TimeMs ms,
|
|
|
|
const QRect &geometry,
|
|
|
|
RectParts corners,
|
|
|
|
not_null<uint64*> cacheKey,
|
|
|
|
not_null<QPixmap*> cache) const override;
|
|
|
|
HistoryTextState getStateGrouped(
|
|
|
|
const QRect &geometry,
|
|
|
|
QPoint point,
|
|
|
|
HistoryStateRequest request) const override;
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
void updateSentMedia(const MTPMessageMedia &media) override;
|
|
|
|
bool needReSetInlineResultMedia(const MTPMessageMedia &media) override;
|
|
|
|
|
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
|
|
|
bool hasReplyPreview() const override {
|
|
|
|
return !_data->thumb->isNull();
|
|
|
|
}
|
|
|
|
ImagePtr replyPreview() override;
|
|
|
|
|
|
|
|
TextWithEntities getCaption() const override {
|
|
|
|
return _caption.originalTextWithEntities();
|
|
|
|
}
|
2017-06-22 15:11:41 +00:00
|
|
|
bool needsBubble() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return _caption.isEmpty();
|
|
|
|
}
|
2016-11-18 16:27:47 +00:00
|
|
|
bool skipBubbleTail() const override {
|
2016-11-22 08:36:02 +00:00
|
|
|
return isBubbleBottom() && _caption.isEmpty();
|
2016-11-18 16:27:47 +00:00
|
|
|
}
|
2017-04-02 10:25:54 +00:00
|
|
|
bool canEditCaption() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-29 19:42:14 +00:00
|
|
|
bool isReadyForOpen() const override {
|
|
|
|
return _data->loaded();
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
protected:
|
2017-12-25 14:17:00 +00:00
|
|
|
float64 dataProgress() const override;
|
|
|
|
bool dataFinished() const override;
|
|
|
|
bool dataLoaded() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
private:
|
2018-01-11 13:07:29 +00:00
|
|
|
bool needInfoDisplay() const;
|
2017-12-13 18:10:48 +00:00
|
|
|
void validateGroupedCache(
|
|
|
|
const QRect &geometry,
|
|
|
|
RectParts corners,
|
|
|
|
not_null<uint64*> cacheKey,
|
|
|
|
not_null<QPixmap*> cache) const;
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<PhotoData*> _data;
|
2016-09-28 10:15:03 +00:00
|
|
|
int16 _pixw = 1;
|
|
|
|
int16 _pixh = 1;
|
|
|
|
Text _caption;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class HistoryVideo : public HistoryFileMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryVideo(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
const QString &caption);
|
2017-12-15 16:25:47 +00:00
|
|
|
HistoryVideo(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<HistoryItem*> realParent,
|
|
|
|
const HistoryVideo &other);
|
2017-12-13 18:10:48 +00:00
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeVideo;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
return std::make_unique<HistoryVideo>(newParent, realParent, *this);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int width) override;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-10-13 19:07:04 +00:00
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _caption.adjustSelection(selection, type);
|
|
|
|
}
|
2017-06-23 19:28:42 +00:00
|
|
|
uint16 fullSelectionLength() const override {
|
|
|
|
return _caption.length();
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
bool hasTextForCopy() const override {
|
|
|
|
return !_caption.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
QString inDialogsText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
2017-05-18 12:37:06 +00:00
|
|
|
|
2017-12-15 19:05:10 +00:00
|
|
|
DocumentData *getDocument() const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
2017-12-13 18:10:48 +00:00
|
|
|
bool canBeGrouped() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
QSize sizeForGrouping() const override;
|
|
|
|
void drawGrouped(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &clip,
|
|
|
|
TextSelection selection,
|
|
|
|
TimeMs ms,
|
|
|
|
const QRect &geometry,
|
|
|
|
RectParts corners,
|
|
|
|
not_null<uint64*> cacheKey,
|
|
|
|
not_null<QPixmap*> cache) const override;
|
|
|
|
HistoryTextState getStateGrouped(
|
|
|
|
const QRect &geometry,
|
|
|
|
QPoint point,
|
|
|
|
HistoryStateRequest request) const override;
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
bool uploading() const override {
|
|
|
|
return _data->uploading();
|
|
|
|
}
|
|
|
|
|
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
2017-03-09 09:47:45 +00:00
|
|
|
void updateSentMedia(const MTPMessageMedia &media) override;
|
2016-09-28 10:15:03 +00:00
|
|
|
bool needReSetInlineResultMedia(const MTPMessageMedia &media) override;
|
|
|
|
|
|
|
|
bool hasReplyPreview() const override {
|
|
|
|
return !_data->thumb->isNull();
|
|
|
|
}
|
|
|
|
ImagePtr replyPreview() override;
|
|
|
|
|
|
|
|
TextWithEntities getCaption() const override {
|
|
|
|
return _caption.originalTextWithEntities();
|
|
|
|
}
|
2017-06-22 15:11:41 +00:00
|
|
|
bool needsBubble() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return _caption.isEmpty();
|
|
|
|
}
|
2016-11-18 16:27:47 +00:00
|
|
|
bool skipBubbleTail() const override {
|
2016-11-22 08:36:02 +00:00
|
|
|
return isBubbleBottom() && _caption.isEmpty();
|
2016-11-18 16:27:47 +00:00
|
|
|
}
|
2017-04-02 10:25:54 +00:00
|
|
|
bool canEditCaption() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
protected:
|
2017-12-25 14:17:00 +00:00
|
|
|
float64 dataProgress() const override;
|
|
|
|
bool dataFinished() const override;
|
|
|
|
bool dataLoaded() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
private:
|
2017-12-13 18:10:48 +00:00
|
|
|
void validateGroupedCache(
|
|
|
|
const QRect &geometry,
|
|
|
|
RectParts corners,
|
|
|
|
not_null<uint64*> cacheKey,
|
|
|
|
not_null<QPixmap*> cache) const;
|
|
|
|
void setStatusSize(int32 newSize) const;
|
|
|
|
void updateStatusText() const;
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<DocumentData*> _data;
|
2016-09-28 10:15:03 +00:00
|
|
|
int32 _thumbw;
|
|
|
|
Text _caption;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-09-29 11:37:16 +00:00
|
|
|
class HistoryDocument : public HistoryFileMedia, public RuntimeComposer {
|
2016-09-28 10:15:03 +00:00
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryDocument(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
const QString &caption);
|
|
|
|
HistoryDocument(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
const HistoryDocument &other);
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
HistoryMediaType type() const override {
|
2017-12-10 10:26:58 +00:00
|
|
|
return _data->isVoiceMessage()
|
|
|
|
? MediaTypeVoiceFile
|
|
|
|
: (_data->isSong()
|
|
|
|
? MediaTypeMusicFile
|
|
|
|
: MediaTypeFile);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
Expects(newParent == realParent);
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
return std::make_unique<HistoryDocument>(newParent, *this);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int width) override;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
|
|
|
void updatePressed(QPoint point) override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-10-13 19:07:04 +00:00
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
2017-12-18 15:44:50 +00:00
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override;
|
|
|
|
uint16 fullSelectionLength() const override;
|
|
|
|
bool hasTextForCopy() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
QString inDialogsText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
2017-05-18 12:37:06 +00:00
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
bool uploading() const override {
|
|
|
|
return _data->uploading();
|
|
|
|
}
|
|
|
|
|
2017-12-15 19:05:10 +00:00
|
|
|
DocumentData *getDocument() const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
2017-05-19 18:11:33 +00:00
|
|
|
bool playInline(bool autoplay) override;
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
|
|
|
void updateSentMedia(const MTPMessageMedia &media) override;
|
|
|
|
bool needReSetInlineResultMedia(const MTPMessageMedia &media) override;
|
|
|
|
|
|
|
|
bool hasReplyPreview() const override {
|
|
|
|
return !_data->thumb->isNull();
|
|
|
|
}
|
|
|
|
ImagePtr replyPreview() override;
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
TextWithEntities getCaption() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
bool needsBubble() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-23 13:21:01 +00:00
|
|
|
QMargins bubbleMargins() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
bool hideForwardedFrom() const override {
|
2017-12-10 10:26:58 +00:00
|
|
|
return _data->isSong();
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
2017-04-02 10:25:54 +00:00
|
|
|
bool canEditCaption() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
void step_voiceProgress(float64 ms, bool timer);
|
|
|
|
|
2017-02-10 22:37:37 +00:00
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
|
|
|
|
2018-01-11 13:07:29 +00:00
|
|
|
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
protected:
|
2017-12-25 14:17:00 +00:00
|
|
|
float64 dataProgress() const override;
|
|
|
|
bool dataFinished() const override;
|
|
|
|
bool dataLoaded() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void createComponents(bool caption);
|
2017-01-31 09:13:51 +00:00
|
|
|
void fillNamedFromData(HistoryDocumentNamed *named);
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
void setStatusSize(int32 newSize, qint64 realDuration = 0) const;
|
|
|
|
bool updateStatusText() const; // returns showPause
|
|
|
|
|
|
|
|
// Callback is a void(const QString &, const QString &, const Text &) functor.
|
|
|
|
// It will be called as callback(attachType, attachFileName, attachCaption).
|
|
|
|
template <typename Callback>
|
|
|
|
void buildStringRepresentation(Callback callback) const;
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<DocumentData*> _data;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class HistoryGif : public HistoryFileMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryGif(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
const QString &caption);
|
2017-08-17 08:31:24 +00:00
|
|
|
HistoryGif(not_null<HistoryItem*> parent, const HistoryGif &other);
|
2017-12-13 18:10:48 +00:00
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeGif;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
Expects(newParent == realParent);
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
return std::make_unique<HistoryGif>(newParent, *this);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int width) override;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-10-13 19:07:04 +00:00
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _caption.adjustSelection(selection, type);
|
|
|
|
}
|
2017-06-23 19:28:42 +00:00
|
|
|
uint16 fullSelectionLength() const override {
|
|
|
|
return _caption.length();
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
bool hasTextForCopy() const override {
|
|
|
|
return !_caption.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
QString inDialogsText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
2017-05-18 12:37:06 +00:00
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
bool uploading() const override {
|
|
|
|
return _data->uploading();
|
|
|
|
}
|
|
|
|
|
2017-12-15 19:05:10 +00:00
|
|
|
DocumentData *getDocument() const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
Media::Clip::Reader *getClipReader() override {
|
2016-09-28 20:28:53 +00:00
|
|
|
return _gif.get();
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool playInline(bool autoplay) override;
|
|
|
|
void stopInline() override;
|
2017-05-12 17:44:18 +00:00
|
|
|
bool isRoundVideoPlaying() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
|
|
|
void updateSentMedia(const MTPMessageMedia &media) override;
|
|
|
|
bool needReSetInlineResultMedia(const MTPMessageMedia &media) override;
|
|
|
|
|
|
|
|
bool hasReplyPreview() const override {
|
|
|
|
return !_data->thumb->isNull();
|
|
|
|
}
|
|
|
|
ImagePtr replyPreview() override;
|
|
|
|
|
|
|
|
TextWithEntities getCaption() const override {
|
|
|
|
return _caption.originalTextWithEntities();
|
|
|
|
}
|
2017-06-22 15:11:41 +00:00
|
|
|
bool needsBubble() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return _caption.isEmpty();
|
|
|
|
}
|
2017-04-30 13:04:38 +00:00
|
|
|
QString additionalInfoString() const override;
|
|
|
|
|
2016-11-18 16:27:47 +00:00
|
|
|
bool skipBubbleTail() const override {
|
2016-11-22 08:36:02 +00:00
|
|
|
return isBubbleBottom() && _caption.isEmpty();
|
2016-11-18 16:27:47 +00:00
|
|
|
}
|
2017-04-02 10:25:54 +00:00
|
|
|
bool canEditCaption() const override {
|
2017-12-10 10:26:58 +00:00
|
|
|
return !_data->isVideoMessage();
|
2017-04-02 10:25:54 +00:00
|
|
|
}
|
2016-09-29 19:42:14 +00:00
|
|
|
bool isReadyForOpen() const override {
|
|
|
|
return _data->loaded();
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
~HistoryGif();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float64 dataProgress() const override;
|
|
|
|
bool dataFinished() const override;
|
|
|
|
bool dataLoaded() const override;
|
|
|
|
|
2017-04-02 16:42:18 +00:00
|
|
|
void setClipReader(Media::Clip::ReaderPointer gif);
|
|
|
|
void clearClipReader() {
|
|
|
|
setClipReader(Media::Clip::ReaderPointer());
|
|
|
|
}
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
private:
|
2018-01-11 13:07:29 +00:00
|
|
|
bool needInfoDisplay() const;
|
2017-12-18 15:44:50 +00:00
|
|
|
int additionalWidth(
|
|
|
|
const HistoryMessageVia *via,
|
|
|
|
const HistoryMessageReply *reply,
|
|
|
|
const HistoryMessageForwarded *forwarded) const;
|
|
|
|
int additionalWidth() const;
|
2017-04-15 19:26:28 +00:00
|
|
|
QString mediaTypeString() const;
|
2017-05-26 12:20:11 +00:00
|
|
|
bool isSeparateRoundVideo() const;
|
2017-04-15 19:26:28 +00:00
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<DocumentData*> _data;
|
2017-05-18 13:22:57 +00:00
|
|
|
ClickHandlerPtr _openInMediaviewLink;
|
2016-09-28 20:28:53 +00:00
|
|
|
int32 _thumbw = 1;
|
|
|
|
int32 _thumbh = 1;
|
2016-09-28 10:15:03 +00:00
|
|
|
Text _caption;
|
|
|
|
|
2017-05-18 17:20:07 +00:00
|
|
|
mutable std::unique_ptr<Media::Clip::Playback> _roundPlayback;
|
2016-09-28 20:28:53 +00:00
|
|
|
Media::Clip::ReaderPointer _gif;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
void setStatusSize(int32 newSize) const;
|
|
|
|
void updateStatusText() const;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class HistorySticker : public HistoryMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistorySticker(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<DocumentData*> document);
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeSticker;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
Expects(newParent == realParent);
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
return std::make_unique<HistorySticker>(newParent, _data);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int width) override;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool dragItem() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
2017-12-15 19:05:10 +00:00
|
|
|
DocumentData *getDocument() const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
|
|
|
void updateSentMedia(const MTPMessageMedia &media) override;
|
|
|
|
bool needReSetInlineResultMedia(const MTPMessageMedia &media) override;
|
|
|
|
|
2017-04-24 16:02:17 +00:00
|
|
|
bool hasReplyPreview() const override {
|
|
|
|
return !_data->thumb->isNull();
|
|
|
|
}
|
|
|
|
ImagePtr replyPreview() override;
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
bool needsBubble() const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-28 16:23:25 +00:00
|
|
|
QString emoji() const {
|
|
|
|
return _emoji;
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply) const;
|
2017-12-18 15:44:50 +00:00
|
|
|
int additionalWidth() const;
|
2016-09-28 10:15:03 +00:00
|
|
|
QString toString() const;
|
|
|
|
|
2016-09-28 16:23:25 +00:00
|
|
|
int16 _pixw = 1;
|
|
|
|
int16 _pixh = 1;
|
2016-09-28 10:15:03 +00:00
|
|
|
ClickHandlerPtr _packLink;
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<DocumentData*> _data;
|
2016-09-28 10:15:03 +00:00
|
|
|
QString _emoji;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class HistoryContact : public HistoryMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryContact(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
int32 userId,
|
|
|
|
const QString &first,
|
|
|
|
const QString &last,
|
|
|
|
const QString &phone);
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeContact;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
Expects(newParent == realParent);
|
|
|
|
|
|
|
|
return std::make_unique<HistoryContact>(
|
|
|
|
newParent,
|
|
|
|
_userId,
|
|
|
|
_fname,
|
|
|
|
_lname,
|
|
|
|
_phone);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
|
|
|
void updateSentMedia(const MTPMessageMedia &media) override;
|
|
|
|
|
|
|
|
bool needsBubble() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &fname() const {
|
|
|
|
return _fname;
|
|
|
|
}
|
|
|
|
const QString &lname() const {
|
|
|
|
return _lname;
|
|
|
|
}
|
|
|
|
const QString &phone() const {
|
|
|
|
return _phone;
|
|
|
|
}
|
|
|
|
|
2017-12-05 08:43:18 +00:00
|
|
|
~HistoryContact();
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
private:
|
2017-04-02 10:25:54 +00:00
|
|
|
int32 _userId = 0;
|
2016-12-23 13:21:01 +00:00
|
|
|
UserData *_contact = nullptr;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2016-12-23 13:21:01 +00:00
|
|
|
int _phonew = 0;
|
2016-09-28 10:15:03 +00:00
|
|
|
QString _fname, _lname, _phone;
|
|
|
|
Text _name;
|
2017-12-05 08:43:18 +00:00
|
|
|
std::unique_ptr<Ui::EmptyUserpic> _photoEmpty;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
ClickHandlerPtr _linkl;
|
2016-12-23 13:21:01 +00:00
|
|
|
int _linkw = 0;
|
2016-09-28 10:15:03 +00:00
|
|
|
QString _link;
|
2017-04-02 10:25:54 +00:00
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
};
|
|
|
|
|
2017-04-27 21:17:00 +00:00
|
|
|
class HistoryCall : public HistoryMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryCall(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
const MTPDmessageActionPhoneCall &call);
|
|
|
|
|
2017-04-27 21:17:00 +00:00
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeCall;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
2017-04-27 21:17:00 +00:00
|
|
|
Unexpected("Clone HistoryCall.");
|
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
|
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2017-04-27 21:17:00 +00:00
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
|
|
|
bool needsBubble() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum class FinishReason {
|
|
|
|
Missed,
|
|
|
|
Busy,
|
|
|
|
Disconnected,
|
|
|
|
Hangup,
|
|
|
|
};
|
|
|
|
FinishReason reason() const {
|
|
|
|
return _reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static FinishReason GetReason(const MTPDmessageActionPhoneCall &call);
|
|
|
|
|
|
|
|
FinishReason _reason = FinishReason::Missed;
|
|
|
|
int _duration = 0;
|
|
|
|
|
|
|
|
QString _text;
|
|
|
|
QString _status;
|
|
|
|
|
|
|
|
ClickHandlerPtr _link;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
class HistoryWebPage : public HistoryMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryWebPage(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<WebPageData*> data);
|
|
|
|
HistoryWebPage(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
const HistoryWebPage &other);
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeWebPage;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
Expects(newParent == realParent);
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
return std::make_unique<HistoryWebPage>(newParent, *this);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int width) override;
|
2017-12-18 13:13:41 +00:00
|
|
|
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-10-13 19:07:04 +00:00
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override;
|
2017-06-23 19:28:42 +00:00
|
|
|
uint16 fullSelectionLength() const override {
|
|
|
|
return _title.length() + _description.length();
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
bool hasTextForCopy() const override {
|
|
|
|
return false; // we do not add _title and _description in FullSelection text copy.
|
|
|
|
}
|
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return _attach && _attach->toggleSelectionByHandlerClick(p);
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return _attach && _attach->dragItemByHandler(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
bool isDisplayed() const override;
|
2017-12-15 19:05:10 +00:00
|
|
|
PhotoData *getPhoto() const override {
|
|
|
|
return _attach ? _attach->getPhoto() : nullptr;
|
|
|
|
}
|
|
|
|
DocumentData *getDocument() const override {
|
2017-06-20 19:48:53 +00:00
|
|
|
return _attach ? _attach->getDocument() : nullptr;
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
Media::Clip::Reader *getClipReader() override {
|
2017-06-20 19:48:53 +00:00
|
|
|
return _attach ? _attach->getClipReader() : nullptr;
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
bool playInline(bool autoplay) override {
|
|
|
|
return _attach ? _attach->playInline(autoplay) : false;
|
|
|
|
}
|
|
|
|
void stopInline() override {
|
|
|
|
if (_attach) _attach->stopInline();
|
|
|
|
}
|
|
|
|
|
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
2017-03-21 17:59:35 +00:00
|
|
|
bool hasReplyPreview() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
ImagePtr replyPreview() override;
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<WebPageData*> webpage() {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool needsBubble() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return false;
|
|
|
|
}
|
2017-07-11 17:11:06 +00:00
|
|
|
bool allowsFastShare() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
HistoryMedia *attach() const {
|
|
|
|
return _attach.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
TextSelection toDescriptionSelection(TextSelection selection) const {
|
|
|
|
return internal::unshiftSelection(selection, _title);
|
|
|
|
}
|
|
|
|
TextSelection fromDescriptionSelection(TextSelection selection) const {
|
|
|
|
return internal::shiftSelection(selection, _title);
|
|
|
|
}
|
|
|
|
QMargins inBubblePadding() const;
|
|
|
|
int bottomInfoPadding() const;
|
2017-06-23 10:54:18 +00:00
|
|
|
bool isLogEntryOriginal() const;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<WebPageData*> _data;
|
2016-09-28 10:15:03 +00:00
|
|
|
ClickHandlerPtr _openl;
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<HistoryMedia> _attach;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
bool _asArticle = false;
|
2017-12-31 09:39:21 +00:00
|
|
|
int _dataVersion = -1;
|
|
|
|
int _titleLines = 0;
|
|
|
|
int _descriptionLines = 0;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
Text _title, _description;
|
2017-12-31 09:39:21 +00:00
|
|
|
int _siteNameWidth = 0;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
QString _duration;
|
2017-12-31 09:39:21 +00:00
|
|
|
int _durationWidth = 0;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
int16 _pixw = 0;
|
|
|
|
int16 _pixh = 0;
|
2017-04-02 10:25:54 +00:00
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class HistoryGame : public HistoryMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryGame(not_null<HistoryItem*> parent, not_null<GameData*> data);
|
2017-08-17 08:31:24 +00:00
|
|
|
HistoryGame(not_null<HistoryItem*> parent, const HistoryGame &other);
|
2017-12-13 18:10:48 +00:00
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeGame;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
Expects(newParent == realParent);
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
return std::make_unique<HistoryGame>(newParent, *this);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int width) override;
|
2017-12-18 13:13:41 +00:00
|
|
|
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-10-13 19:07:04 +00:00
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override;
|
2017-06-23 19:28:42 +00:00
|
|
|
uint16 fullSelectionLength() const override {
|
|
|
|
return _title.length() + _description.length();
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
bool isAboveMessage() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool hasTextForCopy() const override {
|
|
|
|
return false; // we do not add _title and _description in FullSelection text copy.
|
|
|
|
}
|
2016-09-28 11:38:35 +00:00
|
|
|
bool consumeMessageText(const TextWithEntities &textWithEntities) override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return _attach && _attach->toggleSelectionByHandlerClick(p);
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return _attach && _attach->dragItemByHandler(p);
|
|
|
|
}
|
|
|
|
|
2016-09-28 11:38:35 +00:00
|
|
|
QString notificationText() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
|
|
|
|
2017-12-15 19:05:10 +00:00
|
|
|
PhotoData *getPhoto() const override {
|
|
|
|
return _attach ? _attach->getPhoto() : nullptr;
|
|
|
|
}
|
|
|
|
DocumentData *getDocument() const override {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _attach ? _attach->getDocument() : nullptr;
|
|
|
|
}
|
|
|
|
Media::Clip::Reader *getClipReader() override {
|
|
|
|
return _attach ? _attach->getClipReader() : nullptr;
|
|
|
|
}
|
|
|
|
bool playInline(bool autoplay) override {
|
|
|
|
return _attach ? _attach->playInline(autoplay) : false;
|
|
|
|
}
|
|
|
|
void stopInline() override {
|
|
|
|
if (_attach) _attach->stopInline();
|
|
|
|
}
|
|
|
|
|
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
|
|
|
bool hasReplyPreview() const override {
|
|
|
|
return (_data->photo && !_data->photo->thumb->isNull()) || (_data->document && !_data->document->thumb->isNull());
|
|
|
|
}
|
|
|
|
ImagePtr replyPreview() override;
|
|
|
|
|
2017-12-13 18:10:48 +00:00
|
|
|
not_null<GameData*> game() {
|
2016-09-28 10:15:03 +00:00
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
|
2016-09-28 16:23:25 +00:00
|
|
|
void updateSentMedia(const MTPMessageMedia &media) override;
|
|
|
|
bool needReSetInlineResultMedia(const MTPMessageMedia &media) override;
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
bool needsBubble() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return false;
|
|
|
|
}
|
2017-07-11 17:11:06 +00:00
|
|
|
bool allowsFastShare() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
HistoryMedia *attach() const {
|
|
|
|
return _attach.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
TextSelection toDescriptionSelection(TextSelection selection) const {
|
|
|
|
return internal::unshiftSelection(selection, _title);
|
|
|
|
}
|
|
|
|
TextSelection fromDescriptionSelection(TextSelection selection) const {
|
|
|
|
return internal::shiftSelection(selection, _title);
|
|
|
|
}
|
|
|
|
QMargins inBubblePadding() const;
|
|
|
|
int bottomInfoPadding() const;
|
|
|
|
|
2017-12-13 18:10:48 +00:00
|
|
|
not_null<GameData*> _data;
|
2017-12-18 13:13:41 +00:00
|
|
|
std::shared_ptr<ReplyMarkupClickHandler> _openl;
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<HistoryMedia> _attach;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
int32 _titleLines, _descriptionLines;
|
|
|
|
|
|
|
|
Text _title, _description;
|
|
|
|
|
2016-09-28 11:38:35 +00:00
|
|
|
int _gameTagWidth = 0;
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
};
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
class HistoryInvoice : public HistoryMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryInvoice(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
const MTPDmessageMediaInvoice &data);
|
|
|
|
HistoryInvoice(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
const HistoryInvoice &other);
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
HistoryMediaType type() const override {
|
2017-03-05 15:41:58 +00:00
|
|
|
return MediaTypeInvoice;
|
2017-03-05 13:39:10 +00:00
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
Expects(newParent == realParent);
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
return std::make_unique<HistoryInvoice>(newParent, *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int width) override;
|
2017-12-18 13:13:41 +00:00
|
|
|
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
2017-03-05 13:39:10 +00:00
|
|
|
|
2017-03-06 15:00:59 +00:00
|
|
|
MsgId getReceiptMsgId() const {
|
|
|
|
return _receiptMsgId;
|
|
|
|
}
|
2017-03-05 15:41:58 +00:00
|
|
|
QString getTitle() const {
|
|
|
|
return _title.originalText();
|
|
|
|
}
|
2017-11-05 17:40:16 +00:00
|
|
|
static QString fillAmountAndCurrency(uint64 amount, const QString ¤cy);
|
2017-03-05 15:41:58 +00:00
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2017-03-05 13:39:10 +00:00
|
|
|
|
2017-10-13 19:07:04 +00:00
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override;
|
2017-06-23 19:28:42 +00:00
|
|
|
uint16 fullSelectionLength() const override {
|
|
|
|
return _title.length() + _description.length();
|
|
|
|
}
|
2017-03-05 13:39:10 +00:00
|
|
|
bool hasTextForCopy() const override {
|
|
|
|
return false; // we do not add _title and _description in FullSelection text copy.
|
|
|
|
}
|
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return _attach && _attach->toggleSelectionByHandlerClick(p);
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return _attach && _attach->dragItemByHandler(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
|
|
|
|
|
|
|
void attachToParent() override;
|
|
|
|
void detachFromParent() override;
|
|
|
|
|
|
|
|
bool hasReplyPreview() const override {
|
|
|
|
return _attach && _attach->hasReplyPreview();
|
|
|
|
}
|
|
|
|
ImagePtr replyPreview() override {
|
|
|
|
return _attach ? _attach->replyPreview() : ImagePtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool needsBubble() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
HistoryMedia *attach() const {
|
|
|
|
return _attach.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void fillFromData(const MTPDmessageMediaInvoice &data);
|
|
|
|
|
|
|
|
TextSelection toDescriptionSelection(TextSelection selection) const {
|
|
|
|
return internal::unshiftSelection(selection, _title);
|
|
|
|
}
|
|
|
|
TextSelection fromDescriptionSelection(TextSelection selection) const {
|
|
|
|
return internal::shiftSelection(selection, _title);
|
|
|
|
}
|
|
|
|
QMargins inBubblePadding() const;
|
|
|
|
int bottomInfoPadding() const;
|
|
|
|
|
|
|
|
std::unique_ptr<HistoryMedia> _attach;
|
|
|
|
|
2017-03-06 15:00:59 +00:00
|
|
|
int _titleHeight = 0;
|
|
|
|
int _descriptionHeight = 0;
|
2017-03-05 13:39:10 +00:00
|
|
|
Text _title;
|
|
|
|
Text _description;
|
|
|
|
Text _status;
|
|
|
|
|
2017-03-06 15:00:59 +00:00
|
|
|
MsgId _receiptMsgId = 0;
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
};
|
|
|
|
|
2017-02-03 10:17:40 +00:00
|
|
|
class LocationCoords;
|
2016-09-28 10:15:03 +00:00
|
|
|
struct LocationData;
|
|
|
|
|
|
|
|
class HistoryLocation : public HistoryMedia {
|
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryLocation(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
const LocationCoords &coords,
|
|
|
|
const QString &title = QString(),
|
|
|
|
const QString &description = QString());
|
|
|
|
HistoryLocation(
|
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
const HistoryLocation &other);
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
HistoryMediaType type() const override {
|
|
|
|
return MediaTypeLocation;
|
|
|
|
}
|
2017-12-13 18:10:48 +00:00
|
|
|
std::unique_ptr<HistoryMedia> clone(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<HistoryItem*> newParent,
|
|
|
|
not_null<HistoryItem*> realParent) const override {
|
|
|
|
Expects(newParent == realParent);
|
|
|
|
|
2017-03-05 13:39:10 +00:00
|
|
|
return std::make_unique<HistoryLocation>(newParent, *this);
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int resizeGetHeight(int32 width) override;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
2017-06-21 21:38:31 +00:00
|
|
|
HistoryTextState getState(QPoint point, HistoryStateRequest request) const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2017-10-13 19:07:04 +00:00
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override;
|
2017-06-23 19:28:42 +00:00
|
|
|
uint16 fullSelectionLength() const override {
|
|
|
|
return _title.length() + _description.length();
|
|
|
|
}
|
2016-09-28 10:15:03 +00:00
|
|
|
bool hasTextForCopy() const override {
|
|
|
|
return !_title.isEmpty() || !_description.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return p == _link;
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return p == _link;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString notificationText() const override;
|
|
|
|
QString inDialogsText() const override;
|
|
|
|
TextWithEntities selectedText(TextSelection selection) const override;
|
|
|
|
|
2017-06-22 15:11:41 +00:00
|
|
|
bool needsBubble() const override;
|
2016-09-28 10:15:03 +00:00
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-18 16:27:47 +00:00
|
|
|
bool skipBubbleTail() const override {
|
|
|
|
return isBubbleBottom();
|
|
|
|
}
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
private:
|
|
|
|
TextSelection toDescriptionSelection(TextSelection selection) const {
|
|
|
|
return internal::unshiftSelection(selection, _title);
|
|
|
|
}
|
|
|
|
TextSelection fromDescriptionSelection(TextSelection selection) const {
|
|
|
|
return internal::shiftSelection(selection, _title);
|
|
|
|
}
|
|
|
|
|
|
|
|
LocationData *_data;
|
|
|
|
Text _title, _description;
|
|
|
|
ClickHandlerPtr _link;
|
|
|
|
|
|
|
|
int32 fullWidth() const;
|
|
|
|
int32 fullHeight() const;
|
|
|
|
|
|
|
|
};
|