use units to understand the devicePixelRatio

This commit is contained in:
Marco Martin 2014-02-24 16:55:19 +01:00
parent c009c7f0cd
commit a04a87bcec
4 changed files with 14 additions and 3 deletions

View File

@ -101,6 +101,7 @@ FrameSvgItem::FrameSvgItem(QQuickItem *parent)
m_fixedMargins->setFixed(true);
setFlag(ItemHasContents, true);
connect(m_frameSvg, SIGNAL(repaintNeeded()), this, SLOT(doUpdate()));
connect(&m_units, &Units::devicePixelRatioChanged, this, &FrameSvgItem::updateDevicePixelRatio);
}
@ -270,8 +271,7 @@ void FrameSvgItem::componentComplete()
void FrameSvgItem::updateDevicePixelRatio()
{
m_frameSvg->resize();
m_frameSvg->resize(m_frameSvg->size() * 5);
m_frameSvg->setDevicePixelRatio(qMax((qreal)1.0, floor(m_units.devicePixelRatio())));
}
} // Plasma namespace

View File

@ -34,6 +34,7 @@ SvgItem::SvgItem(QQuickItem *parent)
m_smooth(false)
{
setFlag(QQuickItem::ItemHasContents, true);
connect(&m_units, &Units::devicePixelRatioChanged, this, &SvgItem::updateDevicePixelRatio);
}
@ -83,6 +84,8 @@ void SvgItem::setSvg(Plasma::Svg *svg)
disconnect(m_svg.data(), 0, this, 0);
}
m_svg = svg;
updateDevicePixelRatio();
if (svg) {
connect(svg, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
connect(svg, SIGNAL(repaintNeeded()), this, SIGNAL(naturalSizeChanged()));
@ -181,6 +184,13 @@ qreal SvgItem::implicitHeight() const
return QQuickItem::implicitHeight();
}
void SvgItem::updateDevicePixelRatio()
{
if (m_svg) {
m_svg.data()->setDevicePixelRatio(qMax((qreal)1.0, floor(m_units.devicePixelRatio())));
}
}
} // Plasma namespace
#include "svgitem.moc"

View File

@ -101,6 +101,7 @@ Q_SIGNALS:
protected Q_SLOTS:
void updateNeeded();
void updateDevicePixelRatio();
private:
QWeakPointer<Plasma::Svg> m_svg;

View File

@ -137,7 +137,7 @@ SvgPrivate::SvgPrivate(Svg *svg)
renderer(0),
styleCrc(0),
lastModified(0),
devicePixelRatio(2.0),
devicePixelRatio(1.0),
multipleImages(false),
themed(false),
applyColors(false),