Respected copy restriction on translate box.
This commit is contained in:
parent
3fdb807a1e
commit
6695d7d503
|
@ -140,7 +140,8 @@ void TranslateBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
MsgId msgId,
|
MsgId msgId,
|
||||||
TextWithEntities text) {
|
TextWithEntities text,
|
||||||
|
bool hasCopyRestriction) {
|
||||||
box->setWidth(st::boxWideWidth);
|
box->setWidth(st::boxWideWidth);
|
||||||
box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); });
|
box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); });
|
||||||
const auto container = box->verticalLayout();
|
const auto container = box->verticalLayout();
|
||||||
|
@ -182,6 +183,10 @@ void TranslateBox(
|
||||||
box,
|
box,
|
||||||
object_ptr<FlatLabel>(box, stLabel)));
|
object_ptr<FlatLabel>(box, stLabel)));
|
||||||
{
|
{
|
||||||
|
if (hasCopyRestriction) {
|
||||||
|
original->entity()->setContextMenuHook([](auto&&) {
|
||||||
|
});
|
||||||
|
}
|
||||||
original->entity()->setMarkedText(text);
|
original->entity()->setMarkedText(text);
|
||||||
original->setMinimalHeight(lineHeight);
|
original->setMinimalHeight(lineHeight);
|
||||||
original->hide(anim::type::instant);
|
original->hide(anim::type::instant);
|
||||||
|
@ -232,7 +237,7 @@ void TranslateBox(
|
||||||
const auto translated = box->addRow(object_ptr<SlideWrap<FlatLabel>>(
|
const auto translated = box->addRow(object_ptr<SlideWrap<FlatLabel>>(
|
||||||
box,
|
box,
|
||||||
object_ptr<FlatLabel>(box, stLabel)));
|
object_ptr<FlatLabel>(box, stLabel)));
|
||||||
translated->entity()->setSelectable(true);
|
translated->entity()->setSelectable(!hasCopyRestriction);
|
||||||
translated->hide(anim::type::instant);
|
translated->hide(anim::type::instant);
|
||||||
|
|
||||||
constexpr auto kMaxLines = 3;
|
constexpr auto kMaxLines = 3;
|
||||||
|
|
|
@ -19,7 +19,8 @@ void TranslateBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
MsgId msgId,
|
MsgId msgId,
|
||||||
TextWithEntities text);
|
TextWithEntities text,
|
||||||
|
bool hasCopyRestriction);
|
||||||
|
|
||||||
[[nodiscard]] bool SkipTranslate(TextWithEntities textWithEntities);
|
[[nodiscard]] bool SkipTranslate(TextWithEntities textWithEntities);
|
||||||
|
|
||||||
|
|
|
@ -2276,7 +2276,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
Ui::TranslateBox,
|
Ui::TranslateBox,
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
MsgId(),
|
MsgId(),
|
||||||
getSelectedText().rich));
|
getSelectedText().rich,
|
||||||
|
hasCopyRestrictionForSelected()));
|
||||||
}, &st::menuIconTranslate);
|
}, &st::menuIconTranslate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2376,7 +2377,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
Ui::TranslateBox,
|
Ui::TranslateBox,
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
MsgId(),
|
MsgId(),
|
||||||
getSelectedText().rich));
|
getSelectedText().rich,
|
||||||
|
hasCopyRestrictionForSelected()));
|
||||||
}, &st::menuIconTranslate);
|
}, &st::menuIconTranslate);
|
||||||
}
|
}
|
||||||
addItemActions(item, item);
|
addItemActions(item, item);
|
||||||
|
@ -2446,7 +2448,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
Ui::TranslateBox,
|
Ui::TranslateBox,
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
item->fullId().msg,
|
item->fullId().msg,
|
||||||
item->originalText()));
|
item->originalText(),
|
||||||
|
hasCopyRestriction(item)));
|
||||||
}, &st::menuIconTranslate);
|
}, &st::menuIconTranslate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1014,7 +1014,8 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
Ui::TranslateBox,
|
Ui::TranslateBox,
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
MsgId(),
|
MsgId(),
|
||||||
list->getSelectedText().rich));
|
list->getSelectedText().rich,
|
||||||
|
list->hasCopyRestrictionForSelected()));
|
||||||
}
|
}
|
||||||
}, &st::menuIconTranslate);
|
}, &st::menuIconTranslate);
|
||||||
}
|
}
|
||||||
|
@ -1061,7 +1062,8 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
Ui::TranslateBox,
|
Ui::TranslateBox,
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
item->fullId().msg,
|
item->fullId().msg,
|
||||||
item->originalText()));
|
item->originalText(),
|
||||||
|
list->hasCopyRestriction(view->data())));
|
||||||
}
|
}
|
||||||
}, &st::menuIconTranslate);
|
}, &st::menuIconTranslate);
|
||||||
}
|
}
|
||||||
|
@ -1143,7 +1145,8 @@ void AddPollActions(
|
||||||
Ui::TranslateBox,
|
Ui::TranslateBox,
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
MsgId(),
|
MsgId(),
|
||||||
TextWithEntities{ .text = text }));
|
TextWithEntities{ .text = text },
|
||||||
|
item->forbidsForward()));
|
||||||
}, &st::menuIconTranslate);
|
}, &st::menuIconTranslate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue