on xenial help sign in
properly show/hide the keyboard indicator when a HW (dis)appears and/or the keymap count changes
fbb4f8aLukáš Tinkl
qml/Components/KeymapSwitcher.qml+21−2
@@ -16,6 +16,7 @@
16
16
17import QtQuick 2.4
17import QtQuick 2.4
18import AccountsService 0.1
18import AccountsService 0.1
19+import GSettings 1.0
19import GlobalShortcut 1.0
20import GlobalShortcut 1.0
20import QMenuModel 0.1
21import QMenuModel 0.1
21import Unity.Application 0.1
22import Unity.Application 0.1
@@ -23,6 +24,9 @@ import Unity.Application 0.1
23Item {
24Item {
24 id: root
25 id: root
25
26
27+ // to be set from Shell.qml
28+ property bool hasKeyboard
29+
26 GlobalShortcut {
30 GlobalShortcut {
27 shortcut: Qt.MetaModifier|Qt.Key_Space
31 shortcut: Qt.MetaModifier|Qt.Key_Space
28 onTriggered: root.nextKeymap()
32 onTriggered: root.nextKeymap()
@@ -79,16 +83,31 @@ Item {
79 }
83 }
80
84
81 onCurrentKeymapIndexChanged: {
85 onCurrentKeymapIndexChanged: {
82− print("!!! Current keymap index changed:", currentKeymapIndex)
83 actionGroup.currentAction.updateState(currentKeymapIndex);
86 actionGroup.currentAction.updateState(currentKeymapIndex);
84 }
87 }
85
88
86 readonly property int activeActionState: actionGroup.activeAction.valid ? actionGroup.activeAction.state : -1
89 readonly property int activeActionState: actionGroup.activeAction.valid ? actionGroup.activeAction.state : -1
87
90
88 onActiveActionStateChanged: {
91 onActiveActionStateChanged: {
89− print("!!! Active keymap changed (via indicator) to:", activeActionState);
90 if (activeActionState != -1) {
92 if (activeActionState != -1) {
91 currentKeymapIndex = activeActionState;
93 currentKeymapIndex = activeActionState;
92 }
94 }
93 }
95 }
96+
97+ // indicator visibility
98+ GSettings {
99+ id: settings
100+ schema.id: "com.canonical.indicator.keyboard"
101+ }
102+
103+ function updateIndicatorVisibility() {
104+ settings.visible = keymapCount > 1 && hasKeyboard;
105+ }
106+
107+ onHasKeyboardChanged: updateIndicatorVisibility();
108+ onKeymapCountChanged: updateIndicatorVisibility();
109+
110+ Component.onCompleted: {
111+ updateIndicatorVisibility();
112+ }
94}
113}
qml/OrientedShell.qml+1
@@ -254,6 +254,7 @@ Item {
254 nativeHeight: root.height
254 nativeHeight: root.height
255 mode: applicationArguments.mode
255 mode: applicationArguments.mode
256 hasMouse: miceModel.count + touchPadModel.count > 0
256 hasMouse: miceModel.count + touchPadModel.count > 0
257+ hasKeyboard: keyboardsModel.count > 0
257 // TODO: Factor in if the current screen is a touch screen and if the user wants to
258 // TODO: Factor in if the current screen is a touch screen and if the user wants to
258 // have multiple keyboards around. For now we only enable one keyboard at a time
259 // have multiple keyboards around. For now we only enable one keyboard at a time
259 // thus hiding it here if there is a physical one around or if we have a second
260 // thus hiding it here if there is a physical one around or if we have a second
qml/Shell.qml+4−1
@@ -68,6 +68,7 @@ StyledItem {
68 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
68 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
69 }
69 }
70 property bool hasMouse: false
70 property bool hasMouse: false
71+ property bool hasKeyboard: false
71
72
72 // to be read from outside
73 // to be read from outside
73 readonly property int mainAppWindowOrientationAngle:
74 readonly property int mainAppWindowOrientationAngle:
@@ -780,7 +781,9 @@ StyledItem {
780 }
781 }
781
782
782 // non-visual object
783 // non-visual object
783− KeymapSwitcher {}
784+ KeymapSwitcher {
785+ hasKeyboard: shell.hasKeyboard
786+ }
784
787
785 Rectangle {
788 Rectangle {
786 id: shutdownFadeOutRectangle
789 id: shutdownFadeOutRectangle