From 697f8f9921701a5da3ef8a97c97f33ade1db8ecf Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 12 Feb 2010 14:12:04 +1000 Subject: Adds inputMethodHint property to TextEdit and TextInput. Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qmlgraphicstextedit_p.h | 1 + src/declarative/graphicsitems/qmlgraphicstextinput_p.h | 2 ++ .../qmlgraphicstextedit/data/inputmethodhints.qml | 6 ++++++ .../qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp | 16 ++++++++++++++++ .../qmlgraphicstextinput/data/inputmethodhints.qml | 6 ++++++ .../qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp | 16 ++++++++++++++++ 6 files changed, 47 insertions(+) create mode 100644 tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml create mode 100644 tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h index 97c3fae..e95b077 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h @@ -84,6 +84,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsTextEdit : public QmlGraphicsPaintedItem Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged) Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged) Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged) + Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints) public: QmlGraphicsTextEdit(QmlGraphicsItem *parent=0); diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h index 68f28f8..4708381 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h @@ -81,6 +81,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsTextInput : public QmlGraphicsPaintedItem Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged) Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged) Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged) + Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints) + Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged) Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged) Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged) diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml b/tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml new file mode 100644 index 0000000..c3d4c16 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +TextEdit { + text: "Hello world!" + inputMethodHints: Qt.ImhNoPredictiveText +} diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp index 99e8259..2bfb280 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp +++ b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp @@ -76,6 +76,7 @@ private slots: void persistentSelection(); void focusOnPress(); void selection(); + void inputMethodHints(); void cursorDelegate(); void delegateLoading(); @@ -600,6 +601,21 @@ void tst_qmlgraphicstextedit::selection() QVERIFY(textEditObject->selectedText().size() == 10); } +void tst_qmlgraphicstextedit::inputMethodHints() +{ + QmlView *canvas = createView(SRCDIR "/data/inputMethodHints.qml"); + canvas->execute(); + canvas->show(); + canvas->setFocus(); + + QVERIFY(canvas->root() != 0); + QmlGraphicsTextEdit *textEditObject = qobject_cast(canvas->root()); + QVERIFY(textEditObject != 0); + QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText); + textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); + QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly); +} + void tst_qmlgraphicstextedit::cursorDelegate() { QmlView* view = createView(SRCDIR "/data/cursorTest.qml"); diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml b/tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml new file mode 100644 index 0000000..b404682 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +TextInput { + text: "Hello world!" + inputMethodHints: Qt.ImhNoPredictiveText +} diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp index 7896464..c8fe446 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp +++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp @@ -65,6 +65,7 @@ private slots: void maxLength(); void masks(); void validators(); + void inputMethodHints(); void cursorDelegate(); void navigation(); @@ -489,6 +490,21 @@ void tst_qmlgraphicstextinput::validators() QCOMPARE(strInput->hasAcceptableInput(), true); } +void tst_qmlgraphicstextinput::inputMethodHints() +{ + QmlView *canvas = createView(SRCDIR "/data/inputMethodHints.qml"); + canvas->execute(); + canvas->show(); + canvas->setFocus(); + + QVERIFY(canvas->root() != 0); + QmlGraphicsTextInput *textinputObject = qobject_cast(canvas->root()); + QVERIFY(textinputObject != 0); + QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText); + textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly); + QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly); +} + /* TextInput element should only handle left/right keys until the cursor reaches the extent of the text, then they should ignore the keys. -- cgit v0.12