aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/virtualkeyboard/abstractinputmethod.cpp48
-rw-r--r--src/virtualkeyboard/abstractinputmethod.h5
-rw-r--r--src/virtualkeyboard/content/components/HandwritingModeKey.qml40
-rw-r--r--src/virtualkeyboard/content/components/Keyboard.qml4
-rw-r--r--src/virtualkeyboard/content/components/TraceInputArea.qml165
-rw-r--r--src/virtualkeyboard/content/components/TraceInputKey.qml97
-rw-r--r--src/virtualkeyboard/content/content.qrc3
-rw-r--r--src/virtualkeyboard/content/styles/default/default_style.qrc2
-rw-r--r--src/virtualkeyboard/content/styles/default/images/handwriting-868482.svg18
-rw-r--r--src/virtualkeyboard/content/styles/default/images/textmode-868482.svg33
-rw-r--r--src/virtualkeyboard/content/styles/default/style.qml125
-rw-r--r--src/virtualkeyboard/content/styles/retro/images/handwriting-110b05.svg18
-rw-r--r--src/virtualkeyboard/content/styles/retro/images/key154px_colorA.svg19
-rw-r--r--src/virtualkeyboard/content/styles/retro/images/textmode-110b05.svg33
-rw-r--r--src/virtualkeyboard/content/styles/retro/retro_style.qrc3
-rw-r--r--src/virtualkeyboard/content/styles/retro/style.qml141
-rw-r--r--src/virtualkeyboard/declarativeinputengine.cpp156
-rw-r--r--src/virtualkeyboard/declarativeinputengine.h13
-rw-r--r--src/virtualkeyboard/declarativeinputmethod.cpp67
-rw-r--r--src/virtualkeyboard/declarativeinputmethod.h5
-rw-r--r--src/virtualkeyboard/declarativetrace.cpp416
-rw-r--r--src/virtualkeyboard/declarativetrace.h69
-rw-r--r--src/virtualkeyboard/doc/src/technical-guide.qdoc46
-rw-r--r--src/virtualkeyboard/plugin.cpp20
-rw-r--r--src/virtualkeyboard/styles/KeyboardStyle.qml24
-rw-r--r--src/virtualkeyboard/styles/TraceCanvas.qml133
-rw-r--r--src/virtualkeyboard/styles/TraceInputKeyPanel.qml50
-rw-r--r--src/virtualkeyboard/styles/TraceUtils.js75
-rw-r--r--src/virtualkeyboard/styles/styles.qrc3
-rw-r--r--src/virtualkeyboard/styles/styles_plugin.cpp2
-rw-r--r--src/virtualkeyboard/virtualkeyboard.pro6
31 files changed, 1830 insertions, 9 deletions
diff --git a/src/virtualkeyboard/abstractinputmethod.cpp b/src/virtualkeyboard/abstractinputmethod.cpp
index 3b74a927..88468a60 100644
--- a/src/virtualkeyboard/abstractinputmethod.cpp
+++ b/src/virtualkeyboard/abstractinputmethod.cpp
@@ -148,6 +148,54 @@ void AbstractInputMethod::selectionListItemSelected(DeclarativeSelectionListMode
}
/*!
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ Returns list of supported pattern recognition modes.
+
+ This method is called by the input engine to query the list of
+ supported pattern recognition modes.
+*/
+QList<DeclarativeInputEngine::PatternRecognitionMode> AbstractInputMethod::patternRecognitionModes() const
+{
+ return QList<DeclarativeInputEngine::PatternRecognitionMode>();
+}
+
+/*!
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ This method is called when a trace interaction starts with the specified \a patternRecognitionMode.
+ The \a traceCaptureDeviceInfo provides information about the source device and the
+ \a traceScreenInfo provides information about the screen context.
+
+ If the input method accepts the event and wants to capture the trace input, it must return
+ a new Trace object. This object must remain valid until the traceEnd() method is called. If the
+ Trace is rendered on screen, it remains there until the Trace object is destroyed.
+*/
+DeclarativeTrace *AbstractInputMethod::traceBegin(DeclarativeInputEngine::PatternRecognitionMode patternRecognitionMode,
+ const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo)
+{
+ Q_UNUSED(patternRecognitionMode)
+ Q_UNUSED(traceCaptureDeviceInfo)
+ Q_UNUSED(traceScreenInfo)
+ return 0;
+}
+
+/*!
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ This method is called when the trace interaction ends. The input method should destroy the \a trace object
+ at some point after this function is called. See the \l Trace API how to access the gathered
+ data.
+
+ The method returns \c true if the trace interaction was accepted.
+*/
+bool AbstractInputMethod::traceEnd(DeclarativeTrace *trace)
+{
+ Q_UNUSED(trace)
+ return false;
+}
+
+/*!
\fn QList<DeclarativeInputEngine::InputMode> AbstractInputMethod::inputModes(const QString& locale)
Returns the list of input modes for \a locale.
diff --git a/src/virtualkeyboard/abstractinputmethod.h b/src/virtualkeyboard/abstractinputmethod.h
index b7839d81..a4ad337a 100644
--- a/src/virtualkeyboard/abstractinputmethod.h
+++ b/src/virtualkeyboard/abstractinputmethod.h
@@ -56,6 +56,11 @@ public:
virtual QVariant selectionListData(DeclarativeSelectionListModel::Type type, int index, int role);
virtual void selectionListItemSelected(DeclarativeSelectionListModel::Type type, int index);
+ virtual QList<DeclarativeInputEngine::PatternRecognitionMode> patternRecognitionModes() const;
+ virtual DeclarativeTrace *traceBegin(DeclarativeInputEngine::PatternRecognitionMode patternRecognitionMode,
+ const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo);
+ virtual bool traceEnd(DeclarativeTrace *trace);
+
signals:
void selectionListChanged(int type);
void selectionListActiveItemChanged(int type, int index);
diff --git a/src/virtualkeyboard/content/components/HandwritingModeKey.qml b/src/virtualkeyboard/content/components/HandwritingModeKey.qml
new file mode 100644
index 00000000..7eb44a93
--- /dev/null
+++ b/src/virtualkeyboard/content/components/HandwritingModeKey.qml
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://www.qt.io
+**
+** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
+**
+** 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://www.qt.io
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+/*!
+ \qmltype HandwritingModeKey
+ \inqmlmodule QtQuick.Enterprise.VirtualKeyboard
+ \ingroup qtvirtualkeyboard-qml
+ \inherits Key
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ \brief Hand writing mode key for keyboard layouts.
+
+ This key toggles between the handwriting mode layout and the main layout.
+*/
+
+Key {
+ key: Qt.Key_Context2
+ displayText: "HWR"
+ functionKey: true
+ visible: VirtualKeyboardInputMethods.indexOf("HandwritingInputMethod") !== -1
+ onClicked: keyboard.handwritingMode = !keyboard.handwritingMode
+ keyPanelDelegate: keyboard.style ? keyboard.style.handwritingKeyPanel : undefined
+}
diff --git a/src/virtualkeyboard/content/components/Keyboard.qml b/src/virtualkeyboard/content/components/Keyboard.qml
index e9271b7e..c5d79556 100644
--- a/src/virtualkeyboard/content/components/Keyboard.qml
+++ b/src/virtualkeyboard/content/components/Keyboard.qml
@@ -44,10 +44,12 @@ Item {
if (InputContext.inputMethodHints & Qt.ImhFormattedNumbersOnly) return "numbers"
if (InputContext.inputMethodHints & Qt.ImhDigitsOnly) return "digits"
if (keyboard.symbolMode) return "symbols"
+ if (keyboard.handwritingMode) return "handwriting"
return "main"
}
property bool active: Qt.inputMethod.visible
property bool uppercased: InputContext.shift
+ property bool handwritingMode
property bool symbolMode
property var defaultInputMethod: initDefaultInputMethod()
property var plainInputMethod: PlainInputMethod {}
@@ -94,7 +96,7 @@ Item {
updateInputMethod()
}
onPreferNumbersChanged: {
- keyboard.symbolMode = preferNumbers
+ keyboard.symbolMode = !keyboard.handwritingMode && preferNumbers
if (!preferNumbers)
inputModeNeedsReset = true
updateInputMethod()
diff --git a/src/virtualkeyboard/content/components/TraceInputArea.qml b/src/virtualkeyboard/content/components/TraceInputArea.qml
new file mode 100644
index 00000000..7f54173f
--- /dev/null
+++ b/src/virtualkeyboard/content/components/TraceInputArea.qml
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://www.qt.io
+**
+** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
+**
+** 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://www.qt.io
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.2
+import QtQuick.Enterprise.VirtualKeyboard 1.4
+
+/*!
+ \qmltype TraceInputArea
+ \inqmlmodule QtQuick.Enterprise.VirtualKeyboard
+ \ingroup qtvirtualkeyboard-qml
+ \inherits MultiPointTouchArea
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ \brief A specialized MultiPointTouchArea for collecting touch input data.
+
+ This type handles the trace interaction between the touch screen and the input engine.
+
+ The traces are rendered using the delegate from the current style
+ \l {KeyboardStyle::traceCanvasDelegate} {KeyboardStyle.traceCanvasDelegate}.
+*/
+
+MultiPointTouchArea {
+ id: traceInputArea
+
+ /*! Pattern recognition mode of this input area.
+
+ The default value is \l {DeclarativeInputEngine::PatternRecognitionDisabled} {InputEngine.PatternRecognitionDisabled}.
+ */
+ property int patternRecognitionMode: InputEngine.PatternRecognitionDisabled
+
+ /*! List of horizontal rulers in the input area.
+
+ The rulers are defined as a number of pixels from the top edge of the boundingBox.
+
+ Here is an example how to define rulers:
+
+ \code
+ horizontalRulers: [boundingBox.height / 3, boundingBox.height / 3 * 2]
+ verticalRulers: [boundingBox.width / 3, boundingBox.width / 3 * 2]
+ \endcode
+ */
+ property var horizontalRulers
+
+ /*! List of vertical rulers in the input area.
+
+ The rulers are defined as a number of pixels from the left edge of the boundingBox.
+ */
+ property var verticalRulers
+
+ /*! Bounding box for the trace input.
+
+ This property is readonly and is automatically updated based on the item size
+ and margins.
+ */
+ readonly property rect boundingBox: (width > 0 && height > 0) ?
+ Qt.rect(traceInputArea.x + traceInputArea.anchors.leftMargin,
+ traceInputArea.y + traceInputArea.anchors.topMargin,
+ traceInputArea.width,
+ traceInputArea.height) :
+ Qt.rect(0, 0, 0, 0)
+
+ property var __traceCanvasList: ([])
+
+ /*! \internal */
+ function findTraceCanvasById(traceId) {
+ for (var i = 0; i < __traceCanvasList.length;) {
+ var traceCanvas = __traceCanvasList[i]
+ if (!traceCanvas || !traceCanvas.trace)
+ __traceCanvasList.splice(i, 1)
+ else if (traceCanvas.trace.traceId === traceId)
+ return traceCanvas
+ else
+ i++
+ }
+ return null
+ }
+
+ property var __traceCaptureDeviceInfo:
+ ({
+ channels: ['t'],
+ sampleRate: 60,
+ uniform: false,
+ latency: 0.0,
+ dpi: Screen.pixelDensity * 25.4
+ })
+ property var __traceScreenInfo:
+ ({
+ boundingBox: traceInputArea.boundingBox,
+ horizontalRulers: traceInputArea.horizontalRulers,
+ verticalRulers: traceInputArea.verticalRulers
+ })
+
+ enabled: patternRecognitionMode !== InputEngine.PatternRecognitionDisabled && InputContext.inputEngine.patternRecognitionModes.indexOf(patternRecognitionMode) !== -1
+
+ onPressed: {
+ if (!keyboard.style.traceCanvasDelegate)
+ return
+ for (var i = 0; i < touchPoints.length; i++) {
+ var trace = InputContext.inputEngine.traceBegin(touchPoints[i].pointId, patternRecognitionMode, __traceCaptureDeviceInfo, __traceScreenInfo)
+ if (trace) {
+ var traceCanvas = keyboard.style.traceCanvasDelegate.createObject(traceInputArea, { "trace": trace, "autoDestroy": true })
+ traceCanvas.anchors.fill = traceCanvas.parent
+ var index = trace.addPoint(Qt.point(touchPoints[i].x, touchPoints[i].y))
+ if (trace.channels.indexOf('t') !== -1) {
+ var dt = new Date()
+ trace.setChannelData('t', index, dt.getTime())
+ }
+ __traceCanvasList.push(traceCanvas)
+ }
+ }
+ }
+
+ onUpdated: {
+ for (var i = 0; i < touchPoints.length; i++) {
+ var traceCanvas = findTraceCanvasById(touchPoints[i].pointId)
+ if (traceCanvas) {
+ var trace = traceCanvas.trace
+ var index = trace.addPoint(Qt.point(touchPoints[i].x, touchPoints[i].y))
+ if (trace.channels.indexOf('t') !== -1) {
+ var dt = new Date()
+ trace.setChannelData('t', index, dt.getTime())
+ }
+ }
+ }
+ }
+
+ onReleased: {
+ for (var i = 0; i < touchPoints.length; i++) {
+ var traceCanvas = findTraceCanvasById(touchPoints[i].pointId)
+ if (traceCanvas) {
+ traceCanvas.trace.isFinal = true
+ __traceCanvasList.splice(__traceCanvasList.indexOf(traceCanvas), 1)
+ InputContext.inputEngine.traceEnd(traceCanvas.trace)
+ }
+ }
+ }
+
+ onCanceled: {
+ for (var i = 0; i < touchPoints.length; i++) {
+ var traceCanvas = findTraceCanvasById(touchPoints[i].pointId)
+ if (traceCanvas) {
+ traceCanvas.trace.isFinal = true
+ traceCanvas.trace.isCanceled = true
+ __traceCanvasList.splice(__traceCanvasList.indexOf(traceCanvas), 1)
+ InputContext.inputEngine.traceEnd(traceCanvas.trace)
+ }
+ }
+ }
+}
diff --git a/src/virtualkeyboard/content/components/TraceInputKey.qml b/src/virtualkeyboard/content/components/TraceInputKey.qml
new file mode 100644
index 00000000..9b22cd62
--- /dev/null
+++ b/src/virtualkeyboard/content/components/TraceInputKey.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://www.qt.io
+**
+** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
+**
+** 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://www.qt.io
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+
+/*!
+ \qmltype TraceInputKey
+ \inqmlmodule QtQuick.Enterprise.VirtualKeyboard
+ \ingroup qtvirtualkeyboard-qml
+ \inherits Item
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ \brief A specialized key for collecting touch input data.
+
+ This type can be placed in the keyboard layout. It collects
+ and renders touch input data (trace) from the key area.
+*/
+
+Item {
+ id: traceInputKey
+
+ /*! Sets the key weight value which determines the relative size of the key.
+
+ Use this property to change the key size in the layout.
+
+ The default value is inherited from the parent element
+ of the key in the layout hierarchy.
+ */
+ property real weight: parent.keyWeight
+
+ /*! Pattern recognition mode of this input area.
+
+ The default value is \l {DeclarativeInputEngine::PatternRecognitionDisabled} {InputEngine.PatternRecognitionDisabled}.
+ */
+ property alias patternRecognitionMode: traceInputArea.patternRecognitionMode
+
+ /*! List of horizontal rulers in the input area.
+
+ The rulers are defined as a number of pixels from the top edge of the bounding box.
+
+ Here is an example how to define rulers:
+
+ \code
+ horizontalRulers: [boundingBox.height / 3, boundingBox.height / 3 * 2]
+ verticalRulers: [boundingBox.width / 3, boundingBox.width / 3 * 2]
+ \endcode
+ */
+ property alias horizontalRulers: traceInputArea.horizontalRulers
+
+ /*! List of vertical rulers in the input area.
+
+ The rulers are defined as a number of pixels from the left edge of the bounding box.
+ */
+ property alias verticalRulers: traceInputArea.verticalRulers
+
+ /*! Bounding box for the trace input.
+
+ This property is readonly and is automatically updated based on the item size
+ and margins.
+ */
+ readonly property alias boundingBox: traceInputArea.boundingBox
+
+ Layout.minimumWidth: traceInputKeyPanel.implicitWidth
+ Layout.minimumHeight: traceInputKeyPanel.implicitHeight
+ Layout.preferredWidth: weight
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ Loader {
+ id: traceInputKeyPanel
+ sourceComponent: keyboard.style.traceInputKeyPanelDelegate
+ anchors.fill: parent
+ onStatusChanged: if (status == Loader.Ready) traceInputKeyPanel.item.control = traceInputKey
+ }
+
+ TraceInputArea {
+ id: traceInputArea
+ anchors.fill: traceInputKeyPanel
+ anchors.margins: traceInputKeyPanel.item ? traceInputKeyPanel.item.traceMargins : 0
+ }
+}
diff --git a/src/virtualkeyboard/content/content.qrc b/src/virtualkeyboard/content/content.qrc
index 51ec1896..6c23d86a 100644
--- a/src/virtualkeyboard/content/content.qrc
+++ b/src/virtualkeyboard/content/content.qrc
@@ -22,5 +22,8 @@
<file>components/ShiftKey.qml</file>
<file>components/SpaceKey.qml</file>
<file>components/SymbolModeKey.qml</file>
+ <file>components/TraceInputKey.qml</file>
+ <file>components/TraceInputArea.qml</file>
+ <file>components/HandwritingModeKey.qml</file>
</qresource>
</RCC>
diff --git a/src/virtualkeyboard/content/styles/default/default_style.qrc b/src/virtualkeyboard/content/styles/default/default_style.qrc
index 8c691ce6..c6762b54 100644
--- a/src/virtualkeyboard/content/styles/default/default_style.qrc
+++ b/src/virtualkeyboard/content/styles/default/default_style.qrc
@@ -5,10 +5,12 @@
<file>images/check-868482.svg</file>
<file>images/enter-868482.svg</file>
<file>images/globe-868482.svg</file>
+ <file>images/handwriting-868482.svg</file>
<file>images/hidekeyboard-868482.svg</file>
<file>images/search-868482.svg</file>
<file>images/shift-80c342.svg</file>
<file>images/shift-868482.svg</file>
<file>images/shift-c5d6b6.svg</file>
+ <file>images/textmode-868482.svg</file>
</qresource>
</RCC>
diff --git a/src/virtualkeyboard/content/styles/default/images/handwriting-868482.svg b/src/virtualkeyboard/content/styles/default/images/handwriting-868482.svg
new file mode 100644
index 00000000..d7af73ca
--- /dev/null
+++ b/src/virtualkeyboard/content/styles/default/images/handwriting-868482.svg
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 18.1.1, 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"
+ viewBox="0 0 156 104" enable-background="new 0 0 156 104" xml:space="preserve">
+<g>
+ <g>
+ <path fill="#868482" d="M37.6,103.3c-10.1,0-18.9-5-23.1-13.6C4.4,68.7,19.9,52.3,36.2,35c1.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.6L0,36.6C0.3,35.3,6.4,4.3,31.2,0.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.8C28.3,60.9,19.1,71.6,25.4,84.5
+ 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.3C42.5,103,40,103.3,37.6,103.3z M119.8,53.7
+ c-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.2C117.3,72.2,120.3,62.6,119.8,53.7z"/>
+ </g>
+ <rect fill="none" width="156" height="104"/>
+</g>
+</svg>
diff --git a/src/virtualkeyboard/content/styles/default/images/textmode-868482.svg b/src/virtualkeyboard/content/styles/default/images/textmode-868482.svg
new file mode 100644
index 00000000..2f9428c2
--- /dev/null
+++ b/src/virtualkeyboard/content/styles/default/images/textmode-868482.svg
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 18.1.1, 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="124px" height="96px" viewBox="0 0 124 96" enable-background="new 0 0 124 96" xml:space="preserve">
+<g>
+ <g>
+ <g>
+ <path fill="#868482" d="M55.4,70.8L46.9,49H19.4L11,70.8H2.9L30,2h6.7l27,68.8H55.4z M44.4,41.8l-8-21.2c-1-2.7-2.1-6-3.2-9.9
+ c-0.7,3-1.7,6.3-3,9.9l-8.1,21.2H44.4z"/>
+ <path fill="#868482" d="M66.6,72.8H54.1L45.5,51H20.8l-8.4,21.8H0L28.7,0h9.4L66.6,72.8z M56.8,68.8h4L35.4,4h-1.9l1.7,6.2
+ c1.1,3.8,2.1,7.1,3.1,9.7l9,24h-28l9.1-23.9c1.2-3.5,2.2-6.7,2.9-9.6L32.8,4h-1.4L5.9,68.8h3.8L18.1,47h30.2L56.8,68.8z
+ M25.1,39.8h16.4l-7-18.5c-0.4-1.1-0.8-2.2-1.2-3.4c-0.4,1.1-0.7,2.2-1.2,3.4L25.1,39.8z"/>
+ </g>
+ <g>
+ <path fill="#868482" d="M116.2,70.8l-1.5-7.3h-0.4c-2.6,3.2-5.1,5.4-7.7,6.5s-5.7,1.7-9.5,1.7c-5.1,0-9.1-1.3-12-3.9
+ s-4.3-6.4-4.3-11.2c0-10.4,8.3-15.8,24.9-16.3l8.7-0.3v-3.2c0-4-0.9-7-2.6-8.9s-4.5-2.9-8.3-2.9c-4.3,0-9.1,1.3-14.5,3.9l-2.4-6
+ c2.5-1.4,5.3-2.5,8.3-3.2s6-1.2,9.1-1.2c6.1,0,10.7,1.4,13.6,4.1s4.4,7.1,4.4,13.1v35.1H116.2z M98.7,65.3c4.8,0,8.6-1.3,11.4-4
+ s4.1-6.4,4.1-11.2v-4.6l-7.8,0.3c-6.2,0.2-10.6,1.2-13.4,2.9S89,53.1,89,56.7c0,2.8,0.9,5,2.6,6.4S95.6,65.3,98.7,65.3z"/>
+ <path fill="#868482" d="M97.1,73.8c-5.6,0-10.1-1.5-13.3-4.5c-3.3-3-5-7.3-5-12.7c0-11.6,9-17.8,26.8-18.3l6.8-0.2v-1.3
+ c0-3.5-0.7-6.1-2.1-7.6c-1.3-1.5-3.6-2.2-6.8-2.2c-4,0-8.6,1.3-13.7,3.7l-1.9,0.9L84,22.1l1.6-0.8c2.7-1.4,5.6-2.6,8.8-3.4
+ c3.2-0.8,6.4-1.2,9.6-1.2c6.6,0,11.7,1.6,15,4.6c3.4,3.1,5.1,8,5.1,14.5v37.1h-9.4l-1.1-5.3c-2,2-4,3.5-6,4.4
+ C104.7,73.1,101.2,73.8,97.1,73.8z M103.5,23c4.4,0,7.7,1.2,9.8,3.5c2.1,2.3,3.1,5.7,3.1,10.3V42l-10.7,0.3
+ c-23,0.7-23,10.9-23,14.3c0,4.3,1.2,7.5,3.7,9.7c2.5,2.3,6.1,3.4,10.6,3.4c3.5,0,6.4-0.5,8.7-1.5c2.2-1,4.6-3,6.9-6l0.6-0.8h2.6
+ l0.7,1.6l1.2,5.7h2.1V35.8c0-5.4-1.3-9.3-3.8-11.6c-2.6-2.4-6.7-3.5-12.3-3.5c-2.8,0-5.7,0.4-8.6,1.1c-2.2,0.6-4.3,1.3-6.3,2.3
+ l0.9,2.3C94.9,24.1,99.4,23,103.5,23z M98.7,67.3c-3.5,0-6.4-0.9-8.5-2.7C88,62.8,87,60.1,87,56.7c0-4.3,1.7-7.6,5-9.6
+ c3.1-1.9,7.8-3,14.4-3.2l9.9-0.4v6.7c0,5.3-1.6,9.6-4.8,12.6C108.3,65.8,104,67.3,98.7,67.3z M112.2,47.6l-5.7,0.2
+ c-5.8,0.2-10,1.1-12.4,2.6C92,51.8,91,53.8,91,56.7c0,2.2,0.6,3.8,1.9,4.9c1.3,1.1,3.3,1.7,5.8,1.7c4.3,0,7.6-1.1,10-3.4
+ c2.4-2.3,3.5-5.5,3.5-9.7V47.6z"/>
+ </g>
+ </g>
+ <rect y="88" fill="#868482" width="124" height="8"/>
+</g>
+</svg>
diff --git a/src/virtualkeyboard/content/styles/default/style.qml b/src/virtualkeyboard/content/styles/default/style.qml
index e0556404..b1f1a623 100644
--- a/src/virtualkeyboard/content/styles/default/style.qml
+++ b/src/virtualkeyboard/content/styles/default/style.qml
@@ -17,8 +17,8 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Enterprise.VirtualKeyboard 1.3
-import QtQuick.Enterprise.VirtualKeyboard.Styles 1.3
+import QtQuick.Enterprise.VirtualKeyboard 1.4
+import QtQuick.Enterprise.VirtualKeyboard.Styles 1.4
KeyboardStyle {
id: currentStyle
@@ -487,6 +487,51 @@ KeyboardStyle {
]
}
+ handwritingKeyPanel: KeyPanel {
+ Rectangle {
+ id: hwrKeyBackground
+ radius: 5
+ color: "#35322f"
+ anchors.fill: parent
+ anchors.margins: keyBackgroundMargin
+ Image {
+ id: hwrKeyIcon
+ anchors.centerIn: parent
+ readonly property size hwrKeyIconSize: keyboard.handwritingMode ? Qt.size(124, 96) : Qt.size(156, 104)
+ sourceSize.width: hwrKeyIconSize.width * keyIconScale
+ sourceSize.height: hwrKeyIconSize.height * keyIconScale
+ smooth: false
+ source: resourcePrefix + (keyboard.handwritingMode ? "images/textmode-868482.svg" : "images/handwriting-868482.svg")
+ }
+ }
+ states: [
+ State {
+ name: "pressed"
+ when: control.pressed
+ PropertyChanges {
+ target: hwrKeyBackground
+ opacity: 0.80
+ }
+ PropertyChanges {
+ target: hwrKeyIcon
+ opacity: 0.6
+ }
+ },
+ State {
+ name: "disabled"
+ when: !control.enabled
+ PropertyChanges {
+ target: hwrKeyBackground
+ opacity: 0.8
+ }
+ PropertyChanges {
+ target: hwrKeyIcon
+ opacity: 0.2
+ }
+ }
+ ]
+ }
+
characterPreviewMargin: 0
characterPreviewDelegate: Item {
property string text
@@ -607,4 +652,80 @@ KeyboardStyle {
border.color: "yellow"
border.width: 5
}
+
+ traceInputKeyPanelDelegate: TraceInputKeyPanel {
+ traceMargins: keyBackgroundMargin
+ Rectangle {
+ id: traceInputKeyPanelBackground
+ radius: 5
+ color: "#35322f"
+ anchors.fill: parent
+ anchors.margins: keyBackgroundMargin
+ Text {
+ id: hwrInputModeIndicator
+ visible: control.patternRecognitionMode === InputEngine.HandwritingRecoginition
+ text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "Abc" : "123"
+ color: "white"
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: keyContentMargin
+ font {
+ family: fontFamily
+ weight: Font.Normal
+ pixelSize: 44 * scaleHint
+ capitalization: {
+ if (InputContext.capsLock)
+ return Font.AllUppercase
+ if (InputContext.shift)
+ return Font.MixedCase
+ return Font.AllLowercase
+ }
+ }
+ }
+ }
+ Canvas {
+ id: traceInputKeyGuideLines
+ anchors.fill: traceInputKeyPanelBackground
+ opacity: 0.1
+ onPaint: {
+ var ctx = getContext("2d")
+ ctx.lineWidth = 1
+ ctx.strokeStyle = Qt.rgba(0xFF, 0xFF, 0xFF)
+ ctx.clearRect(0, 0, width, height)
+ var i
+ if (control.horizontalRulers) {
+ for (i = 0; i < control.horizontalRulers.length; i++) {
+ ctx.beginPath()
+ ctx.moveTo(0, control.horizontalRulers[i])
+ ctx.lineTo(width, control.horizontalRulers[i])
+ ctx.stroke()
+ }
+ }
+ if (control.verticalRulers) {
+ for (i = 0; i < control.verticalRulers.length; i++) {
+ ctx.beginPath()
+ ctx.moveTo(control.verticalRulers[i], 0)
+ ctx.lineTo(control.verticalRulers[i], height)
+ ctx.stroke()
+ }
+ }
+ }
+ }
+ }
+
+ traceCanvasDelegate: TraceCanvas {
+ id: traceCanvas
+ onAvailableChanged: {
+ if (!available)
+ return
+ var ctx = getContext("2d")
+ ctx.lineWidth = 10 * scaleHint
+ ctx.lineCap = "round"
+ ctx.strokeStyle = Qt.rgba(0xFF, 0xFF, 0xFF)
+ ctx.fillStyle = ctx.strokeStyle
+ }
+ autoDestroyDelay: 800
+ onTraceChanged: if (trace === null) opacity = 0
+ Behavior on opacity { PropertyAnimation { easing.type: Easing.OutCubic; duration: 150 } }
+ }
}
diff --git a/src/virtualkeyboard/content/styles/retro/images/handwriting-110b05.svg b/src/virtualkeyboard/content/styles/retro/images/handwriting-110b05.svg
new file mode 100644
index 00000000..d19c4da7
--- /dev/null
+++ b/src/virtualkeyboard/content/styles/retro/images/handwriting-110b05.svg
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 18.1.1, 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="156px" height="104px" viewBox="0 0 156 104" enable-background="new 0 0 156 104" xml:space="preserve">
+<g>
+ <rect fill="none" width="156" height="104"/>
+ <g>
+ <path fill="#110B05" d="M37.6,103.3c-10.1,0-18.9-5-23.1-13.6C4.4,68.7,19.9,52.3,36.2,35c1.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.6L0,36.6C0.3,35.3,6.4,4.3,31.2,0.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.8C28.3,60.9,19.1,71.6,25.4,84.5
+ 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.3C42.5,103,40,103.3,37.6,103.3z M119.8,53.7
+ c-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.2C117.3,72.2,120.3,62.6,119.8,53.7z"/>
+ </g>
+</g>
+</svg>
diff --git a/src/virtualkeyboard/content/styles/retro/images/key154px_colorA.svg b/src/virtualkeyboard/content/styles/retro/images/key154px_colorA.svg
new file mode 100644
index 00000000..13af8a63
--- /dev/null
+++ b/src/virtualkeyboard/content/styles/retro/images/key154px_colorA.svg
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 18.1.1, 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"
+ viewBox="0 0 154 154" enable-background="new 0 0 154 154" xml:space="preserve">
+<g>
+ <radialGradient id="SVGID_1_" cx="77" cy="77" r="73" gradientUnits="userSpaceOnUse">
+ <stop offset="0" style="stop-color:#CFBE90"/>
+ <stop offset="1" style="stop-color:#B2945A"/>
+ </radialGradient>
+ <path fill="url(#SVGID_1_)" d="M77,150c-40.3,0-73-32.7-73-73C4,36.7,36.7,4,77,4c40.3,0,73,32.7,73,73C150,117.3,117.3,150,77,150
+ z"/>
+ <path fill="#C2B49B" d="M77,8c38,0,69,31,69,69s-31,69-69,69S8,115,8,77S39,8,77,8 M77,0C34.5,0,0,34.5,0,77s34.5,77,77,77
+ s77-34.5,77-77S119.5,0,77,0L77,0z"/>
+</g>
+<g opacity="8.000000e-02">
+ <path d="M77,16c33.6,0,61,27.4,61,61s-27.4,61-61,61s-61-27.4-61-61S43.4,16,77,16 M77,8C38.9,8,8,38.9,8,77s30.9,69,69,69
+ s69-30.9,69-69S115.1,8,77,8L77,8z"/>
+</g>
+</svg>
diff --git a/src/virtualkeyboard/content/styles/retro/images/textmode-110b05.svg b/src/virtualkeyboard/content/styles/retro/images/textmode-110b05.svg
new file mode 100644
index 00000000..b891d960
--- /dev/null
+++ b/src/virtualkeyboard/content/styles/retro/images/textmode-110b05.svg
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 18.1.1, 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="124px" height="96px" viewBox="0 0 124 96" enable-background="new 0 0 124 96" xml:space="preserve">
+<g>
+ <g>
+ <g>
+ <path fill="#110B05" d="M55.4,70.8L46.9,49H19.4L11,70.8H2.9L30,2h6.7l27,68.8H55.4z M44.4,41.8l-8-21.2c-1-2.7-2.1-6-3.2-9.9
+ c-0.7,3-1.7,6.3-3,9.9l-8.1,21.2H44.4z"/>
+ <path fill="#110B05" d="M66.6,72.8H54.1L45.5,51H20.8l-8.4,21.8H0L28.7,0h9.4L66.6,72.8z M56.8,68.8h4L35.4,4h-1.9l1.7,6.2
+ c1.1,3.8,2.1,7.1,3.1,9.7l9,24h-28l9.1-23.9c1.2-3.5,2.2-6.7,2.9-9.6L32.8,4h-1.4L5.9,68.8h3.8L18.1,47h30.2L56.8,68.8z
+ M25.1,39.8h16.4l-7-18.5c-0.4-1.1-0.8-2.2-1.2-3.4c-0.4,1.1-0.7,2.2-1.2,3.4L25.1,39.8z"/>
+ </g>
+ <g>
+ <path fill="#110B05" d="M116.2,70.8l-1.5-7.3h-0.4c-2.6,3.2-5.1,5.4-7.7,6.5s-5.7,1.7-9.5,1.7c-5.1,0-9.1-1.3-12-3.9
+ s-4.3-6.4-4.3-11.2c0-10.4,8.3-15.8,24.9-16.3l8.7-0.3v-3.2c0-4-0.9-7-2.6-8.9s-4.5-2.9-8.3-2.9c-4.3,0-9.1,1.3-14.5,3.9l-2.4-6
+ c2.5-1.4,5.3-2.5,8.3-3.2s6-1.2,9.1-1.2c6.1,0,10.7,1.4,13.6,4.1s4.4,7.1,4.4,13.1v35.1H116.2z M98.7,65.3c4.8,0,8.6-1.3,11.4-4
+ s4.1-6.4,4.1-11.2v-4.6l-7.8,0.3c-6.2,0.2-10.6,1.2-13.4,2.9S89,53.1,89,56.7c0,2.8,0.9,5,2.6,6.4S95.6,65.3,98.7,65.3z"/>
+ <path fill="#110B05" d="M97.1,73.8c-5.6,0-10.1-1.5-13.3-4.5c-3.3-3-5-7.3-5-12.7c0-11.6,9-17.8,26.8-18.3l6.8-0.2v-1.3
+ c0-3.5-0.7-6.1-2.1-7.6c-1.3-1.5-3.6-2.2-6.8-2.2c-4,0-8.6,1.3-13.7,3.7l-1.9,0.9L84,22.1l1.6-0.8c2.7-1.4,5.6-2.6,8.8-3.4
+ c3.2-0.8,6.4-1.2,9.6-1.2c6.6,0,11.7,1.6,15,4.6c3.4,3.1,5.1,8,5.1,14.5v37.1h-9.4l-1.1-5.3c-2,2-4,3.5-6,4.4
+ C104.7,73.1,101.2,73.8,97.1,73.8z M103.5,23c4.4,0,7.7,1.2,9.8,3.5c2.1,2.3,3.1,5.7,3.1,10.3V42l-10.7,0.3
+ c-23,0.7-23,10.9-23,14.3c0,4.3,1.2,7.5,3.7,9.7c2.5,2.3,6.1,3.4,10.6,3.4c3.5,0,6.4-0.5,8.7-1.5c2.2-1,4.6-3,6.9-6l0.6-0.8h2.6
+ l0.7,1.6l1.2,5.7h2.1V35.8c0-5.4-1.3-9.3-3.8-11.6c-2.6-2.4-6.7-3.5-12.3-3.5c-2.8,0-5.7,0.4-8.6,1.1c-2.2,0.6-4.3,1.3-6.3,2.3
+ l0.9,2.3C94.9,24.1,99.4,23,103.5,23z M98.7,67.3c-3.5,0-6.4-0.9-8.5-2.7C88,62.8,87,60.1,87,56.7c0-4.3,1.7-7.6,5-9.6
+ c3.1-1.9,7.8-3,14.4-3.2l9.9-0.4v6.7c0,5.3-1.6,9.6-4.8,12.6C108.3,65.8,104,67.3,98.7,67.3z M112.2,47.6l-5.7,0.2
+ c-5.8,0.2-10,1.1-12.4,2.6C92,51.8,91,53.8,91,56.7c0,2.2,0.6,3.8,1.9,4.9c1.3,1.1,3.3,1.7,5.8,1.7c4.3,0,7.6-1.1,10-3.4
+ c2.4-2.3,3.5-5.5,3.5-9.7V47.6z"/>
+ </g>
+ </g>
+ <rect y="88" fill="#110B05" width="124" height="8"/>
+</g>
+</svg>
diff --git a/src/virtualkeyboard/content/styles/retro/retro_style.qrc b/src/virtualkeyboard/content/styles/retro/retro_style.qrc
index 82056d00..0de3a9f9 100644
--- a/src/virtualkeyboard/content/styles/retro/retro_style.qrc
+++ b/src/virtualkeyboard/content/styles/retro/retro_style.qrc
@@ -7,6 +7,7 @@
<file>images/key154px_capslock.png</file>
<file>images/key154px_colorA_long.png</file>
<file>images/key154px_colorA.png</file>
+ <file>images/key154px_colorA.svg</file>
<file>images/key154px_colorB.png</file>
<file>images/key154px_shiftcase_long.png</file>
<file>images/key154px_shiftcase.png</file>
@@ -24,10 +25,12 @@
<file>images/check-c5a96f.svg</file>
<file>images/enter-c5a96f.svg</file>
<file>images/globe-110b05.svg</file>
+ <file>images/handwriting-110b05.svg</file>
<file>images/hidekeyboard-c5a96f.svg</file>
<file>images/search-c5a96f.svg</file>
<file>images/shift-c5a96f.svg</file>
<file>images/shift-cd8865.svg</file>
<file>images/shift-dc4f28.svg</file>
+ <file>images/textmode-110b05.svg</file>
</qresource>
</RCC>
diff --git a/src/virtualkeyboard/content/styles/retro/style.qml b/src/virtualkeyboard/content/styles/retro/style.qml
index 7af2fe81..82a6ebcd 100644
--- a/src/virtualkeyboard/content/styles/retro/style.qml
+++ b/src/virtualkeyboard/content/styles/retro/style.qml
@@ -17,8 +17,8 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Enterprise.VirtualKeyboard 1.3
-import QtQuick.Enterprise.VirtualKeyboard.Styles 1.3
+import QtQuick.Enterprise.VirtualKeyboard 1.4
+import QtQuick.Enterprise.VirtualKeyboard.Styles 1.4
KeyboardStyle {
id: currentStyle
@@ -27,7 +27,8 @@ KeyboardStyle {
readonly property real keyBackgroundMargin: Math.round(9 * scaleHint)
readonly property real keyContentMargin: Math.round(50 * scaleHint)
readonly property real keyIconScale: scaleHint * 0.6
- readonly property string resourcePrefix: "qrc:/content/styles/retro/"
+ readonly property string resourcePath: "content/styles/retro/"
+ readonly property string resourcePrefix: "qrc:/" + resourcePath
readonly property string inputLocale: InputContext.locale
property color inputLocaleIndicatorColor: "#110b05"
@@ -560,6 +561,57 @@ KeyboardStyle {
]
}
+ handwritingKeyPanel: KeyPanel {
+ BorderImage {
+ id: hwrKeyBackground
+ source: resourcePrefix + "images/key154px_colorB.png"
+ width: (parent.width - 2 * hwrKeyBackground) / scale
+ height: sourceSize.height
+ anchors.centerIn: parent
+ border.left: 76
+ border.top: 76
+ border.right: 76
+ border.bottom: 76
+ horizontalTileMode: BorderImage.Stretch
+ scale: (parent.height - 2 * keyBackgroundMargin) / sourceSize.height
+ }
+ Image {
+ id: hwrKeyIcon
+ anchors.centerIn: parent
+ readonly property size hwrKeyIconSize: keyboard.handwritingMode ? Qt.size(124, 96) : Qt.size(156, 104)
+ sourceSize.width: hwrKeyIconSize.width * keyIconScale
+ sourceSize.height: hwrKeyIconSize.height * keyIconScale
+ smooth: false
+ source: resourcePrefix + (keyboard.handwritingMode ? "images/textmode-110b05.svg" : "images/handwriting-110b05.svg")
+ }
+ states: [
+ State {
+ name: "pressed"
+ when: control.pressed
+ PropertyChanges {
+ target: hwrKeyBackground
+ opacity: 0.70
+ }
+ PropertyChanges {
+ target: hwrKeyIcon
+ opacity: 0.70
+ }
+ },
+ State {
+ name: "disabled"
+ when: !control.enabled
+ PropertyChanges {
+ target: hwrKeyBackground
+ opacity: 0.20
+ }
+ PropertyChanges {
+ target: hwrKeyIcon
+ opacity: 0.20
+ }
+ }
+ ]
+ }
+
characterPreviewMargin: Math.round(20 * scaleHint)
characterPreviewDelegate: Item {
property string text
@@ -723,4 +775,87 @@ KeyboardStyle {
border.color: "yellow"
border.width: 5
}
+
+ traceInputKeyPanelDelegate: TraceInputKeyPanel {
+ traceMargins: keyBackgroundMargin
+ BorderImage {
+ id: traceInputKeyPanelBackground
+ readonly property int traceInputKeyPanelSvgImageHeight: Math.round(height / 12)
+ readonly property real traceInputKeyPanelSvgImageScale: traceInputKeyPanelSvgImageHeight / 154
+ source: "image://qtvkbsvg/%1/images/key154px_colorA.svg?height=%2".arg(resourcePath).arg(traceInputKeyPanelSvgImageHeight)
+ anchors.fill: parent
+ anchors.margins: keyBackgroundMargin
+ border.left: 76 * traceInputKeyPanelSvgImageScale
+ border.top: 76 * traceInputKeyPanelSvgImageScale
+ border.right: 78 * traceInputKeyPanelSvgImageScale
+ border.bottom: 78 * traceInputKeyPanelSvgImageScale
+ horizontalTileMode: BorderImage.Stretch
+ verticalTileMode: BorderImage.Stretch
+ }
+ Text {
+ id: hwrInputModeIndicator
+ visible: control.patternRecognitionMode === InputEngine.HandwritingRecoginition
+ text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "Abc" : "123"
+ color: "black"
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: keyContentMargin * 1.5
+ font {
+ family: fontFamily
+ weight: Font.Bold
+ pixelSize: 72 * scaleHint
+ capitalization: {
+ if (InputContext.capsLock)
+ return Font.AllUppercase
+ if (InputContext.shift)
+ return Font.MixedCase
+ return Font.AllLowercase
+ }
+ }
+ }
+ Canvas {
+ id: traceInputKeyGuideLines
+ anchors.fill: traceInputKeyPanelBackground
+ opacity: 0.1
+ onPaint: {
+ var ctx = getContext("2d")
+ ctx.lineWidth = 1
+ ctx.strokeStyle = Qt.rgba(0xFF, 0xFF, 0xFF)
+ ctx.clearRect(0, 0, width, height)
+ var i
+ if (control.horizontalRulers) {
+ for (i = 0; i < control.horizontalRulers.length; i++) {
+ ctx.beginPath()
+ ctx.moveTo(0, control.horizontalRulers[i])
+ ctx.lineTo(width, control.horizontalRulers[i])
+ ctx.stroke()
+ }
+ }
+ if (control.verticalRulers) {
+ for (i = 0; i < control.verticalRulers.length; i++) {
+ ctx.beginPath()
+ ctx.moveTo(control.verticalRulers[i], 0)
+ ctx.lineTo(control.verticalRulers[i], height)
+ ctx.stroke()
+ }
+ }
+ }
+ }
+ }
+
+ traceCanvasDelegate: TraceCanvas {
+ id: traceCanvas
+ onAvailableChanged: {
+ if (!available)
+ return
+ var ctx = getContext("2d")
+ ctx.lineWidth = 10 * scaleHint
+ ctx.lineCap = "round"
+ ctx.strokeStyle = Qt.rgba(0, 0, 0)
+ ctx.fillStyle = ctx.strokeStyle
+ }
+ autoDestroyDelay: 800
+ onTraceChanged: if (trace === null) opacity = 0
+ Behavior on opacity { PropertyAnimation { easing.type: Easing.OutCubic; duration: 150 } }
+ }
}
diff --git a/src/virtualkeyboard/declarativeinputengine.cpp b/src/virtualkeyboard/declarativeinputengine.cpp
index 9b4c3eab..c9644ce1 100644
--- a/src/virtualkeyboard/declarativeinputengine.cpp
+++ b/src/virtualkeyboard/declarativeinputengine.cpp
@@ -19,6 +19,7 @@
#include "declarativeinputengine.h"
#include "declarativeinputcontext.h"
#include "defaultinputmethod.h"
+#include "declarativetrace.h"
#include "virtualkeyboarddebug.h"
#include <QTimerEvent>
@@ -384,6 +385,7 @@ void DeclarativeInputEngine::setInputMethod(AbstractInputMethod *inputMethod)
}
emit inputMethodChanged();
emit inputModesChanged();
+ emit patternRecognitionModesChanged();
}
}
@@ -447,6 +449,113 @@ bool DeclarativeInputEngine::wordCandidateListVisibleHint() const
}
/*!
+ Returns list of supported pattern recognition modes.
+*/
+QList<int> DeclarativeInputEngine::patternRecognitionModes() const
+{
+ Q_D(const DeclarativeInputEngine);
+ QList<PatternRecognitionMode> patterRecognitionModeList;
+ if (d->inputMethod)
+ patterRecognitionModeList = d->inputMethod->patternRecognitionModes();
+ if (patterRecognitionModeList.isEmpty())
+ return QList<int>();
+ QList<int> resultList;
+ foreach (const PatternRecognitionMode &patternRecognitionMode, patterRecognitionModeList)
+ resultList.append(patternRecognitionMode);
+ return resultList;
+}
+
+/*!
+ \qmlmethod Trace InputEngine::traceBegin(int patternRecognitionMode, var traceCaptureDeviceInfo, var traceScreenInfo)
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ Starts a trace interaction with the input engine.
+
+ The trace is uniquely identified by the \a traceId. The input engine will assign
+ the id to the Trace object if the input method accepts the event.
+
+ The \a patternRecognitionMode specifies the recognition mode used for the pattern.
+
+ If the current input method accepts the event it returns a Trace object associated with this interaction.
+ If the input method discards the event, it returns a null value.
+
+ The \a traceCaptureDeviceInfo provides information about the source device and the \a traceScreenInfo
+ provides information about the screen context.
+
+ By definition, the Trace object remains valid until the traceEnd() method is called.
+
+ The trace interaction is ended by calling the \l {InputEngine::traceEnd()} {InputEngine.traceEnd()} method.
+*/
+/*!
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ Starts a trace interaction with the input engine.
+
+ The trace is uniquely identified by the \a traceId. The input engine will assign
+ the id to the Trace object if the input method accepts the event.
+
+ The \a patternRecognitionMode specifies the recognition mode used for the pattern.
+
+ If the current input method accepts the event it returns a Trace object associated with this interaction.
+ If the input method discards the event, it returns a NULL value.
+
+ The \a traceCaptureDeviceInfo provides information about the source device and the \a traceScreenInfo
+ provides information about the screen context.
+
+ By definition, the Trace object remains valid until the traceEnd() method is called.
+
+ The trace interaction is ended by calling the traceEnd() method.
+*/
+DeclarativeTrace *DeclarativeInputEngine::traceBegin(int traceId, DeclarativeInputEngine::PatternRecognitionMode patternRecognitionMode,
+ const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo)
+{
+ Q_D(DeclarativeInputEngine);
+ VIRTUALKEYBOARD_DEBUG() << "DeclarativeInputEngine::traceBegin():"
+ << "traceId:" << traceId
+ << "patternRecognitionMode:" << patternRecognitionMode
+ << "traceCaptureDeviceInfo:" << traceCaptureDeviceInfo
+ << "traceScreenInfo:" << traceScreenInfo;
+ if (!d->inputMethod)
+ return 0;
+ if (patternRecognitionMode == PatternRecognitionDisabled)
+ return 0;
+ if (!d->inputMethod->patternRecognitionModes().contains(patternRecognitionMode))
+ return 0;
+ DeclarativeTrace *trace = d->inputMethod->traceBegin(patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo);
+ if (trace)
+ trace->setTraceId(traceId);
+ return trace;
+}
+
+/*!
+ \qmlmethod bool InputEngine::traceEnd(Trace trace)
+
+ Ends the trace interaction with the input engine.
+
+ The \a trace object may be discarded at any point after calling this function.
+
+ The function returns true if the trace interaction was accepted (i.e. the touch
+ events should not be used for anything else).
+*/
+/*!
+ Ends the trace interaction with the input engine.
+
+ The \a trace object may be discarded at any point after calling this function.
+
+ The function returns true if the trace interaction was accepted (i.e. the touch
+ events should not be used for anything else).
+*/
+bool DeclarativeInputEngine::traceEnd(DeclarativeTrace *trace)
+{
+ Q_D(DeclarativeInputEngine);
+ VIRTUALKEYBOARD_DEBUG() << "DeclarativeInputEngine::traceEnd():" << trace;
+ Q_ASSERT(trace);
+ if (!d->inputMethod)
+ return false;
+ return d->inputMethod->traceEnd(trace);
+}
+
+/*!
\internal
Resets the input method.
*/
@@ -657,6 +766,17 @@ void DeclarativeInputEngine::timerEvent(QTimerEvent *timerEvent)
*/
/*!
+ \enum DeclarativeInputEngine::PatternRecognitionMode
+
+ This enum specifies the input mode for the input method.
+
+ \value PatternRecognitionDisabled
+ Pattern recognition is not available.
+ \value HandwritingRecoginition
+ Pattern recognition mode for handwriting recognition.
+*/
+
+/*!
\qmlsignal void InputEngine::virtualKeyClicked(int key, string text, int modifiers)
Indicates that the virtual \a key was clicked with the given \a text and
@@ -674,6 +794,21 @@ void DeclarativeInputEngine::timerEvent(QTimerEvent *timerEvent)
*/
/*!
+ \qmlproperty list<int> InputEngine::patternRecognitionModes
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ The list of available pattern recognition modes.
+*/
+
+/*!
+ \property DeclarativeInputEngine::patternRecognitionModes
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+ \brief the list of available pattern recognition modes.
+
+ The list of available pattern recognition modes.
+*/
+
+/*!
\qmlsignal void InputEngine::activeKeyChanged(int key)
Indicates that the active \a key has changed.
@@ -764,3 +899,24 @@ void DeclarativeInputEngine::timerEvent(QTimerEvent *timerEvent)
Indicates that the input mode has changed.
*/
+
+/*!
+ \qmlsignal void InputEngine::patternRecognitionModesChanged()
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ Indicates that the available pattern recognition modes have changed.
+
+ The predefined pattern recognition modes are:
+
+ \list
+ \li \c InputEngine.PatternRecognitionDisabled Pattern recognition is not available.
+ \li \c InputEngine.HandwritingRecoginition Pattern recognition mode for handwriting recognition.
+ \endlist
+*/
+
+/*!
+ \fn void DeclarativeInputEngine::patternRecognitionModesChanged()
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ Indicates that the available pattern recognition modes have changed.
+*/
diff --git a/src/virtualkeyboard/declarativeinputengine.h b/src/virtualkeyboard/declarativeinputengine.h
index 202578d7..c6abc5b4 100644
--- a/src/virtualkeyboard/declarativeinputengine.h
+++ b/src/virtualkeyboard/declarativeinputengine.h
@@ -26,6 +26,7 @@ class DeclarativeInputContext;
class DeclarativeSelectionListModel;
class AbstractInputMethod;
class DeclarativeInputEnginePrivate;
+class DeclarativeTrace;
class DeclarativeInputEngine : public QObject
{
@@ -34,11 +35,13 @@ class DeclarativeInputEngine : public QObject
Q_DECLARE_PRIVATE(DeclarativeInputEngine)
Q_ENUMS(TextCase)
Q_ENUMS(InputMode)
+ Q_ENUMS(PatternRecognitionMode)
Q_PROPERTY(Qt::Key activeKey READ activeKey NOTIFY activeKeyChanged)
Q_PROPERTY(Qt::Key previousKey READ previousKey NOTIFY previousKeyChanged)
Q_PROPERTY(AbstractInputMethod *inputMethod READ inputMethod WRITE setInputMethod NOTIFY inputMethodChanged)
Q_PROPERTY(QList<int> inputModes READ inputModes NOTIFY inputModesChanged)
Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode NOTIFY inputModeChanged)
+ Q_PROPERTY(QList<int> patternRecognitionModes READ patternRecognitionModes NOTIFY patternRecognitionModesChanged)
Q_PROPERTY(DeclarativeSelectionListModel *wordCandidateListModel READ wordCandidateListModel NOTIFY wordCandidateListModelChanged)
Q_PROPERTY(bool wordCandidateListVisibleHint READ wordCandidateListVisibleHint NOTIFY wordCandidateListVisibleHintChanged)
@@ -59,6 +62,10 @@ public:
Katakana,
FullwidthLatin
};
+ enum PatternRecognitionMode {
+ PatternRecognitionDisabled,
+ HandwritingRecoginition
+ };
public:
~DeclarativeInputEngine();
@@ -83,6 +90,11 @@ public:
DeclarativeSelectionListModel *wordCandidateListModel() const;
bool wordCandidateListVisibleHint() const;
+ QList<int> patternRecognitionModes() const;
+ Q_INVOKABLE DeclarativeTrace *traceBegin(int traceId, DeclarativeInputEngine::PatternRecognitionMode patternRecognitionMode,
+ const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo);
+ Q_INVOKABLE bool traceEnd(DeclarativeTrace *trace);
+
signals:
void virtualKeyClicked(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers, bool isAutoRepeat);
void activeKeyChanged(Qt::Key key);
@@ -92,6 +104,7 @@ signals:
void inputMethodUpdate();
void inputModesChanged();
void inputModeChanged();
+ void patternRecognitionModesChanged();
void wordCandidateListModelChanged();
void wordCandidateListVisibleHintChanged();
diff --git a/src/virtualkeyboard/declarativeinputmethod.cpp b/src/virtualkeyboard/declarativeinputmethod.cpp
index 86e91590..060132da 100644
--- a/src/virtualkeyboard/declarativeinputmethod.cpp
+++ b/src/virtualkeyboard/declarativeinputmethod.cpp
@@ -17,6 +17,7 @@
****************************************************************************/
#include "declarativeinputmethod.h"
+#include "declarativetrace.h"
#include <QVariant>
/*!
@@ -148,6 +149,39 @@
in the selection list identified by \a type.
*/
+/*!
+ \qmlmethod list<int> InputMethod::patternRecognitionModes()
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ Returns list of supported pattern recognition modes.
+
+ This method is invoked by the input engine to query the list of
+ supported pattern recognition modes.
+*/
+
+/*!
+ \qmlmethod Trace InputMethod::traceBegin(var traceCaptureDeviceInfo, var traceScreenInfo)
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ This method is called when a trace interaction starts. The \a traceCaptureDeviceInfo provides
+ information about the source device and the \a traceScreenInfo provides information about the screen
+ context.
+
+ If the input method accepts the event and wants to capture the trace input, it must return
+ a new Trace object. This object must remain valid until the \l {InputMethod::traceEnd()}
+ {InputMethod.traceEnd()} method is called. If the Trace is rendered on screen, it remains there
+ until the Trace object is destroyed.
+*/
+
+/*!
+ \qmlmethod bool InputMethod::traceEnd(Trace trace)
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ This method is called when the trace interaction ends. The input method should destroy the \a trace object
+ at some point after this function is called. See the \l Trace API how to access the gathered
+ data.
+*/
+
DeclarativeInputMethod::DeclarativeInputMethod(QObject *parent) :
AbstractInputMethod(parent)
{
@@ -242,6 +276,39 @@ void DeclarativeInputMethod::selectionListItemSelected(DeclarativeSelectionListM
Q_ARG(QVariant, index));
}
+QList<DeclarativeInputEngine::PatternRecognitionMode> DeclarativeInputMethod::patternRecognitionModes() const
+{
+ QVariant result;
+ QMetaObject::invokeMethod(const_cast<DeclarativeInputMethod *>(this), "patternRecognitionModes",
+ Q_RETURN_ARG(QVariant, result));
+ QList<DeclarativeInputEngine::PatternRecognitionMode> patterRecognitionModeList;
+ foreach (const QVariant &patterRecognitionMode, result.toList()) {
+ patterRecognitionModeList.append(static_cast<DeclarativeInputEngine::PatternRecognitionMode>(patterRecognitionMode.toInt()));
+ }
+ return patterRecognitionModeList;
+}
+
+DeclarativeTrace *DeclarativeInputMethod::traceBegin(DeclarativeInputEngine::PatternRecognitionMode patternRecognitionMode,
+ const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo)
+{
+ Q_UNUSED(patternRecognitionMode)
+ QVariant result;
+ QMetaObject::invokeMethod(this, "traceBegin",
+ Q_RETURN_ARG(QVariant, result),
+ Q_ARG(QVariant, traceCaptureDeviceInfo),
+ Q_ARG(QVariant, traceScreenInfo));
+ return result.value<DeclarativeTrace *>();
+}
+
+bool DeclarativeInputMethod::traceEnd(DeclarativeTrace *trace)
+{
+ QVariant result;
+ QMetaObject::invokeMethod(this, "traceEnd",
+ Q_RETURN_ARG(QVariant, result),
+ Q_ARG(QVariant, QVariant::fromValue(trace)));
+ return result.toBool();
+}
+
void DeclarativeInputMethod::reset()
{
QMetaObject::invokeMethod(this, "reset");
diff --git a/src/virtualkeyboard/declarativeinputmethod.h b/src/virtualkeyboard/declarativeinputmethod.h
index fe0b7105..95fe11a9 100644
--- a/src/virtualkeyboard/declarativeinputmethod.h
+++ b/src/virtualkeyboard/declarativeinputmethod.h
@@ -42,6 +42,11 @@ public:
QVariant selectionListData(DeclarativeSelectionListModel::Type type, int index, int role);
void selectionListItemSelected(DeclarativeSelectionListModel::Type type, int index);
+ QList<DeclarativeInputEngine::PatternRecognitionMode> patternRecognitionModes() const;
+ DeclarativeTrace *traceBegin(DeclarativeInputEngine::PatternRecognitionMode patternRecognitionMode,
+ const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo);
+ bool traceEnd(DeclarativeTrace *trace);
+
void reset();
void update();
};
diff --git a/src/virtualkeyboard/declarativetrace.cpp b/src/virtualkeyboard/declarativetrace.cpp
new file mode 100644
index 00000000..e390d8d1
--- /dev/null
+++ b/src/virtualkeyboard/declarativetrace.cpp
@@ -0,0 +1,416 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://www.qt.io
+**
+** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
+**
+** 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://www.qt.io
+**
+****************************************************************************/
+
+#include "declarativetrace.h"
+#include <QtCore/private/qobject_p.h>
+
+class DeclarativeTracePrivate : public QObjectPrivate
+{
+public:
+ DeclarativeTracePrivate() :
+ QObjectPrivate(),
+ traceId(0),
+ final(false),
+ canceled(false)
+ { }
+
+ int traceId;
+ QVariantList points;
+ QMap<QString, QVariantList> channels;
+ bool final;
+ bool canceled;
+};
+
+/*!
+ \class DeclarativeTrace
+ \inmodule qtvirtualkeyboard
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+ \brief Trace is a data model for touch input data.
+
+ Trace provides the data model for coordinate data and other
+ optional data associated with a single stroke.
+
+ A typical use case for the trace object is as follows:
+ \list
+ \li TraceInputArea or other input device initiates
+ the trace event by calling \l {InputEngine::traceBegin()}
+ {InputEngine.traceBegin()} method.
+ \li If the current input method accepts the event it creates
+ a trace object and configures the required data channels
+ (if any).
+ \li TraceInputArea collects the data for the Trace object.
+ \li TraceInputArea calls the \l {InputEngine::traceEnd()}
+ {InputEngine.traceEnd()} method to finish the trace and
+ passing the trace object back to input method.
+ \li The input method processes the data and discards the object
+ when it is no longer needed.
+ \endlist
+
+ The coordinate data is retrieved using the points() function.
+
+ In addition to coordinate based data, it is possible
+ to attach an arbitrary data channel for each data point.
+
+ The data channels must be defined before the points are added.
+ The data channels supported by the TraceInputArea are listed below:
+
+ \list
+ \li \c "t" Collects time for each data point. The time is
+ the number of milliseconds since 1970/01/01:
+ \endlist
+
+ For example, to configure the object to collect the times for
+ each point:
+
+ \code
+ DeclarativeTrace *trace = new DeclarativeTrace(this);
+ trace->setChannels(QStringList() << "t");
+ \endcode
+
+ The collected data can be accessed using the channelData() function:
+
+ \code
+ QVariantList timeData = trace->channelData("t");
+ \endcode
+
+ Trace objects are owned by their creator, which is the input method in
+ normal case. This means the objects are constructed in
+ \l {AbstractInputMethod::traceBegin()} (C++) or \l {InputMethod::traceBegin()}
+ {InputMethod.traceBegin()} (QML) method.
+
+ By definition, the trace object can be destroyed at earliest in the
+ \l {AbstractInputMethod::traceEnd()} (C++) or \l {InputMethod::traceEnd()}
+ {InputMethod.traceEnd()} (QML) method.
+*/
+
+/*!
+ \qmltype Trace
+ \instantiates DeclarativeTrace
+ \inqmlmodule QtQuick.Enterprise.VirtualKeyboard
+ \ingroup qtvirtualkeyboard-qml
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+ \brief Trace is a data model for touch input data.
+
+ Trace provides the data model for coordinate data and other
+ optional data associated with a single stroke.
+
+ A typical use case for the trace object is as follows:
+ \list
+ \li TraceInputArea or other input device initiates
+ the trace event by calling \l {InputEngine::traceBegin()}
+ {InputEngine.traceBegin()} method.
+ \li If the current input method accepts the event it creates
+ a trace object and configures the required data channels
+ (if any).
+ \li TraceInputArea collects the data for the trace object.
+ \li TraceInputArea calls the \l {InputEngine::traceEnd()}
+ {InputEngine.traceEnd()} method to finish the trace and
+ passing the trace object back to input method.
+ \li The input method processes the data and discards the object
+ when it is no longer needed.
+ \endlist
+
+ The coordinate data is retrieved using the points() function.
+
+ In addition to coordinate based data, it is possible
+ to attach an arbitrary data channel for each data point.
+
+ The data channels must be defined before the points are added.
+ The data channels supported by the TraceInputArea are listed below:
+
+ \list
+ \li \c "t" Collects time for each data point. The time is
+ the number of milliseconds since 1970/01/01:
+ \endlist
+
+ For example, to configure the object to collect the times for
+ each point:
+
+ \code
+ DeclarativeTrace *trace = new DeclarativeTrace(this);
+ trace->setChannels(QStringList() << "t");
+ \endcode
+
+ The collected data can be accessed using the channelData() function:
+
+ \code
+ QVariantList timeData = trace->channelData("t");
+ \endcode
+
+ Trace objects are owned by their creator, which is the input method in
+ normal case. This means the objects are constructed in
+ \l {AbstractInputMethod::traceBegin()} (C++) or \l {InputMethod::traceBegin()}
+ {InputMethod.traceBegin()} (QML) method.
+
+ By definition, the trace object can be destroyed at earliest in the
+ \l {AbstractInputMethod::traceEnd()} (C++) or \l {InputMethod::traceEnd()}
+ {InputMethod.traceEnd()} (QML) method.
+*/
+
+/*! \internal */
+DeclarativeTrace::DeclarativeTrace(QObject *parent) :
+ QObject(*new DeclarativeTracePrivate(), parent)
+{
+}
+
+/*! \internal */
+DeclarativeTrace::~DeclarativeTrace()
+{
+}
+
+int DeclarativeTrace::traceId() const
+{
+ Q_D(const DeclarativeTrace);
+ return d->traceId;
+}
+
+void DeclarativeTrace::setTraceId(int id)
+{
+ Q_D(DeclarativeTrace);
+ if (d->traceId != id) {
+ d->traceId = id;
+ emit traceIdChanged(id);
+ }
+}
+
+QStringList DeclarativeTrace::channels() const
+{
+ Q_D(const DeclarativeTrace);
+ return d->channels.keys();
+}
+
+void DeclarativeTrace::setChannels(const QStringList &channels)
+{
+ Q_D(DeclarativeTrace);
+ Q_ASSERT(d->points.isEmpty());
+ if (d->points.isEmpty()) {
+ d->channels.clear();
+ for (QStringList::ConstIterator i = channels.constBegin();
+ i != channels.constEnd(); i++) {
+ d->channels[*i] = QVariantList();
+ }
+ emit channelsChanged();
+ }
+}
+
+int DeclarativeTrace::length() const
+{
+ Q_D(const DeclarativeTrace);
+ return d->points.size();
+}
+
+/*! \qmlmethod var Trace::points(int pos, int count)
+
+ Returns list of points. If no parameters are given, the
+ function returns all the points.
+
+ If the \a pos parameter is given, the function returns points starting
+ at the position. The \a count parameter limits how many points are
+ returned.
+
+ The returned list contains \c point types.
+*/
+
+/*! Returns list of points. If no parameters are given, the
+ method returns all the data.
+
+ If the \a pos parameter is given, the method returns points starting
+ at the position. The \a count parameter limits how many points are
+ returned.
+
+ The returned list contains QPointF types.
+*/
+
+QVariantList DeclarativeTrace::points(int pos, int count) const
+{
+ Q_D(const DeclarativeTrace);
+ return d->points.mid(pos, count);
+}
+
+/*! \qmlmethod int Trace::addPoint(point point)
+
+ Adds a \a point to the Trace.
+
+ The method returns index of the point added, or -1 if
+ the points cannot be added (i.e. the isFinal is true).
+
+ \note The returned index is required to associate additional
+ data with the point using the setChannelData() function.
+*/
+
+/*! Adds a \a point to the Trace.
+
+ The method returns index of the point added, or -1 if
+ the points cannot be added (i.e. the isFinal is true).
+
+ \note The returned index is required to associate additional
+ data with the point using the setChannelData() method.
+*/
+
+int DeclarativeTrace::addPoint(const QPointF &point)
+{
+ Q_D(DeclarativeTrace);
+ int index;
+ if (!d->final) {
+ index = d->points.size();
+ d->points.append(point);
+ emit lengthChanged(d->points.size());
+ } else {
+ index = -1;
+ }
+ return index;
+}
+
+/*! \qmlmethod void Trace::setChannelData(int index, string channel, var data)
+
+ Sets \a data for the point at \a index in the given data \a channel.
+
+ If this method is not called for each data point, the channel data
+ will be padded with empty values. However, the data cannot be added at
+ arbitrary index, i.e., it must be added in synchronously with the point data.
+*/
+
+/*! Sets \a data for the point at \a index in the given data \a channel.
+
+ If this method is not called for each data point, the channel data
+ will be padded with empty values. However, the data cannot be added at
+ arbitrary index, i.e., it must be added in synchronously with the point data.
+*/
+
+void DeclarativeTrace::setChannelData(const QString &channel, int index, const QVariant &data)
+{
+ Q_D(DeclarativeTrace);
+ if (!d->final && (index + 1) == d->points.size() && d->channels.contains(channel)) {
+ QVariantList &channelData = d->channels[channel];
+ while (index > channelData.size())
+ channelData.append(QVariant());
+ if (index == channelData.size())
+ channelData.append(data);
+ }
+}
+
+/*! \qmlmethod var Trace::channelData(string channel, int pos, int count)
+
+ Returns data from the specified \a channel. If no other parameters
+ are given, the function returns all the data.
+
+ If the \a pos parameter is given, the function returns data starting
+ at the position. The \a count parameter limits how many items are
+ returned.
+*/
+
+/*! Returns data from the specified \a channel. If no other parameters
+ are given, the method returns all the data.
+
+ If the \a pos parameter is given, the method returns data starting
+ at the position. The \a count parameter limits how many items are
+ returned.
+*/
+
+QVariantList DeclarativeTrace::channelData(const QString &channel, int pos, int count) const
+{
+ Q_D(const DeclarativeTrace);
+ return d->channels.value(channel).mid(pos, count);
+}
+
+bool DeclarativeTrace::isFinal() const
+{
+ Q_D(const DeclarativeTrace);
+ return d->final;
+}
+
+void DeclarativeTrace::setFinal(bool final)
+{
+ Q_D(DeclarativeTrace);
+ if (d->final != final) {
+ d->final = final;
+ emit finalChanged(final);
+ }
+}
+
+bool DeclarativeTrace::isCanceled() const
+{
+ Q_D(const DeclarativeTrace);
+ return d->canceled;
+}
+
+void DeclarativeTrace::setCanceled(bool canceled)
+{
+ Q_D(DeclarativeTrace);
+ if (d->canceled != canceled) {
+ d->canceled = canceled;
+ emit canceledChanged(canceled);
+ }
+}
+
+/*! \qmlproperty int Trace::traceId
+
+ Unique id of this Trace.
+*/
+
+/*! \property DeclarativeTrace::traceId
+ \brief unique id of this Trace.
+*/
+
+/*! \qmlproperty list<strings> Trace::channels
+
+ List of additional data channels in the Trace.
+ This property must be initialized before the data
+ is added.
+*/
+
+/*! \property DeclarativeTrace::channels
+ \brief list of data channels in the Trace.
+
+ This property must be initialized before the data
+ is added.
+*/
+
+/*! \qmlproperty int Trace::length
+
+ The number of points in the Trace.
+*/
+
+/*! \property DeclarativeTrace::length
+ \brief the number of of points in the Trace.
+*/
+
+/*! \qmlproperty bool Trace::isFinal
+
+ This property defines whether the Trace can accept more data.
+ If the value is true, no more data is accepted.
+*/
+
+/*! \property DeclarativeTrace::isFinal
+ \brief defines whether the Trace can accept more data.
+ If the value is true, no more data is accepted.
+*/
+
+/*! \qmlproperty bool Trace::isCanceled
+
+ This property defines whether the Trace is canceled.
+ The input data should not be processed from the Traces
+ whose isCanceled property set to true.
+*/
+
+/*! \property DeclarativeTrace::isCanceled
+ \brief defines whether the Trace is canceled.
+
+ The input data should not be processed from the Traces
+ whose isCanceled property set to true.
+*/
diff --git a/src/virtualkeyboard/declarativetrace.h b/src/virtualkeyboard/declarativetrace.h
new file mode 100644
index 00000000..80f5c91c
--- /dev/null
+++ b/src/virtualkeyboard/declarativetrace.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://www.qt.io
+**
+** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
+**
+** 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://www.qt.io
+**
+****************************************************************************/
+
+#ifndef DECLARATIVETRACE_H
+#define DECLARATIVETRACE_H
+
+#include <QObject>
+#include <QVariant>
+#include <QPointF>
+
+class DeclarativeTracePrivate;
+
+class DeclarativeTrace : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(DeclarativeTrace)
+ Q_PROPERTY(int traceId READ traceId WRITE setTraceId NOTIFY traceIdChanged)
+ Q_PROPERTY(QStringList channels READ channels WRITE setChannels NOTIFY channelsChanged)
+ Q_PROPERTY(int length READ length NOTIFY lengthChanged)
+ Q_PROPERTY(bool isFinal READ isFinal WRITE setFinal NOTIFY finalChanged)
+ Q_PROPERTY(bool isCanceled READ isCanceled WRITE setCanceled NOTIFY canceledChanged)
+public:
+ explicit DeclarativeTrace(QObject *parent = 0);
+ ~DeclarativeTrace();
+
+ int traceId() const;
+ void setTraceId(int id);
+
+ QStringList channels() const;
+ void setChannels(const QStringList &channels);
+
+ int length() const;
+
+ Q_INVOKABLE QVariantList points(int pos = 0, int count = -1) const;
+ Q_INVOKABLE int addPoint(const QPointF &point);
+
+ Q_INVOKABLE void setChannelData(const QString &channel, int index, const QVariant &data);
+ Q_INVOKABLE QVariantList channelData(const QString &channel, int pos = 0, int count = -1) const;
+
+ bool isFinal() const;
+ void setFinal(bool final);
+
+ bool isCanceled() const;
+ void setCanceled(bool canceled);
+
+signals:
+ void traceIdChanged(int traceId);
+ void channelsChanged();
+ void lengthChanged(int length);
+ void finalChanged(bool isFinal);
+ void canceledChanged(bool isCanceled);
+};
+
+#endif // DECLARATIVETRACE_H
diff --git a/src/virtualkeyboard/doc/src/technical-guide.qdoc b/src/virtualkeyboard/doc/src/technical-guide.qdoc
index ba9224d3..35e58245 100644
--- a/src/virtualkeyboard/doc/src/technical-guide.qdoc
+++ b/src/virtualkeyboard/doc/src/technical-guide.qdoc
@@ -264,6 +264,47 @@ to hide the list if necessary.
The list model's word candidate list is provided by the
InputEngine::wordCandidateListModel property.
+\section1 Integrating Handwriting Recognition
+
+Since the version 1.4 of the virtual keyboard, the input methods can consume
+touch input data from touch screen or other input device.
+
+\section2 Data Model for the Handwriting Input
+
+The data collected from the input source is stored in an object named DeclarativeTrace (C++) or \l Trace (QML).
+
+By definition, a trace is a set of points collected from a single point of contact.
+In addition to point data, the trace may also include data from other channels,
+such as the time for each data point.
+
+\section2 Trace API for Input Method
+
+The trace API consists of the following virtual methods, which the input method
+must implement in order to receive and process touch input data.
+
+\list
+ \li \l { AbstractInputMethod::patternRecognitionModes } { patternRecognitionModes }
+ \li \l { AbstractInputMethod::traceBegin } { traceBegin }
+ \li \l { AbstractInputMethod::traceEnd } { traceEnd }
+\endlist
+
+By implementing these methods, the input method can receive and process the data
+from variety of input sources.
+
+The patternRecognitionModes method returns a list of pattern recognition modes,
+which are supported by the input method. A pattern recognition mode, such as the
+\l { DeclarativeInputEngine::HandwritingRecoginition } { HandwritingRecoginition },
+defines the method by which the input method processes the data.
+
+The trace interaction is started when an input source detects a new contact point, and
+calls the traceBegin method for a new trace object. If the input method accepts the
+interaction, it creates a new trace object and returns it to the caller. From this point
+on, the data is collected to the trace until the traceEnd method is called.
+
+When the traceEnd method is called, the input method may begin processing of the data
+contained in the trace object. After processing the data the input method should destroy
+the object. This also removes the trace rendered to the screen.
+
\section1 Keyboard Layouts
Keyboard layouts are located in the \e src/virtualkeyboard/content/layouts
@@ -275,7 +316,7 @@ uppercase, two or three-letter ISO 3166 country code.
\section2 Layout Types
Different keyboard layout types are used in different input modes. The default
-layout which is used for reqular text input, is called the "main" layout.
+layout which is used for regular text input, is called the "main" layout.
The layout type is determined by the layout file name. Therefore, the "main" layout
file is called the "main.qml".
@@ -287,6 +328,7 @@ List of supported layout types:
\li \c numbers Numeric layout for formatted numbers (activated by Qt::ImhFormattedNumbersOnly)
\li \c digits Digits only layout (activated by Qt::ImhDigitsOnly)
\li \c dialpad Dialpad layout for phone number input (activated by Qt::ImhDialableCharactersOnly)
+ \li \c handwriting Handwriting layout for handwriting recognition (activated from main layout)
\endlist
\section2 Adding New Keyboard Layouts
@@ -328,6 +370,8 @@ specialized key types. Below is the list of all key types:
\li \l ShiftKey
\li \l SpaceKey
\li \l SymbolModeKey
+ \li \l HandwritingModeKey
+ \li \l TraceInputKey
\endlist
For example, to add a regular key which sends a key event to the input method:
diff --git a/src/virtualkeyboard/plugin.cpp b/src/virtualkeyboard/plugin.cpp
index baa4315e..c1507f03 100644
--- a/src/virtualkeyboard/plugin.cpp
+++ b/src/virtualkeyboard/plugin.cpp
@@ -38,6 +38,7 @@
#include "enterkeyaction.h"
#include "enterkeyactionattachedtype.h"
#include "declarativesettings.h"
+#include "declarativetrace.h"
static QPointer<PlatformInputContext> platformInputContext;
@@ -45,6 +46,21 @@ static QObject *createInputContextModule(QQmlEngine *engine, QJSEngine *scriptEn
{
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);
+ QQmlContext *rootContext = engine->rootContext();
+ QStringList inputMethodList = QStringList()
+ << QStringLiteral("PlainInputMethod")
+ << QStringLiteral("HunspellInputMethod")
+#ifdef HAVE_PINYIN
+ << QStringLiteral("PinyinInputMethod")
+#endif
+#ifdef HAVE_HANGUL
+ << QStringLiteral("HangulInputMethod")
+#endif
+#ifdef HAVE_OPENWNN
+ << QStringLiteral("JapaneseInputMethod")
+#endif
+ ;
+ rootContext->setContextProperty(QStringLiteral("VirtualKeyboardInputMethods"), inputMethodList);
return new DeclarativeInputContext(platformInputContext);
}
@@ -80,6 +96,7 @@ QPlatformInputContext *PlatformInputContextPlugin::create(const QString &system,
#endif
qmlRegisterType<EnterKeyActionAttachedType>();
qmlRegisterType<EnterKeyAction>("QtQuick.Enterprise.VirtualKeyboard", 1, 0, "EnterKeyAction");
+ qmlRegisterType<DeclarativeTrace>("QtQuick.Enterprise.VirtualKeyboard", 1, 4, "Trace");
qmlRegisterSingletonType<DeclarativeSettings>("QtQuick.Enterprise.VirtualKeyboard.Settings", 1, 0, "VirtualKeyboardSettings", DeclarativeSettings::registerSettingsModule);
qmlRegisterSingletonType<DeclarativeSettings>("QtQuick.Enterprise.VirtualKeyboard.Settings", 1, 1, "VirtualKeyboardSettings", DeclarativeSettings::registerSettingsModule);
qmlRegisterSingletonType<DeclarativeSettings>("QtQuick.Enterprise.VirtualKeyboard.Settings", 1, 2, "VirtualKeyboardSettings", DeclarativeSettings::registerSettingsModule);
@@ -110,6 +127,9 @@ QPlatformInputContext *PlatformInputContextPlugin::create(const QString &system,
qmlRegisterType(QUrl(componentsPath + "ShiftKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "ShiftKey");
qmlRegisterType(QUrl(componentsPath + "SpaceKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "SpaceKey");
qmlRegisterType(QUrl(componentsPath + "SymbolModeKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "SymbolModeKey");
+ qmlRegisterType(QUrl(componentsPath + "HandwritingModeKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 4, "HandwritingModeKey");
+ qmlRegisterType(QUrl(componentsPath + "TraceInputArea.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 4, "TraceInputArea");
+ qmlRegisterType(QUrl(componentsPath + "TraceInputKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 4, "TraceInputKey");
if (system.compare(system, QStringLiteral("qtvirtualkeyboard"), Qt::CaseInsensitive) == 0) {
platformInputContext = new PlatformInputContext();
diff --git a/src/virtualkeyboard/styles/KeyboardStyle.qml b/src/virtualkeyboard/styles/KeyboardStyle.qml
index 14b68892..96636a28 100644
--- a/src/virtualkeyboard/styles/KeyboardStyle.qml
+++ b/src/virtualkeyboard/styles/KeyboardStyle.qml
@@ -142,6 +142,12 @@ QtObject {
*/
property Component symbolKeyPanel: null
+ /*! Template for the handwriting mode key.
+
+ \note The delegate must be based on KeyPanel type.
+ */
+ property Component handwritingKeyPanel: null
+
/*! Number of pixels between the key top and the characterPreviewDelegate bottom. */
property real characterPreviewMargin: 0
@@ -258,4 +264,22 @@ QtObject {
high contrast border.
*/
property Component navigationHighlight: null
+
+ /*!
+ \since QtQuick.Enterprise.VirtualKeyboard.Styles 1.4
+
+ Template for the trace input key.
+
+ \note The delegate must be based on TraceInputKeyPanel type.
+ */
+ property Component traceInputKeyPanelDelegate: null
+
+ /*!
+ \since QtQuick.Enterprise.VirtualKeyboard.Styles 1.4
+
+ Template for rendering a Trace object.
+
+ \note The delegate must be based on TraceCanvas type.
+ */
+ property Component traceCanvasDelegate: null
}
diff --git a/src/virtualkeyboard/styles/TraceCanvas.qml b/src/virtualkeyboard/styles/TraceCanvas.qml
new file mode 100644
index 00000000..1103495e
--- /dev/null
+++ b/src/virtualkeyboard/styles/TraceCanvas.qml
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://www.qt.io
+**
+** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
+**
+** 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://www.qt.io
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "TraceUtils.js" as TraceUtils
+
+/*!
+ \qmltype TraceCanvas
+ \inqmlmodule QtQuick.Enterprise.VirtualKeyboard.Styles
+ \brief A specialized Canvas type for rendering Trace objects.
+ \ingroup qtvirtualkeyboard-styles-qml
+ \inherits Canvas
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ This type provides capabilities for rendering Trace objects on the screen.
+
+ To make the Trace rendering available in the keyboard, this type must be
+ declared as the \l {KeyboardStyle::traceCanvasDelegate}
+ {KeyboardStyle.traceCanvasDelegate} component.
+
+ \code
+ traceCanvasDelegate: TraceCanvas {
+ }
+ \endcode
+
+ Custom drawing attributes can be initialized in the Canvas.available
+ signal. For example:
+
+ \code
+ onAvailableChanged: {
+ if (!available)
+ return;
+ var ctx = getContext("2d")
+ ctx.lineWidth = 8 * scaleHint
+ ctx.lineCap = "round"
+ ctx.strokeStyle = Qt.rgba(0xFF, 0xFF, 0xFF)
+ ctx.fillStyle = ctx.strokeStyle
+ }
+ \endcode
+
+ The type offers built-in options for Trace rendering. Currently
+ the following rendering options are available:
+
+ \list
+ \li \c renderSmoothedLine Renders smoothed line with round corners (the default)
+ \endlist
+
+ The rendering function can be changed with the renderFunction property.
+
+ \code
+ renderFunction: renderSmoothedLine
+ \endcode
+
+ Custom rendering function is also supported. Consider the following example:
+
+ \code
+ renderFunction: renderCustomLine
+
+ function renderCustomLine() {
+ getContext("2d")
+ var points = trace.points()
+
+ ...
+ }
+ \endcode
+*/
+
+Canvas {
+ id: canvas
+
+ /*! Provides access to \l Trace object.
+ */
+ property var trace
+
+ /*! Enables auto destruction mode.
+
+ If enabled, this item will be destroyed when the \c trace object is
+ destroyed.
+
+ The default value is false.
+ */
+ property bool autoDestroy
+
+ /*! Specifies the approximate delay in milliseconds, counted from the beginning of the
+ auto destruction, before the object is to be destroyed.
+
+ This delay makes it possible, for example, to animate the item before destruction.
+
+ The default value is 0.
+ */
+ property int autoDestroyDelay
+
+ /*! This property defines the rendering function.
+
+ The default value is \c renderSmoothedLine
+ */
+ property var renderFunction: renderSmoothedLine
+
+ property int __renderPos
+
+ /*! Renders smoothed line with round corners.
+
+ This function is incremental and renders only the new part added to the Trace.
+
+ This function does not alter any of the canvas attributes (i.e. they can be set elsewhere.)
+ */
+ function renderSmoothedLine() {
+ __renderPos = TraceUtils.renderSmoothedLine(getContext("2d"), trace, __renderPos)
+ }
+
+ onTraceChanged: if (trace === null && autoDestroy) destroy(autoDestroyDelay)
+
+ Connections {
+ target: trace ? trace : null
+ onLengthChanged: if (renderFunction) canvas.requestAnimationFrame(renderFunction)
+ onFinalChanged: if (renderFunction) canvas.requestAnimationFrame(renderFunction)
+ }
+}
diff --git a/src/virtualkeyboard/styles/TraceInputKeyPanel.qml b/src/virtualkeyboard/styles/TraceInputKeyPanel.qml
new file mode 100644
index 00000000..269c319c
--- /dev/null
+++ b/src/virtualkeyboard/styles/TraceInputKeyPanel.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://www.qt.io
+**
+** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
+**
+** 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://www.qt.io
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+/*!
+ \qmltype TraceInputKeyPanel
+ \inqmlmodule QtQuick.Enterprise.VirtualKeyboard.Styles
+ \brief A base type of the trace input key.
+ \ingroup qtvirtualkeyboard-styles-qml
+ \since QtQuick.Enterprise.VirtualKeyboard 1.4
+
+ This type provides panel for decorating TraceInputKey
+ items in the keyboard layout.
+*/
+
+Item {
+ /*! Provides access to properties in TraceInputKey.
+
+ A list of available properties in control:
+ \list
+ \li \c patternRecognitionMode Pattern recognition mode of this input area
+ \li \c horizontalRulers A list of horizontal rulers
+ \li \c verticalRulers A list of vertical rulers
+ \li \c boundingBox Bounding box for the trace input
+ \endlist
+ */
+ property Item control
+
+ /*! Sets margins of the trace input area.
+
+ The margins affect to the bounding box of the trace input area.
+ */
+ property real traceMargins
+}
diff --git a/src/virtualkeyboard/styles/TraceUtils.js b/src/virtualkeyboard/styles/TraceUtils.js
new file mode 100644
index 00000000..b5b6d3bb
--- /dev/null
+++ b/src/virtualkeyboard/styles/TraceUtils.js
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://www.qt.io
+**
+** This file is part of the Qt Virtual Keyboard add-on for Qt Enterprise.
+**
+** 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://www.qt.io
+**
+****************************************************************************/
+
+.pragma library
+
+function renderSmoothedLine(ctx, trace, renderPos) {
+
+ if (!trace)
+ return renderPos
+
+ if (renderPos >= trace.length)
+ return renderPos
+
+ // Fetch points and draw the initial "dot"
+ var points, tp
+ if (renderPos === 0) {
+ points = trace.points()
+ tp = points[renderPos++]
+ ctx.beginPath()
+ ctx.moveTo(tp.x, tp.y)
+ ctx.lineTo(tp.x, tp.y + 0.000001)
+ ctx.stroke()
+ } else {
+ points = trace.points(renderPos - 1)
+ }
+
+ // Draw smoothed line using quadratic curve
+ var i = 1
+ if (i + 1 < points.length) {
+ var pt1, pt2
+ if (renderPos === 1) {
+ tp = points[i - 1]
+ } else {
+ pt1 = points[i - 1]
+ pt2 = points[i]
+ tp = Qt.point((pt1.x + pt2.x) / 2, (pt1.y + pt2.y) / 2)
+ }
+ ctx.beginPath()
+ ctx.moveTo(tp.x, tp.y)
+ while (i + 1 < points.length) {
+ pt1 = points[i++]
+ pt2 = points[i]
+ tp = Qt.point((pt1.x + pt2.x) / 2, (pt1.y + pt2.y) / 2)
+ ctx.quadraticCurveTo(pt1.x, pt1.y, tp.x, tp.y)
+ }
+ }
+
+ // Draw the remainder of the line
+ if (trace.isFinal) {
+ if (i < points.length) {
+ tp = points[i++]
+ ctx.lineTo(tp.x, tp.y)
+ }
+ }
+
+ if (i > 1)
+ ctx.stroke()
+
+ return renderPos + i - 1
+}
diff --git a/src/virtualkeyboard/styles/styles.qrc b/src/virtualkeyboard/styles/styles.qrc
index ff6f7995..7ea39976 100644
--- a/src/virtualkeyboard/styles/styles.qrc
+++ b/src/virtualkeyboard/styles/styles.qrc
@@ -5,5 +5,8 @@
<file>KeyPanel.qml</file>
<file>SelectionListItem.qml</file>
<file>qmldir</file>
+ <file>TraceInputKeyPanel.qml</file>
+ <file>TraceCanvas.qml</file>
+ <file>TraceUtils.js</file>
</qresource>
</RCC>
diff --git a/src/virtualkeyboard/styles/styles_plugin.cpp b/src/virtualkeyboard/styles/styles_plugin.cpp
index b20c6d01..4ad7eedc 100644
--- a/src/virtualkeyboard/styles/styles_plugin.cpp
+++ b/src/virtualkeyboard/styles/styles_plugin.cpp
@@ -39,6 +39,8 @@ void StylesPlugin::registerTypes(const char *uri)
qmlRegisterType(QUrl(path + "KeyIcon.qml"), uri, 1, 0, "KeyIcon");
qmlRegisterType(QUrl(path + "KeyPanel.qml"), uri, 1, 0, "KeyPanel");
qmlRegisterType(QUrl(path + "SelectionListItem.qml"), uri, 1, 0, "SelectionListItem");
+ qmlRegisterType(QUrl(path + "TraceInputKeyPanel.qml"), uri, 1, 4, "TraceInputKeyPanel");
+ qmlRegisterType(QUrl(path + "TraceCanvas.qml"), uri, 1, 4, "TraceCanvas");
}
void StylesPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
diff --git a/src/virtualkeyboard/virtualkeyboard.pro b/src/virtualkeyboard/virtualkeyboard.pro
index 88da19d2..1aa32403 100644
--- a/src/virtualkeyboard/virtualkeyboard.pro
+++ b/src/virtualkeyboard/virtualkeyboard.pro
@@ -29,7 +29,8 @@ SOURCES += platforminputcontext.cpp \
enterkeyaction.cpp \
enterkeyactionattachedtype.cpp \
settings.cpp \
- declarativesettings.cpp
+ declarativesettings.cpp \
+ declarativetrace.cpp \
HEADERS += platforminputcontext.h \
declarativeinputcontext.h \
@@ -46,7 +47,8 @@ HEADERS += platforminputcontext.h \
enterkeyactionattachedtype.h \
settings.h \
declarativesettings.h \
- plugin.h
+ plugin.h \
+ declarativetrace.h \
RESOURCES += \
content/styles/default/default_style.qrc \