mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-05 20:31:56 +02:00
[ui] Viewer2D: keep previous image displayed when source changes
* cache last loaded image and display it while the main Image is loading to avoid empty screen * fix the BusyIndicator by dynamically creating a binding on the running property (Qt bug ?)
This commit is contained in:
parent
3b10fd6200
commit
d0a0f4491c
1 changed files with 24 additions and 13 deletions
|
@ -37,17 +37,7 @@ FocusScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// placeholder, visible when image isn't ready
|
// Main Image
|
||||||
Rectangle {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
width: Math.min(parent.width, parent.height*1.5) * 0.95 // 5% margin
|
|
||||||
height: Math.min(parent.height, parent.width*1.5) * 0.95 // 5% margin
|
|
||||||
color: "transparent"
|
|
||||||
border.color: "#333"
|
|
||||||
visible: image.status != Image.Ready
|
|
||||||
}
|
|
||||||
|
|
||||||
// image
|
|
||||||
Image {
|
Image {
|
||||||
id: image
|
id: image
|
||||||
transformOrigin: Item.TopLeft
|
transformOrigin: Item.TopLeft
|
||||||
|
@ -56,12 +46,33 @@ FocusScope {
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
autoTransform: true
|
autoTransform: true
|
||||||
onWidthChanged: if(status==Image.Ready) fit()
|
onWidthChanged: if(status==Image.Ready) fit()
|
||||||
|
onStatusChanged: {
|
||||||
|
// update cache source when image is loaded
|
||||||
|
if(status === Image.Ready)
|
||||||
|
cache.source = source
|
||||||
|
}
|
||||||
|
|
||||||
|
// Image cache of the last loaded image
|
||||||
|
// Only visible when the main one is loading, to keep an image
|
||||||
|
// displayed at all time and smoothen transitions
|
||||||
|
Image {
|
||||||
|
id: cache
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
asynchronous: true
|
||||||
|
smooth: parent.smooth
|
||||||
|
fillMode: parent.fillMode
|
||||||
|
autoTransform: parent.autoTransform
|
||||||
|
|
||||||
|
visible: image.status === Image.Loading
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// busy indicator
|
// Busy indicator
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
running: image.status === Image.Loading
|
// running property binding seems broken, only dynamic binding assignment works
|
||||||
|
Component.onCompleted: running = Qt.binding(function() { return image.status === Image.Loading })
|
||||||
}
|
}
|
||||||
|
|
||||||
// mouse area
|
// mouse area
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue