Convert Layerview component to controls 2

This commit is contained in:
Jaime van Kessel 2021-11-11 16:51:03 +01:00
parent 99a5aa363f
commit 75cd792b00
3 changed files with 25 additions and 32 deletions

View file

@ -1,14 +1,14 @@
// Copyright (c) 2017 Ultimaker B.V.
// Copyright (c) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.5
import QtQuick.Controls 1.2
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
import UM 1.0 as UM
import Cura 1.0 as Cura
UM.PointingRectangle {
UM.PointingRectangle
{
id: sliderLabelRoot
// custom properties
@ -28,47 +28,40 @@ UM.PointingRectangle {
borderColor: UM.Theme.getColor("lining")
borderWidth: UM.Theme.getSize("default_lining").width
Behavior on height {
NumberAnimation {
duration: 50
}
}
Behavior on height { NumberAnimation { duration: 50 } }
// catch all mouse events so they're not handled by underlying 3D scene
MouseArea {
MouseArea
{
anchors.fill: parent
}
TextMetrics {
TextMetrics
{
id: maxValueMetrics
font: valueLabel.font
text: maximumValue + 1 // layers are 0 based, add 1 for display value
}
TextField {
TextField
{
id: valueLabel
anchors {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
alignWhenCentered: false
}
anchors.centerIn: parent
width: maxValueMetrics.width + UM.Theme.getSize("default_margin").width
//width: maxValueMetrics.contentWidth + 2 * UM.Theme.getSize("default_margin").width
text: sliderLabelRoot.value + startFrom // the current handle value, add 1 because layers is an array
horizontalAlignment: TextInput.AlignHCenter
leftPadding: UM.Theme.getSize("narrow_margin").width
rightPadding: UM.Theme.getSize("narrow_margin").width
// key bindings, work when label is currently focused (active handle in LayerSlider)
Keys.onUpPressed: sliderLabelRoot.setValue(sliderLabelRoot.value + ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
Keys.onDownPressed: sliderLabelRoot.setValue(sliderLabelRoot.value - ((event.modifiers & Qt.ShiftModifier) ? 10 : 1))
style: TextFieldStyle {
textColor: UM.Theme.getColor("text")
font: UM.Theme.getFont("default")
renderType: Text.NativeRendering
background: Item { }
}
color: UM.Theme.getColor("text")
font: UM.Theme.getFont("default")
renderType: Text.NativeRendering
background: Item {}
onEditingFinished: {
@ -84,16 +77,18 @@ UM.PointingRectangle {
}
}
validator: IntValidator {
validator: IntValidator
{
bottom: startFrom
top: sliderLabelRoot.maximumValue + startFrom // +startFrom because maybe we want to start in a different value rather than 0
}
}
BusyIndicator {
BusyIndicator
{
id: busyIndicator
anchors {
anchors
{
left: parent.right
leftMargin: Math.round(UM.Theme.getSize("default_margin").width / 2)
verticalCenter: parent.verticalCenter