From b97367494f9e3b753de907e8fbf3d668a00d5f44 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 12 Oct 2011 11:21:29 +1000 Subject: Remove the InputContext module. The input context module provided a bridge between QML and a QInputContext which allowed an application to implement it's own input method in-process. However since QInputContext has been replaced and now only exists as a QWidget compatibility API this module no longer works with the QtQuick 2 items and porting it to the new QPlatformInputContext API does not seem to be an option as there is no way to override the instance provided by the platform integration. Change-Id: Ica602377436fcea42b9ffd05e1b347e2ee52acc8 Reviewed-by: Martin Jones --- .../inputmethods/inputmethods.qmlproject | 16 - .../declarative/inputmethods/spellcheck/Key.qml | 85 ----- .../inputmethods/spellcheck/Keyboard.qml | 141 ------- .../inputmethods/spellcheck/WordSuggestions.qml | 100 ----- .../inputmethods/spellcheck/spellcheck.qml | 137 ------- src/imports/imports.pro | 2 +- .../inputcontext/declarativeinputcontext.cpp | 199 ---------- src/imports/inputcontext/declarativeinputcontext.h | 104 ------ src/imports/inputcontext/inputcontext.pro | 38 -- src/imports/inputcontext/inputcontextfilter.cpp | 352 ------------------ src/imports/inputcontext/inputcontextfilter.h | 162 -------- src/imports/inputcontext/inputcontextmodule.cpp | 413 --------------------- src/imports/inputcontext/inputcontextmodule.h | 121 ------ src/imports/inputcontext/plugin.cpp | 79 ---- src/imports/inputcontext/qmldir | 1 - 15 files changed, 1 insertion(+), 1949 deletions(-) delete mode 100644 examples/declarative/inputmethods/inputmethods.qmlproject delete mode 100644 examples/declarative/inputmethods/spellcheck/Key.qml delete mode 100644 examples/declarative/inputmethods/spellcheck/Keyboard.qml delete mode 100644 examples/declarative/inputmethods/spellcheck/WordSuggestions.qml delete mode 100644 examples/declarative/inputmethods/spellcheck/spellcheck.qml delete mode 100644 src/imports/inputcontext/declarativeinputcontext.cpp delete mode 100644 src/imports/inputcontext/declarativeinputcontext.h delete mode 100755 src/imports/inputcontext/inputcontext.pro delete mode 100644 src/imports/inputcontext/inputcontextfilter.cpp delete mode 100644 src/imports/inputcontext/inputcontextfilter.h delete mode 100644 src/imports/inputcontext/inputcontextmodule.cpp delete mode 100644 src/imports/inputcontext/inputcontextmodule.h delete mode 100644 src/imports/inputcontext/plugin.cpp delete mode 100644 src/imports/inputcontext/qmldir diff --git a/examples/declarative/inputmethods/inputmethods.qmlproject b/examples/declarative/inputmethods/inputmethods.qmlproject deleted file mode 100644 index d4909f8685..0000000000 --- a/examples/declarative/inputmethods/inputmethods.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/inputmethods/spellcheck/Key.qml b/examples/declarative/inputmethods/spellcheck/Key.qml deleted file mode 100644 index c95a3f0b2c..0000000000 --- a/examples/declarative/inputmethods/spellcheck/Key.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - property string text - property string displayText - property alias font: keyText.font - property int key: 0 - - id: root - radius: 2 - - width: 28 - height: 28 - - gradient: Gradient { - GradientStop { position: 0.0; color: "darkgrey" } - GradientStop { position: 1.0; color: "grey" } - } - - Text { - id: keyText - - anchors.fill: parent - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - font.pixelSize: 18 - font.capitalization: keyboard.shift && displayText == "" ? Font.AllUppercase : Font.MixedCase - - text: root.displayText != "" ? root.displayText : root.text - - style: !mouseArea.pressed ? Text.Raised : Text.Normal - color: "white" - styleColor: "grey" - } - - MouseArea { - id: mouseArea - - anchors.fill: parent - onPressed: keyboard.keyPress(key, text) - onReleased: keyboard.keyRelease(key, text) - } -} diff --git a/examples/declarative/inputmethods/spellcheck/Keyboard.qml b/examples/declarative/inputmethods/spellcheck/Keyboard.qml deleted file mode 100644 index 533762e7ba..0000000000 --- a/examples/declarative/inputmethods/spellcheck/Keyboard.qml +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.labs.inputcontext 1.0 as InputContext - - -Rectangle { - id: keyboard - - radius: 5 - height: 122 - width: 324 - - property bool shift: false - - gradient: Gradient { - GradientStop { position: 0.0; color: "lightgrey" } - GradientStop { position: 1.0; color: "white" } - } - - Column { - anchors.left: parent.left; anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - - spacing: 2 - - Row { - spacing: 2 - anchors.horizontalCenter: parent.horizontalCenter - - Key { key: Qt.Key_Q; text: "q"; } - Key { key: Qt.Key_W; text: "w"; } - Key { key: Qt.Key_E; text: "e"; } - Key { key: Qt.Key_R; text: "r"; } - Key { key: Qt.Key_T; text: "t"; } - Key { key: Qt.Key_Y; text: "y"; } - Key { key: Qt.Key_U; text: "u"; } - Key { key: Qt.Key_I; text: "i"; } - Key { key: Qt.Key_O; text: "o"; } - Key { key: Qt.Key_P; text: "p"; } - } - Row { - spacing: 2 - anchors.horizontalCenter: parent.horizontalCenter - - Key { key: Qt.Key_A; text: "a"; } - Key { key: Qt.Key_S; text: "s"; } - Key { key: Qt.Key_D; text: "d"; } - Key { key: Qt.Key_F; text: "f"; } - Key { key: Qt.Key_G; text: "g"; } - Key { key: Qt.Key_H; text: "h"; } - Key { key: Qt.Key_J; text: "j"; } - Key { key: Qt.Key_K; text: "k"; } - Key { key: Qt.Key_L; text: "l"; } - } - Row { - spacing: 2 - anchors.horizontalCenter: parent.horizontalCenter - - Key { key: Qt.Key_Shift; displayText: "shift"; width: 50 } - Key { key: Qt.Key_Z; text: "z"; } - Key { key: Qt.Key_X; text: "x"; } - Key { key: Qt.Key_C; text: "c"; } - Key { key: Qt.Key_V; text: "v"; } - Key { key: Qt.Key_B; text: "b"; } - Key { key: Qt.Key_N; text: "n"; } - Key { key: Qt.Key_M; text: "m"; } - Key { key: Qt.Key_Comma; text: ","; } - Key { key: Qt.Key_Period; text: "."; } - } - - Row { - spacing: 2 - anchors.horizontalCenter: parent.horizontalCenter - - Key { key: Qt.Key_Enter; text: "\n"; displayText: "enter"; width: 90 } - Key { key: Qt.Key_Space; text: " "; displayText: "space"; width: 138} - Key { key: Qt.Key_Backspace; displayText: "backspace"; width: 90 } - } - } - - function keyPress(key, text) - { - if (key == Qt.Key_Shift) - keyboard.shift = !keyboard.shift - else if (keyboard.shift) - InputContext.sendKeyPress(key, text.toUpperCase(), Qt.ShiftModifier) - else - InputContext.sendKeyPress(key, text) - } - - function keyRelease(key, text) - { - if (key != Qt.Key_Shift) { - if (keyboard.shift) { - InputContext.sendKeyRelease(key, text.toUpperCase(), Qt.ShiftModifier) - keyboard.shift = false - } else { - InputContext.sendKeyRelease(key, text) - } - } - } -} diff --git a/examples/declarative/inputmethods/spellcheck/WordSuggestions.qml b/examples/declarative/inputmethods/spellcheck/WordSuggestions.qml deleted file mode 100644 index 5c4e9cb4a2..0000000000 --- a/examples/declarative/inputmethods/spellcheck/WordSuggestions.qml +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.labs.inputcontext 1.0 as InputContext - -ListView { - property int globalX: InputContext.microFocus.x + ((InputContext.microFocus.width - width) / 2) - property int globalY: InputContext.microFocus.y + InputContext.microFocus.height - - x: parent.mapToItem(null, globalX, globalY).x - y: parent.mapToItem(null, globalX, globalY).y - - visible: suggestionModel.count > 0 - - width: 200 - height: 70 - - InputContext.KeyFilter { - onPressed: event.accepted = filterKeyPress(event.key, event.text) - } - - InputContext.MouseHandler { - onPressed: { - if (cursor < 0 || cursor >= InputContext.preeditText.length) - InputContext.commit() - } - } - - model: XmlListModel { - id: suggestionModel - - query: "/query/results/s:suggestion" - namespaceDeclarations: "declare namespace s=\"http://www.inktomi.com/\";" - source: InputContext.preeditText.length > 4 ? "http://query.yahooapis.com/v1/public/yql?q=select * from search.spelling where query=\"" + InputContext.preeditText + "\"" : "" - - XmlRole { name: "suggestion"; query: "string()" } - } - - delegate: Rectangle { - radius: 2 - color: "lightsteelblue" - - anchors.horizontalCenter: parent.horizontalCenter - - width: suggestionText.implicitWidth + 2 - height: suggestionText.implicitHeight + 2 - - Text { - id: suggestionText - - font: InputContext.font - text: suggestion - - anchors.fill: parent - anchors.margins: 1 - } - MouseArea { - anchors.fill: parent - onClicked: InputContext.commit(suggestion) - } - } -} diff --git a/examples/declarative/inputmethods/spellcheck/spellcheck.qml b/examples/declarative/inputmethods/spellcheck/spellcheck.qml deleted file mode 100644 index 57e81451a6..0000000000 --- a/examples/declarative/inputmethods/spellcheck/spellcheck.qml +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.labs.inputcontext 1.0 as InputContext - -Item { - width: 360 - height: 240 - - function filterKeyPress(key, text) - { - switch (key) { - case Qt.Key_Enter: - case Qt.Key_Return: - case Qt.Key_Space: - case Qt.Key_Tab: - if (InputContext.preeditText != "") - InputContext.commit(); - break; - case Qt.Key_Backspace: - if (InputContext.preeditText != "") { - InputContext.preeditText = InputContext.preeditText.substr(0, InputContext.preeditText.length - 1); - return true; - } - break; - default: - if (text != "") { - InputContext.preeditText += text - return true; - } else if (InputContext.preeditText != "") { - InputContext.commit(); - } - break; - } - return false; - } - - Rectangle { - anchors.left: parent.left; anchors.top: parent.top; anchors.right: parent.right; - anchors.bottom: keyboard.top - anchors.margins: 2 - - border.width: 1 - radius: 2 - - TextEdit { - id: textEdit - - wrapMode: TextEdit.WordWrap - - anchors.fill: parent - anchors.margins: 2 - } - - MouseArea { - anchors.fill: textEdit - - onPressed: { - mouse.accepted = false - var position = textEdit.positionAt(mouse.x, mouse.y); - if (position != textEdit.cursorPosition) { - InputContext.commit() - textEdit.cursorPosition = textEdit.positionAt(mouse.x, mouse.y) - textEdit.selectWord() - var word = textEdit.selectedText - if (word != "") { - InputContext.commit(""); - InputContext.preeditText = word; - } - } - } - } - } - - WordSuggestions {} - - Keyboard { - id: keyboard - anchors.horizontalCenter: parent.horizontalCenter - - y: parent.height - - states: [ - State { - name: "visible" - PropertyChanges { target: keyboard; y: parent.height - height } - when: InputContext.softwareInputPanelVisible - }, - State { - name: "hidden" - PropertyChanges { target: keyboard; y: parent.height } - when: !InputContext.softwareInputPanelVisible - } - ] - transitions: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.InOutQuad; duration: 100 } - } - } -} diff --git a/src/imports/imports.pro b/src/imports/imports.pro index c60e72db08..9c66082ba9 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += qtquick1 qt47 folderlistmodel particles gestures inputcontext etcprovider +SUBDIRS += qtquick1 qt47 folderlistmodel particles gestures etcprovider contains(QT_CONFIG, qmltest): SUBDIRS += testlib diff --git a/src/imports/inputcontext/declarativeinputcontext.cpp b/src/imports/inputcontext/declarativeinputcontext.cpp deleted file mode 100644 index 9eb01c66cd..0000000000 --- a/src/imports/inputcontext/declarativeinputcontext.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "declarativeinputcontext.h" - -#include "inputcontextmodule.h" -#include "inputcontextfilter.h" - -#include - -QT_BEGIN_NAMESPACE - -DeclarativeInputContext::DeclarativeInputContext(QObject *parent) - : QInputContext(parent) - , m_module(0) -{ -} - -DeclarativeInputContext::~DeclarativeInputContext() -{ -} - -bool DeclarativeInputContext::isComposing() const -{ - return m_module && !m_module->preeditText().isEmpty(); -} - -QString DeclarativeInputContext::identifierName() -{ - return QLatin1String("Qt.labs.inputcontext/1.0"); -} - -QString DeclarativeInputContext::language() -{ - return QString(); -} - -void DeclarativeInputContext::setFocusWidget(QWidget *widget) -{ - QInputContext::setFocusWidget(widget); - - if (m_module) - m_module->setFocusWidget(widget); -} - -void DeclarativeInputContext::mouseHandler(int x, QMouseEvent *event) -{ - if (!m_mouseHandlers.isEmpty()) { - InputContextMouseEvent me(*event); - foreach (InputContextMouseHandler *handler, m_mouseHandlers) { - handler->processEvent(event->type(), x, &me); - if (me.isAccepted()) { - event->setAccepted(true); - return; - } - } - } -} - -bool DeclarativeInputContext::filterMouseEvent(const QMouseEvent *event) -{ - if (!m_mouseFilters.isEmpty()) { - InputContextMouseEvent me(*event); - foreach (InputContextMouseFilter *filter, m_mouseFilters) { - filter->processEvent(event->type(), &me); - if (me.isAccepted()) - return true; - } - } - - return false; -} - -bool DeclarativeInputContext::filterKeyEvent(const QKeyEvent *event) -{ - if (!m_keyFilters.isEmpty()) { - InputContextKeyEvent ke(*event); - foreach (InputContextKeyFilter *filter, m_keyFilters) { - filter->processEvent(event->type(), &ke); - if (ke.isAccepted()) - return true; - } - } - return false; -} - -bool DeclarativeInputContext::filterEvent(const QEvent *event) -{ - switch (event->type()) { - case QEvent::RequestSoftwareInputPanel: - if (m_module) - m_module->setVisible(true); - return true; - case QEvent::CloseSoftwareInputPanel: - if (m_module) - m_module->setVisible(false); - return true; - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseButtonDblClick: - case QEvent::MouseMove: - return filterMouseEvent(static_cast(event)); - case QEvent::KeyPress: - case QEvent::KeyRelease: - return filterKeyEvent(static_cast(event)); - default: - return false; - } -} - -void DeclarativeInputContext::reset() -{ - if (m_module) - m_module->commit(); -} - -void DeclarativeInputContext::update() -{ - if (m_module) - m_module->update(); -} - -void DeclarativeInputContext::setModule(InputContextModule *module) -{ - m_module = module; -} - -void DeclarativeInputContext::registerMouseHandler(InputContextMouseHandler *handler) -{ - connect(handler, SIGNAL(destroyed(QObject*)), this, SLOT(mouseHandlerDestroyed(QObject*))); - m_mouseHandlers.append(handler); -} - -void DeclarativeInputContext::registerMouseFilter(InputContextMouseFilter *filter) -{ - connect(filter, SIGNAL(destroyed(QObject*)), this, SLOT(mouseFilterDestroyed(QObject*))); - m_mouseFilters.append(filter); -} - -void DeclarativeInputContext::registerKeyFilter(InputContextKeyFilter *filter) -{ - connect(filter, SIGNAL(destroyed(QObject*)), this, SLOT(keyFilterDestroyed(QObject*))); - m_keyFilters.append(filter); -} - -void DeclarativeInputContext::mouseHandlerDestroyed(QObject *handler) -{ - m_mouseHandlers.removeAll(static_cast(handler)); -} - -void DeclarativeInputContext::mouseFilterDestroyed(QObject *filter) -{ - m_mouseFilters.removeAll(static_cast(filter)); -} - -void DeclarativeInputContext::keyFilterDestroyed(QObject *filter) -{ - m_keyFilters.removeAll(static_cast(filter)); -} - -QT_END_NAMESPACE diff --git a/src/imports/inputcontext/declarativeinputcontext.h b/src/imports/inputcontext/declarativeinputcontext.h deleted file mode 100644 index 9e6e65fd6e..0000000000 --- a/src/imports/inputcontext/declarativeinputcontext.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DECLARATIVEINPUTCONTEXT_H -#define DECLARATIVEINPUTCONTEXT_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class InputContextKeyFilter; -class InputContextModule; -class InputContextMouseFilter; -class InputContextMouseHandler; - -class DeclarativeInputContext : public QInputContext -{ - Q_OBJECT -public: - explicit DeclarativeInputContext(QObject *parent = 0); - ~DeclarativeInputContext(); - - bool isComposing() const; - - QString identifierName(); - QString language(); - - void setFocusWidget(QWidget *widget); - - void mouseHandler(int x, QMouseEvent *event); - - bool filterMouseEvent(const QMouseEvent *event); - bool filterKeyEvent(const QKeyEvent *event); - - bool filterEvent(const QEvent *event); - - void reset(); - void update(); - - void setModule(InputContextModule *module); - - void registerMouseHandler(InputContextMouseHandler *handler); - void registerMouseFilter(InputContextMouseFilter *filter); - void registerKeyFilter(InputContextKeyFilter *filter); - -private slots: - void mouseHandlerDestroyed(QObject *handler); - void mouseFilterDestroyed(QObject *filter); - void keyFilterDestroyed(QObject *filter); - -private: - InputContextModule *m_module; - QList m_mouseHandlers; - QList m_mouseFilters; - QList m_keyFilters; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/imports/inputcontext/inputcontext.pro b/src/imports/inputcontext/inputcontext.pro deleted file mode 100755 index c8641d20e3..0000000000 --- a/src/imports/inputcontext/inputcontext.pro +++ /dev/null @@ -1,38 +0,0 @@ -TARGET = qmlinputcontextplugin -TARGETPATH = Qt/labs/inputcontext -include(../qimportbase.pri) - -QT += declarative widgets - -SOURCES += \ - declarativeinputcontext.cpp \ - inputcontextfilter.cpp \ - inputcontextmodule.cpp \ - plugin.cpp - -HEADERS += \ - declarativeinputcontext.h \ - inputcontextfilter.h \ - inputcontextmodule.h - -OTHER_FILES = \ - qmldir - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -symbian:{ - TARGET.UID3 = 0x20031E91 - - isEmpty(DESTDIR):importFiles.files = qmlinputcontextplugin{QT_LIBINFIX}.dll qmldir - else:importFiles.files = $$DESTDIR/qmlinputcontextplugin$${QT_LIBINFIX}.dll qmldir - importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH - - DEPLOYMENT = importFiles -} - -INSTALLS += target qmldir - diff --git a/src/imports/inputcontext/inputcontextfilter.cpp b/src/imports/inputcontext/inputcontextfilter.cpp deleted file mode 100644 index be89841b85..0000000000 --- a/src/imports/inputcontext/inputcontextfilter.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "inputcontextfilter.h" - -#include "declarativeinputcontext.h" - -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass KeyEvent InputContextKeyEvent - - \inqmlmodule Qt.labs.inputcontext - - \brief The KeyEvent object provides information about a key event. -*/ - -/*! - \qmlproperty int KeyEvent::key - - This property holds the key code of the key that was pressed or released. -*/ - -/*! - \qmlproperty string KeyEvent::text - - This property holds the text that this key generated. -*/ - -/*! - \qmlproperty int KeyEvent::modifiers - - This property holds the keyboard modifier flags that existed immediately - after this event was generated. -*/ - -/*! - \qmlproperty bool KeyEvent::autoRepeat - - This property returns true if this event comes from an auto repeating key - press, on the initial key press this returns false. -*/ - -/*! - \qmlproperty int KeyEvent::count - - This property holds the number of keys involved in this event. If the - \l text is non-empty this is the length of the string. -*/ - -/*! - \qmlproperty bool KeyEvent::accepted - - This property holds whether the event was accepted. - - This is false by default. -*/ - -/*! - \qmlclass MouseEvent InputContextMouseEvent - - \inqmlmodule Qt.labs.inputcontext - - \brief The MouseEvent object provides information about a mouse event. - -*/ - -/*! - \qmlproperty int MouseEvent::x - - This property holds the x position in scene coordinates of the mouse cursor - at the time of the event. -*/ - -/*! - \qmlproperty int MouseEvent::y - - This property holds the y position in scene coordinates of the mouse cursor - at the time of the event. -*/ - -/*! - \qmlproperty enum MouseEvent::button - - This property holds the button that caused the event. -*/ - -/*! - \qmlproperty int MouseEvent::buttons - - This property holds the button state when the event was generated. -*/ - -/*! - \qmlproperty int MouseEvent::modifiers - - This property holds the keyboard modifier flags that existed when the event - was generated. -*/ - -/*! - \qmlproperty bool MouseEvent::accepted - - This property holds whether the event was accepted. - - This is false by default. -*/ - -/*! - \qmlclass MouseHandler InputContextMouseHandler - - \inqmlmodule Qt.labs.inputcontext - - \brief The MouseHandler item provides mouse event handling for input methods. - - The MouseHandler item can be used to handle mouse press, release, move and - double click events within or surrounding the pre-edit text. -*/ - -/*! - \qmlsignal MouseHandler::onPressed(int cursor, MouseEvent mouse) - - This handler is called when there is a press. The \a cursor parameter is - the text cursor position of the press within the pre-edit text, and the - \a mouse parameter holds information about the press. -*/ - -/*! - \qmlsignal MouseHandler::onReleased(int cursor, MouseEvent mouse) - - This handler is called when there is a release. The \a cursor parameter is - the text cursor position of the press within the pre-edit text, and the - \a mouse parameter holds information about the release. -*/ - -/*! - \qmlsignal MouseHandler::onPositionChanged(int cursor, MouseEvent mouse) - - This handler is called when the mouse position changes. - - The \a cursor parameter is the text cursor position of the press within - the pre-edit text, and the \a mouse parameter holds information about the - position change. -*/ - -/*! - \qmlsignal MouseHandler::onDoubleClicked(int cursor, MouseEvent mouse) - - This handler is called when there is a double-click. The \a cursor - parameter is the text cursor position of the press within the pre-edit - text, and the \a mouse parameter holds information about the double-click. -*/ - -InputContextMouseHandler::InputContextMouseHandler(QObject *parent) - : QObject(parent) -{ - if (DeclarativeInputContext *context = qobject_cast( - qApp->inputContext())) { - context->registerMouseHandler(this); - } -} - -void InputContextMouseHandler::processEvent(QEvent::Type type, int cursor, InputContextMouseEvent *event) -{ - switch (type) { - case QEvent::MouseButtonPress: - emit pressed(cursor, event); - break; - case QEvent::MouseButtonRelease: - emit released(cursor, event); - break; - case QEvent::MouseButtonDblClick: - emit doubleClicked(cursor, event); - break; - case QEvent::MouseMove: - emit positionChanged(cursor, event); - break; - default: - break; - } -} - -/*! - \qmlclass MouseFilter InputContextMouseFilter - - \inqmlmodule Qt.labs.inputcontext - - \brief The MouseFilter item provides mouse event filtering for input methods. - - The MouseFilter item can be used to filter mouse press, release, move and - double click events received by the item with active focus. -*/ - -/*! - \qmlsignal MouseHandler::onPressed(MouseEvent mouse) - - This handler is called when there is a press. The \a mouse parameter holds - information about the press. - - If the event is accepted it will not be delivered to the item. -*/ - -/*! - \qmlsignal MouseHandler::onReleased(MouseEvent mouse) - - This handler is called when there is a release. The \a mouse parameter - holds information about the release. - - If the event is accepted it will not be delivered to the item. -*/ - -/*! - \qmlsignal MouseHandler::onPositionChanged(MouseEvent mouse) - - This handler is called when the mouse position changes. - - The \a mouse parameter holds information about the position change. - - If the event is accepted it will not be delivered to the item. -*/ - -/*! - \qmlsignal MouseHandler::onDoubleClicked(MouseEvent mouse) - - This handler is called when there is a double-click. The \a mouse - parameter holds information about the double-click. - - If the event is accepted it will not be delivered to the item. -*/ - -InputContextMouseFilter::InputContextMouseFilter(QObject *parent) - : QObject(parent) -{ - if (DeclarativeInputContext *context = qobject_cast( - qApp->inputContext())) { - context->registerMouseFilter(this); - } -} - -void InputContextMouseFilter::processEvent(QEvent::Type type, InputContextMouseEvent *event) -{ - switch (type) { - case QEvent::MouseButtonPress: - emit pressed(event); - break; - case QEvent::MouseButtonRelease: - emit released(event); - break; - case QEvent::MouseButtonDblClick: - emit doubleClicked(event); - break; - case QEvent::MouseMove: - emit positionChanged(event); - break; - default: - break; - } -} - -/*! - \qmlclass KeyFilter InputContextKeyFilter - - \inqmlmodule Qt.labs.inputcontext - - \brief The KeyFilter item provides key event filtering for input methods. - - The KeyFilter item can be used to filter key press and releae events - received by the item with active focus. -*/ - -/*! - \qmlsignal KeyFilter::onPressed(KeyEvent event) - - This handler is called when there is a key press. The \a event parameter - holds information about the press. - - If the event is accepted it will not be delivered to the item. -*/ - -/*! - \qmlsignal KeyFilter::onReleased(KeyEvent event) - - This handler is called when there is a key release. The \a event parameter - holds information about the release. - - If the event is accepted it will not be delivered to the item. -*/ - -InputContextKeyFilter::InputContextKeyFilter(QObject *parent) - : QObject(parent) -{ - if (DeclarativeInputContext *context = qobject_cast( - qApp->inputContext())) { - context->registerKeyFilter(this); - } -} - -void InputContextKeyFilter::processEvent(QEvent::Type type, InputContextKeyEvent *event) -{ - switch (type) { - case QEvent::KeyPress: - emit pressed(event); - break; - case QEvent::KeyRelease: - emit released(event); - break; - default: - break; - } -} - -QT_END_NAMESPACE diff --git a/src/imports/inputcontext/inputcontextfilter.h b/src/imports/inputcontext/inputcontextfilter.h deleted file mode 100644 index f0eefd90c1..0000000000 --- a/src/imports/inputcontext/inputcontextfilter.h +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INPUTCONTEXTFILTER_H -#define INPUTCONTEXTFILTER_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class InputContextKeyEvent : public QObject -{ - Q_OBJECT - Q_PROPERTY(int key READ key) - Q_PROPERTY(QString text READ text) - Q_PROPERTY(int modifiers READ modifiers) - Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat) - Q_PROPERTY(int count READ count) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) - -public: - InputContextKeyEvent(const QKeyEvent &ke) - : event(ke) { event.setAccepted(false); } - - int key() const { return event.key(); } - QString text() const { return event.text(); } - int modifiers() const { return event.modifiers(); } - bool isAutoRepeat() const { return event.isAutoRepeat(); } - int count() const { return event.count(); } - - bool isAccepted() { return event.isAccepted(); } - void setAccepted(bool accepted) { event.setAccepted(accepted); } - -private: - QKeyEvent event; -}; - -class InputContextMouseEvent : public QObject -{ - Q_OBJECT - Q_PROPERTY(int x READ x) - Q_PROPERTY(int y READ y) - Q_PROPERTY(int button READ button) - Q_PROPERTY(int buttons READ buttons) - Q_PROPERTY(int modifiers READ modifiers) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) - -public: - InputContextMouseEvent(const QMouseEvent &me) - : event(me) { event.setAccepted(false);} - - int x() const { return event.x(); } - int y() const { return event.y(); } - int button() const { return event.button(); } - int buttons() const { return event.buttons(); } - int modifiers() const { return event.modifiers(); } - - bool isAccepted() { return event.isAccepted(); } - void setAccepted(bool accepted) { event.setAccepted(accepted); } - -private: - QMouseEvent event; -}; - -class InputContextMouseHandler : public QObject -{ - Q_OBJECT -public: - InputContextMouseHandler(QObject *parent = 0); - - void processEvent(QEvent::Type type, int cursor, InputContextMouseEvent *event); - -signals: - void pressed(int cursor, InputContextMouseEvent *mouse); - void released(int cursor, InputContextMouseEvent *mouse); - void doubleClicked(int cursor, InputContextMouseEvent *mouse); - void positionChanged(int cursor, InputContextMouseEvent *mouse); -}; - -class InputContextMouseFilter : public QObject -{ - Q_OBJECT -public: - InputContextMouseFilter(QObject *parent = 0); - - void processEvent(QEvent::Type type, InputContextMouseEvent *event); - -signals: - void pressed(InputContextMouseEvent *mouse); - void released(InputContextMouseEvent *mouse); - void doubleClicked(InputContextMouseEvent *mouse); - void positionChanged(InputContextMouseEvent *mouse); -}; - -class InputContextKeyFilter : public QObject -{ - Q_OBJECT -public: - InputContextKeyFilter(QObject *parent = 0); - - void processEvent(QEvent::Type type, InputContextKeyEvent *event); - -signals: - void pressed(InputContextKeyEvent *event); - void released(InputContextKeyEvent *event); -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(InputContextKeyEvent) -QML_DECLARE_TYPE(InputContextMouseEvent) -QML_DECLARE_TYPE(InputContextMouseHandler) -QML_DECLARE_TYPE(InputContextMouseFilter) -QML_DECLARE_TYPE(InputContextKeyFilter) - -QT_END_HEADER - -#endif diff --git a/src/imports/inputcontext/inputcontextmodule.cpp b/src/imports/inputcontext/inputcontextmodule.cpp deleted file mode 100644 index 578fb98733..0000000000 --- a/src/imports/inputcontext/inputcontextmodule.cpp +++ /dev/null @@ -1,413 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "inputcontextmodule.h" - -#include "declarativeinputcontext.h" - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmlmodule Qt.labs.inputcontext InputContextModule - - \brief The Qt.labs.inputcontext module provides an API for implementing input methods is QML. -*/ - -InputContextModule::InputContextModule(QObject *parent) - : QObject(parent) - , m_inputContext(qobject_cast(qApp->inputContext())) - , m_focusWidget(m_inputContext ? m_inputContext->focusWidget() : 0) - , m_visible(false) -{ - if (m_inputContext) - m_inputContext->setModule(this); -} - -InputContextModule::~InputContextModule() -{ - if (m_inputContext) - m_inputContext->setModule(0); -} - -/*! - \qmlproperty bool focus - - \inqmlmodule Qt.labs.inputcontext - - This property identifies whether an item that takes text input has active focus. -*/ - -bool InputContextModule::hasFocus() const -{ - return m_focusWidget != 0; -} - -void InputContextModule::setFocusWidget(QWidget *widget) -{ - m_focusWidget = widget; - - if (!m_focusWidget) - setVisible(false); - - emit focusChanged(); -} - -/*! - \qmlproperty bool softwareInputPanelVisible - - \inqmlmodule Qt.labs.inputcontext - - This property identifies whether the item with focus has requested a - software input panel. -*/ - -bool InputContextModule::isVisible() const -{ - return m_visible; -} - -void InputContextModule::setVisible(bool visible) -{ - if (m_visible != visible) { - m_visible = visible; - - emit visibleChanged(); - } -} - -/*! - \qmlproperty string preeditText - - \inqmlmodule Qt.labs.inputcontext - - This property holds the uncommited text that is displayed in the item that - has focus. -*/ - -QString InputContextModule::preeditText() const -{ - return m_preeditText; -} - -void InputContextModule::setPreeditText(const QString &text) -{ - if (text != m_preeditText) - sendPreedit(text); -} - -/*! - \qmlproperty rectangle microFocus - - \inqmlmodule Qt.labs.inputcontext - - This property holds a rectangle in scene coordinates around the position - of the cursor. -*/ - -QRect InputContextModule::microFocus() const -{ - return m_focusWidget - ? m_focusWidget->inputMethodQuery(Qt::ImMicroFocus).toRect() - : QRect(); -} - -/*! - \qmlproperty font font - - \inqmlmodule Qt.labs.inputcontext - - This property holds the font of the text that currently has focus. -*/ - -QFont InputContextModule::font() const -{ - return m_focusWidget - ? m_focusWidget->inputMethodQuery(Qt::ImFont).value() - : QFont(); -} - -/*! - \qmlproperty int cursorPosition - - \inqmlmodule Qt.labs.inputcontext - - This property holds the position of the text cursor in the - \l surroundingText. -*/ - -int InputContextModule::cursorPosition() const -{ - return m_focusWidget - ? m_focusWidget->inputMethodQuery(Qt::ImCursorPosition).toInt() - : 0; -} - -/*! - \qmlproperty int anchorPosition - - \inqmlmodule Qt.labs.inputcontext - - This property holds the position of the selection anchor in the - \l surroundingText. If no text is selected this is the same as the - \l cursorPosition. -*/ - -int InputContextModule::anchorPosition() const -{ - return m_focusWidget - ? m_focusWidget->inputMethodQuery(Qt::ImAnchorPosition).toInt() - : 0; -} - -/*! - \qmlproperty int maximumTextLength - - \inqmlmodule Qt.labs.inputcontext - - This property holds the maximum number of characters that the item with - focus can hold. If there is no limit -1 is returned. -*/ - -int InputContextModule::maximumTextLength() const -{ - QVariant length; - if (m_focusWidget) - length = m_focusWidget->inputMethodQuery(Qt::ImMaximumTextLength); - return length.isValid() ? length.toInt() : -1; -} - -/*! - \qmlproperty string surroundingText - - \inqmlmodule Qt.labs.inputcontext - - This property holds the plain text around the input area. For example the - current paragraph. -*/ - -QString InputContextModule::surroundingText() const -{ - return m_focusWidget - ? m_focusWidget->inputMethodQuery(Qt::ImSurroundingText).toString() - : QString(); -} - -/*! - \qmlproperty string selectedText - - \inqmlmodule Qt.labs.inputcontext - - This property holds the currently selected text. -*/ - -QString InputContextModule::selectedText() const -{ - return m_focusWidget - ? m_focusWidget->inputMethodQuery(Qt::ImCurrentSelection).toString() - : QString(); -} - -/*! - \qmlmethod sendKeyPress(int key, string text, int modifiers, bool autoRepeat) - - \inqmlmodule Qt.labs.inputcontext - - This method sends a key press event to the item that currently has focus. - - Int key is the code for the Qt::Key that the event loop should listen for. - If key is 0, the event is not a result of a known key; for example, it may - be the result of a compose sequence or keyboard macro. The modifiers holds - the keyboard modifiers, and the given text is the Unicode text that the key - generated. If autorep is true, isAutoRepeat() will be true. count is the - number of keys involved in the event. -*/ -void InputContextModule::sendKeyPress( - int key, const QString &text, int modifiers, bool autoRepeat, int count) -{ - if (m_focusWidget) { - QKeyEvent event( - QEvent::KeyPress, key, Qt::KeyboardModifiers(modifiers), text, autoRepeat, count); - if (!m_inputContext || !m_inputContext->filterKeyEvent(&event)) - QApplication::sendEvent(m_focusWidget, &event); - } -} - -/*! - \qmlmethod sendKeyRelease(int key, string text, int modifiers) - - \inqmlmodule Qt.labs.inputcontext - - This method sends a key release event to the item that currently has focus. - - Int key is the code for the Qt::Key that the event loop should listen for. - If key is 0, the event is not a result of a known key; for example, it may - be the result of a compose sequence or keyboard macro. The modifiers holds - the keyboard modifiers, and the given text is the Unicode text that the key - generated. count is the number of keys involved in the event. -*/ -void InputContextModule::sendKeyRelease(int key, const QString &text, int modifiers, int count) -{ - if (m_focusWidget) { - QKeyEvent event( - QEvent::KeyRelease, key, Qt::KeyboardModifiers(modifiers), text, false, count); - if (!m_inputContext || !m_inputContext->filterKeyEvent(&event)) - QApplication::sendEvent(m_focusWidget, &event); - } -} - -/*! - \qmlmethod sendPreedit(string text, int cursor = -1) - - \inqmlmodule Qt.labs.inputcontext - - Sends a pre-edit event to the item with active focus. - - This will set \l preeditText to \a text, and position the text \a cursor - within the pre-edit text. If the value of cursor is -1 the cursor will be - positioned at the end of the pre-edit text. -*/ -void InputContextModule::sendPreedit(const QString &text, int cursor) -{ - const QString preedit = m_preeditText; - m_preeditText = text; - - if (m_inputContext) { - QList attributes; - - if (cursor >= 0 && cursor <= text.length()) { - attributes.append(QInputMethodEvent::Attribute( - QInputMethodEvent::Cursor, cursor, text.length(), QVariant())); - } else { - cursor = text.length(); - } - - if (cursor > 0) { - attributes.append(QInputMethodEvent::Attribute( - QInputMethodEvent::TextFormat, - 0, - cursor, - m_inputContext->standardFormat(QInputContext::PreeditFormat))); - } - if (cursor < text.length()) { - attributes.append(QInputMethodEvent::Attribute( - QInputMethodEvent::TextFormat, - cursor, - text.length(), - m_inputContext->standardFormat(QInputContext::SelectionFormat))); - } - - m_inputContext->sendEvent(QInputMethodEvent(text, attributes)); - } - - if (m_preeditText != preedit) - emit preeditTextChanged(); -} - - -/*! - \qmlmethod commit() - - \inqmlmodule Qt.labs.inputcontext - - Commits \l preeditText to the item with active focus. -*/ -void InputContextModule::commit() -{ - // Create an explicit copy of m_preeditText as the reference value is cleared before sending - // the event. - commit(QString(m_preeditText)); -} - -/*! - \qmlmethod commit(string) - - \inqmlmodule Qt.labs.inputcontext - - Commits \a text to the item with active focus and clears the current - \l preeditText. The text will be inserted into the \l surroundingText at a - position \a replacementStart relative to the \l cursorPosition and will - replace \a replacementLength characters. -*/ -void InputContextModule::commit(const QString &text, int replacementStart, int replacementLength) -{ - const QString preedit = m_preeditText; - m_preeditText.clear(); - - if (m_inputContext) { - QInputMethodEvent inputEvent; - inputEvent.setCommitString(text, replacementStart, replacementLength); - m_inputContext->sendEvent(inputEvent); - } - - if (m_preeditText != preedit) - emit preeditTextChanged(); -} - -/*! - \qmlmethod clear() - - \inqmlmodule Qt.labs.inputcontext - - Clears the current \l preeditText. -*/ -void InputContextModule::clear() -{ - const QString preedit = m_preeditText; - m_preeditText.clear(); - - if (m_inputContext) - m_inputContext->sendEvent(QInputMethodEvent()); - - if (m_preeditText != preedit) - emit preeditTextChanged(); -} - -void InputContextModule::update() -{ - emit contextUpdated(); -} - -QT_END_NAMESPACE diff --git a/src/imports/inputcontext/inputcontextmodule.h b/src/imports/inputcontext/inputcontextmodule.h deleted file mode 100644 index 079890ba9a..0000000000 --- a/src/imports/inputcontext/inputcontextmodule.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INPUTCONTEXTMODULE_H -#define INPUTCONTEXTMODULE_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class DeclarativeInputContext; - -class InputContextModule : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool softwareInputPanelVisible READ isVisible WRITE setVisible NOTIFY visibleChanged) - Q_PROPERTY(bool focus READ hasFocus NOTIFY focusChanged) - Q_PROPERTY(QString preeditText READ preeditText WRITE setPreeditText NOTIFY preeditTextChanged) - Q_PROPERTY(QRect microFocus READ microFocus NOTIFY contextUpdated) - Q_PROPERTY(QFont font READ font NOTIFY contextUpdated) - Q_PROPERTY(int cursorPosition READ cursorPosition NOTIFY contextUpdated) - Q_PROPERTY(int anchorPosition READ anchorPosition NOTIFY contextUpdated) - Q_PROPERTY(int maximumTextLength READ maximumTextLength NOTIFY contextUpdated) - Q_PROPERTY(QString surroundingText READ surroundingText NOTIFY contextUpdated) - Q_PROPERTY(QString selectedText READ selectedText NOTIFY contextUpdated) -public: - explicit InputContextModule(QObject *parent = 0); - ~InputContextModule(); - - bool hasFocus() const; - void setFocusWidget(QWidget *widget); - - bool isVisible() const; - void setVisible(bool visible); - - QString preeditText() const; - void setPreeditText(const QString &text); - - QRect microFocus() const; - QFont font() const; - int cursorPosition() const; - int anchorPosition() const; - int maximumTextLength() const; - QString surroundingText() const; - QString selectedText() const; - - Q_INVOKABLE void sendKeyPress( - int key, const QString &text, int modifiers = 0, bool autoRepeat = false, int count = 1); - Q_INVOKABLE void sendKeyRelease(int key, const QString &text, int modifiers = 0, int count = 1); - - Q_INVOKABLE void sendPreedit(const QString &text, int cursor = -1); - - Q_INVOKABLE void commit(); - Q_INVOKABLE void commit(const QString &text, int replacementStart = 0, int replacementEnd = 0); - - Q_INVOKABLE void clear(); - - void update(); - -signals: - void preeditTextChanged(); - void visibleChanged(); - void contextUpdated(); - void focusChanged(); - -private: - QString m_preeditText; - DeclarativeInputContext *m_inputContext; - QWidget *m_focusWidget; - bool m_visible; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/imports/inputcontext/plugin.cpp b/src/imports/inputcontext/plugin.cpp deleted file mode 100644 index 70fed2e241..0000000000 --- a/src/imports/inputcontext/plugin.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "declarativeinputcontext.h" -#include "inputcontextfilter.h" -#include "inputcontextmodule.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -static QObject *createContext(QDeclarativeEngine *, QJSEngine *) -{ - return new InputContextModule; -} - -class InputContextQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.inputcontext")); - - qApp->setInputContext(new DeclarativeInputContext); - - qmlRegisterModuleApi(uri, 1, 0, createContext); - qmlRegisterType(uri, 1, 0, "MouseHandler"); - qmlRegisterType(uri, 1, 0, "MouseFilter"); - qmlRegisterType(uri, 1, 0, "KeyFilter"); - qmlRegisterType(); - qmlRegisterType(); - } -}; - -QT_END_NAMESPACE - -Q_EXPORT_PLUGIN2(InputContext, QT_PREPEND_NAMESPACE(InputContextQmlPlugin)); - -#include "plugin.moc" diff --git a/src/imports/inputcontext/qmldir b/src/imports/inputcontext/qmldir deleted file mode 100644 index 3fb65a6e0e..0000000000 --- a/src/imports/inputcontext/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlinputcontextplugin -- cgit v1.2.3