From c1a29dfdfd500c9ee27debb00cbfec00ac1a478e Mon Sep 17 00:00:00 2001 From: Jukka Helle Date: Tue, 21 Apr 2009 02:43:04 +0300 Subject: [PATCH] Play nice with older Qt. --- src/uisupport/inputline.cpp | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/uisupport/inputline.cpp b/src/uisupport/inputline.cpp index 2973faa..f133e1c 100644 --- a/src/uisupport/inputline.cpp +++ b/src/uisupport/inputline.cpp @@ -28,7 +28,7 @@ #include "inputline.h" #include "tabcompleter.h" -const int leftMargin = 3; +const int documentMargin = 3; InputLine::InputLine(QWidget *parent) : @@ -41,9 +41,9 @@ InputLine::InputLine(QWidget *parent) tabCompleter(new TabCompleter(this)) { // Make the QTextEdit look like a QLineEdit -//#if QT_VERSION >= 0x040500 - document()->setDocumentMargin(leftMargin); // new in Qt 4.5 and we really don't want it here (except for Squider) -//#endif +#if QT_VERSION >= 0x040500 + document()->setDocumentMargin(documentMargin); // new in Qt 4.5 and we really don't want it here (except for Squider) +#endif setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setAcceptRichText(false); @@ -221,7 +221,11 @@ void InputLine::on_textChanged(QString newText) { if(lineCount > 1) { setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); QFontMetrics fm(font()); - setMinimumSize(QSize(0, lineCount * fm.lineSpacing() + 2 * frameWidth() + 2 * leftMargin)); + int h = lineCount * fm.lineSpacing() + 2 * frameWidth(); +# if QT_VERSION >= 0x040500 + h += 2 * documentMargin; +# endif + setMinimumSize(QSize(0, h)); } else { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setMinimumSize(QSize(0, 0)); -- 1.6.1.9.g97c34