┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Paul St James <[email protected]>2008-08-18 20:25:52 +0000
committerSimon Paul St James <[email protected]>2008-08-18 20:25:52 +0000
commit58efff7c2c568a1f4b9713a0cae925b6f4a52bfd (patch)
treefe33af15994bf2cb56e9c49cf5b4d5bcea6f826e /src
parent10468b1c06a5852b006331b91e066bad75278b2e (diff)
Deal with the case where the icon might be taller than the text. Approved by fredrik.
svn path=/trunk/KDE/kdebase/apps/; revision=848980
Diffstat (limited to 'src')
-rw-r--r--src/kformattedballoontipdelegate.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/kformattedballoontipdelegate.cpp b/src/kformattedballoontipdelegate.cpp
index 833f612f1..5df695ba6 100644
--- a/src/kformattedballoontipdelegate.cpp
+++ b/src/kformattedballoontipdelegate.cpp
@@ -21,14 +21,22 @@
#include "kformattedballoontipdelegate.h"
#include <QBitmap>
#include <QTextDocument>
+#include <kdebug.h>
QSize KFormattedBalloonTipDelegate::sizeHint(const KStyleOptionToolTip *option, const KToolTipItem *item) const
{
QTextDocument doc;
doc.setHtml(item->text());
QIcon icon = item->icon();
- QSize is = (icon.isNull()) ? QSize(0,0) : QSize(icon.actualSize(option->decorationSize).width(),0);
- return doc.size().toSize()+is+QSize(20+5,20+1);
+
+ QSize iconSize = (icon.isNull()) ? QSize(0,0) : icon.actualSize(option->decorationSize);
+ QSize docSize = doc.size().toSize();
+ QSize contentSize = iconSize + docSize;
+
+ // Re-adjust contentSize's height so that it is the maximum of the icon
+ // and doc sizes.
+ contentSize.setHeight( iconSize.height() > doc.size().height() ? iconSize.height() : doc.size().height());
+ return contentSize + QSize(20+5,20+1);
}
void KFormattedBalloonTipDelegate::paint(QPainter *painter, const KStyleOptionToolTip *option, const KToolTipItem *item) const
@@ -62,6 +70,9 @@ void KFormattedBalloonTipDelegate::paint(QPainter *painter, const KStyleOptionTo
bitmap.fill(Qt::transparent);
QPainter p(&bitmap);
doc.drawContents(&p);
+
+ // Ensure doc text is not stretched when icon is larger.
+ contents.setSize(doc.size().toSize());
painter->drawPixmap(contents, bitmap);
}