Extended context menu for outgoing gifts.

This commit is contained in:
23rd 2025-02-03 22:07:28 +03:00 committed by John Preston
parent bee4118513
commit f2f0c7df92
2 changed files with 25 additions and 0 deletions

View file

@ -3952,6 +3952,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_context_read_show" = "show when";
"lng_context_edit_shortcut" = "Edit Shortcut";
"lng_context_delete_shortcut" = "Delete Quick Reply";
"lng_context_gift_send" = "Send Another Gift";
"lng_add_tag_about" = "Tag this message with an emoji for quick search.";
"lng_subscribe_tag_about" = "Organize your Saved Messages with tags. {link}";

View file

@ -55,6 +55,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/about_sponsored_box.h"
#include "boxes/delete_messages_box.h"
#include "boxes/report_messages_box.h"
#include "boxes/star_gift_box.h" // ShowStarGiftBox
#include "boxes/sticker_set_box.h"
#include "boxes/translate_box.h"
#include "chat_helpers/message_field.h"
@ -2770,6 +2771,29 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
_menu->addAction(tr::lng_profile_copy_phone(tr::now), [=] {
QGuiApplication::clipboard()->setText(phone);
}, &st::menuIconCopy);
} else if (const auto gift = media->gift()) {
const auto peer = item->history()->peer;
const auto user = peer->asUser();
if (!user
|| (!user->isInaccessible()
&& !user->isNotificationsUser())) {
const auto controller = _controller;
const auto starGiftUpgrade = gift->upgrade
&& (gift->type == Data::GiftType::StarGift);
const auto isGift = gift->slug.isEmpty()
|| !gift->channel;
const auto out = item->out();
const auto outgoingGift = isGift
&& (starGiftUpgrade ? !out : out);
if (outgoingGift) {
_menu->addAction(
tr::lng_context_gift_send(tr::now),
[=] {
Ui::ShowStarGiftBox(controller, peer);
},
&st::menuIconGiftPremium);
}
}
}
}
if (!item->isService() && view && actionText.isEmpty()) {