diff options
Diffstat (limited to 'examples/virtualkeyboard/basic/content')
9 files changed, 681 insertions, 0 deletions
diff --git a/examples/virtualkeyboard/basic/content/AutoScroller.qml b/examples/virtualkeyboard/basic/content/AutoScroller.qml new file mode 100644 index 00000000..c863e96a --- /dev/null +++ b/examples/virtualkeyboard/basic/content/AutoScroller.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Enterprise.VirtualKeyboard 2.0 + +Item { + + property var innerFlickable + property var outerFlickable + property var inputItem: InputContext.inputItem + + onInputItemChanged: { + innerFlickable = null + outerFlickable = null + if (inputItem !== null) { + var parent_ = inputItem.parent + while (parent_) { + if (parent_.maximumFlickVelocity) { + if (innerFlickable) { + outerFlickable = parent_ + break + } else { + innerFlickable = parent_ + } + } + parent_ = parent_.parent + } + delayedLoading.triggered() + } + } + + function ensureVisible(flickable) { + if (Qt.inputMethod.visible && inputItem && flickable && flickable.visible && flickable.interactive) { + + var verticallyFlickable = (flickable.flickableDirection === Flickable.HorizontalAndVerticalFlick || flickable.flickableDirection === Flickable.VerticalFlick + || (flickable.flickableDirection === Flickable.AutoFlickDirection && flickable.contentHeight > flickable.height)) + var horizontallyFlickable = (flickable.flickableDirection === Flickable.HorizontalAndVerticalFlick || flickable.flickableDirection === Flickable.HorizontalFlick + || (flickable.flickableDirection === Flickable.AutoFlickDirection && flickable.contentWidth > flickable.width)) + + if ((!verticallyFlickable && !horizontallyFlickable) || !inputItem.hasOwnProperty("cursorRectangle")) + return + + var cursorRectangle = flickable.contentItem.mapFromItem(inputItem, inputItem.cursorRectangle.x, inputItem.cursorRectangle.y) + + var oldContentY = flickable.contentY + if (verticallyFlickable) { + var scrollMarginVertical = (flickable && flickable.scrollMarginVertical) ? flickable.scrollMarginVertical : 10 + if (flickable.contentY >= cursorRectangle.y - scrollMarginVertical) + flickable.contentY = Math.max(0, cursorRectangle.y - scrollMarginVertical) + else if (flickable.contentY + flickable.height <= cursorRectangle.y + inputItem.cursorRectangle.height + scrollMarginVertical) + flickable.contentY = Math.min(flickable.contentHeight - flickable.height, cursorRectangle.y + inputItem.cursorRectangle.height - flickable.height + scrollMarginVertical) + } + if (horizontallyFlickable) { + var scrollMarginHorizontal = (flickable && flickable.scrollMarginHorizontal) ? flickable.scrollMarginHorizontal : 10 + if (flickable.contentX >= cursorRectangle.x - scrollMarginHorizontal) + flickable.contentX = Math.max(0, cursorRectangle.x - scrollMarginHorizontal) + else if (flickable.contentX + flickable.width <= cursorRectangle.x + inputItem.cursorRectangle.width + scrollMarginHorizontal) + flickable.contentX = Math.min(flickable.contentWidth - flickable.width, cursorRectangle.x + inputItem.cursorRectangle.width - flickable.width + scrollMarginHorizontal) + } + } + } + Timer { + id: delayedLoading + interval: 10 + onTriggered: { + ensureVisible(innerFlickable) + ensureVisible(outerFlickable) + } + } + Connections { + ignoreUnknownSignals: true + target: inputItem && !Qt.inputMethod.animating ? Qt.inputMethod : null + onKeyboardRectangleChanged: delayedLoading.triggered() + } + Connections { + ignoreUnknownSignals: true + target: inputItem && inputItem.activeFocus ? inputItem : null + onCursorRectangleChanged: delayedLoading.triggered() + } +} diff --git a/examples/virtualkeyboard/basic/content/FloatingButton_Active.svg b/examples/virtualkeyboard/basic/content/FloatingButton_Active.svg new file mode 100644 index 00000000..ef108358 --- /dev/null +++ b/examples/virtualkeyboard/basic/content/FloatingButton_Active.svg @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + width="390px" height="390px" viewBox="0 0 390 390" style="enable-background:new 0 0 390 390;" xml:space="preserve"> +<style type="text/css"> + .st0{opacity:0.3;enable-background:new ;} + .st1{opacity:0.5;} + .st2{fill:#FFFFFF;} + .st3{fill:#5CAA15;} + .st4{fill:none;} +</style> +<g id="Active"> + <g> + <circle class="st0" cx="195" cy="195" r="191"/> + <g class="st1"> + <path class="st2" d="M195,4c105.5,0,191,85.5,191,191s-85.5,191-191,191S4,300.5,4,195S89.5,4,195,4 M195,0 + c-26.3,0-51.9,5.2-75.9,15.3c-23.2,9.8-44.1,23.9-62,41.8s-32,38.8-41.8,62C5.2,143.1,0,168.7,0,195s5.2,51.9,15.3,75.9 + c9.8,23.2,23.9,44.1,41.8,62s38.8,32,62,41.8c24,10.2,49.6,15.3,75.9,15.3s51.9-5.2,75.9-15.3c23.2-9.8,44.1-23.9,62-41.8 + s32-38.8,41.8-62c10.2-24,15.3-49.6,15.3-75.9s-5.2-51.9-15.3-75.9c-9.8-23.2-23.9-44.1-41.8-62s-38.8-32-62-41.8 + C246.9,5.2,221.3,0,195,0L195,0z"/> + </g> + </g> + <circle class="st3" cx="195" cy="195" r="141"/> +</g> +<g id="icon"> + <g> + <g> + <path class="st2" d="M155.6,247.3c-10.1,0-18.9-5-23.1-13.6c-10.1-21,5.4-37.4,21.7-54.7c1.2-1.2,2.4-2.5,3.6-3.8 + c5.3-5.7,5.2-11.5,3.5-14.8c-1.8-3.4-5.5-4.9-10.2-4.2c-16.5,2.6-21.2,26.4-21.2,26.6l-11.9-2.2c0.3-1.3,6.4-32.3,31.2-36.3 + c9.8-1.6,18.5,2.4,22.7,10.4c4.7,8.9,2.6,20.1-5.3,28.6c-1.2,1.3-2.4,2.6-3.6,3.8c-16.7,17.8-25.9,28.5-19.6,41.4 + c3.3,6.8,11.1,7.6,16.9,6.3c9.2-2.1,19.8-11.1,19.7-29.5c-0.2-28.1,16.2-41.8,30.2-44.9c14.5-3.2,28.4,3.6,34.7,17 + c1.3,2.8,2.3,5.4,3.1,8.1c13.3,0.7,25.5,4.3,26,4.4l-3.4,11.5c-0.1,0-9.7-2.8-20.6-3.8c0.5,16.5-8.6,28.9-20.1,34.7 + c-11.9,6-24,3.8-28.9-5.2c-3.1-5.6-1.9-14.7,2.9-22.5c7.9-13,21.3-17.4,31.5-18.8c-0.4-1.2-0.9-2.4-1.4-3.4 + c-3.9-8.3-12.2-12.4-21.1-10.4c-9.7,2.2-21,12.1-20.8,33.1c0.2,25.5-15.6,38.1-29,41.3C160.5,247,158,247.3,155.6,247.3z + M237.8,197.7c-14,1.5-20.6,8.5-23.4,12.9c-3.3,5.2-3.4,9.8-2.9,10.9c1.6,2.9,7.3,3,13,0.2C235.3,216.2,238.3,206.6,237.8,197.7z + "/> + </g> + <rect x="118" y="144" class="st4" width="156" height="104"/> + </g> +</g> +</svg> diff --git a/examples/virtualkeyboard/basic/content/FloatingButton_Available.svg b/examples/virtualkeyboard/basic/content/FloatingButton_Available.svg new file mode 100644 index 00000000..1178c8c6 --- /dev/null +++ b/examples/virtualkeyboard/basic/content/FloatingButton_Available.svg @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + width="390px" height="390px" viewBox="0 0 390 390" style="enable-background:new 0 0 390 390;" xml:space="preserve"> +<style type="text/css"> + .st0{opacity:0.3;enable-background:new ;} + .st1{opacity:0.5;} + .st2{fill:#FFFFFF;} + .st3{fill:#26282A;} + .st4{fill:none;} +</style> +<g id="Available"> + <g> + <circle class="st0" cx="195" cy="195" r="191"/> + <g class="st1"> + <path class="st2" d="M195,4c105.5,0,191,85.5,191,191s-85.5,191-191,191S4,300.5,4,195S89.5,4,195,4 M195,0 + c-26.3,0-51.9,5.2-75.9,15.3c-23.2,9.8-44.1,23.9-62,41.8s-32,38.8-41.8,62C5.2,143.1,0,168.7,0,195s5.2,51.9,15.3,75.9 + c9.8,23.2,23.9,44.1,41.8,62s38.8,32,62,41.8c24,10.2,49.6,15.3,75.9,15.3s51.9-5.2,75.9-15.3c23.2-9.8,44.1-23.9,62-41.8 + s32-38.8,41.8-62c10.2-24,15.3-49.6,15.3-75.9s-5.2-51.9-15.3-75.9c-9.8-23.2-23.9-44.1-41.8-62s-38.8-32-62-41.8 + C246.9,5.2,221.3,0,195,0L195,0z"/> + </g> + </g> + <circle class="st3" cx="195" cy="195" r="141"/> +</g> +<g id="icon"> + <g> + <g> + <path class="st2" d="M155.6,247.3c-10.1,0-18.9-5-23.1-13.6c-10.1-21,5.4-37.4,21.7-54.7c1.2-1.2,2.4-2.5,3.6-3.8 + c5.3-5.7,5.2-11.5,3.5-14.8c-1.8-3.4-5.5-4.9-10.2-4.2c-16.5,2.6-21.2,26.4-21.2,26.6l-11.9-2.2c0.3-1.3,6.4-32.3,31.2-36.3 + c9.8-1.6,18.5,2.4,22.7,10.4c4.7,8.9,2.6,20.1-5.3,28.6c-1.2,1.3-2.4,2.6-3.6,3.8c-16.7,17.8-25.9,28.5-19.6,41.4 + c3.3,6.8,11.1,7.6,16.9,6.3c9.2-2.1,19.8-11.1,19.7-29.5c-0.2-28.1,16.2-41.8,30.2-44.9c14.5-3.2,28.4,3.6,34.7,17 + c1.3,2.8,2.3,5.4,3.1,8.1c13.3,0.7,25.5,4.3,26,4.4l-3.4,11.5c-0.1,0-9.7-2.8-20.6-3.8c0.5,16.5-8.6,28.9-20.1,34.7 + c-11.9,6-24,3.8-28.9-5.2c-3.1-5.6-1.9-14.7,2.9-22.5c7.9-13,21.3-17.4,31.5-18.8c-0.4-1.2-0.9-2.4-1.4-3.4 + c-3.9-8.3-12.2-12.4-21.1-10.4c-9.7,2.2-21,12.1-20.8,33.1c0.2,25.5-15.6,38.1-29,41.3C160.5,247,158,247.3,155.6,247.3z + M237.8,197.7c-14,1.5-20.6,8.5-23.4,12.9c-3.3,5.2-3.4,9.8-2.9,10.9c1.6,2.9,7.3,3,13,0.2C235.3,216.2,238.3,206.6,237.8,197.7z + "/> + </g> + <rect x="118" y="144" class="st4" width="156" height="104"/> + </g> +</g> +</svg> diff --git a/examples/virtualkeyboard/basic/content/FloatingButton_Unavailable.svg b/examples/virtualkeyboard/basic/content/FloatingButton_Unavailable.svg new file mode 100644 index 00000000..d8149b53 --- /dev/null +++ b/examples/virtualkeyboard/basic/content/FloatingButton_Unavailable.svg @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + width="390px" height="390px" viewBox="0 0 390 390" style="enable-background:new 0 0 390 390;" xml:space="preserve"> +<style type="text/css"> + .st0{opacity:0.3;enable-background:new ;} + .st1{opacity:0.5;} + .st2{fill:#FFFFFF;} + .st3{fill:none;} +</style> +<g id="Unavailable"> + <g> + <circle class="st0" cx="195" cy="195" r="191"/> + <g class="st1"> + <path class="st2" d="M195,4c105.5,0,191,85.5,191,191s-85.5,191-191,191S4,300.5,4,195S89.5,4,195,4 M195,0 + c-26.3,0-51.9,5.2-75.9,15.3c-23.2,9.8-44.1,23.9-62,41.8s-32,38.8-41.8,62C5.2,143.1,0,168.7,0,195s5.2,51.9,15.3,75.9 + c9.8,23.2,23.9,44.1,41.8,62s38.8,32,62,41.8c24,10.2,49.6,15.3,75.9,15.3s51.9-5.2,75.9-15.3c23.2-9.8,44.1-23.9,62-41.8 + s32-38.8,41.8-62c10.2-24,15.3-49.6,15.3-75.9s-5.2-51.9-15.3-75.9c-9.8-23.2-23.9-44.1-41.8-62s-38.8-32-62-41.8 + C246.9,5.2,221.3,0,195,0L195,0z"/> + </g> + </g> +</g> +<g id="icon"> + <g> + <g> + <path class="st2" d="M155.6,247.3c-10.1,0-18.9-5-23.1-13.6c-10.1-21,5.4-37.4,21.7-54.7c1.2-1.2,2.4-2.5,3.6-3.8 + c5.3-5.7,5.2-11.5,3.5-14.8c-1.8-3.4-5.5-4.9-10.2-4.2c-16.5,2.6-21.2,26.4-21.2,26.6l-11.9-2.2c0.3-1.3,6.4-32.3,31.2-36.3 + c9.8-1.6,18.5,2.4,22.7,10.4c4.7,8.9,2.6,20.1-5.3,28.6c-1.2,1.3-2.4,2.6-3.6,3.8c-16.7,17.8-25.9,28.5-19.6,41.4 + c3.3,6.8,11.1,7.6,16.9,6.3c9.2-2.1,19.8-11.1,19.7-29.5c-0.2-28.1,16.2-41.8,30.2-44.9c14.5-3.2,28.4,3.6,34.7,17 + c1.3,2.8,2.3,5.4,3.1,8.1c13.3,0.7,25.5,4.3,26,4.4l-3.4,11.5c-0.1,0-9.7-2.8-20.6-3.8c0.5,16.5-8.6,28.9-20.1,34.7 + c-11.9,6-24,3.8-28.9-5.2c-3.1-5.6-1.9-14.7,2.9-22.5c7.9-13,21.3-17.4,31.5-18.8c-0.4-1.2-0.9-2.4-1.4-3.4 + c-3.9-8.3-12.2-12.4-21.1-10.4c-9.7,2.2-21,12.1-20.8,33.1c0.2,25.5-15.6,38.1-29,41.3C160.5,247,158,247.3,155.6,247.3z + M237.8,197.7c-14,1.5-20.6,8.5-23.4,12.9c-3.3,5.2-3.4,9.8-2.9,10.9c1.6,2.9,7.3,3,13,0.2C235.3,216.2,238.3,206.6,237.8,197.7z + "/> + </g> + <rect x="118" y="144" class="st3" width="156" height="104"/> + </g> +</g> +</svg> diff --git a/examples/virtualkeyboard/basic/content/HandwritingModeButton.qml b/examples/virtualkeyboard/basic/content/HandwritingModeButton.qml new file mode 100644 index 00000000..6b2f9dbc --- /dev/null +++ b/examples/virtualkeyboard/basic/content/HandwritingModeButton.qml @@ -0,0 +1,165 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: handwritingModeButton + state: "unavailable" + property bool floating + property bool flipable + readonly property real __minWidthHeight: Math.min(width, height) + + signal clicked() + signal doubleClicked() + + Flipable { + id: flipableImage + anchors.fill: parent + + property bool flipped + + front: Image { + sourceSize.width: handwritingModeButton.__minWidthHeight + sourceSize.height: handwritingModeButton.__minWidthHeight + smooth: false + source: "qrc:/content/FloatingButton_Unavailable.svg" + } + + back: Image { + id: buttonImage + sourceSize.width: handwritingModeButton.__minWidthHeight + sourceSize.height: handwritingModeButton.__minWidthHeight + smooth: false + source: "qrc:/content/FloatingButton_Available.svg" + } + + states: State { + PropertyChanges { target: rotation; angle: 180 } + when: flipableImage.flipped + } + + transform: Rotation { + id: rotation + origin.x: flipableImage.width / 2 + origin.y: flipableImage.height / 2 + axis { x: 0; y: 1; z: 0 } + angle: 0 + } + + transitions: Transition { + enabled: handwritingModeButton.flipable + NumberAnimation { target: rotation; property: "angle"; duration: 400 } + } + } + + states: [ + State { + name: "available" + PropertyChanges { target: flipableImage; flipped: true } + }, + State { + name: "active" + PropertyChanges { target: flipableImage; flipped: true } + PropertyChanges { target: buttonImage; source: "qrc:/content/FloatingButton_Active.svg" } + } + ] + + function snapHorizontal() { + if (!floating) + return + if (mouseArea.drag.maximumX > mouseArea.drag.minimumX) { + if (x + 20 >= mouseArea.drag.maximumX) { + anchors.left = undefined + anchors.right = parent.right + } else if (x - 20 <= mouseArea.drag.minimumX) { + anchors.right = undefined + anchors.left = parent.left + } + } + } + + function snapVertical() { + if (!floating) + return + if (mouseArea.drag.maximumY > mouseArea.drag.minimumY) { + if (y + 20 >= mouseArea.drag.maximumY) { + anchors.top = undefined + anchors.bottom = parent.bottom + } else if (y - 20 <= mouseArea.drag.minimumY) { + anchors.bottom = undefined + anchors.top = parent.top + } + } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + drag { + target: handwritingModeButton.floating ? handwritingModeButton : undefined + axis: Drag.XAxis | Drag.YAxis + minimumX: 0 + maximumX: handwritingModeButton.parent.width - handwritingModeButton.width + onMaximumXChanged: !mouseArea.drag.active && handwritingModeButton.snapHorizontal() + minimumY: 0 + maximumY: handwritingModeButton.parent.height - handwritingModeButton.height + onMaximumYChanged: !mouseArea.drag.active && handwritingModeButton.snapVertical() + } + onPressed: { + if (!handwritingModeButton.floating) + return + handwritingModeButton.anchors.left = undefined + handwritingModeButton.anchors.top = undefined + handwritingModeButton.anchors.right = undefined + handwritingModeButton.anchors.bottom = undefined + } + onReleased: { + handwritingModeButton.snapHorizontal() + handwritingModeButton.snapVertical() + } + onClicked: { + handwritingModeButton.snapHorizontal() + handwritingModeButton.snapVertical() + clickTimer.restart() + } + onDoubleClicked: { + clickTimer.stop() + handwritingModeButton.snapHorizontal() + handwritingModeButton.snapVertical() + handwritingModeButton.doubleClicked() + } + Timer { + id: clickTimer + interval: Qt.styleHints ? Qt.styleHints.mouseDoubleClickInterval / 3 : 0 + repeat: false + onTriggered: handwritingModeButton.clicked() + } + } +} diff --git a/examples/virtualkeyboard/basic/content/ScrollBar.qml b/examples/virtualkeyboard/basic/content/ScrollBar.qml new file mode 100644 index 00000000..db0e47b3 --- /dev/null +++ b/examples/virtualkeyboard/basic/content/ScrollBar.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/examples/virtualkeyboard/basic/content/TextArea.qml b/examples/virtualkeyboard/basic/content/TextArea.qml new file mode 100644 index 00000000..b862fd55 --- /dev/null +++ b/examples/virtualkeyboard/basic/content/TextArea.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Enterprise.VirtualKeyboard 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: "#D6D6D6" + } + } + MouseArea { + anchors.fill: parent + onClicked: textEdit.forceActiveFocus() + } + TextEdit { + id: textEdit + + EnterKeyAction.actionId: textArea.enterKeyAction + EnterKeyAction.label: textArea.enterKeyText + EnterKeyAction.enabled: textArea.enterKeyEnabled + + y: 6 + focus: true + color: "#2B2C2E" + 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) + selectByMouse: true + anchors { left: parent.left; right: parent.right; margins: 12 } + } +} diff --git a/examples/virtualkeyboard/basic/content/TextBase.qml b/examples/virtualkeyboard/basic/content/TextBase.qml new file mode 100644 index 00000000..124e8087 --- /dev/null +++ b/examples/virtualkeyboard/basic/content/TextBase.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Enterprise.VirtualKeyboard 2.0 + +FocusScope { + id: textBase + + property var editor + property bool previewTextActive: !editor.activeFocus && text.length === 0 + property int fontPixelSize: 32 + property string previewText + property int enterKeyAction: EnterKeyAction.None + property string enterKeyText + property bool enterKeyEnabled: enterKeyAction === EnterKeyAction.None || editor.text.length > 0 || editor.inputMethodComposing + + implicitHeight: editor.height + 12 + + signal enterKeyClicked + + Keys.onReleased: { + if (event.key === Qt.Key_Return) + enterKeyClicked() + } + + Rectangle { + // background + radius: 5.0 + anchors.fill: parent + color: "#FFFFFF" + border { width: 1; color: editor.activeFocus ? "#5CAA15" : "#BDBEBF" } + } + Text { + id: previewText + + y: 8 + clip: true + color: "#a0a1a2" + visible: previewTextActive + text: textBase.previewText + font.pixelSize: 28 + anchors { left: parent.left; right: parent.right; margins: 12 } + + } +} diff --git a/examples/virtualkeyboard/basic/content/TextField.qml b/examples/virtualkeyboard/basic/content/TextField.qml new file mode 100644 index 00000000..3228b256 --- /dev/null +++ b/examples/virtualkeyboard/basic/content/TextField.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Enterprise.VirtualKeyboard 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 + property int passwordMaskDelay: 1000 + + editor: textInput + + 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 + + EnterKeyAction.actionId: textField.enterKeyAction + EnterKeyAction.label: textField.enterKeyText + EnterKeyAction.enabled: textField.enterKeyEnabled + + y: 6 + focus: true + color: "#2B2C2E" + cursorVisible: activeFocus + passwordCharacter: "\u2022" + font.pixelSize: textField.fontPixelSize + selectionColor: Qt.rgba(0.0, 0.0, 0.0, 0.15) + selectedTextColor: color + selectByMouse: true + width: Math.max(flickable.width, implicitWidth)-2 + + Binding { + target: textInput + property: "passwordMaskDelay" + value: textField.passwordMaskDelay + when: textInput.hasOwnProperty("passwordMaskDelay") + } + } + } +} |