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."""
def emitGlobalStackExtrudersChanged(self):
# HACK
# 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
# after the extruder have changed properly. This is important for any QML using ExtruderManager.extruderIds

View file

@ -74,7 +74,7 @@ UM.TooltipArea
return
}
if (typeof propertyProvider.properties["options"] == "string")
if (typeof propertyProvider.properties["options"] === "string")
{
return
}
@ -84,9 +84,9 @@ UM.TooltipArea
{
var key = propertyProvider.properties["options"].keys()[i]
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
}
@ -132,7 +132,7 @@ UM.TooltipArea
onActivated:
{
var newValue = model.get(index).value
if (propertyProvider.properties.value != newValue && newValue != undefined)
if (propertyProvider.properties.value !== newValue && newValue !== undefined)
{
if (setValueFunction !== null)
{

View file

@ -14,8 +14,8 @@ RecommendedSettingSection
title: catalog.i18nc("@label", "Adhesion")
icon: UM.Theme.getIcon("Adhesion")
enableSectionSwitchVisible: platformAdhesionType.properties.enabled == "True"
enableSectionSwitchChecked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none"
enableSectionSwitchVisible: platformAdhesionType.properties.enabled === "True"
enableSectionSwitchChecked: platformAdhesionType.properties.value !== "skirt" && platformAdhesionType.properties.value !== "none"
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.")
@ -30,7 +30,8 @@ RecommendedSettingSection
storeIndex: 0
}
function onEnableSectionChanged(state) {
function onEnableSectionChanged(state)
{
curaRecommendedMode.setAdhesion(state)
}
}

View file

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

View file

@ -41,7 +41,6 @@ Item
onExited: base.hideTooltip()
}
Loader
{
id: settingContainer
@ -86,7 +85,6 @@ Item
NumberAnimation { property: "Layout.minimumHeight"; duration: 100; }
// Animate section dissapearring as it closes
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.
import QtQuick 2.7
@ -40,7 +40,7 @@ RecommendedSettingSection
settingName: "infill_sparse_density"
updateAllExtruders: true
// disable slider when gradual support is enabled
enabled: parseInt(infillSteps.properties.value) == 0
enabled: parseInt(infillSteps.properties.value) === 0
function updateSetting(value)
{

View file

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

View file

@ -137,10 +137,10 @@ Item
delegate: Cura.ExtruderButton
{
extruder: model
isTopElement: extrudersModel.getItem(0).id == model.id
isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id == model.id
isTopElement: extrudersModel.getItem(0).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)
checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1
checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) !== -1
enabled: UM.Selection.hasSelection && extruder.stack.isEnabled
font: UM.Theme.getFont("small_emphasis")

View file

@ -43,7 +43,7 @@ Cura.ComboBox {
var value = propertyProvider.properties["options"][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.
currentIndex = i
@ -81,7 +81,7 @@ Cura.ComboBox {
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)
}

View file

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

View file

@ -87,13 +87,13 @@ UM.TextField
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
return
}
if (propertyProvider && text != propertyProvider.properties.value)
if (propertyProvider && text !== propertyProvider.properties.value)
{
updateSetting(text);
}
@ -119,7 +119,7 @@ UM.TextField
State
{
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
{
target: background
@ -130,7 +130,7 @@ UM.TextField
State
{
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
{
target: background