mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -05:00
Apply max length limit to initial text.
This commit is contained in:
parent
07d8dafa5e
commit
7252e9b266
1 changed files with 17 additions and 1 deletions
|
@ -1217,7 +1217,23 @@ void InputField::setAdditionalMargin(int margin) {
|
|||
}
|
||||
|
||||
void InputField::setMaxLength(int length) {
|
||||
_maxLength = length;
|
||||
if (_maxLength != length) {
|
||||
_maxLength = length;
|
||||
if (_maxLength > 0) {
|
||||
const auto document = _inner->document();
|
||||
_correcting = true;
|
||||
QTextCursor(document->docHandle(), 0).joinPreviousEditBlock();
|
||||
const auto guard = gsl::finally([&] {
|
||||
_correcting = false;
|
||||
QTextCursor(document->docHandle(), 0).endEditBlock();
|
||||
handleContentsChanged();
|
||||
});
|
||||
|
||||
auto cursor = QTextCursor(document->docHandle(), 0);
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
chopByMaxLength(0, cursor.position());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputField::setMinHeight(int height) {
|
||||
|
|
Loading…
Add table
Reference in a new issue