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
This commit is contained in:
Marco Martin 2010-03-28 15:59:45 +00:00
parent 2f8e70b7ab
commit 621ead5280

View File

@ -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 -