Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene.py add _hideReloadMessage, connect to startReloadAll #964

Open
wants to merge 1 commit into
base: 5.8
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions UM/Scene/Scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def __init__(self) -> None:

self._metadata: Dict[str, Any] = {}

# If available connect reloadAll to hide the file change reload message.
import UM.Application
app = UM.Application.Application.getInstance()
if getattr(app, "startReloadAll", None):
app.startReloadAll.connect(self._hideReloadMessage)

def setMetaDataEntry(self, key: str, entry: Any) -> None:
self._metadata[key] = entry

Expand Down Expand Up @@ -189,8 +195,7 @@ def _onFileChanged(self, file_path: str) -> None:
if modified_nodes:
# Hide the message if it was already visible
# Todo: keep one message for each modified file, when multiple had been updated at same time
if self._reload_message is not None:
self._reload_message.hide()
self._hideReloadMessage()

self._reload_message = Message(i18n_catalog.i18nc("@info", "Would you like to reload {filename}?").format(
filename = os.path.basename(file_path)),
Expand All @@ -212,8 +217,7 @@ def _reloadNodes(self, nodes: List["SceneNode"], file_path: str, message: str, a

if action != "reload":
return
if self._reload_message is not None:
self._reload_message.hide()
self._hideReloadMessage()

if not file_path or not os.path.isfile(file_path): # File doesn't exist anymore.
return
Expand Down Expand Up @@ -265,3 +269,10 @@ def _reloadJobFinished(self, replaced_nodes: [SceneNode], job: ReadMeshJob) -> N
# Current node is a new one in the file, or it's name has changed
# TODO: Load this mesh into the scene. Also alter the "ReloadAll" action in CuraApplication.
Logger.log("w", "Could not find matching node for object '{0}' in the scene.", node_name)

def _hideReloadMessage(self) -> None:
"""Hide file modification reload dialog if showing"""
if self._reload_message is not None:
self._reload_message.hide()
if self._reload_callback is not None:
self._reload_callback = None
Loading