mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Fixed some bugs in EditCaptionBox.
Fixed checkbox display in some cases.
Fixed editing of album items.
Regression was introduced in 7e83088a84
.
This commit is contained in:
@@ -101,6 +101,11 @@ Ui::AlbumType ComputeAlbumType(not_null<HistoryItem*> item) {
|
||||
return Ui::AlbumType();
|
||||
}
|
||||
|
||||
bool CanBeCompressed(Ui::AlbumType type) {
|
||||
return (type == Ui::AlbumType::None)
|
||||
|| (type == Ui::AlbumType::PhotoVideo);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EditCaptionBox::EditCaptionBox(
|
||||
@@ -170,7 +175,7 @@ void EditCaptionBox::rebuildPreview() {
|
||||
const auto photo = media->photo();
|
||||
const auto document = media->document();
|
||||
if (photo || document->isVideoFile() || document->isAnimation()) {
|
||||
_isPhoto = true;
|
||||
_isPhoto = (photo != nullptr);
|
||||
const auto media = Ui::CreateChild<Ui::ItemSingleMediaPreview>(
|
||||
this,
|
||||
gifPaused,
|
||||
@@ -230,6 +235,8 @@ void EditCaptionBox::rebuildPreview() {
|
||||
_scroll->setOwnedWidget(
|
||||
object_ptr<Ui::RpWidget>::fromRaw(_content.get()));
|
||||
|
||||
_previewRebuilds.fire({});
|
||||
|
||||
captionResized();
|
||||
}
|
||||
|
||||
@@ -302,10 +309,11 @@ void EditCaptionBox::setupShadows() {
|
||||
}
|
||||
|
||||
void EditCaptionBox::setupControls() {
|
||||
auto hintLabelToggleOn = _isPhoto.value(
|
||||
) | rpl::map([=](bool value) {
|
||||
auto hintLabelToggleOn = _previewRebuilds.events_starting_with(
|
||||
rpl::empty_value()
|
||||
) | rpl::map([=] {
|
||||
return _controller->session().settings().photoEditorHintShown()
|
||||
? value
|
||||
? _isPhoto
|
||||
: false;
|
||||
});
|
||||
|
||||
@@ -327,9 +335,12 @@ void EditCaptionBox::setupControls() {
|
||||
st::defaultBoxCheckbox),
|
||||
st::editMediaCheckboxMargins)
|
||||
)->toggleOn(
|
||||
_isPhoto.value(
|
||||
) | rpl::map([=](bool value) {
|
||||
return value && (_albumType == Ui::AlbumType::None);
|
||||
_previewRebuilds.events_starting_with(
|
||||
rpl::empty_value()
|
||||
) | rpl::map([=] {
|
||||
return _isPhoto
|
||||
&& CanBeCompressed(_albumType)
|
||||
&& !_preparedList.files.empty();
|
||||
}),
|
||||
anim::type::instant
|
||||
)->entity()->checkedChanges(
|
||||
@@ -610,6 +621,7 @@ void EditCaptionBox::resizeEvent(QResizeEvent *e) {
|
||||
_emojiToggle->update();
|
||||
|
||||
if (!_controls->isHidden()) {
|
||||
_controls->resizeToWidth(width());
|
||||
_controls->moveToLeft(
|
||||
st::boxPhotoPadding.left(),
|
||||
bottom - _controls->heightNoMargins());
|
||||
@@ -661,7 +673,7 @@ void EditCaptionBox::save() {
|
||||
|
||||
_controller->session().api().editMedia(
|
||||
std::move(_preparedList),
|
||||
(!_asFile && _isPhoto.current())
|
||||
(!_asFile && _isPhoto && CanBeCompressed(_albumType))
|
||||
? SendMediaType::Photo
|
||||
: SendMediaType::File,
|
||||
_field->getTextWithAppliedMarkdown(),
|
||||
|
@@ -74,14 +74,14 @@ private:
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
const not_null<HistoryItem*> _historyItem;
|
||||
const bool _isAllowedEditMedia = false;
|
||||
const bool _isAllowedEditMedia;
|
||||
const Ui::AlbumType _albumType;
|
||||
|
||||
const base::unique_qptr<Ui::VerticalLayout> _controls;
|
||||
const base::unique_qptr<Ui::ScrollArea> _scroll;
|
||||
const base::unique_qptr<Ui::InputField> _field;
|
||||
const base::unique_qptr<Ui::EmojiButton> _emojiToggle;
|
||||
const base::unique_qptr<Ui::FadeShadow> _topShadow,_bottomShadow;
|
||||
const base::unique_qptr<Ui::FadeShadow> _topShadow, _bottomShadow;
|
||||
|
||||
base::unique_qptr<Ui::AbstractSinglePreview> _content;
|
||||
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
||||
@@ -93,15 +93,16 @@ private:
|
||||
|
||||
mtpRequestId _saveRequestId = 0;
|
||||
|
||||
bool _isPhoto = false;
|
||||
bool _asFile = false;
|
||||
|
||||
QString _error;
|
||||
|
||||
rpl::variable<bool> _isPhoto = false;
|
||||
rpl::variable<int> _footerHeight = 0;
|
||||
|
||||
rpl::event_stream<> _editMediaClicks;
|
||||
rpl::event_stream<> _photoEditorOpens;
|
||||
rpl::event_stream<> _previewRebuilds;
|
||||
rpl::event_stream<int> _contentHeight;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user