mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Allow to copy message links in public supergroups.
This commit is contained in:
parent
f32af6999b
commit
48bd693679
3 changed files with 22 additions and 10 deletions
|
@ -1221,7 +1221,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
|
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 (isUponSelected > 1) {
|
||||||
if (selectedState.count > 0 && selectedState.canForwardCount == selectedState.count) {
|
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);
|
_menu->addAction(linkCopyToClipboardText, this, SLOT(copyContextUrl()))->setEnabled(true);
|
||||||
}
|
}
|
||||||
if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
|
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 (isUponSelected > 1) {
|
||||||
if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) {
|
if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) {
|
||||||
|
|
|
@ -929,9 +929,22 @@ bool HistoryItem::suggestDeleteAllReport() const {
|
||||||
return !isPost() && !out() && from()->isUser() && toHistoryMessage();
|
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 {
|
QString HistoryItem::directLink() const {
|
||||||
if (hasDirectLink()) {
|
if (hasDirectLink()) {
|
||||||
auto query = _history->peer->asChannel()->username + '/' + QString::number(id);
|
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 media = getMedia()) {
|
||||||
if (auto document = media->getDocument()) {
|
if (auto document = media->getDocument()) {
|
||||||
if (document->isRoundVideo()) {
|
if (document->isRoundVideo()) {
|
||||||
|
@ -939,6 +952,7 @@ QString HistoryItem::directLink() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Messenger::Instance().createInternalLinkFull(query);
|
return Messenger::Instance().createInternalLinkFull(query);
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
@ -717,9 +717,7 @@ public:
|
||||||
bool suggestBanReport() const;
|
bool suggestBanReport() const;
|
||||||
bool suggestDeleteAllReport() const;
|
bool suggestDeleteAllReport() const;
|
||||||
|
|
||||||
bool hasDirectLink() const {
|
bool hasDirectLink() const;
|
||||||
return id > 0 && _history->peer->isChannel() && _history->peer->asChannel()->isPublic() && !_history->peer->isMegagroup();
|
|
||||||
}
|
|
||||||
QString directLink() const;
|
QString directLink() const;
|
||||||
|
|
||||||
int y() const {
|
int y() const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue