mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
[ui] 3DViewer: make 'visible' property drive media load request
* remove the notion of manual media (un)loading from high-level UI * visibility button now drives media loading: * if media is not available (not yet computed), it will be loaded once available if visibility is on * once loaded, media can't be explicitly unloaded * use an icon to indicate that the media is not available instead of colors
This commit is contained in:
parent
717b4f8b37
commit
2e06ad1b83
2 changed files with 26 additions and 15 deletions
|
@ -147,7 +147,6 @@ FloatingPane {
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
enabled: model.status === SceneLoader.Ready
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
MaterialToolButton {
|
MaterialToolButton {
|
||||||
|
@ -233,19 +232,18 @@ FloatingPane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Media unavailability indicator
|
||||||
MaterialToolButton {
|
MaterialToolButton {
|
||||||
id: requestMediaButton
|
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
enabled: false
|
||||||
enabled: !loading
|
visible: !model.valid
|
||||||
text: loading || !model.requested ? MaterialIcons.radio_button_unchecked : MaterialIcons.radio_button_checked
|
text: MaterialIcons.no_sim
|
||||||
font.pointSize: 10
|
font.pointSize: 10
|
||||||
palette.buttonText: model.valid ? "#4CAF50" : label.palette.buttonText
|
|
||||||
ToolTip.text: ""
|
|
||||||
onClicked: model.requested = !model.requested
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove media from library button
|
||||||
MaterialToolButton {
|
MaterialToolButton {
|
||||||
|
id: removeButton
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
visible: !loading
|
visible: !loading
|
||||||
|
@ -255,12 +253,13 @@ FloatingPane {
|
||||||
onClicked: mediaLibrary.remove(index)
|
onClicked: mediaLibrary.remove(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Media loading indicator
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
visible: loading
|
visible: loading
|
||||||
running: visible
|
running: visible
|
||||||
padding: 0
|
padding: removeButton.padding
|
||||||
implicitHeight: 14
|
implicitHeight: implicitWidth
|
||||||
implicitWidth: requestMediaButton.width
|
implicitWidth: removeButton.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,6 @@ Entity {
|
||||||
var idx = find(source);
|
var idx = find(source);
|
||||||
if(idx === -1)
|
if(idx === -1)
|
||||||
return
|
return
|
||||||
// load / make media visible
|
|
||||||
m.mediaModel.get(idx).requested = true;
|
|
||||||
m.mediaModel.get(idx).visible = true;
|
m.mediaModel.get(idx).visible = true;
|
||||||
loadRequest(idx);
|
loadRequest(idx);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +141,7 @@ Entity {
|
||||||
readonly property var attribute: model.attribute
|
readonly property var attribute: model.attribute
|
||||||
readonly property int idx: index
|
readonly property int idx: index
|
||||||
readonly property var modelSource: attribute || model.source
|
readonly property var modelSource: attribute || model.source
|
||||||
|
readonly property bool visible: model.visible
|
||||||
|
|
||||||
// multi-step binding to ensure MediaLoader source is properly
|
// multi-step binding to ensure MediaLoader source is properly
|
||||||
// updated when needed, whether raw source is valid or not
|
// updated when needed, whether raw source is valid or not
|
||||||
|
@ -163,7 +162,7 @@ Entity {
|
||||||
readonly property string finalSource: model.requested ? currentSource : ""
|
readonly property string finalSource: model.requested ? currentSource : ""
|
||||||
|
|
||||||
renderMode: root.renderMode
|
renderMode: root.renderMode
|
||||||
enabled: model.visible
|
enabled: visible
|
||||||
|
|
||||||
// QObject.destroyed signal is not accessible
|
// QObject.destroyed signal is not accessible
|
||||||
// Use the object as NodeInstantiator model to be notified of its deletion
|
// Use the object as NodeInstantiator model to be notified of its deletion
|
||||||
|
@ -173,6 +172,17 @@ Entity {
|
||||||
onObjectRemoved: remove(idx)
|
onObjectRemoved: remove(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'visible' property drives media loading request
|
||||||
|
onVisibleChanged: {
|
||||||
|
// always request media loading if visible
|
||||||
|
if(model.visible)
|
||||||
|
model.requested = true;
|
||||||
|
// only cancel loading request if media is not valid
|
||||||
|
// (a media won't be unloaded if already loaded, only hidden)
|
||||||
|
else if(!model.valid)
|
||||||
|
model.requested = false;
|
||||||
|
}
|
||||||
|
|
||||||
function updateModelAndCache(forceRequest) {
|
function updateModelAndCache(forceRequest) {
|
||||||
// don't cache explicitely unloaded media
|
// don't cache explicitely unloaded media
|
||||||
if(model.requested && object && dependencyReady) {
|
if(model.requested && object && dependencyReady) {
|
||||||
|
@ -184,8 +194,10 @@ Entity {
|
||||||
if(attribute) {
|
if(attribute) {
|
||||||
model.source = rawSource;
|
model.source = rawSource;
|
||||||
}
|
}
|
||||||
// auto-restore entity if raw source is in cache
|
// auto-restore entity if raw source is in cache ...
|
||||||
model.requested = forceRequest || (!model.valid && model.requested) || cache.contains(rawSource);
|
model.requested = forceRequest || (!model.valid && model.requested) || cache.contains(rawSource);
|
||||||
|
// ... and update media visibility (useful if media was hidden but loaded back from cache)
|
||||||
|
model.visible = model.requested;
|
||||||
model.valid = Filepath.exists(rawSource) && dependencyReady;
|
model.valid = Filepath.exists(rawSource) && dependencyReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue