Skip to content

Commit

Permalink
Only display supported file types in save to disk dialog
Browse files Browse the repository at this point in the history
CURA-11390
  • Loading branch information
casperlamboo committed Nov 27, 2023
1 parent cfafed3 commit bac2797
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 5 additions & 5 deletions UM/FileHandler/FileHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def __init__(self, application: "QtApplication", writer_type: str = "unknown_fil
cast(FileHandler, self.__class__).__instance = self

self._application = application
self._readers = {} # type: Dict[str, FileReader]
self._writers = {} # type: Dict[str, FileWriter]
self._readers: Dict[str, FileReader] = {}
self._writers: Dict[str, FileWriter] = {}

self._writer_type = writer_type # type: str
self._reader_type = reader_type # type: str
self._writer_type: str = writer_type
self._reader_type: str = reader_type

self._add_to_recent_files_hints = [] # type: List[QUrl]
self._add_to_recent_files_hints: List[QUrl] = []

PluginRegistry.addType(self._writer_type, self.addWriter)
PluginRegistry.addType(self._reader_type, self.addReader)
Expand Down
4 changes: 2 additions & 2 deletions UM/Qt/Bindings/OutputDeviceManagerProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class OutputDeviceManagerProxy(QObject):
def __init__(self, parent = None) -> None:
super().__init__(parent)
self._device_manager = Application.getInstance().getOutputDeviceManager() #type: OutputDeviceManager
self._device_manager: OutputDeviceManager = Application.getInstance().getOutputDeviceManager()
self._device_manager.activeDeviceChanged.connect(self._onActiveDeviceChanged)

Application.getInstance().getPreferences().addPreference("output_devices/last_used_device", "")
Expand Down Expand Up @@ -140,7 +140,7 @@ def _writeToDevice(self, nodes: List[SceneNode], device_id: str, file_name: str,
device = self._device_manager.getOutputDevice(device_id)
if not device:
return
file_handler = None #type: Optional[FileHandler]
file_handler: Optional[FileHandler] = None
if file_type == "mesh":
file_handler = UM.Qt.QtApplication.QtApplication.getInstance().getMeshFileHandler()
elif file_type == "workspace":
Expand Down
7 changes: 7 additions & 0 deletions plugins/LocalFileOutputDevice/LocalFileOutputDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ def requestWrite(self, nodes, file_name = None, limit_mimetypes = None, file_han
preferred_mimetype = mime_type
break

container = Application.getInstance().getGlobalContainerStack().findContainer({"file_formats": "*"})
machine_file_formats = [file_type.strip() for file_type in
container.getMetaDataEntry("file_formats").split(";")]

extension_added = False
for item in file_types:
if item["mime_type"] not in machine_file_formats:
continue

type_filter = "{0} (*.{1})".format(item["description"], item["extension"])
filters.append(type_filter)
mime_types.append(item["mime_type"])
Expand Down

0 comments on commit bac2797

Please sign in to comment.