Merge branch 'feature_intent'

Here we go!

Contributes to issue CURA-6864.
This commit is contained in:
Ghostkeeper 2019-10-08 13:17:54 +02:00
commit cf14fa6820
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
154 changed files with 5293 additions and 4600 deletions

View file

@ -1,10 +1,10 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.1
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import QtQuick 2.10
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
import UM 1.2 as UM
import Cura 1.0 as Cura
@ -139,22 +139,6 @@ UM.Dialog
}
}
}
Row
{
visible: Cura.MachineManager.hasVariantBuildplates
width: parent.width
height: childrenRect.height
Label
{
text: catalog.i18nc("@action:label", "Build plate")
width: Math.floor(scroll.width / 3) | 0
}
Label
{
text: Cura.activeStack != null ? Cura.MachineManager.activeStack.variant.name : ""
width: Math.floor(scroll.width / 3) | 0
}
}
Repeater
{
width: parent.width
@ -256,6 +240,23 @@ UM.Dialog
width: Math.floor(scroll.width / 3) | 0
}
}
// Intent
Row
{
width: parent.width
height: childrenRect.height
Label
{
text: catalog.i18nc("@action:label", "Intent")
width: Math.floor(scroll.width / 3) | 0
}
Label
{
text: Cura.MachineManager.activeIntentCategory
width: Math.floor(scroll.width / 3) | 0
}
}
}
}
}

View file

@ -0,0 +1,65 @@
// 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 QtQuick.Layouts 1.3
import UM 1.2 as UM
// The labelBar shows a set of labels that are evenly spaced from one another.
// The first item is aligned to the left, the last is aligned to the right.
// It's intended to be used together with RadioCheckBar. As such, it needs
// to know what the used itemSize is, so it can ensure the labels are aligned correctly.
Item
{
id: base
property var model: null
property string modelKey: ""
property int itemSize: 14
height: childrenRect.height
RowLayout
{
anchors.left: parent.left
anchors.right: parent.right
spacing: 0
Repeater
{
id: repeater
model: base.model
Item
{
Layout.fillWidth: true
Layout.maximumWidth: Math.round(index + 1 === repeater.count || repeater.count <= 1 ? itemSize : base.width / (repeater.count - 1))
height: label.height
Label
{
id: label
text: model[modelKey]
color: UM.Theme.getColor("text")
font: UM.Theme.getFont("default")
renderType: Text.NativeRendering
height: contentHeight
anchors
{
// Some magic to ensure that the items are aligned properly.
// We want the following:
// First item should be aligned to the left, no margin.
// Last item should be aligned to the right, no margin.
// The middle item(s) should be aligned to the center of the "item" it's showing (hence half the itemsize as offset).
// We want the center of the label to align with the center of the item, so we negatively offset by half the contentWidth
right: index + 1 === repeater.count ? parent.right: undefined
left: index + 1 === repeater.count || index === 0 ? undefined: parent.left
leftMargin: Math.round((itemSize - contentWidth) * 0.5)
// For some reason, the last label in the row gets misaligned with Qt 5.10. This lines seems to
// fix it.
verticalCenter: parent.verticalCenter
}
}
}
}
}
}

View file

@ -1,36 +0,0 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 1.4
import UM 1.2 as UM
import Cura 1.0 as Cura
Menu
{
id: menu
title: "Build plate"
property var buildPlateModel: CuraApplication.getBuildPlateModel()
Instantiator
{
model: menu.buildPlateModel
MenuItem {
text: model.name
checkable: true
checked: model.name == Cura.MachineManager.globalVariantName
exclusiveGroup: group
onTriggered: {
Cura.MachineManager.setGlobalVariant(model.container_node);
}
}
onObjectAdded: menu.insertItem(index, object)
onObjectRemoved: menu.removeItem(object)
}
ExclusiveGroup { id: group }
}

View file

@ -1,8 +1,8 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Controls.Styles 1.4
import UM 1.2 as UM
@ -99,12 +99,14 @@ Cura.ExpandablePopup
left: extruderIcon.right
leftMargin: UM.Theme.getSize("default_margin").width
top: typeAndBrandNameLabel.bottom
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
}
}
}
}
//Placeholder text if there is a configuration to select but no materials (so we can't show the materials per extruder).
// Placeholder text if there is a configuration to select but no materials (so we can't show the materials per extruder).
Label
{
text: catalog.i18nc("@label", "Select configuration")

View file

@ -14,7 +14,7 @@ Menu
property int extruderIndex: 0
property string currentRootMaterialId: Cura.MachineManager.currentRootMaterialId[extruderIndex]
property string activeMaterialId: Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
property string activeMaterialId: Cura.MachineManager.activeMachine.extruderList[extruderIndex].material.id
property bool updateModels: true
Cura.FavoriteMaterialsModel
{
@ -52,10 +52,10 @@ Menu
checkable: true
checked: model.root_material_id === menu.currentRootMaterialId
onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node)
exclusiveGroup: group
exclusiveGroup: favoriteGroup // One favorite and one item from the others can be active at the same time.
}
onObjectAdded: menu.insertItem(index, object)
onObjectRemoved: menu.removeItem(object) // TODO: This ain't gonna work, removeItem() takes an index, not object
onObjectRemoved: menu.removeItem(index)
}
MenuSeparator {}
@ -77,7 +77,7 @@ Menu
onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node)
}
onObjectAdded: genericMenu.insertItem(index, object)
onObjectRemoved: genericMenu.removeItem(object) // TODO: This ain't gonna work, removeItem() takes an index, not object
onObjectRemoved: genericMenu.removeItem(index)
}
}
@ -126,10 +126,16 @@ Menu
onObjectRemoved: menu.removeItem(object)
}
ExclusiveGroup {
ExclusiveGroup
{
id: group
}
ExclusiveGroup
{
id: favoriteGroup
}
MenuSeparator {}
MenuItem

View file

@ -1,84 +0,0 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 1.4
import UM 1.2 as UM
import Cura 1.0 as Cura
Menu
{
id: menu
Instantiator
{
model: Cura.QualityProfilesDropDownMenuModel
MenuItem
{
text:
{
var full_text = (model.layer_height != "") ? model.name + " - " + model.layer_height + model.layer_height_unit : model.name
full_text += model.is_experimental ? " - " + catalog.i18nc("@label", "Experimental") : ""
return full_text
}
checkable: true
checked: Cura.MachineManager.activeQualityOrQualityChangesName == model.name
exclusiveGroup: group
onTriggered: Cura.MachineManager.setQualityGroup(model.quality_group)
visible: model.available
}
onObjectAdded: menu.insertItem(index, object)
onObjectRemoved: menu.removeItem(object)
}
MenuSeparator
{
id: customSeparator
visible: Cura.CustomQualityProfilesDropDownMenuModel.count > 0
}
Instantiator
{
id: customProfileInstantiator
model: Cura.CustomQualityProfilesDropDownMenuModel
Connections
{
target: Cura.CustomQualityProfilesDropDownMenuModel
onModelReset: customSeparator.visible = Cura.CustomQualityProfilesDropDownMenuModel.count > 0
}
MenuItem
{
text: model.name
checkable: true
checked: Cura.MachineManager.activeQualityOrQualityChangesName == model.name
exclusiveGroup: group
onTriggered: Cura.MachineManager.setQualityChangesGroup(model.quality_changes_group)
}
onObjectAdded:
{
customSeparator.visible = model.count > 0;
menu.insertItem(index, object);
}
onObjectRemoved:
{
customSeparator.visible = model.count > 0;
menu.removeItem(object);
}
}
ExclusiveGroup { id: group; }
MenuSeparator { id: profileMenuSeparator }
MenuItem { action: Cura.Actions.addProfile }
MenuItem { action: Cura.Actions.updateProfile }
MenuItem { action: Cura.Actions.resetProfile }
MenuSeparator { }
MenuItem { action: Cura.Actions.manageProfiles }
}

View file

@ -22,7 +22,7 @@ Menu
Menu
{
title: modelData.name
property var extruder: Cura.MachineManager.getExtruder(model.index)
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
@ -41,14 +41,14 @@ Menu
{
text: catalog.i18nc("@action:inmenu", "Enable Extruder")
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true)
visible: !Cura.MachineManager.getExtruder(model.index).isEnabled
visible: extruder === null ? false : !extruder.isEnabled
}
MenuItem
{
text: catalog.i18nc("@action:inmenu", "Disable Extruder")
onTriggered: Cura.MachineManager.setExtruderEnabled(index, false)
visible: Cura.MachineManager.getExtruder(model.index).isEnabled
visible: extruder === null ? false : extruder.isEnabled
enabled: Cura.MachineManager.numberExtrudersEnabled > 1
}
@ -57,14 +57,6 @@ Menu
onObjectRemoved: base.removeItem(object)
}
// TODO Only show in dev mode. Remove check when feature ready
BuildplateMenu
{
title: catalog.i18nc("@title:menu", "&Build plate")
visible: CuraSDKVersion == "dev" && Cura.MachineManager.hasVariantBuildplates
}
ProfileMenu { title: catalog.i18nc("@title:settings", "&Profile") }
MenuSeparator { }
MenuItem { action: Cura.Actions.configureSettingVisibility }

View file

@ -7,7 +7,7 @@ import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
import UM 1.2 as UM
import Cura 1.0 as Cura
import Cura 1.5 as Cura
Item
{
@ -17,6 +17,8 @@ Item
property var resetEnabled: false
property var currentItem: null
property var materialManagementModel: CuraApplication.getMaterialManagementModel()
property var hasCurrentItem: base.currentItem != null
property var isCurrentItemActivated:
{
@ -119,7 +121,7 @@ Item
onClicked:
{
forceActiveFocus();
base.newRootMaterialIdToSwitchTo = CuraApplication.getMaterialManager().createMaterial();
base.newRootMaterialIdToSwitchTo = base.materialManagementModel.createMaterial();
base.toActivateNewMaterial = true;
}
}
@ -134,7 +136,7 @@ Item
onClicked:
{
forceActiveFocus();
base.newRootMaterialIdToSwitchTo = CuraApplication.getMaterialManager().duplicateMaterial(base.currentItem.container_node);
base.newRootMaterialIdToSwitchTo = base.materialManagementModel.duplicateMaterial(base.currentItem.container_node);
base.toActivateNewMaterial = true;
}
}
@ -145,7 +147,8 @@ Item
id: removeMenuButton
text: catalog.i18nc("@action:button", "Remove")
iconName: "list-remove"
enabled: base.hasCurrentItem && !base.currentItem.is_read_only && !base.isCurrentItemActivated && CuraApplication.getMaterialManager().canMaterialBeRemoved(base.currentItem.container_node)
enabled: base.hasCurrentItem && !base.currentItem.is_read_only && !base.isCurrentItemActivated && base.materialManagementModel.canMaterialBeRemoved(base.currentItem.container_node)
onClicked:
{
forceActiveFocus();
@ -294,7 +297,7 @@ Item
{
// Set the active material as the fallback. It will be selected when the current material is deleted
base.newRootMaterialIdToSwitchTo = base.active_root_material_id
CuraApplication.getMaterialManager().removeMaterial(base.currentItem.container_node);
base.materialManagementModel.removeMaterial(base.currentItem.container_node);
}
}

View file

@ -82,11 +82,12 @@ Rectangle
{
if (materialSlot.is_favorite)
{
CuraApplication.getMaterialManager().removeFavorite(material.root_material_id)
return
CuraApplication.getMaterialManagementModel().removeFavorite(material.root_material_id)
}
else
{
CuraApplication.getMaterialManagementModel().addFavorite(material.root_material_id)
}
CuraApplication.getMaterialManager().addFavorite(material.root_material_id)
return
}
style: ButtonStyle
{

View file

@ -23,6 +23,7 @@ TabView
property real secondColumnWidth: (width * 0.40) | 0
property string containerId: ""
property var materialPreferenceValues: UM.Preferences.getValue("cura/material_settings") ? JSON.parse(UM.Preferences.getValue("cura/material_settings")) : {}
property var materialManagementModel: CuraApplication.getMaterialManagementModel()
property double spoolLength: calculateSpoolLength()
property real costPerMeter: calculateCostPerMeter()
@ -565,7 +566,7 @@ TabView
}
// update the values
CuraApplication.getMaterialManager().setMaterialName(base.currentMaterialNode, new_name)
base.materialManagementModel.setMaterialName(base.currentMaterialNode, new_name)
properties.name = new_name
}

View file

@ -38,14 +38,28 @@ Tab
property var setting: qualitySettings.getItem(styleData.row)
height: childrenRect.height
width: (parent != null) ? parent.width : 0
text: (styleData.value.substr(0,1) == "=") ? styleData.value : ""
text:
{
if (styleData.value === undefined)
{
return ""
}
return (styleData.value.substr(0,1) == "=") ? styleData.value : ""
}
Label
{
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.right: parent.right
text: (styleData.value.substr(0,1) == "=") ? catalog.i18nc("@info:status", "Calculated") : styleData.value
text:
{
if (styleData.value === undefined)
{
return ""
}
return (styleData.value.substr(0,1) == "=") ? catalog.i18nc("@info:status", "Calculated") : styleData.value
}
font.strikeout: styleData.column == 1 && setting.user_value != "" && base.isQualityItemCurrentlyActivated
font.italic: setting.profile_value_source == "quality_changes" || (setting.user_value != "" && base.isQualityItemCurrentlyActivated)
opacity: font.strikeout ? 0.5 : 1

View file

@ -1,4 +1,4 @@
// Copyright (c) 2018 Ultimaker B.V.
// Copyright (c) 2019 Ultimaker B.V.
// Uranium is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
@ -7,26 +7,24 @@ import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
import UM 1.2 as UM
import Cura 1.0 as Cura
import Cura 1.6 as Cura
Item
{
id: base
property QtObject qualityManager: CuraApplication.getQualityManager()
property var resetEnabled: false // Keep PreferencesDialog happy
property var extrudersModel: CuraApplication.getExtrudersModel()
property var qualityManagementModel: CuraApplication.getQualityManagementModel()
UM.I18nCatalog { id: catalog; name: "cura"; }
Cura.QualityManagementModel {
id: qualitiesModel
}
Label {
Label
{
id: titleLabel
anchors {
anchors
{
top: parent.top
left: parent.left
right: parent.right
@ -38,28 +36,41 @@ Item
property var hasCurrentItem: base.currentItem != null
property var currentItem: {
property var currentItem:
{
var current_index = qualityListView.currentIndex;
return (current_index == -1) ? null : qualitiesModel.getItem(current_index);
return (current_index == -1) ? null : base.qualityManagementModel.getItem(current_index);
}
property var currentItemName: hasCurrentItem ? base.currentItem.name : ""
property var currentItemDisplayName: hasCurrentItem ? base.qualityManagementModel.getQualityItemDisplayName(base.currentItem) : ""
property var isCurrentItemActivated: {
if (!base.currentItem) {
property var isCurrentItemActivated:
{
if (!base.currentItem)
{
return false;
}
return base.currentItem.name == Cura.MachineManager.activeQualityOrQualityChangesName;
if (base.currentItem.is_read_only)
{
return (base.currentItem.name == Cura.MachineManager.activeQualityOrQualityChangesName) && (base.currentItem.intent_category == Cura.MachineManager.activeIntentCategory);
}
else
{
return base.currentItem.name == Cura.MachineManager.activeQualityOrQualityChangesName;
}
}
property var canCreateProfile: {
property var canCreateProfile:
{
return isCurrentItemActivated && Cura.MachineManager.hasUserSettings;
}
Row // Button Row
{
id: buttonRow
anchors {
anchors
{
left: parent.left
right: parent.right
top: titleLabel.bottom
@ -73,10 +84,14 @@ Item
text: catalog.i18nc("@action:button", "Activate")
iconName: "list-activate"
enabled: !isCurrentItemActivated
onClicked: {
if (base.currentItem.is_read_only) {
Cura.MachineManager.setQualityGroup(base.currentItem.quality_group);
} else {
onClicked:
{
if (base.currentItem.is_read_only)
{
Cura.IntentManager.selectIntent(base.currentItem.intent_category, base.currentItem.quality_type);
}
else
{
Cura.MachineManager.setQualityChangesGroup(base.currentItem.quality_changes_group);
}
}
@ -91,7 +106,8 @@ Item
enabled: base.canCreateProfile && !Cura.MachineManager.stacksHaveErrors
visible: base.canCreateProfile
onClicked: {
onClicked:
{
createQualityDialog.object = Cura.ContainerManager.makeUniqueName(base.currentItem.name);
createQualityDialog.open();
createQualityDialog.selectText();
@ -107,7 +123,8 @@ Item
enabled: !base.canCreateProfile
visible: !base.canCreateProfile
onClicked: {
onClicked:
{
duplicateQualityDialog.object = Cura.ContainerManager.makeUniqueName(base.currentItem.name);
duplicateQualityDialog.open();
duplicateQualityDialog.selectText();
@ -121,7 +138,8 @@ Item
text: catalog.i18nc("@action:button", "Remove")
iconName: "list-remove"
enabled: base.hasCurrentItem && !base.currentItem.is_read_only && !base.isCurrentItemActivated
onClicked: {
onClicked:
{
forceActiveFocus();
confirmRemoveQualityDialog.open();
}
@ -134,7 +152,8 @@ Item
text: catalog.i18nc("@action:button", "Rename")
iconName: "edit-rename"
enabled: base.hasCurrentItem && !base.currentItem.is_read_only
onClicked: {
onClicked:
{
renameQualityDialog.object = base.currentItem.name;
renameQualityDialog.open();
renameQualityDialog.selectText();
@ -147,7 +166,8 @@ Item
id: importMenuButton
text: catalog.i18nc("@action:button", "Import")
iconName: "document-import"
onClicked: {
onClicked:
{
importDialog.open();
}
}
@ -159,7 +179,8 @@ Item
text: catalog.i18nc("@action:button", "Export")
iconName: "document-export"
enabled: base.hasCurrentItem && !base.currentItem.is_read_only
onClicked: {
onClicked:
{
exportDialog.open();
}
}
@ -185,7 +206,7 @@ Item
{
base.newQualityNameToSelect = newName; // We want to switch to the new profile once it's created
base.toActivateNewQuality = true;
base.qualityManager.createQualityChanges(newName);
base.qualityManagementModel.createQualityChanges(newName);
}
}
@ -195,7 +216,7 @@ Item
// This connection makes sure that we will switch to the correct quality after the model gets updated
Connections
{
target: qualitiesModel
target: base.qualityManagementModel
onItemsChanged:
{
var toSelectItemName = base.currentItem == null ? "" : base.currentItem.name;
@ -208,9 +229,9 @@ Item
if (toSelectItemName != "")
{
// Select the required quality name if given
for (var idx = 0; idx < qualitiesModel.count; ++idx)
for (var idx = 0; idx < base.qualityManagementModel.count; ++idx)
{
var item = qualitiesModel.getItem(idx);
var item = base.qualityManagementModel.getItem(idx);
if (item.name == toSelectItemName)
{
// Switch to the newly created profile if needed
@ -240,7 +261,7 @@ Item
object: "<new name>"
onAccepted:
{
base.qualityManager.duplicateQualityChanges(newName, base.currentItem);
base.qualityManagementModel.duplicateQualityChanges(newName, base.currentItem);
}
}
@ -257,7 +278,7 @@ Item
onYes:
{
base.qualityManager.removeQualityChangesGroup(base.currentItem.quality_changes_group);
base.qualityManagementModel.removeQualityChangesGroup(base.currentItem.quality_changes_group);
// reset current item to the first if available
qualityListView.currentIndex = -1; // Reset selection.
}
@ -271,7 +292,7 @@ Item
object: "<new name>"
onAccepted:
{
var actualNewName = base.qualityManager.renameQualityChangesGroup(base.currentItem.quality_changes_group, newName);
var actualNewName = base.qualityManagementModel.renameQualityChangesGroup(base.currentItem.quality_changes_group, newName);
base.newQualityNameToSelect = actualNewName; // Select the new name after the model gets updated
}
}
@ -282,19 +303,22 @@ Item
id: importDialog
title: catalog.i18nc("@title:window", "Import Profile")
selectExisting: true
nameFilters: qualitiesModel.getFileNameFilters("profile_reader")
nameFilters: base.qualityManagementModel.getFileNameFilters("profile_reader")
folder: CuraApplication.getDefaultPath("dialog_profile_path")
onAccepted:
{
var result = Cura.ContainerManager.importProfile(fileUrl);
messageDialog.text = result.message;
if (result.status == "ok") {
if (result.status == "ok")
{
messageDialog.icon = StandardIcon.Information;
}
else if (result.status == "duplicate") {
else if (result.status == "duplicate")
{
messageDialog.icon = StandardIcon.Warning;
}
else {
else
{
messageDialog.icon = StandardIcon.Critical;
}
messageDialog.open();
@ -308,14 +332,15 @@ Item
id: exportDialog
title: catalog.i18nc("@title:window", "Export Profile")
selectExisting: false
nameFilters: qualitiesModel.getFileNameFilters("profile_writer")
nameFilters: base.qualityManagementModel.getFileNameFilters("profile_writer")
folder: CuraApplication.getDefaultPath("dialog_profile_path")
onAccepted:
{
var result = Cura.ContainerManager.exportQualityChangesGroup(base.currentItem.quality_changes_group,
fileUrl, selectedNameFilter);
if (result && result.status == "error") {
if (result && result.status == "error")
{
messageDialog.icon = StandardIcon.Critical;
messageDialog.text = result.message;
messageDialog.open();
@ -326,10 +351,12 @@ Item
}
}
Item {
Item
{
id: contentsItem
anchors {
anchors
{
top: titleLabel.bottom
left: parent.left
right: parent.right
@ -343,7 +370,8 @@ Item
Item
{
anchors {
anchors
{
top: buttonRow.bottom
topMargin: UM.Theme.getSize("default_margin").height
left: parent.left
@ -351,12 +379,16 @@ Item
bottom: parent.bottom
}
SystemPalette { id: palette }
SystemPalette
{
id: palette
}
Label
{
id: captionLabel
anchors {
anchors
{
top: parent.top
left: parent.left
}
@ -369,14 +401,16 @@ Item
ScrollView
{
id: profileScrollView
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
@ -390,16 +424,16 @@ Item
{
id: qualityListView
model: qualitiesModel
model: base.qualityManagementModel
Component.onCompleted:
{
var selectedItemName = Cura.MachineManager.activeQualityOrQualityChangesName;
// Select the required quality name if given
for (var idx = 0; idx < qualitiesModel.count; idx++)
for (var idx = 0; idx < base.qualityManagementModel.count; idx++)
{
var item = qualitiesModel.getItem(idx);
var item = base.qualityManagementModel.getItem(idx);
if (item.name == selectedItemName)
{
currentIndex = idx;
@ -408,7 +442,7 @@ Item
}
}
section.property: "is_read_only"
section.property: "section_name"
section.delegate: Rectangle
{
height: childrenRect.height
@ -417,7 +451,7 @@ Item
{
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_lining").width
text: section == "true" ? catalog.i18nc("@label", "Default profiles") : catalog.i18nc("@label", "Custom profiles")
text: section
font.bold: true
}
}
@ -441,14 +475,27 @@ Item
width: Math.floor((parent.width * 0.8))
text: model.name
elide: Text.ElideRight
font.italic: model.name == Cura.MachineManager.activeQualityOrQualityChangesName
font.italic:
{
if (model.is_read_only)
{
// For built-in qualities, it needs to match both the intent category and the quality name
return model.name == Cura.MachineManager.activeQualityOrQualityChangesName && model.intent_category == Cura.MachineManager.activeIntentCategory
}
else
{
// For custom qualities, it only needs to match the name
return model.name == Cura.MachineManager.activeQualityOrQualityChangesName
}
}
color: parent.isCurrentItem ? palette.highlightedText : palette.text
}
MouseArea
{
anchors.fill: parent
onClicked: {
onClicked:
{
parent.ListView.view.currentIndex = model.index;
}
}
@ -461,7 +508,8 @@ Item
{
id: detailsPanel
anchors {
anchors
{
left: profileScrollView.right
leftMargin: UM.Theme.getSize("default_margin").width
top: parent.top
@ -481,15 +529,17 @@ Item
width: parent.width
height: childrenRect.height
Label {
text: base.currentItemName
Label
{
text: base.currentItemDisplayName
font: UM.Theme.getFont("large_bold")
}
}
Flow {
Flow
{
id: currentSettingsActions
visible: base.hasCurrentItem && base.currentItem.name == Cura.MachineManager.activeQualityOrQualityChangesName
visible: base.hasCurrentItem && base.currentItem.name == Cura.MachineManager.activeQualityOrQualityChangesName && base.currentItem.intent_category == Cura.MachineManager.activeIntentCategory
anchors.left: parent.left
anchors.right: parent.right
anchors.top: profileName.bottom
@ -510,7 +560,8 @@ Item
}
}
Column {
Column
{
id: profileNotices
anchors.top: currentSettingsActions.visible ? currentSettingsActions.bottom : currentSettingsActions.anchors.top
anchors.topMargin: UM.Theme.getSize("default_margin").height
@ -518,14 +569,16 @@ Item
anchors.right: parent.right
spacing: UM.Theme.getSize("default_margin").height
Label {
Label
{
id: defaultsMessage
visible: false
text: catalog.i18nc("@action:label", "This profile uses the defaults specified by the printer, so it has no settings/overrides in the list below.")
wrapMode: Text.WordWrap
width: parent.width
}
Label {
Label
{
id: noCurrentSettingsMessage
visible: base.isCurrentItemActivated && !Cura.MachineManager.hasUserSettings
text: catalog.i18nc("@action:label", "Your current settings match the selected profile.")
@ -534,7 +587,6 @@ Item
}
}
TabView
{
anchors.left: parent.left

View file

@ -1,12 +1,13 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Controls 1.4 as OldControls
import UM 1.3 as UM
import Cura 1.0 as Cura
import Cura 1.6 as Cura
import ".."
Item
{
@ -17,19 +18,175 @@ Item
property var extrudersModel: CuraApplication.getExtrudersModel()
// Profile selector row
GlobalProfileSelector
Item
{
id: globalProfileRow
id: intent
height: childrenRect.height
anchors
{
top: parent.top
topMargin: parent.padding
topMargin: UM.Theme.getSize("default_margin").height
left: parent.left
leftMargin: parent.padding
right: parent.right
rightMargin: parent.padding
}
Label
{
id: profileLabel
anchors
{
top: parent.top
bottom: parent.bottom
left: parent.left
right: intentSelection.left
}
text: catalog.i18nc("@label", "Profile")
font: UM.Theme.getFont("medium")
renderType: Text.NativeRendering
color: UM.Theme.getColor("text")
verticalAlignment: Text.AlignVCenter
}
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
onClicked: menu.opened ? menu.close() : menu.open()
text: generateActiveQualityText()
anchors.right: parent.right
width: UM.Theme.getSize("print_setup_big_item").width
height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height
hoverEnabled: true
baselineOffset: null // If we don't do this, there is a binding loop. WHich is a bit weird, since we override the contentItem anyway...
contentItem: Label
{
id: textLabel
text: intentSelection.text
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.verticalCenter: intentSelection.verticalCenter
height: contentHeight
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
}
background: Rectangle
{
id: backgroundItem
border.color: intentSelection.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
border.width: UM.Theme.getSize("default_lining").width
radius: UM.Theme.getSize("default_radius").width
color: UM.Theme.getColor("main_background")
}
function generateActiveQualityText()
{
var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
var resultMain = resultMap["main"]
var resultSuffix = resultMap["suffix"]
var result = ""
if (Cura.MachineManager.isActiveQualityExperimental)
{
resultSuffix += " (Experimental)"
}
if (Cura.MachineManager.isActiveQualitySupported)
{
if (Cura.MachineManager.activeQualityLayerHeight > 0)
{
result = resultMain
if (resultSuffix)
{
result += " - "
}
result += "<font color=\"" + UM.Theme.getColor("text_detail") + "\">"
if (resultSuffix)
{
result += resultSuffix
}
result += " - "
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
result += "</font>"
}
}
return result
}
UM.SimpleButton
{
id: customisedSettings
visible: Cura.MachineManager.hasUserSettings
width: UM.Theme.getSize("print_setup_icon").width
height: UM.Theme.getSize("print_setup_icon").height
anchors.verticalCenter: parent.verticalCenter
anchors.right: downArrow.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width
color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
iconSource: UM.Theme.getIcon("star")
onClicked:
{
forceActiveFocus();
Cura.Actions.manageProfiles.trigger()
}
onEntered:
{
var content = catalog.i18nc("@tooltip", "Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.")
base.showTooltip(intent, Qt.point(-UM.Theme.getSize("default_margin").width, 0), content)
}
onExited: base.hideTooltip()
}
UM.RecolorImage
{
id: downArrow
source: UM.Theme.getIcon("arrow_bottom")
width: UM.Theme.getSize("standard_arrow").width
height: UM.Theme.getSize("standard_arrow").height
anchors
{
right: parent.right
verticalCenter: parent.verticalCenter
rightMargin: UM.Theme.getSize("default_margin").width
}
color: UM.Theme.getColor("setting_control_button")
}
}
QualitiesWithIntentMenu
{
id: menu
y: intentSelection.y + intentSelection.height
x: intentSelection.x
width: intentSelection.width
}
}
UM.TabRow
@ -40,7 +197,7 @@ Item
anchors
{
top: globalProfileRow.bottom
top: intent.bottom
topMargin: UM.Theme.getSize("default_margin").height
left: parent.left
leftMargin: parent.padding
@ -99,7 +256,7 @@ Item
{
anchors
{
top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom
top: tabBar.visible ? tabBar.bottom : intent.bottom
topMargin: -UM.Theme.getSize("default_lining").width
left: parent.left
leftMargin: parent.padding

View file

@ -1,100 +0,0 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.2
import UM 1.2 as UM
import Cura 1.0 as Cura
Item
{
id: globalProfileRow
height: childrenRect.height
Label
{
id: globalProfileLabel
anchors
{
top: parent.top
bottom: parent.bottom
left: parent.left
right: globalProfileSelection.left
}
text: catalog.i18nc("@label", "Profile")
font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("text")
verticalAlignment: Text.AlignVCenter
}
ToolButton
{
id: globalProfileSelection
text: generateActiveQualityText()
width: UM.Theme.getSize("print_setup_big_item").width
height: UM.Theme.getSize("print_setup_big_item").height
anchors
{
top: parent.top
right: parent.right
}
tooltip: Cura.MachineManager.activeQualityOrQualityChangesName
style: UM.Theme.styles.print_setup_header_button
activeFocusOnPress: true
menu: Cura.ProfileMenu { }
function generateActiveQualityText()
{
var result = Cura.MachineManager.activeQualityOrQualityChangesName
if (Cura.MachineManager.isActiveQualityExperimental)
{
result += " (Experimental)"
}
if (Cura.MachineManager.isActiveQualitySupported)
{
if (Cura.MachineManager.activeQualityLayerHeight > 0)
{
result += " <font color=\"" + UM.Theme.getColor("text_detail") + "\">"
result += " - "
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
result += "</font>"
}
}
return result
}
UM.SimpleButton
{
id: customisedSettings
visible: Cura.MachineManager.hasUserSettings
width: UM.Theme.getSize("print_setup_icon").width
height: UM.Theme.getSize("print_setup_icon").height
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: Math.round(UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("thick_margin").width)
color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
iconSource: UM.Theme.getIcon("star")
onClicked:
{
forceActiveFocus();
Cura.Actions.manageProfiles.trigger()
}
onEntered:
{
var content = catalog.i18nc("@tooltip","Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.")
base.showTooltip(globalProfileRow, Qt.point(-UM.Theme.getSize("default_margin").width, 0), content)
}
onExited: base.hideTooltip()
}
}
}

View file

@ -0,0 +1,54 @@
// 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
Button
{
// This is a work around for a qml issue. Since the default button uses a private implementation for contentItem
// (the so called IconText), which handles the mnemonic conversion (aka; ensuring that &Button) text property
// is rendered with the B underlined. Since we're also forced to mix controls 1.0 and 2.0 actions together,
// we need a special property for the text of the label if we do want it to be rendered correclty, but don't want
// another shortcut to be added (which will cause for "QQuickAction::event: Ambiguous shortcut overload: " to
// happen.
property string labelText: ""
id: button
hoverEnabled: true
background: Rectangle
{
id: backgroundRectangle
border.width: UM.Theme.getSize("default_lining").width
border.color: button.checked ? UM.Theme.getColor("setting_control_border_highlight") : "transparent"
color: button.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent"
radius: UM.Theme.getSize("action_button_radius").width
}
// Workarround to ensure that the mnemonic highlighting happens correctly
function replaceText(txt)
{
var index = txt.indexOf("&")
if(index >= 0)
{
txt = txt.replace(txt.substr(index, 2), ("<u>" + txt.substr(index + 1, 1) + "</u>"))
}
return txt
}
contentItem: Label
{
id: textLabel
text: button.text != "" ? replaceText(button.text) : replaceText(button.labelText)
height: contentHeight
verticalAlignment: Text.AlignVCenter
anchors.left: button.left
anchors.leftMargin: UM.Theme.getSize("wide_margin").width
renderType: Text.NativeRendering
font: UM.Theme.getFont("default")
color: button.enabled ? UM.Theme.getColor("text") :UM.Theme.getColor("text_inactive")
}
}

View file

@ -0,0 +1,315 @@
// 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
Popup
{
id: popup
implicitWidth: 400
property var dataModel: Cura.IntentCategoryModel {}
property int defaultMargin: UM.Theme.getSize("default_margin").width
property color backgroundColor: UM.Theme.getColor("main_background")
property color borderColor: UM.Theme.getColor("lining")
topPadding: UM.Theme.getSize("narrow_margin").height
rightPadding: UM.Theme.getSize("default_lining").width
leftPadding: UM.Theme.getSize("default_lining").width
padding: 0
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
background: Cura.RoundedRectangle
{
color: backgroundColor
border.width: UM.Theme.getSize("default_lining").width
border.color: borderColor
cornerSide: Cura.RoundedRectangle.Direction.Down
}
ButtonGroup
{
id: buttonGroup
exclusive: true
onClicked: popup.visible = false
}
contentItem: Column
{
// This repeater adds the intent labels
ScrollView
{
property real maximumHeight: screenScaleFactor * 400
contentHeight: dataColumn.height
height: Math.min(contentHeight, maximumHeight)
clip: true
ScrollBar.vertical.policy: height == maximumHeight ? ScrollBar.AlwaysOn: ScrollBar.AlwaysOff
Column
{
id: dataColumn
width: parent.width
Repeater
{
model: dataModel
delegate: Item
{
// We need to set it like that, otherwise we'd have to set the sub model with model: model.qualities
// Which obviously won't work due to naming conflicts.
property variant subItemModel: model.qualities
height: childrenRect.height
width: popup.contentWidth
Label
{
id: headerLabel
text: model.name
renderType: Text.NativeRendering
height: visible ? contentHeight: 0
enabled: false
visible: qualitiesList.visibleChildren.length > 0
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width
}
Column
{
id: qualitiesList
anchors.top: headerLabel.bottom
anchors.left: parent.left
anchors.right: parent.right
// We set it by means of a binding, since then we can use the when condition, which we need to
// prevent a binding loop.
Binding
{
target: parent
property: "height"
value: parent.childrenRect.height
when: parent.visibleChildren.length > 0
}
// Add the qualities that belong to the intent
Repeater
{
visible: false
model: subItemModel
MenuButton
{
id: button
onClicked: Cura.IntentManager.selectIntent(model.intent_category, model.quality_type)
width: parent.width
checkable: true
visible: model.available
text: model.name + " - " + model.layer_height + " mm"
checked:
{
if (Cura.MachineManager.hasCustomQuality)
{
// When user created profile is active, no quality tickbox should be active.
return false;
}
return Cura.MachineManager.activeQualityType == model.quality_type && Cura.MachineManager.activeIntentCategory == model.intent_category;
}
ButtonGroup.group: buttonGroup
}
}
}
}
}
//Another "intent category" for custom profiles.
Item
{
height: childrenRect.height
anchors
{
left: parent.left
right: parent.right
}
Label
{
id: customProfileHeader
text: catalog.i18nc("@label:header", "Custom profiles")
renderType: Text.NativeRendering
height: visible ? contentHeight: 0
enabled: false
visible: profilesList.visibleChildren.length > 1
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width
}
Column
{
id: profilesList
anchors
{
top: customProfileHeader.bottom
left: parent.left
right: parent.right
}
//We set it by means of a binding, since then we can use the
//"when" condition, which we need to prevent a binding loop.
Binding
{
target: parent
property: "height"
value: parent.childrenRect.height
when: parent.visibleChildren.length > 1
}
//Add all the custom profiles.
Repeater
{
model: Cura.CustomQualityProfilesDropDownMenuModel
MenuButton
{
onClicked: Cura.MachineManager.setQualityChangesGroup(model.quality_changes_group)
width: parent.width
checkable: true
visible: model.available
text: model.name
checked:
{
var active_quality_group = Cura.MachineManager.activeQualityChangesGroup
if (active_quality_group != null)
{
return active_quality_group.name == model.quality_changes_group.name
}
return false
}
ButtonGroup.group: buttonGroup
}
}
}
}
}
}
Rectangle
{
height: UM.Theme.getSize("default_lining").height
anchors.left: parent.left
anchors.right: parent.right
color: borderColor
}
MenuButton
{
labelText: Cura.Actions.addProfile.text
anchors.left: parent.left
anchors.right: parent.right
enabled: Cura.Actions.addProfile.enabled
onClicked:
{
Cura.Actions.addProfile.trigger()
popup.visible = false
}
}
MenuButton
{
labelText: Cura.Actions.updateProfile.text
anchors.left: parent.left
anchors.right: parent.right
enabled: Cura.Actions.updateProfile.enabled
onClicked:
{
popup.visible = false
Cura.Actions.updateProfile.trigger()
}
}
MenuButton
{
text: catalog.i18nc("@action:button", "Discard current changes")
anchors.left: parent.left
anchors.right: parent.right
enabled: Cura.MachineManager.hasUserSettings
onClicked:
{
popup.visible = false
Cura.ContainerManager.clearUserContainers()
}
}
Rectangle
{
height: UM.Theme.getSize("default_lining").width
anchors.left: parent.left
anchors.right: parent.right
color: borderColor
}
MenuButton
{
id: manageProfilesButton
text: Cura.Actions.manageProfiles.text
anchors
{
left: parent.left
right: parent.right
}
height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height
contentItem: Item
{
width: parent.width
height: childrenRect.height
Label
{
id: textLabel
text: manageProfilesButton.text
height: contentHeight
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
}
Label
{
id: shortcutLabel
text: Cura.Actions.manageProfiles.shortcut
height: contentHeight
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
}
}
onClicked:
{
popup.visible = false
Cura.Actions.manageProfiles.trigger()
}
}
// spacer
Item
{
width: 2
height: UM.Theme.getSize("default_radius").width
}
}
}

View file

@ -0,0 +1,36 @@
// 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.RecolorImage
{
source: UM.Theme.getIcon("info")
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()
}
}

View file

@ -1,7 +1,7 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
@ -20,10 +20,16 @@ RowLayout
{
if (Cura.MachineManager.activeStack)
{
var text = Cura.MachineManager.activeQualityOrQualityChangesName
var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
var text = resultMap["main"]
if (resultMap["suffix"])
{
text += " - " + resultMap["suffix"]
}
if (!Cura.MachineManager.hasNotSupportedQuality)
{
text += " " + layerHeight.properties.value + "mm"
text += " - " + layerHeight.properties.value + "mm"
text += Cura.MachineManager.isActiveQualityExperimental ? " - " + catalog.i18nc("@label", "Experimental") : ""
}
return text

View file

@ -1,7 +1,7 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick 2.10
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
@ -27,7 +27,6 @@ Item
Column
{
width: parent.width - 2 * parent.padding
spacing: UM.Theme.getSize("wide_margin").height
anchors

View file

@ -1,17 +1,15 @@
// Copyright (c) 2018 Ultimaker B.V.
// Copyright (c) 2019 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick 2.10
import QtQuick.Controls 1.4
import QtQuick.Controls 2.3 as Controls2
import QtQuick.Controls.Styles 1.4
import UM 1.2 as UM
import Cura 1.0 as Cura
import Cura 1.6 as Cura
import ".."
//
// Quality profile
//
Item
{
id: qualityRow
@ -20,436 +18,153 @@ Item
property real labelColumnWidth: Math.round(width / 3)
property real settingsColumnWidth: width - labelColumnWidth
Timer
{
id: qualitySliderChangeTimer
interval: 50
running: false
repeat: false
onTriggered:
{
var item = Cura.QualityProfilesDropDownMenuModel.getItem(qualitySlider.value);
Cura.MachineManager.activeQualityGroup = item.quality_group;
}
}
Component.onCompleted: qualityModel.update()
Connections
{
target: Cura.QualityProfilesDropDownMenuModel
onItemsChanged: qualityModel.update()
}
Connections {
target: base
onVisibleChanged:
{
// update needs to be called when the widgets are visible, otherwise the step width calculation
// will fail because the width of an invisible item is 0.
if (visible)
{
qualityModel.update();
}
}
}
ListModel
{
id: qualityModel
property var totalTicks: 0
property var availableTotalTicks: 0
property var existingQualityProfile: 0
property var qualitySliderActiveIndex: 0
property var qualitySliderStepWidth: 0
property var qualitySliderAvailableMin: 0
property var qualitySliderAvailableMax: 0
property var qualitySliderMarginRight: 0
function update ()
{
reset()
var availableMin = -1
var availableMax = -1
for (var i = 0; i < Cura.QualityProfilesDropDownMenuModel.rowCount(); i++)
{
var qualityItem = Cura.QualityProfilesDropDownMenuModel.getItem(i)
// Add each quality item to the UI quality model
qualityModel.append(qualityItem)
// Set selected value
if (Cura.MachineManager.activeQualityType == qualityItem.quality_type)
{
// set to -1 when switching to user created profile so all ticks are clickable
if (Cura.MachineManager.hasCustomQuality)
{
qualityModel.qualitySliderActiveIndex = -1
}
else
{
qualityModel.qualitySliderActiveIndex = i
}
qualityModel.existingQualityProfile = 1
}
// Set min available
if (qualityItem.available && availableMin == -1)
{
availableMin = i
}
// Set max available
if (qualityItem.available)
{
availableMax = i
}
}
// Set total available ticks for active slider part
if (availableMin != -1)
{
qualityModel.availableTotalTicks = availableMax - availableMin + 1
}
// Calculate slider values
calculateSliderStepWidth(qualityModel.totalTicks)
calculateSliderMargins(availableMin, availableMax, qualityModel.totalTicks)
qualityModel.qualitySliderAvailableMin = availableMin
qualityModel.qualitySliderAvailableMax = availableMax
}
function calculateSliderStepWidth (totalTicks)
{
// Do not use Math.round otherwise the tickmarks won't be aligned
qualityModel.qualitySliderStepWidth = totalTicks != 0 ?
((settingsColumnWidth - UM.Theme.getSize("print_setup_slider_handle").width) / (totalTicks)) : 0
}
function calculateSliderMargins (availableMin, availableMax, totalTicks)
{
if (availableMin == -1 || (availableMin == 0 && availableMax == 0))
{
// Do not use Math.round otherwise the tickmarks won't be aligned
qualityModel.qualitySliderMarginRight = settingsColumnWidth / 2
}
else if (availableMin == availableMax)
{
// Do not use Math.round otherwise the tickmarks won't be aligned
qualityModel.qualitySliderMarginRight = (totalTicks - availableMin) * qualitySliderStepWidth
}
else
{
// Do not use Math.round otherwise the tickmarks won't be aligned
qualityModel.qualitySliderMarginRight = (totalTicks - availableMax) * qualitySliderStepWidth
}
}
function reset () {
qualityModel.clear()
qualityModel.availableTotalTicks = 0
qualityModel.existingQualityProfile = 0
// check, the ticks count cannot be less than zero
qualityModel.totalTicks = Math.max(0, Cura.QualityProfilesDropDownMenuModel.rowCount() - 1)
}
}
// Here are the elements that are shown in the left column
Item
Column
{
id: titleRow
width: labelColumnWidth
height: childrenRect.height
Cura.IconWithText
{
id: qualityRowTitle
source: UM.Theme.getIcon("category_layer_height")
text: catalog.i18nc("@label", "Layer Height")
font: UM.Theme.getFont("medium")
anchors.left: parent.left
anchors.right: customisedSettings.left
}
UM.SimpleButton
{
id: customisedSettings
visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.MachineManager.hasCustomQuality
height: visible ? UM.Theme.getSize("print_setup_icon").height : 0
width: height
anchors
{
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
leftMargin: UM.Theme.getSize("default_margin").width
verticalCenter: parent.verticalCenter
}
color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button")
iconSource: UM.Theme.getIcon("reset")
onClicked:
{
// if the current profile is user-created, switch to a built-in quality
Cura.MachineManager.resetToUseDefaultQuality()
}
onEntered:
{
var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.")
base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent)
}
onExited: base.hideTooltip()
}
}
// Show titles for the each quality slider ticks
Item
{
anchors.left: speedSlider.left
anchors.top: speedSlider.bottom
height: childrenRect.height
Repeater
{
model: qualityModel
Label
{
anchors.verticalCenter: parent.verticalCenter
anchors.top: parent.top
// The height has to be set manually, otherwise it's not automatically calculated in the repeater
height: UM.Theme.getSize("default_margin").height
color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
text:
{
var result = ""
if(Cura.MachineManager.activeMachine != null)
{
result = Cura.QualityProfilesDropDownMenuModel.getItem(index).layer_height
if(result == undefined)
{
result = "";
}
else
{
result = Number(Math.round(result + "e+2") + "e-2"); //Round to 2 decimals. Javascript makes this difficult...
if (result == undefined || result != result) //Parse failure.
{
result = "";
}
}
}
return result
}
x:
{
// Make sure the text aligns correctly with each tick
if (qualityModel.totalTicks == 0)
{
// If there is only one tick, align it centrally
return Math.round(((settingsColumnWidth) - width) / 2)
}
else if (index == 0)
{
return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index
}
else if (index == qualityModel.totalTicks)
{
return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - width
}
else
{
return Math.round((settingsColumnWidth / qualityModel.totalTicks) * index - (width / 2))
}
}
font: UM.Theme.getFont("default")
}
}
}
// Print speed slider
// Two sliders are created, one at the bottom with the unavailable qualities
// and the other at the top with the available quality profiles and so the handle to select them.
Item
{
id: speedSlider
height: childrenRect.height
anchors
{
left: titleRow.right
left: parent.left
right: parent.right
verticalCenter: titleRow.verticalCenter
}
// Draw unavailable slider
Slider
spacing: UM.Theme.getSize("default_margin").height
Controls2.ButtonGroup
{
id: unavailableSlider
id: activeProfileButtonGroup
exclusive: true
onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type)
}
width: parent.width
height: qualitySlider.height // Same height as the slider that is on top
updateValueWhileDragging : false
tickmarksEnabled: true
minimumValue: 0
// maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly
// speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available)
maximumValue: qualityModel.totalTicks
stepSize: 1
style: SliderStyle
Item
{
height: childrenRect.height
anchors
{
//Draw Unvailable line
groove: Item
{
Rectangle
{
height: UM.Theme.getSize("print_setup_slider_groove").height
width: control.width - UM.Theme.getSize("print_setup_slider_handle").width
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
color: UM.Theme.getColor("quality_slider_unavailable")
}
}
handle: Item {}
tickmarks: Repeater
{
id: qualityRepeater
model: qualityModel.totalTicks > 0 ? qualityModel : 0
Rectangle
{
color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width
implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height
anchors.verticalCenter: parent.verticalCenter
// Do not use Math.round otherwise the tickmarks won't be aligned
x: ((UM.Theme.getSize("print_setup_slider_handle").width / 2) - (implicitWidth / 2) + (qualityModel.qualitySliderStepWidth * index))
radius: Math.round(implicitWidth / 2)
}
}
left: parent.left
right: parent.right
}
// Create a mouse area on top of the unavailable profiles to show a specific tooltip
MouseArea
Cura.IconWithText
{
anchors.fill: parent
hoverEnabled: true
enabled: !Cura.MachineManager.hasCustomQuality
id: profileLabel
source: UM.Theme.getIcon("category_layer_height")
text: catalog.i18nc("@label", "Profiles")
font: UM.Theme.getFont("medium")
width: labelColumnWidth
}
UM.SimpleButton
{
id: customisedSettings
visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.MachineManager.hasCustomQuality
height: visible ? UM.Theme.getSize("print_setup_icon").height : 0
width: height
anchors
{
right: profileLabel.right
rightMargin: UM.Theme.getSize("default_margin").width
leftMargin: UM.Theme.getSize("default_margin").width
verticalCenter: parent.verticalCenter
}
color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button")
iconSource: UM.Theme.getIcon("reset")
onClicked:
{
// if the current profile is user-created, switch to a built-in quality
Cura.MachineManager.resetToUseDefaultQuality()
}
onEntered:
{
var tooltipContent = catalog.i18nc("@tooltip", "This quality profile is not available for your current material and nozzle configuration. Please change these to enable this quality profile.")
base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent)
var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.")
base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent)
}
onExited: base.hideTooltip()
}
}
// Draw available slider
Slider
{
id: qualitySlider
width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) + UM.Theme.getSize("print_setup_slider_handle").width
height: UM.Theme.getSize("print_setup_slider_handle").height // The handle is the widest element of the slider
enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized
visible: qualityModel.availableTotalTicks > 0
updateValueWhileDragging : false
anchors
Cura.LabelBar
{
right: parent.right
rightMargin: qualityModel.qualitySliderMarginRight
}
minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0
// maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly
// speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available)
maximumValue: qualityModel.qualitySliderAvailableMax >= 1 ? qualityModel.qualitySliderAvailableMax : 1
stepSize: 1
value: qualityModel.qualitySliderActiveIndex
style: SliderStyle
{
// Draw Available line
groove: Item
id: labelbar
anchors
{
Rectangle
{
height: UM.Theme.getSize("print_setup_slider_groove").height
width: control.width - UM.Theme.getSize("print_setup_slider_handle").width
anchors.verticalCenter: parent.verticalCenter
// Do not use Math.round otherwise the tickmarks won't be aligned
x: UM.Theme.getSize("print_setup_slider_handle").width / 2
color: UM.Theme.getColor("quality_slider_available")
}
left: profileLabel.right
right: parent.right
}
handle: Rectangle
{
id: qualityhandleButton
color: UM.Theme.getColor("primary")
implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width
implicitHeight: implicitWidth
radius: Math.round(implicitWidth / 2)
visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.MachineManager.hasCustomQuality && qualityModel.existingQualityProfile
}
}
onValueChanged:
{
// only change if an active machine is set and the slider is visible at all.
if (Cura.MachineManager.activeMachine != null && visible)
{
// prevent updating during view initializing. Trigger only if the value changed by user
if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1)
{
// start updating with short delay
qualitySliderChangeTimer.start()
}
}
}
// This mouse area is only used to capture the onHover state and don't propagate it to the unavailable mouse area
MouseArea
{
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
enabled: !Cura.MachineManager.hasCustomQuality
model: Cura.QualityProfilesDropDownMenuModel
modelKey: "layer_height"
}
}
// This mouse area will only take the mouse events and show a tooltip when the profile in use is
// a user created profile
MouseArea
{
anchors.fill: parent
hoverEnabled: true
visible: Cura.MachineManager.hasCustomQuality
onEntered:
Repeater
{
model: Cura.IntentCategoryModel {}
Item
{
var tooltipContent = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab")
base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent)
anchors
{
left: parent.left
right: parent.right
}
height: intentCategoryLabel.height
Label
{
id: intentCategoryLabel
text: model.name
width: labelColumnWidth - UM.Theme.getSize("section_icon").width
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("section_icon").width + UM.Theme.getSize("narrow_margin").width
font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("text")
renderType: Text.NativeRendering
elide: Text.ElideRight
}
NoIntentIcon
{
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
}
Cura.RadioCheckbar
{
anchors
{
left: intentCategoryLabel.right
right: parent.right
}
dataModel: model["qualities"]
buttonGroup: activeProfileButtonGroup
function checkedFunction(modelItem)
{
if(Cura.MachineManager.hasCustomQuality)
{
// When user created profile is active, no quality tickbox should be active.
return false
}
if(modelItem === null)
{
return false
}
return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category
}
isCheckedFunction: checkedFunction
}
}
onExited: base.hideTooltip()
}
}
}

View file

@ -0,0 +1,152 @@
// 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 QtQuick.Layouts 1.3
import UM 1.1 as UM
Item
{
id: base
property ButtonGroup buttonGroup: null
property color activeColor: UM.Theme.getColor("primary")
property color inactiveColor: UM.Theme.getColor("slider_groove")
property color defaultItemColor: UM.Theme.getColor("small_button_active")
property int checkboxSize: Math.round(UM.Theme.getSize("radio_button").height * 0.75)
property int inactiveMarkerSize: 2 * barSize
property int barSize: UM.Theme.getSize("slider_groove_radius").height
property var isCheckedFunction // Function that accepts the modelItem and returns if the item should be active.
implicitWidth: 200 * screenScaleFactor
implicitHeight: checkboxSize
property var dataModel: null
// The horizontal inactive bar that sits behind the buttons
Rectangle
{
id: inactiveLine
color: inactiveColor
height: barSize
anchors
{
left: buttonBar.left
right: buttonBar.right
leftMargin: Math.round((checkboxSize - inactiveMarkerSize) / 2)
rightMargin: Math.round((checkboxSize - inactiveMarkerSize) / 2)
verticalCenter: parent.verticalCenter
}
}
RowLayout
{
id: buttonBar
anchors.top: parent.top
height: checkboxSize
width: parent.width
spacing: 0
Repeater
{
id: repeater
model: base.dataModel
height: checkboxSize
Item
{
Layout.fillWidth: true
Layout.fillHeight: true
// The last item of the repeater needs to be shorter, as we don't need another part to fit
// the horizontal bar. The others should essentially not be limited.
Layout.maximumWidth: index + 1 === repeater.count ? activeComponent.width : 200000000
property bool isEnabled: model.available
// The horizontal bar between the checkable options.
// Note that the horizontal bar points towards the previous item.
Rectangle
{
property Item previousItem: repeater.itemAt(index - 1)
height: barSize
width: Math.round(buttonBar.width / (repeater.count - 1) - activeComponent.width - 2)
color: defaultItemColor
anchors
{
right: activeComponent.left
verticalCenter: parent.verticalCenter
}
visible: previousItem !== null && previousItem.isEnabled && isEnabled
}
Loader
{
id: activeComponent
sourceComponent: isEnabled? checkboxComponent : disabledComponent
width: checkboxSize
property var modelItem: model
}
}
}
}
Component
{
id: disabledComponent
Item
{
height: checkboxSize
width: checkboxSize
Rectangle
{
// This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator
// but not when using the exact same QML in Cura.
anchors.verticalCenter: parent ? parent.verticalCenter : undefined
anchors.horizontalCenter: parent ? parent.horizontalCenter : undefined
height: inactiveMarkerSize
width: inactiveMarkerSize
radius: Math.round(width / 2)
color: inactiveColor
}
}
}
Component
{
id: checkboxComponent
CheckBox
{
id: checkbox
ButtonGroup.group: buttonGroup
width: checkboxSize
height: checkboxSize
property var modelData: modelItem
checked: isCheckedFunction(modelItem)
indicator: Rectangle
{
height: checkboxSize
width: checkboxSize
radius: Math.round(width / 2)
border.color: defaultItemColor
Rectangle
{
anchors
{
fill: parent
}
radius: Math.round(width / 2)
color: activeColor
visible: checkbox.checked
}
}
}
}
}

View file

@ -20,7 +20,6 @@ SettingItem
textRole: "value"
anchors.fill: parent
highlighted: base.hovered
onActivated:
{

View file

@ -86,7 +86,11 @@ Item
{
id: machineList
cacheBuffer: 1000000 // Set a large cache to effectively just cache every list item.
// CURA-6793
// Enabling the buffer seems to cause the blank items issue. When buffer is enabled, if the ListView's
// individual item has a dynamic change on its visibility, the ListView doesn't redraw itself.
// The default value of cacheBuffer is platform-dependent, so we explicitly disable it here.
cacheBuffer: 0
model: UM.DefinitionContainersModel
{

View file

@ -14,40 +14,34 @@ import Cura 1.1 as Cura
ComboBox
{
id: control
property bool highlighted: false
states: [
State
{
name: "disabled"
when: !control.enabled
PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_control_disabled_border")}
PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_control_disabled")}
PropertyChanges { target: contentLabel; color: UM.Theme.getColor("setting_control_disabled_text")}
},
State
{
name: "highlighted"
when: control.hovered || control.activeFocus
PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_control_border_highlight") }
PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_control_highlight")}
}
]
background: Rectangle
{
color:
{
if (!enabled)
{
return UM.Theme.getColor("setting_control_disabled")
}
if (control.hovered || control.activeFocus || control.highlighted)
{
return UM.Theme.getColor("setting_control_highlight")
}
return UM.Theme.getColor("setting_control")
}
id: backgroundRectangle
color: UM.Theme.getColor("setting_control")
radius: UM.Theme.getSize("setting_control_radius").width
border.width: UM.Theme.getSize("default_lining").width
border.color:
{
if (!enabled)
{
return UM.Theme.getColor("setting_control_disabled_border")
}
border.color: UM.Theme.getColor("setting_control_border")
if (control.hovered || control.activeFocus || control.highlighted)
{
return UM.Theme.getColor("setting_control_border_highlight")
}
return UM.Theme.getColor("setting_control_border")
}
}
indicator: UM.RecolorImage
@ -67,6 +61,7 @@ ComboBox
contentItem: Label
{
id: contentLabel
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
anchors.verticalCenter: parent.verticalCenter
@ -76,7 +71,7 @@ ComboBox
textFormat: Text.PlainText
renderType: Text.NativeRendering
font: UM.Theme.getFont("default")
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
color: UM.Theme.getColor("setting_control_text")
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}