From 54859f64709f297b97bb48367759479d58f991fe Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Fri, 20 Aug 2010 16:27:36 +0100
Subject: Don't temporarily show a scrollbar in chat input after growing.

Resolves; #527

diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index 9811bb2..3668220 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -49,8 +49,11 @@ void QtTextEdit::handleTextChanged() {
 
 QSize QtTextEdit::sizeHint() const {
 	QFontMetrics inputMetrics(currentFont());
-	QRect boundingRect = inputMetrics.boundingRect(geometry(), Qt::TextWordWrap, toPlainText());
-	int height = boundingRect.height() + inputMetrics.height();
+	QRect horizontalBounds = contentsRect().adjusted(0,0,0,9999);
+	QRect boundingRect = inputMetrics.boundingRect(horizontalBounds, Qt::TextWordWrap, toPlainText() + "A");
+	int left, top, right, bottom;
+	getContentsMargins(&left, &top, &right, &bottom);
+	int height = boundingRect.height() + top + bottom + inputMetrics.height();
 	return QSize(width(), height);
 	//int numberOfLines = 1;
 	//int lineHeight = inputMetrics.lineSpacing();
-- 
cgit v0.10.2-6-g49f6