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

View file

@ -2,7 +2,6 @@
// 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.4 import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1

View file

@ -2,7 +2,6 @@
// 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.4 import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0