From 520a6441502ff81aca7015659553105788ae03c0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 16 Dec 2017 11:20:04 +0400 Subject: [PATCH] Fix drag by date of grouped media. --- .../history/history_inner_widget.cpp | 2 +- .../history/history_media_grouped.cpp | 17 +++++++++++------ .../SourceFiles/history/history_media_grouped.h | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 4d8e5c1693..e12174059e 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1024,7 +1024,7 @@ void HistoryInner::performDrag() { forwardMimeType = qsl("application/x-td-forward-pressed"); } } - if (const auto pressedLnkItem = _dragStateItem) { + if (const auto pressedLnkItem = _mouseActionItem) { if ((pressedMedia = pressedLnkItem->getMedia())) { if (forwardMimeType.isEmpty() && pressedMedia->dragItemByHandler(pressedHandler)) { forwardMimeType = qsl("application/x-td-forward-pressed-link"); diff --git a/Telegram/SourceFiles/history/history_media_grouped.cpp b/Telegram/SourceFiles/history/history_media_grouped.cpp index e48b253134..3c4f5bf644 100644 --- a/Telegram/SourceFiles/history/history_media_grouped.cpp +++ b/Telegram/SourceFiles/history/history_media_grouped.cpp @@ -205,7 +205,7 @@ void HistoryGroupedMedia::draw( } } -HistoryTextState HistoryGroupedMedia::getState( +HistoryTextState HistoryGroupedMedia::getElementState( QPoint point, HistoryStateRequest request) const { for (const auto &element : _elements) { @@ -218,7 +218,14 @@ HistoryTextState HistoryGroupedMedia::getState( return result; } } - if (!_caption.isEmpty()) { + return HistoryTextState(_parent); +} + +HistoryTextState HistoryGroupedMedia::getState( + QPoint point, + HistoryStateRequest request) const { + auto result = getElementState(point, request); + if (!result.link && !_caption.isEmpty()) { const auto captionw = _width - st::msgPadding.left() - st::msgPadding.right(); const auto captiony = _height - (isBubbleBottom() ? st::msgPadding.bottom() : 0) @@ -229,9 +236,7 @@ HistoryTextState HistoryGroupedMedia::getState( captionw, request.forText())); } - } - auto result = HistoryTextState(_parent); - if (_caption.isEmpty() && _parent->getMedia() == this) { + } else if (_parent->getMedia() == this) { auto fullRight = _width; auto fullBottom = _height; if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayOverImage)) { @@ -245,7 +250,7 @@ HistoryTextState HistoryGroupedMedia::getState( } } } - return HistoryTextState(); + return result; } bool HistoryGroupedMedia::toggleSelectionByHandlerClick( diff --git a/Telegram/SourceFiles/history/history_media_grouped.h b/Telegram/SourceFiles/history/history_media_grouped.h index ed5cf1a090..1de3f76b79 100644 --- a/Telegram/SourceFiles/history/history_media_grouped.h +++ b/Telegram/SourceFiles/history/history_media_grouped.h @@ -128,6 +128,9 @@ private: not_null main() const; bool validateGroupElements( const std::vector> &others) const; + HistoryTextState getElementState( + QPoint point, + HistoryStateRequest request) const; Text _caption; std::vector _elements;