Changed parseInt to Math.floor

This commit is contained in:
Mark 2017-10-11 16:47:40 +02:00
parent 331574eec0
commit 3a7fbdb173
7 changed files with 64 additions and 64 deletions

View file

@ -108,15 +108,15 @@ TabView
{
width: scrollView.columnWidth;
height: parent.rowHeight;
spacing: parseInt(UM.Theme.getSize("default_margin").width/2)
spacing: Math.floor(UM.Theme.getSize("default_margin").width/2)
Rectangle
{
id: colorSelector
color: properties.color_code
width: parseInt(colorLabel.height * 0.75)
height: parseInt(colorLabel.height * 0.75)
width: Math.floor(colorLabel.height * 0.75)
height: Math.floor(colorLabel.height * 0.75)
border.width: UM.Theme.getSize("default_lining").height
anchors.verticalCenter: parent.verticalCenter

View file

@ -67,7 +67,7 @@ UM.ManagementPage
}
Label
{
width: parseInt((parent.width * 0.3))
width: Math.floor((parent.width * 0.3))
text: model.metadata.material
elide: Text.ElideRight
font.italic: model.id == activeId

View file

@ -24,7 +24,7 @@ Column
{
id: connectedPrinterHeader
width: parent.width
height: parseInt(childrenRect.height + UM.Theme.getSize("default_margin").height * 2)
height: Math.floor(childrenRect.height + UM.Theme.getSize("default_margin").height * 2)
color: UM.Theme.getColor("setting_category")
Label
@ -82,7 +82,7 @@ Column
{
id: extruderRectangle
color: UM.Theme.getColor("sidebar")
width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : parseInt(extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2)
width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : Math.floor(extrudersGrid.width / 2 - UM.Theme.getSize("sidebar_lining_thin").width / 2)
height: UM.Theme.getSize("sidebar_extruder_box").height
Label //Extruder name.
@ -162,8 +162,8 @@ Column
Rectangle //Material colour indication.
{
id: materialColor
width: parseInt(materialName.height * 0.75)
height: parseInt(materialName.height * 0.75)
width: Math.floor(materialName.height * 0.75)
height: Math.floor(materialName.height * 0.75)
radius: width / 2
color: (connectedPrinter != null && connectedPrinter.materialColors[index] != null && connectedPrinter.materialIds[index] != "") ? connectedPrinter.materialColors[index] : "#00000000"
border.width: UM.Theme.getSize("default_lining").width
@ -357,7 +357,7 @@ Column
color: !enabled ? UM.Theme.getColor("setting_control_disabled") : showError ? UM.Theme.getColor("setting_validation_error_background") : UM.Theme.getColor("setting_validation_ok")
property var showError:
{
if(bedTemperature.properties.maximum_value != "None" && bedTemperature.properties.maximum_value < parseInt(preheatTemperatureInput.text))
if(bedTemperature.properties.maximum_value != "None" && bedTemperature.properties.maximum_value < Math.floor(preheatTemperatureInput.text))
{
return true;
} else
@ -475,7 +475,7 @@ Column
visible: preheatCountdown.visible
source: UM.Theme.getIcon("print_time")
anchors.right: preheatCountdown.left
anchors.rightMargin: parseInt(UM.Theme.getSize("default_margin").width / 2)
anchors.rightMargin: Math.floor(UM.Theme.getSize("default_margin").width / 2)
anchors.verticalCenter: preheatCountdown.verticalCenter
}
@ -527,15 +527,15 @@ Column
{
return true; //Can always cancel if the timer is running.
}
if (bedTemperature.properties.minimum_value != "None" && parseInt(preheatTemperatureInput.text) < parseInt(bedTemperature.properties.minimum_value))
if (bedTemperature.properties.minimum_value != "None" && Math.floor(preheatTemperatureInput.text) < Math.floor(bedTemperature.properties.minimum_value))
{
return false; //Target temperature too low.
}
if (bedTemperature.properties.maximum_value != "None" && parseInt(preheatTemperatureInput.text) > parseInt(bedTemperature.properties.maximum_value))
if (bedTemperature.properties.maximum_value != "None" && Math.floor(preheatTemperatureInput.text) > Math.floor(bedTemperature.properties.maximum_value))
{
return false; //Target temperature too high.
}
if (parseInt(preheatTemperatureInput.text) == 0)
if (Math.floor(preheatTemperatureInput.text) == 0)
{
return false; //Setting the temperature to 0 is not allowed (since that cancels the pre-heating).
}
@ -708,13 +708,13 @@ Column
Row
{
height: UM.Theme.getSize("setting_control").height
width: parseInt(base.width - 2 * UM.Theme.getSize("default_margin").width)
width: Math.floor(base.width - 2 * UM.Theme.getSize("default_margin").width)
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width
Label
{
width: parseInt(parent.width * 0.4)
width: Math.floor(parent.width * 0.4)
anchors.verticalCenter: parent.verticalCenter
text: label
color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
@ -723,7 +723,7 @@ Column
}
Label
{
width: parseInt(parent.width * 0.6)
width: Math.floor(parent.width * 0.6)
anchors.verticalCenter: parent.verticalCenter
text: value
color: connectedPrinter != null && connectedPrinter.acceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")

View file

@ -39,7 +39,7 @@ Item
{
id: globalProfileLabel
text: catalog.i18nc("@label","Profile:");
width: parseInt(parent.width * 0.45 - UM.Theme.getSize("sidebar_margin").width - 2)
width: Math.floor(parent.width * 0.45 - UM.Theme.getSize("sidebar_margin").width - 2)
font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text");
verticalAlignment: Text.AlignVCenter
@ -63,7 +63,7 @@ Item
}
enabled: !header.currentExtruderVisible || header.currentExtruderIndex > -1
width: parseInt(parent.width * 0.55)
width: Math.floor(parent.width * 0.55)
height: UM.Theme.getSize("setting_control").height
anchors.left: globalProfileLabel.right
anchors.right: parent.right
@ -77,8 +77,8 @@ Item
id: customisedSettings
visible: Cura.MachineManager.hasUserSettings
height: parseInt(parent.height * 0.6)
width: parseInt(parent.height * 0.6)
height: Math.floor(parent.height * 0.6)
width: Math.floor(parent.height * 0.6)
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right

View file

@ -121,7 +121,7 @@ Rectangle
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
anchors.top: headerSeparator.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
width: parseInt(parent.width * 0.45)
width: Math.floor(parent.width * 0.45)
font: UM.Theme.getFont("large")
color: UM.Theme.getColor("text")
visible: !monitoringPrint && !hideView
@ -130,7 +130,7 @@ Rectangle
Rectangle {
id: settingsModeSelection
color: "transparent"
width: parseInt(parent.width * 0.55)
width: Math.floor(parent.width * 0.55)
height: UM.Theme.getSize("sidebar_header_mode_toggle").height
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
@ -154,7 +154,7 @@ Rectangle
anchors.left: parent.left
anchors.leftMargin: model.index * (settingsModeSelection.width / 2)
anchors.verticalCenter: parent.verticalCenter
width: parseInt(0.5 * parent.width)
width: Math.floor(0.5 * parent.width)
text: model.text
exclusiveGroup: modeMenuGroup;
checkable: true;
@ -310,7 +310,7 @@ Rectangle
height: UM.Theme.getSize("sidebar_lining").height
color: UM.Theme.getColor("sidebar_lining")
anchors.bottom: printSpecs.top
anchors.bottomMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 2 + UM.Theme.getSize("progressbar").height + UM.Theme.getFont("default_bold").pixelSize)
anchors.bottomMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 2 + UM.Theme.getSize("progressbar").height + UM.Theme.getFont("default_bold").pixelSize)
}
Rectangle
@ -490,7 +490,7 @@ Rectangle
})
sidebarContents.push({ "item": modesListModel.get(base.currentModeIndex).item, "immediate": true });
var index = parseInt(UM.Preferences.getValue("cura/active_mode"))
var index = Math.floor(UM.Preferences.getValue("cura/active_mode"))
if(index)
{
currentModeIndex = index;

View file

@ -17,7 +17,7 @@ Column
property int currentExtruderIndex: ExtruderManager.activeExtruderIndex;
property bool currentExtruderVisible: extrudersList.visible;
spacing: UM.Theme.getSize("sidebar_margin").width * 0.9
spacing: Math.floor(UM.Theme.getSize("sidebar_margin").width * 0.9)
signal showTooltip(Item item, point location, string text)
signal hideTooltip()
@ -52,15 +52,15 @@ Column
{
id: extruderSelectionRow
width: parent.width
height: UM.Theme.getSize("sidebar_tabs").height * 2 / 3
height: Math.floor(UM.Theme.getSize("sidebar_tabs").height * 2 / 3)
visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("sidebar_margin").width * 0.7
leftMargin: Math.floor(UM.Theme.getSize("sidebar_margin").width * 0.7)
right: parent.right
rightMargin: UM.Theme.getSize("sidebar_margin").width * 0.7
rightMargin: Math.floor(UM.Theme.getSize("sidebar_margin").width * 0.7)
topMargin: UM.Theme.getSize("sidebar_margin").height
}
@ -70,15 +70,15 @@ Column
property var index: 0
height: UM.Theme.getSize("sidebar_header_mode_tabs").height
width: parent.width
width: Math.floor(parent.width)
boundsBehavior: Flickable.StopAtBounds
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width / 2
leftMargin: Math.floor(UM.Theme.getSize("default_margin").width / 2)
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width / 2
rightMargin: Math.floor(UM.Theme.getSize("default_margin").width / 2)
verticalCenter: parent.verticalCenter
}
@ -134,7 +134,7 @@ Column
width: {
var extruderTextWidth = extruderStaticText.visible ? extruderStaticText.width : 0;
var iconWidth = extruderIconItem.width;
return parseInt(extruderTextWidth + iconWidth + UM.Theme.getSize("default_margin").width / 2);
return Math.floor(extruderTextWidth + iconWidth + UM.Theme.getSize("default_margin").width / 2);
}
// Static text "Extruder"
@ -166,7 +166,7 @@ Column
var minimumWidth = control.width < UM.Theme.getSize("button").width ? control.width : UM.Theme.getSize("button").width;
var minimumHeight = control.height < UM.Theme.getSize("button").height ? control.height : UM.Theme.getSize("button").height;
var minimumSize = minimumWidth < minimumHeight ? minimumWidth : minimumHeight;
minimumSize -= parseInt(UM.Theme.getSize("default_margin").width / 2);
minimumSize -= Math.floor(UM.Theme.getSize("default_margin").width / 2);
return minimumSize;
}
@ -254,7 +254,7 @@ Column
{
id: materialLabel
text: catalog.i18nc("@label","Material");
width: parseInt(parent.width * 0.45 - UM.Theme.getSize("default_margin").width)
width: Math.floor(parent.width * 0.45 - UM.Theme.getSize("default_margin").width)
font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text");
}
@ -310,7 +310,7 @@ Column
{
id: printCoreLabel
text: Cura.MachineManager.activeDefinitionVariantsName;
width: parseInt(parent.width * 0.45 - UM.Theme.getSize("default_margin").width)
width: Math.floor(parent.width * 0.45 - UM.Theme.getSize("default_margin").width)
font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text");
}
@ -322,7 +322,7 @@ Column
visible: Cura.MachineManager.hasVariants
height: UM.Theme.getSize("setting_control").height
width: parseInt(parent.width * 0.7 + UM.Theme.getSize("sidebar_margin").width)
width: Math.floor(parent.width * 0.7 + UM.Theme.getSize("sidebar_margin").width)
anchors.right: parent.right
style: UM.Theme.styles.sidebar_header_button
activeFocusOnPress: true;
@ -335,7 +335,7 @@ Column
Item
{
id: materialInfoRow
height: parseInt(UM.Theme.getSize("sidebar_setup").height / 2)
height: Math.floor(UM.Theme.getSize("sidebar_setup").height / 2)
visible: (Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials) && !sidebar.monitoringPrint && !sidebar.hideSettings
anchors
@ -349,7 +349,7 @@ Column
Item {
height: UM.Theme.getSize("sidebar_setup").height
anchors.right: parent.right
width: parseInt(parent.width * 0.7 + UM.Theme.getSize("sidebar_margin").width)
width: Math.floor(parent.width * 0.7 + UM.Theme.getSize("sidebar_margin").width)
UM.RecolorImage {
id: warningImage

View file

@ -175,7 +175,7 @@ Item
{
anchors.verticalCenter: parent.verticalCenter
anchors.top: parent.top
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height / 2)
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height / 2)
color: (Cura.MachineManager.activeMachine != null && Cura.ProfilesModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
text:
{
@ -194,13 +194,13 @@ Item
// Make sure the text aligns correctly with each tick
if (qualityModel.totalTicks == 0) {
// If there is only one tick, align it centrally
return parseInt(((base.width * 0.55) - width) / 2)
return Math.floor(((base.width * 0.55) - width) / 2)
} else if (index == 0) {
return (base.width * 0.55 / qualityModel.totalTicks) * index
} else if (index == qualityModel.totalTicks) {
return (base.width * 0.55 / qualityModel.totalTicks) * index - width
} else {
return parseInt((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2))
return Math.floor((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2))
}
}
}
@ -361,7 +361,7 @@ Item
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height * 2
anchors.left: parent.left
width: parseInt(UM.Theme.getSize("sidebar").width * .45 - UM.Theme.getSize("sidebar_margin").width)
width: Math.floor(UM.Theme.getSize("sidebar").width * .45 - UM.Theme.getSize("sidebar_margin").width)
Label
{
@ -371,7 +371,7 @@ Item
color: UM.Theme.getColor("text")
anchors.top: parent.top
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 1.7)
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 1.7)
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
}
@ -382,7 +382,7 @@ Item
id: infillCellRight
height: infillSlider.height + UM.Theme.getSize("sidebar_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("sidebar_margin").height)
width: parseInt(UM.Theme.getSize("sidebar").width * .55)
width: Math.floor(UM.Theme.getSize("sidebar").width * .55)
anchors.left: infillCellLeft.right
anchors.top: infillCellLeft.top
@ -393,10 +393,10 @@ Item
//anchors.top: parent.top
anchors.left: infillSlider.left
anchors.leftMargin: parseInt((infillSlider.value / infillSlider.stepSize) * (infillSlider.width / (infillSlider.maximumValue / infillSlider.stepSize)) - 10 * screenScaleFactor)
anchors.leftMargin: Math.floor((infillSlider.value / infillSlider.stepSize) * (infillSlider.width / (infillSlider.maximumValue / infillSlider.stepSize)) - 10 * screenScaleFactor)
anchors.right: parent.right
text: parseInt(infillDensity.properties.value) + "%"
text: Math.floor(infillDensity.properties.value) + "%"
horizontalAlignment: Text.AlignLeft
color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
@ -406,7 +406,7 @@ Item
Binding {
target: infillSlider
property: "value"
value: parseInt(infillDensity.properties.value)
value: Math.floor(infillDensity.properties.value)
}
Slider
@ -419,7 +419,7 @@ Item
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
height: UM.Theme.getSize("sidebar_margin").height
width: parseInt(infillCellRight.width - UM.Theme.getSize("sidebar_margin").width - style.handleWidth)
width: Math.floor(infillCellRight.width - UM.Theme.getSize("sidebar_margin").width - style.handleWidth)
minimumValue: 0
maximumValue: 100
@ -427,15 +427,15 @@ Item
tickmarksEnabled: true
// disable slider when gradual support is enabled
enabled: parseInt(infillSteps.properties.value) == 0
enabled: Math.floor(infillSteps.properties.value) == 0
// set initial value from stack
value: parseInt(infillDensity.properties.value)
value: Math.floor(infillDensity.properties.value)
onValueChanged: {
// Don't round the value if it's already the same
if (parseInt(infillDensity.properties.value) == infillSlider.value) {
if (Math.floor(infillDensity.properties.value) == infillSlider.value) {
return
}
@ -504,7 +504,7 @@ Item
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height / 2)
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height / 2)
// we loop over all density icons and only show the one that has the current density and steps
Repeater
@ -515,8 +515,8 @@ Item
property int activeIndex: {
for (var i = 0; i < infillModel.count; i++) {
var density = parseInt(infillDensity.properties.value)
var steps = parseInt(infillSteps.properties.value)
var density = Math.floor(infillDensity.properties.value)
var steps = Math.floor(infillSteps.properties.value)
var infillModelItem = infillModel.get(i)
if (density >= infillModelItem.percentageMin
@ -555,13 +555,13 @@ Item
property alias _hovered: enableGradualInfillMouseArea.containsMouse
anchors.top: infillSlider.bottom
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height / 2) // closer to slider since it belongs to the same category
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height / 2) // closer to slider since it belongs to the same category
anchors.left: infillCellRight.left
style: UM.Theme.styles.checkbox
enabled: base.settingsEnabled
visible: infillSteps.properties.enabled == "True"
checked: parseInt(infillSteps.properties.value) > 0
checked: Math.floor(infillSteps.properties.value) > 0
MouseArea {
id: enableGradualInfillMouseArea
@ -570,18 +570,18 @@ Item
hoverEnabled: true
enabled: true
property var previousInfillDensity: parseInt(infillDensity.properties.value)
property var previousInfillDensity: Math.floor(infillDensity.properties.value)
onClicked: {
// Set to 90% only when enabling gradual infill
if (parseInt(infillSteps.properties.value) == 0) {
previousInfillDensity = parseInt(infillDensity.properties.value)
if (Math.floor(infillSteps.properties.value) == 0) {
previousInfillDensity = Math.floor(infillDensity.properties.value)
infillDensity.setPropertyValue("value", String(90))
} else {
infillDensity.setPropertyValue("value", String(previousInfillDensity))
}
infillSteps.setPropertyValue("value", (parseInt(infillSteps.properties.value) == 0) ? 5 : 0)
infillSteps.setPropertyValue("value", (Math.floor(infillSteps.properties.value) == 0) ? 5 : 0)
}
onEntered: {
@ -597,7 +597,7 @@ Item
Label {
id: gradualInfillLabel
anchors.left: enableGradualInfillCheckBox.right
anchors.leftMargin: parseInt(UM.Theme.getSize("sidebar_margin").width / 2)
anchors.leftMargin: Math.floor(UM.Theme.getSize("sidebar_margin").width / 2)
text: catalog.i18nc("@label", "Enable gradual")
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
@ -658,7 +658,7 @@ Item
visible: enableSupportCheckBox.visible
anchors.top: infillCellRight.bottom
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 1.5)
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 1.5)
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
anchors.verticalCenter: enableSupportCheckBox.verticalCenter
@ -867,7 +867,7 @@ Item
{
id: tipsCell
anchors.top: adhesionCheckBox.visible ? adhesionCheckBox.bottom : (enableSupportCheckBox.visible ? supportExtruderCombobox.bottom : infillCellRight.bottom)
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 2)
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 2)
anchors.left: parent.left
width: parent.width
height: tipsText.contentHeight * tipsText.lineCount