Allow to copy message links in public supergroups.

This commit is contained in:
John Preston 2017-07-11 20:21:24 +03:00
parent f32af6999b
commit 48bd693679
3 changed files with 22 additions and 10 deletions

View file

@ -1221,7 +1221,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
}
}
if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
_menu->addAction(lang(lng_context_copy_post_link), _widget, SLOT(onCopyPostLink()));
_menu->addAction(lang(item->history()->peer->isMegagroup() ? lng_context_copy_link : lng_context_copy_post_link), _widget, SLOT(onCopyPostLink()));
}
if (isUponSelected > 1) {
if (selectedState.count > 0 && selectedState.canForwardCount == selectedState.count) {
@ -1329,7 +1329,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
_menu->addAction(linkCopyToClipboardText, this, SLOT(copyContextUrl()))->setEnabled(true);
}
if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
_menu->addAction(lang(lng_context_copy_post_link), _widget, SLOT(onCopyPostLink()));
_menu->addAction(lang(item->history()->peer->isMegagroup() ? lng_context_copy_link : lng_context_copy_post_link), _widget, SLOT(onCopyPostLink()));
}
if (isUponSelected > 1) {
if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) {

View file

@ -929,13 +929,27 @@ bool HistoryItem::suggestDeleteAllReport() const {
return !isPost() && !out() && from()->isUser() && toHistoryMessage();
}
bool HistoryItem::hasDirectLink() const {
if (id <= 0) {
return false;
}
if (auto channel = _history->peer->asChannel()) {
return channel->isPublic();
}
return false;
}
QString HistoryItem::directLink() const {
if (hasDirectLink()) {
auto query = _history->peer->asChannel()->username + '/' + QString::number(id);
if (auto media = getMedia()) {
if (auto document = media->getDocument()) {
if (document->isRoundVideo()) {
return qsl("https://telesco.pe/") + query;
auto channel = _history->peer->asChannel();
t_assert(channel != nullptr);
auto query = channel->username + '/' + QString::number(id);
if (!channel->isMegagroup()) {
if (auto media = getMedia()) {
if (auto document = media->getDocument()) {
if (document->isRoundVideo()) {
return qsl("https://telesco.pe/") + query;
}
}
}
}

View file

@ -717,9 +717,7 @@ public:
bool suggestBanReport() const;
bool suggestDeleteAllReport() const;
bool hasDirectLink() const {
return id > 0 && _history->peer->isChannel() && _history->peer->asChannel()->isPublic() && !_history->peer->isMegagroup();
}
bool hasDirectLink() const;
QString directLink() const;
int y() const {