aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2016-11-29 16:07:17 +0200
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-01-14 10:42:39 +0000
commit0a8c8dfc6d4e2b95195b855fcdd1fbd852fdb679 (patch)
tree998317bb475a05dcc82880afa401440fc43c847f
parent58bdb78952d2c9a238507c0c7ea42505dd24664a (diff)
Add language popup
This change adds language popup as an alternative method for selecting the input language. The language popup is enabled when the active style supports it. This change adds the support for the default style. The popup opens from the change language key with single tap and can be dismissed by tapping anywhere else on the keyboard. The old toggle method for changing the input language is still available and supported (can be enabled easily from keyboard style). Some basic tests are included in this change. [ChangeLog] Added language selection popup for faster selection of input language. Change-Id: Ie3773f1d0cac78dee8237285e8596fe57c8bb5e4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/virtualkeyboard/content/components/ChangeLanguageKey.qml24
-rw-r--r--src/virtualkeyboard/content/components/Keyboard.qml172
-rw-r--r--src/virtualkeyboard/content/components/LanguagePopupList.qml67
-rw-r--r--src/virtualkeyboard/content/content.qrc1
-rw-r--r--src/virtualkeyboard/content/styles/default/style.qml70
-rw-r--r--src/virtualkeyboard/plugin.cpp1
-rw-r--r--src/virtualkeyboard/styles/KeyboardStyle.qml63
-rw-r--r--tests/auto/inputpanel/data/inputpanel/inputpanel.qml6
-rw-r--r--tests/auto/inputpanel/data/tst_inputpanel.qml85
9 files changed, 468 insertions, 21 deletions
diff --git a/src/virtualkeyboard/content/components/ChangeLanguageKey.qml b/src/virtualkeyboard/content/components/ChangeLanguageKey.qml
index a152ed22..ba4becde 100644
--- a/src/virtualkeyboard/content/components/ChangeLanguageKey.qml
+++ b/src/virtualkeyboard/content/components/ChangeLanguageKey.qml
@@ -28,6 +28,8 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.VirtualKeyboard 2.1
+import QtQuick.VirtualKeyboard.Styles 2.1
/*!
\qmltype ChangeLanguageKey
@@ -37,8 +39,17 @@ import QtQuick 2.0
\brief Change language key for keyboard layouts.
- Changes the current input language to the next one in the list of supported
- languages.
+ 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 \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 {
@@ -53,9 +64,16 @@ BaseKey {
*/
property bool customLayoutsOnly: false
+ id: changeLanguageKey
+ objectName: "changeLanguageKey"
functionKey: true
displayText: keyboard.locale.split("_")[0]
keyPanelDelegate: keyboard.style ? keyboard.style.languageKeyPanel : undefined
- onClicked: keyboard.changeInputLanguage(customLayoutsOnly)
+ onClicked: {
+ if (keyboard.style.languagePopupListEnabled)
+ keyboard.showLanguagePopup(changeLanguageKey, customLayoutsOnly)
+ else
+ keyboard.changeInputLanguage(customLayoutsOnly)
+ }
enabled: keyboard.canChangeInputLanguage(customLayoutsOnly)
}
diff --git a/src/virtualkeyboard/content/components/Keyboard.qml b/src/virtualkeyboard/content/components/Keyboard.qml
index bb1f4197..e666cc02 100644
--- a/src/virtualkeyboard/content/components/Keyboard.qml
+++ b/src/virtualkeyboard/content/components/Keyboard.qml
@@ -71,6 +71,7 @@ Item {
property bool inputMethodNeedsReset: true
property bool inputModeNeedsReset: true
property bool navigationModeActive: false
+ readonly property bool languagePopupListActive: languagePopupList.enabled
property alias soundEffect: soundEffect
function initDefaultInputMethod() {
@@ -83,6 +84,7 @@ Item {
width: keyboardBackground.width
height: wordCandidateView.height + keyboardBackground.height
onActiveChanged: {
+ hideLanguagePopup()
keyboardInputArea.reset()
}
onActiveKeyChanged: {
@@ -101,7 +103,10 @@ Item {
localeIndex = defaultLocaleIndex
}
}
+ onAvailableLocaleIndicesChanged: hideLanguagePopup()
+ onAvailableCustomLocaleIndicesChanged: hideLanguagePopup()
onLocaleChanged: {
+ hideLanguagePopup()
inputMethodNeedsReset = true
inputModeNeedsReset = true
updateLayout()
@@ -110,6 +115,7 @@ Item {
if (Qt.locale(inputLocale).name !== "C")
InputContext.locale = inputLocale
}
+ onLayoutChanged: hideLanguagePopup()
onLayoutTypeChanged: {
updateAvailableLocaleIndices()
updateLayout()
@@ -127,9 +133,14 @@ Item {
}
onHandwritingModeChanged: if (!keyboard.handwritingMode) keyboard.fullScreenHandwritingMode = false
onFullScreenHandwritingModeChanged: if (keyboard.fullScreenHandwritingMode) keyboard.handwritingMode = true
+ onLanguagePopupListActiveChanged: {
+ if (languagePopupListActive && navigationModeActive)
+ keyboardInputArea.initialKey = null
+ }
Connections {
target: InputContext
+ onInputItemChanged: keyboard.hideLanguagePopup()
onFocusChanged: {
if (InputContext.focus)
updateInputMethod()
@@ -143,6 +154,12 @@ Item {
switch (key) {
case Qt.Key_Left:
if (keyboard.navigationModeActive && !keyboardInputArea.initialKey) {
+ if (languagePopupListActive) {
+ hideLanguagePopup()
+ keyboardInputArea.setActiveKey(null)
+ keyboardInputArea.navigateToNextKey(0, 0, false)
+ break
+ }
if (alternativeKeys.active) {
if (alternativeKeys.listView.currentIndex > 0) {
alternativeKeys.listView.decrementCurrentIndex()
@@ -185,7 +202,17 @@ Item {
}
break
case Qt.Key_Up:
- if (alternativeKeys.active) {
+ if (languagePopupListActive) {
+ if (languagePopupList.currentIndex > 0) {
+ languagePopupList.decrementCurrentIndex()
+ } else if (languagePopupList.keyNavigationWraps) {
+ languagePopupList.currentIndex = languagePopupList.count - 1
+ } else {
+ hideLanguagePopup()
+ keyboardInputArea.setActiveKey(null)
+ keyboardInputArea.navigateToNextKey(0, 0, false)
+ }
+ } else if (alternativeKeys.active) {
alternativeKeys.close()
keyboardInputArea.setActiveKey(null)
keyboardInputArea.navigateToNextKey(0, 0, false)
@@ -205,6 +232,12 @@ Item {
break
case Qt.Key_Right:
if (keyboard.navigationModeActive && !keyboardInputArea.initialKey) {
+ if (languagePopupListActive) {
+ hideLanguagePopup()
+ keyboardInputArea.setActiveKey(null)
+ keyboardInputArea.navigateToNextKey(0, 0, false)
+ break
+ }
if (alternativeKeys.active) {
if (alternativeKeys.listView.currentIndex + 1 < alternativeKeys.listView.count) {
alternativeKeys.listView.incrementCurrentIndex()
@@ -247,7 +280,17 @@ Item {
}
break
case Qt.Key_Down:
- if (alternativeKeys.active) {
+ if (languagePopupListActive) {
+ if (languagePopupList.currentIndex + 1 < languagePopupList.count) {
+ languagePopupList.incrementCurrentIndex()
+ } else if (languagePopupList.keyNavigationWraps) {
+ languagePopupList.currentIndex = 0
+ } else {
+ hideLanguagePopup()
+ keyboardInputArea.setActiveKey(null)
+ keyboardInputArea.navigateToNextKey(0, 0, false)
+ }
+ } else if (alternativeKeys.active) {
alternativeKeys.close()
keyboardInputArea.setActiveKey(null)
keyboardInputArea.navigateToNextKey(0, 0, false)
@@ -268,7 +311,13 @@ Item {
case Qt.Key_Return:
if (!keyboard.navigationModeActive)
break
- if (alternativeKeys.active) {
+ if (languagePopupListActive) {
+ if (!isAutoRepeat) {
+ languagePopupList.model.selectItem(languagePopupList.currentIndex)
+ keyboardInputArea.reset()
+ keyboardInputArea.navigateToNextKey(0, 0, false)
+ }
+ } else if (alternativeKeys.active) {
if (!isAutoRepeat) {
alternativeKeys.clicked()
keyboardInputArea.reset()
@@ -293,14 +342,17 @@ Item {
onNavigationKeyReleased: {
switch (key) {
case Qt.Key_Return:
- if (!keyboard.navigationModeActive)
+ if (!keyboard.navigationModeActive) {
+ if (languagePopupListActive)
+ languagePopupList.model.selectItem(languagePopupList.currentIndex)
break
- if (!alternativeKeys.active && keyboard.activeKey && !isAutoRepeat) {
+ }
+ if (!languagePopupListActive && !alternativeKeys.active && keyboard.activeKey && !isAutoRepeat) {
keyboardInputArea.release(keyboard.activeKey)
pressAndHoldTimer.stop()
alternativeKeys.close()
keyboardInputArea.setActiveKey(null)
- if (keyboardInputArea.navigationCursor !== Qt.point(-1, -1))
+ if (!languagePopupListActive && keyboardInputArea.navigationCursor !== Qt.point(-1, -1))
keyboardInputArea.navigateToNextKey(0, 0, false)
}
break
@@ -403,11 +455,6 @@ Item {
keyboard.y + characterPreview.y,
characterPreview.width,
characterPreview.height)
- onVisibleChanged: {
- if (visible)
- InputContext.previewRectangle = Qt.binding(function() {return previewRect})
- InputContext.previewVisible = visible
- }
}
Binding {
target: InputContext
@@ -415,6 +462,23 @@ Item {
value: Qt.rect(keyboard.x, keyboard.y, keyboard.width, keyboard.height)
when: keyboard.active && !InputContext.animating
}
+ Binding {
+ target: InputContext
+ property: "previewRectangle"
+ value: characterPreview.previewRect
+ when: characterPreview.visible
+ }
+ Binding {
+ target: InputContext
+ property: "previewRectangle"
+ value: languagePopupList.previewRect
+ when: languagePopupListActive
+ }
+ Binding {
+ target: InputContext
+ property: "previewVisible"
+ value: characterPreview.visible || languagePopupListActive
+ }
Loader {
id: styleLoader
source: VirtualKeyboardSettings.style
@@ -431,6 +495,8 @@ Item {
if (keyboard.navigationModeActive) {
if (keyboardInputArea.initialKey) {
return keyboardInputArea.initialKey
+ } else if (languagePopupListActive) {
+ return languagePopupList.highlightItem
} else if (alternativeKeys.listView.count > 0) {
return alternativeKeys.listView.highlightItem
} else if (wordCandidateView.count > 0) {
@@ -843,6 +909,80 @@ Item {
}
}
+ Item {
+ z: 1
+ anchors.fill: parent
+
+ MouseArea {
+ onPressed: keyboard.hideLanguagePopup()
+ anchors.fill: parent
+ enabled: languagePopupList.enabled
+ }
+
+ LanguagePopupList {
+ id: languagePopupList
+ z: 2
+ anchors.left: parent.left
+ anchors.top: parent.top
+ enabled: false
+ model: languageListModel
+ property rect previewRect: Qt.rect(keyboard.x + languagePopupList.x,
+ keyboard.y + languagePopupList.y,
+ languagePopupList.width,
+ languagePopupList.height)
+ }
+
+ ListModel {
+ id: languageListModel
+
+ function selectItem(index) {
+ languagePopupList.currentIndex = index
+ keyboard.soundEffect.play(languagePopupList.currentItem.soundEffect)
+ changeLanguageTimer.newLocaleIndex = languageListModel.get(index).localeIndex
+ changeLanguageTimer.start()
+ }
+ }
+
+ Timer {
+ id: changeLanguageTimer
+ interval: 1
+ property int newLocaleIndex
+ onTriggered: {
+ if (languagePopupListActive) {
+ hideLanguagePopup()
+ start()
+ } else {
+ localeIndex = newLocaleIndex
+ }
+ }
+ }
+ }
+
+ function showLanguagePopup(parentItem, customLayoutsOnly) {
+ if (!languagePopupList.enabled) {
+ var locales = keyboard.listLocales(customLayoutsOnly)
+ languageListModel.clear()
+ for (var i = 0; i < locales.length; i++) {
+ languageListModel.append({localeName: locales[i].name, displayName: locales[i].locale.nativeLanguageName, localeIndex: locales[i].index})
+ if (locales[i].index === keyboard.localeIndex)
+ languagePopupList.currentIndex = i
+ }
+ languagePopupList.positionViewAtIndex(languagePopupList.currentIndex, ListView.Center)
+ languagePopupList.anchors.leftMargin = Qt.binding(function() {return Math.round(keyboard.mapFromItem(parentItem, (parentItem.width - languagePopupList.width) / 2, 0).x)})
+ languagePopupList.anchors.topMargin = Qt.binding(function() {return Math.round(keyboard.mapFromItem(parentItem, 0, -languagePopupList.height).y)})
+ }
+ languagePopupList.enabled = true
+ }
+
+ function hideLanguagePopup() {
+ if (languagePopupList.enabled) {
+ languagePopupList.enabled = false
+ languagePopupList.anchors.leftMargin = undefined
+ languagePopupList.anchors.topMargin = undefined
+ languageListModel.clear()
+ }
+ }
+
function updateInputMethod() {
if (!keyboardLayoutLoader.item)
return
@@ -1016,6 +1156,16 @@ Item {
availableCustomLocaleIndices = newIndices
}
+ function listLocales(customLayoutsOnly) {
+ var locales = []
+ var localeIndices = customLayoutsOnly ? availableCustomLocaleIndices : availableLocaleIndices
+ for (var i = 0; i < localeIndices.length; i++) {
+ var layoutFolder = layoutsModel.get(localeIndices[i], "fileName")
+ locales.push({locale:Qt.locale(layoutFolder), index:localeIndices[i], name:layoutFolder})
+ }
+ return locales
+ }
+
function nextLocaleIndex(customLayoutsOnly) {
var newLocaleIndex = localeIndex
var localeIndices = customLayoutsOnly ? availableCustomLocaleIndices : availableLocaleIndices
diff --git a/src/virtualkeyboard/content/components/LanguagePopupList.qml b/src/virtualkeyboard/content/components/LanguagePopupList.qml
new file mode 100644
index 00000000..2c8b8c99
--- /dev/null
+++ b/src/virtualkeyboard/content/components/LanguagePopupList.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.VirtualKeyboard 2.1
+
+ListView {
+ id: languagePopupList
+ objectName: "languagePopupList"
+
+ property int maxVisibleItems: 5
+ readonly property int preferredVisibleItems: count < maxVisibleItems ? count : maxVisibleItems
+ readonly property real contentWidth: contentItem.childrenRect.width
+
+ 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.languageListDelegate
+ highlight: keyboard.style.languageListHighlight ? keyboard.style.languageListHighlight : defaultHighlight
+ highlightMoveDuration: 0
+ highlightResizeDuration: 0
+ add: keyboard.style.languageListAdd
+ remove: keyboard.style.languageListRemove
+ keyNavigationWraps: true
+
+ onCurrentItemChanged: if (currentItem) keyboard.soundEffect.register(currentItem.soundEffect)
+
+ Component {
+ id: defaultHighlight
+ Item {}
+ }
+
+ Loader {
+ sourceComponent: keyboard.style.languageListBackground
+ anchors.fill: parent
+ z: -1
+ }
+}
diff --git a/src/virtualkeyboard/content/content.qrc b/src/virtualkeyboard/content/content.qrc
index c203791f..20627466 100644
--- a/src/virtualkeyboard/content/content.qrc
+++ b/src/virtualkeyboard/content/content.qrc
@@ -27,6 +27,7 @@
<file>components/TraceInputArea.qml</file>
<file>components/HandwritingModeKey.qml</file>
<file>components/WordCandidatePopupList.qml</file>
+ <file>components/LanguagePopupList.qml</file>
<file>components/SelectionControl.qml</file>
</qresource>
</RCC>
diff --git a/src/virtualkeyboard/content/styles/default/style.qml b/src/virtualkeyboard/content/styles/default/style.qml
index fa9c6992..e02b749e 100644
--- a/src/virtualkeyboard/content/styles/default/style.qml
+++ b/src/virtualkeyboard/content/styles/default/style.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.7
import QtQuick.VirtualKeyboard 2.1
import QtQuick.VirtualKeyboard.Styles 2.1
@@ -882,6 +882,74 @@ KeyboardStyle {
NumberAnimation { property: "opacity"; to: 0; duration: 200 }
}
+ languagePopupListEnabled: true
+
+ languageListDelegate: SelectionListItem {
+ id: languageListItem
+ width: languageNameTextMetrics.width * 17
+ height: languageNameTextMetrics.height + languageListLabel.anchors.topMargin + languageListLabel.anchors.bottomMargin
+ Text {
+ id: languageListLabel
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.leftMargin: languageNameTextMetrics.height / 2
+ anchors.rightMargin: anchors.leftMargin
+ anchors.topMargin: languageNameTextMetrics.height / 3
+ anchors.bottomMargin: anchors.topMargin
+ text: languageNameFormatter.elidedText
+ color: "#5CAA15"
+ font {
+ family: fontFamily
+ weight: Font.Normal
+ pixelSize: 44 * scaleHint
+ }
+ }
+ TextMetrics {
+ id: languageNameTextMetrics
+ font {
+ family: fontFamily
+ weight: Font.Normal
+ pixelSize: 44 * scaleHint
+ }
+ text: "X"
+ }
+ TextMetrics {
+ id: languageNameFormatter
+ font {
+ family: fontFamily
+ weight: Font.Normal
+ pixelSize: 44 * scaleHint
+ }
+ elide: Text.ElideRight
+ elideWidth: languageListItem.width - languageListLabel.anchors.leftMargin - languageListLabel.anchors.rightMargin
+ text: displayName
+ }
+ states: State {
+ name: "current"
+ when: languageListItem.ListView.isCurrentItem
+ PropertyChanges {
+ target: languageListLabel
+ color: "black"
+ }
+ }
+ }
+
+ languageListBackground: Rectangle {
+ color: "white"
+ border {
+ width: 1
+ color: "#929495"
+ }
+ }
+
+ languageListAdd: Transition {
+ NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 200 }
+ }
+
+ languageListRemove: Transition {
+ NumberAnimation { property: "opacity"; to: 0; duration: 200 }
+ }
+
selectionHandle: Image {
sourceSize.width: 20
source: resourcePrefix + "images/selectionhandle-bottom.svg"
diff --git a/src/virtualkeyboard/plugin.cpp b/src/virtualkeyboard/plugin.cpp
index e73df7a6..9b3bd3b7 100644
--- a/src/virtualkeyboard/plugin.cpp
+++ b/src/virtualkeyboard/plugin.cpp
@@ -241,6 +241,7 @@ QPlatformInputContext *QVirtualKeyboardPlugin::create(const QString &system, con
qmlRegisterType(QUrl(componentsPath + QLatin1String("TraceInputArea.qml")), pluginUri, 2, 0, "TraceInputArea");
qmlRegisterType(QUrl(componentsPath + QLatin1String("TraceInputKey.qml")), pluginUri, 2, 0, "TraceInputKey");
qmlRegisterType(QUrl(componentsPath + QLatin1String("WordCandidatePopupList.qml")), pluginUri, 2, 0, "WordCandidatePopupList");
+ qmlRegisterType(QUrl(componentsPath + QLatin1String("LanguagePopupList.qml")), pluginUri, 2, 1, "LanguagePopupList");
qmlRegisterType(QUrl(componentsPath + QLatin1String("SelectionControl.qml")), pluginUri, 2, 1, "SelectionControl");
if (system.compare(system, QLatin1String(pluginName), Qt::CaseInsensitive) == 0) {
diff --git a/src/virtualkeyboard/styles/KeyboardStyle.qml b/src/virtualkeyboard/styles/KeyboardStyle.qml
index 8c4dd153..547aa8be 100644
--- a/src/virtualkeyboard/styles/KeyboardStyle.qml
+++ b/src/virtualkeyboard/styles/KeyboardStyle.qml
@@ -236,7 +236,7 @@ QtObject {
/*! Template for the alternative keys list item.
- \note The delegate is used as \c ListView.delegate.
+ \note The delegate is used in a \l ListView.
*/
property Component alternateKeysListDelegate: null
@@ -254,8 +254,8 @@ QtObject {
/*! Template for the selection list item.
- \note The delegate is used as \c ListView.delegate.
- \note The delegate must be based on the SelectionListItem type.
+ \note The delegate is used in a \l ListView.
+ \note The delegate must be based on the \l SelectionListItem type.
The following properties are available to the item:
\list
@@ -323,8 +323,8 @@ QtObject {
Template for the popup list item.
- \note The delegate is used as \c ListView.delegate.
- \note The delegate must be based on the SelectionListItem type.
+ \note The delegate is used in a \l ListView.
+ \note The delegate must be based on the \l SelectionListItem type.
The following properties are available to the item:
\list
@@ -362,6 +362,59 @@ QtObject {
*/
property Transition popupListRemove
+ /*! \since QtQuick.VirtualKeyboard.Styles 2.1
+
+ This property determines whether a popup list will be shown when the
+ language key is clicked. If this property is \c false, clicking the
+ language key cycles through the available languages one at a time.
+
+ The default value is \c false.
+ */
+ property bool languagePopupListEnabled: false
+
+ /*! \since QtQuick.VirtualKeyboard.Styles 2.1
+
+ Template for the language list item.
+
+ \note The delegate is used in a \l ListView.
+ \note The delegate must be based on the \l SelectionListItem type.
+
+ The following properties are available to the item:
+ \list
+ \li \c display Display text for the current item.
+ \li \c wordCompletionLength Word completion length measured from the end of the display text.
+ \endlist
+ */
+ property Component languageListDelegate: null
+
+ /*! \since QtQuick.VirtualKeyboard.Styles 2.1
+
+ Template for the language list highlight.
+
+ \note The delegate is used as \c ListView.highlight.
+ */
+ property Component languageListHighlight: null
+
+ /*! \since QtQuick.VirtualKeyboard.Styles 2.1
+
+ Template for the language list background.
+ */
+ property Component languageListBackground: null
+
+ /*! \since QtQuick.VirtualKeyboard.Styles 2.1
+
+ This property holds the transition to apply to items that
+ are added to the language list view.
+ */
+ property Transition languageListAdd
+
+ /*! \since QtQuick.VirtualKeyboard.Styles 2.1
+
+ This property holds the transition to apply to items that
+ are removed from the language list view.
+ */
+ property Transition languageListRemove
+
/*!
\since QtQuick.VirtualKeyboard.Styles 2.1
diff --git a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
index 4d42d941..1fb37d74 100644
--- a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
+++ b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml
@@ -258,8 +258,12 @@ InputPanel {
return Utils.findChildByProperty(keyboardLayoutLoader, "effectiveAlternativeKeys", key, function(propertyValue, key) { return propertyValue.indexOf(key) !== -1 })
}
+ function findObjectByName(objectName) {
+ return Utils.findChildByProperty(keyboard, "objectName", objectName, null)
+ }
+
function virtualKeyPressOnCurrentLayout(key) {
- var keyObj = findVirtualKey(key)
+ var keyObj = typeof key == "object" && key.hasOwnProperty("key") ? key : findVirtualKey(key)
var alternativeKey = false
if (!keyObj && typeof key == "string") {
keyObj = findVirtualKeyAlternative(key)
diff --git a/tests/auto/inputpanel/data/tst_inputpanel.qml b/tests/auto/inputpanel/data/tst_inputpanel.qml
index ed4f37ef..61363882 100644
--- a/tests/auto/inputpanel/data/tst_inputpanel.qml
+++ b/tests/auto/inputpanel/data/tst_inputpanel.qml
@@ -1461,5 +1461,90 @@ Rectangle {
compare(anchorHandlePointsTo.y, anchorRect.y + anchorRect.height)
}
}
+
+ function test_languagePopupListToggle() {
+ prepareTest()
+ if (inputPanel.availableLocales.length < 2)
+ skip("Input language can not be changed")
+ var changeLanguageKey = inputPanel.findObjectByName("changeLanguageKey")
+ var languagePopupList = inputPanel.findObjectByName("languagePopupList")
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ compare(languagePopupList.visible, true)
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ compare(languagePopupList.visible, false)
+ }
+
+ function test_languagePopupListHideOnFocusChange() {
+ prepareTest()
+ if (inputPanel.availableLocales.length < 2)
+ skip("Input language can not be changed")
+ var changeLanguageKey = inputPanel.findObjectByName("changeLanguageKey")
+ var languagePopupList = inputPanel.findObjectByName("languagePopupList")
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ compare(languagePopupList.visible, true)
+ container.forceActiveFocus()
+ textInput.forceActiveFocus()
+ compare(languagePopupList.visible, false)
+ }
+
+ function test_languagePopupListHideOnKeyboardHide() {
+ prepareTest()
+ if (inputPanel.availableLocales.length < 2)
+ skip("Input language can not be changed")
+ var changeLanguageKey = inputPanel.findObjectByName("changeLanguageKey")
+ var languagePopupList = inputPanel.findObjectByName("languagePopupList")
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ compare(languagePopupList.visible, true)
+ Qt.inputMethod.hide()
+ Qt.inputMethod.show()
+ compare(languagePopupList.visible, false)
+ }
+
+ function test_languagePopupListActiveLocales_data() {
+ return [
+ { activeLocales: ["fi_FI"], initLocale: "fi_FI", languagePopupVisible: false },
+ { activeLocales: ["en_GB", "fi_FI", "ar_AR"], selectLocale: "ar_AR", languagePopupVisible: true },
+ ]
+ }
+
+ function test_languagePopupListActiveLocales(data) {
+ prepareTest(data)
+
+ for (var i = 0; i < data.activeLocales.length; ++i) {
+ if (!inputPanel.isLocaleSupported(data.activeLocales[i])) {
+ expectFail("", "Input locale not available (%1)".arg(data.activeLocales[i]))
+ break
+ }
+ }
+
+ var changeLanguageKey = inputPanel.findObjectByName("changeLanguageKey")
+ var languagePopupList = inputPanel.findObjectByName("languagePopupList")
+ inputPanel.virtualKeyClick(changeLanguageKey)
+
+ compare(languagePopupList.visible, data.languagePopupVisible)
+ if (!data.languagePopupVisible)
+ return
+
+ compare(data.activeLocales.length, languagePopupList.model.count)
+ for (i = 0; i < languagePopupList.model.count; ++i) {
+ verify(data.activeLocales.indexOf(languagePopupList.model.get(i).localeName) !== -1)
+ }
+
+ if (data.hasOwnProperty("selectLocale")) {
+ for (i = 0; i < languagePopupList.model.count; ++i) {
+ if (languagePopupList.model.get(i).localeName === data.selectLocale) {
+ inputPanel.keyboardLayoutLoaderItemSpy.clear()
+ languagePopupList.model.selectItem(i)
+ inputPanel.keyboardLayoutLoaderItemSpy.wait()
+ break
+ }
+ }
+ compare(inputPanel.locale, data.selectLocale, "Language popup select %1".arg(data.selectLocale))
+ } else {
+ inputPanel.virtualKeyClick(changeLanguageKey)
+ }
+
+ compare(languagePopupList.visible, false)
+ }
}
}