mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 15:13:56 -06:00
Merge branch 'main' into CURA-9365_fix_building_cura_main
This commit is contained in:
commit
93e58d55fa
6 changed files with 28 additions and 67 deletions
|
@ -1,7 +1,9 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
import glob
|
||||
import os
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, cast, Dict, List, Set, Tuple, TYPE_CHECKING, Optional
|
||||
|
||||
from UM.Logger import Logger
|
||||
|
@ -55,6 +57,26 @@ class CuraPackageManager(PackageManager):
|
|||
|
||||
super().initialize()
|
||||
|
||||
def isMaterialBundled(self, file_name: str, guid: str):
|
||||
""" Check if there is a bundled material name with file_name and guid """
|
||||
for path in Resources.getSecureSearchPaths():
|
||||
# Secure search paths are install directory paths, if a material is in here it must be bundled.
|
||||
|
||||
paths = [Path(p) for p in glob.glob(path + '/**/*.xml.fdm_material')]
|
||||
for material in paths:
|
||||
if material.name == file_name:
|
||||
with open(str(material), encoding="utf-8") as f:
|
||||
# Make sure the file we found has the same guid as our material
|
||||
# Parsing this xml would be better but the namespace is needed to search it.
|
||||
parsed_guid = PluginRegistry.getInstance().getPluginObject(
|
||||
"XmlMaterialProfile").getMetadataFromSerialized(
|
||||
f.read(), "GUID")
|
||||
if guid == parsed_guid:
|
||||
# The material we found matches both filename and GUID
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def getMaterialFilePackageId(self, file_name: str, guid: str) -> str:
|
||||
"""Get the id of the installed material package that contains file_name"""
|
||||
for material_package in [f for f in os.scandir(self._installation_dirs_dict["materials"]) if f.is_dir()]:
|
||||
|
|
|
@ -267,10 +267,15 @@ class ThreeMFWriter(MeshWriter):
|
|||
# Don't export materials not in use
|
||||
continue
|
||||
|
||||
if package_manager.isMaterialBundled(extruder.material.getFileName(), extruder.material.getMetaDataEntry("GUID")):
|
||||
# Don't export bundled materials
|
||||
continue
|
||||
|
||||
package_id = package_manager.getMaterialFilePackageId(extruder.material.getFileName(), extruder.material.getMetaDataEntry("GUID"))
|
||||
package_data = package_manager.getInstalledPackageInfo(package_id)
|
||||
|
||||
if not package_data:
|
||||
# We failed to find the package for this material
|
||||
message = Message(catalog.i18nc("@error:material",
|
||||
"It was not possible to store material package information in project file: {material}. This project may not open correctly on other systems.".format(material=extruder.getName())),
|
||||
title=catalog.i18nc("@info:title", "Failed to save material package information"),
|
||||
|
@ -278,9 +283,6 @@ class ThreeMFWriter(MeshWriter):
|
|||
message.show()
|
||||
continue
|
||||
|
||||
if package_data.get("is_bundled"):
|
||||
continue
|
||||
|
||||
material_metadata = {"id": package_id,
|
||||
"display_name": package_data.get("display_name") if package_data.get("display_name") else "",
|
||||
"package_version": package_data.get("package_version") if package_data.get("package_version") else "",
|
||||
|
|
|
@ -330,7 +330,7 @@ class PauseAtHeight(Script):
|
|||
|
||||
current_height = current_z - layer_0_z
|
||||
if current_height < pause_height:
|
||||
continue # Scan the enitre layer, z-changes are not always on the same/first line.
|
||||
continue # Scan the entire layer, z-changes are not always on the same/first line.
|
||||
|
||||
# Pause at layer
|
||||
else:
|
||||
|
|
|
@ -47,18 +47,6 @@ Item
|
|||
font: UM.Theme.getFont("medium")
|
||||
}
|
||||
|
||||
NoIntentIcon
|
||||
{
|
||||
affected_extruders: Cura.MachineManager.extruderPositionsWithNonActiveIntent
|
||||
intent_type: Cura.MachineManager.activeIntentCategory
|
||||
anchors.right: intentSelection.left
|
||||
anchors.rightMargin: UM.Theme.getSize("narrow_margin").width
|
||||
width: Math.round(profileLabel.height * 0.5)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
height: width
|
||||
visible: affected_extruders.length
|
||||
}
|
||||
|
||||
Button
|
||||
{
|
||||
id: intentSelection
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 2019 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.6 as Cura
|
||||
|
||||
Item
|
||||
{
|
||||
id: icon
|
||||
property var affected_extruders
|
||||
property var intent_type: ""
|
||||
|
||||
implicitWidth: UM.Theme.getSize("section_icon").width
|
||||
implicitHeight: UM.Theme.getSize("section_icon").height
|
||||
|
||||
UM.ColorImage
|
||||
{
|
||||
source: UM.Theme.getIcon("Information")
|
||||
color: UM.Theme.getColor("icon")
|
||||
anchors.fill: parent
|
||||
}
|
||||
MouseArea
|
||||
{
|
||||
anchors.fill: parent
|
||||
hoverEnabled: parent.visible
|
||||
onEntered:
|
||||
{
|
||||
var tooltipContent = catalog.i18ncp("@label %1 is filled in with the type of a profile. %2 is filled with a list of numbers (eg '1' or '1, 2')", "There is no %1 profile for the configuration in extruder %2. The default intent will be used instead", "There is no %1 profile for the configurations in extruders %2. The default intent will be used instead", affected_extruders.length).arg(intent_type).arg(affected_extruders)
|
||||
base.showTooltip(icon.parent, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent)
|
||||
}
|
||||
onExited: base.hideTooltip()
|
||||
}
|
||||
}
|
|
@ -178,22 +178,7 @@ Item
|
|||
intentTooltipTimer.stop()
|
||||
}
|
||||
}
|
||||
|
||||
NoIntentIcon // This icon has hover priority over intentDescriptionHoverArea, so draw it above it.
|
||||
{
|
||||
affected_extruders: Cura.MachineManager.extruderPositionsWithNonActiveIntent
|
||||
intent_type: model.name
|
||||
anchors.right: intentCategoryLabel.right
|
||||
anchors.rightMargin: UM.Theme.getSize("narrow_margin").width
|
||||
width: intentCategoryLabel.height * 0.75
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
height: width
|
||||
visible: Cura.MachineManager.activeIntentCategory == model.intent_category && affected_extruders.length
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue