Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX(client): Limit size of the chat bar #6578

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/mumble/CustomElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ChatbarTextEdit::ChatbarTextEdit(QWidget *p) : QTextEdit(p), iHistoryIndex(-1) {
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setMinimumHeight(0);
connect(this, SIGNAL(textChanged()), SLOT(doResize()));
connect(this, &ChatbarTextEdit::textChanged, this, &ChatbarTextEdit::doResize);

bDefaultVisible = true;
setDefaultText(tr("<center>Type chat message here</center>"));
Expand All @@ -121,10 +121,12 @@ QSize ChatbarTextEdit::minimumSizeHint() const {
}

QSize ChatbarTextEdit::sizeHint() const {
QSize sh = QTextEdit::sizeHint();
const int minHeight = minimumSizeHint().height();
const int documentHeight = static_cast< int >(document()->documentLayout()->documentSize().height());
sh.setHeight(std::max(minHeight, documentHeight));
QSize sh = QTextEdit::sizeHint();
const int minHeight = minimumSizeHint().height();
const int documentHeight = static_cast< int >(document()->documentLayout()->documentSize().height());
const int chatBarLineHeight = QFontMetrics(ChatbarTextEdit::font()).height();

sh.setHeight(std::max(minHeight, std::min(chatBarLineHeight * 10, documentHeight)));
const_cast< ChatbarTextEdit * >(this)->setMaximumHeight(sh.height());
return sh;
}
Expand All @@ -144,7 +146,8 @@ void ChatbarTextEdit::doResize() {
}

void ChatbarTextEdit::doScrollbar() {
setVerticalScrollBarPolicy(sizeHint().height() > height() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
const int documentHeight = static_cast< int >(document()->documentLayout()->documentSize().height());
setVerticalScrollBarPolicy(documentHeight > height() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
ensureCursorVisible();
}

Expand Down