mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Make SpinBox a reusable component
Forgot to update Readonly `SpinBox`es to Qt 2 when implementing Cura 8684. As the spinbox is used in various places with the same functionality it made sense to create a reusable component. There is still a feature gap in the implementation; The `SpinBox`es from QtControls 2.x value is defined as an integer. For some use-cases we do require a fractional value in the `SpinBox`. The only two places where this is required are the `material_diameter` and `material_density` fields in the material prefference page. Cura 8684
This commit is contained in:
parent
b18582e1fb
commit
1746e24dd9
3 changed files with 63 additions and 105 deletions
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (c) 2016 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.1
|
||||
import QtQuick.Controls 1.1
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
Item
|
||||
{
|
||||
id: base
|
||||
|
||||
property alias value: spinBox.value
|
||||
property alias minimumValue: spinBox.minimumValue
|
||||
property alias maximumValue: spinBox.maximumValue
|
||||
property alias stepSize: spinBox.stepSize
|
||||
property alias prefix: spinBox.prefix
|
||||
property alias suffix: spinBox.suffix
|
||||
property alias decimals: spinBox.decimals
|
||||
|
||||
signal editingFinished();
|
||||
|
||||
property bool readOnly: false
|
||||
|
||||
width: spinBox.width
|
||||
height: spinBox.height
|
||||
|
||||
SpinBox
|
||||
{
|
||||
id: spinBox
|
||||
|
||||
enabled: !base.readOnly
|
||||
opacity: base.readOnly ? 0.5 : 1.0
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
onEditingFinished: base.editingFinished()
|
||||
Keys.onEnterPressed: spinBox.focus = false
|
||||
Keys.onReturnPressed: spinBox.focus = false
|
||||
}
|
||||
|
||||
Label
|
||||
{
|
||||
visible: base.readOnly
|
||||
text: base.prefix + base.value.toFixed(spinBox.decimals) + base.suffix
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: spinBox.__style ? spinBox.__style.padding.left : 0
|
||||
|
||||
color: palette.buttonText
|
||||
}
|
||||
|
||||
SystemPalette { id: palette }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue