mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-11 01:59:00 +08:00
Merge branch 'master' of github.com:Ultimaker/Cura
This commit is contained in:
commit
1261cf975e
@ -57,9 +57,10 @@ class MachineActionManager(QObject):
|
||||
def addRequiredAction(self, definition_id, action_key):
|
||||
if action_key in self._machine_actions:
|
||||
if definition_id in self._required_actions:
|
||||
self._required_actions[definition_id] |= {self._machine_actions[action_key]}
|
||||
if self._machine_actions[action_key] not in self._required_actions[definition_id]:
|
||||
self._required_actions[definition_id].append(self._machine_actions[action_key])
|
||||
else:
|
||||
self._required_actions[definition_id] = {self._machine_actions[action_key]}
|
||||
self._required_actions[definition_id] = [self._machine_actions[action_key]]
|
||||
else:
|
||||
raise UnknownMachineActionError("Action %s, which is required for %s is not known." % (action_key, definition_id))
|
||||
|
||||
@ -67,9 +68,10 @@ class MachineActionManager(QObject):
|
||||
def addSupportedAction(self, definition_id, action_key):
|
||||
if action_key in self._machine_actions:
|
||||
if definition_id in self._supported_actions:
|
||||
self._supported_actions[definition_id] |= {self._machine_actions[action_key]}
|
||||
if self._machine_actions[action_key] not in self._supported_actions[definition_id]:
|
||||
self._supported_actions[definition_id].append(self._machine_actions[action_key])
|
||||
else:
|
||||
self._supported_actions[definition_id] = {self._machine_actions[action_key]}
|
||||
self._supported_actions[definition_id] = [self._machine_actions[action_key]]
|
||||
else:
|
||||
Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, definition_id)
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
"visible": true,
|
||||
"author": "Calvindog717",
|
||||
"manufacturer": "PrintrBot",
|
||||
"category": "Other",
|
||||
"file_formats": "text/x-gcode"
|
||||
},
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"preferred_material": "*pla*",
|
||||
"preferred_quality": "*normal*",
|
||||
"first_start_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel"],
|
||||
"supported_actions": ["UMOCheckup", "UpgradeFirmware", "BedLevel", "UMOUpgradeSelection"]
|
||||
"supported_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel", "UpgradeFirmware"]
|
||||
},
|
||||
|
||||
"overrides": {
|
||||
|
@ -16,12 +16,23 @@ UM.Dialog
|
||||
{
|
||||
id: base
|
||||
title: catalog.i18nc("@title:window", "Add Printer")
|
||||
property string activeManufacturer: "Ultimaker";
|
||||
property string preferredCategory: "Ultimaker"
|
||||
property string activeCategory: preferredCategory
|
||||
|
||||
onVisibilityChanged:
|
||||
{
|
||||
// Reset selection and machine name
|
||||
if (visible) {
|
||||
activeCategory = preferredCategory;
|
||||
machineList.currentIndex = 0;
|
||||
machineName.text = getMachineName();
|
||||
}
|
||||
}
|
||||
|
||||
signal machineAdded(string id)
|
||||
function getMachineName()
|
||||
{
|
||||
var name = machineList.model.getItem(machineList.currentIndex).name
|
||||
var name = machineList.model.get(machineList.currentIndex).name
|
||||
return name
|
||||
}
|
||||
|
||||
@ -36,16 +47,32 @@ UM.Dialog
|
||||
right: parent.right;
|
||||
bottom: parent.bottom;
|
||||
}
|
||||
|
||||
ListView
|
||||
{
|
||||
id: machineList
|
||||
|
||||
model: UM.DefinitionContainersModel
|
||||
model: ListModel
|
||||
{
|
||||
id: machineDefinitionsModel
|
||||
filter: {"visible":true}
|
||||
id: sortedMachineDefinitionsModel
|
||||
Component.onCompleted: {
|
||||
// DefinitionContainersModel is sorted alphabetically, but we want the preferred
|
||||
// category on top so we create a custom-sorted ListModel from it.
|
||||
var items = [];
|
||||
for(var i in machineDefinitionsModel.items) {
|
||||
var item = machineDefinitionsModel.getItem(i);
|
||||
if (item["category"] == preferredCategory)
|
||||
sortedMachineDefinitionsModel.append(item);
|
||||
else
|
||||
items.push(item);
|
||||
}
|
||||
section.property: "manufacturer"
|
||||
for(var i in items) {
|
||||
sortedMachineDefinitionsModel.append(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
section.property: "category"
|
||||
section.delegate: Button
|
||||
{
|
||||
text: section
|
||||
@ -76,16 +103,25 @@ UM.Dialog
|
||||
sourceSize.width: width
|
||||
sourceSize.height: width
|
||||
color: palette.windowText
|
||||
source: base.activeManufacturer == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right")
|
||||
source: base.activeCategory == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClicked:
|
||||
{
|
||||
base.activeManufacturer = section;
|
||||
machineList.currentIndex = machineList.model.find("manufacturer", section)
|
||||
machineName.text = getMachineName()
|
||||
base.activeCategory = section;
|
||||
if (machineList.model.get(machineList.currentIndex).category != section) {
|
||||
// Find the first machine from this category
|
||||
for(var i = 0; i < sortedMachineDefinitionsModel.count; i++) {
|
||||
var item = sortedMachineDefinitionsModel.get(i);
|
||||
if (item.category == section) {
|
||||
machineList.currentIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
machineName.text = getMachineName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +150,7 @@ UM.Dialog
|
||||
states: State
|
||||
{
|
||||
name: "collapsed";
|
||||
when: base.activeManufacturer != model.manufacturer;
|
||||
when: base.activeCategory != model.category;
|
||||
|
||||
PropertyChanges { target: machineButton; opacity: 0; height: 0; }
|
||||
}
|
||||
@ -161,7 +197,7 @@ UM.Dialog
|
||||
onClicked:
|
||||
{
|
||||
base.visible = false
|
||||
var item = machineList.model.getItem(machineList.currentIndex);
|
||||
var item = machineList.model.get(machineList.currentIndex);
|
||||
Cura.MachineManager.addMachine(machineName.text, item.id)
|
||||
base.machineAdded(item.id) // Emit signal that the user added a machine.
|
||||
}
|
||||
@ -174,6 +210,11 @@ UM.Dialog
|
||||
id: catalog;
|
||||
name: "cura";
|
||||
}
|
||||
UM.DefinitionContainersModel
|
||||
{
|
||||
id: machineDefinitionsModel
|
||||
filter: { "visible": true }
|
||||
}
|
||||
SystemPalette { id: palette }
|
||||
ExclusiveGroup { id: printerGroup; }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user