CustomQualityProfilesDropDownMenuModel.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from UM.Logger import Logger
  4. from cura.Machines.Models.QualityProfilesDropDownMenuModel import QualityProfilesDropDownMenuModel
  5. #
  6. # This model is used for the custom profile items in the profile drop down menu.
  7. #
  8. class CustomQualityProfilesDropDownMenuModel(QualityProfilesDropDownMenuModel):
  9. def _update(self):
  10. Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
  11. active_global_stack = self._machine_manager.activeMachine
  12. if active_global_stack is None:
  13. self.setItems([])
  14. Logger.log("d", "No active GlobalStack, set %s as empty.", self.__class__.__name__)
  15. return
  16. quality_changes_group_dict = self._quality_manager.getQualityChangesGroups(active_global_stack)
  17. item_list = []
  18. for key in sorted(quality_changes_group_dict, key = lambda name: name.upper()):
  19. quality_changes_group = quality_changes_group_dict[key]
  20. item = {"name": quality_changes_group.name,
  21. "layer_height": "",
  22. "layer_height_without_unit": "",
  23. "available": quality_changes_group.is_available,
  24. "quality_changes_group": quality_changes_group}
  25. item_list.append(item)
  26. self.setItems(item_list)