diff options
author | Mitch Curtis <mitch.curtis@digia.com> | 2014-01-27 14:06:59 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-01-28 14:50:17 +0200 |
commit | 9778eb24c145ce24c80ca753ea3526e104e9aa91 (patch) | |
tree | 988e487da09aee27157dd23ac6c4e7673603bd63 /examples | |
parent | 631db7a021c80949b122311e5f38203989319743 (diff) |
Restructure and rename.
This restructures the repo to match other Qt modules, like the
Enterprise Controls. It also renames the plugin and usages of its name
in the documentation so that the abbreviated "VKB" is not used
anywhere.
Change-Id: I5de3fc67846a50438e52f4be057abfa0d9be0d91
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'examples')
12 files changed, 483 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro new file mode 100644 index 00000000..7664d615 --- /dev/null +++ b/examples/examples.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS += quick/enterprise/virtualkeyboard diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard.pro b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard.pro new file mode 100644 index 00000000..8c37ce46 --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + virtualkeyboard diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/VirtualKeyboard-b2qt.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/VirtualKeyboard-b2qt.qml new file mode 100644 index 00000000..84ef8478 --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/VirtualKeyboard-b2qt.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Quick Enterprise Controls add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Enterprise.VirtualKeyboard 1.0 + +Item { + implicitWidth: virtualKeyboard.implicitHeight + implicitHeight: virtualKeyboard.implicitWidth + Item { + id: appContainer + width: parent.height + height: parent.width + anchors.centerIn: parent + rotation: 90 + VirtualKeyboard { + id: virtualKeyboard + anchors.left: parent.left + anchors.top: parent.top + anchors.right: parent.right + anchors.bottom: inputPanel.top + } + InputPanel { + id: inputPanel + z: 99 + y: appContainer.height + anchors.left: parent.left + anchors.right: parent.right + states: State { + name: "visible" + when: Qt.inputMethod.visible + PropertyChanges { + target: inputPanel + y: appContainer.height - inputPanel.height + } + } + transitions: Transition { + from: "" + to: "visible" + reversible: true + ParallelAnimation { + NumberAnimation { + properties: "y" + duration: 250 + easing.type: Easing.InOutQuad + } + } + } + } + } +} diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/VirtualKeyboard.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/VirtualKeyboard.qml new file mode 100644 index 00000000..6d10029a --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/VirtualKeyboard.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Quick Enterprise Controls add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Image { + source: "content/images/background.png" + + 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" + 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" + 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" + onEnterKeyClicked: textArea.focus = true + } + TextArea { + id: textArea + + width: parent.width + previewText: "Multiple lines field" + height: Math.max(206, implicitHeight) + } + } + } + } +} diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/ScrollBar.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/ScrollBar.qml new file mode 100644 index 00000000..1dd842de --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/ScrollBar.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Quick Enterprise Controls add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +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/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextArea.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextArea.qml new file mode 100644 index 00000000..77bbcdcb --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextArea.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Quick Enterprise Controls add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +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 } + onActiveFocusChanged: if (!activeFocus) deselect() + } +} diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextBase.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextBase.qml new file mode 100644 index 00000000..46172d2f --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextBase.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Quick Enterprise Controls add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +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: enterKeyText.length === 0 || editor.text.length > 0 || editor.inputMethodComposing + 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: { + if (editor.inputMethodComposing) + Qt.inputMethod.commit() + 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/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextField.qml b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextField.qml new file mode 100644 index 00000000..da2d4a27 --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/TextField.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Quick Enterprise Controls add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +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 + onActiveFocusChanged: if (!activeFocus) deselect() + } + } +} diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/images/background.png b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/images/background.png Binary files differnew file mode 100644 index 00000000..80070f97 --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/content/images/background.png diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/demo.qrc b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/demo.qrc new file mode 100644 index 00000000..c2b65cbf --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/demo.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>VirtualKeyboard-b2qt.qml</file> + <file>VirtualKeyboard.qml</file> + <file>content/ScrollBar.qml</file> + <file>content/TextArea.qml</file> + <file>content/TextBase.qml</file> + <file>content/TextField.qml</file> + <file>content/images/background.png</file> + </qresource> +</RCC> diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/main.cpp b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/main.cpp new file mode 100644 index 00000000..0f729046 --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/main.cpp @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Quick Enterprise Controls add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include <QQuickView> +#include <QGuiApplication> +#include <QQmlEngine> + +int main(int argc, char *argv[]) +{ + qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + + QGuiApplication app(argc, argv); + QQuickView view(QString("qrc:/%2").arg(MAIN_QML)); + view.setResizeMode(QQuickView::SizeRootObjectToView); + + view.show(); + + return app.exec(); +} diff --git a/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/virtualkeyboard.pro b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/virtualkeyboard.pro new file mode 100644 index 00000000..f17bc776 --- /dev/null +++ b/examples/quick/enterprise/virtualkeyboard/virtualkeyboard/virtualkeyboard.pro @@ -0,0 +1,30 @@ +TEMPLATE = app +TARGET = virtualkeyboard +QT += qml quick +SOURCES += main.cpp +CONFIG += link_pkgconfig +android-no-sdk|!isEmpty(CROSS_COMPILE) { + TARGETPATH = /data/user/qt/virtualkeyboard +} else { + TARGETPATH = $$[QT_INSTALL_EXAMPLES]/virtualkeyboard +} +target.path = $$TARGETPATH +INSTALLS += target + +RESOURCES += \ + demo.qrc + +OTHER_FILES += \ + VirtualKeyboard.qml \ + VirtualKeyboard-b2qt.qml \ + content/ScrollBar.qml \ + content/TextArea.qml \ + content/TextBase.qml \ + content/TextField.qml \ + content/images/background.png + +disable-xcb|android-no-sdk|!isEmpty(CROSS_COMPILE) { + DEFINES += MAIN_QML=\\\"VirtualKeyboard-b2qt.qml\\\" +} else { + DEFINES += MAIN_QML=\\\"VirtualKeyboard.qml\\\" +} |