internal: use device scaling for image caching (#348)

* internal: fixes image caching (#275)

* fixes

---------

Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
This commit is contained in:
Davi Ribeiro 2025-08-05 01:29:11 -03:00 committed by GitHub
parent 6ae451413d
commit e26e1947bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,5 @@
import qs.utils
import Quickshell
import Quickshell.Io
import QtQuick
@ -7,12 +8,16 @@ Image {
property string path
property string hash
readonly property string cachePath: `${Paths.stringify(Paths.imagecache)}/${hash}@${width}x${height}.png`
readonly property string cachePath: `${Paths.stringify(Paths.imagecache)}/${hash}@${effectiveWidth}x${effectiveHeight}.png`
readonly property real effectiveScale: QsWindow.window?.devicePixelRatio ?? 1
readonly property int effectiveWidth: Math.ceil(width * effectiveScale)
readonly property int effectiveHeight: Math.ceil(height * effectiveScale)
asynchronous: true
fillMode: Image.PreserveAspectCrop
sourceSize.width: width
sourceSize.height: height
sourceSize.width: effectiveWidth
sourceSize.height: effectiveHeight
onPathChanged: shaProc.exec(["sha256sum", Paths.strip(path)])