Merge pull request #9089 from Ultimaker/CURA-7864_open_remote_files_mvp

Open remote files MVP
This commit is contained in:
Konstantinos Karmas 2021-01-12 11:04:29 +01:00 committed by GitHub
commit 0edd6278f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
import os import os
import sys import sys
import tempfile
import time import time
from typing import cast, TYPE_CHECKING, Optional, Callable, List, Any, Dict from typing import cast, TYPE_CHECKING, Optional, Callable, List, Any, Dict
@ -1477,7 +1478,8 @@ class CuraApplication(QtApplication):
for file_name, nodes in objects_in_filename.items(): for file_name, nodes in objects_in_filename.items():
for node in nodes: for node in nodes:
job = ReadMeshJob(file_name) file_path = os.path.normpath(os.path.dirname(file_name))
job = ReadMeshJob(file_name, add_to_recent_files = file_path != tempfile.gettempdir()) # Don't add temp files to the recent files list
job._node = node # type: ignore job._node = node # type: ignore
job.finished.connect(self._reloadMeshFinished) job.finished.connect(self._reloadMeshFinished)
if has_merged_nodes: if has_merged_nodes:
@ -1735,7 +1737,7 @@ class CuraApplication(QtApplication):
@pyqtSlot(QUrl, str) @pyqtSlot(QUrl, str)
@pyqtSlot(QUrl) @pyqtSlot(QUrl)
def readLocalFile(self, file: QUrl, project_mode: Optional[str] = None): def readLocalFile(self, file: QUrl, project_mode: Optional[str] = None, add_to_recent_files: bool = True):
"""Open a local file """Open a local file
:param project_mode: How to handle project files. Either None(default): Follow user preference, "open_as_model" :param project_mode: How to handle project files. Either None(default): Follow user preference, "open_as_model"
@ -1760,7 +1762,7 @@ class CuraApplication(QtApplication):
if is_project_file and project_mode == "open_as_project": if is_project_file and project_mode == "open_as_project":
# open as project immediately without presenting a dialog # open as project immediately without presenting a dialog
workspace_handler = self.getWorkspaceFileHandler() workspace_handler = self.getWorkspaceFileHandler()
workspace_handler.readLocalFile(file) workspace_handler.readLocalFile(file, add_to_recent_files = add_to_recent_files)
return return
if is_project_file and project_mode == "always_ask": if is_project_file and project_mode == "always_ask":
@ -1801,7 +1803,7 @@ class CuraApplication(QtApplication):
if extension in self._non_sliceable_extensions: if extension in self._non_sliceable_extensions:
self.deleteAll(only_selectable = False) self.deleteAll(only_selectable = False)
job = ReadMeshJob(f) job = ReadMeshJob(f, add_to_recent_files = add_to_recent_files)
job.finished.connect(self._readMeshFinished) job.finished.connect(self._readMeshFinished)
job.start() job.start()