Fixed caption area height in EditCaptionBox.

Regression was introduced in 51f960442e.
This commit is contained in:
23rd 2021-04-22 23:39:41 +03:00
parent 22213a71c1
commit 5bd17ae1b2
3 changed files with 26 additions and 0 deletions

View File

@ -382,6 +382,7 @@ confirmCaptionArea: InputField(defaultInputField) {
textMargins: margins(1px, 26px, 31px, 4px);
heightMax: 158px;
}
confirmEditCaptionAreaHeightMax: 78px;
confirmBg: windowBgOver;
confirmMaxHeight: 245px;
confirmMaxHeightSkip: 25px;

View File

@ -660,6 +660,7 @@ void EditCaptionBox::updateEditPreview() {
}
}
updateEditMediaButton();
updateCaptionMaxHeight();
captionResized();
}
@ -783,6 +784,7 @@ void EditCaptionBox::prepare() {
auto cursor = _field->textCursor();
cursor.movePosition(QTextCursor::End);
_field->setTextCursor(cursor);
updateCaptionMaxHeight();
setupDragArea();
}
@ -826,6 +828,28 @@ void EditCaptionBox::captionResized() {
update();
}
void EditCaptionBox::updateCaptionMaxHeight() {
// Save.
const auto wasCursor = _field->textCursor();
const auto position = wasCursor.position();
const auto anchor = wasCursor.anchor();
const auto text = _field->getTextWithAppliedMarkdown();
_field->setTextWithTags({});
_field->setMaxHeight(_doc
? st::confirmCaptionArea.heightMax
: st::confirmEditCaptionAreaHeightMax);
// Restore.
_field->setTextWithTags(text);
auto cursor = _field->textCursor();
cursor.setPosition(anchor);
if (position != anchor) {
cursor.setPosition(position, QTextCursor::KeepAnchor);
}
_field->setTextCursor(cursor);
}
void EditCaptionBox::setupEmojiPanel() {
const auto container = getDelegate()->outerContainer();
_emojiPanel = base::make_unique_q<ChatHelpers::TabbedPanel>(

View File

@ -91,6 +91,7 @@ private:
bool fileFromClipboard(not_null<const QMimeData*> data);
void updateEditPreview();
void updateEditMediaButton();
void updateCaptionMaxHeight();
int errorTopSkip() const;