Verified Commit 98e0e17a authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applets/tasmanager: consider `devicePixelRatio` in font height

The font height does not consider devicePixelRatio unlike other size
properties. This makes stripe work correctly when HiDPI is enabled.
parent 40076890
......@@ -130,28 +130,23 @@ function preferredMaxWidth() {
function preferredMinHeight() {
// TODO FIXME UPSTREAM: Port to proper font metrics for descenders once we have access to them.
return PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height + 4;
return PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height / tasks.devicePixelRatio + 4;
}
function preferredMaxHeight() {
let adjustedHeight;
if (tasks.vertical) {
return verticalMargins() +
Math.min(
// Do not allow the preferred icon size to exceed the width of
// the vertical task manager.
tasks.width,
tasks.iconsOnly ? tasks.width :
Math.max(
PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height,
PlasmaCore.Units.iconSizes.medium
)
);
// Do not allow the preferred icon size to exceed the width of
// the vertical task manager.
if (tasks.iconsOnly) {
adjustedHeight = tasks.width;
} else {
adjustedHeight = Math.max(PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height / tasks.devicePixelRatio, PlasmaCore.Units.iconSizes.medium);
}
return verticalMargins() + Math.min(tasks.width, adjustedHeight);
} else {
return verticalMargins() +
Math.min(
PlasmaCore.Units.iconSizes.small * 3,
PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height *
3);
adjustedHeight = Math.min(PlasmaCore.Units.iconSizes.small, PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height / tasks.devicePixelRatio) * 3
return verticalMargins() + adjustedHeight;
}
}
......
......@@ -6,6 +6,7 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQml 2.15
import org.kde.plasma.plasmoid 2.0
......@@ -23,6 +24,7 @@ MouseArea {
anchors.fill: parent
hoverEnabled: true
readonly property real devicePixelRatio: Screen.devicePixelRatio
property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
property bool iconsOnly: plasmoid.pluginName === "org.kde.plasma.icontasks"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment