diff --git a/Telegram/SourceFiles/boxes/translate_box.cpp b/Telegram/SourceFiles/boxes/translate_box.cpp index 1797c34fac..2d460a2038 100644 --- a/Telegram/SourceFiles/boxes/translate_box.cpp +++ b/Telegram/SourceFiles/boxes/translate_box.cpp @@ -140,7 +140,8 @@ void TranslateBox( not_null box, not_null peer, MsgId msgId, - TextWithEntities text) { + TextWithEntities text, + bool hasCopyRestriction) { box->setWidth(st::boxWideWidth); box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); }); const auto container = box->verticalLayout(); @@ -182,6 +183,10 @@ void TranslateBox( box, object_ptr(box, stLabel))); { + if (hasCopyRestriction) { + original->entity()->setContextMenuHook([](auto&&) { + }); + } original->entity()->setMarkedText(text); original->setMinimalHeight(lineHeight); original->hide(anim::type::instant); @@ -232,7 +237,7 @@ void TranslateBox( const auto translated = box->addRow(object_ptr>( box, object_ptr(box, stLabel))); - translated->entity()->setSelectable(true); + translated->entity()->setSelectable(!hasCopyRestriction); translated->hide(anim::type::instant); constexpr auto kMaxLines = 3; diff --git a/Telegram/SourceFiles/boxes/translate_box.h b/Telegram/SourceFiles/boxes/translate_box.h index 22daec17b3..467fb4b85e 100644 --- a/Telegram/SourceFiles/boxes/translate_box.h +++ b/Telegram/SourceFiles/boxes/translate_box.h @@ -19,7 +19,8 @@ void TranslateBox( not_null box, not_null peer, MsgId msgId, - TextWithEntities text); + TextWithEntities text, + bool hasCopyRestriction); [[nodiscard]] bool SkipTranslate(TextWithEntities textWithEntities); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index fbc075a27d..50744ca936 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2276,7 +2276,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { Ui::TranslateBox, item->history()->peer, MsgId(), - getSelectedText().rich)); + getSelectedText().rich, + hasCopyRestrictionForSelected())); }, &st::menuIconTranslate); } } @@ -2376,7 +2377,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { Ui::TranslateBox, item->history()->peer, MsgId(), - getSelectedText().rich)); + getSelectedText().rich, + hasCopyRestrictionForSelected())); }, &st::menuIconTranslate); } addItemActions(item, item); @@ -2446,7 +2448,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { Ui::TranslateBox, item->history()->peer, item->fullId().msg, - item->originalText())); + item->originalText(), + hasCopyRestriction(item))); }, &st::menuIconTranslate); } } diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 67bd272b13..41b90b3090 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -1014,7 +1014,8 @@ base::unique_qptr FillContextMenu( Ui::TranslateBox, item->history()->peer, MsgId(), - list->getSelectedText().rich)); + list->getSelectedText().rich, + list->hasCopyRestrictionForSelected())); } }, &st::menuIconTranslate); } @@ -1061,7 +1062,8 @@ base::unique_qptr FillContextMenu( Ui::TranslateBox, item->history()->peer, item->fullId().msg, - item->originalText())); + item->originalText(), + list->hasCopyRestriction(view->data()))); } }, &st::menuIconTranslate); } @@ -1143,7 +1145,8 @@ void AddPollActions( Ui::TranslateBox, item->history()->peer, MsgId(), - TextWithEntities{ .text = text })); + TextWithEntities{ .text = text }, + item->forbidsForward())); }, &st::menuIconTranslate); } }