mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Move message text to send media box caption field.
This commit is contained in:
parent
f35bf41d26
commit
3ac50cf77f
3 changed files with 31 additions and 17 deletions
|
@ -1320,8 +1320,15 @@ void SendFilesBox::AlbumPreview::mouseReleaseEvent(QMouseEvent *e) {
|
|||
SendFilesBox::SendFilesBox(
|
||||
QWidget*,
|
||||
Storage::PreparedList &&list,
|
||||
const TextWithTags &caption,
|
||||
CompressConfirm compressed)
|
||||
: _list(std::move(list))
|
||||
, _caption(
|
||||
this,
|
||||
st::confirmCaptionArea,
|
||||
Ui::InputField::Mode::MultiLine,
|
||||
FieldPlaceholder(_list),
|
||||
caption)
|
||||
, _compressConfirmInitial(compressed)
|
||||
, _compressConfirm(compressed) {
|
||||
}
|
||||
|
@ -1418,6 +1425,7 @@ void SendFilesBox::prepare() {
|
|||
|
||||
_send = addButton(langFactory(lng_send_button), [this] { send(); });
|
||||
addButton(langFactory(lng_cancel), [this] { closeBox(); });
|
||||
setupCaption();
|
||||
initSendWay();
|
||||
preparePreview();
|
||||
subscribe(boxClosing, [this] {
|
||||
|
@ -1489,7 +1497,7 @@ void SendFilesBox::preparePreview() {
|
|||
void SendFilesBox::setupControls() {
|
||||
setupTitleText();
|
||||
setupSendWayControls();
|
||||
setupCaption();
|
||||
_caption->setPlaceholder(FieldPlaceholder(_list));
|
||||
}
|
||||
|
||||
void SendFilesBox::setupSendWayControls() {
|
||||
|
@ -1546,23 +1554,13 @@ void SendFilesBox::applyAlbumOrder() {
|
|||
}
|
||||
|
||||
void SendFilesBox::setupCaption() {
|
||||
if (_caption) {
|
||||
_caption->setPlaceholder(FieldPlaceholder(_list));
|
||||
return;
|
||||
}
|
||||
|
||||
_caption.create(
|
||||
this,
|
||||
st::confirmCaptionArea,
|
||||
Ui::InputField::Mode::MultiLine,
|
||||
FieldPlaceholder(_list));
|
||||
_caption->setMaxLength(MaxPhotoCaption);
|
||||
_caption->setSubmitSettings(Ui::InputField::SubmitSettings::Both);
|
||||
connect(_caption, &Ui::InputField::resized, this, [this] {
|
||||
captionResized();
|
||||
});
|
||||
connect(_caption, &Ui::InputField::submitted, this, [this](
|
||||
bool ctrlShiftEnter) {
|
||||
bool ctrlShiftEnter) {
|
||||
send(ctrlShiftEnter);
|
||||
});
|
||||
connect(_caption, &Ui::InputField::cancelled, this, [this] {
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
SendFilesBox(
|
||||
QWidget*,
|
||||
Storage::PreparedList &&list,
|
||||
const TextWithTags &caption,
|
||||
CompressConfirm compressed);
|
||||
|
||||
void setConfirmedCallback(
|
||||
|
|
|
@ -4163,7 +4163,15 @@ bool HistoryWidget::confirmSendingFiles(
|
|||
? CompressConfirm::None
|
||||
: compressed;
|
||||
|
||||
auto box = Box<SendFilesBox>(std::move(list), boxCompressConfirm);
|
||||
const auto cursor = _field->textCursor();
|
||||
const auto position = cursor.position();
|
||||
const auto anchor = cursor.anchor();
|
||||
const auto text = _field->getTextWithTags();
|
||||
auto box = Box<SendFilesBox>(
|
||||
std::move(list),
|
||||
text,
|
||||
boxCompressConfirm);
|
||||
_field->setTextWithTags({});
|
||||
box->setConfirmedCallback(base::lambda_guarded(this, [=](
|
||||
Storage::PreparedList &&list,
|
||||
SendFilesWay way,
|
||||
|
@ -4185,11 +4193,18 @@ bool HistoryWidget::confirmSendingFiles(
|
|||
replyToId(),
|
||||
album);
|
||||
}));
|
||||
if (!insertTextOnCancel.isEmpty()) {
|
||||
box->setCancelledCallback(base::lambda_guarded(this, [=] {
|
||||
box->setCancelledCallback(base::lambda_guarded(this, [=] {
|
||||
_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);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
ActivateWindowDelayed(controller());
|
||||
Ui::show(std::move(box));
|
||||
|
|
Loading…
Add table
Reference in a new issue