Now icons can be resized
BUG: 152695 svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=750084
This commit is contained in:
parent
8f05e1b7b0
commit
d7f413742a
@ -782,6 +782,17 @@ void Icon::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||||||
}
|
}
|
||||||
#endif
|
#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);
|
calculateSize(option);
|
||||||
d->setActiveMargins();
|
d->setActiveMargins();
|
||||||
|
|
||||||
@ -798,13 +809,23 @@ void Icon::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||||||
state = Private::HoverState;
|
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);
|
const QPointF iconPos = d->iconPosition(option, icon);
|
||||||
|
|
||||||
QTextLayout labelLayout, infoLayout;
|
QTextLayout labelLayout, infoLayout;
|
||||||
QRectF textBoundingRect;
|
QRectF textBoundingRect;
|
||||||
d->layoutTextItems(option, icon, &labelLayout, &infoLayout, &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->svg.resize(size());
|
||||||
d->drawBackground(painter, state);
|
d->drawBackground(painter, state);
|
||||||
|
|
||||||
@ -1032,11 +1053,6 @@ void Icon::setAlignment(Qt::Alignment alignment)
|
|||||||
d->alignment=alignment;
|
d->alignment=alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::Orientations Icon::expandingDirections() const
|
|
||||||
{
|
|
||||||
return Qt::Horizontal;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
|
||||||
#include "icon.moc"
|
#include "icon.moc"
|
||||||
|
@ -153,8 +153,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setAlignment(Qt::Alignment alignment);
|
void setAlignment(Qt::Alignment alignment);
|
||||||
|
|
||||||
Qt::Orientations expandingDirections() const;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Sets the appearance of the icon to pressed or restores the appearance
|
* Sets the appearance of the icon to pressed or restores the appearance
|
||||||
|
Loading…
x
Reference in New Issue
Block a user