2 * Copyright (C) 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
21 /*! Range Input Filter Widget. */
26 implicitHeight: field1.height + units.gu(2)
28 function setFieldValue(field, hasValue, value) {
30 // Need this othewise if we are on 4.5 and backspace instead of
31 // having 4. in the text field we end up with 4 which is confusing
32 if (field.text != value) {
42 onStartValueChanged: root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
43 onHasStartValueChanged: root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
44 onEndValueChanged: root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
45 onHasEndValueChanged: root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
48 onWidgetDataChanged: {
50 root.setFieldValue(field1, widgetData.hasStartValue, widgetData.startValue);
51 root.setFieldValue(field2, widgetData.hasEndValue, widgetData.endValue);
53 root.setFieldValue(field1, false, -1);
54 root.setFieldValue(field2, false, -1);
61 topMargin: units.gu(1)
62 bottomMargin: units.gu(1)
66 Layout.fillWidth: true
70 text: widgetData.startPrefixLabel
71 verticalAlignment: Text.AlignVCenter
76 objectName: "startValueField"
77 implicitWidth: units.gu(9)
78 verticalAlignment: Text.AlignVCenter
79 inputMethodHints: Qt.ImhFormattedNumbersOnly
80 validator: DoubleValidator {
81 notation: DoubleValidator.StandardNotation
84 if (text === "") widgetData.eraseStartValue();
85 else widgetData.startValue = text;
90 text: widgetData.startPostfixLabel
91 verticalAlignment: Text.AlignVCenter
95 Layout.fillWidth: true
99 text: widgetData.centralLabel
100 verticalAlignment: Text.AlignVCenter
104 Layout.fillWidth: true
108 text: widgetData.endPrefixLabel
109 verticalAlignment: Text.AlignVCenter
114 objectName: "endValueField"
115 implicitWidth: units.gu(9)
116 verticalAlignment: Text.AlignVCenter
117 inputMethodHints: Qt.ImhFormattedNumbersOnly
118 validator: DoubleValidator {
119 notation: DoubleValidator.StandardNotation
122 if (text === "") widgetData.eraseEndValue();
123 else widgetData.endValue = text;
128 text: widgetData.endPostfixLabel
129 verticalAlignment: Text.AlignVCenter
133 Layout.fillWidth: true