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" //aspect ratio very "tall"
if (currentSize.width() < heightAvail) { if (!text.isEmpty() || !infoText.isEmpty()) {
iconWidth = currentSize.width() - if (currentSize.width() < heightAvail) {
horizontalMargin[IconWidgetPrivate::IconMargin].left - iconWidth = currentSize.width() -
horizontalMargin[IconWidgetPrivate::IconMargin].right; horizontalMargin[IconWidgetPrivate::IconMargin].left -
horizontalMargin[IconWidgetPrivate::IconMargin].right;
} else {
iconWidth = heightAvail -
verticalMargin[IconWidgetPrivate::IconMargin].top -
verticalMargin[IconWidgetPrivate::IconMargin].bottom;
}
} else { } else {
iconWidth = heightAvail - iconWidth = qMin(heightAvail, currentSize.width());
verticalMargin[IconWidgetPrivate::IconMargin].top -
verticalMargin[IconWidgetPrivate::IconMargin].bottom;
} }
iconWidth -= horizontalMargin[IconWidgetPrivate::ItemMargin].left + horizontalMargin[IconWidgetPrivate::ItemMargin].right; iconWidth -= horizontalMargin[IconWidgetPrivate::ItemMargin].left + horizontalMargin[IconWidgetPrivate::ItemMargin].right;
} else { } 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 there is text resize the icon in order to make room for the text
if (text.isEmpty() && infoText.isEmpty()) { if (text.isEmpty() && infoText.isEmpty()) {
// with no text, we just take up the whole geometry // with no text, we just take up the whole geometry
iconWidth = qMin(currentSize.height() - iconWidth = qMin(currentSize.height(), currentSize.width());
horizontalMargin[IconWidgetPrivate::IconMargin].left -
horizontalMargin[IconWidgetPrivate::IconMargin].right,
currentSize.width() -
horizontalMargin[IconWidgetPrivate::IconMargin].left -
horizontalMargin[IconWidgetPrivate::IconMargin].right);
} else { } else {
iconWidth = currentSize.height() - iconWidth = currentSize.height() -
verticalMargin[IconWidgetPrivate::IconMargin].top - verticalMargin[IconWidgetPrivate::IconMargin].top -