Apply suggestions from code review

Co-authored-by: Casper Lamboo <c.lamboo@ultimaker.com>
Co-authored-by: Jelle Spijker <j.spijker@ultimaker.com>
This commit is contained in:
Joey de l'Arago 2022-12-12 11:44:21 +01:00 committed by GitHub
parent e03b4e07f9
commit 1e6184448c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 26 additions and 25 deletions

View file

@ -56,6 +56,7 @@ class ExtruderManager(QObject):
"""Notify when the user switches the currently active extruder.""" """Notify when the user switches the currently active extruder."""
def emitGlobalStackExtrudersChanged(self): def emitGlobalStackExtrudersChanged(self):
# HACK
# The emit function can't be directly connected to another signal. This wrapper function is required. # The emit function can't be directly connected to another signal. This wrapper function is required.
# The extrudersChanged signal is emitted early when changing machines. This triggers it a second time # The extrudersChanged signal is emitted early when changing machines. This triggers it a second time
# after the extruder have changed properly. This is important for any QML using ExtruderManager.extruderIds # after the extruder have changed properly. This is important for any QML using ExtruderManager.extruderIds

View file

@ -74,7 +74,7 @@ UM.TooltipArea
return return
} }
if (typeof propertyProvider.properties["options"] == "string") if (typeof propertyProvider.properties["options"] === "string")
{ {
return return
} }
@ -84,9 +84,9 @@ UM.TooltipArea
{ {
var key = propertyProvider.properties["options"].keys()[i] var key = propertyProvider.properties["options"].keys()[i]
var value = propertyProvider.properties["options"][key] var value = propertyProvider.properties["options"][key]
append({ text: value, code: key}) append({ text: value, code: key })
if (propertyProvider.properties.value == key) if (propertyProvider.properties.value === key)
{ {
comboBox.currentIndex = i comboBox.currentIndex = i
} }
@ -132,7 +132,7 @@ UM.TooltipArea
onActivated: onActivated:
{ {
var newValue = model.get(index).value var newValue = model.get(index).value
if (propertyProvider.properties.value != newValue && newValue != undefined) if (propertyProvider.properties.value !== newValue && newValue !== undefined)
{ {
if (setValueFunction !== null) if (setValueFunction !== null)
{ {

View file

@ -14,8 +14,8 @@ RecommendedSettingSection
title: catalog.i18nc("@label", "Adhesion") title: catalog.i18nc("@label", "Adhesion")
icon: UM.Theme.getIcon("Adhesion") icon: UM.Theme.getIcon("Adhesion")
enableSectionSwitchVisible: platformAdhesionType.properties.enabled == "True" enableSectionSwitchVisible: platformAdhesionType.properties.enabled === "True"
enableSectionSwitchChecked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" enableSectionSwitchChecked: platformAdhesionType.properties.value !== "skirt" && platformAdhesionType.properties.value !== "none"
enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled
tooltipText: catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.") tooltipText: catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")
@ -30,7 +30,8 @@ RecommendedSettingSection
storeIndex: 0 storeIndex: 0
} }
function onEnableSectionChanged(state) { function onEnableSectionChanged(state)
{
curaRecommendedMode.setAdhesion(state) curaRecommendedMode.setAdhesion(state)
} }
} }

View file

@ -77,7 +77,8 @@ Item
Item { height: UM.Theme.getSize("narrow_margin").height } //Spacer Item { height: UM.Theme.getSize("narrow_margin").height } //Spacer
Column { Column
{
id: settingColumn id: settingColumn
width: parent.width width: parent.width
spacing: UM.Theme.getSize("thin_margin").height spacing: UM.Theme.getSize("thin_margin").height
@ -117,7 +118,8 @@ Item
width: parent.width width: parent.width
} }
RecommendedAdhesionSelector { RecommendedAdhesionSelector
{
width: parent.width width: parent.width
} }
} }

View file

@ -41,7 +41,6 @@ Item
onExited: base.hideTooltip() onExited: base.hideTooltip()
} }
Loader Loader
{ {
id: settingContainer id: settingContainer
@ -86,7 +85,6 @@ Item
NumberAnimation { property: "Layout.minimumHeight"; duration: 100; } NumberAnimation { property: "Layout.minimumHeight"; duration: 100; }
// Animate section dissapearring as it closes // Animate section dissapearring as it closes
NumberAnimation { property: "opacity"; duration: 100; } NumberAnimation { property: "opacity"; duration: 100; }
} }
} }
} }

View file

@ -1,4 +1,4 @@
// Copyright (c) 2022 Ultimaker // Copyright (c) 2022 UltiMaker
// Cura is released under the terms of the LGPLv3 or higher. // Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7 import QtQuick 2.7
@ -40,7 +40,7 @@ RecommendedSettingSection
settingName: "infill_sparse_density" settingName: "infill_sparse_density"
updateAllExtruders: true updateAllExtruders: true
// disable slider when gradual support is enabled // disable slider when gradual support is enabled
enabled: parseInt(infillSteps.properties.value) == 0 enabled: parseInt(infillSteps.properties.value) === 0
function updateSetting(value) function updateSetting(value)
{ {

View file

@ -59,7 +59,6 @@ RecommendedSettingSection
settingControl: Cura.SingleSettingExtruderSelectorBar settingControl: Cura.SingleSettingExtruderSelectorBar
{ {
extruderSettingName: "support_extruder_nr" extruderSettingName: "support_extruder_nr"
} }
}, },

View file

@ -137,10 +137,10 @@ Item
delegate: Cura.ExtruderButton delegate: Cura.ExtruderButton
{ {
extruder: model extruder: model
isTopElement: extrudersModel.getItem(0).id == model.id isTopElement: extrudersModel.getItem(0).id === model.id
isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id == model.id isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id === model.id
text: catalog.i18ncp("@label %1 is filled in with the name of an extruder", "Print Selected Model with %1", "Print Selected Models with %1", UM.Selection.selectionCount).arg(extruder.name) text: catalog.i18ncp("@label %1 is filled in with the name of an extruder", "Print Selected Model with %1", "Print Selected Models with %1", UM.Selection.selectionCount).arg(extruder.name)
checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) !== -1
enabled: UM.Selection.hasSelection && extruder.stack.isEnabled enabled: UM.Selection.hasSelection && extruder.stack.isEnabled
font: UM.Theme.getFont("small_emphasis") font: UM.Theme.getFont("small_emphasis")

View file

@ -43,7 +43,7 @@ Cura.ComboBox {
var value = propertyProvider.properties["options"][key] var value = propertyProvider.properties["options"][key]
comboboxModel.append({ text: value, code: key}) comboboxModel.append({ text: value, code: key})
if (propertyProvider.properties.value == key) if (propertyProvider.properties.value === key)
{ {
// The combobox is cleared after each value change so the currentIndex must be set each time. // The combobox is cleared after each value change so the currentIndex must be set each time.
currentIndex = i currentIndex = i
@ -81,7 +81,7 @@ Cura.ComboBox {
function parseValueAndUpdateSetting() function parseValueAndUpdateSetting()
{ {
if (comboboxModel.get(currentIndex) && comboboxModel.get(currentIndex).code != propertyProvider.properties.value) if (comboboxModel.get(currentIndex) && comboboxModel.get(currentIndex).code !== propertyProvider.properties.value)
{ {
updateSetting(comboboxModel.get(currentIndex).code) updateSetting(comboboxModel.get(currentIndex).code)
} }

View file

@ -56,10 +56,10 @@ Row
Cura.ExtruderButton Cura.ExtruderButton
{ {
anchors.margins : 0 anchors.margins: 0
padding: 0 padding: 0
extruder: model extruder: model
checked: extruder.index == selectedIndex checked: extruder.index === selectedIndex
iconScale: 0.8 iconScale: 0.8
font: UM.Theme.getFont("tiny_emphasis") font: UM.Theme.getFont("tiny_emphasis")
buttonSize: UM.Theme.getSize("small_button").width buttonSize: UM.Theme.getSize("small_button").width

View file

@ -87,13 +87,13 @@ UM.TextField
function parseValueUpdateSetting() function parseValueUpdateSetting()
{ {
if (propertyProvider.properties.value == text || (parseFloat(propertyProvider.properties.value) == parseFloat(text) && !isNan(parseFloat(text)))) if (propertyProvider.properties.value === text || (parseFloat(propertyProvider.properties.value) === parseFloat(text)))
{ {
// Don't set the property value from the control. It already has the same value // Don't set the property value from the control. It already has the same value
return return
} }
if (propertyProvider && text != propertyProvider.properties.value) if (propertyProvider && text !== propertyProvider.properties.value)
{ {
updateSetting(text); updateSetting(text);
} }
@ -119,7 +119,7 @@ UM.TextField
State State
{ {
name: "validationError" name: "validationError"
when: propertyProvider.properties.validationState == "ValidatorState.Exception" || propertyProvider.properties.validationState == "ValidatorState.MinimumError" || propertyProvider.properties.validationState == "ValidatorState.MaximumError" when: propertyProvider.properties.validationState === "ValidatorState.Exception" || propertyProvider.properties.validationState === "ValidatorState.MinimumError" || propertyProvider.properties.validationState === "ValidatorState.MaximumError"
PropertyChanges PropertyChanges
{ {
target: background target: background
@ -130,7 +130,7 @@ UM.TextField
State State
{ {
name: "validationWarning" name: "validationWarning"
when: propertyProvider.properties.validationState == "ValidatorState.MinimumWarning" || propertyProvider.properties.validationState == "ValidatorState.MaximumWarning" when: propertyProvider.properties.validationState === "ValidatorState.MinimumWarning" || propertyProvider.properties.validationState === "ValidatorState.MaximumWarning"
PropertyChanges PropertyChanges
{ {
target: background target: background