Compare commits

...

2 commits

Author SHA1 Message Date
wackyideas
e4cca91b12 desktopcontainment: improve text rendering for hidpi screens 2026-10-07 14:32:08 +02:00
wackyideas
2a068e65e0 Tweak panel blur offset for hidpi displays 2026-10-07 13:22:31 +02:00
2 changed files with 11 additions and 26 deletions

View file

@ -39,6 +39,8 @@ Item {
Accessible.role: Accessible.Canvas Accessible.role: Accessible.Canvas
readonly property real dpi: main.Window.window.devicePixelRatio
// This MouseArea exists to intercept press and hold; preventing edit mode // This MouseArea exists to intercept press and hold; preventing edit mode
// from being triggered when pressing and holding on an icon (if there is one). // from being triggered when pressing and holding on an icon (if there is one).
MouseArea { MouseArea {
@ -205,7 +207,7 @@ Item {
active: impl.iconAndLabelsShouldlookSelected || model.selected active: impl.iconAndLabelsShouldlookSelected || model.selected
asynchronous: true asynchronous: true
width: parent.width width: Math.round(parent.width * main.dpi) / main.dpi
height: root.useListViewMode height: root.useListViewMode
? parent.height ? parent.height
@ -309,22 +311,10 @@ Item {
PlasmaComponents.Label { PlasmaComponents.Label {
id: label id: label
renderType: Text.NativeRendering
font.hintingPreference: Font.PreferFullHinting
z: 2 // So it's always above the highlight effect z: 2 // So it's always above the highlight effect
font.kerning: Screen.devicePixelRatio == 1.0 renderType: main.dpi == 1.0 ? Text.NativeRendering : Text.QtRendering
font.hintingPreference: Font.PreferFullHinting
Timer {
id: hidpi_hack
interval: 50
onTriggered: {
front.anchors.rightMargin += 1;
front.anchors.rightMargin -= 1;
behind.anchors.rightMargin += 1;
behind.anchors.rightMargin -= 1;
}
}
// Hacks to improve font rendering to increase contrast and text brightness // Hacks to improve font rendering to increase contrast and text brightness
// This is done to get darker subpixel rendering, closer to ClearType // This is done to get darker subpixel rendering, closer to ClearType
PlasmaComponents.Label { PlasmaComponents.Label {
@ -334,9 +324,8 @@ Item {
anchors.rightMargin: 1 anchors.rightMargin: 1
anchors.leftMargin: -1 anchors.leftMargin: -1
color: model.selected && Plasmoid.configuration.selectionStyle ? "black" : "#F9000000" color: model.selected && Plasmoid.configuration.selectionStyle ? "black" : "#F9000000"
renderType: Text.NativeRendering renderType: main.dpi == 1.0 ? Text.NativeRendering : Text.QtRendering
font.hintingPreference: Font.PreferFullHinting font.hintingPreference: Font.PreferFullHinting
font.kerning: Screen.devicePixelRatio == 1.0
text: parent.text text: parent.text
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: parent.maximumLineCount maximumLineCount: parent.maximumLineCount
@ -350,9 +339,8 @@ Item {
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: 0 anchors.rightMargin: 0
color: model.selected && Plasmoid.configuration.selectionStyle ? "black" : "#ffffffff" color: model.selected && Plasmoid.configuration.selectionStyle ? "black" : "#ffffffff"
renderType: Text.NativeRendering renderType: main.dpi == 1.0 ? Text.NativeRendering : Text.QtRendering
font.hintingPreference: Font.PreferFullHinting font.hintingPreference: Font.PreferFullHinting
font.kerning: Screen.devicePixelRatio == 1.0
text: parent.text text: parent.text
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: parent.maximumLineCount maximumLineCount: parent.maximumLineCount
@ -369,7 +357,7 @@ Item {
target: label target: label
anchors.topMargin: Kirigami.Units.smallSpacing anchors.topMargin: Kirigami.Units.smallSpacing
// Ffs // Ffs
width: Math.floor((parent.width - Kirigami.Units.smallSpacing + (Screen.devicePixelRatio != 1.0) * 2 * Screen.devicePixelRatio) * Screen.devicePixelRatio) / Screen.devicePixelRatio width: Math.round((parent.width - Kirigami.Units.smallSpacing) * main.dpi) / main.dpi
maximumLineCount: Plasmoid.configuration.textLines maximumLineCount: Plasmoid.configuration.textLines
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
@ -397,11 +385,6 @@ Item {
anchors.rightMargin: 1 anchors.rightMargin: 1
anchors.leftMargin: -1 anchors.leftMargin: -1
} }
StateChangeScript {
script: {
hidpi_hack.start();
}
}
}, },
State { // list view State { // list view
when: root.useListViewMode when: root.useListViewMode

View file

@ -32,6 +32,8 @@ Item {
} }
} }
property real dpi: root.Window.window.devicePixelRatio
property Item containment property Item containment
property bool floatingPrefix: floatingPanelSvg.usedPrefix === "floating" property bool floatingPrefix: floatingPanelSvg.usedPrefix === "floating"
readonly property bool verticalPanel: containment?.plasmoid?.formFactor === PlasmaCore.Types.Vertical readonly property bool verticalPanel: containment?.plasmoid?.formFactor === PlasmaCore.Types.Vertical
@ -151,7 +153,7 @@ Item {
property var panelMask: floatingness === 0 ? (panelOpacity === 1 ? opaqueItem.mask : translucentItem.mask) : (panelOpacity === 1 ? floatingOpaqueItem.mask : floatingTranslucentItem.mask) property var panelMask: floatingness === 0 ? (panelOpacity === 1 ? opaqueItem.mask : translucentItem.mask) : (panelOpacity === 1 ? floatingOpaqueItem.mask : floatingTranslucentItem.mask)
// The point is read from panelview.cpp and is used as an offset for the mask // The point is read from panelview.cpp and is used as an offset for the mask
readonly property point floatingTranslucentItemOffset: Qt.point(floatingTranslucentItem.x, floatingTranslucentItem.y) readonly property point floatingTranslucentItemOffset: Qt.point(floatingTranslucentItem.x+(root.rightEdge && root.dpi != 1.0 ? 1 : 0), floatingTranslucentItem.y+(root.bottomEdge && root.dpi != 1.0 ? 1 : 0))
KSvg.FrameSvgItem { KSvg.FrameSvgItem {
id: translucentItem id: translucentItem