From: Andrew den Exter Date: Fri, 22 Jun 2012 06:00:08 +0000 (+1000) Subject: Remove the open and closeSofwareInputPanel functions. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=3721de405e8556a25b66f7bc4bc946ba35b45292;p=konrad%2Fqtdeclarative.git Remove the open and closeSofwareInputPanel functions. Functionality is provided by the global Qt.application.inputMethod object. Task-number: QTBUG-21449 Change-Id: I75c082bcbe44c8834ccaf966a3f9a09ab91ec290 Reviewed-by: Martin Jones --- diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 058b816..5206785 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -1480,7 +1480,7 @@ void QQuickTextEdit::mousePressEvent(QMouseEvent *event) forceActiveFocus(); // re-open input panel on press if already focused if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) - openSoftwareInputPanel(); + qGuiApp->inputMethod()->show(); } if (!event->isAccepted()) QQuickImplicitSizeItem::mousePressEvent(event); @@ -2044,99 +2044,11 @@ void QQuickTextEditPrivate::updateDefaultTextOption() } } - - -/*! - \qmlmethod void QtQuick2::TextEdit::openSoftwareInputPanel() - - Opens software input panels like virtual keyboards for typing, useful for - customizing when you want the input keyboard to be shown and hidden in - your application. - - By default the opening of input panels follows the platform style. Input panels are - always closed if no editor has active focus. - - You can disable the automatic behavior by setting the property \c activeFocusOnPress to false - and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement - the behavior you want. - - Only relevant on platforms, which provide virtual keyboards. - - \code - import QtQuick 2.0 - TextEdit { - id: textEdit - text: "Hello world!" - activeFocusOnPress: false - MouseArea { - anchors.fill: parent - onClicked: { - if (!textEdit.activeFocus) { - textEdit.forceActiveFocus(); - textEdit.openSoftwareInputPanel(); - } else { - textEdit.focus = false; - } - } - onPressAndHold: textEdit.closeSoftwareInputPanel(); - } - } - \endcode -*/ -void QQuickTextEdit::openSoftwareInputPanel() -{ - if (qGuiApp) - qGuiApp->inputMethod()->show(); -} - -/*! - \qmlmethod void QtQuick2::TextEdit::closeSoftwareInputPanel() - - Closes a software input panel like a virtual keyboard shown on the screen, useful - for customizing when you want the input keyboard to be shown and hidden in - your application. - - By default the opening of input panels follows the platform style. Input panels are - always closed if no editor has active focus. - - You can disable the automatic behavior by setting the property \c activeFocusOnPress to false - and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement - the behavior you want. - - Only relevant on platforms, which provide virtual keyboards. - - \code - import QtQuick 2.0 - TextEdit { - id: textEdit - text: "Hello world!" - activeFocusOnPress: false - MouseArea { - anchors.fill: parent - onClicked: { - if (!textEdit.activeFocus) { - textEdit.forceActiveFocus(); - textEdit.openSoftwareInputPanel(); - } else { - textEdit.focus = false; - } - } - onPressAndHold: textEdit.closeSoftwareInputPanel(); - } - } - \endcode -*/ -void QQuickTextEdit::closeSoftwareInputPanel() -{ - if (qGuiApp) - qGuiApp->inputMethod()->hide(); -} - void QQuickTextEdit::focusInEvent(QFocusEvent *event) { Q_D(const QQuickTextEdit); if (d->focusOnPress && !isReadOnly()) - openSoftwareInputPanel(); + qGuiApp->inputMethod()->show(); QQuickImplicitSizeItem::focusInEvent(event); } diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h index 48954cc..b19873c 100644 --- a/src/quick/items/qquicktextedit_p.h +++ b/src/quick/items/qquicktextedit_p.h @@ -130,9 +130,6 @@ public: SelectWords }; - Q_INVOKABLE void openSoftwareInputPanel(); - Q_INVOKABLE void closeSoftwareInputPanel(); - QString text() const; void setText(const QString &); diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index a8d10f3..0d05d6f 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -1451,7 +1451,7 @@ void QQuickTextInput::mousePressEvent(QMouseEvent *event) forceActiveFocus(); // re-open input panel on press if already focused if (hasActiveFocus() && hadActiveFocus && !d->m_readOnly) - openSoftwareInputPanel(); + qGuiApp->inputMethod()->show(); } event->setAccepted(true); @@ -2372,97 +2372,11 @@ void QQuickTextInput::moveCursorSelection(int pos, SelectionMode mode) } } -/*! - \qmlmethod void QtQuick2::TextInput::openSoftwareInputPanel() - - Opens software input panels like virtual keyboards for typing, useful for - customizing when you want the input keyboard to be shown and hidden in - your application. - - By default the opening of input panels follows the platform style. Input panels are - always closed if no editor has active focus. - - You can disable the automatic behavior by setting the property \c activeFocusOnPress to false - and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement - the behavior you want. - - Only relevant on platforms, which provide virtual keyboards. - - \qml - import QtQuick 2.0 - TextInput { - id: textInput - text: "Hello world!" - activeFocusOnPress: false - MouseArea { - anchors.fill: parent - onClicked: { - if (!textInput.activeFocus) { - textInput.forceActiveFocus() - textInput.openSoftwareInputPanel(); - } else { - textInput.focus = false; - } - } - onPressAndHold: textInput.closeSoftwareInputPanel(); - } - } - \endqml -*/ -void QQuickTextInput::openSoftwareInputPanel() -{ - if (qGuiApp) - qGuiApp->inputMethod()->show(); -} - -/*! - \qmlmethod void QtQuick2::TextInput::closeSoftwareInputPanel() - - Closes a software input panel like a virtual keyboard shown on the screen, useful - for customizing when you want the input keyboard to be shown and hidden in - your application. - - By default the opening of input panels follows the platform style. Input panels are - always closed if no editor has active focus. - - You can disable the automatic behavior by setting the property \c activeFocusOnPress to false - and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement - the behavior you want. - - Only relevant on platforms, which provide virtual keyboards. - - \qml - import QtQuick 2.0 - TextInput { - id: textInput - text: "Hello world!" - activeFocusOnPress: false - MouseArea { - anchors.fill: parent - onClicked: { - if (!textInput.activeFocus) { - textInput.forceActiveFocus(); - textInput.openSoftwareInputPanel(); - } else { - textInput.focus = false; - } - } - onPressAndHold: textInput.closeSoftwareInputPanel(); - } - } - \endqml -*/ -void QQuickTextInput::closeSoftwareInputPanel() -{ - if (qGuiApp) - qGuiApp->inputMethod()->hide(); -} - void QQuickTextInput::focusInEvent(QFocusEvent *event) { Q_D(const QQuickTextInput); if (d->focusOnPress && !d->m_readOnly) - openSoftwareInputPanel(); + qGuiApp->inputMethod()->show(); QQuickImplicitSizeItem::focusInEvent(event); } diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h index a7b0789..fb21eb9 100644 --- a/src/quick/items/qquicktextinput_p.h +++ b/src/quick/items/qquicktextinput_p.h @@ -157,9 +157,6 @@ public: Q_INVOKABLE void moveCursorSelection(int pos); Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode); - Q_INVOKABLE void openSoftwareInputPanel(); - Q_INVOKABLE void closeSoftwareInputPanel(); - QString text() const; void setText(const QString &); diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 80d81cc..763c191 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2656,14 +2656,6 @@ void tst_qquicktextedit::openInputPanel() QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); QCOMPARE(qApp->inputMethod()->isVisible(), false); - // input panel should open when openSoftwareInputPanel is called - edit->openSoftwareInputPanel(); - QCOMPARE(qApp->inputMethod()->isVisible(), true); - - // input panel should close when closeSoftwareInputPanel is called - edit->closeSoftwareInputPanel(); - QCOMPARE(qApp->inputMethod()->isVisible(), false); - inputMethodPrivate->testContext = 0; } diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 1742335..5044f48 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -3216,14 +3216,6 @@ void tst_qquicktextinput::openInputPanel() QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); QCOMPARE(qApp->inputMethod()->isVisible(), false); - - // input panel should open when openSoftwareInputPanel is called - input->openSoftwareInputPanel(); - QCOMPARE(qApp->inputMethod()->isVisible(), true); - - // input panel should close when closeSoftwareInputPanel is called - input->closeSoftwareInputPanel(); - QCOMPARE(qApp->inputMethod()->isVisible(), false); } class MyTextInput : public QQuickTextInput