From 37a34885b83515bedce1783bfb1c8d0aed5ca63c Mon Sep 17 00:00:00 2001 From: Voldivh Date: Wed, 20 Sep 2023 14:17:49 -0500 Subject: [PATCH 1/6] Changes SpinBox for a TextField Signed-off-by: Voldivh --- include/gz/gui/qml/GzSpinBox.qml | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index 800db5e11..2b0637dd8 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -18,12 +18,31 @@ import QtQuick 2.9 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 -SpinBox { - style: SpinBoxStyle{ - background: Rectangle { - implicitWidth: 70 - implicitHeight: 40 - border.color: "gray" +Item { + property double minimumValue : 0 + property double maximumValue : 100 + property double stepSize : 0 + property double decimals : 0 + property real value : 0 + signal onEditingFinished() + + TextField { + id: numberField + placeholderText: "0.0" + validator: DoubleValidator{bottom: minimumValue; + top: maximumValue; + decimals: decimals; + notation: DoubleValidator.StandardNotation; + } + onEditingFinished: { + parent.value = parseFloat(text) + } + style: TextFieldStyle{ + background: Rectangle { + implicitWidth: 70 + implicitHeight: 40 + border.color: "gray" + } } } } From bb26cc84693a2522050122d5447965863fd54609 Mon Sep 17 00:00:00 2001 From: Voldivh Date: Wed, 20 Sep 2023 14:46:41 -0500 Subject: [PATCH 2/6] Forwards signal emitter to correct element Signed-off-by: Voldivh --- include/gz/gui/qml/GzSpinBox.qml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index 2b0637dd8..31de6d5bf 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -23,20 +23,24 @@ Item { property double maximumValue : 100 property double stepSize : 0 property double decimals : 0 - property real value : 0 - signal onEditingFinished() + property double value : 0 + signal editingFinished + + onEditingFinished: { + value = parseFloat(numberField.text) + } TextField { id: numberField placeholderText: "0.0" - validator: DoubleValidator{bottom: minimumValue; - top: maximumValue; - decimals: decimals; + validator: DoubleValidator{bottom: parent.minimumValue; + top: parent.maximumValue; + decimals: parent.decimals; notation: DoubleValidator.StandardNotation; } onEditingFinished: { - parent.value = parseFloat(text) - } + parent.editingFinished() + } style: TextFieldStyle{ background: Rectangle { implicitWidth: 70 From 8c223e903a755fd58f73ec9f0efbe6886819a363 Mon Sep 17 00:00:00 2001 From: Voldivh Date: Wed, 20 Sep 2023 15:06:06 -0500 Subject: [PATCH 3/6] Adds name to top level element Signed-off-by: Voldivh --- include/gz/gui/qml/GzSpinBox.qml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index 31de6d5bf..d821b8701 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -19,11 +19,12 @@ import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 Item { - property double minimumValue : 0 - property double maximumValue : 100 - property double stepSize : 0 - property double decimals : 0 - property double value : 0 + id: gzSpinBoxItem + property real minimumValue : 0 + property real maximumValue : 100 + property real stepSize : 0 + property int decimals : 0 + property real value : 0 signal editingFinished onEditingFinished: { @@ -33,13 +34,13 @@ Item { TextField { id: numberField placeholderText: "0.0" - validator: DoubleValidator{bottom: parent.minimumValue; - top: parent.maximumValue; - decimals: parent.decimals; + validator: DoubleValidator{bottom: gzSpinBoxItem.minimumValue; + top: gzSpinBoxItem.maximumValue; + decimals: gzSpinBoxItem.decimals; notation: DoubleValidator.StandardNotation; } onEditingFinished: { - parent.editingFinished() + gzSpinBoxItem.editingFinished() } style: TextFieldStyle{ background: Rectangle { From 1c70799cd346e9a1d0795377902c753bd47f2cd1 Mon Sep 17 00:00:00 2001 From: Voldivh Date: Wed, 20 Sep 2023 15:24:34 -0500 Subject: [PATCH 4/6] Updates to use version 2.15 of QtQuick.Controls Signed-off-by: Voldivh --- include/gz/gui/qml/GzSpinBox.qml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index d821b8701..c1b045977 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -15,8 +15,8 @@ * */ import QtQuick 2.9 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 +import QtQuick.Controls 2.15 +import QtQuick.Controls.Styles 2.15 Item { id: gzSpinBoxItem @@ -40,14 +40,13 @@ Item { notation: DoubleValidator.StandardNotation; } onEditingFinished: { - gzSpinBoxItem.editingFinished() + parent.editingFinished() } - style: TextFieldStyle{ - background: Rectangle { - implicitWidth: 70 - implicitHeight: 40 - border.color: "gray" - } + + background: Rectangle { + implicitWidth: 70 + implicitHeight: 40 + border.color: "gray" } } } From ba589e0f0490cea0f7351471270641b4a90d111f Mon Sep 17 00:00:00 2001 From: Voldivh Date: Wed, 20 Sep 2023 15:41:57 -0500 Subject: [PATCH 5/6] Modifies the placeholder text Signed-off-by: Voldivh --- include/gz/gui/qml/GzSpinBox.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index c1b045977..745ad1a70 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -16,7 +16,6 @@ */ import QtQuick 2.9 import QtQuick.Controls 2.15 -import QtQuick.Controls.Styles 2.15 Item { id: gzSpinBoxItem @@ -33,7 +32,8 @@ Item { TextField { id: numberField - placeholderText: "0.0" + placeholderText: gzSpinBoxItem.value + horizontalAlignment: TextInput.AlignHCenter validator: DoubleValidator{bottom: gzSpinBoxItem.minimumValue; top: gzSpinBoxItem.maximumValue; decimals: gzSpinBoxItem.decimals; From 329433c307f80c9cda03b5e5b9441053914fcbf2 Mon Sep 17 00:00:00 2001 From: Voldivh Date: Fri, 22 Sep 2023 11:48:09 -0500 Subject: [PATCH 6/6] Disables the TextField from GzSpinBox Signed-off-by: Voldivh --- include/gz/gui/qml/GzSpinBox.qml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index 745ad1a70..ca22fc713 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -17,8 +17,8 @@ import QtQuick 2.9 import QtQuick.Controls 2.15 -Item { - id: gzSpinBoxItem +Control { + id: spinBoxItem property real minimumValue : 0 property real maximumValue : 100 property real stepSize : 0 @@ -26,23 +26,21 @@ Item { property real value : 0 signal editingFinished - onEditingFinished: { - value = parseFloat(numberField.text) - } - TextField { id: numberField - placeholderText: gzSpinBoxItem.value + placeholderText: spinBoxItem.value horizontalAlignment: TextInput.AlignHCenter - validator: DoubleValidator{bottom: gzSpinBoxItem.minimumValue; - top: gzSpinBoxItem.maximumValue; - decimals: gzSpinBoxItem.decimals; + activeFocusOnPress: spinBoxItem.activeFocusOnPress + enabled: false // The TextField is disabled for the moment due to a not desired behavior. + validator: DoubleValidator{bottom: spinBoxItem.minimumValue; + top: spinBoxItem.maximumValue; + decimals: spinBoxItem.decimals; notation: DoubleValidator.StandardNotation; } onEditingFinished: { - parent.editingFinished() + spinBoxItem.value = parseFloat(text) + spinBoxItem.editingFinished() } - background: Rectangle { implicitWidth: 70 implicitHeight: 40