diff options
Diffstat (limited to 'basicsuite/textinput')
-rw-r--r-- | basicsuite/textinput/ScrollBar.qml | 67 | ||||
-rw-r--r-- | basicsuite/textinput/TextArea.qml | 89 | ||||
-rw-r--r-- | basicsuite/textinput/TextBase.qml | 96 | ||||
-rw-r--r-- | basicsuite/textinput/TextField.qml | 94 | ||||
-rw-r--r-- | basicsuite/textinput/description.txt | 3 | ||||
-rw-r--r-- | basicsuite/textinput/main.qml | 114 | ||||
-rw-r--r-- | basicsuite/textinput/preview_l.jpg | bin | 0 -> 16465 bytes | |||
-rw-r--r-- | basicsuite/textinput/textinput.pro | 13 | ||||
-rw-r--r-- | basicsuite/textinput/title.txt | 1 |
9 files changed, 477 insertions, 0 deletions
diff --git a/basicsuite/textinput/ScrollBar.qml b/basicsuite/textinput/ScrollBar.qml new file mode 100644 index 0000000..b4753f2 --- /dev/null +++ b/basicsuite/textinput/ScrollBar.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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 Digia Plc 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 + +Item { + property var scrollArea: parent + + width: 6 + opacity: scrollArea && scrollArea.movingVertically ? 1.0 : 0.0 + visible: scrollArea && scrollArea.contentHeight >= scrollArea.height + anchors { right: parent.right; top: parent.top; bottom: parent.bottom; margins: 2 } + + Behavior on opacity { NumberAnimation { properties: "opacity"; duration: 600 } } + + function size() { + var nh = scrollArea.visibleArea.heightRatio * height + var ny = scrollArea.visibleArea.yPosition * height + return ny > 3 ? Math.min(nh, Math.ceil(height - 3 - ny)) : nh + ny + } + Rectangle { + x: 1 + y: scrollArea ? Math.max(2, scrollArea.visibleArea.yPosition * parent.height) : 0 + height: scrollArea ? size() : 0 + width: parent.width - 2 + color: Qt.rgba(1.0, 1.0, 1.0, 0.5) + radius: 1 + } +} diff --git a/basicsuite/textinput/TextArea.qml b/basicsuite/textinput/TextArea.qml new file mode 100644 index 0000000..490e066 --- /dev/null +++ b/basicsuite/textinput/TextArea.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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 Digia Plc 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 + +TextBase { + id: textArea + + property alias color: textEdit.color + property alias text: textEdit.text + property alias textWidth: textEdit.width + property alias readOnly: textEdit.readOnly + property alias inputMethodHints: textEdit.inputMethodHints + + editor: textEdit + + Repeater { + model: Math.floor((parent.height - 30) / editor.cursorRectangle.height) + Rectangle { + x: 8 + y: (index+1)*editor.cursorRectangle.height+6 + height: 1; width: textArea.width-24 + color: Qt.rgba(1.0, 1.0, 1.0, 0.5) + } + } + TextEdit { + id: textEdit + + property alias enterKeyText: textArea.enterKeyText + property alias enterKeyEnabled: textArea.enterKeyEnabled + + y: 6 + focus: true + color: "#EEEEEE" + wrapMode: TextEdit.Wrap + cursorVisible: activeFocus + height: Math.max(implicitHeight, 60) + font.pixelSize: textArea.fontPixelSize + selectionColor: Qt.rgba(1.0, 1.0, 1.0, 0.5) + selectedTextColor: Qt.rgba(0.0, 0.0, 0.0, 0.8) + anchors { left: parent.left; right: parent.right; margins: 12 } + cursorDelegate: Rectangle { + width: 2 + opacity: 0.7 + color: "#EEEEEE" + visible: textEdit.activeFocus + } + + onActiveFocusChanged: if (!activeFocus) deselect() + } +} diff --git a/basicsuite/textinput/TextBase.qml b/basicsuite/textinput/TextBase.qml new file mode 100644 index 0000000..67ee3e3 --- /dev/null +++ b/basicsuite/textinput/TextBase.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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 Digia Plc 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 + +FocusScope { + id: textBase + + property var editor + property bool previewTextActive: !editor.activeFocus && text.length === 0 + property int fontPixelSize: 32 + property string previewText + property string enterKeyText + property bool enterKeyEnabled: true + property alias mouseParent: mouseArea.parent + + implicitHeight: editor.height + 12 + + signal enterKeyClicked + + Keys.onReleased: { + if (event.key === Qt.Key_Return) + enterKeyClicked() + } + + Rectangle { + // background + radius: 5.0 + anchors.fill: parent + color: Qt.rgba(1.0, 1.0, 1.0, 0.2) + border { width: editor.activeFocus ? 2 : 0; color: "#CCCCCC" } + } + Text { + id: previewText + + y: 8 + color: "#CCCCCC" + visible: previewTextActive + text: textBase.previewText + font.pixelSize: 28 + anchors { left: parent.left; right: parent.right; margins: 12 } + + } + MouseArea { + id: mouseArea + + z: 1 + parent: textBase + anchors.fill: parent + onClicked: { + var positionInEditor = mapToItem(editor, mouseX, mouseY) + var cursorPosition = editor.positionAt(positionInEditor.x, positionInEditor.y) + editor.cursorPosition = cursorPosition + editor.forceActiveFocus() + Qt.inputMethod.show() + } + } +} diff --git a/basicsuite/textinput/TextField.qml b/basicsuite/textinput/TextField.qml new file mode 100644 index 0000000..9b01418 --- /dev/null +++ b/basicsuite/textinput/TextField.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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 Digia Plc 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 + +TextBase { + id: textField + + property alias color: textInput.color + property alias text: textInput.text + property alias textWidth: textInput.width + property alias readOnly: textInput.readOnly + property alias inputMethodHints: textInput.inputMethodHints + property alias validator: textInput.validator + property alias echoMode: textInput.echoMode + + editor: textInput + mouseParent: flickable + + Flickable { + id: flickable + + x: 12 + clip: true + width: parent.width-24 + height: parent.height + flickableDirection: Flickable.HorizontalFlick + interactive: contentWidth - 4 > width + + contentWidth: textInput.width+2 + contentHeight: textInput.height + TextInput { + id: textInput + + property alias enterKeyText: textField.enterKeyText + property alias enterKeyEnabled: textField.enterKeyEnabled + + y: 6 + focus: true + color: "#EEEEEE" + cursorVisible: activeFocus + passwordCharacter: "\u2022" + font.pixelSize: textField.fontPixelSize + selectionColor: Qt.rgba(1.0, 1.0, 1.0, 0.5) + selectedTextColor: Qt.rgba(0.0, 0.0, 0.0, 0.8) + width: Math.max(flickable.width, implicitWidth)-2 + cursorDelegate: Rectangle { + width: 2 + opacity: 0.7 + color: "#EEEEEE" + visible: textInput.activeFocus + } + onActiveFocusChanged: if (!activeFocus) deselect() + } + } +} diff --git a/basicsuite/textinput/description.txt b/basicsuite/textinput/description.txt new file mode 100644 index 0000000..5330313 --- /dev/null +++ b/basicsuite/textinput/description.txt @@ -0,0 +1,3 @@ +This example illustrates how to handle input on touch devices. + +Qt Enterprise Embedded comes with Qt Virtual Keyboard - a framework that consists of a C++ back end with support for custom input methods, as well as a reference keyboard front end implemented in QML, supporting multiple languages. diff --git a/basicsuite/textinput/main.qml b/basicsuite/textinput/main.qml new file mode 100644 index 0000000..8f63b83 --- /dev/null +++ b/basicsuite/textinput/main.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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 Digia Plc 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 + +Flickable { + id: flickable + + property real scrollMarginVertical: 20 + + anchors.fill: parent + contentWidth: content.width + contentHeight: content.height + interactive: contentHeight > height + flickableDirection: Flickable.VerticalFlick + children: ScrollBar {} + + MouseArea { + id: content + + width: flickable.width + height: textEditors.height + 24 + + onClicked: focus = true + + Column { + id: textEditors + spacing: 15 + x: 12; y: 12 + width: parent.width - 26 + + Text { + color: "#EEEEEE" + text: "Tap fields to enter text" + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 22 + } + TextField { + width: parent.width + previewText: "One line field" + enterKeyText: "Next" + enterKeyEnabled: text.length > 0 + onEnterKeyClicked: passwordField.focus = true + } + TextField { + id: passwordField + + width: parent.width + echoMode: TextInput.PasswordEchoOnEdit + previewText: "Password field" + inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase | Qt.ImhSensitiveData | Qt.ImhNoPredictiveText + enterKeyText: "Next" + enterKeyEnabled: text.length > 0 + onEnterKeyClicked: numberField.focus = true + } + TextField { + id: numberField + + validator: RegExpValidator { regExp: /^[0-9\+\-\#\*\ ]{6,}$/ } + width: parent.width + previewText: "Phone number field" + inputMethodHints: Qt.ImhDialableCharactersOnly + enterKeyText: "Next" + enterKeyEnabled: text.length > 0 + onEnterKeyClicked: textArea.focus = true + } + TextArea { + id: textArea + + width: parent.width + previewText: "Multiple lines field" + height: Math.max(206, implicitHeight) + } + } + } +} diff --git a/basicsuite/textinput/preview_l.jpg b/basicsuite/textinput/preview_l.jpg Binary files differnew file mode 100644 index 0000000..f415a86 --- /dev/null +++ b/basicsuite/textinput/preview_l.jpg diff --git a/basicsuite/textinput/textinput.pro b/basicsuite/textinput/textinput.pro new file mode 100644 index 0000000..b5b97b2 --- /dev/null +++ b/basicsuite/textinput/textinput.pro @@ -0,0 +1,13 @@ +TARGET = textinput + +include(../shared/shared.pri) +b2qtdemo_deploy_defaults() + +content.files = \ + *.qml \ + *.png +content.path = $$DESTPATH + +OTHER_FILES += $${content.files} + +INSTALLS += target content diff --git a/basicsuite/textinput/title.txt b/basicsuite/textinput/title.txt new file mode 100644 index 0000000..932c2f3 --- /dev/null +++ b/basicsuite/textinput/title.txt @@ -0,0 +1 @@ +Virtual Keyboard |