mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed clearing of text field in sections when sending files.
This commit is contained in:
parent
e85394b520
commit
bff3291631
4 changed files with 31 additions and 36 deletions
|
@ -2373,4 +2373,27 @@ void ComposeControls::applyInlineBotQuery(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fn<void()> ComposeControls::restoreTextCallback(
|
||||||
|
const QString &insertTextOnCancel) const {
|
||||||
|
const auto cursor = _field->textCursor();
|
||||||
|
const auto position = cursor.position();
|
||||||
|
const auto anchor = cursor.anchor();
|
||||||
|
const auto text = getTextWithAppliedMarkdown();
|
||||||
|
|
||||||
|
_field->setTextWithTags({});
|
||||||
|
|
||||||
|
return crl::guard(_field, [=] {
|
||||||
|
_field->setTextWithTags(text);
|
||||||
|
auto cursor = _field->textCursor();
|
||||||
|
cursor.setPosition(anchor);
|
||||||
|
if (position != anchor) {
|
||||||
|
cursor.setPosition(position, QTextCursor::KeepAnchor);
|
||||||
|
}
|
||||||
|
_field->setTextCursor(cursor);
|
||||||
|
if (!insertTextOnCancel.isEmpty()) {
|
||||||
|
_field->textCursor().insertText(insertTextOnCancel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -172,6 +172,8 @@ public:
|
||||||
void applyDraft(
|
void applyDraft(
|
||||||
FieldHistoryAction fieldHistoryAction = FieldHistoryAction::Clear);
|
FieldHistoryAction fieldHistoryAction = FieldHistoryAction::Clear);
|
||||||
|
|
||||||
|
Fn<void()> restoreTextCallback(const QString &insertTextOnCancel) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class TextUpdateEvent {
|
enum class TextUpdateEvent {
|
||||||
SaveDraft = (1 << 0),
|
SaveDraft = (1 << 0),
|
||||||
|
|
|
@ -626,19 +626,14 @@ bool RepliesWidget::confirmSendingFiles(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//const auto cursor = _field->textCursor();
|
|
||||||
//const auto position = cursor.position();
|
|
||||||
//const auto anchor = cursor.anchor();
|
|
||||||
const auto text = _composeControls->getTextWithAppliedMarkdown();//_field->getTextWithTags();
|
|
||||||
using SendLimit = SendFilesBox::SendLimit;
|
using SendLimit = SendFilesBox::SendLimit;
|
||||||
auto box = Box<SendFilesBox>(
|
auto box = Box<SendFilesBox>(
|
||||||
controller(),
|
controller(),
|
||||||
std::move(list),
|
std::move(list),
|
||||||
text,
|
_composeControls->getTextWithAppliedMarkdown(),
|
||||||
_history->peer->slowmodeApplied() ? SendLimit::One : SendLimit::Many,
|
_history->peer->slowmodeApplied() ? SendLimit::One : SendLimit::Many,
|
||||||
Api::SendType::Normal,
|
Api::SendType::Normal,
|
||||||
SendMenu::Type::SilentOnly); // #TODO replies schedule
|
SendMenu::Type::SilentOnly); // #TODO replies schedule
|
||||||
_composeControls->setText({});
|
|
||||||
|
|
||||||
const auto replyTo = replyToId();
|
const auto replyTo = replyToId();
|
||||||
box->setConfirmedCallback(crl::guard(this, [=](
|
box->setConfirmedCallback(crl::guard(this, [=](
|
||||||
|
@ -654,18 +649,8 @@ bool RepliesWidget::confirmSendingFiles(
|
||||||
options,
|
options,
|
||||||
ctrlShiftEnter);
|
ctrlShiftEnter);
|
||||||
}));
|
}));
|
||||||
box->setCancelledCallback(crl::guard(this, [=] {
|
box->setCancelledCallback(_composeControls->restoreTextCallback(
|
||||||
_composeControls->setText(text);
|
insertTextOnCancel));
|
||||||
//auto cursor = _field->textCursor();
|
|
||||||
//cursor.setPosition(anchor);
|
|
||||||
//if (position != anchor) {
|
|
||||||
// cursor.setPosition(position, QTextCursor::KeepAnchor);
|
|
||||||
//}
|
|
||||||
//_field->setTextCursor(cursor);
|
|
||||||
//if (!insertTextOnCancel.isEmpty()) {
|
|
||||||
// _field->textCursor().insertText(insertTextOnCancel);
|
|
||||||
//}
|
|
||||||
}));
|
|
||||||
|
|
||||||
//ActivateWindow(controller());
|
//ActivateWindow(controller());
|
||||||
const auto shown = Ui::show(std::move(box));
|
const auto shown = Ui::show(std::move(box));
|
||||||
|
|
|
@ -350,21 +350,16 @@ bool ScheduledWidget::confirmSendingFiles(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//const auto cursor = _field->textCursor();
|
|
||||||
//const auto position = cursor.position();
|
|
||||||
//const auto anchor = cursor.anchor();
|
|
||||||
const auto text = _composeControls->getTextWithAppliedMarkdown();//_field->getTextWithTags();
|
|
||||||
using SendLimit = SendFilesBox::SendLimit;
|
using SendLimit = SendFilesBox::SendLimit;
|
||||||
auto box = Box<SendFilesBox>(
|
auto box = Box<SendFilesBox>(
|
||||||
controller(),
|
controller(),
|
||||||
std::move(list),
|
std::move(list),
|
||||||
text,
|
_composeControls->getTextWithAppliedMarkdown(),
|
||||||
_history->peer->slowmodeApplied() ? SendLimit::One : SendLimit::Many,
|
_history->peer->slowmodeApplied() ? SendLimit::One : SendLimit::Many,
|
||||||
CanScheduleUntilOnline(_history->peer)
|
CanScheduleUntilOnline(_history->peer)
|
||||||
? Api::SendType::ScheduledToUser
|
? Api::SendType::ScheduledToUser
|
||||||
: Api::SendType::Scheduled,
|
: Api::SendType::Scheduled,
|
||||||
SendMenu::Type::Disabled);
|
SendMenu::Type::Disabled);
|
||||||
//_field->setTextWithTags({});
|
|
||||||
|
|
||||||
box->setConfirmedCallback(crl::guard(this, [=](
|
box->setConfirmedCallback(crl::guard(this, [=](
|
||||||
Ui::PreparedList &&list,
|
Ui::PreparedList &&list,
|
||||||
|
@ -379,18 +374,8 @@ bool ScheduledWidget::confirmSendingFiles(
|
||||||
options,
|
options,
|
||||||
ctrlShiftEnter);
|
ctrlShiftEnter);
|
||||||
}));
|
}));
|
||||||
//box->setCancelledCallback(crl::guard(this, [=] {
|
box->setCancelledCallback(_composeControls->restoreTextCallback(
|
||||||
// _field->setTextWithTags(text);
|
insertTextOnCancel));
|
||||||
// auto cursor = _field->textCursor();
|
|
||||||
// cursor.setPosition(anchor);
|
|
||||||
// if (position != anchor) {
|
|
||||||
// cursor.setPosition(position, QTextCursor::KeepAnchor);
|
|
||||||
// }
|
|
||||||
// _field->setTextCursor(cursor);
|
|
||||||
// if (!insertTextOnCancel.isEmpty()) {
|
|
||||||
// _field->textCursor().insertText(insertTextOnCancel);
|
|
||||||
// }
|
|
||||||
//}));
|
|
||||||
|
|
||||||
//ActivateWindow(controller());
|
//ActivateWindow(controller());
|
||||||
const auto shown = Ui::show(std::move(box));
|
const auto shown = Ui::show(std::move(box));
|
||||||
|
|
Loading…
Add table
Reference in a new issue