mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-11 05:19: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):
|
def addRequiredAction(self, definition_id, action_key):
|
||||||
if action_key in self._machine_actions:
|
if action_key in self._machine_actions:
|
||||||
if definition_id in self._required_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:
|
else:
|
||||||
self._required_actions[definition_id] = {self._machine_actions[action_key]}
|
self._required_actions[definition_id] = [self._machine_actions[action_key]]
|
||||||
else:
|
else:
|
||||||
raise UnknownMachineActionError("Action %s, which is required for %s is not known." % (action_key, definition_id))
|
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):
|
def addSupportedAction(self, definition_id, action_key):
|
||||||
if action_key in self._machine_actions:
|
if action_key in self._machine_actions:
|
||||||
if definition_id in self._supported_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:
|
else:
|
||||||
self._supported_actions[definition_id] = {self._machine_actions[action_key]}
|
self._supported_actions[definition_id] = [self._machine_actions[action_key]]
|
||||||
else:
|
else:
|
||||||
Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, definition_id)
|
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,
|
"visible": true,
|
||||||
"author": "Calvindog717",
|
"author": "Calvindog717",
|
||||||
"manufacturer": "PrintrBot",
|
"manufacturer": "PrintrBot",
|
||||||
|
"category": "Other",
|
||||||
"file_formats": "text/x-gcode"
|
"file_formats": "text/x-gcode"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"preferred_material": "*pla*",
|
"preferred_material": "*pla*",
|
||||||
"preferred_quality": "*normal*",
|
"preferred_quality": "*normal*",
|
||||||
"first_start_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel"],
|
"first_start_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel"],
|
||||||
"supported_actions": ["UMOCheckup", "UpgradeFirmware", "BedLevel", "UMOUpgradeSelection"]
|
"supported_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel", "UpgradeFirmware"]
|
||||||
},
|
},
|
||||||
|
|
||||||
"overrides": {
|
"overrides": {
|
||||||
|
@ -16,12 +16,23 @@ UM.Dialog
|
|||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
title: catalog.i18nc("@title:window", "Add Printer")
|
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)
|
signal machineAdded(string id)
|
||||||
function getMachineName()
|
function getMachineName()
|
||||||
{
|
{
|
||||||
var name = machineList.model.getItem(machineList.currentIndex).name
|
var name = machineList.model.get(machineList.currentIndex).name
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,16 +47,32 @@ UM.Dialog
|
|||||||
right: parent.right;
|
right: parent.right;
|
||||||
bottom: parent.bottom;
|
bottom: parent.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView
|
ListView
|
||||||
{
|
{
|
||||||
id: machineList
|
id: machineList
|
||||||
|
|
||||||
model: UM.DefinitionContainersModel
|
model: ListModel
|
||||||
{
|
{
|
||||||
id: machineDefinitionsModel
|
id: sortedMachineDefinitionsModel
|
||||||
filter: {"visible":true}
|
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);
|
||||||
|
}
|
||||||
|
for(var i in items) {
|
||||||
|
sortedMachineDefinitionsModel.append(items[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
section.property: "manufacturer"
|
|
||||||
|
section.property: "category"
|
||||||
section.delegate: Button
|
section.delegate: Button
|
||||||
{
|
{
|
||||||
text: section
|
text: section
|
||||||
@ -76,16 +103,25 @@ UM.Dialog
|
|||||||
sourceSize.width: width
|
sourceSize.width: width
|
||||||
sourceSize.height: width
|
sourceSize.height: width
|
||||||
color: palette.windowText
|
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:
|
onClicked:
|
||||||
{
|
{
|
||||||
base.activeManufacturer = section;
|
base.activeCategory = section;
|
||||||
machineList.currentIndex = machineList.model.find("manufacturer", section)
|
if (machineList.model.get(machineList.currentIndex).category != section) {
|
||||||
machineName.text = getMachineName()
|
// 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
|
states: State
|
||||||
{
|
{
|
||||||
name: "collapsed";
|
name: "collapsed";
|
||||||
when: base.activeManufacturer != model.manufacturer;
|
when: base.activeCategory != model.category;
|
||||||
|
|
||||||
PropertyChanges { target: machineButton; opacity: 0; height: 0; }
|
PropertyChanges { target: machineButton; opacity: 0; height: 0; }
|
||||||
}
|
}
|
||||||
@ -161,7 +197,7 @@ UM.Dialog
|
|||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
base.visible = false
|
base.visible = false
|
||||||
var item = machineList.model.getItem(machineList.currentIndex);
|
var item = machineList.model.get(machineList.currentIndex);
|
||||||
Cura.MachineManager.addMachine(machineName.text, item.id)
|
Cura.MachineManager.addMachine(machineName.text, item.id)
|
||||||
base.machineAdded(item.id) // Emit signal that the user added a machine.
|
base.machineAdded(item.id) // Emit signal that the user added a machine.
|
||||||
}
|
}
|
||||||
@ -174,6 +210,11 @@ UM.Dialog
|
|||||||
id: catalog;
|
id: catalog;
|
||||||
name: "cura";
|
name: "cura";
|
||||||
}
|
}
|
||||||
|
UM.DefinitionContainersModel
|
||||||
|
{
|
||||||
|
id: machineDefinitionsModel
|
||||||
|
filter: { "visible": true }
|
||||||
|
}
|
||||||
SystemPalette { id: palette }
|
SystemPalette { id: palette }
|
||||||
ExclusiveGroup { id: printerGroup; }
|
ExclusiveGroup { id: printerGroup; }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user