mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added ability to copy filename of named documents.
This commit is contained in:
parent
b959262140
commit
0e571ea679
5 changed files with 49 additions and 0 deletions
|
@ -2752,6 +2752,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_context_copy_email" = "Copy Email Address";
|
||||
"lng_context_copy_hashtag" = "Copy Hashtag";
|
||||
"lng_context_copy_mention" = "Copy Username";
|
||||
"lng_context_copy_filename" = "Copy Filename";
|
||||
"lng_context_save_image" = "Save Image As...";
|
||||
"lng_context_copy_image" = "Copy Image";
|
||||
"lng_context_cancel_download" = "Cancel Download";
|
||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_item_text.h"
|
||||
#include "history/admin_log/history_admin_log_section.h"
|
||||
#include "history/admin_log/history_admin_log_filter.h"
|
||||
#include "history/view/history_view_context_menu.h"
|
||||
#include "history/view/history_view_message.h"
|
||||
#include "history/view/history_view_service_message.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
|
@ -1251,6 +1252,12 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
_menu->addAction(lnkIsVideo ? tr::lng_context_save_video(tr::now) : (lnkIsVoice ? tr::lng_context_save_audio(tr::now) : (lnkIsAudio ? tr::lng_context_save_audio_file(tr::now) : tr::lng_context_save_file(tr::now))), base::fn_delayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, lnkDocument] {
|
||||
saveDocumentToFile(lnkDocument);
|
||||
}), &st::menuIconDownload);
|
||||
|
||||
HistoryView::AddCopyFilename(
|
||||
_menu,
|
||||
lnkDocument,
|
||||
[] { return false; });
|
||||
|
||||
if (lnkDocument->hasAttachedStickers()) {
|
||||
const auto controller = _controller;
|
||||
auto callback = [=] {
|
||||
|
|
|
@ -2223,6 +2223,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
_menu->addAction(lnkIsVideo ? tr::lng_context_save_video(tr::now) : (lnkIsVoice ? tr::lng_context_save_audio(tr::now) : (lnkIsAudio ? tr::lng_context_save_audio_file(tr::now) : tr::lng_context_save_file(tr::now))), base::fn_delayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
|
||||
saveDocumentToFile(itemId, document);
|
||||
}), &st::menuIconDownload);
|
||||
|
||||
HistoryView::AddCopyFilename(
|
||||
_menu,
|
||||
document,
|
||||
[=] { return showCopyRestrictionForSelected(); });
|
||||
}
|
||||
if (document->hasAttachedStickers()) {
|
||||
_menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] {
|
||||
|
|
|
@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/menu/menu_multiline_action.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/text/format_song_document_name.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/controls/delete_message_context_action.h"
|
||||
#include "ui/controls/who_reacted_context_action.h"
|
||||
|
@ -326,6 +327,10 @@ void AddDocumentActions(
|
|||
AddSaveSoundForNotifications(menu, item, document, controller);
|
||||
}
|
||||
AddSaveDocumentAction(menu, item, document, list);
|
||||
AddCopyFilename(
|
||||
menu,
|
||||
document,
|
||||
[=] { return list->showCopyRestrictionForSelected(); });
|
||||
}
|
||||
|
||||
void AddPostLinkAction(
|
||||
|
@ -1555,6 +1560,33 @@ void ShowTagInListMenu(
|
|||
(*menu)->popup(position);
|
||||
}
|
||||
|
||||
void AddCopyFilename(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<DocumentData*> document,
|
||||
Fn<bool()> showCopyRestrictionForSelected) {
|
||||
const auto filenameToCopy = [&] {
|
||||
if (document->isAudioFile()) {
|
||||
return TextForMimeData().append(
|
||||
Ui::Text::FormatSongNameFor(document).string());
|
||||
} else if (document->sticker()
|
||||
|| document->isAnimation()
|
||||
|| document->isVideoMessage()
|
||||
|| document->isVideoFile()
|
||||
|| document->isVoiceMessage()) {
|
||||
return TextForMimeData();
|
||||
} else {
|
||||
return TextForMimeData().append(document->filename());
|
||||
}
|
||||
}();
|
||||
if (!filenameToCopy.empty()) {
|
||||
menu->addAction(tr::lng_context_copy_filename(tr::now), [=] {
|
||||
if (!showCopyRestrictionForSelected()) {
|
||||
TextUtilities::SetClipboardText(filenameToCopy);
|
||||
}
|
||||
}, &st::menuIconCopy);
|
||||
}
|
||||
}
|
||||
|
||||
void ShowWhoReactedMenu(
|
||||
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
||||
QPoint position,
|
||||
|
|
|
@ -94,6 +94,10 @@ void ShowTagInListMenu(
|
|||
not_null<QWidget*> context,
|
||||
const Data::ReactionId &id,
|
||||
not_null<Window::SessionController*> controller);
|
||||
void AddCopyFilename(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<DocumentData*> document,
|
||||
Fn<bool()> showCopyRestrictionForSelected);
|
||||
|
||||
enum class EmojiPacksSource {
|
||||
Message,
|
||||
|
|
Loading…
Add table
Reference in a new issue