mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Restrict saving files as if noforwards.
This commit is contained in:
parent
fd6751233e
commit
96c910190b
4 changed files with 33 additions and 19 deletions
|
@ -1776,9 +1776,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
showContextInFolder(document);
|
||||
});
|
||||
}
|
||||
_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))), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
|
||||
saveDocumentToFile(itemId, document);
|
||||
}));
|
||||
if (_peer->allowsForwarding()) {
|
||||
_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))), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
|
||||
saveDocumentToFile(itemId, document);
|
||||
}));
|
||||
}
|
||||
if (document->hasAttachedStickers()) {
|
||||
_menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] {
|
||||
session->api().attachedStickers().requestAttachedStickerSets(
|
||||
|
@ -1932,9 +1934,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
Api::ToggleFavedSticker(document, itemId);
|
||||
});
|
||||
}
|
||||
_menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
|
||||
saveDocumentToFile(itemId, document);
|
||||
}));
|
||||
if (_peer->allowsForwarding()) {
|
||||
_menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
|
||||
saveDocumentToFile(itemId, document);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (const auto media = item->media()) {
|
||||
|
|
|
@ -188,7 +188,11 @@ void ShowInFolder(not_null<DocumentData*> document) {
|
|||
void AddSaveDocumentAction(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
Data::FileOrigin origin,
|
||||
not_null<DocumentData*> document) {
|
||||
not_null<DocumentData*> document,
|
||||
not_null<ListWidget*> list) {
|
||||
if (list->hasCopyRestriction()) {
|
||||
return;
|
||||
}
|
||||
const auto save = [=] {
|
||||
DocumentSaveClickHandler::Save(
|
||||
origin,
|
||||
|
@ -272,7 +276,7 @@ void AddDocumentActions(
|
|||
tr::lng_context_attached_stickers(tr::now),
|
||||
std::move(callback));
|
||||
}
|
||||
AddSaveDocumentAction(menu, contextId, document);
|
||||
AddSaveDocumentAction(menu, contextId, document, list);
|
||||
}
|
||||
|
||||
void AddPostLinkAction(
|
||||
|
|
|
@ -1595,15 +1595,17 @@ void ListWidget::showContextMenu(
|
|||
document,
|
||||
DocumentSaveClickHandler::Mode::ToNewFile);
|
||||
});
|
||||
_contextMenu->addAction(
|
||||
(isVideo
|
||||
? tr::lng_context_save_video(tr::now)
|
||||
: isVoice
|
||||
? tr::lng_context_save_audio(tr::now)
|
||||
: isAudio
|
||||
? tr::lng_context_save_audio_file(tr::now)
|
||||
: tr::lng_context_save_file(tr::now)),
|
||||
std::move(handler));
|
||||
if (_peer->allowsForwarding()) {
|
||||
_contextMenu->addAction(
|
||||
(isVideo
|
||||
? tr::lng_context_save_video(tr::now)
|
||||
: isVoice
|
||||
? tr::lng_context_save_audio(tr::now)
|
||||
: isAudio
|
||||
? tr::lng_context_save_audio_file(tr::now)
|
||||
: tr::lng_context_save_file(tr::now)),
|
||||
std::move(handler));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -727,7 +727,9 @@ void OverlayWidget::refreshNavVisibility() {
|
|||
}
|
||||
|
||||
bool OverlayWidget::contentCanBeSaved() const {
|
||||
if (_photo) {
|
||||
if (hasCopyRestriction()) {
|
||||
return false;
|
||||
} else if (_photo) {
|
||||
return _photo->hasVideo() || _photoMedia->loaded();
|
||||
} else if (_document) {
|
||||
return _document->filepath(true).isEmpty() && !_document->loading();
|
||||
|
@ -943,7 +945,9 @@ void OverlayWidget::fillContextMenuActions(const MenuCallback &addAction) {
|
|||
if (canDelete) {
|
||||
addAction(tr::lng_mediaview_delete(tr::now), [=] { deleteMedia(); });
|
||||
}
|
||||
addAction(tr::lng_mediaview_save_as(tr::now), [=] { saveAs(); });
|
||||
if (!hasCopyRestriction()) {
|
||||
addAction(tr::lng_mediaview_save_as(tr::now), [=] { saveAs(); });
|
||||
}
|
||||
|
||||
if (const auto overviewType = computeOverviewType()) {
|
||||
const auto text = _document
|
||||
|
|
Loading…
Add table
Reference in a new issue