feat: restore caption from send files box

This commit is contained in:
AlexeyZavar 2025-05-19 00:59:23 +03:00
parent 353e9adec1
commit 631f5a1043
6 changed files with 20 additions and 6 deletions

View file

@ -482,7 +482,8 @@ SendFilesBox::SendFilesBox(
const TextWithTags &caption, const TextWithTags &caption,
not_null<PeerData*> toPeer, not_null<PeerData*> toPeer,
Api::SendType sendType, Api::SendType sendType,
SendMenu::Details sendMenuDetails) SendMenu::Details sendMenuDetails,
Fn<void(const TextWithTags &text)> cancelled2)
: SendFilesBox(nullptr, { : SendFilesBox(nullptr, {
.show = controller->uiShow(), .show = controller->uiShow(),
.list = std::move(list), .list = std::move(list),
@ -492,6 +493,7 @@ SendFilesBox::SendFilesBox(
.check = DefaultCheckForPeer(controller, toPeer), .check = DefaultCheckForPeer(controller, toPeer),
.sendType = sendType, .sendType = sendType,
.sendMenuDetails = [=] { return sendMenuDetails; }, .sendMenuDetails = [=] { return sendMenuDetails; },
.cancelled2 = cancelled2,
}) { }) {
} }
@ -510,6 +512,7 @@ SendFilesBox::SendFilesBox(QWidget*, SendFilesBoxDescriptor &&descriptor)
, _check(std::move(descriptor.check)) , _check(std::move(descriptor.check))
, _confirmedCallback(std::move(descriptor.confirmed)) , _confirmedCallback(std::move(descriptor.confirmed))
, _cancelledCallback(std::move(descriptor.cancelled)) , _cancelledCallback(std::move(descriptor.cancelled))
, _cancelled2Callback(std::move(descriptor.cancelled2))
, _caption(this, _st.files.caption, Ui::InputField::Mode::MultiLine) , _caption(this, _st.files.caption, Ui::InputField::Mode::MultiLine)
, _prefilledCaptionText(std::move(descriptor.caption)) , _prefilledCaptionText(std::move(descriptor.caption))
, _scroll(this, st::boxScroll) , _scroll(this, st::boxScroll)
@ -631,6 +634,10 @@ void SendFilesBox::prepare() {
if (!_confirmed && _cancelledCallback) { if (!_confirmed && _cancelledCallback) {
_cancelledCallback(); _cancelledCallback();
} }
auto text = _caption->getTextWithAppliedMarkdown();
if (!_confirmed && _cancelled2Callback && !text.empty()) {
_cancelled2Callback(std::move(text));
}
}, lifetime()); }, lifetime());
setupDragArea(); setupDragArea();

View file

@ -102,6 +102,7 @@ struct SendFilesBoxDescriptor {
const style::ComposeControls *stOverride = nullptr; const style::ComposeControls *stOverride = nullptr;
SendFilesConfirmed confirmed; SendFilesConfirmed confirmed;
Fn<void()> cancelled; Fn<void()> cancelled;
Fn<void(const TextWithTags &text)> cancelled2;
}; };
class SendFilesBox : public Ui::BoxContent { class SendFilesBox : public Ui::BoxContent {
@ -117,7 +118,8 @@ public:
const TextWithTags &caption, const TextWithTags &caption,
not_null<PeerData*> toPeer, not_null<PeerData*> toPeer,
Api::SendType sendType, Api::SendType sendType,
SendMenu::Details sendMenuDetails); SendMenu::Details sendMenuDetails,
Fn<void(const TextWithTags &text)> cancelled2 = nullptr);
SendFilesBox(QWidget*, SendFilesBoxDescriptor &&descriptor); SendFilesBox(QWidget*, SendFilesBoxDescriptor &&descriptor);
void setConfirmedCallback(SendFilesConfirmed callback) { void setConfirmedCallback(SendFilesConfirmed callback) {
@ -272,6 +274,7 @@ private:
SendFilesCheck _check; SendFilesCheck _check;
SendFilesConfirmed _confirmedCallback; SendFilesConfirmed _confirmedCallback;
Fn<void()> _cancelledCallback; Fn<void()> _cancelledCallback;
Fn<void(const TextWithTags &text)> _cancelled2Callback;
rpl::variable<uint64> _price = 0; rpl::variable<uint64> _price = 0;
std::unique_ptr<Ui::RpWidget> _priceTag; std::unique_ptr<Ui::RpWidget> _priceTag;
QImage _priceTagBg; QImage _priceTagBg;

View file

@ -6264,7 +6264,8 @@ bool HistoryWidget::confirmSendingFiles(
text, text,
_peer, _peer,
Api::SendType::Normal, Api::SendType::Normal,
sendMenuDetails()); sendMenuDetails(),
[=](const TextWithTags &text) { _field->setTextWithTags(text); });
_field->setTextWithTags({}); _field->setTextWithTags({});
box->setConfirmedCallback(crl::guard(this, [=]( box->setConfirmedCallback(crl::guard(this, [=](
Ui::PreparedList &&list, Ui::PreparedList &&list,

View file

@ -1085,7 +1085,8 @@ bool RepliesWidget::confirmSendingFiles(
_composeControls->getTextWithAppliedMarkdown(), _composeControls->getTextWithAppliedMarkdown(),
_history->peer, _history->peer,
Api::SendType::Normal, Api::SendType::Normal,
sendMenuDetails()); sendMenuDetails(),
[=](const TextWithTags &text) { _composeControls->setText(text); });
box->setConfirmedCallback(crl::guard(this, [=]( box->setConfirmedCallback(crl::guard(this, [=](
Ui::PreparedList &&list, Ui::PreparedList &&list,

View file

@ -572,7 +572,8 @@ bool ScheduledWidget::confirmSendingFiles(
(CanScheduleUntilOnline(_history->peer) (CanScheduleUntilOnline(_history->peer)
? Api::SendType::ScheduledToUser ? Api::SendType::ScheduledToUser
: Api::SendType::Scheduled), : Api::SendType::Scheduled),
SendMenu::Details()); SendMenu::Details(),
[=](const TextWithTags &text) { _composeControls->setText(text); });
box->setConfirmedCallback(crl::guard(this, [=]( box->setConfirmedCallback(crl::guard(this, [=](
Ui::PreparedList &&list, Ui::PreparedList &&list,

View file

@ -1353,7 +1353,8 @@ bool ShortcutMessages::confirmSendingFiles(
_composeControls->getTextWithAppliedMarkdown(), _composeControls->getTextWithAppliedMarkdown(),
_history->peer, _history->peer,
Api::SendType::Normal, Api::SendType::Normal,
SendMenu::Details()); SendMenu::Details(),
[=](const TextWithTags &text) { _composeControls->setText(text); });
box->setConfirmedCallback(crl::guard(this, [=]( box->setConfirmedCallback(crl::guard(this, [=](
Ui::PreparedList &&list, Ui::PreparedList &&list,