smooth property (default off)
svn path=/trunk/KDE/kdebase/runtime/; revision=1204366
This commit is contained in:
parent
4ff23c21ea
commit
20e4b7ca35
@ -28,7 +28,8 @@ namespace Plasma
|
||||
{
|
||||
|
||||
SvgItem::SvgItem(QDeclarativeItem *parent)
|
||||
: QDeclarativeItem(parent)
|
||||
: QDeclarativeItem(parent),
|
||||
m_smooth(false)
|
||||
{
|
||||
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
||||
}
|
||||
@ -79,6 +80,20 @@ Plasma::Svg *SvgItem::svg() const
|
||||
return m_svg.data();
|
||||
}
|
||||
|
||||
void SvgItem::setSmooth(const bool smooth)
|
||||
{
|
||||
if (smooth == m_smooth) {
|
||||
return;
|
||||
}
|
||||
m_smooth = smooth;
|
||||
update();
|
||||
}
|
||||
|
||||
bool SvgItem::smooth() const
|
||||
{
|
||||
return m_smooth;
|
||||
}
|
||||
|
||||
void SvgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
@ -87,9 +102,17 @@ void SvgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
||||
if (!m_svg) {
|
||||
return;
|
||||
}
|
||||
//do without painter save, faster and the support can be compiled out
|
||||
const bool wasAntiAlias = painter->testRenderHint(QPainter::Antialiasing);
|
||||
const bool wasSmoothTransform = painter->testRenderHint(QPainter::SmoothPixmapTransform);
|
||||
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
|
||||
|
||||
//setContainsMultipleImages has to be done there since m_frameSvg can be shared with somebody else
|
||||
m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty());
|
||||
m_svg.data()->paint(painter, boundingRect(), m_elementID);
|
||||
painter->setRenderHint(QPainter::Antialiasing, wasAntiAlias);
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothTransform);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
@ -32,6 +32,7 @@ class SvgItem : public QDeclarativeItem
|
||||
Q_PROPERTY(QString elementId READ elementId WRITE setElementId)
|
||||
Q_PROPERTY(Plasma::Svg * svg READ svg WRITE setSvg)
|
||||
Q_PROPERTY(QSizeF naturalSize READ naturalSize NOTIFY naturalSizeChanged)
|
||||
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
|
||||
|
||||
public:
|
||||
SvgItem(QDeclarativeItem *parent=0);
|
||||
@ -43,6 +44,9 @@ public:
|
||||
void setSvg(Plasma::Svg *svg);
|
||||
Plasma::Svg *svg() const;
|
||||
|
||||
void setSmooth(const bool smooth);
|
||||
bool smooth() const;
|
||||
|
||||
QSizeF naturalSize() const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
@ -53,6 +57,7 @@ Q_SIGNALS:
|
||||
private:
|
||||
QWeakPointer<Plasma::Svg> m_svg;
|
||||
QString m_elementID;
|
||||
bool m_smooth;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user