mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-30 05:06:14 -05:00
Restructure "src/" folder
Moving files from the "src/" folder into "src/legacy", "src/macro-core", and "src/utils" was necessary as it was becoming a bit too cluttered.
This commit is contained in:
31
src/utils/resizing-text-edit.cpp
Normal file
31
src/utils/resizing-text-edit.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "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();
|
||||
}
|
||||
Reference in New Issue
Block a user