diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2017-09-21 23:28:23 +0300 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-01-19 09:40:22 +0000 |
commit | 46f6b84e7e8d5cff6e038d47026baf657ecb1460 (patch) | |
tree | b5a0fd8a5a8f149244011026956b274f914ddac5 /src/virtualkeyboard/content/components | |
parent | d297dfd0641e6608386205d99a0518726c315867 (diff) |
Add support for external language switch
Added new signal InputPanel::externalLanguageSwitch and
a property InputPanel::externalLanguageSwitchEnabled for
enabling external language switch.
If the externalLanguageSwitchEnabled is true, the signal is
triggered instead of built-in language popup.
The new language can be selected by setting the
VirtualKeyboardSettings::locale property.
[ChangeLog] Add option to use external language dialog instead of
built-in language popup.
Change-Id: I44f88e6b3e52db4cfbee02bd3b6d7f4be38a9521
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/virtualkeyboard/content/components')
-rw-r--r-- | src/virtualkeyboard/content/components/Keyboard.qml | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/virtualkeyboard/content/components/Keyboard.qml b/src/virtualkeyboard/content/components/Keyboard.qml index 22378b44..5a2e76eb 100644 --- a/src/virtualkeyboard/content/components/Keyboard.qml +++ b/src/virtualkeyboard/content/components/Keyboard.qml @@ -1069,9 +1069,20 @@ Item { function showLanguagePopup(parentItem, customLayoutsOnly) { if (!languagePopupList.enabled) { - var locales = keyboard.listLocales(customLayoutsOnly) + var locales = keyboard.listLocales(customLayoutsOnly, parent.externalLanguageSwitchEnabled) + if (parent.externalLanguageSwitchEnabled) { + var currentIndex = 0 + for (var i = 0; i < locales.length; i++) { + if (locales[i] === keyboard.locale) { + currentIndex = i + break + } + } + parent.externalLanguageSwitch(locales, currentIndex) + return + } languageListModel.clear() - for (var i = 0; i < locales.length; i++) { + for (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 @@ -1269,12 +1280,15 @@ Item { availableCustomLocaleIndices = newIndices } - function listLocales(customLayoutsOnly) { + function listLocales(customLayoutsOnly, localeNameOnly) { 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}) + if (localeNameOnly) + locales.push(layoutFolder) + else + locales.push({locale:Qt.locale(layoutFolder), index:localeIndices[i], name:layoutFolder}) } return locales } |