diff --git a/widgets/icon.cpp b/widgets/icon.cpp index adb82235f..600896c87 100644 --- a/widgets/icon.cpp +++ b/widgets/icon.cpp @@ -150,8 +150,8 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid if (!d->icon.isNull()) { - int deltaX = d->size.width() * 0.1; - int deltaY = d->size.height() * 0.1; + qreal deltaX = d->size.width() * 0.1; + qreal deltaY = d->size.height() * 0.1; painter->drawPixmap(deltaX, deltaY, d->icon.pixmap((d->size * 0.9).toSize())); } @@ -214,6 +214,11 @@ QSizeF Icon::size() const return d->size; } +QSizeF Icon::iconSize() const +{ + return d->size * .9; +} + void Icon::setSize(const QSizeF& s) { prepareGeometryChange(); @@ -322,6 +327,11 @@ void Icon::setGeometry(const QRectF &r) setPos(r.x(),r.y()); } +int Icon::boundsForIconSize(int iconSize) +{ + return iconSize * 1.1; +} + } // namespace Plasma #include "icon.moc" diff --git a/widgets/icon.h b/widgets/icon.h index 60431259e..b039a37d8 100644 --- a/widgets/icon.h +++ b/widgets/icon.h @@ -48,6 +48,7 @@ class PLASMA_EXPORT Icon : public QObject, void setText(const QString &name); QSizeF size() const; + QSizeF iconSize() const; void setSize(const QSizeF& size); void setSize(int height, int width); @@ -55,7 +56,7 @@ class PLASMA_EXPORT Icon : public QObject, void setIcon(const QIcon& icon); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - QRectF boundingRect() const; + QRectF boundingRect() const; //layout stufff Qt::Orientations expandingDirections() const; @@ -74,6 +75,8 @@ class PLASMA_EXPORT Icon : public QObject, QSizeF sizeHint() const; + static int boundsForIconSize(int iconSize); + Q_SIGNALS: void pressed(bool down); void clicked();