take into account device pixel ratio

make sure framesvgitem returns the proper implicitWidth/height

Change-Id: I6d756e474c69bb32d2abef1a34d989c339d28ef9
This commit is contained in:
Marco Martin 2014-09-17 11:49:47 +02:00
parent 919694a1de
commit 306e353fe6
3 changed files with 9 additions and 21 deletions

View File

@ -273,13 +273,9 @@ void FrameSvgItem::setImagePath(const QString &path)
m_frameSvg->setElementPrefix(m_prefix);
updateDevicePixelRatio();
if (implicitWidth() <= 0) {
setImplicitWidth(m_frameSvg->marginSize(Plasma::Types::LeftMargin) + m_frameSvg->marginSize(Plasma::Types::RightMargin));
}
setImplicitWidth(m_frameSvg->marginSize(Plasma::Types::LeftMargin) + m_frameSvg->marginSize(Plasma::Types::RightMargin));
if (implicitHeight() <= 0) {
setImplicitHeight(m_frameSvg->marginSize(Plasma::Types::TopMargin) + m_frameSvg->marginSize(Plasma::Types::BottomMargin));
}
setImplicitHeight(m_frameSvg->marginSize(Plasma::Types::TopMargin) + m_frameSvg->marginSize(Plasma::Types::BottomMargin));
emit imagePathChanged();
m_margins->update();
@ -305,13 +301,9 @@ void FrameSvgItem::setPrefix(const QString &prefix)
m_frameSvg->setElementPrefix(prefix);
m_prefix = prefix;
if (implicitWidth() <= 0) {
setImplicitWidth(m_frameSvg->marginSize(Plasma::Types::LeftMargin) + m_frameSvg->marginSize(Plasma::Types::RightMargin));
}
setImplicitWidth(m_frameSvg->marginSize(Plasma::Types::LeftMargin) + m_frameSvg->marginSize(Plasma::Types::RightMargin));
if (implicitHeight() <= 0) {
setImplicitHeight(m_frameSvg->marginSize(Plasma::Types::TopMargin) + m_frameSvg->marginSize(Plasma::Types::BottomMargin));
}
setImplicitHeight(m_frameSvg->marginSize(Plasma::Types::TopMargin) + m_frameSvg->marginSize(Plasma::Types::BottomMargin));
emit prefixChanged();
m_margins->update();
@ -372,13 +364,9 @@ void FrameSvgItem::geometryChanged(const QRectF &newGeometry,
void FrameSvgItem::doUpdate()
{
if (implicitWidth() <= 0) {
setImplicitWidth(m_frameSvg->marginSize(Plasma::Types::LeftMargin) + m_frameSvg->marginSize(Plasma::Types::RightMargin));
}
setImplicitWidth(m_frameSvg->marginSize(Plasma::Types::LeftMargin) + m_frameSvg->marginSize(Plasma::Types::RightMargin));
if (implicitHeight() <= 0) {
setImplicitHeight(m_frameSvg->marginSize(Plasma::Types::TopMargin) + m_frameSvg->marginSize(Plasma::Types::BottomMargin));
}
setImplicitHeight(m_frameSvg->marginSize(Plasma::Types::TopMargin) + m_frameSvg->marginSize(Plasma::Types::BottomMargin));
QString prefix = m_frameSvg->actualPrefix();
bool hasOverlay = !prefix.startsWith(QStringLiteral("mask-")) && m_frameSvg->hasElement(prefix % "overlay");

View File

@ -83,8 +83,8 @@ Item {
id: background
anchors.centerIn: parent
width: _isVertical ? barSvg.elementSize("hint-bar-size").width : parent.width
height: _isVertical ? parent.height : barSvg.elementSize("hint-bar-size").height
width: _isVertical ? Math.round(barSvg.elementSize("hint-bar-size").width * units.devicePixelRatio) : parent.width
height: _isVertical ? parent.height : Math.round(barSvg.elementSize("hint-bar-size").height * units.devicePixelRatio)
imagePath: barSvg.imagePath
prefix: "bar-inactive"

View File

@ -27,7 +27,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
QtQuickControlStyle.ScrollViewStyle {
property Flickable flickableItem: control.flickableItem
property real widthHint: scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : scrollbarSvg.elementSize("arrow-up").width
property real widthHint: Math.round( (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : scrollbarSvg.elementSize("arrow-up").width) * units.devicePixelRatio)
frame: Item {
PlasmaCore.Svg {