aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/SpinBox.qml2
-rw-r--r--src/imports/controls/material/SpinBox.qml2
-rw-r--r--src/imports/controls/universal/SpinBox.qml2
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp58
-rw-r--r--src/quicktemplates2/qquickspinbox_p.h9
5 files changed, 67 insertions, 6 deletions
diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml
index 80b19839..09d59264 100644
--- a/src/imports/controls/SpinBox.qml
+++ b/src/imports/controls/SpinBox.qml
@@ -76,7 +76,7 @@ T.SpinBox {
readOnly: !control.editable
validator: control.validator
- inputMethodHints: Qt.ImhFormattedNumbersOnly
+ inputMethodHints: control.inputMethodHints
Rectangle {
x: -6 - (down.indicator ? 1 : 0)
diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml
index 203a8f8d..11d0f0dc 100644
--- a/src/imports/controls/material/SpinBox.qml
+++ b/src/imports/controls/material/SpinBox.qml
@@ -78,7 +78,7 @@ T.SpinBox {
readOnly: !control.editable
validator: control.validator
- inputMethodHints: Qt.ImhFormattedNumbersOnly
+ inputMethodHints: control.inputMethodHints
}
up.indicator: Item {
diff --git a/src/imports/controls/universal/SpinBox.qml b/src/imports/controls/universal/SpinBox.qml
index facc7bdd..3d582b89 100644
--- a/src/imports/controls/universal/SpinBox.qml
+++ b/src/imports/controls/universal/SpinBox.qml
@@ -79,7 +79,7 @@ T.SpinBox {
readOnly: !control.editable
validator: control.validator
- inputMethodHints: Qt.ImhFormattedNumbersOnly
+ inputMethodHints: control.inputMethodHints
}
up.indicator: Item {
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index 506405fe..829c64cc 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -43,6 +43,7 @@
#include <QtQml/qqmlinfo.h>
#include <QtQml/private/qqmllocale_p.h>
#include <QtQml/private/qqmlengine_p.h>
+#include <QtQuick/private/qquicktextinput_p.h>
QT_BEGIN_NAMESPACE
@@ -98,7 +99,7 @@ class QQuickSpinBoxPrivate : public QQuickControlPrivate
public:
QQuickSpinBoxPrivate() : editable(false), from(0), to(99), value(0), stepSize(1),
- delayTimer(0), repeatTimer(0), up(nullptr), down(nullptr), validator(nullptr) { }
+ delayTimer(0), repeatTimer(0), up(nullptr), down(nullptr), validator(nullptr), inputMethodHints(Qt::ImhDigitsOnly) { }
int boundValue(int value) const;
void updateValue();
@@ -132,6 +133,7 @@ public:
QValidator *validator;
mutable QJSValue textFromValue;
mutable QJSValue valueFromText;
+ Qt::InputMethodHints inputMethodHints;
};
int QQuickSpinBoxPrivate::boundValue(int value) const
@@ -594,6 +596,50 @@ QQuickSpinButton *QQuickSpinBox::down() const
}
/*!
+ \since QtQuick.Controls 2.2
+ \qmlproperty flags QtQuick.Controls::SpinBox::inputMethodHints
+
+ This property provides hints to the input method about the expected content
+ of the spin box and how it should operate.
+
+ The default value is \c Qt.ImhDigitsOnly.
+
+ \include inputmethodhints.qdocinc
+*/
+Qt::InputMethodHints QQuickSpinBox::inputMethodHints() const
+{
+ Q_D(const QQuickSpinBox);
+ return d->inputMethodHints;
+}
+
+void QQuickSpinBox::setInputMethodHints(Qt::InputMethodHints hints)
+{
+ Q_D(QQuickSpinBox);
+ if (d->inputMethodHints == hints)
+ return;
+
+ d->inputMethodHints = hints;
+ emit inputMethodHintsChanged();
+}
+
+/*!
+ \since QtQuick.Controls 2.2
+ \qmlproperty bool QtQuick.Controls::SpinBox::inputMethodComposing
+ \readonly
+
+ This property holds whether an editable spin box has partial text input from an input method.
+
+ While it is composing, an input method may rely on mouse or key events from the spin box to
+ edit or commit the partial text. This property can be used to determine when to disable event
+ handlers that may interfere with the correct operation of an input method.
+*/
+bool QQuickSpinBox::isInputMethodComposing() const
+{
+ Q_D(const QQuickSpinBox);
+ return d->contentItem && d->contentItem->property("inputMethodComposing").toBool();
+}
+
+/*!
\qmlmethod void QtQuick.Controls::SpinBox::increase()
Increases the value by \l stepSize, or \c 1 if stepSize is not defined.
@@ -773,9 +819,15 @@ void QQuickSpinBox::itemChange(ItemChange change, const ItemChangeData &value)
void QQuickSpinBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
{
- Q_UNUSED(oldItem);
- if (newItem)
+ if (QQuickTextInput *oldInput = qobject_cast<QQuickTextInput *>(oldItem))
+ disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged);
+
+ if (newItem) {
newItem->setActiveFocusOnTab(true);
+
+ if (QQuickTextInput *newInput = qobject_cast<QQuickTextInput *>(newItem))
+ connect(newInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged);
+ }
}
QFont QQuickSpinBox::defaultFont() const
diff --git a/src/quicktemplates2/qquickspinbox_p.h b/src/quicktemplates2/qquickspinbox_p.h
index b34f81a2..c3cd7ca8 100644
--- a/src/quicktemplates2/qquickspinbox_p.h
+++ b/src/quicktemplates2/qquickspinbox_p.h
@@ -71,6 +71,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSpinBox : public QQuickControl
Q_PROPERTY(QJSValue valueFromText READ valueFromText WRITE setValueFromText NOTIFY valueFromTextChanged FINAL)
Q_PROPERTY(QQuickSpinButton *up READ up CONSTANT FINAL)
Q_PROPERTY(QQuickSpinButton *down READ down CONSTANT FINAL)
+ Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged FINAL REVISION 2)
+ Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged FINAL REVISION 2)
public:
explicit QQuickSpinBox(QQuickItem *parent = nullptr);
@@ -102,6 +104,11 @@ public:
QQuickSpinButton *up() const;
QQuickSpinButton *down() const;
+ Qt::InputMethodHints inputMethodHints() const;
+ void setInputMethodHints(Qt::InputMethodHints hints);
+
+ bool isInputMethodComposing() const;
+
public Q_SLOTS:
void increase();
void decrease();
@@ -115,6 +122,8 @@ Q_SIGNALS:
void validatorChanged();
void textFromValueChanged();
void valueFromTextChanged();
+ Q_REVISION(2) void inputMethodHintsChanged();
+ Q_REVISION(2) void inputMethodComposingChanged();
protected:
bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;