From 306e353fe6f45a34b093084ae1f7ced80aed35b2 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 17 Sep 2014 11:49:47 +0200 Subject: [PATCH] take into account device pixel ratio make sure framesvgitem returns the proper implicitWidth/height Change-Id: I6d756e474c69bb32d2abef1a34d989c339d28ef9 --- src/declarativeimports/core/framesvgitem.cpp | 24 +++++-------------- .../plasmacomponents/qml/ProgressBar.qml | 4 ++-- .../qml/styles/ScrollViewStyle.qml | 2 +- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp index af4ddf29a..40271c09b 100644 --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -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"); diff --git a/src/declarativeimports/plasmacomponents/qml/ProgressBar.qml b/src/declarativeimports/plasmacomponents/qml/ProgressBar.qml index 630893b48..665b12ec6 100644 --- a/src/declarativeimports/plasmacomponents/qml/ProgressBar.qml +++ b/src/declarativeimports/plasmacomponents/qml/ProgressBar.qml @@ -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" diff --git a/src/declarativeimports/plasmacomponents/qml/styles/ScrollViewStyle.qml b/src/declarativeimports/plasmacomponents/qml/styles/ScrollViewStyle.qml index cce4e27bb..e5cb52ebf 100644 --- a/src/declarativeimports/plasmacomponents/qml/styles/ScrollViewStyle.qml +++ b/src/declarativeimports/plasmacomponents/qml/styles/ScrollViewStyle.qml @@ -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 {