mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02: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:
parent
1ce66e5198
commit
3dc73417e9
2 changed files with 24 additions and 11 deletions
|
@ -101,6 +101,11 @@ Ui::AlbumType ComputeAlbumType(not_null<HistoryItem*> item) {
|
||||||
return Ui::AlbumType();
|
return Ui::AlbumType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CanBeCompressed(Ui::AlbumType type) {
|
||||||
|
return (type == Ui::AlbumType::None)
|
||||||
|
|| (type == Ui::AlbumType::PhotoVideo);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
EditCaptionBox::EditCaptionBox(
|
EditCaptionBox::EditCaptionBox(
|
||||||
|
@ -170,7 +175,7 @@ void EditCaptionBox::rebuildPreview() {
|
||||||
const auto photo = media->photo();
|
const auto photo = media->photo();
|
||||||
const auto document = media->document();
|
const auto document = media->document();
|
||||||
if (photo || document->isVideoFile() || document->isAnimation()) {
|
if (photo || document->isVideoFile() || document->isAnimation()) {
|
||||||
_isPhoto = true;
|
_isPhoto = (photo != nullptr);
|
||||||
const auto media = Ui::CreateChild<Ui::ItemSingleMediaPreview>(
|
const auto media = Ui::CreateChild<Ui::ItemSingleMediaPreview>(
|
||||||
this,
|
this,
|
||||||
gifPaused,
|
gifPaused,
|
||||||
|
@ -230,6 +235,8 @@ void EditCaptionBox::rebuildPreview() {
|
||||||
_scroll->setOwnedWidget(
|
_scroll->setOwnedWidget(
|
||||||
object_ptr<Ui::RpWidget>::fromRaw(_content.get()));
|
object_ptr<Ui::RpWidget>::fromRaw(_content.get()));
|
||||||
|
|
||||||
|
_previewRebuilds.fire({});
|
||||||
|
|
||||||
captionResized();
|
captionResized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,10 +309,11 @@ void EditCaptionBox::setupShadows() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditCaptionBox::setupControls() {
|
void EditCaptionBox::setupControls() {
|
||||||
auto hintLabelToggleOn = _isPhoto.value(
|
auto hintLabelToggleOn = _previewRebuilds.events_starting_with(
|
||||||
) | rpl::map([=](bool value) {
|
rpl::empty_value()
|
||||||
|
) | rpl::map([=] {
|
||||||
return _controller->session().settings().photoEditorHintShown()
|
return _controller->session().settings().photoEditorHintShown()
|
||||||
? value
|
? _isPhoto
|
||||||
: false;
|
: false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -327,9 +335,12 @@ void EditCaptionBox::setupControls() {
|
||||||
st::defaultBoxCheckbox),
|
st::defaultBoxCheckbox),
|
||||||
st::editMediaCheckboxMargins)
|
st::editMediaCheckboxMargins)
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
_isPhoto.value(
|
_previewRebuilds.events_starting_with(
|
||||||
) | rpl::map([=](bool value) {
|
rpl::empty_value()
|
||||||
return value && (_albumType == Ui::AlbumType::None);
|
) | rpl::map([=] {
|
||||||
|
return _isPhoto
|
||||||
|
&& CanBeCompressed(_albumType)
|
||||||
|
&& !_preparedList.files.empty();
|
||||||
}),
|
}),
|
||||||
anim::type::instant
|
anim::type::instant
|
||||||
)->entity()->checkedChanges(
|
)->entity()->checkedChanges(
|
||||||
|
@ -610,6 +621,7 @@ void EditCaptionBox::resizeEvent(QResizeEvent *e) {
|
||||||
_emojiToggle->update();
|
_emojiToggle->update();
|
||||||
|
|
||||||
if (!_controls->isHidden()) {
|
if (!_controls->isHidden()) {
|
||||||
|
_controls->resizeToWidth(width());
|
||||||
_controls->moveToLeft(
|
_controls->moveToLeft(
|
||||||
st::boxPhotoPadding.left(),
|
st::boxPhotoPadding.left(),
|
||||||
bottom - _controls->heightNoMargins());
|
bottom - _controls->heightNoMargins());
|
||||||
|
@ -661,7 +673,7 @@ void EditCaptionBox::save() {
|
||||||
|
|
||||||
_controller->session().api().editMedia(
|
_controller->session().api().editMedia(
|
||||||
std::move(_preparedList),
|
std::move(_preparedList),
|
||||||
(!_asFile && _isPhoto.current())
|
(!_asFile && _isPhoto && CanBeCompressed(_albumType))
|
||||||
? SendMediaType::Photo
|
? SendMediaType::Photo
|
||||||
: SendMediaType::File,
|
: SendMediaType::File,
|
||||||
_field->getTextWithAppliedMarkdown(),
|
_field->getTextWithAppliedMarkdown(),
|
||||||
|
|
|
@ -74,14 +74,14 @@ private:
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
const not_null<HistoryItem*> _historyItem;
|
const not_null<HistoryItem*> _historyItem;
|
||||||
const bool _isAllowedEditMedia = false;
|
const bool _isAllowedEditMedia;
|
||||||
const Ui::AlbumType _albumType;
|
const Ui::AlbumType _albumType;
|
||||||
|
|
||||||
const base::unique_qptr<Ui::VerticalLayout> _controls;
|
const base::unique_qptr<Ui::VerticalLayout> _controls;
|
||||||
const base::unique_qptr<Ui::ScrollArea> _scroll;
|
const base::unique_qptr<Ui::ScrollArea> _scroll;
|
||||||
const base::unique_qptr<Ui::InputField> _field;
|
const base::unique_qptr<Ui::InputField> _field;
|
||||||
const base::unique_qptr<Ui::EmojiButton> _emojiToggle;
|
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<Ui::AbstractSinglePreview> _content;
|
||||||
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
||||||
|
@ -93,15 +93,16 @@ private:
|
||||||
|
|
||||||
mtpRequestId _saveRequestId = 0;
|
mtpRequestId _saveRequestId = 0;
|
||||||
|
|
||||||
|
bool _isPhoto = false;
|
||||||
bool _asFile = false;
|
bool _asFile = false;
|
||||||
|
|
||||||
QString _error;
|
QString _error;
|
||||||
|
|
||||||
rpl::variable<bool> _isPhoto = false;
|
|
||||||
rpl::variable<int> _footerHeight = 0;
|
rpl::variable<int> _footerHeight = 0;
|
||||||
|
|
||||||
rpl::event_stream<> _editMediaClicks;
|
rpl::event_stream<> _editMediaClicks;
|
||||||
rpl::event_stream<> _photoEditorOpens;
|
rpl::event_stream<> _photoEditorOpens;
|
||||||
|
rpl::event_stream<> _previewRebuilds;
|
||||||
rpl::event_stream<int> _contentHeight;
|
rpl::event_stream<int> _contentHeight;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue