Reduce text edit areas size of file, filter, source, transform segments

This commit is contained in:
WarmUpTill
2022-02-26 15:48:18 +01:00
committed by WarmUpTill
parent 6fb8297275
commit 1cfd981245
19 changed files with 102 additions and 26 deletions

View File

@@ -0,0 +1,31 @@
#include "headers/resizing-text-edit.hpp"
ResizingPlainTextEdit::ResizingPlainTextEdit(QWidget *parent,
const int scrollAt,
const int minLines,
const int paddingLines)
: QPlainTextEdit(parent),
_scrollAt(scrollAt),
_minLines(minLines),
_paddingLines(paddingLines)
{
QWidget::connect(this, SIGNAL(textChanged()), this,
SLOT(ResizeTexteditArea()));
}
void ResizingPlainTextEdit::ResizeTexteditArea()
{
QFontMetrics f(font());
int rowHeight = f.lineSpacing();
int numLines = document()->blockCount();
if (numLines + _paddingLines < _minLines) {
setFixedHeight(_minLines * rowHeight);
} else if (numLines + _paddingLines < _scrollAt) {
setFixedHeight((numLines + _paddingLines) * rowHeight);
} else {
setFixedHeight(_scrollAt * rowHeight);
}
adjustSize();
updateGeometry();
}