123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import QtQuick 2.5
- import QtQuick.Controls 2.2
- import QtQuick.Layouts 1.1
- import UM 1.0 as UM
- import Cura 1.0 as Cura
- UM.PointingRectangle
- {
- id: sliderLabelRoot
-
- property real maximumValue: 100
- property real value: 0
- property var setValue
- property bool busy: false
- property int startFrom: 1
- target: Qt.point(parent.width, y + height / 2)
- arrowSize: UM.Theme.getSize("button_tooltip_arrow").height
- height: parent.height
- width: valueLabel.width
- visible: false
- color: UM.Theme.getColor("tool_panel_background")
- borderColor: UM.Theme.getColor("lining")
- borderWidth: UM.Theme.getSize("default_lining").width
- Behavior on height { NumberAnimation { duration: 50 } }
-
- MouseArea
- {
- anchors.fill: parent
- }
- TextMetrics
- {
- id: maxValueMetrics
- font: valueLabel.font
- text: maximumValue + 1
- }
- TextField
- {
- id: valueLabel
- anchors.centerIn: parent
-
- text: sliderLabelRoot.value + startFrom
- horizontalAlignment: TextInput.AlignHCenter
- leftPadding: UM.Theme.getSize("narrow_margin").width
- rightPadding: UM.Theme.getSize("narrow_margin").width
-
- Keys.onUpPressed: 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")
- font: UM.Theme.getFont("default")
- renderType: Text.NativeRendering
- background: Item {}
- selectByMouse: true
- onEditingFinished: {
-
-
-
- cursorPosition = 0
- if (valueLabel.text != "") {
-
- sliderLabelRoot.setValue(parseInt(valueLabel.text) - startFrom)
- }
- }
- validator: IntValidator
- {
- bottom: startFrom
- top: sliderLabelRoot.maximumValue + startFrom
- }
- }
- BusyIndicator
- {
- id: busyIndicator
- anchors
- {
- left: parent.right
- leftMargin: Math.round(UM.Theme.getSize("default_margin").width / 2)
- verticalCenter: parent.verticalCenter
- }
- width: sliderLabelRoot.height
- height: width
- visible: sliderLabelRoot.busy
- running: sliderLabelRoot.busy
- }
- }
|