From kde-commits Tue Jan 29 09:48:15 2008 From: Andras Mantia Date: Tue, 29 Jan 2008 09:48:15 +0000 To: kde-commits Subject: branches/KDE/4.0/kdelibs/kdeui/widgets Message-Id: <1201600095.837343.26862.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=120160010523598 SVN commit 768072 by amantia: Backport the KSqueezedTextLabel width fix. M +9 -1 ksqueezedtextlabel.cpp --- branches/KDE/4.0/kdelibs/kdeui/widgets/ksqueezedtextlabel.cpp #768071:768072 @@ -18,6 +18,8 @@ #include "ksqueezedtextlabel.h" +#include + class KSqueezedTextLabelPrivate { public: @@ -61,7 +63,13 @@ QSize KSqueezedTextLabel::sizeHint() const { - return QSize(contentsRect().width(), QLabel::sizeHint().height()); + int maxWidth = KGlobalSettings::desktopGeometry( this ).width() * 3 / 4; + QFontMetrics fm(fontMetrics()); + int textWidth = fm.width(d->fullText); + if (textWidth > maxWidth) { + textWidth = maxWidth; + } + return QSize(textWidth, QLabel::sizeHint().height()); } void KSqueezedTextLabel::setText( const QString &text ) {