mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 17:25:57 +08:00
Fix file name update
CURA-5122
This commit is contained in:
parent
d7b0f11ddf
commit
f97e615634
@ -309,16 +309,13 @@ class PrintInformation(QObject):
|
|||||||
|
|
||||||
self.jobNameChanged.emit()
|
self.jobNameChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty(str)
|
|
||||||
def baseName(self):
|
|
||||||
return self._base_name
|
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def setProjectName(self, name):
|
def setProjectName(self, name):
|
||||||
self.setBaseName(name, is_project_file = True)
|
self.setBaseName(name, is_project_file = True)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
baseNameChanged = pyqtSignal()
|
||||||
def setBaseName(self, base_name, is_project_file = False):
|
|
||||||
|
def setBaseName(self, base_name: str, is_project_file: bool = False):
|
||||||
# Ensure that we don't use entire path but only filename
|
# Ensure that we don't use entire path but only filename
|
||||||
name = os.path.basename(base_name)
|
name = os.path.basename(base_name)
|
||||||
|
|
||||||
@ -336,6 +333,9 @@ class PrintInformation(QObject):
|
|||||||
self._base_name = name
|
self._base_name = name
|
||||||
self._updateJobName()
|
self._updateJobName()
|
||||||
|
|
||||||
|
@pyqtProperty(str, fset = setBaseName, notify = baseNameChanged)
|
||||||
|
def baseName(self):
|
||||||
|
return self._base_name
|
||||||
|
|
||||||
## Created an acronymn-like abbreviated machine name from the currently active machine name
|
## Created an acronymn-like abbreviated machine name from the currently active machine name
|
||||||
# Called each time the global stack is switched
|
# Called each time the global stack is switched
|
||||||
@ -395,7 +395,6 @@ class PrintInformation(QObject):
|
|||||||
|
|
||||||
## Listen to scene changes to check if we need to reset the print information
|
## Listen to scene changes to check if we need to reset the print information
|
||||||
def _onSceneChanged(self, scene_node):
|
def _onSceneChanged(self, scene_node):
|
||||||
|
|
||||||
# Ignore any changes that are not related to sliceable objects
|
# Ignore any changes that are not related to sliceable objects
|
||||||
if not isinstance(scene_node, SceneNode)\
|
if not isinstance(scene_node, SceneNode)\
|
||||||
or not scene_node.callDecoration("isSliceable")\
|
or not scene_node.callDecoration("isSliceable")\
|
||||||
|
@ -13,7 +13,7 @@ Item {
|
|||||||
id: base
|
id: base
|
||||||
|
|
||||||
property bool activity: CuraApplication.platformActivity
|
property bool activity: CuraApplication.platformActivity
|
||||||
property string fileBaseName: ""
|
property string fileBaseName: PrintInformation.baseName
|
||||||
|
|
||||||
UM.I18nCatalog { id: catalog; name:"cura"}
|
UM.I18nCatalog { id: catalog; name:"cura"}
|
||||||
|
|
||||||
@ -24,26 +24,17 @@ Item {
|
|||||||
target: backgroundItem
|
target: backgroundItem
|
||||||
onHasMesh:
|
onHasMesh:
|
||||||
{
|
{
|
||||||
if (base.fileBaseName == "")
|
if (PrintInformation.baseName == "")
|
||||||
{
|
{
|
||||||
base.fileBaseName = name;
|
PrintInformation.baseName = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onActivityChanged: {
|
onActivityChanged: {
|
||||||
if (activity == true && base.fileBaseName == ''){
|
if (activity == false) {
|
||||||
//this only runs when you open a file from the terminal (or something that works the same way; for example when you drag a file on the icon in MacOS or use 'open with' on Windows)
|
|
||||||
base.fileBaseName = PrintInformation.baseName; //get the fileBaseName from PrintInformation.py because this saves the filebase when the file is opened using the terminal (or something alike)
|
|
||||||
PrintInformation.setBaseName(base.fileBaseName);
|
|
||||||
}
|
|
||||||
if (activity == true && base.fileBaseName != ''){
|
|
||||||
//this runs in all other cases where there is a mesh on the buildplate (activity == true). It uses the fileBaseName from the hasMesh signal
|
|
||||||
PrintInformation.setBaseName(base.fileBaseName);
|
|
||||||
}
|
|
||||||
if (activity == false){
|
|
||||||
//When there is no mesh in the buildplate; the printJobTextField is set to an empty string so it doesn't set an empty string as a jobName (which is later used for saving the file)
|
//When there is no mesh in the buildplate; the printJobTextField is set to an empty string so it doesn't set an empty string as a jobName (which is later used for saving the file)
|
||||||
PrintInformation.setBaseName('')
|
PrintInformation.baseName = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user