on xenial help sign in
correctly switch/update keymaps
81f11b2Lukáš Tinkl
qml/Components/KeymapSwitcher.qml+11−5
@@ -37,7 +37,8 @@ Item {
37
37
38 readonly property var keymaps: AccountsService.keymaps
38 readonly property var keymaps: AccountsService.keymaps
39 readonly property int keymapCount: keymaps.length
39 readonly property int keymapCount: keymaps.length
40+ // default keymap, either the one remembered by the indicator, or the 1st one selected by user
40− property int currentKeymapIndex: 0
41+ property int currentKeymapIndex: actionGroup.currentAction.valid ? actionGroup.currentAction.state : 0
41 readonly property string currentKeymap: keymaps[currentKeymapIndex]
42 readonly property string currentKeymap: keymaps[currentKeymapIndex]
42
43
43 function nextKeymap() {
44 function nextKeymap() {
@@ -72,6 +73,10 @@ Item {
72 objectPath: "/com/canonical/indicator/keyboard"
73 objectPath: "/com/canonical/indicator/keyboard"
73
74
74 property variant currentAction: action("current")
75 property variant currentAction: action("current")
76+ property variant activeAction: action("active")
77+
78+
79+ Component.onCompleted: actionGroup.start();
75 }
80 }
76
81
77 onCurrentKeymapIndexChanged: {
82 onCurrentKeymapIndexChanged: {
@@ -79,11 +84,12 @@ Item {
79 actionGroup.currentAction.updateState(currentKeymapIndex);
84 actionGroup.currentAction.updateState(currentKeymapIndex);
80 }
85 }
81
86
87+ readonly property int activeActionState: actionGroup.activeAction.valid ? actionGroup.activeAction.state : -1
82
88
83− Component.onCompleted: {
89+ onActiveActionStateChanged: {
84− actionGroup.start();
90+ print("!!! Active keymap changed (via indicator) to:", activeActionState);
85− if (actionGroup.currentAction.valid) {
91+ if (activeActionState != -1) {
86− // TODO root.currentKeymapIndex = actionGroup.activeAction.state; // restore keymap saved by the indicator
92+ currentKeymapIndex = activeActionState;
87 }
93 }
88 }
94 }
89}
95}
qml/Panel/Indicators/MenuItemFactory.qml+1−19
@@ -995,7 +995,7 @@ Item {
995 objectName: "keymapMenu"
995 objectName: "keymapMenu"
996 property QtObject menuData: null
996 property QtObject menuData: null
997 property int menuIndex: -1
997 property int menuIndex: -1
998− property bool serverChecked: menuData && menuData.isToggled || false
998+ readonly property bool serverChecked: menuData && menuData.isToggled || false
999
999
1000 text: menuData && menuData.label || ""
1000 text: menuData && menuData.label || ""
1001 enabled: menuData && menuData.sensitive || false
1001 enabled: menuData && menuData.sensitive || false
@@ -1013,26 +1013,8 @@ Item {
1013
1013
1014 onSyncTriggered: {
1014 onSyncTriggered: {
1015 menuModel.activate(checkItem.menuIndex);
1015 menuModel.activate(checkItem.menuIndex);
1016−
1017− print("!!! Keymap", checkItem.menuIndex, "triggered")
1018− print("!!! Active action state:", actionGroup.activeAction.state)
1019− if (MirFocusController.focusedSurface) {
1020− print("!!! Switching keymap to:", AccountsService.keymaps[checkItem.menuIndex])
1021− MirFocusController.focusedSurface.keymap = AccountsService.keymaps[checkItem.menuIndex];
1022− }
1023 }
1016 }
1024 }
1017 }
1025−
1026− QDBusActionGroup {
1027− id: actionGroup
1028− busType: DBus.SessionBus
1029− busName: "com.canonical.indicator.keyboard"
1030− objectPath: "/com/canonical/indicator/keyboard"
1031−
1032− property variant activeAction: action("active")
1033−
1034− Component.onCompleted: actionGroup.start()
1035− }
1036 }
1018 }
1037 }
1019 }
1038
1020