From e8a929bdbd079d867f151ce3f9cdc1d3c809f598 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 3 Jun 2024 15:03:41 +0400 Subject: [PATCH] Fix bottom info display in media. --- .../history/history_inner_widget.cpp | 6 +++- .../view/history_view_replies_section.cpp | 7 +++-- .../history/view/media/history_view_gif.cpp | 31 ++++++++++--------- .../view/media/history_view_media_grouped.cpp | 4 +-- .../history/view/media/history_view_photo.cpp | 4 +-- 5 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 48db2a0770..f450af658c 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2451,7 +2451,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto quoteOffset = selected.offset; text.replace('&', u"&&"_q); _menu->addAction(text, [=] { - if (canSendReply && !base::IsCtrlPressed()) { + const auto still = session->data().message(itemId); + const auto forceAnotherChat = base::IsCtrlPressed() + && still + && still->allowsForward(); + if (canSendReply && !forceAnotherChat) { _widget->replyToMessage({ .messageId = itemId, .quote = quote, diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 27ff0e4ff6..cf2ef8d816 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -331,9 +331,12 @@ RepliesWidget::RepliesWidget( ? Data::CanSendAnything(_topic) : Data::CanSendAnything(_history->peer); const auto &to = request.to; - if (_joinGroup || !canSendReply || request.forceAnotherChat) { + const auto still = _history->owner().message(to.messageId); + const auto allowInAnotherChat = still && still->allowsForward(); + if (allowInAnotherChat + && (_joinGroup || !canSendReply || request.forceAnotherChat)) { Controls::ShowReplyToChatBox(controller->uiShow(), { to }); - } else { + } else if (!_joinGroup && canSendReply) { replyToMessage(to); _composeControls->focus(); } diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index a04ea9256f..62dde278df 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -762,7 +762,8 @@ void Gif::draw(Painter &p, const PaintContext &context) const { fullRight = maxRight; } } - if (isRound || needInfoDisplay()) { + if (isRound + || ((!bubble || isBubbleBottom()) && needInfoDisplay())) { _parent->drawInfo( p, context, @@ -1117,7 +1118,9 @@ TextState Gif::textState(QPoint point, StateRequest request) const { ? _cancell : _savel; } - if (unwrapped || !bubble) { + const auto checkBottomInfo = !inWebPage + && (unwrapped || !bubble || isBubbleBottom()); + if (checkBottomInfo) { auto fullRight = usex + paintx + usew; auto fullBottom = painty + painth; auto maxRight = _parent->width() - st::msgMargin.left(); @@ -1136,19 +1139,17 @@ TextState Gif::textState(QPoint point, StateRequest request) const { fullRight = maxRight; } } - if (!inWebPage) { - const auto bottomInfoResult = _parent->bottomInfoTextState( - fullRight, - fullBottom, - point, - (unwrapped - ? InfoDisplayType::Background - : InfoDisplayType::Image)); - if (bottomInfoResult.link - || bottomInfoResult.cursor != CursorState::None - || bottomInfoResult.customTooltip) { - return bottomInfoResult; - } + const auto bottomInfoResult = _parent->bottomInfoTextState( + fullRight, + fullBottom, + point, + (unwrapped + ? InfoDisplayType::Background + : InfoDisplayType::Image)); + if (bottomInfoResult.link + || bottomInfoResult.cursor != CursorState::None + || bottomInfoResult.customTooltip) { + return bottomInfoResult; } if (const auto size = bubble ? std::nullopt : _parent->rightActionSize()) { const auto rightActionWidth = size->width(); diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp index 8d6583405c..6a67bf426d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp @@ -396,7 +396,7 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const { } // date - if (_parent->media() == this && isBubbleBottom()) { + if (_parent->media() == this && (!_parent->hasBubble() || isBubbleBottom())) { auto fullRight = width(); auto fullBottom = height(); if (needInfoDisplay()) { @@ -455,7 +455,7 @@ PointState GroupedMedia::pointState(QPoint point) const { TextState GroupedMedia::textState(QPoint point, StateRequest request) const { const auto groupPadding = groupedPadding(); auto result = getPartState(point - QPoint(0, groupPadding.top()), request); - if (_parent->media() == this) { + if (_parent->media() == this && (!_parent->hasBubble() || isBubbleBottom())) { auto fullRight = width(); auto fullBottom = height(); const auto bottomInfoResult = _parent->bottomInfoTextState( diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index 9c5ccd302d..db309ee621 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -364,7 +364,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const { } // date - if (isBubbleBottom() && !inWebPage) { + if (!inWebPage && (!bubble || isBubbleBottom())) { auto fullRight = paintx + paintw; auto fullBottom = painty + painth; if (needInfoDisplay()) { @@ -621,7 +621,7 @@ TextState Photo::textState(QPoint point, StateRequest request) const { result.cursor = CursorState::Enlarge; } } - if (isBubbleBottom() && _parent->media() == this) { + if (_parent->media() == this && (!_parent->hasBubble() || isBubbleBottom())) { auto fullRight = paintx + paintw; auto fullBottom = painty + painth; const auto bottomInfoResult = _parent->bottomInfoTextState(