Merge remote-tracking branch 'origin/master' into CURA-5059_reset_icon_visibility

This commit is contained in:
Lipu Fei 2018-03-13 10:25:01 +01:00
commit 40d3e09d90
36 changed files with 617 additions and 275 deletions

View file

@ -194,14 +194,31 @@ UM.MainWindow
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
MenuSeparator {
MenuSeparator
{
visible: Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials
}
MenuItem {
MenuItem
{
text: catalog.i18nc("@action:inmenu", "Set as Active Extruder")
onTriggered: Cura.ExtruderManager.setActiveExtruderIndex(model.index)
onTriggered: Cura.MachineManager.setExtruderIndex(model.index)
}
MenuItem
{
text: catalog.i18nc("@action:inmenu", "Enable Extruder")
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true)
visible: !Cura.MachineManager.getExtruder(model.index).isEnabled
}
MenuItem
{
text: catalog.i18nc("@action:inmenu", "Disable Extruder")
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, false)
visible: Cura.MachineManager.getExtruder(model.index).isEnabled
}
}
onObjectAdded: settingsMenu.insertItem(index, object)
onObjectRemoved: settingsMenu.removeItem(object)

View file

@ -19,7 +19,7 @@ Button
iconSource: UM.Theme.getIcon("extruder_button")
checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1
enabled: UM.Selection.hasSelection
enabled: UM.Selection.hasSelection && extruder.stack.isEnabled
property color customColor: base.hovered ? UM.Theme.getColor("button_hover") : UM.Theme.getColor("button");

View file

@ -19,14 +19,17 @@ Item
UM.I18nCatalog { id: catalog; name: "cura"; }
Cura.MaterialManagementModel {
Cura.MaterialManagementModel
{
id: materialsModel
}
Label {
Label
{
id: titleLabel
anchors {
anchors
{
top: parent.top
left: parent.left
right: parent.right
@ -170,22 +173,27 @@ Item
Connections
{
target: materialsModel
onItemsChanged: {
onItemsChanged:
{
var currentItemId = base.currentItem == null ? "" : base.currentItem.root_material_id;
var position = Cura.ExtruderManager.activeExtruderIndex;
// try to pick the currently selected item; it may have been moved
if (base.newRootMaterialIdToSwitchTo == "") {
if (base.newRootMaterialIdToSwitchTo == "")
{
base.newRootMaterialIdToSwitchTo = currentItemId;
}
for (var idx = 0; idx < materialsModel.rowCount(); ++idx) {
for (var idx = 0; idx < materialsModel.rowCount(); ++idx)
{
var item = materialsModel.getItem(idx);
if (item.root_material_id == base.newRootMaterialIdToSwitchTo) {
if (item.root_material_id == base.newRootMaterialIdToSwitchTo)
{
// Switch to the newly created profile if needed
materialListView.currentIndex = idx;
materialListView.activateDetailsWithIndex(materialListView.currentIndex);
if (base.toActivateNewMaterial) {
if (base.toActivateNewMaterial)
{
Cura.MachineManager.setMaterial(position, item.container_node);
}
base.newRootMaterialIdToSwitchTo = "";
@ -196,7 +204,8 @@ Item
materialListView.currentIndex = 0;
materialListView.activateDetailsWithIndex(materialListView.currentIndex);
if (base.toActivateNewMaterial) {
if (base.toActivateNewMaterial)
{
Cura.MachineManager.setMaterial(position, materialsModel.getItem(0).container_node);
}
base.newRootMaterialIdToSwitchTo = "";
@ -233,14 +242,17 @@ Item
messageDialog.title = catalog.i18nc("@title:window", "Import Material");
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags <filename> or <message>!", "Could not import material <filename>%1</filename>: <message>%2</message>").arg(fileUrl).arg(result.message);
if (result.status == "success") {
if (result.status == "success")
{
messageDialog.icon = StandardIcon.Information;
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully imported material <filename>%1</filename>").arg(fileUrl);
}
else if (result.status == "duplicate") {
else if (result.status == "duplicate")
{
messageDialog.icon = StandardIcon.Warning;
}
else {
else
{
messageDialog.icon = StandardIcon.Critical;
}
messageDialog.open();
@ -260,12 +272,14 @@ Item
var result = Cura.ContainerManager.exportContainer(base.currentItem.root_material_id, selectedNameFilter, fileUrl);
messageDialog.title = catalog.i18nc("@title:window", "Export Material");
if (result.status == "error") {
if (result.status == "error")
{
messageDialog.icon = StandardIcon.Critical;
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags <filename> and <message>!", "Failed to export material to <filename>%1</filename>: <message>%2</message>").arg(fileUrl).arg(result.message);
messageDialog.open();
}
else if (result.status == "success") {
else if (result.status == "success")
{
messageDialog.icon = StandardIcon.Information;
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully exported material to <filename>%1</filename>").arg(result.path);
messageDialog.open();
@ -283,7 +297,8 @@ Item
Item {
id: contentsItem
anchors {
anchors
{
top: titleLabel.bottom
left: parent.left
right: parent.right
@ -297,7 +312,8 @@ Item
Item
{
anchors {
anchors
{
top: buttonRow.bottom
topMargin: UM.Theme.getSize("default_margin").height
left: parent.left
@ -310,12 +326,14 @@ Item
Label
{
id: captionLabel
anchors {
anchors
{
top: parent.top
left: parent.left
}
visible: text != ""
text: {
text:
{
var caption = catalog.i18nc("@action:label", "Printer") + ": " + Cura.MachineManager.activeMachineName;
if (Cura.MachineManager.hasVariants)
{
@ -330,14 +348,16 @@ Item
ScrollView
{
id: materialScrollView
anchors {
anchors
{
top: captionLabel.visible ? captionLabel.bottom : parent.top
topMargin: captionLabel.visible ? UM.Theme.getSize("default_margin").height : 0
bottom: parent.bottom
left: parent.left
}
Rectangle {
Rectangle
{
parent: viewport
anchors.fill: parent
color: palette.light
@ -418,13 +438,15 @@ Item
MouseArea
{
anchors.fill: parent
onClicked: {
onClicked:
{
parent.ListView.view.currentIndex = model.index;
}
}
}
function activateDetailsWithIndex(index) {
function activateDetailsWithIndex(index)
{
var model = materialsModel.getItem(index);
base.currentItem = model;
materialDetailsView.containerId = model.container_id;
@ -446,7 +468,8 @@ Item
{
id: detailsPanel
anchors {
anchors
{
left: materialScrollView.right
leftMargin: UM.Theme.getSize("default_margin").width
top: parent.top

View file

@ -11,7 +11,7 @@ Tab
{
id: base
property string extruderPosition: ""
property int extruderPosition: -1 //Denotes the global stack.
property var qualityItem: null
property bool isQualityItemCurrentlyActivated:

View file

@ -17,14 +17,39 @@ SettingItem
id: control
anchors.fill: parent
model: Cura.ExtrudersModel { onModelChanged: control.color = getItem(control.currentIndex).color }
model: Cura.ExtrudersModel
{
onModelChanged: {
control.color = getItem(control.currentIndex).color;
}
}
textRole: "name"
// knowing the extruder position, try to find the item index in the model
function getIndexByPosition(position)
{
for (var item_index in model.items)
{
var item = model.getItem(item_index)
if (item.index == position)
{
return item_index
}
}
return -1
}
onActivated:
{
forceActiveFocus();
propertyProvider.setPropertyValue("value", model.getItem(index).index);
if (model.getItem(index).enabled)
{
forceActiveFocus();
propertyProvider.setPropertyValue("value", model.getItem(index).index);
} else
{
currentIndex = propertyProvider.properties.value; // keep the old value
}
}
onActiveFocusChanged:
@ -64,6 +89,23 @@ SettingItem
value: control.currentText != "" ? control.model.getItem(control.currentIndex).color : ""
}
Binding
{
target: control
property: "currentIndex"
value:
{
if(propertyProvider.properties.value == -1)
{
return control.getIndexByPosition(Cura.MachineManager.defaultExtruderPosition);
}
return propertyProvider.properties.value
}
// Sometimes when the value is already changed, the model is still being built.
// The when clause ensures that the current index is not updated when this happens.
when: control.model.items.length > 0
}
indicator: UM.RecolorImage
{
id: downArrow
@ -173,7 +215,13 @@ SettingItem
{
text: model.name
renderType: Text.NativeRendering
color: UM.Theme.getColor("setting_control_text")
color: {
if (model.enabled) {
UM.Theme.getColor("setting_control_text")
} else {
UM.Theme.getColor("action_button_disabled_text");
}
}
font: UM.Theme.getFont("default")
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter

View file

@ -91,10 +91,39 @@ Column
exclusiveGroup: extruderMenuGroup
checked: base.currentExtruderIndex == index
onClicked:
MouseArea
{
forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
Cura.ExtruderManager.setActiveExtruderIndex(index);
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
switch (mouse.button) {
case Qt.LeftButton:
forceActiveFocus(); // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
Cura.ExtruderManager.setActiveExtruderIndex(index);
break;
case Qt.RightButton:
extruderMenu.popup();
break;
}
}
}
Menu
{
id: extruderMenu
MenuItem {
text: catalog.i18nc("@action:inmenu", "Enable Extruder")
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true)
visible: !Cura.MachineManager.getExtruder(model.index).isEnabled
}
MenuItem {
text: catalog.i18nc("@action:inmenu", "Disable Extruder")
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, false)
visible: Cura.MachineManager.getExtruder(model.index).isEnabled
}
}
style: ButtonStyle
@ -114,6 +143,18 @@ Column
Behavior on color { ColorAnimation { duration: 50; } }
}
function buttonColor(index) {
var extruder = Cura.MachineManager.getExtruder(index);
if (extruder.isEnabled) {
return (
control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_text") :
control.hovered ? UM.Theme.getColor("action_button_hovered_text") :
UM.Theme.getColor("action_button_text");
} else {
return UM.Theme.getColor("action_button_disabled_text");
}
}
Item
{
id: extruderButtonFace
@ -131,9 +172,7 @@ Column
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_text") :
control.hovered ? UM.Theme.getColor("action_button_hovered_text") :
UM.Theme.getColor("action_button_text")
color: buttonColor(index)
font: UM.Theme.getFont("large_nonbold")
text: catalog.i18nc("@label", "Extruder")
@ -176,9 +215,7 @@ Column
id: extruderNumberText
anchors.centerIn: parent
text: index + 1;
color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_text") :
control.hovered ? UM.Theme.getColor("action_button_hovered_text") :
UM.Theme.getColor("action_button_text")
color: buttonColor(index)
font: UM.Theme.getFont("default_bold")
}

View file

@ -19,7 +19,7 @@ Item
property Action configureSettings;
property variant minimumPrintTime: PrintInformation.minimumPrintTime;
property variant maximumPrintTime: PrintInformation.maximumPrintTime;
property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || extrudersEnabledCount.properties.value == 1
Component.onCompleted: PrintInformation.enabled = true
Component.onDestruction: PrintInformation.enabled = false
@ -67,10 +67,8 @@ Item
Connections
{
target: Cura.MachineManager
onActiveQualityChanged: qualityModel.update()
onActiveMaterialChanged: qualityModel.update()
onActiveVariantChanged: qualityModel.update()
target: Cura.QualityProfilesDropDownMenuModel
onItemsChanged: qualityModel.update()
}
Connections {
@ -788,25 +786,10 @@ Item
}
}
Label
{
id: supportExtruderLabel
visible: supportExtruderCombobox.visible
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
anchors.right: infillCellLeft.right
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
anchors.verticalCenter: supportExtruderCombobox.verticalCenter
text: catalog.i18nc("@label", "Support Extruder");
font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text");
elide: Text.ElideRight
}
ComboBox
{
id: supportExtruderCombobox
visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)
visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1)
model: extruderModel
property string color_override: "" // for manually setting values
@ -820,11 +803,12 @@ Item
textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started
anchors.top: enableSupportCheckBox.bottom
anchors.topMargin: ((supportEnabled.properties.value === "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("sidebar_margin").height : 0
anchors.left: infillCellRight.left
anchors.top: enableSupportCheckBox.top
//anchors.topMargin: ((supportEnabled.properties.value === "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("sidebar_margin").height : 0
anchors.left: enableSupportCheckBox.right
anchors.leftMargin: Math.round(UM.Theme.getSize("sidebar_margin").width / 2)
width: Math.round(UM.Theme.getSize("sidebar").width * .55)
width: Math.round(UM.Theme.getSize("sidebar").width * .55) - Math.round(UM.Theme.getSize("sidebar_margin").width / 2) - enableSupportCheckBox.width
height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0
Behavior on height { NumberAnimation { duration: 100 } }
@ -891,7 +875,7 @@ Item
id: adhesionCheckBox
property alias _hovered: adhesionMouseArea.containsMouse
anchors.top: enableSupportCheckBox.visible ? supportExtruderCombobox.bottom : infillCellRight.bottom
anchors.top: enableSupportCheckBox.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.left: infillCellRight.left
@ -1022,9 +1006,9 @@ Item
UM.SettingPropertyProvider
{
id: machineExtruderCount
id: extrudersEnabledCount
containerStackId: Cura.MachineManager.activeMachineId
key: "machine_extruder_count"
key: "extruders_enabled_count"
watchedProperties: [ "value" ]
storeIndex: 0
}