mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +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"
|
||||
|
||||
constexpr auto kPeerLinkPeerIdProperty = 0x01;
|
||||
constexpr auto kPhotoLinkMediaIdProperty = 0x02;
|
||||
constexpr auto kDocumentLinkMediaIdProperty = 0x03;
|
||||
constexpr auto kPhotoLinkMediaProperty = 0x02;
|
||||
constexpr auto kDocumentLinkMediaProperty = 0x03;
|
||||
constexpr auto kSendReactionEmojiProperty = 0x04;
|
||||
constexpr auto kReactionsCountEmojiProperty = 0x05;
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ DocumentClickHandler::DocumentClickHandler(
|
|||
: FileClickHandler(context)
|
||||
, _document(document) {
|
||||
setProperty(
|
||||
kDocumentLinkMediaIdProperty,
|
||||
QVariant(qulonglong(_document->id)));
|
||||
kDocumentLinkMediaProperty,
|
||||
reinterpret_cast<qulonglong>(_document.get()));
|
||||
}
|
||||
|
||||
DocumentOpenClickHandler::DocumentOpenClickHandler(
|
||||
|
@ -150,7 +150,9 @@ PhotoClickHandler::PhotoClickHandler(
|
|||
: FileClickHandler(context)
|
||||
, _photo(photo)
|
||||
, _peer(peer) {
|
||||
setProperty(kPhotoLinkMediaIdProperty, QVariant(qulonglong(_photo->id)));
|
||||
setProperty(
|
||||
kPhotoLinkMediaProperty,
|
||||
reinterpret_cast<qulonglong>(_photo.get()));
|
||||
}
|
||||
|
||||
not_null<PhotoData*> PhotoClickHandler::photo() const {
|
||||
|
|
|
@ -1169,17 +1169,13 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
auto view = App::hoveredItem()
|
||||
? App::hoveredItem()
|
||||
: App::hoveredLinkItem();
|
||||
const auto lnkPhotoId = PhotoId(link
|
||||
? link->property(kPhotoLinkMediaIdProperty).toULongLong()
|
||||
: 0);
|
||||
const auto lnkDocumentId = DocumentId(link
|
||||
? link->property(kDocumentLinkMediaIdProperty).toULongLong()
|
||||
: 0);
|
||||
const auto lnkPhoto = lnkPhotoId
|
||||
? session().data().photo(lnkPhotoId).get()
|
||||
const auto lnkPhoto = link
|
||||
? reinterpret_cast<PhotoData*>(
|
||||
link->property(kPhotoLinkMediaProperty).toULongLong())
|
||||
: nullptr;
|
||||
const auto lnkDocument = lnkDocumentId
|
||||
? session().data().document(lnkDocumentId).get()
|
||||
const auto lnkDocument = link
|
||||
? reinterpret_cast<DocumentData*>(
|
||||
link->property(kDocumentLinkMediaProperty).toULongLong())
|
||||
: nullptr;
|
||||
auto lnkIsVideo = lnkDocument ? lnkDocument->isVideoFile() : false;
|
||||
auto lnkIsVoice = lnkDocument ? lnkDocument->isVoiceMessage() : false;
|
||||
|
|
|
@ -2066,13 +2066,15 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
};
|
||||
|
||||
const auto lnkPhotoId = PhotoId(link
|
||||
? link->property(kPhotoLinkMediaIdProperty).toULongLong()
|
||||
: 0);
|
||||
const auto lnkDocumentId = DocumentId(link
|
||||
? link->property(kDocumentLinkMediaIdProperty).toULongLong()
|
||||
: 0);
|
||||
if (lnkPhotoId || lnkDocumentId) {
|
||||
const auto lnkPhoto = link
|
||||
? reinterpret_cast<PhotoData*>(
|
||||
link->property(kPhotoLinkMediaProperty).toULongLong())
|
||||
: nullptr;
|
||||
const auto lnkDocument = link
|
||||
? reinterpret_cast<DocumentData*>(
|
||||
link->property(kDocumentLinkMediaProperty).toULongLong())
|
||||
: nullptr;
|
||||
if (lnkPhoto || lnkDocument) {
|
||||
const auto item = _dragStateItem;
|
||||
const auto itemId = item ? item->fullId() : FullMsgId();
|
||||
if (isUponSelected > 0 && !hasCopyRestrictionForSelected()) {
|
||||
|
@ -2084,10 +2086,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
&st::menuIconCopy);
|
||||
}
|
||||
addItemActions(item, item);
|
||||
if (lnkPhotoId) {
|
||||
addPhotoActions(session->data().photo(lnkPhotoId), item);
|
||||
if (lnkPhoto) {
|
||||
addPhotoActions(lnkPhoto, item);
|
||||
} else {
|
||||
addDocumentActions(session->data().document(lnkDocumentId), item);
|
||||
addDocumentActions(lnkDocument, item);
|
||||
}
|
||||
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), [=] {
|
||||
|
|
|
@ -923,17 +923,13 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
|||
const auto view = request.view;
|
||||
const auto item = request.item;
|
||||
const auto itemId = item ? item->fullId() : FullMsgId();
|
||||
const auto lnkPhotoId = PhotoId(link
|
||||
? link->property(kPhotoLinkMediaIdProperty).toULongLong()
|
||||
: 0);
|
||||
const auto lnkDocumentId = DocumentId(link
|
||||
? link->property(kDocumentLinkMediaIdProperty).toULongLong()
|
||||
: 0);
|
||||
const auto photo = lnkPhotoId
|
||||
? list->session().data().photo(lnkPhotoId).get()
|
||||
const auto lnkPhoto = link
|
||||
? reinterpret_cast<PhotoData*>(
|
||||
link->property(kPhotoLinkMediaProperty).toULongLong())
|
||||
: nullptr;
|
||||
const auto document = lnkDocumentId
|
||||
? list->session().data().document(lnkDocumentId).get()
|
||||
const auto lnkDocument = link
|
||||
? reinterpret_cast<DocumentData*>(
|
||||
link->property(kDocumentLinkMediaProperty).toULongLong())
|
||||
: nullptr;
|
||||
const auto poll = item
|
||||
? (item->media() ? item->media()->poll() : nullptr)
|
||||
|
@ -958,10 +954,10 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
|||
}
|
||||
|
||||
AddTopMessageActions(result, request, list);
|
||||
if (photo) {
|
||||
AddPhotoActions(result, photo, item, list);
|
||||
} else if (document) {
|
||||
AddDocumentActions(result, document, item, list);
|
||||
if (lnkPhoto) {
|
||||
AddPhotoActions(result, lnkPhoto, item, list);
|
||||
} else if (lnkDocument) {
|
||||
AddDocumentActions(result, lnkDocument, item, list);
|
||||
} else if (poll) {
|
||||
AddPollActions(result, poll, item, list->elementContext());
|
||||
} else if (!request.overSelection && view && !hasSelection) {
|
||||
|
|
|
@ -135,7 +135,7 @@ private:
|
|||
const PaintContext &context,
|
||||
QPoint photoPosition) const;
|
||||
|
||||
not_null<PhotoData*> _data;
|
||||
const not_null<PhotoData*> _data;
|
||||
int _serviceWidth = 0;
|
||||
int _pixw = 1;
|
||||
int _pixh = 1;
|
||||
|
|
|
@ -1593,17 +1593,13 @@ void ListWidget::showContextMenu(
|
|||
},
|
||||
&st::menuIconShowInChat);
|
||||
|
||||
const auto lnkPhotoId = PhotoId(link
|
||||
? link->property(kPhotoLinkMediaIdProperty).toULongLong()
|
||||
: 0);
|
||||
const auto lnkDocumentId = DocumentId(link
|
||||
? link->property(kDocumentLinkMediaIdProperty).toULongLong()
|
||||
: 0);
|
||||
const auto lnkPhoto = lnkPhotoId
|
||||
? session().data().photo(lnkPhotoId).get()
|
||||
const auto lnkPhoto = link
|
||||
? reinterpret_cast<PhotoData*>(
|
||||
link->property(kPhotoLinkMediaProperty).toULongLong())
|
||||
: nullptr;
|
||||
const auto lnkDocument = lnkDocumentId
|
||||
? session().data().document(lnkDocumentId).get()
|
||||
const auto lnkDocument = link
|
||||
? reinterpret_cast<DocumentData*>(
|
||||
link->property(kDocumentLinkMediaProperty).toULongLong())
|
||||
: nullptr;
|
||||
if (lnkPhoto || lnkDocument) {
|
||||
auto [isVideo, isVoice, isAudio] = [&] {
|
||||
|
|
Loading…
Add table
Reference in a new issue