2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Add "Photo or video" and "Document" attach menu items.

This commit is contained in:
John Preston
2022-04-05 10:49:55 +04:00
parent 0e75204762
commit 0374d8caa8
12 changed files with 28 additions and 13 deletions

View File

@@ -498,10 +498,14 @@ HistoryWidget::HistoryWidget(
_attachBotsMenu->setAutoHiding(true);
}
};
const auto attach = [=](bool compress) {
chooseAttach(compress);
};
_attachBotsMenu = InlineBots::MakeAttachBotsMenu(
this,
controller,
forceShown);
forceShown,
attach);
_attachBotsMenu->setOrigin(
Ui::PanelAnimation::Origin::BottomLeft);
if (_history && _history->peer->isUser()) {
@@ -4039,7 +4043,8 @@ void HistoryWidget::cornerButtonsAnimationFinish() {
updateCornerButtonsPositions();
}
void HistoryWidget::chooseAttach() {
void HistoryWidget::chooseAttach(
std::optional<bool> overrideSendImagesAsPhotos) {
if (_editMsgId) {
controller()->show(Ui::MakeInformBox(tr::lng_edit_caption_attach()));
return;
@@ -4058,7 +4063,9 @@ void HistoryWidget::chooseAttach() {
return;
}
const auto filter = FileDialog::AllOrImagesFilter();
const auto filter = (overrideSendImagesAsPhotos == true)
? FileDialog::ImagesOrAllFilter()
: FileDialog::AllOrImagesFilter();
FileDialog::GetOpenPaths(this, tr::lng_choose_files(tr::now), filter, crl::guard(this, [=](
FileDialog::OpenResult &&result) {
@@ -4073,7 +4080,8 @@ void HistoryWidget::chooseAttach() {
if (!read.image.isNull() && !read.animated) {
confirmSendingFiles(
std::move(read.image),
std::move(result.remoteContent));
std::move(result.remoteContent),
overrideSendImagesAsPhotos);
} else {
uploadFile(result.remoteContent, SendMediaType::File);
}
@@ -4081,6 +4089,7 @@ void HistoryWidget::chooseAttach() {
auto list = Storage::PrepareMediaList(
result.paths,
st::sendMediaPreviewSize);
list.overrideSendImagesAsPhotos = overrideSendImagesAsPhotos;
confirmSendingFiles(std::move(list));
}
}), nullptr);