mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix context menu on sent images / documents.
This commit is contained in:
parent
c5e7048a3d
commit
1657c2c7f2
7 changed files with 42 additions and 50 deletions
|
@ -10,8 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/basic_click_handlers.h"
|
#include "ui/basic_click_handlers.h"
|
||||||
|
|
||||||
constexpr auto kPeerLinkPeerIdProperty = 0x01;
|
constexpr auto kPeerLinkPeerIdProperty = 0x01;
|
||||||
constexpr auto kPhotoLinkMediaIdProperty = 0x02;
|
constexpr auto kPhotoLinkMediaProperty = 0x02;
|
||||||
constexpr auto kDocumentLinkMediaIdProperty = 0x03;
|
constexpr auto kDocumentLinkMediaProperty = 0x03;
|
||||||
constexpr auto kSendReactionEmojiProperty = 0x04;
|
constexpr auto kSendReactionEmojiProperty = 0x04;
|
||||||
constexpr auto kReactionsCountEmojiProperty = 0x05;
|
constexpr auto kReactionsCountEmojiProperty = 0x05;
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ DocumentClickHandler::DocumentClickHandler(
|
||||||
: FileClickHandler(context)
|
: FileClickHandler(context)
|
||||||
, _document(document) {
|
, _document(document) {
|
||||||
setProperty(
|
setProperty(
|
||||||
kDocumentLinkMediaIdProperty,
|
kDocumentLinkMediaProperty,
|
||||||
QVariant(qulonglong(_document->id)));
|
reinterpret_cast<qulonglong>(_document.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentOpenClickHandler::DocumentOpenClickHandler(
|
DocumentOpenClickHandler::DocumentOpenClickHandler(
|
||||||
|
@ -150,7 +150,9 @@ PhotoClickHandler::PhotoClickHandler(
|
||||||
: FileClickHandler(context)
|
: FileClickHandler(context)
|
||||||
, _photo(photo)
|
, _photo(photo)
|
||||||
, _peer(peer) {
|
, _peer(peer) {
|
||||||
setProperty(kPhotoLinkMediaIdProperty, QVariant(qulonglong(_photo->id)));
|
setProperty(
|
||||||
|
kPhotoLinkMediaProperty,
|
||||||
|
reinterpret_cast<qulonglong>(_photo.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<PhotoData*> PhotoClickHandler::photo() const {
|
not_null<PhotoData*> PhotoClickHandler::photo() const {
|
||||||
|
|
|
@ -1169,17 +1169,13 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
auto view = App::hoveredItem()
|
auto view = App::hoveredItem()
|
||||||
? App::hoveredItem()
|
? App::hoveredItem()
|
||||||
: App::hoveredLinkItem();
|
: App::hoveredLinkItem();
|
||||||
const auto lnkPhotoId = PhotoId(link
|
const auto lnkPhoto = link
|
||||||
? link->property(kPhotoLinkMediaIdProperty).toULongLong()
|
? reinterpret_cast<PhotoData*>(
|
||||||
: 0);
|
link->property(kPhotoLinkMediaProperty).toULongLong())
|
||||||
const auto lnkDocumentId = DocumentId(link
|
|
||||||
? link->property(kDocumentLinkMediaIdProperty).toULongLong()
|
|
||||||
: 0);
|
|
||||||
const auto lnkPhoto = lnkPhotoId
|
|
||||||
? session().data().photo(lnkPhotoId).get()
|
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto lnkDocument = lnkDocumentId
|
const auto lnkDocument = link
|
||||||
? session().data().document(lnkDocumentId).get()
|
? reinterpret_cast<DocumentData*>(
|
||||||
|
link->property(kDocumentLinkMediaProperty).toULongLong())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
auto lnkIsVideo = lnkDocument ? lnkDocument->isVideoFile() : false;
|
auto lnkIsVideo = lnkDocument ? lnkDocument->isVideoFile() : false;
|
||||||
auto lnkIsVoice = lnkDocument ? lnkDocument->isVoiceMessage() : false;
|
auto lnkIsVoice = lnkDocument ? lnkDocument->isVoiceMessage() : false;
|
||||||
|
|
|
@ -2066,13 +2066,15 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto lnkPhotoId = PhotoId(link
|
const auto lnkPhoto = link
|
||||||
? link->property(kPhotoLinkMediaIdProperty).toULongLong()
|
? reinterpret_cast<PhotoData*>(
|
||||||
: 0);
|
link->property(kPhotoLinkMediaProperty).toULongLong())
|
||||||
const auto lnkDocumentId = DocumentId(link
|
: nullptr;
|
||||||
? link->property(kDocumentLinkMediaIdProperty).toULongLong()
|
const auto lnkDocument = link
|
||||||
: 0);
|
? reinterpret_cast<DocumentData*>(
|
||||||
if (lnkPhotoId || lnkDocumentId) {
|
link->property(kDocumentLinkMediaProperty).toULongLong())
|
||||||
|
: nullptr;
|
||||||
|
if (lnkPhoto || lnkDocument) {
|
||||||
const auto item = _dragStateItem;
|
const auto item = _dragStateItem;
|
||||||
const auto itemId = item ? item->fullId() : FullMsgId();
|
const auto itemId = item ? item->fullId() : FullMsgId();
|
||||||
if (isUponSelected > 0 && !hasCopyRestrictionForSelected()) {
|
if (isUponSelected > 0 && !hasCopyRestrictionForSelected()) {
|
||||||
|
@ -2084,10 +2086,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
&st::menuIconCopy);
|
&st::menuIconCopy);
|
||||||
}
|
}
|
||||||
addItemActions(item, item);
|
addItemActions(item, item);
|
||||||
if (lnkPhotoId) {
|
if (lnkPhoto) {
|
||||||
addPhotoActions(session->data().photo(lnkPhotoId), item);
|
addPhotoActions(lnkPhoto, item);
|
||||||
} else {
|
} else {
|
||||||
addDocumentActions(session->data().document(lnkDocumentId), item);
|
addDocumentActions(lnkDocument, item);
|
||||||
}
|
}
|
||||||
if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
|
if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
|
||||||
_menu->addAction(item->history()->peer->isMegagroup() ? tr::lng_context_copy_message_link(tr::now) : tr::lng_context_copy_post_link(tr::now), [=] {
|
_menu->addAction(item->history()->peer->isMegagroup() ? tr::lng_context_copy_message_link(tr::now) : tr::lng_context_copy_post_link(tr::now), [=] {
|
||||||
|
|
|
@ -923,17 +923,13 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
const auto view = request.view;
|
const auto view = request.view;
|
||||||
const auto item = request.item;
|
const auto item = request.item;
|
||||||
const auto itemId = item ? item->fullId() : FullMsgId();
|
const auto itemId = item ? item->fullId() : FullMsgId();
|
||||||
const auto lnkPhotoId = PhotoId(link
|
const auto lnkPhoto = link
|
||||||
? link->property(kPhotoLinkMediaIdProperty).toULongLong()
|
? reinterpret_cast<PhotoData*>(
|
||||||
: 0);
|
link->property(kPhotoLinkMediaProperty).toULongLong())
|
||||||
const auto lnkDocumentId = DocumentId(link
|
|
||||||
? link->property(kDocumentLinkMediaIdProperty).toULongLong()
|
|
||||||
: 0);
|
|
||||||
const auto photo = lnkPhotoId
|
|
||||||
? list->session().data().photo(lnkPhotoId).get()
|
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto document = lnkDocumentId
|
const auto lnkDocument = link
|
||||||
? list->session().data().document(lnkDocumentId).get()
|
? reinterpret_cast<DocumentData*>(
|
||||||
|
link->property(kDocumentLinkMediaProperty).toULongLong())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto poll = item
|
const auto poll = item
|
||||||
? (item->media() ? item->media()->poll() : nullptr)
|
? (item->media() ? item->media()->poll() : nullptr)
|
||||||
|
@ -958,10 +954,10 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTopMessageActions(result, request, list);
|
AddTopMessageActions(result, request, list);
|
||||||
if (photo) {
|
if (lnkPhoto) {
|
||||||
AddPhotoActions(result, photo, item, list);
|
AddPhotoActions(result, lnkPhoto, item, list);
|
||||||
} else if (document) {
|
} else if (lnkDocument) {
|
||||||
AddDocumentActions(result, document, item, list);
|
AddDocumentActions(result, lnkDocument, item, list);
|
||||||
} else if (poll) {
|
} else if (poll) {
|
||||||
AddPollActions(result, poll, item, list->elementContext());
|
AddPollActions(result, poll, item, list->elementContext());
|
||||||
} else if (!request.overSelection && view && !hasSelection) {
|
} else if (!request.overSelection && view && !hasSelection) {
|
||||||
|
|
|
@ -135,7 +135,7 @@ private:
|
||||||
const PaintContext &context,
|
const PaintContext &context,
|
||||||
QPoint photoPosition) const;
|
QPoint photoPosition) const;
|
||||||
|
|
||||||
not_null<PhotoData*> _data;
|
const not_null<PhotoData*> _data;
|
||||||
int _serviceWidth = 0;
|
int _serviceWidth = 0;
|
||||||
int _pixw = 1;
|
int _pixw = 1;
|
||||||
int _pixh = 1;
|
int _pixh = 1;
|
||||||
|
|
|
@ -1593,17 +1593,13 @@ void ListWidget::showContextMenu(
|
||||||
},
|
},
|
||||||
&st::menuIconShowInChat);
|
&st::menuIconShowInChat);
|
||||||
|
|
||||||
const auto lnkPhotoId = PhotoId(link
|
const auto lnkPhoto = link
|
||||||
? link->property(kPhotoLinkMediaIdProperty).toULongLong()
|
? reinterpret_cast<PhotoData*>(
|
||||||
: 0);
|
link->property(kPhotoLinkMediaProperty).toULongLong())
|
||||||
const auto lnkDocumentId = DocumentId(link
|
|
||||||
? link->property(kDocumentLinkMediaIdProperty).toULongLong()
|
|
||||||
: 0);
|
|
||||||
const auto lnkPhoto = lnkPhotoId
|
|
||||||
? session().data().photo(lnkPhotoId).get()
|
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto lnkDocument = lnkDocumentId
|
const auto lnkDocument = link
|
||||||
? session().data().document(lnkDocumentId).get()
|
? reinterpret_cast<DocumentData*>(
|
||||||
|
link->property(kDocumentLinkMediaProperty).toULongLong())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (lnkPhoto || lnkDocument) {
|
if (lnkPhoto || lnkDocument) {
|
||||||
auto [isVideo, isVoice, isAudio] = [&] {
|
auto [isVideo, isVoice, isAudio] = [&] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue