diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index 1354506f5a..2bf06ae912 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -1751,3 +1751,4 @@ topPeersSelectorUserpicSize: 30px; topPeersSelectorUserpicGap: 8px; topPeersSelectorPadding: 6px; topPeersSelectorUserpicExpand: 0.1; +topPeersSelectorSkip: point(11px, -5px); diff --git a/Telegram/SourceFiles/core/click_handler_types.h b/Telegram/SourceFiles/core/click_handler_types.h index 520b1282a1..a1cd3bd35b 100644 --- a/Telegram/SourceFiles/core/click_handler_types.h +++ b/Telegram/SourceFiles/core/click_handler_types.h @@ -18,6 +18,7 @@ constexpr auto kReactionsCountEmojiProperty = 0x05; constexpr auto kDocumentFilenameTooltipProperty = 0x06; constexpr auto kPhoneNumberLinkProperty = 0x07; constexpr auto kTodoListItemIdProperty = 0x08; +constexpr auto kFastShareProperty = 0x09; namespace Ui { class Show; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 333b8d106e..41946075c8 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_reaction_preview.h" #include "history/view/history_view_quick_action.h" #include "history/view/history_view_emoji_interactions.h" +#include "history/view/history_view_top_peers_selector.h" #include "history/history_item_components.h" #include "history/history_item_text.h" #include "payments/payments_reaction_process.h" @@ -2307,6 +2308,24 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { e, session().data().reactions().favoriteId())) { return; + } else if (link && link->property(kFastShareProperty).value()) { + if (const auto item = _dragStateItem) { + const auto view = viewByItem(item); + const auto rightSize = view->rightActionSize().value_or(QSize()); + const auto top = itemTop(view) + + view->height() + - _visibleAreaTop + - rightSize.height(); + const auto right = rect::right(view->innerGeometry()) + - st::historyFastShareLeft + - rightSize.width(); + HistoryView::ShowTopPeersSelector( + this, + _controller->uiShow(), + item->fullId(), + parentWidget()->mapToGlobal(QPoint(right, top))); + return; + } } auto selectedState = getSelectionState(); diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 5127738984..2e396ce649 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_service_message.h" #include "history/view/history_view_cursor_state.h" #include "history/view/history_view_translate_tracker.h" +#include "history/view/history_view_top_peers_selector.h" #include "history/view/history_view_quick_action.h" #include "chat_helpers/message_field.h" #include "mainwindow.h" @@ -55,6 +56,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/chat/chat_theme.h" #include "ui/chat/chat_style.h" #include "ui/painter.h" +#include "ui/rect.h" #include "ui/ui_utility.h" #include "lang/lang_keys.h" #include "boxes/delete_messages_box.h" @@ -2849,6 +2851,26 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { : _overElement ? _overElement->data().get() : nullptr; + if (link + && link->property(kFastShareProperty).value() + && overItem) { + if (const auto view = viewForItem(overItem)) { + const auto rightSize = view->rightActionSize().value_or(QSize()); + const auto top = itemTop(view) + + view->height() + - _visibleTop + - rightSize.height(); + const auto right = rect::right(view->innerGeometry()) + - st::historyFastShareLeft + - rightSize.width(); + ShowTopPeersSelector( + this, + controller()->uiShow(), + overItem->fullId(), + parentWidget()->mapToGlobal(QPoint(right, top))); + return; + } + } const auto clickedReaction = Reactions::ReactionIdOfLink(link); const auto linkPhoneNumber = link ? link->property(kPhoneNumberLinkProperty).toString() diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 712f3f0fb9..a5263e3092 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -4017,7 +4017,7 @@ ClickHandlerPtr Message::prepareRightActionLink() const { } }; }; - return std::make_shared([=]( + const auto result = std::make_shared([=]( ClickContext context) { const auto controller = ExtractController(context); if (!controller || controller->session().uniqueId() != sessionId) { @@ -4039,6 +4039,8 @@ ClickHandlerPtr Message::prepareRightActionLink() const { } } }); + result->setProperty(kFastShareProperty, QVariant::fromValue(true)); + return result; } ClickHandlerPtr Message::fastReplyLink() const { diff --git a/Telegram/SourceFiles/history/view/history_view_top_peers_selector.cpp b/Telegram/SourceFiles/history/view/history_view_top_peers_selector.cpp index a599aa3af0..5c14913a0b 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_peers_selector.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_peers_selector.cpp @@ -49,7 +49,8 @@ constexpr auto kMaxPeers = 5; void ShowTopPeersSelector( not_null parent, std::shared_ptr show, - FullMsgId fullId) { + FullMsgId fullId, + QPoint globalPos) { const auto session = &show->session(); const auto peers = CollectPeers(session); auto thumbnails = std::vector>(); @@ -108,7 +109,9 @@ void ShowTopPeersSelector( }); userpicsWidget->setCursor(style::cur_pointer); selector->updateShowState(0, 0, true); - selector->popup(QCursor::pos()); + selector->popup((!globalPos.isNull() ? globalPos : QCursor::pos()) + - QPoint(selector->width() / 2, selector->height()) + + st::topPeersSelectorSkip); auto animation = selector->lifetime().make_state(); diff --git a/Telegram/SourceFiles/history/view/history_view_top_peers_selector.h b/Telegram/SourceFiles/history/view/history_view_top_peers_selector.h index f1bd9588a5..6de3b03f8e 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_peers_selector.h +++ b/Telegram/SourceFiles/history/view/history_view_top_peers_selector.h @@ -19,6 +19,7 @@ namespace HistoryView { void ShowTopPeersSelector( not_null parent, std::shared_ptr show, - FullMsgId fullId); + FullMsgId fullId, + QPoint globalPos); } // namespace HistoryView