2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 15:35:51 +00:00

Added draft menu to EditCaptionBox to open photo editor.

This commit is contained in:
23rd
2021-02-20 10:52:48 +03:00
parent 671a06c407
commit d1b6cf1fae
7 changed files with 111 additions and 31 deletions

View File

@@ -621,33 +621,12 @@ void SendFilesBox::pushBlock(int from, int till) {
block.itemModifyRequest(
) | rpl::start_with_next([=, controller = _controller](int index) {
auto &file = _list.files[index];
if (file.type != Ui::PreparedFile::Type::Photo) {
return;
}
using ImageInfo = Ui::PreparedFileInformation::Image;
const auto image = std::get_if<ImageInfo>(&file.information->media);
if (!image) {
return;
}
auto callback = [=](const Editor::PhotoModifications &mods) {
image->modifications = mods;
Storage::UpdateImageDetails(
_list.files[index],
st::sendMediaPreviewSize);
refreshAllAfterChanges(from);
};
auto copy = image->data;
const auto fileImage = std::make_shared<Image>(std::move(copy));
controller->showLayer(
std::make_unique<Editor::LayerWidget>(
this,
&controller->window(),
fileImage,
image->modifications,
std::move(callback)),
Ui::LayerOption::KeepOther);
Editor::OpenWithPreparedFile(
this,
controller,
&_list.files[index],
st::sendMediaPreviewSize,
[=] { refreshAllAfterChanges(from); });
}, widget->lifetime());
}