Merge remote-tracking branch 'origin/CURA-8688_qt6_cleanup' into CURA-8688_qt6_cleanup

This commit is contained in:
j.delarago 2022-03-01 11:48:57 +01:00
commit a6801fc88a

View File

@ -1,9 +1,8 @@
// Copyright (c) 2018 Ultimaker B.V. // Copyright (c) 2022 Ultimaker B.V.
// 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
import QtQuick.Controls 1.4 import QtQuick.Controls 2.15
import QtQuick.Controls.Styles 1.4
import UM 1.5 as UM import UM 1.5 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
@ -87,10 +86,9 @@ Item
width: parent.width width: parent.width
height: UM.Theme.getSize("print_setup_slider_handle").height // The handle is the widest element of the slider height: UM.Theme.getSize("print_setup_slider_handle").height // The handle is the widest element of the slider
minimumValue: 0 from: 0
maximumValue: 100 to: 100
stepSize: 1 stepSize: 1
tickmarksEnabled: 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
@ -98,53 +96,37 @@ Item
// set initial value from stack // set initial value from stack
value: parseInt(infillDensity.properties.value) value: parseInt(infillDensity.properties.value)
style: SliderStyle
{
//Draw line //Draw line
groove: Item background: Rectangle
{
Rectangle
{ {
id: backgroundLine
height: UM.Theme.getSize("print_setup_slider_groove").height height: UM.Theme.getSize("print_setup_slider_groove").height
width: control.width - UM.Theme.getSize("print_setup_slider_handle").width width: infillSlider.width - UM.Theme.getSize("print_setup_slider_handle").width
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
}
}
handle: Rectangle Repeater
{
id: handleButton
color: control.enabled ? UM.Theme.getColor("primary") : UM.Theme.getColor("quality_slider_unavailable")
implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width
implicitHeight: implicitWidth
radius: Math.round(implicitWidth / 2)
border.color: UM.Theme.getColor("slider_groove_fill")
border.width: UM.Theme.getSize("default_lining").height
}
tickmarks: Repeater
{ {
id: repeater id: repeater
model: control.maximumValue / control.stepSize + 1 anchors.fill: parent
model: infillSlider.to / infillSlider.stepSize + 1
Rectangle Rectangle
{ {
color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width
implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
// Do not use Math.round otherwise the tickmarks won't be aligned // Do not use Math.round otherwise the tickmarks won't be aligned
x: ((styleData.handleWidth / 2) - (implicitWidth / 2) + (index * ((repeater.width - styleData.handleWidth) / (repeater.count-1)))) x: ((handleButton.width / 2) - (backgroundLine.implicitWidth / 2) + (index * ((repeater.width - handleButton.width) / (repeater.count-1))))
radius: Math.round(implicitWidth / 2) radius: Math.round(backgroundLine.implicitWidth / 2)
visible: (index % 10) == 0 // Only show steps of 10% visible: (index % 10) == 0 // Only show steps of 10%
Label UM.Label
{ {
text: index text: index
font: UM.Theme.getFont("default")
visible: (index % 20) == 0 // Only show steps of 20% visible: (index % 20) == 0 // Only show steps of 20%
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y: UM.Theme.getSize("thin_margin").height y: UM.Theme.getSize("thin_margin").height
@ -155,7 +137,23 @@ Item
} }
} }
onValueChanged: handle: Rectangle
{
id: handleButton
x: infillSlider.leftPadding + infillSlider.visualPosition * (infillSlider.availableWidth - width)
y: infillSlider.topPadding + infillSlider.availableHeight / 2 - height / 2
color: infillSlider.enabled ? UM.Theme.getColor("primary") : UM.Theme.getColor("quality_slider_unavailable")
implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width
implicitHeight: implicitWidth
radius: Math.round(implicitWidth / 2)
border.color: UM.Theme.getColor("slider_groove_fill")
border.width: UM.Theme.getSize("default_lining").height
}
Connections
{
target: infillSlider
function onValueChanged()
{ {
// Don't round the value if it's already the same // Don't round the value if it's already the same
if (parseInt(infillDensity.properties.value) == infillSlider.value) if (parseInt(infillDensity.properties.value) == infillSlider.value)
@ -172,7 +170,7 @@ Item
// Update value only if the Recommended mode is Active, // Update value only if the Recommended mode is Active,
// Otherwise if I change the value in the Custom mode the Recommended view will try to repeat // Otherwise if I change the value in the Custom mode the Recommended view will try to repeat
// same operation // same operation
var active_mode = UM.Preferences.getValue("cura/active_mode") const active_mode = UM.Preferences.getValue("cura/active_mode")
if (active_mode == 0 || active_mode == "simple") if (active_mode == 0 || active_mode == "simple")
{ {
@ -182,6 +180,7 @@ Item
} }
} }
} }
}
// Gradual Support Infill Checkbox // Gradual Support Infill Checkbox
UM.CheckBox UM.CheckBox