From b46f6e8e09582f49216e4f0af295a413b78c9e7e Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 5 Dec 2023 18:24:44 +0100 Subject: [PATCH] Add support for CLI file opening with 'cura' and 'slicer' schemes CURA-11288 --- cura/CuraApplication.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 079a27b6ce..a71b6d9915 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -276,6 +276,8 @@ class CuraApplication(QtApplication): self._conan_installs = ApplicationMetadata.CONAN_INSTALLS self._python_installs = ApplicationMetadata.PYTHON_INSTALLS + self._supported_url_schemes: List[str] = ["cura", "slicer"] + @pyqtProperty(str, constant=True) def ultimakerCloudApiRootUrl(self) -> str: return UltimakerCloudConstants.CuraCloudAPIRoot @@ -328,7 +330,11 @@ class CuraApplication(QtApplication): assert not "This crash is triggered by the trigger_early_crash command line argument." for filename in self._cli_args.file: - self._files_to_open.append(os.path.abspath(filename)) + url = QUrl(filename) + if url.scheme() in self._supported_url_schemes: + self._open_url_queue.append(url) + else: + self._files_to_open.append(os.path.abspath(filename)) def initialize(self) -> None: self.__addExpectedResourceDirsAndSearchPaths() # Must be added before init of super @@ -1794,8 +1800,7 @@ class CuraApplication(QtApplication): self.readLocalFile(QUrl.fromLocalFile(filename)) def _openUrl(self, url: QUrl) -> None: - supported_schemes = ["cura", "slicer"] - if url.scheme() not in supported_schemes: + if url.scheme() not in self._supported_url_schemes: # only handle cura:// and slicer:// urls schemes return