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:
parent
6ae451413d
commit
e26e1947bf
1 changed files with 8 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import qs.utils
|
import qs.utils
|
||||||
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
|
|
@ -7,12 +8,16 @@ Image {
|
||||||
|
|
||||||
property string path
|
property string path
|
||||||
property string hash
|
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
|
asynchronous: true
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
sourceSize.width: width
|
sourceSize.width: effectiveWidth
|
||||||
sourceSize.height: height
|
sourceSize.height: effectiveHeight
|
||||||
|
|
||||||
onPathChanged: shaProc.exec(["sha256sum", Paths.strip(path)])
|
onPathChanged: shaProc.exec(["sha256sum", Paths.strip(path)])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue