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 {
|
||||
Layout.alignment: Qt.AlignTop
|
||||
enabled: model.status === SceneLoader.Ready
|
||||
spacing: 0
|
||||
|
||||
MaterialToolButton {
|
||||
|
@ -233,19 +232,18 @@ FloatingPane {
|
|||
}
|
||||
}
|
||||
|
||||
// Media unavailability indicator
|
||||
MaterialToolButton {
|
||||
id: requestMediaButton
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
enabled: !loading
|
||||
text: loading || !model.requested ? MaterialIcons.radio_button_unchecked : MaterialIcons.radio_button_checked
|
||||
enabled: false
|
||||
visible: !model.valid
|
||||
text: MaterialIcons.no_sim
|
||||
font.pointSize: 10
|
||||
palette.buttonText: model.valid ? "#4CAF50" : label.palette.buttonText
|
||||
ToolTip.text: ""
|
||||
onClicked: model.requested = !model.requested
|
||||
}
|
||||
|
||||
// Remove media from library button
|
||||
MaterialToolButton {
|
||||
id: removeButton
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
visible: !loading
|
||||
|
@ -255,12 +253,13 @@ FloatingPane {
|
|||
onClicked: mediaLibrary.remove(index)
|
||||
}
|
||||
|
||||
// Media loading indicator
|
||||
BusyIndicator {
|
||||
visible: loading
|
||||
running: visible
|
||||
padding: 0
|
||||
implicitHeight: 14
|
||||
implicitWidth: requestMediaButton.width
|
||||
padding: removeButton.padding
|
||||
implicitHeight: implicitWidth
|
||||
implicitWidth: removeButton.width
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,6 @@ Entity {
|
|||
var idx = find(source);
|
||||
if(idx === -1)
|
||||
return
|
||||
// load / make media visible
|
||||
m.mediaModel.get(idx).requested = true;
|
||||
m.mediaModel.get(idx).visible = true;
|
||||
loadRequest(idx);
|
||||
}
|
||||
|
@ -143,6 +141,7 @@ Entity {
|
|||
readonly property var attribute: model.attribute
|
||||
readonly property int idx: index
|
||||
readonly property var modelSource: attribute || model.source
|
||||
readonly property bool visible: model.visible
|
||||
|
||||
// multi-step binding to ensure MediaLoader source is properly
|
||||
// updated when needed, whether raw source is valid or not
|
||||
|
@ -163,7 +162,7 @@ Entity {
|
|||
readonly property string finalSource: model.requested ? currentSource : ""
|
||||
|
||||
renderMode: root.renderMode
|
||||
enabled: model.visible
|
||||
enabled: visible
|
||||
|
||||
// QObject.destroyed signal is not accessible
|
||||
// Use the object as NodeInstantiator model to be notified of its deletion
|
||||
|
@ -173,6 +172,17 @@ Entity {
|
|||
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) {
|
||||
// don't cache explicitely unloaded media
|
||||
if(model.requested && object && dependencyReady) {
|
||||
|
@ -184,8 +194,10 @@ Entity {
|
|||
if(attribute) {
|
||||
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);
|
||||
// ... and update media visibility (useful if media was hidden but loaded back from cache)
|
||||
model.visible = model.requested;
|
||||
model.valid = Filepath.exists(rawSource) && dependencyReady;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue