@@ -102,6 +102,8 @@ Item {
102102 // internal props from here onwards
103103 readonly property var mainApp:
104104 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
105+ readonly property var mainAppWindow:
106+ applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindow : null
105107
106108 // Disable everything while greeter is waiting, so that the user can't swipe
107109 // the greeter or launcher until we know whether the session is locked.
@@ -737,6 +739,57 @@ Item {
737739 onMouseMoved: { cursor.opacity = 1; }
738740 }
739741
742+ // keymap switching
743+ GlobalShortcut {
744+ shortcut: Qt.MetaModifier|Qt.Key_Space
745+ onTriggered: keymapPriv.nextKeymap()
746+ active: keymapPriv.keymapCount > 1
747+ }
748+
749+ GlobalShortcut {
750+ shortcut: Qt.MetaModifier|Qt.ShiftModifier|Qt.Key_Space
751+ onTriggered: keymapPriv.previousKeymap()
752+ active: keymapPriv.keymapCount > 1
753+ }
754+
755+ QtObject {
756+ id: keymapPriv
757+
758+ readonly property var keymaps: AccountsService.keymaps
759+ readonly property int keymapCount: keymaps.length
760+ readonly property int activeKeymapIndex: mainAppWindow ? keymaps.indexOf(mainAppWindow.activeKeymap) : 0 // the one that the window currently has
761+ property int currentKeymapIndex: 0 // the new one that we're setting
762+ onCurrentKeymapIndexChanged: switchToKeymap();
763+
764+ function nextKeymap() {
765+ var nextIndex = 0;
766+
767+ if (activeKeymapIndex !== -1 && activeKeymapIndex < keymapCount - 1) {
768+ nextIndex = activeKeymapIndex + 1;
769+ }
770+ print("!!! next keymap:", currentKeymapIndex, "->", nextIndex);
771+ currentKeymapIndex = nextIndex;
772+ }
773+
774+ function previousKeymap() {
775+ var prevIndex = keymapCount - 1;
776+
777+ if (activeKeymapIndex > 0) {
778+ prevIndex = activeKeymapIndex - 1;
779+ }
780+ print("!!! prev keymap:", currentKeymapIndex, "->", prevIndex);
781+ currentKeymapIndex = prevIndex;
782+ }
783+
784+ function switchToKeymap() {
785+ if (mainAppWindow) {
786+ mainAppWindow.switchToKeymap(keymaps[currentKeymapIndex]);
787+ }
788+ }
789+ }
790+
791+ onMainAppWindowChanged: keymapPriv.switchToKeymap()
792+
740793 Rectangle {
741794 id: shutdownFadeOutRectangle
742795 z: cursor.z + 1