filedialog: cache thumbnails
Much faster loading
This commit is contained in:
parent
8155e5b873
commit
89c7739fdb
3 changed files with 32 additions and 4 deletions
31
widgets/CachingIconImage.qml
Normal file
31
widgets/CachingIconImage.qml
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Item {
|
||||||
|
property alias asynchronous: image.asynchronous
|
||||||
|
property alias status: image.status
|
||||||
|
property alias mipmap: image.mipmap
|
||||||
|
property alias backer: image
|
||||||
|
|
||||||
|
property real implicitSize
|
||||||
|
readonly property real actualSize: Math.min(width, height)
|
||||||
|
|
||||||
|
property url source
|
||||||
|
|
||||||
|
onSourceChanged: {
|
||||||
|
if (source?.toString().startsWith("image://icon/"))
|
||||||
|
// Directly skip the path prop and treat like a normal Image component
|
||||||
|
image.source = source;
|
||||||
|
else if (source)
|
||||||
|
image.path = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitWidth: implicitSize
|
||||||
|
implicitHeight: implicitSize
|
||||||
|
|
||||||
|
CachingImage {
|
||||||
|
id: image
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import qs.services
|
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
@ -11,7 +10,6 @@ Image {
|
||||||
readonly property string cachePath: `${Paths.stringify(Paths.imagecache)}/${hash}@${width}x${height}.png`
|
readonly property string cachePath: `${Paths.stringify(Paths.imagecache)}/${hash}@${width}x${height}.png`
|
||||||
|
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
cache: false
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
sourceSize.width: width
|
sourceSize.width: width
|
||||||
sourceSize.height: height
|
sourceSize.height: height
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell.Widgets
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Effects
|
import QtQuick.Effects
|
||||||
|
|
@ -140,7 +139,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IconImage {
|
CachingIconImage {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue