mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-06-26 01:15:28 -06:00
Moved calculating UCP only to Preread and getting value here
CURA-11403
This commit is contained in:
parent
0e70b80446
commit
b119a010ca
3 changed files with 8 additions and 12 deletions
|
@ -1,6 +1,5 @@
|
|||
# Copyright (c) 2023 UltiMaker
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
import zipfile
|
||||
from typing import List, cast
|
||||
|
||||
from PyQt6.QtCore import QObject, QUrl, pyqtSignal, pyqtProperty
|
||||
|
@ -33,8 +32,6 @@ from cura.Operations.SetBuildPlateNumberOperation import SetBuildPlateNumberOper
|
|||
from UM.Logger import Logger
|
||||
from UM.Scene.SceneNode import SceneNode
|
||||
|
||||
USER_SETTINGS_PATH = "Cura/user-settings.json"
|
||||
|
||||
class CuraActions(QObject):
|
||||
def __init__(self, parent: QObject = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
@ -196,13 +193,6 @@ class CuraActions(QObject):
|
|||
operation.addOperation(SetObjectExtruderOperation(node, extruder_id))
|
||||
operation.push()
|
||||
|
||||
@pyqtSlot(str, result = bool)
|
||||
def isProjectUcp(self, file_url) -> bool:
|
||||
file_name = QUrl(file_url).toLocalFile()
|
||||
archive = zipfile.ZipFile(file_name, "r")
|
||||
cura_file_names = [name for name in archive.namelist() if name.startswith("Cura/")]
|
||||
return USER_SETTINGS_PATH in cura_file_names
|
||||
|
||||
@pyqtSlot(int)
|
||||
def setBuildPlateForSelection(self, build_plate_nr: int) -> None:
|
||||
Logger.log("d", "Setting build plate number... %d" % build_plate_nr)
|
||||
|
|
|
@ -2194,6 +2194,12 @@ class CuraApplication(QtApplication):
|
|||
def addNonSliceableExtension(self, extension):
|
||||
self._non_sliceable_extensions.append(extension)
|
||||
|
||||
@pyqtSlot(str, result = bool)
|
||||
def isProjectUcp(self, file_url) -> bool:
|
||||
file_path = QUrl(file_url).toLocalFile()
|
||||
workspace_reader = self.getWorkspaceFileHandler().getReaderForFile(file_path)
|
||||
return workspace_reader.getIsProjectUcp()
|
||||
|
||||
@pyqtSlot(str, result=bool)
|
||||
def checkIsValidProjectFile(self, file_url):
|
||||
"""Checks if the given file URL is a valid project file. """
|
||||
|
|
|
@ -702,7 +702,7 @@ UM.MainWindow
|
|||
if (hasProjectFile)
|
||||
{
|
||||
var projectFile = projectFileUrlList[0]
|
||||
var is_ucp = CuraActions.isProjectUcp(projectFile);
|
||||
var is_ucp = CuraApplication.isProjectUcp(projectFile);
|
||||
if (is_ucp)
|
||||
{
|
||||
askOpenAsProjectOrUcpOrImportModelsDialog.fileUrl = projectFile;
|
||||
|
@ -788,7 +788,7 @@ UM.MainWindow
|
|||
target: CuraApplication
|
||||
function onOpenProjectFile(project_file, add_to_recent_files)
|
||||
{
|
||||
var is_ucp = CuraActions.isProjectUcp(project_file);
|
||||
var is_ucp = CuraApplication.isProjectUcp(project_file);
|
||||
if (is_ucp)
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue