diff --git a/plugins/SimulationView/SimulationSliderLabel.qml b/plugins/SimulationView/SimulationSliderLabel.qml index afd02069eb..850fff7440 100644 --- a/plugins/SimulationView/SimulationSliderLabel.qml +++ b/plugins/SimulationView/SimulationSliderLabel.qml @@ -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 diff --git a/plugins/SimulationView/SimulationViewMainComponent.qml b/plugins/SimulationView/SimulationViewMainComponent.qml index af60692273..aaea15025e 100644 --- a/plugins/SimulationView/SimulationViewMainComponent.qml +++ b/plugins/SimulationView/SimulationViewMainComponent.qml @@ -2,7 +2,6 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.4 -import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.1 diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index 379da63c28..1e58fb23bb 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -2,7 +2,6 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.4 -import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.1 import QtGraphicalEffects 1.0