Now icons can be resized

BUG: 152695

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=750084
This commit is contained in:
Marco Martin 2007-12-18 16:56:34 +00:00
parent 8f05e1b7b0
commit d7f413742a
2 changed files with 22 additions and 8 deletions

View File

@ -782,6 +782,17 @@ void Icon::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option
}
#endif
int iconWidth;
if (size().width() < size().height()) {
iconWidth = size().width() -
d->horizontalMargin[Private::IconMargin].left -
d->horizontalMargin[Private::IconMargin].right;
}else{
iconWidth = size().height() -
d->verticalMargin[Private::IconMargin].top -
d->verticalMargin[Private::IconMargin].bottom;
}
d->iconSize = QSizeF(iconWidth, iconWidth);
calculateSize(option);
d->setActiveMargins();
@ -798,13 +809,23 @@ void Icon::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option
state = Private::HoverState;
}
QPixmap icon = d->decoration(option, state != Private::NoState);
QPixmap icon = d->decoration(option, state != Private::NoState);
const QPointF iconPos = d->iconPosition(option, icon);
QTextLayout labelLayout, infoLayout;
QRectF textBoundingRect;
d->layoutTextItems(option, icon, &labelLayout, &infoLayout, &textBoundingRect);
//did the calculated icon size left room for the text?
if (!d->text.isEmpty() && iconPos.y()+
d->iconSize.height()+
textBoundingRect.height() > size().height()) {
int iconWidth = d->iconSize.width() -
textBoundingRect.height() +
iconPos.y();
d->iconSize = QSizeF(iconWidth, iconWidth);
}
d->svg.resize(size());
d->drawBackground(painter, state);
@ -1032,11 +1053,6 @@ void Icon::setAlignment(Qt::Alignment alignment)
d->alignment=alignment;
}
Qt::Orientations Icon::expandingDirections() const
{
return Qt::Horizontal;
}
} // namespace Plasma
#include "icon.moc"

View File

@ -153,8 +153,6 @@ public:
*/
void setAlignment(Qt::Alignment alignment);
Qt::Orientations expandingDirections() const;
public Q_SLOTS:
/**
* Sets the appearance of the icon to pressed or restores the appearance