From af00946f81c62a90622dbdf42e7687d76fe9e273 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 23 Jan 2018 15:58:39 +0100 Subject: [PATCH] don't multiply svg sizes by devicepixelratio Summary: when the native high dpi scaling is enabled, some things gets scaled two times, as sizes taken from svgs should *not* be manually scaled by devicePixelRatio Test Plan: works correctly on wayland, svg.elementSize will have to be tweaked in x11 to return a value scaled by scalefactor, to homogenize the behavior compared to native qt high dpi scaling. to return a value scaled by scalefactor for this qml code to work there too. I advise everybody with high dpi laptops to test this on both wayland and x11 Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: hein, broulik, plasma-devel, #frameworks Tags: #plasma, #frameworks Differential Revision: https://phabricator.kde.org/D9286 --- .../plasmacomponents/qml/private/ScrollBarDelegate.qml | 4 ++-- .../plasmacomponents/qml/private/ScrollDecoratorDelegate.qml | 4 ++-- src/declarativeimports/plasmastyle/ProgressBarStyle.qml | 2 +- src/declarativeimports/plasmastyle/ScrollViewStyle.qml | 2 +- src/declarativeimports/plasmastyle/TableViewStyle.qml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/declarativeimports/plasmacomponents/qml/private/ScrollBarDelegate.qml b/src/declarativeimports/plasmacomponents/qml/private/ScrollBarDelegate.qml index db9f28f00..ea5ef4941 100644 --- a/src/declarativeimports/plasmacomponents/qml/private/ScrollBarDelegate.qml +++ b/src/declarativeimports/plasmacomponents/qml/private/ScrollBarDelegate.qml @@ -28,8 +28,8 @@ PlasmaCore.FrameSvgItem { imagePath:"widgets/scrollbar" prefix: internalLoader.isVertical ? "background-vertical" : "background-horizontal" - property int implicitWidth: (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : scrollbarSvg.elementSize("arrow-up").width) * Math.max(1, Math.floor(units.devicePixelRatio)) - property int implicitHeight: (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").height : scrollbarSvg.elementSize("arrow-left").height) * Math.max(1, Math.floor(units.devicePixelRatio)) + property int implicitWidth: (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : scrollbarSvg.elementSize("arrow-up").width) + property int implicitHeight: (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").height : scrollbarSvg.elementSize("arrow-left").height) Keys.onUpPressed: { if (!enabled || !internalLoader.isVertical) diff --git a/src/declarativeimports/plasmacomponents/qml/private/ScrollDecoratorDelegate.qml b/src/declarativeimports/plasmacomponents/qml/private/ScrollDecoratorDelegate.qml index fbf9d7d27..c2746c8e5 100644 --- a/src/declarativeimports/plasmacomponents/qml/private/ScrollDecoratorDelegate.qml +++ b/src/declarativeimports/plasmacomponents/qml/private/ScrollDecoratorDelegate.qml @@ -28,8 +28,8 @@ PlasmaCore.FrameSvgItem { imagePath:"widgets/scrollbar" prefix: internalLoader.isVertical ? "background-vertical" : "background-horizontal" - property int implicitWidth: scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width * Math.max(1, Math.floor(units.devicePixelRatio)) : 12 - property int implicitHeight: scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").height * Math.max(1, Math.floor(units.devicePixelRatio)) : 12 + property int implicitWidth: scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : 12 + property int implicitHeight: scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").height : 12 opacity: 0 Behavior on opacity { diff --git a/src/declarativeimports/plasmastyle/ProgressBarStyle.qml b/src/declarativeimports/plasmastyle/ProgressBarStyle.qml index 303ea7e52..3a924e747 100644 --- a/src/declarativeimports/plasmastyle/ProgressBarStyle.qml +++ b/src/declarativeimports/plasmastyle/ProgressBarStyle.qml @@ -29,7 +29,7 @@ ProgressBarStyle { readonly property string imagePath: "widgets/bar_meter_horizontal" - readonly property real implicitHeight: barSvg.preferredHeight * Math.max(1, Math.floor(units.devicePixelRatio)) + readonly property real implicitHeight: barSvg.preferredHeight PlasmaCore.Svg { id: barSvg diff --git a/src/declarativeimports/plasmastyle/ScrollViewStyle.qml b/src/declarativeimports/plasmastyle/ScrollViewStyle.qml index 95760fccd..37951e794 100644 --- a/src/declarativeimports/plasmastyle/ScrollViewStyle.qml +++ b/src/declarativeimports/plasmastyle/ScrollViewStyle.qml @@ -28,7 +28,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents QtQuickControlStyle.ScrollViewStyle { property Flickable flickableItem: control.flickableItem - property real widthHint: Math.round( (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : scrollbarSvg.elementSize("arrow-up").width) * units.devicePixelRatio) + property real widthHint: Math.round( (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : scrollbarSvg.elementSize("arrow-up").width)) property StyleItem __styleitem: StyleItem { elementType: "frame" } readonly property int __wheelScrollLines: __styleitem.styleHint("wheelScrollLines") diff --git a/src/declarativeimports/plasmastyle/TableViewStyle.qml b/src/declarativeimports/plasmastyle/TableViewStyle.qml index aa05deafb..2531fcedf 100644 --- a/src/declarativeimports/plasmastyle/TableViewStyle.qml +++ b/src/declarativeimports/plasmastyle/TableViewStyle.qml @@ -34,7 +34,7 @@ QtQuickControlStyle.TableViewStyle { activateItemOnSingleClick: false - property real scrollbarWidthHint: Math.round( (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : scrollbarSvg.elementSize("arrow-up").width) * units.devicePixelRatio) + property real scrollbarWidthHint: Math.round( (scrollbarSvg.hasElement("hint-scrollbar-size") ? scrollbarSvg.elementSize("hint-scrollbar-size").width : scrollbarSvg.elementSize("arrow-up").width)) headerDelegate: PlasmaCore.FrameSvgItem { imagePath: "widgets/button"