mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Move MIME type declarations into constructors of readers
So that if you disable the plug-in, the MIME type declaration is also not added. Fixes #4151.
This commit is contained in:
parent
88ba2ac345
commit
0ce9bf61be
4 changed files with 27 additions and 25 deletions
|
@ -7,20 +7,19 @@ from UM.Mesh.MeshReader import MeshReader #The class we're extending/implementin
|
||||||
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType #To add the .gcode.gz files to the MIME type database.
|
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType #To add the .gcode.gz files to the MIME type database.
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
|
|
||||||
MimeTypeDatabase.addMimeType(
|
|
||||||
MimeType(
|
|
||||||
name = "application/x-cura-compressed-gcode-file",
|
|
||||||
comment = "Cura Compressed GCode File",
|
|
||||||
suffixes = ["gcode.gz"]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
## A file reader that reads gzipped g-code.
|
## A file reader that reads gzipped g-code.
|
||||||
#
|
#
|
||||||
# If you're zipping g-code, you might as well use gzip!
|
# If you're zipping g-code, you might as well use gzip!
|
||||||
class GCodeGzReader(MeshReader):
|
class GCodeGzReader(MeshReader):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
MimeTypeDatabase.addMimeType(
|
||||||
|
MimeType(
|
||||||
|
name = "application/x-cura-compressed-gcode-file",
|
||||||
|
comment = "Cura Compressed GCode File",
|
||||||
|
suffixes = ["gcode.gz"]
|
||||||
|
)
|
||||||
|
)
|
||||||
self._supported_extensions = [".gcode.gz"]
|
self._supported_extensions = [".gcode.gz"]
|
||||||
|
|
||||||
def _read(self, file_name):
|
def _read(self, file_name):
|
||||||
|
|
|
@ -12,13 +12,7 @@ catalog = i18nCatalog("cura")
|
||||||
from . import MarlinFlavorParser, RepRapFlavorParser
|
from . import MarlinFlavorParser, RepRapFlavorParser
|
||||||
|
|
||||||
|
|
||||||
MimeTypeDatabase.addMimeType(
|
|
||||||
MimeType(
|
|
||||||
name = "application/x-cura-gcode-file",
|
|
||||||
comment = "Cura GCode File",
|
|
||||||
suffixes = ["gcode"]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Class for loading and parsing G-code files
|
# Class for loading and parsing G-code files
|
||||||
|
@ -30,7 +24,15 @@ class GCodeReader(MeshReader):
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
MimeTypeDatabase.addMimeType(
|
||||||
|
MimeType(
|
||||||
|
name = "application/x-cura-gcode-file",
|
||||||
|
comment = "Cura GCode File",
|
||||||
|
suffixes = ["gcode"]
|
||||||
|
)
|
||||||
|
)
|
||||||
self._supported_extensions = [".gcode", ".g"]
|
self._supported_extensions = [".gcode", ".g"]
|
||||||
|
|
||||||
self._flavor_reader = None
|
self._flavor_reader = None
|
||||||
|
|
||||||
Application.getInstance().getPreferences().addPreference("gcodereader/show_caution", True)
|
Application.getInstance().getPreferences().addPreference("gcodereader/show_caution", True)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#Copyright (c) 2018 Ultimaker B.V.
|
#Copyright (c) 2018 Ultimaker B.V.
|
||||||
#Cura is released under the terms of the LGPLv3 or higher.
|
#Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
from Charon.VirtualFile import VirtualFile #To open UFP files.
|
from Charon.VirtualFile import VirtualFile #To open UFP files.
|
||||||
|
@ -9,6 +10,7 @@ from io import StringIO #For converting g-code to bytes.
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Mesh.MeshWriter import MeshWriter #The writer we need to implement.
|
from UM.Mesh.MeshWriter import MeshWriter #The writer we need to implement.
|
||||||
|
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
|
||||||
from UM.PluginRegistry import PluginRegistry #To get the g-code writer.
|
from UM.PluginRegistry import PluginRegistry #To get the g-code writer.
|
||||||
from PyQt5.QtCore import QBuffer
|
from PyQt5.QtCore import QBuffer
|
||||||
|
|
||||||
|
@ -22,6 +24,15 @@ catalog = i18nCatalog("cura")
|
||||||
class UFPWriter(MeshWriter):
|
class UFPWriter(MeshWriter):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(add_to_recent_files = False)
|
super().__init__(add_to_recent_files = False)
|
||||||
|
|
||||||
|
MimeTypeDatabase.addMimeType(
|
||||||
|
MimeType(
|
||||||
|
name = "application/x-cura-stl-file",
|
||||||
|
comment = "Cura UFP File",
|
||||||
|
suffixes = ["ufp"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self._snapshot = None
|
self._snapshot = None
|
||||||
Application.getInstance().getOutputDeviceManager().writeStarted.connect(self._createSnapshot)
|
Application.getInstance().getOutputDeviceManager().writeStarted.connect(self._createSnapshot)
|
||||||
|
|
||||||
|
|
|
@ -11,16 +11,6 @@ except ImportError:
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog #To translate the file format description.
|
from UM.i18n import i18nCatalog #To translate the file format description.
|
||||||
from UM.Mesh.MeshWriter import MeshWriter #For the binary mode flag.
|
from UM.Mesh.MeshWriter import MeshWriter #For the binary mode flag.
|
||||||
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
|
|
||||||
|
|
||||||
|
|
||||||
MimeTypeDatabase.addMimeType(
|
|
||||||
MimeType(
|
|
||||||
name = "application/x-cura-stl-file",
|
|
||||||
comment = "Cura UFP File",
|
|
||||||
suffixes = ["ufp"]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
i18n_catalog = i18nCatalog("cura")
|
i18n_catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue