diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index e2d5f1faa..ce528cd60 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -643,6 +643,8 @@ usernameTextStyle: TextStyle(boxTextStyle, passcodeTextStyle) { } usernameDefaultFg: windowSubTextFg; +editMediaCheckboxMargins: margins(0px, 15px, 23px, 15px); + downloadPathSkip: 10px; colorEditWidth: 390px; diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 26c97cbcd..69c20b3fd 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text_options.h" #include "ui/widgets/input_fields.h" #include "window/window_controller.h" +#include "ui/widgets/checkbox.h" EditCaptionBox::EditCaptionBox( QWidget*, @@ -247,6 +248,22 @@ EditCaptionBox::EditCaptionBox( _field->setInstantReplacesEnabled(Global::ReplaceEmojiValue()); _field->setMarkdownReplacesEnabled(rpl::single(true)); _field->setEditLinkCallback(DefaultEditLinkCallback(_field)); + + auto r = object_ptr>( + this, + object_ptr( + this, + lang(lng_send_file), + false, + st::defaultBoxCheckbox), + st::editMediaCheckboxMargins); + _wayWrap = r.data(); + _wayWrap->toggle(false, anim::type::instant); + + r->entity()->checkedChanges( + ) | rpl::start_with_next([&](bool checked) { + _asFile = checked; + }, _wayWrap->lifetime()); } bool EditCaptionBox::emojiFilter(not_null event) { @@ -345,6 +362,7 @@ void EditCaptionBox::prepare() { _gifw = _gifh = _gifx = 0; auto isGif = false; + _wayWrap->toggle(_isImage, anim::type::instant); using Info = FileMediaInformation; if (const auto image = base::get_if(fileMedia) @@ -450,6 +468,9 @@ void EditCaptionBox::setupEmojiPanel() { void EditCaptionBox::updateBoxSize() { auto newHeight = st::boxPhotoPadding.top() + st::boxPhotoCaptionSkip + _field->height() + errorTopSkip() + st::normalFont->height; + if (_isImage) { + newHeight += _wayWrap->height() / 2; + } if (_photo || _animated) { newHeight += std::max(_thumbh, _gifh); } else if (_thumbw) { @@ -564,6 +585,14 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) { void EditCaptionBox::resizeEvent(QResizeEvent *e) { BoxContent::resizeEvent(e); + + if (_isImage) { + _wayWrap->resize(st::sendMediaPreviewSize, _wayWrap->height()); + _wayWrap->moveToLeft( + st::boxPhotoPadding.left(), + st::boxPhotoPadding.top() + _thumbh); + } + _field->resize(st::sendMediaPreviewSize, _field->height()); _field->moveToLeft(st::boxPhotoPadding.left(), height() - st::normalFont->height - errorTopSkip() - _field->height()); _emojiToggle->moveToLeft( @@ -620,7 +649,7 @@ void EditCaptionBox::save() { Auth().api().editMedia( std::move(_preparedList), - _isImage ? SendMediaType::Photo : SendMediaType::File, + (!_asFile && _isImage) ? SendMediaType::Photo : SendMediaType::File, _field->getTextWithAppliedMarkdown(), ApiWrap::SendOptions(item->history())); closeBox(); diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.h b/Telegram/SourceFiles/boxes/edit_caption_box.h index 195c75d1a..e1e3c921d 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.h +++ b/Telegram/SourceFiles/boxes/edit_caption_box.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" #include "storage/storage_media_prepare.h" +#include "ui/wrap/slide_wrap.h" namespace ChatHelpers { class TabbedPanel; @@ -25,6 +26,7 @@ class Media; namespace Ui { class InputField; class EmojiButton; +class Checkbox; } // namespace Ui namespace Window { @@ -99,6 +101,8 @@ private: bool _previewCancelled = false; mtpRequestId _saveRequestId = 0; + bool _asFile = false; + Ui::SlideWrap *_wayWrap = nullptr; QString _newMediaPath; QString _error;