diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index de3fbb7f5..3150be5d7 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2275,6 +2275,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto canReport = item && item->suggestReport(); const auto canBlockSender = item && item->history()->peer->isRepliesChat(); const auto view = item ? item->mainView() : nullptr; + const auto actionText = link + ? link->copyToClipboardContextItemText() + : QString(); if (isUponSelected > 0) { if (!hasCopyRestrictionForSelected()) { @@ -2335,7 +2338,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } if (!item->isService() && view - && !link + && actionText.isEmpty() && !hasCopyRestriction(item) && (view->hasVisibleText() || mediaHasTextForCopy)) { _menu->addAction(tr::lng_context_copy_text(tr::now), [=] { @@ -2344,10 +2347,6 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } } - - const auto actionText = link - ? link->copyToClipboardContextItemText() - : QString(); if (!actionText.isEmpty()) { _menu->addAction( actionText, diff --git a/Telegram/SourceFiles/history/view/media/history_view_large_emoji.h b/Telegram/SourceFiles/history/view/media/history_view_large_emoji.h index e89e91386..7ac0f32ff 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_large_emoji.h +++ b/Telegram/SourceFiles/history/view/media/history_view_large_emoji.h @@ -35,6 +35,9 @@ public: bool alwaysShowOutTimestamp() override { return true; } + bool hasTextForCopy() const { + return true; + } private: const not_null _parent; diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp index d57ff81b3..56049d8be 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp @@ -404,6 +404,10 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) const { return result; } +bool UnwrappedMedia::hasTextForCopy() const { + return _content->hasTextForCopy(); +} + QRect UnwrappedMedia::contentRectForReactions() const { const auto inWebPage = (_parent->media() != this); if (inWebPage) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h index 85be053d9..612cb5931 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h @@ -60,6 +60,9 @@ public: [[nodiscard]] virtual bool alwaysShowOutTimestamp() { return false; } + virtual bool hasTextForCopy() const { + return false; + } virtual ~Content() = default; }; @@ -71,6 +74,8 @@ public: PointState pointState(QPoint point) const override; TextState textState(QPoint point, StateRequest request) const override; + bool hasTextForCopy() const override; + bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override { return true; } diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.h b/Telegram/SourceFiles/history/view/media/history_view_sticker.h index 127e3873d..c6bcc2ebe 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.h +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.h @@ -60,6 +60,9 @@ public: void unloadHeavyPart() override; void refreshLink() override; + bool hasTextForCopy() const { + return isEmojiSticker(); + } void setDiceIndex(const QString &emoji, int index); [[nodiscard]] bool atTheEnd() const {