fix: handle hidpi properly

This commit is contained in:
2 * r + 2 * t 2026-04-27 21:49:21 +10:00
parent 6777ad0a2d
commit dea8efcc97
3 changed files with 13 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import QtQuick
import Quickshell
import Caelestia.Images
Image {
@ -9,5 +10,8 @@ Image {
asynchronous: true
fillMode: Image.PreserveAspectCrop
source: IUtils.urlForPath(path, fillMode)
sourceSize: Qt.size(width, height)
sourceSize: {
const dpr = (QsWindow.window as QsWindow)?.devicePixelRatio ?? 1;
return Qt.size(width * dpr, height * dpr);
}
}

View file

@ -1,4 +1,5 @@
import QtQuick
import Quickshell
import Caelestia.Config
import Caelestia.Models
import qs.components
@ -66,7 +67,10 @@ Item {
anchors.fill: parent
path: root.modelData.path
smooth: !root.PathView.view.moving
sourceSize: Qt.size(image.implicitWidth, image.implicitHeight)
sourceSize: {
const dpr = (QsWindow.window as QsWindow)?.devicePixelRatio ?? 1;
return Qt.size(image.implicitWidth * dpr, image.implicitHeight * dpr);
}
}
}

View file

@ -16,6 +16,9 @@ IUtils* IUtils::create(QQmlEngine* engine, QJSEngine* jsEngine) {
}
QUrl IUtils::urlForPath(const QString& path, int fillMode) {
if (path.isEmpty())
return QUrl();
QString prefix;
switch (fillMode) {
case 1: // Image.PreserveAspectFit