Initial commit

This commit is contained in:
2026-04-29 07:19:21 +03:00
commit 9a8cdfa08a
5964 changed files with 1194660 additions and 0 deletions
@@ -0,0 +1,107 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
Item {
property bool active: listView.currentIndex != -1
property int highlightIndex: -1
property alias listView: listView
property int keyCode
property point origin
signal clicked
LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true
z: 1
visible: active
anchors.fill: parent
ListModel {
id: listModel
}
ListView {
id: listView
spacing: 0
model: listModel
delegate: keyboard.style.alternateKeysListDelegate
highlight: keyboard.style.alternateKeysListHighlight ? keyboard.style.alternateKeysListHighlight : defaultHighlight
highlightMoveDuration: 0
highlightResizeDuration: 0
keyNavigationWraps: true
orientation: ListView.Horizontal
height: keyboard.style ? keyboard.style.alternateKeysListItemHeight : 0
x: origin.x
y: keyboard.style ? origin.y - height - keyboard.style.alternateKeysListBottomMargin : 0
Component {
id: defaultHighlight
Item {}
}
}
Loader {
id: backgroundLoader
sourceComponent: keyboard.style.alternateKeysListBackground
anchors.fill: listView
z: -1
states: State {
name: "highlighted"
when: highlightIndex !== -1 && highlightIndex === listView.currentIndex &&
backgroundLoader.item !== null && backgroundLoader.item.hasOwnProperty("currentItemHighlight")
PropertyChanges {
target: backgroundLoader.item
currentItemHighlight: true
}
}
}
onClicked: {
if (active && listView.currentIndex >= 0 && listView.currentIndex < listView.model.count) {
var activeKey = listView.model.get(listView.currentIndex)
InputContext.inputEngine.virtualKeyClick(keyCode, activeKey.data,
InputContext.uppercase ? Qt.ShiftModifier : 0)
}
}
function open(key, originX, originY) {
keyCode = key.key
var alternativeKeys = key.effectiveAlternativeKeys
var displayAlternativeKeys = key.displayAlternativeKeys
if (alternativeKeys.length > 0 && displayAlternativeKeys.length === alternativeKeys.length) {
for (var i = 0; i < alternativeKeys.length; i++) {
listModel.append({
"text": InputContext.uppercase ? displayAlternativeKeys[i].toUpperCase() : displayAlternativeKeys[i],
"data": InputContext.uppercase ? alternativeKeys[i].toUpperCase() : alternativeKeys[i]
})
}
listView.width = keyboard.style.alternateKeysListItemWidth * listModel.count
listView.forceLayout()
highlightIndex = key.effectiveAlternativeKeysHighlightIndex
if (highlightIndex === -1) {
console.log("AlternativeKeys: active key \"" + key.text + "\" not found in alternativeKeys \"" + alternativeKeys + ".\"")
highlightIndex = 0
}
listView.currentIndex = highlightIndex
var currentItemOffset = (listView.currentIndex + 0.5) * keyboard.style.alternateKeysListItemWidth
origin = Qt.point(Math.min(Math.max(keyboard.style.alternateKeysListLeftMargin, originX - currentItemOffset), width - listView.width - keyboard.style.alternateKeysListRightMargin), originY)
if (backgroundLoader.item && backgroundLoader.item.hasOwnProperty("currentItemOffset")) {
backgroundLoader.item.currentItemOffset = currentItemOffset
}
}
return active
}
function move(mouseX) {
var newIndex = listView.indexAt(Math.max(1, Math.min(listView.width - 1, mapToItem(listView, mouseX, 0).x)), 1)
if (newIndex !== listView.currentIndex) {
listView.currentIndex = newIndex
}
}
function close() {
listView.currentIndex = -1
listModel.clear()
}
}
@@ -0,0 +1,28 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype BackspaceKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits BaseKey
\brief Backspace key for keyboard layouts.
Sends a backspace key for input method processing.
This key is repeatable.
*/
BaseKey {
key: Qt.Key_Backspace
keyType: QtVirtualKeyboard.KeyType.BackspaceKey
repeat: true
functionKey: true
highlighted: true
keyPanelDelegate: keyboard.style ? keyboard.style.backspaceKeyPanel : undefined
}
@@ -0,0 +1,234 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Layouts
import QtQuick.VirtualKeyboard
/*!
\qmltype BaseKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\inherits Item
\brief Common parent for all key types.
BaseKey is a common type for all keys in keyboard layout.
This type should not be used directly in the layouts. The specialized
key types, such as Key or EnterKey should be used instead.
*/
Item {
id: keyItem
/*! \since 6.1
\l Key type for the specialized key. Possible values are defined by the
{QtVirtualKeyboard::KeyType}{key type enumeration}.
For example, \l SpaceKey sets this value to \e QtVirtualKeyboard.KeyType.SpaceKey.
*/
property int keyType: QtVirtualKeyboard.KeyType.BaseKey
/*! 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
/*! Sets the key text for input method processing.
In most cases, this is the Unicode representation of the key code.
The default value is an empty string.
*/
property string text: ""
/*! Sets the display text.
This string is rendered in the keyboard layout.
The default value is the key text.
*/
property string displayText: text
/*! \since QtQuick.VirtualKeyboard 2.0
Sets the small text rendered in the corner of the key.
The default value based on the default item in the effective alternative keys.
*/
property string smallText: effectiveAlternativeKeys && effectiveAlternativeKeysHighlightIndex !== -1 ? effectiveAlternativeKeys[effectiveAlternativeKeysHighlightIndex] : ""
/*! \since QtQuick.VirtualKeyboard 2.0
Sets the visibility of small text.
The default value is inherited from the parent.
*/
property bool smallTextVisible: parent.smallTextVisible
/*! Sets the list of alternative keys.
This property can be set to a string, or a list of strings. If the value is
a string, the alternative keys are presented as individual characters of
that string. If the value is a list of strings, the list is used instead.
The alternative keys are presented to the user by pressing and holding a key
with this property set.
\note If the alternative keys contains the key \c text, it will be filtered from
the \c effectiveAlternativeKeys and its position will be used as an indicator
for the highlighted item instead.
The default is empty list.
*/
property var alternativeKeys: []
/*! \since QtQuick.VirtualKeyboard 2.0
This property contains the effective alternative keys presented to user.
The list is contains the items in the \c alternativeKeys excluding the \c text
item.
*/
readonly property var effectiveAlternativeKeys: {
var textIndex = alternativeKeys.indexOf(text)
if (textIndex == -1)
return alternativeKeys
return alternativeKeys.slice(0, textIndex).concat(alternativeKeys.slice(textIndex + 1))
}
/*! \since QtQuick.VirtualKeyboard 2.0
This property contains the index of highlighted item in the \c effectiveAlternativeKeys.
The index is calculated from the index of the key \c text in the \c alternativeKeys.
For example, if the alternative keys contains "çcċčć" and the key \c text is "c",
this index will become 1 and the effective alternative keys presented to user will
be "ç[ċ]čć".
*/
readonly property int effectiveAlternativeKeysHighlightIndex: {
var index = alternativeKeys.indexOf(text)
return index > 0 && (index + 1) == alternativeKeys.length ? index - 1 : index
}
/*! \since 6.2
This property allows overriding the list of key strings presented to the user in the
alternative keys view.
*/
property var displayAlternativeKeys: effectiveAlternativeKeys
/*! Sets the key code for input method processing.
The default is Qt.Key_unknown.
*/
property int key: Qt.Key_unknown
/*! \since QtQuick.VirtualKeyboard 1.3
This property controls whether the key emits key events for input
method processing. When true, the key events are disabled.
By default, the key event is emitted if the \e key is not unknown
or the \e text is not empty.
*/
property bool noKeyEvent: key === Qt.Key_unknown && text.length === 0
/*! This property holds the active status of the key.
This property is automatically set to true when the key is pressed.
*/
property bool active: false
/*! \since QtQuick.VirtualKeyboard 1.3
Disables key modifiers on the emitted key.
The default is false.
*/
property bool noModifier: false
/*! Sets the key repeat attribute.
If the repeat is enabled, the key will repeat the input events while held down.
The repeat should not be used if alternativeKeys is also set.
The default is false.
*/
property bool repeat: false
/*! Sets the highlighted status of the key.
The default is false.
*/
property bool highlighted: false
/*! Sets the function key attribute.
The default is false.
*/
property bool functionKey: false
/*! Sets the show preview attribute.
By default, the character preview popup is not shown for function keys.
*/
property bool showPreview: enabled && !functionKey && !keyboard.navigationModeActive
/*! This property holds the pressed status of the key.
The pressed status can only be true if the key is both enabled and active.
When the key state becomes pressed, it triggers a key down event for the
input engine. A key up event is triggered when the key is released.
*/
property bool pressed: enabled && active
/*! This property holds the uppercase status of the key.
By default, this property reflects the uppercase status of the keyboard.
*/
property bool uppercased: InputContext.uppercase && !noModifier
/*! Sets the key panel delegate for the key.
This property is essential for key decoration. Without a key panel delegate,
the key is invisible. This property should be assigned in the inherited key type.
*/
property alias keyPanelDelegate: keyPanel.sourceComponent
/*!
\since QtQuick.VirtualKeyboard 1.1
This property holds the sound effect to be played on key press.
This property is read-only since the sound effects are defined in the keyboard style.
*/
readonly property url soundEffect: keyPanel.item ? keyPanel.item.soundEffect : ""
onSoundEffectChanged: keyboard.soundEffect.register(soundEffect)
Layout.minimumWidth: keyPanel.implicitWidth
Layout.minimumHeight: keyPanel.implicitHeight
Layout.preferredWidth: weight
Layout.fillWidth: true
Layout.fillHeight: true
Loader {
id: keyPanel
anchors.fill: parent
onLoaded: keyPanel.item.control = keyItem
}
/*! This signal is triggered when the key is pressed, allowing custom processing
of key.
*/
signal clicked
}
@@ -0,0 +1,53 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
import QtQuick.VirtualKeyboard.Settings
/*!
\qmltype ChangeLanguageKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits BaseKey
\brief Change language key for keyboard layouts.
This key changes the current input language in the list of supported
languages. The key has two function modes:
\list
\li Popup mode
\li Toggle mode
\endlist
The popup mode is enabled by the \l {KeyboardStyle::languagePopupListEnabled} property.
If enabled, a key press will open a popup list with available languages. Otherwise
it will cycle to the next available input language.
*/
BaseKey {
/*! If this property is true, the input language is only
changed between the languages providing custom layout.
For example, if only the English and Arabic languages
provide digits layout, then other locales using the
shared default layout are ignored.
The default is false.
*/
property bool customLayoutsOnly: false
id: changeLanguageKey
keyType: QtVirtualKeyboard.KeyType.ChangeLanguageKey
objectName: "changeLanguageKey"
functionKey: true
highlighted: true
displayText: keyboard.locale.split("_")[0]
keyPanelDelegate: keyboard.style ? keyboard.style.languageKeyPanel : undefined
onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.KeyboardFunction.ChangeLanguage, customLayoutsOnly)
enabled: keyboard.isKeyboardFunctionAvailable(QtVirtualKeyboard.KeyboardFunction.ChangeLanguage, customLayoutsOnly)
visible: VirtualKeyboardSettings.visibleFunctionKeys & QtVirtualKeyboard.KeyboardFunctionKeys.Language
}
@@ -0,0 +1,60 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
Item {
property bool active
property Item activeKey: keyboard.activeKey
visible: active && activeKey !== undefined && activeKey !== null && activeKey.showPreview
z: 1
Loader {
id: characterPreview
anchors.fill: parent
sourceComponent: keyboard.style.characterPreviewDelegate
}
Binding {
target: characterPreview.item
property: "text"
value: {
if (!activeKey)
return ""
const displayText = (activeKey.keyType === QtVirtualKeyboard.KeyType.FlickKey) ? activeKey.text : activeKey.displayText
return InputContext.uppercase ? displayText.toUpperCase() : displayText
}
when: activeKey && characterPreview.item
}
onActiveKeyChanged: {
if (characterPreview.item !== null) {
if (!activeKey)
return
if (activeKey.keyType === QtVirtualKeyboard.KeyType.FlickKey) {
if (characterPreview.item.hasOwnProperty("flickLeft")) {
characterPreview.item.flickLeft = activeKey.flickLeft
characterPreview.item.flickRight = activeKey.flickRight
characterPreview.item.flickTop = activeKey.flickTop
characterPreview.item.flickBottom = activeKey.flickBottom
}
} else {
if (characterPreview.item.hasOwnProperty("flickLeft")) {
characterPreview.item.flickLeft = ""
characterPreview.item.flickRight = ""
characterPreview.item.flickTop = ""
characterPreview.item.flickBottom = ""
}
}
width = activeKey.width
height = activeKey.height
var position = keyboard.mapFromItem(activeKey, 0, 0)
x = position.x
y = position.y - height - keyboard.style.characterPreviewMargin
}
}
}
@@ -0,0 +1,34 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype EnterKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits BaseKey
\brief Enter key for keyboard layouts.
Sends an enter key for input method processing.
*/
BaseKey {
/*! This property holds the action id for the enter key.
*/
readonly property int actionId: InputContext.priv.hasEnterKeyAction(InputContext.priv.inputItem) ? InputContext.priv.inputItem.EnterKeyAction.actionId : EnterKeyAction.None
keyType: QtVirtualKeyboard.KeyType.EnterKey
text: "\n"
displayText: InputContext.priv.hasEnterKeyAction(InputContext.priv.inputItem) ? InputContext.priv.inputItem.EnterKeyAction.label : ""
key: Qt.Key_Return
showPreview: false
highlighted: true
enabled: InputContext.priv.hasEnterKeyAction(InputContext.priv.inputItem) ? InputContext.priv.inputItem.EnterKeyAction.enabled : true
keyPanelDelegate: keyboard.style ? keyboard.style.enterKeyPanel : undefined
}
@@ -0,0 +1,23 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype FillerKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits BaseKey
\brief Filler key for keyboard layouts.
This key can be used as a filler in the keyboard layout.
*/
BaseKey {
keyType: QtVirtualKeyboard.KeyType.FillerKey
showPreview: false
}
@@ -0,0 +1,96 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype FlickKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits Key
\since 6.1
\brief Flick key for keyboard layouts.
Allows to enter an alternative character in a four-way gesture.
Characters are taken from the alternate keys starting with the
key at index \c 0 (excluding the main key text) and the positions
are filled in the following order: left, top, bottom, right.
*/
Key {
property int __key
property string __text
property point pt1
readonly property real __centerRadius: width * 0.4
readonly property var flickKeys: {
var keys = InputContext.uppercase ? alternativeKeys.toUpperCase() : alternativeKeys.toLowerCase()
var textIndex = __text ? keys.indexOf(InputContext.uppercase ? __text.toUpperCase() : __text.toLowerCase()) : -1
if (textIndex === -1)
return keys
return keys.slice(0, textIndex).concat(keys.slice(textIndex + 1))
}
property string flickLeft: flickKeys.length > 0 ? flickKeys[0] : ""
property string flickTop: flickKeys.length > 2 ? flickKeys[1] : ""
property string flickBottom: flickKeys.length > 3 ? flickKeys[3] : (flickKeys.length > 2 ? flickKeys[2] : "")
property string flickRight: flickKeys.length > 3 ? flickKeys[2] : (flickKeys.length === 2 ? flickKeys[1] : "")
keyType: QtVirtualKeyboard.KeyType.FlickKey
Component.onCompleted: {
__key = key
__text = text
}
onActiveChanged: {
key = __key
text = __text
}
function __angle(pt2) {
var dx = pt2.x - pt1.x
var dy = pt2.y - pt1.y
var theta = Math.atan2(-dy, dx) * 360 / (2 * Math.PI)
var theta_normalized = theta < 0 ? theta + 360 : theta
return theta_normalized >= 360 ? 0 : theta_normalized
}
function __distance(pt2) {
var dx = pt2.x - pt1.x
dx = dx * dx
var dy = pt2.y - pt1.y
dy = dy * dy
return Math.sqrt(dx + dy)
}
function press(x, y) {
pt1 = Qt.point(x, y)
}
function update(x, y) {
var pt = Qt.point(x, y)
var distance = __distance(pt)
if (distance < __centerRadius) {
return
}
var currentText
var angle = __angle(pt)
if (angle < 45 || angle > 315) {
currentText = flickRight
} else if (angle < 135) {
currentText = flickTop
} else if (angle < 225) {
currentText = flickLeft
} else {
currentText = flickBottom
}
if (currentText.length === 1 && text !== currentText) {
key = currentText.toUpperCase().charCodeAt(0)
text = currentText
}
}
}
@@ -0,0 +1,110 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
import QtQuick.VirtualKeyboard.Settings
Item {
property bool active
property alias listView: listView
property point origin
signal clicked
LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true
z: 1
visible: active
anchors.fill: parent
ListModel {
id: listModel
}
ListView {
id: listView
spacing: 0
model: listModel
currentIndex: -1
delegate: keyboard.style.functionPopupListDelegate
highlight: keyboard.style.functionPopupListHighlight ? keyboard.style.functionPopupListHighlight : defaultHighlight
highlightMoveDuration: 0
highlightResizeDuration: 0
keyNavigationWraps: true
orientation: ListView.Horizontal
width: contentItem.childrenRect.width
height: contentItem.childrenRect.height
x: {
var result = origin.x
if (count > 0) {
const item = itemAtIndex(0)
if (item) {
result -= Math.round(item.width / 2)
}
}
return result
}
y: origin.y - height
Component {
id: defaultHighlight
Item {}
}
}
Loader {
id: backgroundLoader
sourceComponent: keyboard.style.functionPopupListBackground
anchors.fill: listView
z: -1
Binding {
target: backgroundLoader.item
property: "view"
value: listView
when: backgroundLoader.item && backgroundLoader.item.hasOwnProperty("view")
}
}
onClicked: {
if (active && listView.currentIndex >= 0 && listView.currentIndex < listView.model.count) {
const listElement = listView.model.get(listView.currentIndex)
keyboard.doKeyboardFunction(listElement.keyboardFunction)
}
}
function open(key, originX, originY) {
listModel.clear()
for (const keyboardFunction of [
QtVirtualKeyboard.KeyboardFunction.HideInputPanel,
QtVirtualKeyboard.KeyboardFunction.ChangeLanguage,
QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode,
]) {
const functionKey = InputContext.priv.keyboardFunctionKey(keyboardFunction)
if (keyboard.isKeyboardFunctionAvailable(keyboardFunction) &&
!(VirtualKeyboardSettings.visibleFunctionKeys & functionKey)) {
const listElement = {
keyboardFunction: keyboardFunction
}
listModel.append(listElement)
}
}
listView.currentIndex = (listModel.count > 0) ? 0 : -1
origin = Qt.binding(function() {
return Qt.point(Math.min(Math.max(0, originX), width - listView.width), originY)
})
active = listView.currentIndex !== -1
return active
}
function move(pt) {
var listPt = mapToItem(listView, pt.x, pt.y)
var newIndex = listView.indexAt(listPt.x, Math.max(1, Math.min(listView.height - 1, listPt.y)))
if (newIndex !== listView.currentIndex) {
listView.currentIndex = newIndex
}
}
function close() {
listView.currentIndex = -1
active = false
}
}
@@ -0,0 +1,33 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype HandwritingModeKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits Key
\since QtQuick.VirtualKeyboard 2.0
\brief Hand writing mode key for keyboard layouts.
This key toggles between the handwriting mode layout and the main layout.
The key is automatically hidden from the keyboard layout if handwriting support
is not enabled for the virtual keyboard.
*/
Key {
keyType: QtVirtualKeyboard.KeyType.HandwritingModeKey
key: Qt.Key_Context2
displayText: "HWR"
functionKey: true
highlighted: true
visible: keyboard.isKeyboardFunctionAvailable(QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode)
onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode)
keyPanelDelegate: keyboard.style ? keyboard.style.handwritingKeyPanel : undefined
}
@@ -0,0 +1,28 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
import QtQuick.VirtualKeyboard.Settings
/*!
\qmltype HideKeyboardKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits BaseKey
\brief Hide keyboard key for keyboard layouts.
This key hides the keyboard from the user when pressed.
*/
BaseKey {
keyType: QtVirtualKeyboard.KeyType.HideKeyboardKey
functionKey: true
highlighted: true
onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.KeyboardFunction.HideInputPanel)
keyPanelDelegate: keyboard.style ? keyboard.style.hideKeyPanel : undefined
visible: VirtualKeyboardSettings.visibleFunctionKeys & QtVirtualKeyboard.KeyboardFunctionKeys.Hide
}
@@ -0,0 +1,104 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype InputModeKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits Key
\since QtQuick.VirtualKeyboard 2.3
\brief Input mode key for keyboard layouts.
This key toggles between available \l {QVirtualKeyboardInputEngine::inputModes} {InputEngine.inputModes}.
*/
Key {
keyType: QtVirtualKeyboard.KeyType.InputModeKey
key: Qt.Key_Mode_switch
noKeyEvent: true
functionKey: true
highlighted: true
text: InputContext.inputEngine.inputMode < inputModeNameList.length ?
inputModeNameList[InputContext.inputEngine.inputMode] : "ABC"
onClicked: InputContext.inputEngine.inputMode = __nextInputMode(InputContext.inputEngine.inputMode)
keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined
enabled: inputModeCount > 1
/*!
List of input mode names.
The default list contains all known input modes for \l {QVirtualKeyboardInputEngine::inputMode} {InputEngine.inputMode}.
*/
property var inputModeNameList: [
"ABC", // InputEngine.InputMode.Latin
"123", // InputEngine.InputMode.Numeric
"123", // InputEngine.InputMode.Dialable
"拼音", // InputEngine.InputMode.Pinyin
"倉頡", // InputEngine.InputMode.Cangjie
"注音", // InputEngine.InputMode.Zhuyin
"한글", // InputEngine.InputMode.Hangul
"かな", // InputEngine.InputMode.Hiragana
"カナ", // InputEngine.InputMode.Katakana
"全角", // InputEngine.InputMode.FullwidthLatin
"ΑΒΓ", // InputEngine.InputMode.Greek
"АБВ", // InputEngine.InputMode.Cyrillic
"\u0623\u200C\u0628\u200C\u062C", // InputEngine.InputMode.Arabic
"\u05D0\u05D1\u05D2", // InputEngine.InputMode.Hebrew
"中文", // InputEngine.InputMode.ChineseHandwriting
"日本語", // InputEngine.InputMode.JapaneseHandwriting
"한국어", // InputEngine.InputMode.KoreanHandwriting
"กขค", // InputEngine.InputMode.Thai
"笔画", // InputEngine.InputMode.Stroke
"ABC", // InputEngine.InputMode.Romaji
"FLK", // InputEngine.InputMode.HiraganaFlick
]
/*!
List of input modes to toggle.
This property allows to define a custom list of input modes to
toggle.
The default list contains all the available input modes.
*/
property var inputModes: InputContext.inputEngine.inputModes
/*!
This read-only property reflects the actual number of input modes
the user can cycle through this key.
*/
readonly property int inputModeCount: __inputModes !== undefined ? __inputModes.length : 0
property var __inputModes: __filterInputModes([].concat(InputContext.inputEngine.inputModes), inputModes)
onInputModesChanged: {
// Check that the current input mode is included in our list
if (keyboard.active && InputContext.inputEngine.inputMode !== -1 &&
__inputModes !== undefined && __inputModes.length > 0 &&
__inputModes.indexOf(InputContext.inputEngine.inputMode) === -1)
InputContext.inputEngine.inputMode = __inputModes[0]
}
function __nextInputMode(inputMode) {
if (!enabled)
return inputMode
var inputModeIndex = __inputModes.indexOf(inputMode) + 1
if (inputModeIndex >= __inputModes.length)
inputModeIndex = 0
return __inputModes[inputModeIndex]
}
function __filterInputModes(inputModes, filter) {
for (var i = 0; i < inputModes.length; i++) {
if (filter.indexOf(inputModes[i]) === -1)
inputModes.splice(i, 1)
}
return inputModes
}
}
@@ -0,0 +1,25 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype Key
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits BaseKey
\brief Regular character key for keyboard layouts.
This key emits the key code and key text for input method processing.
*/
BaseKey {
id: keyItem
keyType: QtVirtualKeyboard.KeyType.Key
key: !functionKey && text.length > 0 ? text.toUpperCase().charCodeAt(0) : Qt.Key_unknown
keyPanelDelegate: keyboard.style ? keyboard.style.keyPanel : undefined
}
@@ -0,0 +1,38 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Layouts
/*!
\qmltype KeyboardColumn
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\inherits ColumnLayout
\brief Keyboard column for keyboard layouts.
This type can be used in special cases where multiple columns
are added to a single keyboard layout.
*/
ColumnLayout {
/*! Sets the key weight for all children keys.
The default value is inherited from the parent element
in the layout hierarchy.
*/
property real keyWeight: parent ? parent.keyWeight : undefined
/*! \since QtQuick.VirtualKeyboard 2.0
Sets the \c smallTextVisible for all children keys.
The default value is inherited from the parent element
in the layout hierarchy.
*/
property bool smallTextVisible: parent ? parent.smallTextVisible : false
spacing: 0
}
@@ -0,0 +1,163 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Layouts
import QtQuick.VirtualKeyboard
/*!
\qmltype KeyboardLayout
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\inherits ColumnLayout
\brief Keyboard layout.
This type is the root element of the keyboard layout.
Use this element to build a new keyboard layout.
Example:
\code
import QtQuick
import QtQuick.Layouts
import QtQuick.VirtualKeyboard
// file: layouts/en_GB/main.qml
KeyboardLayout {
KeyboardRow {
Key {
key: Qt.Key_Q
text: "q"
}
Key {
key: Qt.Key_W
text: "w"
}
Key {
key: Qt.Key_E
text: "e"
}
Key {
key: Qt.Key_R
text: "r"
}
Key {
key: Qt.Key_T
text: "t"
}
Key {
key: Qt.Key_Y
text: "y"
}
}
}
\endcode
*/
ColumnLayout {
id: root
/*! Sets the input method to be used in this layout.
This property allows a custom input method to be
used in this layout.
*/
property var inputMethod
/*! This function may be overridden by the keyboard layout
to create the input method object dynamically. The default
implementation returns \c null.
The input method object created by this function can outlive
keyboard layout transitions in certain cases. In particular,
this applies to the transitions between the layouts listed in
the sharedLayouts property.
*/
function createInputMethod() {
return null
}
/*! List of layout names which share the input method created
by the createInputMethod() function.
If the list is empty (the default) the input method is not
shared with any other layout and will be destroyed when the
layout changes.
The list should contain only the name of the layout type,
e.g., ['symbols']. The current layout does not have to be
included in the list.
*/
property var sharedLayouts
/*! Sets the input mode to be used in this layout.
By default, the virtual keyboard attempts to preserve
the current input mode when switching to a different
keyboard layout.
If the current input mode is not valid in the current
context, the default input mode is specified by the
input method.
*/
property int inputMode: -1
/*! Sets the key weight for all children keys.
The default value is inherited from the parent element
in the layout hierarchy.
*/
property real keyWeight
/*! \since QtQuick.VirtualKeyboard 2.0
Sets the \c smallTextVisible for all children keys.
The default value is inherited from the parent element
in the layout hierarchy.
*/
property bool smallTextVisible
spacing: 0
function scanLayout() {
var layout = {
width: root.width,
height: root.height,
keys: []
}
__scanLayoutRecursive(this, layout)
return layout
}
function __scanLayoutRecursive(parent, layout) {
for (var i in parent.children) {
var child = parent.children[i]
if (child.keyType !== undefined) {
var pos = mapFromItem(child, 0, 0)
var key = {
left: pos.x,
top: pos.y,
width: child.width,
height: child.height,
keyType: child.keyType,
key: child.key,
text: child.text,
altKeys: child.effectiveAlternativeKeys,
isFunctionKey: child.functionKey,
noKeyEvent: child.noKeyEvent
}
if (key.left + key.width > layout.width)
layout.width = key.left + key.width
if (key.top + key.height > layout.height)
layout.height = key.top + key.height
layout.keys.push(key)
} else {
__scanLayoutRecursive(child, layout)
}
}
}
}
@@ -0,0 +1,115 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype KeyboardLayoutLoader
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\inherits Loader
\since QtQuick.VirtualKeyboard 1.1
\brief Allows dynamic loading of keyboard layout.
This type is useful for keyboard layouts consisting of multiple pages of keys.
A single keyboard layout (a page) is defined by using the Component
as a container. The active keyboard layout can then be changed by
setting the sourceComponent property to a different value.
Example:
\code
import QtQuick
import QtQuick.Layouts
import QtQuick.VirtualKeyboard
// file: layouts/en_GB/symbols.qml
KeyboardLayoutLoader {
property bool secondPage
onVisibleChanged: if (!visible) secondPage = false
sourceComponent: secondPage ? page2 : page1
Component {
id: page1
KeyboardLayout {
// Keyboard layout definition for page 1
}
}
Component {
id: page2
KeyboardLayout {
// Keyboard layout definition for page 2
}
}
}
\endcode
*/
Loader {
/*! Sets the input method for all the keyboard layouts loaded
in this context.
The input method can either be set separately for each keyboard
layout, or commonly at this context. If set separately, then this
property should not be modified.
*/
property var inputMethod: item ? item.inputMethod : null
/*! This function may be overridden by the keyboard layout
to create the input method object dynamically. The default
implementation forwards the call to the child keyboard
layout.
The input method object created by this function can outlive
keyboard layout transitions in certain cases. In particular,
this applies to the transitions between the layouts listed in
the sharedLayouts property.
*/
function createInputMethod() {
return item ? item.createInputMethod() : null
}
/*! List of layout names which share the input method created
by the createInputMethod() function.
If the list is empty (the default) the input method is not
shared with any other layout and will be destroyed when the
layout changes.
The list should contain only the name of the layout type,
e.g., ['symbols']. The current layout does not have to be
included in the list.
*/
property var sharedLayouts: item ? item.sharedLayouts : null
/*! Sets the input mode for all the keyboard layouts loaded
in this context.
The input mode can either be set separately for each keyboard
layout, or commonly at this context. If set separately, then this
property should not be modified.
*/
property int inputMode: item ? item.inputMode : -1
property int __updateCount
active: parent !== null
onItemChanged: {
if (parent && item && __updateCount++ > 0) {
if (!keyboard.inputMethodNeedsReset)
keyboard.updateInputMethod()
keyboard.notifyLayoutChanged()
}
}
function scanLayout() {
if (item === null)
return null
return item.scanLayout()
}
}
@@ -0,0 +1,37 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Layouts
/*!
\qmltype KeyboardRow
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\inherits RowLayout
\brief Keyboard row for keyboard layouts.
Specifies a row of keys in the keyboard layout.
*/
RowLayout {
/*! Sets the key weight for all children keys.
The default value is inherited from the parent element
in the layout hierarchy.
*/
property real keyWeight: parent ? parent.keyWeight : undefined
/*! \since QtQuick.VirtualKeyboard 2.0
Sets the \c smallTextVisible for all children keys.
The default value is inherited from the parent element
in the layout hierarchy.
*/
property bool smallTextVisible: parent ? parent.smallTextVisible : false
spacing: 0
}
@@ -0,0 +1,42 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype ModeKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits Key
\since QtQuick.VirtualKeyboard 2.0
\brief Generic mode key for keyboard layouts.
This key provides generic mode button functionality.
A key press toggles the current mode without emitting key event
for input method processing.
ModeKey can be used in situations where a particular mode is switched
"ON / OFF", and where the mode change does not require changing the
keyboard layout. When this component is used, the \l { BaseKey::displayText } { displayText } should
remain the same regardless of the mode, because the keyboard style
visualizes the status.
*/
Key {
/*! This property provides the current mode.
The default is false.
*/
property bool mode
keyType: QtVirtualKeyboard.KeyType.ModeKey
noKeyEvent: true
functionKey: true
highlighted: true
onClicked: mode = !mode
keyPanelDelegate: keyboard.style ? keyboard.style.modeKeyPanel : undefined
}
@@ -0,0 +1,49 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtMultimedia
Item {
id: multiSoundEffect
property url source
property int maxInstances: 2
property var __cachedInstances
property int __currentIndex: 0
property real soundVolume: 1.0
signal playingChanged(url source, bool playing)
Component {
id: soundEffectComp
SoundEffect {
source: multiSoundEffect.source
onPlayingChanged: multiSoundEffect.playingChanged(source, playing)
}
}
onSourceChanged: {
__cachedInstances = []
__currentIndex = 0
if (source != Qt.resolvedUrl("")) {
var i
for (i = 0; i < maxInstances; i++) {
var soundEffect = soundEffectComp.createObject(multiSoundEffect)
if (soundEffect === null)
return
__cachedInstances.push(soundEffect)
}
}
}
function play() {
if (__cachedInstances === undefined || __cachedInstances.length === 0)
return
if (__cachedInstances[__currentIndex].playing) {
__cachedInstances[__currentIndex].stop()
__currentIndex = (__currentIndex + 1) % __cachedInstances.length
}
__cachedInstances[__currentIndex].volume = soundVolume
__cachedInstances[__currentIndex].play()
}
}
@@ -0,0 +1,106 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard as VKB
VKB.InputMethod {
property string multitapSequence
property int multitapIndex: -1
onMultitapSequenceChanged: selectionListChanged(VKB.SelectionListModel.Type.WordCandidateList)
onMultitapIndexChanged: selectionListActiveItemChanged(VKB.SelectionListModel.Type.WordCandidateList, multitapIndex)
property variant multiTapTimer: Timer {
interval: 1200
onTriggered: {
update()
}
}
function inputModes(locale) {
return [VKB.InputEngine.InputMode.Latin, VKB.InputEngine.InputMode.Numeric, VKB.InputEngine.InputMode.Dialable];
}
function setInputMode(locale, inputMode) {
return true
}
function setTextCase(textCase) {
return true
}
function reset() {
multiTapTimer.stop()
multitapIndex = -1
multitapSequence = ""
}
function update() {
multiTapTimer.stop()
multitapIndex = -1
multitapSequence = ""
if (inputContext !== null && inputContext.preeditText.length > 0) {
inputContext.commit()
}
}
function keyEvent(key, text, modifiers) {
var accept = false
switch (key) {
case Qt.Key_Enter:
case Qt.Key_Return:
case Qt.Key_Tab:
update()
break
case Qt.Key_Backspace:
if (inputContext.preeditText.length > 0) {
inputContext.clear()
update()
accept = true
}
break
default:
if (key !== inputEngine.previousKey) {
update()
}
multitapSequence = text
if (multitapSequence.length > 1) {
multitapIndex = multiTapTimer.running ? (multitapIndex + 1) % multitapSequence.length : 0
inputContext.preeditText = multitapSequence.charAt(multitapIndex)
multiTapTimer.restart()
} else {
inputContext.commit(text)
}
accept = true
break
}
return accept;
}
function selectionLists() {
return [VKB.SelectionListModel.Type.WordCandidateList];
}
function selectionListItemCount(type) {
return multitapSequence.length > 1 ? multitapSequence.length : 0
}
function selectionListData(type, index, role) {
var result = null
switch (role) {
case VKB.SelectionListModel.Role.Display:
result = multitapSequence.charAt(index)
break
default:
break
}
return result
}
function selectionListItemSelected(type, index) {
multitapIndex = index
inputContext.preeditText = multitapSequence.charAt(multitapIndex)
update()
}
}
@@ -0,0 +1,25 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype NumberKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits Key
\brief Specialized number key for keyboard layouts.
This key emits the key code and key text for input method processing.
A NumberKey differs from a normal \l Key in that it does not show a
character preview.
*/
Key {
showPreview: false
keyType: QtVirtualKeyboard.KeyType.NumberKey
}
@@ -0,0 +1,33 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
ListView {
property int maxVisibleItems: 5
readonly property int preferredVisibleItems: count < maxVisibleItems ? count : maxVisibleItems
readonly property real contentWidth: contentItem.childrenRect.width
property alias defaultHighlight: defaultHighlight
clip: true
visible: enabled && count > 0
width: contentWidth
height: currentItem ? currentItem.height * preferredVisibleItems + (spacing * preferredVisibleItems - 1) : 0
orientation: ListView.Vertical
snapMode: ListView.SnapToItem
delegate: keyboard.style.popupListDelegate
highlight: keyboard.style.popupListHighlight ? keyboard.style.popupListHighlight : defaultHighlight
highlightMoveDuration: 0
highlightResizeDuration: 0
add: !keyboard.noAnimations ? keyboard.style.popupListAdd : null
remove: !keyboard.noAnimations ? keyboard.style.popupListRemove : null
keyNavigationWraps: true
onCurrentItemChanged: if (currentItem) keyboard.soundEffect.register(currentItem.soundEffect)
Component {
id: defaultHighlight
Item {}
}
}
@@ -0,0 +1,84 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
Item {
id: root
property bool handleIsMoving: false
property var inputContext: InputContext
visible: enabled && (inputContext.selectionControlVisible || handleIsMoving) && !InputContext.animating
Loader {
id: anchorHandle
sourceComponent: keyboard.style.selectionHandle
Behavior on opacity {
NumberAnimation { duration: 200 }
}
opacity: inputContext !== null && inputContext.anchorRectIntersectsClipRect ? 1.0 : 0.0
MouseArea {
width: parent.width * 2
height: width * 1.12
anchors.centerIn: parent
onPositionChanged: function(mouse) {
// we don't move the handles, the handles will move as the selection changes.
// The middle of a handle is mapped to the middle of the line above it
root.handleIsMoving = true
var xx = x + anchorHandle.x + mouse.x
var yy = y + anchorHandle.y + mouse.y - (anchorHandle.height + inputContext.anchorRectangle.height)/2
var x2 = cursorHandle.x + cursorHandle.width/2
var y2 = cursorHandle.y - inputContext.cursorRectangle.height/2
inputContext.setSelectionOnFocusObject(Qt.point(xx,yy), Qt.point(x2,y2))
}
onReleased: {
root.handleIsMoving = false
}
}
}
// selection cursor handle
Loader {
id: cursorHandle
sourceComponent: keyboard.style.selectionHandle
Behavior on opacity {
NumberAnimation { duration: 200 }
}
opacity: inputContext !== null && inputContext.cursorRectIntersectsClipRect ? 1.0 : 0.0
MouseArea {
width: parent.width * 2
height: width * 1.12
anchors.centerIn: parent
onPositionChanged: function(mouse) {
// we don't move the handles, the handles will move as the selection changes.
root.handleIsMoving = true
var xx = anchorHandle.x + anchorHandle.width/2
var yy = anchorHandle.y - inputContext.anchorRectangle.height/2
var x2 = x + cursorHandle.x + mouse.x
var y2 = y + cursorHandle.y + mouse.y - (cursorHandle.height + inputContext.cursorRectangle.height)/2
inputContext.setSelectionOnFocusObject(Qt.point(xx, yy), Qt.point(x2, y2))
}
onReleased: {
root.handleIsMoving = false
}
}
}
Connections {
target: inputContext
function onCursorRectangleChanged() {
var cursorItemPos = root.mapFromItem(null, inputContext.cursorRectangle.x, inputContext.cursorRectangle.y)
cursorHandle.x = cursorItemPos.x - cursorHandle.width/2
cursorHandle.y = cursorItemPos.y + inputContext.cursorRectangle.height
}
function onAnchorRectangleChanged() {
var anchorItemPos = root.mapFromItem(null, inputContext.anchorRectangle.x, inputContext.anchorRectangle.y)
anchorHandle.x = anchorItemPos.x - anchorHandle.width/2
anchorHandle.y = anchorItemPos.y + inputContext.anchorRectangle.height
}
}
}
@@ -0,0 +1,147 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
// Deliberately imported after QtQuick to avoid missing restoreMode property in Binding. Fix in Qt 6.
import QtQml
import QtQuick.VirtualKeyboard
import QtQuick.VirtualKeyboard.Settings
Item {
id: control
property alias textEdit: shadowInput
property real contentWidth
property real contentHeight
enabled: keyboard.active && VirtualKeyboardSettings.fullScreenMode
MouseArea {
anchors.fill: parent
}
onXChanged: InputContext.priv.shadow.updateSelectionProperties()
onYChanged: InputContext.priv.shadow.updateSelectionProperties()
Binding {
control.contentWidth: flickable.contentWidth + 2 * (keyboard.style.fullScreenInputMargins + keyboard.style.fullScreenInputPadding) + shadowInput.cursorRectangle.width
control.contentHeight: flickable.contentHeight + 2 * (keyboard.style.fullScreenInputMargins + keyboard.style.fullScreenInputPadding)
when: keyboard.style
}
Loader {
id: containerBackground
sourceComponent: keyboard.style.fullScreenInputContainerBackground
anchors.fill: parent
}
Loader {
id: fullScreenInputBackground
sourceComponent: keyboard.style.fullScreenInputBackground
anchors.fill: parent
anchors.margins: keyboard.style.fullScreenInputMargins
}
Flickable {
id: flickable
clip: true
width: containerBackground.width
height: containerBackground.height
Binding {
flickable.x: keyboard.style.fullScreenInputMargins + keyboard.style.fullScreenInputPadding
flickable.width: containerBackground.width - 2 * (keyboard.style.fullScreenInputMargins + keyboard.style.fullScreenInputPadding)
when: keyboard.style
}
flickableDirection: Flickable.HorizontalFlick
interactive: contentWidth > width
contentWidth: shadowInput.contentWidth + 2 * shadowInput.padding + shadowInput.cursorRectangle.width
contentHeight: shadowInput.contentHeight + 2 * shadowInput.padding
onContentXChanged: InputContext.priv.shadow.updateSelectionProperties()
function ensureVisible(rectangle) {
if (contentX >= rectangle.x)
contentX = rectangle.x
else if (contentX + width <= rectangle.x + rectangle.width)
contentX = rectangle.x + rectangle.width - width;
}
TextInput {
id: shadowInput
objectName: "shadowInput"
property bool blinkStatus: true
Binding {
shadowInput.y: keyboard.style.fullScreenInputMargins
when: keyboard.style
}
width: contentWidth + 1 // cursorRectangle.width causes binding loop
topPadding: keyboard.style.fullScreenInputPadding
bottomPadding: keyboard.style.fullScreenInputPadding
activeFocusOnPress: false
font: keyboard.style.fullScreenInputFont
inputMethodHints: InputContext.inputMethodHints
cursorDelegate: keyboard.style.fullScreenInputCursor
passwordCharacter: keyboard.style.fullScreenInputPasswordCharacter
color: keyboard.style.fullScreenInputColor
selectionColor: keyboard.style.fullScreenInputSelectionColor
selectedTextColor: keyboard.style.fullScreenInputSelectedTextColor
echoMode: (InputContext.inputMethodHints & Qt.ImhHiddenText) ? TextInput.Password : TextInput.Normal
selectByMouse: !!InputContext.inputItem && !!InputContext.inputItem.selectByMouse
onCursorPositionChanged: {
cursorSyncTimer.restart()
blinkStatus = true
if (cursorTimer.running)
cursorTimer.restart()
}
onSelectionStartChanged: cursorSyncTimer.restart()
onSelectionEndChanged: cursorSyncTimer.restart()
onCursorRectangleChanged: flickable.ensureVisible(cursorRectangle)
function getAnchorPosition() {
if (selectionStart == selectionEnd)
return cursorPosition
else if (selectionStart == cursorPosition)
return selectionEnd
else
return selectionStart
}
Timer {
id: cursorSyncTimer
interval: 0
onTriggered: {
var anchorPosition = shadowInput.getAnchorPosition()
if (anchorPosition !== InputContext.anchorPosition || shadowInput.cursorPosition !== InputContext.cursorPosition)
InputContext.priv.forceCursorPosition(anchorPosition, shadowInput.cursorPosition)
}
}
Timer {
id: cursorTimer
interval: Qt.styleHints.cursorFlashTime / 2
repeat: true
running: control.visible
onTriggered: shadowInput.blinkStatus = !shadowInput.blinkStatus
}
}
}
Component.onCompleted: {
if (VirtualKeyboardSettings.fullScreenMode) {
InputContext.priv.shadow.inputItem = shadowInput
}
}
Connections {
target: VirtualKeyboardSettings
function onFullScreenModeChanged() {
InputContext.priv.shadow.inputItem = VirtualKeyboardSettings.fullScreenMode ? shadowInput : null
}
}
Connections {
target: InputContext.priv.shadow
function onInputItemChanged() {
cursorSyncTimer.stop()
if (!InputContext.priv.shadow.inputItem)
shadowInput.clear()
}
}
}
@@ -0,0 +1,29 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype ShiftKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits BaseKey
\brief Shift key for keyboard layouts.
This key changes the shift state of the keyboard.
*/
BaseKey {
id: shiftKey
keyType: QtVirtualKeyboard.KeyType.ShiftKey
key: Qt.Key_Shift
enabled: InputContext.priv.shiftHandler.toggleShiftEnabled
highlighted: true
functionKey: true
keyPanelDelegate: keyboard.style ? keyboard.style.shiftKeyPanel : undefined
onClicked: InputContext.priv.shiftHandler.toggleShift()
}
@@ -0,0 +1,29 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype SpaceKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits Key
\brief Space key for keyboard layouts.
This key emits a space for input method processing.
*/
Key {
keyType: QtVirtualKeyboard.KeyType.SpaceKey
text: " "
displayText: ""
repeat: true
showPreview: false
highlighted: true
key: Qt.Key_Space
keyPanelDelegate: keyboard.style ? keyboard.style.spaceKeyPanel : undefined
}
@@ -0,0 +1,28 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.VirtualKeyboard
/*!
\qmltype SymbolModeKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits Key
\brief Symbol mode key for keyboard layouts.
This key toggles between the symbol mode layout and the main layout.
*/
Key {
keyType: QtVirtualKeyboard.KeyType.SymbolModeKey
key: Qt.Key_Context1
displayText: "&123"
functionKey: true
highlighted: true
onClicked: keyboard.symbolMode = !keyboard.symbolMode
keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined
}
@@ -0,0 +1,198 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Window
import QtQuick.VirtualKeyboard
/*!
\qmltype TraceInputArea
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\inherits MultiPointTouchArea
\since QtQuick.VirtualKeyboard 2.0
\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
\l {KeyboardStyle::}{traceCanvasDelegate} property of the current
\l KeyboardStyle.
*/
MultiPointTouchArea {
id: traceInputArea
/*! Pattern recognition mode of this input area.
The default value is \l {InputEngine::patternRecognitionModes} {InputEngine.PatternRecognitionMode.None}.
*/
property int patternRecognitionMode: InputEngine.PatternRecognitionMode.None
/*! 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 that demonstrates 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)
/*! Canvas type of this trace input area.
This property can be used to distinguish between different types of canvases.
For example, in full screen handwriting mode this property is set to \c "fullscreen", and
in keyboard handwriting mode this property is set to \c "keyboard".
*/
property string canvasType
property var __activeTraceCanvases: ({})
property var __traceCanvasList: ([])
property var __recycledTraceCanvasList: ([])
Component.onCompleted: {
for (var i = 0; i < 6; i++) {
__recycledTraceCanvasList.push(__createTraceCanvas())
}
}
function __getTraceCanvas() {
while (__recycledTraceCanvasList.length == 0 &&
__traceCanvasList.length >= 15 &&
!__traceCanvasList.shift().recycle()) {}
return __recycledTraceCanvasList.length > 0 ?
__recycledTraceCanvasList.pop() :
__createTraceCanvas()
}
function __createTraceCanvas() {
var traceCanvas = keyboard.style.traceCanvasDelegate.createObject(traceInputArea)
traceCanvas.onRecycle.connect(__onTraceCanvasRecycled)
traceCanvas.anchors.fill = traceCanvas.parent
return traceCanvas
}
function __onTraceCanvasRecycled(traceCanvas) {
var index = __traceCanvasList.findIndex(function(otherCanvas) {
return traceCanvas === otherCanvas
})
if (index !== -1) {
__traceCanvasList.splice(index, index + 1)
}
__recycledTraceCanvasList.push(traceCanvas)
}
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,
canvasType: traceInputArea.canvasType
})
enabled: patternRecognitionMode !== InputEngine.PatternRecognitionMode.None && InputContext.inputEngine.patternRecognitionModes.indexOf(patternRecognitionMode) !== -1
onPressed: (touchPoints) => {
if (!keyboard.style.traceCanvasDelegate)
return
for (var i = 0; i < touchPoints.length; i++) {
var traceId = touchPoints[i].pointId
var trace = InputContext.inputEngine.traceBegin(traceId, patternRecognitionMode, __traceCaptureDeviceInfo, __traceScreenInfo)
if (trace) {
var traceCanvas = __getTraceCanvas()
if (traceCanvas) {
traceCanvas.trace = 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())
}
__activeTraceCanvases[traceId] = traceCanvas
} else {
__activeTraceCanvases[traceId] = null
}
} else {
__activeTraceCanvases[traceId] = null
}
}
}
onUpdated: (touchPoints) => {
for (var i = 0; i < touchPoints.length; i++) {
var traceId = touchPoints[i].pointId
var traceCanvas = __activeTraceCanvases[traceId]
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: (touchPoints) => {
for (var i = 0; i < touchPoints.length; i++) {
var traceId = touchPoints[i].pointId
var traceCanvas = __activeTraceCanvases[traceId]
if (traceCanvas) {
if (traceCanvas.trace) {
traceCanvas.trace.final = true
InputContext.inputEngine.traceEnd(traceCanvas.trace)
}
__traceCanvasList.push(traceCanvas)
__activeTraceCanvases[traceId] = null
}
}
}
onCanceled: (touchPoints) => {
for (var i = 0; i < touchPoints.length; i++) {
var traceId = touchPoints[i].pointId
var traceCanvas = __activeTraceCanvases[traceId]
if (traceCanvas) {
if (traceCanvas.trace) {
traceCanvas.trace.final = true
traceCanvas.trace.canceled = true
InputContext.inputEngine.traceEnd(traceCanvas.trace)
}
__traceCanvasList.push(traceCanvas)
__activeTraceCanvases[traceId] = null
}
}
}
}
@@ -0,0 +1,92 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Layouts
/*!
\qmltype TraceInputKey
\inqmlmodule QtQuick.VirtualKeyboard.Components
\ingroup qmlclass
\ingroup qtvirtualkeyboard-components-qml
\ingroup qtvirtualkeyboard-key-types
\inherits Item
\since QtQuick.VirtualKeyboard 2.0
\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 {InputEngine::patternRecognitionModes} {InputEngine.PatternRecognitionMode.None}.
*/
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 that demonstrates 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
/*! Canvas type of this trace input area.
This property can be used to distinguish between different types of canvases.
The default value is \c "keyboard".
*/
property alias canvasType: traceInputArea.canvasType
Layout.minimumWidth: traceInputKeyPanel.implicitWidth
Layout.minimumHeight: traceInputKeyPanel.implicitHeight
Layout.preferredWidth: weight
Layout.fillWidth: true
Layout.fillHeight: true
canvasType: "keyboard"
Loader {
id: traceInputKeyPanel
sourceComponent: keyboard.style.traceInputKeyPanelDelegate
anchors.fill: parent
onLoaded: traceInputKeyPanel.item.control = traceInputKey
}
TraceInputArea {
id: traceInputArea
anchors.fill: traceInputKeyPanel
anchors.margins: traceInputKeyPanel.item ? traceInputKeyPanel.item.traceMargins : 0
}
}
@@ -0,0 +1,59 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
// Deliberately imported after QtQuick to avoid missing restoreMode property in Binding. Fix in Qt 6.
import QtQml
import QtQuick.VirtualKeyboard
PopupList {
id: wordCandidatePopupList
readonly property int preferredVisibleItems: {
if (!currentItem)
return 0
var maxHeight = flipVertical ? Qt.inputMethod.cursorRectangle.y : parent.height - Qt.inputMethod.cursorRectangle.height - Qt.inputMethod.cursorRectangle.y
var result = Math.min(count, maxVisibleItems)
while (result > 2 && result * currentItem.height > maxHeight)
--result
return result
}
readonly property bool flipVertical: currentItem &&
Qt.inputMethod.cursorRectangle.y + (Qt.inputMethod.cursorRectangle.height / 2) > (parent.height / 2) &&
Qt.inputMethod.cursorRectangle.y + Qt.inputMethod.cursorRectangle.height + (currentItem.height * 2) > parent.height
height: currentItem ? currentItem.height * preferredVisibleItems + (spacing * preferredVisibleItems - 1) : 0
Binding {
target: wordCandidatePopupList
property: "x"
value: Math.round(Qt.inputMethod.cursorRectangle.x -
(wordCandidatePopupList.currentItem ?
(wordCandidatePopupList.currentItem.hasOwnProperty("cursorAnchor") ?
wordCandidatePopupList.currentItem.cursorAnchor : wordCandidatePopupList.currentItem.width) : 0))
when: wordCandidatePopupList.visible
restoreMode: Binding.RestoreBinding
}
Binding {
target: wordCandidatePopupList
property: "y"
value: Math.round(wordCandidatePopupList.flipVertical ? Qt.inputMethod.cursorRectangle.y - wordCandidatePopupList.height : Qt.inputMethod.cursorRectangle.y + Qt.inputMethod.cursorRectangle.height)
when: wordCandidatePopupList.visible
restoreMode: Binding.RestoreBinding
}
model: enabled ? InputContext.inputEngine.wordCandidateListModel : null
onContentWidthChanged: viewResizeTimer.restart()
Timer {
id: viewResizeTimer
interval: 0
repeat: false
onTriggered: wordCandidatePopupList.width = wordCandidatePopupList.contentWidth
}
Connections {
target: wordCandidatePopupList.model ? wordCandidatePopupList.model : null
function onActiveItemChanged(index) { wordCandidatePopupList.currentIndex = index }
function onItemSelected() { if (wordCandidatePopupList.currentItem) keyboard.soundEffect.play(wordCandidatePopupList.currentItem.soundEffect) }
}
}
@@ -0,0 +1,103 @@
module QtQuick.VirtualKeyboard.Components
linktarget Qt6::qtvkbcomponentsplugin
optional plugin qtvkbcomponentsplugin
classname QtQuick_VirtualKeyboard_ComponentsPlugin
typeinfo qtvkbcomponentsplugin.qmltypes
depends QtQuick auto
depends QtQuick.Layouts auto
depends QtQuick.VirtualKeyboard.Settings auto
prefer :/qt-project.org/imports/QtQuick/VirtualKeyboard/Components/
AlternativeKeys 6.0 AlternativeKeys.qml
AlternativeKeys 2.0 AlternativeKeys.qml
AlternativeKeys 1.0 AlternativeKeys.qml
BackspaceKey 6.0 BackspaceKey.qml
BackspaceKey 2.0 BackspaceKey.qml
BackspaceKey 1.0 BackspaceKey.qml
BaseKey 6.0 BaseKey.qml
BaseKey 2.0 BaseKey.qml
BaseKey 1.0 BaseKey.qml
ChangeLanguageKey 6.0 ChangeLanguageKey.qml
ChangeLanguageKey 2.0 ChangeLanguageKey.qml
ChangeLanguageKey 1.0 ChangeLanguageKey.qml
CharacterPreviewBubble 6.0 CharacterPreviewBubble.qml
CharacterPreviewBubble 2.0 CharacterPreviewBubble.qml
CharacterPreviewBubble 1.0 CharacterPreviewBubble.qml
EnterKey 6.0 EnterKey.qml
EnterKey 2.0 EnterKey.qml
EnterKey 1.0 EnterKey.qml
FillerKey 6.0 FillerKey.qml
FillerKey 2.0 FillerKey.qml
FillerKey 1.0 FillerKey.qml
FlickKey 6.0 FlickKey.qml
FlickKey 2.0 FlickKey.qml
FlickKey 1.0 FlickKey.qml
FunctionPopupList 6.0 FunctionPopupList.qml
FunctionPopupList 2.0 FunctionPopupList.qml
FunctionPopupList 1.0 FunctionPopupList.qml
HandwritingModeKey 6.0 HandwritingModeKey.qml
HandwritingModeKey 2.0 HandwritingModeKey.qml
HandwritingModeKey 1.0 HandwritingModeKey.qml
HideKeyboardKey 6.0 HideKeyboardKey.qml
HideKeyboardKey 2.0 HideKeyboardKey.qml
HideKeyboardKey 1.0 HideKeyboardKey.qml
InputModeKey 6.0 InputModeKey.qml
InputModeKey 2.0 InputModeKey.qml
InputModeKey 1.0 InputModeKey.qml
Key 6.0 Key.qml
Key 2.0 Key.qml
Key 1.0 Key.qml
Keyboard 6.0 Keyboard.qml
Keyboard 2.0 Keyboard.qml
Keyboard 1.0 Keyboard.qml
KeyboardColumn 6.0 KeyboardColumn.qml
KeyboardColumn 2.0 KeyboardColumn.qml
KeyboardColumn 1.0 KeyboardColumn.qml
KeyboardLayout 6.0 KeyboardLayout.qml
KeyboardLayout 2.0 KeyboardLayout.qml
KeyboardLayout 1.0 KeyboardLayout.qml
KeyboardLayoutLoader 6.0 KeyboardLayoutLoader.qml
KeyboardLayoutLoader 2.0 KeyboardLayoutLoader.qml
KeyboardLayoutLoader 1.0 KeyboardLayoutLoader.qml
KeyboardRow 6.0 KeyboardRow.qml
KeyboardRow 2.0 KeyboardRow.qml
KeyboardRow 1.0 KeyboardRow.qml
ModeKey 6.0 ModeKey.qml
ModeKey 2.0 ModeKey.qml
ModeKey 1.0 ModeKey.qml
MultitapInputMethod 6.0 MultitapInputMethod.qml
MultitapInputMethod 2.0 MultitapInputMethod.qml
MultitapInputMethod 1.0 MultitapInputMethod.qml
NumberKey 6.0 NumberKey.qml
NumberKey 2.0 NumberKey.qml
NumberKey 1.0 NumberKey.qml
PopupList 6.0 PopupList.qml
PopupList 2.0 PopupList.qml
PopupList 1.0 PopupList.qml
SelectionControl 6.0 SelectionControl.qml
SelectionControl 2.0 SelectionControl.qml
SelectionControl 1.0 SelectionControl.qml
ShadowInputControl 6.0 ShadowInputControl.qml
ShadowInputControl 2.0 ShadowInputControl.qml
ShadowInputControl 1.0 ShadowInputControl.qml
ShiftKey 6.0 ShiftKey.qml
ShiftKey 2.0 ShiftKey.qml
ShiftKey 1.0 ShiftKey.qml
SpaceKey 6.0 SpaceKey.qml
SpaceKey 2.0 SpaceKey.qml
SpaceKey 1.0 SpaceKey.qml
SymbolModeKey 6.0 SymbolModeKey.qml
SymbolModeKey 2.0 SymbolModeKey.qml
SymbolModeKey 1.0 SymbolModeKey.qml
TraceInputArea 6.0 TraceInputArea.qml
TraceInputArea 2.0 TraceInputArea.qml
TraceInputArea 1.0 TraceInputArea.qml
TraceInputKey 6.0 TraceInputKey.qml
TraceInputKey 2.0 TraceInputKey.qml
TraceInputKey 1.0 TraceInputKey.qml
WordCandidatePopupList 6.0 WordCandidatePopupList.qml
WordCandidatePopupList 2.0 WordCandidatePopupList.qml
WordCandidatePopupList 1.0 WordCandidatePopupList.qml
MultiSoundEffect 6.0 MultiSoundEffect.qml
MultiSoundEffect 2.0 MultiSoundEffect.qml
MultiSoundEffect 1.0 MultiSoundEffect.qml
@@ -0,0 +1,8 @@
import QtQuick.tooling 1.2
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by qmltyperegistrar.
Module {}