From 621ead5280249b2f236f6df088c5254a6d270e42 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 28 Mar 2010 15:59:45 +0000 Subject: [PATCH] IconMargin is useful only to give good proportion when there is text, when there isn't we want the whole size to be really precise with size calculations svn path=/trunk/KDE/kdelibs/; revision=1108320 --- widgets/iconwidget.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/widgets/iconwidget.cpp b/widgets/iconwidget.cpp index 7b8403053..6f346be6d 100644 --- a/widgets/iconwidget.cpp +++ b/widgets/iconwidget.cpp @@ -587,14 +587,18 @@ void IconWidgetPrivate::layoutIcons(const QStyleOptionGraphicsItem *option) } //aspect ratio very "tall" - if (currentSize.width() < heightAvail) { - iconWidth = currentSize.width() - - horizontalMargin[IconWidgetPrivate::IconMargin].left - - horizontalMargin[IconWidgetPrivate::IconMargin].right; + if (!text.isEmpty() || !infoText.isEmpty()) { + if (currentSize.width() < heightAvail) { + iconWidth = currentSize.width() - + horizontalMargin[IconWidgetPrivate::IconMargin].left - + horizontalMargin[IconWidgetPrivate::IconMargin].right; + } else { + iconWidth = heightAvail - + verticalMargin[IconWidgetPrivate::IconMargin].top - + verticalMargin[IconWidgetPrivate::IconMargin].bottom; + } } else { - iconWidth = heightAvail - - verticalMargin[IconWidgetPrivate::IconMargin].top - - verticalMargin[IconWidgetPrivate::IconMargin].bottom; + iconWidth = qMin(heightAvail, currentSize.width()); } iconWidth -= horizontalMargin[IconWidgetPrivate::ItemMargin].left + horizontalMargin[IconWidgetPrivate::ItemMargin].right; } else { @@ -602,12 +606,7 @@ void IconWidgetPrivate::layoutIcons(const QStyleOptionGraphicsItem *option) //if there is text resize the icon in order to make room for the text if (text.isEmpty() && infoText.isEmpty()) { // with no text, we just take up the whole geometry - iconWidth = qMin(currentSize.height() - - horizontalMargin[IconWidgetPrivate::IconMargin].left - - horizontalMargin[IconWidgetPrivate::IconMargin].right, - currentSize.width() - - horizontalMargin[IconWidgetPrivate::IconMargin].left - - horizontalMargin[IconWidgetPrivate::IconMargin].right); + iconWidth = qMin(currentSize.height(), currentSize.width()); } else { iconWidth = currentSize.height() - verticalMargin[IconWidgetPrivate::IconMargin].top -