summaryrefslogtreecommitdiffstats
path: root/basicsuite/textinput
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2014-01-24 13:22:02 +0100
committerTopi Reiniƶ <topi.reinio@digia.com>2014-01-27 11:29:55 +0200
commitca01d5f9f5e960337a044be6e00de58fd4fbdb05 (patch)
tree3f2e25c5f05d5e5ba9bc44f2e5a09b86741c3fb5 /basicsuite/textinput
parent5a362f80d9da6d2d36efc127588f3c427211f98c (diff)
Make basicsuite demos run stand-alone
This change will make the demos run standalone when built in Qt Creator. - Rename example directories to lowercase/non-whitespace to avoid build & deployment problems - Add title.txt files so titles remain displayed correctly in the launcher - Add a common shared source files used for the standalone apps, and .pro-files for each example - Remove .qmlproject files (not needed) - Adjust documentation to match the new directory structure Change-Id: Ib24e461952da3b2c88aab0363249115ea44ee0f2 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@digia.com>
Diffstat (limited to 'basicsuite/textinput')
-rw-r--r--basicsuite/textinput/ScrollBar.qml66
-rw-r--r--basicsuite/textinput/TextArea.qml88
-rw-r--r--basicsuite/textinput/TextBase.qml95
-rw-r--r--basicsuite/textinput/TextField.qml93
-rw-r--r--basicsuite/textinput/description.txt6
-rw-r--r--basicsuite/textinput/main.qml113
-rw-r--r--basicsuite/textinput/preview_l.jpgbin0 -> 16465 bytes
-rw-r--r--basicsuite/textinput/textinput.pro12
-rw-r--r--basicsuite/textinput/title.txt1
9 files changed, 474 insertions, 0 deletions
diff --git a/basicsuite/textinput/ScrollBar.qml b/basicsuite/textinput/ScrollBar.qml
new file mode 100644
index 0000000..e6a8143
--- /dev/null
+++ b/basicsuite/textinput/ScrollBar.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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
+
+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..cf337f6
--- /dev/null
+++ b/basicsuite/textinput/TextArea.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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
+
+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..a26c6c6
--- /dev/null
+++ b/basicsuite/textinput/TextBase.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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
+
+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..aa6768e
--- /dev/null
+++ b/basicsuite/textinput/TextField.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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
+
+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..c60d036
--- /dev/null
+++ b/basicsuite/textinput/description.txt
@@ -0,0 +1,6 @@
+This examples illustrates how Qt can handle input on touch devices.
+
+The launcher loads a custom platform input context plugin and contains a virtual keyboard. When a text control in Qt Quick gets focus, the input context will trigger the virtual keyboard to show on screen and clicks in the virtual keyboard are delegated to the text control.
+
+Our demo virtual keyboard has support for english, finnish and arabic. The input context API is plugin based and users can replace existing plugins with whatever they desire. Qt has a ready made plugin for Maliit, an open-source, cross-platform input method framework for mobile and embedded.
+
diff --git a/basicsuite/textinput/main.qml b/basicsuite/textinput/main.qml
new file mode 100644
index 0000000..b67d960
--- /dev/null
+++ b/basicsuite/textinput/main.qml
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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
+
+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
new file mode 100644
index 0000000..f415a86
--- /dev/null
+++ b/basicsuite/textinput/preview_l.jpg
Binary files differ
diff --git a/basicsuite/textinput/textinput.pro b/basicsuite/textinput/textinput.pro
new file mode 100644
index 0000000..a0f18c0
--- /dev/null
+++ b/basicsuite/textinput/textinput.pro
@@ -0,0 +1,12 @@
+TARGET = textinput
+
+include(../shared/shared.pri)
+
+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..607f060
--- /dev/null
+++ b/basicsuite/textinput/title.txt
@@ -0,0 +1 @@
+Text Input