mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Fix reply previews display.
This commit is contained in:
parent
b007fcb537
commit
d4253d2025
@ -294,6 +294,14 @@ bool MediaPhoto::canBeGrouped() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MediaPhoto::hasReplyPreview() const {
|
||||
return !_photo->thumb->isNull();
|
||||
}
|
||||
|
||||
ImagePtr MediaPhoto::replyPreview() const {
|
||||
return _photo->makeReplyPreview();
|
||||
}
|
||||
|
||||
QString MediaPhoto::notificationText() const {
|
||||
return WithCaptionNotificationText(
|
||||
lang(lng_in_dlg_photo),
|
||||
@ -487,6 +495,14 @@ bool MediaFile::canBeGrouped() const {
|
||||
return _document->isVideoFile();
|
||||
}
|
||||
|
||||
bool MediaFile::hasReplyPreview() const {
|
||||
return !_document->thumb->isNull();
|
||||
}
|
||||
|
||||
ImagePtr MediaFile::replyPreview() const {
|
||||
return _document->makeReplyPreview();
|
||||
}
|
||||
|
||||
QString MediaFile::chatsListText() const {
|
||||
if (const auto sticker = _document->sticker()) {
|
||||
return Media::chatsListText();
|
||||
@ -929,6 +945,24 @@ WebPageData *MediaWebPage::webpage() const {
|
||||
return _page;
|
||||
}
|
||||
|
||||
bool MediaWebPage::hasReplyPreview() const {
|
||||
if (const auto document = _page->document) {
|
||||
return !document->thumb->isNull();
|
||||
} else if (const auto photo = _page->photo) {
|
||||
return !photo->thumb->isNull();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ImagePtr MediaWebPage::replyPreview() const {
|
||||
if (const auto document = _page->document) {
|
||||
return document->makeReplyPreview();
|
||||
} else if (const auto photo = _page->photo) {
|
||||
return photo->makeReplyPreview();
|
||||
}
|
||||
return ImagePtr();
|
||||
}
|
||||
|
||||
QString MediaWebPage::chatsListText() const {
|
||||
return notificationText();
|
||||
}
|
||||
@ -974,6 +1008,24 @@ std::unique_ptr<Media> MediaGame::clone(not_null<HistoryItem*> parent) {
|
||||
return std::make_unique<MediaGame>(parent, _game);
|
||||
}
|
||||
|
||||
bool MediaGame::hasReplyPreview() const {
|
||||
if (const auto document = _game->document) {
|
||||
return !document->thumb->isNull();
|
||||
} else if (const auto photo = _game->photo) {
|
||||
return !photo->thumb->isNull();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ImagePtr MediaGame::replyPreview() const {
|
||||
if (const auto document = _game->document) {
|
||||
return document->makeReplyPreview();
|
||||
} else if (const auto photo = _game->photo) {
|
||||
return photo->makeReplyPreview();
|
||||
}
|
||||
return ImagePtr();
|
||||
}
|
||||
|
||||
QString MediaGame::notificationText() const {
|
||||
// Add a game controller emoji before game title.
|
||||
auto result = QString();
|
||||
@ -1054,6 +1106,20 @@ const Invoice *MediaInvoice::invoice() const {
|
||||
return &_invoice;
|
||||
}
|
||||
|
||||
bool MediaInvoice::hasReplyPreview() const {
|
||||
if (const auto photo = _invoice.photo) {
|
||||
return !photo->thumb->isNull();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ImagePtr MediaInvoice::replyPreview() const {
|
||||
if (const auto photo = _invoice.photo) {
|
||||
return photo->makeReplyPreview();
|
||||
}
|
||||
return ImagePtr();
|
||||
}
|
||||
|
||||
QString MediaInvoice::notificationText() const {
|
||||
return _invoice.title;
|
||||
}
|
||||
|
@ -134,6 +134,8 @@ public:
|
||||
bool uploading() const override;
|
||||
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
||||
bool canBeGrouped() const override;
|
||||
bool hasReplyPreview() const override;
|
||||
ImagePtr replyPreview() const override;
|
||||
QString chatsListText() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
@ -168,6 +170,8 @@ public:
|
||||
bool uploading() const override;
|
||||
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
||||
bool canBeGrouped() const override;
|
||||
bool hasReplyPreview() const override;
|
||||
ImagePtr replyPreview() const override;
|
||||
QString chatsListText() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
@ -289,6 +293,9 @@ public:
|
||||
std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) override;
|
||||
|
||||
WebPageData *webpage() const override;
|
||||
|
||||
bool hasReplyPreview() const override;
|
||||
ImagePtr replyPreview() const override;
|
||||
QString chatsListText() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
@ -316,6 +323,8 @@ public:
|
||||
|
||||
GameData *game() const override;
|
||||
|
||||
bool hasReplyPreview() const override;
|
||||
ImagePtr replyPreview() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
@ -349,6 +358,8 @@ public:
|
||||
|
||||
const Invoice *invoice() const override;
|
||||
|
||||
bool hasReplyPreview() const override;
|
||||
ImagePtr replyPreview() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
|
@ -168,12 +168,6 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasReplyPreview() const {
|
||||
return false;
|
||||
}
|
||||
virtual ImagePtr replyPreview() {
|
||||
return ImagePtr();
|
||||
}
|
||||
virtual TextWithEntities getCaption() const {
|
||||
return TextWithEntities();
|
||||
}
|
||||
|
@ -350,14 +350,6 @@ not_null<HistoryMedia*> HistoryGroupedMedia::main() const {
|
||||
return _parts.back().content.get();
|
||||
}
|
||||
|
||||
bool HistoryGroupedMedia::hasReplyPreview() const {
|
||||
return main()->hasReplyPreview();
|
||||
}
|
||||
|
||||
ImagePtr HistoryGroupedMedia::replyPreview() {
|
||||
return main()->replyPreview();
|
||||
}
|
||||
|
||||
TextWithEntities HistoryGroupedMedia::getCaption() const {
|
||||
return main()->getCaption();
|
||||
}
|
||||
|
@ -59,8 +59,6 @@ public:
|
||||
const ClickHandlerPtr &p,
|
||||
bool pressed) override;
|
||||
|
||||
bool hasReplyPreview() const override;
|
||||
ImagePtr replyPreview() override;
|
||||
TextWithEntities getCaption() const override;
|
||||
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
||||
|
||||
|
@ -681,10 +681,6 @@ bool HistoryPhoto::needsBubble() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
ImagePtr HistoryPhoto::replyPreview() {
|
||||
return _data->makeReplyPreview();
|
||||
}
|
||||
|
||||
HistoryVideo::HistoryVideo(
|
||||
not_null<Element*> parent,
|
||||
not_null<HistoryItem*> realParent,
|
||||
@ -1136,21 +1132,6 @@ void HistoryVideo::updateStatusText() const {
|
||||
}
|
||||
}
|
||||
|
||||
ImagePtr HistoryVideo::replyPreview() {
|
||||
if (_data->replyPreview->isNull() && !_data->thumb->isNull()) {
|
||||
if (_data->thumb->loaded()) {
|
||||
auto w = convertScale(_data->thumb->width());
|
||||
auto h = convertScale(_data->thumb->height());
|
||||
if (w <= 0) w = 1;
|
||||
if (h <= 0) h = 1;
|
||||
_data->replyPreview = ImagePtr(w > h ? _data->thumb->pix(w * st::msgReplyBarSize.height() / h, st::msgReplyBarSize.height()) : _data->thumb->pix(st::msgReplyBarSize.height()), "PNG");
|
||||
} else {
|
||||
_data->thumb->load();
|
||||
}
|
||||
}
|
||||
return _data->replyPreview;
|
||||
}
|
||||
|
||||
HistoryDocument::HistoryDocument(
|
||||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> document)
|
||||
@ -1856,10 +1837,6 @@ TextWithEntities HistoryDocument::getCaption() const {
|
||||
return TextWithEntities();
|
||||
}
|
||||
|
||||
ImagePtr HistoryDocument::replyPreview() {
|
||||
return _data->makeReplyPreview();
|
||||
}
|
||||
|
||||
HistoryGif::HistoryGif(
|
||||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> document)
|
||||
@ -2564,10 +2541,6 @@ QString HistoryGif::additionalInfoString() const {
|
||||
return QString();
|
||||
}
|
||||
|
||||
ImagePtr HistoryGif::replyPreview() {
|
||||
return _data->makeReplyPreview();
|
||||
}
|
||||
|
||||
int HistoryGif::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply, const HistoryMessageForwarded *forwarded) const {
|
||||
int result = 0;
|
||||
if (forwarded) {
|
||||
@ -2930,10 +2903,6 @@ TextState HistorySticker::textState(QPoint point, StateRequest request) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
ImagePtr HistorySticker::replyPreview() {
|
||||
return _data->makeReplyPreview();
|
||||
}
|
||||
|
||||
int HistorySticker::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply) const {
|
||||
int result = 0;
|
||||
if (via) {
|
||||
@ -3784,14 +3753,6 @@ TextWithEntities HistoryWebPage::selectedText(TextSelection selection) const {
|
||||
return titleResult;
|
||||
}
|
||||
|
||||
bool HistoryWebPage::hasReplyPreview() const {
|
||||
return _attach ? _attach->hasReplyPreview() : (_data->photo ? true : false);
|
||||
}
|
||||
|
||||
ImagePtr HistoryWebPage::replyPreview() {
|
||||
return _attach ? _attach->replyPreview() : (_data->photo ? _data->photo->makeReplyPreview() : ImagePtr());
|
||||
}
|
||||
|
||||
QMargins HistoryWebPage::inBubblePadding() const {
|
||||
auto lshift = st::msgPadding.left() + st::webPageLeft;
|
||||
auto rshift = st::msgPadding.right();
|
||||
@ -4181,10 +4142,6 @@ TextWithEntities HistoryGame::selectedText(TextSelection selection) const {
|
||||
return titleResult;
|
||||
}
|
||||
|
||||
ImagePtr HistoryGame::replyPreview() {
|
||||
return _attach ? _attach->replyPreview() : (_data->photo ? _data->photo->makeReplyPreview() : ImagePtr());
|
||||
}
|
||||
|
||||
void HistoryGame::playAnimation(bool autoplay) {
|
||||
if (_attach) {
|
||||
if (autoplay) {
|
||||
|
@ -176,11 +176,6 @@ public:
|
||||
QPoint point,
|
||||
StateRequest request) const override;
|
||||
|
||||
bool hasReplyPreview() const override {
|
||||
return !_data->thumb->isNull();
|
||||
}
|
||||
ImagePtr replyPreview() override;
|
||||
|
||||
TextWithEntities getCaption() const override {
|
||||
return _caption.originalTextWithEntities();
|
||||
}
|
||||
@ -272,11 +267,6 @@ public:
|
||||
return _data->uploading();
|
||||
}
|
||||
|
||||
bool hasReplyPreview() const override {
|
||||
return !_data->thumb->isNull();
|
||||
}
|
||||
ImagePtr replyPreview() override;
|
||||
|
||||
TextWithEntities getCaption() const override {
|
||||
return _caption.originalTextWithEntities();
|
||||
}
|
||||
@ -347,11 +337,6 @@ public:
|
||||
return _data;
|
||||
}
|
||||
|
||||
bool hasReplyPreview() const override {
|
||||
return !_data->thumb->isNull();
|
||||
}
|
||||
ImagePtr replyPreview() override;
|
||||
|
||||
TextWithEntities getCaption() const override;
|
||||
bool needsBubble() const override {
|
||||
return true;
|
||||
@ -426,11 +411,6 @@ public:
|
||||
|
||||
void stopAnimation() override;
|
||||
|
||||
bool hasReplyPreview() const override {
|
||||
return !_data->thumb->isNull();
|
||||
}
|
||||
ImagePtr replyPreview() override;
|
||||
|
||||
TextWithEntities getCaption() const override {
|
||||
return _caption.originalTextWithEntities();
|
||||
}
|
||||
@ -517,11 +497,6 @@ public:
|
||||
return _data;
|
||||
}
|
||||
|
||||
bool hasReplyPreview() const override {
|
||||
return !_data->thumb->isNull();
|
||||
}
|
||||
ImagePtr replyPreview() override;
|
||||
|
||||
bool needsBubble() const override {
|
||||
return false;
|
||||
}
|
||||
@ -704,9 +679,6 @@ public:
|
||||
if (_attach) _attach->stopAnimation();
|
||||
}
|
||||
|
||||
bool hasReplyPreview() const override;
|
||||
ImagePtr replyPreview() override;
|
||||
|
||||
not_null<WebPageData*> webpage() {
|
||||
return _data;
|
||||
}
|
||||
@ -806,11 +778,6 @@ public:
|
||||
if (_attach) _attach->stopAnimation();
|
||||
}
|
||||
|
||||
bool hasReplyPreview() const override {
|
||||
return (_data->photo && !_data->photo->thumb->isNull()) || (_data->document && !_data->document->thumb->isNull());
|
||||
}
|
||||
ImagePtr replyPreview() override;
|
||||
|
||||
not_null<GameData*> game() {
|
||||
return _data;
|
||||
}
|
||||
@ -902,13 +869,6 @@ public:
|
||||
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
||||
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
||||
|
||||
bool hasReplyPreview() const override {
|
||||
return _attach && _attach->hasReplyPreview();
|
||||
}
|
||||
ImagePtr replyPreview() override {
|
||||
return _attach ? _attach->replyPreview() : ImagePtr();
|
||||
}
|
||||
|
||||
bool needsBubble() const override {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user